removed the checks for IM002 because of DM inconsistencies

This commit is contained in:
Jenny Tam 2017-09-27 16:44:51 -07:00
parent 0cbc00384c
commit 5189a9eb65
6 changed files with 26 additions and 28 deletions

View file

@ -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, {} }
};

View file

@ -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

View file

@ -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,

View file

@ -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, {} }
};

View file

@ -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
}
}
?>

View file

@ -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";
}
}
?>