From d62d434cd0494847e541814be0b11a273772276d Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 29 Aug 2017 12:52:01 -0700 Subject: [PATCH] modified skipif and code based on review --- source/shared/core_conn.cpp | 3 +- source/shared/core_sqlsrv.h | 6 ++-- .../pdo_sqlsrv/skipif_server_old.inc | 24 ++++++++++---- test/functional/sqlsrv/skipif_server_old.inc | 33 ++++++++++++++----- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/source/shared/core_conn.cpp b/source/shared/core_conn.cpp index d8b31e11..6666df0f 100644 --- a/source/shared/core_conn.cpp +++ b/source/shared/core_conn.cpp @@ -809,14 +809,13 @@ void load_configure_ksp( _Inout_ sqlsrv_conn* conn TSRMLS_DC ) char* ksp_name = Z_STRVAL_P( conn->ce_option.ksp_name ); char* ksp_path = Z_STRVAL_P( conn->ce_option.ksp_path ); unsigned int name_len = Z_STRLEN_P( conn->ce_option.ksp_name ); - unsigned int path_len = Z_STRLEN_P( conn->ce_option.ksp_path ); unsigned int key_size = conn->ce_option.key_size; sqlsrv_malloc_auto_ptr ksp_data; ksp_data = reinterpret_cast( sqlsrv_malloc( sizeof( CEKEYSTOREDATA ) + key_size ) ); - CEKEYSTOREDATA *pKsd = (CEKEYSTOREDATA*) ksp_data.get(); + CEKEYSTOREDATA *pKsd = reinterpret_cast( ksp_data.get() ); pKsd->dataSize = key_size; diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index 361731ce..ff5e1024 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -2434,10 +2434,8 @@ struct ce_ksp_provider_set_func { static void func( _In_ connection_option const* option, _In_ zval* value, _Inout_ sqlsrv_conn* conn, _Inout_ std::string& conn_str TSRMLS_DC) { - CHECK_CUSTOM_ERROR( Z_TYPE_P( value ) != IS_STRING, conn, SQLSRV_ERROR_INVALID_OPTION_TYPE_STRING, option->odbc_name ) { - throw core::CoreException(); - } - + SQLSRV_ASSERT( Z_TYPE_P( value ) == IS_STRING, "Wrong zval type for this keyword" ) + size_t value_len = Z_STRLEN_P( value ); CHECK_CUSTOM_ERROR( value_len == 0, conn, SQLSRV_ERROR_KEYSTORE_INVALID_VALUE ) { diff --git a/test/functional/pdo_sqlsrv/skipif_server_old.inc b/test/functional/pdo_sqlsrv/skipif_server_old.inc index 0e1ff9f7..55c5e3ce 100644 --- a/test/functional/pdo_sqlsrv/skipif_server_old.inc +++ b/test/functional/pdo_sqlsrv/skipif_server_old.inc @@ -7,13 +7,25 @@ require_once( "MsSetup.inc" ); $conn = new PDO("sqlsrv:server = $server;", $uid, $pwd ); if( ! $conn ) { - die( "skip - could not connect during SKIPIF." ); + echo ( "Error: could not connect during SKIPIF!" ); } - -$attr = $conn->getAttribute(constant('PDO::ATTR_SERVER_VERSION')); -$version = substr($attr, 0, 2); -if ($version < 13) +else { - die( "skip - feature not supported in this version of SQL Server." ); + $attr = $conn->getAttribute(constant('PDO::ATTR_SERVER_VERSION')); + $version = substr($attr, 0, 2); + if ($version < 13) + { + // older than SQL Server 2016 + die( "skip - feature not supported in this version of SQL Server." ); + } + + // check ODBC driver version + $attr = $conn->getAttribute(constant('PDO::ATTR_CLIENT_VERSION')); + $version = substr($attr['DriverVer'], 0, 2); + if ($version < 13) + { + // older than ODBC 13 + die( "skip - feature not supported in this version of ODBC driver." ); + } } ?> \ No newline at end of file diff --git a/test/functional/sqlsrv/skipif_server_old.inc b/test/functional/sqlsrv/skipif_server_old.inc index 3ee03362..42614bd4 100644 --- a/test/functional/sqlsrv/skipif_server_old.inc +++ b/test/functional/sqlsrv/skipif_server_old.inc @@ -9,17 +9,32 @@ $connectionInfo = array( "UID"=>$userName, "PWD"=>$userPassword ); $conn = sqlsrv_connect( $server, $connectionInfo ); if( ! $conn ) { - die( "skip - could not connect during SKIPIF." ); + echo ( "Error: could not connect during SKIPIF!" ); } - -$server_info = sqlsrv_server_info( $conn ); -if( $server_info ) -{ - // check SQL Server version - $version = substr($server_info['SQLServerVersion'], 0, 2); - if ($version < 13) +else +{ + $server_info = sqlsrv_server_info( $conn ); + if( $server_info ) + { + // check SQL Server version + $version = substr($server_info['SQLServerVersion'], 0, 2); + if ($version < 13) + { + // older than SQL Server 2016 + die( "skip - feature not supported in this version of SQL Server." ); + } + } + + $client_info = sqlsrv_client_info( $conn ); + if( $client_info ) { - die( "skip - feature not supported in this version of SQL Server." ); + // check ODBC driver version + $version = substr($client_info['DriverVer'], 0, 2); + if ($version < 13) + { + // older than ODBC 13 + die( "skip - feature not supported in this version of ODBC driver." ); + } } } ?> \ No newline at end of file