Skip to content

AE - Retrieving a negative decimal value (edge case) as output parameter causes truncation #705

@lilgreenbird

Description

@lilgreenbird

To reproduce:

  1. Connect with ColumnEncryption = Enabled
  2. Create an integer column with encryption (doesn't matter whether it's deterministic / randomized)
  3. Insert -2147483647 into this table
  4. Create a stored procedure to return this value as an OUTPUT parameter
  5. Call this stored procedure to retrieve this as a string (PDO::PARAM_STR) with length = 2048
  6. Error message "SQLSTATE[22003]: [Microsoft][ODBC Driver 17 for SQL Server]Numeric value out of range"

With AE, the integer column size is 10, and the buffer size required for "-2147483647" is 11.

This applies to negative decimals / numerics as well, using either SQLSRV or PDO_SQLSRV.
For example, if a column is of type decimal(4, 0), and the input is -9223.3720368548, the output param value is '-922'.

With SQLSRV, this might result in the error: "[Microsoft][ODBC Driver 17 for SQL Server]String data, right truncation"

See the new tests
sqlsrv_ae_output_param_sqltype_decimal_precision.phpt
sqlsrv_ae_output_param_sqltype_numeric.phpt
pdo_ae_output_param_integers.phpt
pdo_ae_output_param_decimals.phpt
for more examples.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions