From 5189a9eb65ae29921ab63aafd772c2df91d7bfff Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 27 Sep 2017 16:44:51 -0700 Subject: [PATCH] removed the checks for IM002 because of DM inconsistencies --- source/pdo_sqlsrv/pdo_util.cpp | 4 ---- source/shared/core_conn.cpp | 13 ------------- source/shared/core_sqlsrv.h | 1 - source/sqlsrv/util.cpp | 4 ---- .../pdo_sqlsrv/pdo_connect_driver.phpt | 18 ++++++++++++++++-- .../sqlsrv/sqlsrv_connect_driver.phpt | 14 ++++++++++---- 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/source/pdo_sqlsrv/pdo_util.cpp b/source/pdo_sqlsrv/pdo_util.cpp index 63cad9d2..2c0d43e4 100644 --- a/source/pdo_sqlsrv/pdo_util.cpp +++ b/source/pdo_sqlsrv/pdo_util.cpp @@ -405,10 +405,6 @@ pdo_error PDO_ERRORS[] = { SQLSRV_ERROR_CONNECT_INVALID_DRIVER, { IMSSP, (SQLCHAR*) "Invalid value %1!s! was specified for Driver option.", -79, true } }, - { - SQLSRV_ERROR_SPECIFIED_DRIVER_NOT_FOUND, - { IMSSP, (SQLCHAR*) "The specified ODBC Driver is not found.", -80, false } - }, { UINT_MAX, {} } }; diff --git a/source/shared/core_conn.cpp b/source/shared/core_conn.cpp index ca0d2f5a..defef8f2 100644 --- a/source/shared/core_conn.cpp +++ b/source/shared/core_conn.cpp @@ -158,12 +158,6 @@ sqlsrv_conn* core_sqlsrv_connect( _In_ sqlsrv_context& henv_cp, _In_ sqlsrv_cont } r = core_odbc_connect( conn, conn_str, is_pooled ); - if( ! SQL_SUCCEEDED( r ) && core_compare_error_state( conn, r, "IM002" ) ) { - // sql state IM002 means that the specified ODBC driver is not installed - CHECK_CUSTOM_ERROR( true, conn, SQLSRV_ERROR_SPECIFIED_DRIVER_NOT_FOUND, CONNECTION_STRING_DRIVER_NAME[ conn->driver_version ].c_str() ) { - throw core::CoreException(); - } - } } else { // driver not specified, so connect using ODBC 17 @@ -196,13 +190,6 @@ sqlsrv_conn* core_sqlsrv_connect( _In_ sqlsrv_context& henv_cp, _In_ sqlsrv_cont else { if( conn->driver_version != ODBC_DRIVER_UNKNOWN ) { r = core_odbc_connect( conn, conn_str, is_pooled ); - - if( ! SQL_SUCCEEDED( r ) && core_compare_error_state( conn, r, "IM002" ) ) { - // sql state IM002 means that the specified ODBC driver is not installed - CHECK_CUSTOM_ERROR( true, conn, SQLSRV_ERROR_SPECIFIED_DRIVER_NOT_FOUND, CONNECTION_STRING_DRIVER_NAME[ conn->driver_version ].c_str() ) { - throw core::CoreException(); - } - } } else { #ifndef _WIN32 diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index 7e8c79c4..1b6dda41 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -1644,7 +1644,6 @@ enum SQLSRV_ERROR_CODES { SQLSRV_ERROR_DRIVER_NOT_INSTALLED, SQLSRV_ERROR_AE_DRIVER_REQUIRED, SQLSRV_ERROR_CONNECT_INVALID_DRIVER, - SQLSRV_ERROR_SPECIFIED_DRIVER_NOT_FOUND, SQLSRV_ERROR_ZEND_HASH, SQLSRV_ERROR_INVALID_PARAMETER_PHPTYPE, SQLSRV_ERROR_INVALID_PARAMETER_SQLTYPE, diff --git a/source/sqlsrv/util.cpp b/source/sqlsrv/util.cpp index d282c9c0..0e527d0c 100644 --- a/source/sqlsrv/util.cpp +++ b/source/sqlsrv/util.cpp @@ -404,10 +404,6 @@ ss_error SS_ERRORS[] = { SQLSRV_ERROR_CONNECT_INVALID_DRIVER, { IMSSP, (SQLCHAR*) "Invalid value %1!s! was specified for Driver option.", -106, true } }, - { - SQLSRV_ERROR_SPECIFIED_DRIVER_NOT_FOUND, - { IMSSP, (SQLCHAR*) "The specified ODBC Driver is not found.", -107, false } - }, // terminate the list of errors/warnings { UINT_MAX, {} } }; diff --git a/test/functional/pdo_sqlsrv/pdo_connect_driver.phpt b/test/functional/pdo_sqlsrv/pdo_connect_driver.phpt index 6ce18fe3..e524ed0c 100644 --- a/test/functional/pdo_sqlsrv/pdo_connect_driver.phpt +++ b/test/functional/pdo_sqlsrv/pdo_connect_driver.phpt @@ -25,6 +25,7 @@ $conn = null; test_valid_values(); test_invalid_values(); test_encrypted_with_odbc(); +test_wrong_odbc(); echo "Done"; // end test @@ -130,6 +131,11 @@ function test_encrypted_with_odbc() $expected = "The Always Encrypted feature requires Microsoft ODBC Driver 17 for SQL Server."; connect_verify_output( $connectionOptions, $expected ); +} + +function test_wrong_odbc() +{ + global $msodbcsql_maj, $server, $uid, $pwd; $value = "ODBC Driver 11 for SQL Server"; if ( $msodbcsql_maj == 17 || $msodbcsql_maj < 13 ) @@ -137,9 +143,17 @@ function test_encrypted_with_odbc() $value = "ODBC Driver 13 for SQL Server"; } $connectionOptions = "Driver = $value;"; - $expected = "The specified ODBC Driver is not found"; - connect_verify_output( $connectionOptions, $expected ); + try + { + $conn = new PDO( "sqlsrv:server = $server ; $connectionOptions", $uid, $pwd ); + + echo "Should have caused an exception!\n"; + } + catch( PDOException $e ) + { + // do nothing here because this is expected + } } ?> diff --git a/test/functional/sqlsrv/sqlsrv_connect_driver.phpt b/test/functional/sqlsrv/sqlsrv_connect_driver.phpt index 2c5db164..192b6bc0 100644 --- a/test/functional/sqlsrv/sqlsrv_connect_driver.phpt +++ b/test/functional/sqlsrv/sqlsrv_connect_driver.phpt @@ -21,6 +21,7 @@ sqlsrv_close($conn); test_valid_values( $msodbcsql_maj, $server, $connectionOptions ); test_invalid_values( $msodbcsql_maj, $server, $connectionOptions ); test_encrypted_with_odbc( $msodbcsql_maj, $server, $connectionOptions ); +test_wrong_odbc( $msodbcsql_maj, $server, $connectionOptions ); echo "Done"; // end test @@ -118,7 +119,10 @@ function test_encrypted_with_odbc( $msodbcsql_maj, $server, $connectionOptions ) $expected = "The Always Encrypted feature requires Microsoft ODBC Driver 17 for SQL Server."; connect_verify_output( $server, $connectionOptions, $expected ); - +} + +function test_wrong_odbc( $msodbcsql_maj, $server, $connectionOptions ) +{ $value = "ODBC Driver 11 for SQL Server"; if ( $msodbcsql_maj == 17 || $msodbcsql_maj < 13 ) { @@ -126,10 +130,12 @@ function test_encrypted_with_odbc( $msodbcsql_maj, $server, $connectionOptions ) } $connectionOptions['Driver']=$value; - $connectionOptions['ColumnEncryption']='Disabled'; - $expected = "The specified ODBC Driver is not found"; - connect_verify_output( $server, $connectionOptions, $expected ); + $conn = sqlsrv_connect($server, $connectionOptions); + if ($conn !== false) + { + echo "Expected errors!\n"; + } } ?>