From 72ca1cd1ebdcde38326802b6508e68c3581c5a96 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 24 Apr 2018 15:38:53 -0700 Subject: [PATCH 1/2] Fixed incorrect error when binding inout PDO STR with binary encoding --- source/pdo_sqlsrv/pdo_stmt.cpp | 4 ++-- .../pdo_sqlsrv/pdo_ae_output_param_binary_size.phpt | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/source/pdo_sqlsrv/pdo_stmt.cpp b/source/pdo_sqlsrv/pdo_stmt.cpp index c52e9442a..6bf20bb7d 100644 --- a/source/pdo_sqlsrv/pdo_stmt.cpp +++ b/source/pdo_sqlsrv/pdo_stmt.cpp @@ -1180,9 +1180,9 @@ int pdo_sqlsrv_stmt_param_hook( _Inout_ pdo_stmt_t *stmt, } // if the parameter is output or input/output, translate the type between the PDO::PARAM_* constant // and the SQLSRV_PHPTYPE_* constant - int pdo_type = param->param_type; + int pdo_type = (direction == SQL_PARAM_OUTPUT) ? param->param_type : param->param_type & ~PDO_PARAM_INPUT_OUTPUT; SQLSRV_PHPTYPE php_out_type = SQLSRV_PHPTYPE_INVALID; - switch( pdo_type & ~PDO_PARAM_INPUT_OUTPUT ) { + switch (pdo_type) { case PDO_PARAM_BOOL: case PDO_PARAM_INT: php_out_type = SQLSRV_PHPTYPE_INT; diff --git a/test/functional/pdo_sqlsrv/pdo_ae_output_param_binary_size.phpt b/test/functional/pdo_sqlsrv/pdo_ae_output_param_binary_size.phpt index 6feb6a503..fbd611111 100644 --- a/test/functional/pdo_sqlsrv/pdo_ae_output_param_binary_size.phpt +++ b/test/functional/pdo_sqlsrv/pdo_ae_output_param_binary_size.phpt @@ -88,12 +88,6 @@ function testOutputBinary($inout) $stmt = $conn->prepare($outSql); trace("\nParam $pdoParamType with INOUT = $inout\n"); - if ($inout && $pdoParamType == PDO::PARAM_STR) { - // Currently do not support getting binary as strings + INOUT param - // See VSO 2829 for details - continue; - } - if (!isAEConnected() && $pdoParamType == PDO::PARAM_INT) { // Without AE, there is no possible way to specify // binary encoding for this output param type, From 3033a26c51d8806ce94447dcfddb4afdda0e9c23 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 25 Apr 2018 07:56:58 -0700 Subject: [PATCH 2/2] Added a comment to address the issue --- source/pdo_sqlsrv/pdo_stmt.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/pdo_sqlsrv/pdo_stmt.cpp b/source/pdo_sqlsrv/pdo_stmt.cpp index 6bf20bb7d..fd65b9eac 100644 --- a/source/pdo_sqlsrv/pdo_stmt.cpp +++ b/source/pdo_sqlsrv/pdo_stmt.cpp @@ -1180,6 +1180,7 @@ int pdo_sqlsrv_stmt_param_hook( _Inout_ pdo_stmt_t *stmt, } // if the parameter is output or input/output, translate the type between the PDO::PARAM_* constant // and the SQLSRV_PHPTYPE_* constant + // vso 2829: derive the pdo_type for input/output parameter as well int pdo_type = (direction == SQL_PARAM_OUTPUT) ? param->param_type : param->param_type & ~PDO_PARAM_INPUT_OUTPUT; SQLSRV_PHPTYPE php_out_type = SQLSRV_PHPTYPE_INVALID; switch (pdo_type) {