From fc7173df11a35f1e2a23930a82df576571f2a333 Mon Sep 17 00:00:00 2001 From: Hadis-Fard Date: Fri, 8 Sep 2017 10:28:01 -0700 Subject: [PATCH] fixed default driver version, sal annotation, and error messages --- source/pdo_sqlsrv/pdo_util.cpp | 5 ++--- source/shared/core_conn.cpp | 4 ++-- source/shared/core_sqlsrv.h | 7 ++++--- source/sqlsrv/util.cpp | 5 +---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/source/pdo_sqlsrv/pdo_util.cpp b/source/pdo_sqlsrv/pdo_util.cpp index 5044ba84..fa184627 100644 --- a/source/pdo_sqlsrv/pdo_util.cpp +++ b/source/pdo_sqlsrv/pdo_util.cpp @@ -397,10 +397,9 @@ pdo_error PDO_ERRORS[] = { SQLSRV_ERROR_KEYSTORE_INVALID_VALUE, { IMSSP, (SQLCHAR*) "Invalid value for loading a custom keystore provider.", -77, false} }, - { + { SQLSRV_AE_ERROR_DRIVER_NOT_INSTALLED, - { IMSSP, (SQLCHAR*) "This extension requires Microsoft ODBC Driver 17 or higher to " - "communicate with SQL Server with ColumnEncryption attribute enabled.", -74, false } + { IMSSP, (SQLCHAR*) "This extension requires Microsoft ODBC Driver 17 for SQL Server when ColumnEncryption attribute is enabled.", -78, false } }, { UINT_MAX, {} } }; diff --git a/source/shared/core_conn.cpp b/source/shared/core_conn.cpp index 700f1bb1..86a95aad 100644 --- a/source/shared/core_conn.cpp +++ b/source/shared/core_conn.cpp @@ -148,7 +148,7 @@ sqlsrv_conn* core_sqlsrv_connect( _In_ sqlsrv_context& henv_cp, _In_ sqlsrv_cont build_connection_string_and_set_conn_attr(conn, server, uid, pwd, options_ht, valid_conn_opts, driver, conn_options TSRMLS_CC); bool missing_driver_error = false; if (conn->ce_option.enabled) { - r = core_odbc_connect(conn, conn_options, DRIVER_VERSION::ODBC_DRIVER_17, wconn_string, wconn_len, missing_driver_error); + r = core_odbc_connect( conn, conn_options, DRIVER_VERSION::ODBC_DRIVER_17, wconn_string, wconn_len, missing_driver_error ); CHECK_CUSTOM_ERROR(missing_driver_error, conn, SQLSRV_AE_ERROR_DRIVER_NOT_INSTALLED, get_processor_arch()) { throw core::CoreException(); @@ -227,7 +227,7 @@ sqlsrv_conn* core_sqlsrv_connect( _In_ sqlsrv_context& henv_cp, _In_ sqlsrv_cont return return_conn; } -SQLRETURN core_odbc_connect(_Inout_ sqlsrv_conn* conn, const std::string& conn_options, const DRIVER_VERSION odbc_version, SQLWCHAR* wconn_string, unsigned int& wconn_len, bool& missing_driver_error) +SQLRETURN core_odbc_connect(_Inout_ sqlsrv_conn* conn, _In_ const std::string& conn_options, _In_ const DRIVER_VERSION odbc_version, _Inout_ SQLWCHAR* wconn_string, _Inout_ unsigned int& wconn_len, _Inout_ bool& missing_driver_error) { SQLRETURN r = SQL_SUCCESS; std::string conn_str = conn_options + CONNECTION_STRING_DRIVER_NAME[odbc_version]; diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index 6116a078..15a653d3 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -1033,7 +1033,8 @@ enum SERVER_VERSION { }; // supported driver versions. -enum DRIVER_VERSION : size_t { +enum DRIVER_VERSION { + ODBC_DRIVER_UNKNOWN = -1, FIRST = 0, ODBC_DRIVER_17 = FIRST, ODBC_DRIVER_13 = 1, @@ -1075,7 +1076,7 @@ struct sqlsrv_conn : public sqlsrv_context { sqlsrv_context( h, SQL_HANDLE_DBC, e, drv, encoding ) { server_version = SERVER_VERSION_UNKNOWN; - driver_version = ODBC_DRIVER_13; + driver_version = ODBC_DRIVER_UNKNOWN; } // sqlsrv_conn has no destructor since its allocated using placement new, which requires that the destructor be @@ -1216,7 +1217,7 @@ sqlsrv_conn* core_sqlsrv_connect( _In_ sqlsrv_context& henv_cp, _In_ sqlsrv_cont _Inout_z_ const char* server, _Inout_opt_z_ const char* uid, _Inout_opt_z_ const char* pwd, _Inout_opt_ HashTable* options_ht, _In_ error_callback err, _In_ const connection_option valid_conn_opts[], _In_ void* driver, _In_z_ const char* driver_func TSRMLS_DC ); -SQLRETURN core_odbc_connect(_Inout_ sqlsrv_conn* conn, const std::string& conn_options, const DRIVER_VERSION odbc_version, SQLWCHAR* wconn_string, unsigned int& wconn_len, bool& missing_driver_error); +SQLRETURN core_odbc_connect( _Inout_ sqlsrv_conn* conn, _In_ const std::string& conn_options, _In_ const DRIVER_VERSION odbc_version, _Inout_ SQLWCHAR* wconn_string, _Inout_ unsigned int& wconn_len, _Inout_ bool& missing_driver_error); void core_sqlsrv_close( _Inout_opt_ sqlsrv_conn* conn TSRMLS_DC ); void core_sqlsrv_prepare( _Inout_ sqlsrv_stmt* stmt, _In_reads_bytes_(sql_len) const char* sql, _In_ SQLLEN sql_len TSRMLS_DC ); void core_sqlsrv_begin_transaction( _Inout_ sqlsrv_conn* conn TSRMLS_DC ); diff --git a/source/sqlsrv/util.cpp b/source/sqlsrv/util.cpp index 018e50a0..5c9e60f7 100644 --- a/source/sqlsrv/util.cpp +++ b/source/sqlsrv/util.cpp @@ -394,11 +394,8 @@ ss_error SS_ERRORS[] = { }, { SQLSRV_AE_ERROR_DRIVER_NOT_INSTALLED, - { IMSSP, (SQLCHAR*) "This extension requires Microsoft ODBC Driver 17 or higher to " - "communicate with SQL Server with ColumnEncryption attribute enabled.", -105, false } + { IMSSP, (SQLCHAR*) "This extension requires Microsoft ODBC Driver 17 for SQL Server when ColumnEncryption attribute is enabled.", -105, false } }, - - // terminate the list of errors/warnings { UINT_MAX, {} } };