From f66b2c3e8a97c76a3f1996a5213bd4f5db61e4e3 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Fri, 27 Aug 2021 09:29:16 -0700 Subject: [PATCH] Updated list of supported processor architecture (#1290) --- source/pdo_sqlsrv/pdo_util.cpp | 2 +- source/shared/core_conn.cpp | 55 +++++++------------ source/sqlsrv/util.cpp | 2 +- .../pdo_sqlsrv/pdo_connect_driver.phpt | 2 +- .../sqlsrv/sqlsrv_connect_driver.phpt | 2 +- 5 files changed, 23 insertions(+), 40 deletions(-) diff --git a/source/pdo_sqlsrv/pdo_util.cpp b/source/pdo_sqlsrv/pdo_util.cpp index 95147ea8..3ad7a43f 100644 --- a/source/pdo_sqlsrv/pdo_util.cpp +++ b/source/pdo_sqlsrv/pdo_util.cpp @@ -383,7 +383,7 @@ pdo_error PDO_ERRORS[] = { }, { SQLSRV_ERROR_CE_DRIVER_REQUIRED, - { IMSSP, (SQLCHAR*) "The Always Encrypted feature requires Microsoft ODBC Driver 17 for SQL Server.", -78, false } + { IMSSP, (SQLCHAR*) "The Always Encrypted feature requires Microsoft ODBC Driver 17 for SQL Server (or above) for %1!s!.", -78, true } }, { SQLSRV_ERROR_CONNECT_INVALID_DRIVER, diff --git a/source/shared/core_conn.cpp b/source/shared/core_conn.cpp index cc5d9f2f..e2f00d98 100644 --- a/source/shared/core_conn.cpp +++ b/source/shared/core_conn.cpp @@ -48,9 +48,6 @@ const int INFO_BUFFER_LEN = 256; // length for name of keystore used in CEKeyStoreData const int MAX_CE_NAME_LEN = 260; -// processor architectures -const char* PROCESSOR_ARCH[] = { "x86", "x64", "ia64" }; - // ODBC driver names. // the order of this list should match the order of DRIVER_VERSION enum std::vector CONNECTION_STRING_DRIVER_NAME{ "Driver={ODBC Driver 17 for SQL Server};", "Driver={ODBC Driver 13 for SQL Server};", "Driver={ODBC Driver 11 for SQL Server};" }; @@ -917,42 +914,28 @@ void build_connection_string_and_set_conn_attr( _Inout_ sqlsrv_conn* conn, _Inou // and return the string of the processor name. const char* get_processor_arch( void ) { -#ifndef _WIN32 - struct utsname sys_info; - if ( uname(&sys_info) == -1 ) - { - DIE( "Error retrieving system info" ); - } - if( strcmp(sys_info.machine, "x86") == 0 ) { - return PROCESSOR_ARCH[0]; - } else if ( strcmp(sys_info.machine, "x86_64") == 0) { - return PROCESSOR_ARCH[1]; - } else if ( strcmp(sys_info.machine, "ia64") == 0 ) { - return PROCESSOR_ARCH[2]; - } else { - DIE( "Unknown processor architecture." ); - } - return NULL; -#else + // processor architectures + const char* PROCESSOR_ARCH[] = {"x86", "x64", "arm64"}; +#ifdef _WIN32 SYSTEM_INFO sys_info; - GetSystemInfo( &sys_info); - switch( sys_info.wProcessorArchitecture ) { - - case PROCESSOR_ARCHITECTURE_INTEL: - return PROCESSOR_ARCH[0]; - - case PROCESSOR_ARCHITECTURE_AMD64: - return PROCESSOR_ARCH[1]; - - case PROCESSOR_ARCHITECTURE_IA64: - return PROCESSOR_ARCH[2]; - - default: - DIE( "Unknown Windows processor architecture." ); - return NULL; + GetSystemInfo(&sys_info); + switch (sys_info.wProcessorArchitecture) { + case PROCESSOR_ARCHITECTURE_INTEL: + return PROCESSOR_ARCH[0]; + case PROCESSOR_ARCHITECTURE_AMD64: + return PROCESSOR_ARCH[1]; + default: + DIE("Unsupported Windows processor architecture."); + return NULL; } +#elif defined(__arm64__) + return PROCESSOR_ARCH[2]; +#elif defined(__x86_64__) + return PROCESSOR_ARCH[1]; +#else + DIE("Unsupported processor architecture."); return NULL; -#endif // !_WIN32 +#endif // _WIN32 } // some features require a server of a certain version or later diff --git a/source/sqlsrv/util.cpp b/source/sqlsrv/util.cpp index fd086444..b821faa2 100644 --- a/source/sqlsrv/util.cpp +++ b/source/sqlsrv/util.cpp @@ -379,7 +379,7 @@ ss_error SS_ERRORS[] = { }, { SQLSRV_ERROR_CE_DRIVER_REQUIRED, - { IMSSP, (SQLCHAR*) "The Always Encrypted feature requires Microsoft ODBC Driver 17 for SQL Server.", -105, false } + { IMSSP, (SQLCHAR*) "The Always Encrypted feature requires Microsoft ODBC Driver 17 for SQL Server (or above) for %1!s!.", -105, true } }, { SQLSRV_ERROR_CONNECT_INVALID_DRIVER, diff --git a/test/functional/pdo_sqlsrv/pdo_connect_driver.phpt b/test/functional/pdo_sqlsrv/pdo_connect_driver.phpt index 41431fa5..a1a18144 100644 --- a/test/functional/pdo_sqlsrv/pdo_connect_driver.phpt +++ b/test/functional/pdo_sqlsrv/pdo_connect_driver.phpt @@ -109,7 +109,7 @@ function testEncryptedWithODBC() $value = "ODBC Driver 13 for SQL Server"; $connectionOptions = "Driver = $value; ColumnEncryption = Enabled;"; - $expected = "The Always Encrypted feature requires Microsoft ODBC Driver 17 for SQL Server."; + $expected = "The Always Encrypted feature requires Microsoft ODBC Driver 17 for SQL Server"; connectVerifyOutput($connectionOptions, $expected); } diff --git a/test/functional/sqlsrv/sqlsrv_connect_driver.phpt b/test/functional/sqlsrv/sqlsrv_connect_driver.phpt index cc90419f..ee78f0a4 100644 --- a/test/functional/sqlsrv/sqlsrv_connect_driver.phpt +++ b/test/functional/sqlsrv/sqlsrv_connect_driver.phpt @@ -106,7 +106,7 @@ function testEncryptedWithODBC($msodbcsqlMaj, $server, $connectionOptions) $connectionOptions['Driver']=$value; $connectionOptions['ColumnEncryption']='Enabled'; - $expected = "The Always Encrypted feature requires Microsoft ODBC Driver 17 for SQL Server."; + $expected = "The Always Encrypted feature requires Microsoft ODBC Driver 17 for SQL Server"; connectVerifyOutput($server, $connectionOptions, $expected); }