From d7a1aca5c782bfad97c36e595705dd22e5dd4ba5 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 19 Dec 2017 14:35:28 -0800 Subject: [PATCH 01/36] Testing locale issues --- test/functional/sqlsrv/MsCommon.inc | 21 ++++++++------------- test/functional/sqlsrv/MsHelper.inc | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index 964e5efe..7d5123c4 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -84,18 +84,6 @@ function isDaasMode() return ($daasMode ? true : false); } -// function isAEQualified($conn) -// { - // $msodbcsql_ver = sqlsrv_client_info($conn)['DriverVer']; - // $server_ver = sqlsrv_server_info($conn)['SQLServerVersion']; - // $msodbcsql_maj = explode(".", $msodbcsql_ver)[0]; - // $msodbcsql_min = explode(".", $msodbcsql_ver)[1]; - // if ($msodbcsql_maj < 17 || explode('.', $server_ver)[0] < 13) { - // return false; - // } - // return true; -// } - function startTest($testName) { if (traceMode()) { @@ -455,10 +443,17 @@ function handleErrors() } // non-UTF8 locale support in ODBC 17 and above only +// if AE enabled, only supported in Windows (AE limitations) function isLocaleSupported() { + if (isWindows()) { + return true; + } + if (AE\isDataEncrypted()) { + return false; + } + // now check ODBC version $conn = AE\connect(); - $msodbcsql_ver = sqlsrv_client_info($conn)['DriverVer']; if (explode(".", $msodbcsql_ver)[0] < 17) { return false; diff --git a/test/functional/sqlsrv/MsHelper.inc b/test/functional/sqlsrv/MsHelper.inc index 988253b1..6792bfe2 100644 --- a/test/functional/sqlsrv/MsHelper.inc +++ b/test/functional/sqlsrv/MsHelper.inc @@ -330,7 +330,7 @@ function getSeqPlaceholders($num) */ function isColEncrypted() { - global $keystore, $dataEncrypted; + global $keystore; if ($keystore === KEYSTORE_NONE) { return false; } else { From f3d04343aa7ac116cbf85e6f44660e2579797d2e Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 20 Dec 2017 08:28:34 -0800 Subject: [PATCH 02/36] Modified local supported method --- test/functional/sqlsrv/MsCommon.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index 7d5123c4..e01802e1 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -449,7 +449,7 @@ function isLocaleSupported() if (isWindows()) { return true; } - if (AE\isDataEncrypted()) { + if (AE\isColEncrypted()) { return false; } // now check ODBC version From 720346f45927493536925f1a3a0e99602f90e07d Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 20 Dec 2017 09:31:44 -0800 Subject: [PATCH 03/36] Modified three tests to test with or without UTF-8 data --- test/functional/sqlsrv/TC42_FetchField.phpt | 40 +++++++++++++++---- test/functional/sqlsrv/TC45_FetchObject.phpt | 34 ++++++++++++---- .../sqlsrv/TC48_FetchScrollable.phpt | 39 ++++++++++++++---- 3 files changed, 90 insertions(+), 23 deletions(-) diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index b1395b5a..baddc6b9 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -6,20 +6,22 @@ retrieving fields from a table including rows with all supported SQL types (28 t --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8')); } else { $conn1 = AE\connect(); @@ -63,16 +65,38 @@ function fetchFields() dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } +// locale must be set before 1st connection +if (!isWindows()) { + setlocale(LC_ALL, "en_US.ISO-8859-1"); +} + +$testName = "Fetch - Field"; + +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + fetchFields(); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); fetchFields(); } catch (Exception $e) { echo $e->getMessage(); } +endTest($testName); ?> --EXPECT-- Test "Fetch - Field" completed successfully. +Test "Fetch - Field" completed successfully. diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index ec20c417..26767834 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -5,7 +5,13 @@ Verifies data retrieval via "sqlsrv_fetch_object". --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8' )); } else { $conn1 = AE\connect(); @@ -73,8 +75,6 @@ function fetchRow($minFetchMode, $maxFetchMode) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } @@ -127,12 +127,30 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } } +$testName = "Fetch - Object"; +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + fetchRow(0, 2); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); fetchRow(0, 2); } catch (Exception $e) { echo $e->getMessage(); } +endTest($testName); ?> --EXPECT-- Test "Fetch - Object" completed successfully. +Test "Fetch - Object" completed successfully. diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index 44090245..09012e67 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -5,19 +5,22 @@ Verifies data retrieval with scrollable result sets. --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8')); } else { $conn1 = AE\connect(); @@ -72,8 +75,6 @@ function fetchRow($noRows) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } function fetchArray($stmt, $rows, $fields) @@ -135,12 +136,36 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } } +// locale must be set before 1st connection +if (!isWindows()) { + setlocale(LC_ALL, "en_US.ISO-8859-1"); +} + +$testName = "Fetch - Scrollable"; + +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + fetchRow(10); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); fetchRow(10); } catch (Exception $e) { echo $e->getMessage(); } +endTest($testName); ?> --EXPECT-- Test "Fetch - Scrollable" completed successfully. +Test "Fetch - Scrollable" completed successfully. From 6b209526cd80453defa6c7363ae8929268600727 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 20 Dec 2017 10:18:46 -0800 Subject: [PATCH 04/36] Added skipif and modified the check of isLocaleSupported() --- test/functional/sqlsrv/MsCommon.inc | 2 + test/functional/sqlsrv/TC34_PrepAndExec.phpt | 43 +++++++++++++++---- test/functional/sqlsrv/TC42_FetchField.phpt | 4 +- test/functional/sqlsrv/TC43_FetchData.phpt | 5 ++- test/functional/sqlsrv/TC44_FetchArray.phpt | 5 ++- test/functional/sqlsrv/TC45_FetchObject.phpt | 14 ++++-- .../sqlsrv/TC46_FetchNextResult.phpt | 5 ++- test/functional/sqlsrv/TC51_StreamRead.phpt | 5 ++- .../sqlsrv/TC55_StreamScrollable.phpt | 5 ++- .../sqlsrv/test_stream_large_data.phpt | 6 +-- 10 files changed, 66 insertions(+), 28 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index e01802e1..14fe90ee 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -98,6 +98,8 @@ function startTest($testName) */ function endTest($testName) { + // reset the utf-8 flag + setUTF8Data(false); echo "Test \"$testName\" completed successfully.\n"; } diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index d8e5d210..d77fef2c 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -6,18 +6,25 @@ Validates that a prepared statement can be successfully executed more than once. --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8')); + } else { + $conn1 = AE\connect(); + } $tableName = 'TC34test'; AE\createTestTable($conn1, $tableName); @@ -80,20 +87,38 @@ function prepareAndExecute($noPasses) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } +// locale must be set before 1st connection if (!isWindows()) { - setUTF8Data(true); + setlocale(LC_ALL, "en_US.ISO-8859-1"); } + +$testName = "Statement - Prepare and Execute"; + +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + prepareAndExecute(5); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); prepareAndExecute(5); } catch (Exception $e) { echo $e->getMessage(); } -setUTF8Data(false); +endTest($testName); ?> --EXPECT-- Test "Statement - Prepare and Execute" completed successfully. +Test "Statement - Prepare and Execute" completed successfully. diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index baddc6b9..dc715b19 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -8,10 +8,10 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- 'UTF-8' )); + $conn1 = AE\connect(array('CharacterSet'=>'UTF-8')); } else { $conn1 = AE\connect(); } @@ -89,7 +89,7 @@ function fetchObject($stmt, $rows, $fields, $useClass) $obj = sqlsrv_fetch_object($stmt); } if ($obj === false) { - fatalError("Row $i is missing"); + fatalError("In fetchObject: Row $i is missing"); } $values[$i] = $obj; } @@ -103,7 +103,7 @@ function fetchArray($stmt, $rows, $fields) for ($i = 0; $i < $rows; $i++) { $row = sqlsrv_fetch_array($stmt); if ($row === false) { - fatalError("Row $i is missing"); + fatalError("In fetchArray: Row $i is missing"); } $values[$i] = $row; } @@ -127,7 +127,13 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } } +// locale must be set before 1st connection +if (!isWindows()) { + setlocale(LC_ALL, "en_US.ISO-8859-1"); +} + $testName = "Fetch - Object"; + // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) startTest($testName); if (isLocaleSupported()) { diff --git a/test/functional/sqlsrv/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index 6848d2e6..bcd5e9e8 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -7,9 +7,10 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- Date: Wed, 20 Dec 2017 21:06:07 -0800 Subject: [PATCH 05/36] Changed helper methods as per review --- test/functional/sqlsrv/MsCommon.inc | 2 -- test/functional/sqlsrv/MsHelper.inc | 12 ++---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index 14fe90ee..e01802e1 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -98,8 +98,6 @@ function startTest($testName) */ function endTest($testName) { - // reset the utf-8 flag - setUTF8Data(false); echo "Test \"$testName\" completed successfully.\n"; } diff --git a/test/functional/sqlsrv/MsHelper.inc b/test/functional/sqlsrv/MsHelper.inc index 6792bfe2..f7cecd4d 100644 --- a/test/functional/sqlsrv/MsHelper.inc +++ b/test/functional/sqlsrv/MsHelper.inc @@ -331,11 +331,7 @@ function getSeqPlaceholders($num) function isColEncrypted() { global $keystore; - if ($keystore === KEYSTORE_NONE) { - return false; - } else { - return true; - } + return ($keystore !== KEYSTORE_NONE); } /** @@ -345,11 +341,7 @@ function isColEncrypted() function isDataEncrypted() { global $keystore, $dataEncrypted; - if ($keystore === KEYSTORE_NONE || !$dataEncrypted) { - return false; - } else { - return true; - } + return ($keystore !== KEYSTORE_NONE && $dataEncrypted); } /** From 44e447a86a81811fc213ce6d7573afa54a48ad58 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 21 Dec 2017 11:02:11 -0800 Subject: [PATCH 06/36] Update version.h Renamed RC RC1 for PECL --- source/shared/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/shared/version.h b/source/shared/version.h index c8c7b127..cb13a805 100644 --- a/source/shared/version.h +++ b/source/shared/version.h @@ -35,7 +35,7 @@ // for stable releases should be empty // "-RC" for release candidates // "-preview" for ETP -#define SEMVER_PRERELEASE "RC" +#define SEMVER_PRERELEASE "RC1" // Semantic versioning build metadata, build meta data is not counted in precedence order. #define SEMVER_BUILDMETA From 244e3401b5d0e02fa62b751bf86cc0ea7a5c0325 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 21 Dec 2017 12:52:36 -0800 Subject: [PATCH 07/36] Added Control Flow Guard to configs --- source/pdo_sqlsrv/config.w32 | 3 ++- source/sqlsrv/config.w32 | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/pdo_sqlsrv/config.w32 b/source/pdo_sqlsrv/config.w32 index b8c72c02..29288b41 100644 --- a/source/pdo_sqlsrv/config.w32 +++ b/source/pdo_sqlsrv/config.w32 @@ -30,11 +30,12 @@ if( PHP_PDO_SQLSRV != "no" ) { CHECK_HEADER_ADD_INCLUDE("sql.h", "CFLAGS_PDO_SQLSRV_ODBC"); CHECK_HEADER_ADD_INCLUDE("sqlext.h", "CFLAGS_PDO_SQLSRV_ODBC"); ADD_SOURCES( configure_module_dirname + "\\shared", shared_src_class, "pdo_sqlsrv" ); - ADD_FLAG( "LDFLAGS_PDO_SQLSRV", "/NXCOMPAT /DYNAMICBASE /debug" ); + ADD_FLAG( "LDFLAGS_PDO_SQLSRV", "/NXCOMPAT /DYNAMICBASE /debug /guard:cf" ); ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/EHsc" ); ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/GS" ); ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/Zi" ); ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/O2" ); + ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/guard:cf" ); ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/D ZEND_WIN32_FORCE_INLINE" ); ADD_EXTENSION_DEP('pdo_sqlsrv', 'pdo'); EXTENSION("pdo_sqlsrv", pdo_sqlsrv_src_class, PHP_PDO_SQLSRV_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); diff --git a/source/sqlsrv/config.w32 b/source/sqlsrv/config.w32 index 727b17e7..6e3df93a 100644 --- a/source/sqlsrv/config.w32 +++ b/source/sqlsrv/config.w32 @@ -30,12 +30,13 @@ if( PHP_SQLSRV != "no" ) { ADD_SOURCES( configure_module_dirname + "\\shared", shared_src_class, "sqlsrv" ); CHECK_HEADER_ADD_INCLUDE("sql.h", "CFLAGS_SQLSRV_ODBC"); CHECK_HEADER_ADD_INCLUDE("sqlext.h", "CFLAGS_SQLSRV_ODBC"); - ADD_FLAG( "LDFLAGS_SQLSRV", "/NXCOMPAT /DYNAMICBASE /debug" ); + ADD_FLAG( "LDFLAGS_SQLSRV", "/NXCOMPAT /DYNAMICBASE /debug /guard:cf" ); ADD_FLAG( "CFLAGS_SQLSRV", "/D ZEND_WIN32_FORCE_INLINE" ); ADD_FLAG( "CFLAGS_SQLSRV", "/EHsc" ); ADD_FLAG( "CFLAGS_SQLSRV", "/GS" ); ADD_FLAG( "CFLAGS_SQLSRV", "/Zi" ); ADD_FLAG( "CFLAGS_SQLSRV", "/O2" ); + ADD_FLAG( "CFLAGS_SQLSRV", "/guard:cf" ); EXTENSION("sqlsrv", sqlsrv_src_class , PHP_SQLSRV_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); } else { WARNING("sqlsrv not enabled; libraries and headers not found"); From 384d1bcd5fc397abcf00bba757d4064bfdfa72a3 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 28 Dec 2017 10:30:17 -0800 Subject: [PATCH 08/36] Adjusted regex for odbc name with dylib --- test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt | 2 +- test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt index 54aa2e80..0e7798eb 100644 --- a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt +++ b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt @@ -32,7 +32,7 @@ PDO::ATTR_ERRMODE: int\(0\) PDO::ATTR_ERRMODE: int\(2\) Array \( - \[DriverDllName\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9] + \[DriverDllName\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? \[DriverODBCVer\] => [0-9]{1,2}\.[0-9]{1,2} \[DriverVer\] => [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} \[ExtensionVer\] => [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? diff --git a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt index d9586d8d..aadd707a 100644 --- a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt +++ b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt @@ -29,7 +29,7 @@ else sqlsrv_close( $conn); ?> --EXPECTREGEX-- -DriverDllName: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9] +DriverDllName: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? DriverODBCVer: [0-9]{1,2}\.[0-9]{1,2} DriverVer: [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} ExtensionVer: [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? \ No newline at end of file From 2759a1f314d367e84bb84476adfd3f72ec879cb6 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 28 Dec 2017 11:45:03 -0800 Subject: [PATCH 09/36] Added alternative for driver name --- test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt | 2 +- test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt index 0e7798eb..c2d05004 100644 --- a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt +++ b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt @@ -32,7 +32,7 @@ PDO::ATTR_ERRMODE: int\(0\) PDO::ATTR_ERRMODE: int\(2\) Array \( - \[DriverDllName\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? + \[DriverDllName\]|\[DriverName\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? \[DriverODBCVer\] => [0-9]{1,2}\.[0-9]{1,2} \[DriverVer\] => [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} \[ExtensionVer\] => [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? diff --git a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt index aadd707a..ed70a5ec 100644 --- a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt +++ b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt @@ -29,7 +29,7 @@ else sqlsrv_close( $conn); ?> --EXPECTREGEX-- -DriverDllName: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? +DriverDllName|DriverName: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? DriverODBCVer: [0-9]{1,2}\.[0-9]{1,2} DriverVer: [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} ExtensionVer: [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? \ No newline at end of file From 24153e50f2d70cb6ffa87e19417918475abbf756 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 28 Dec 2017 12:03:24 -0800 Subject: [PATCH 10/36] Yet another alternative for driver name --- test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt | 2 +- test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt index c2d05004..eb9a44c1 100644 --- a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt +++ b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt @@ -32,7 +32,7 @@ PDO::ATTR_ERRMODE: int\(0\) PDO::ATTR_ERRMODE: int\(2\) Array \( - \[DriverDllName\]|\[DriverName\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? + \[DriverDllName\]|\[DriverName\] => (msodbcsql[0-9]{2}\.dll|(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)) \[DriverODBCVer\] => [0-9]{1,2}\.[0-9]{1,2} \[DriverVer\] => [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} \[ExtensionVer\] => [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? diff --git a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt index ed70a5ec..e979b422 100644 --- a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt +++ b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt @@ -29,7 +29,7 @@ else sqlsrv_close( $conn); ?> --EXPECTREGEX-- -DriverDllName|DriverName: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? +DriverDllName|DriverName: (msodbcsql[0-9]{2}\.dll|(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)) DriverODBCVer: [0-9]{1,2}\.[0-9]{1,2} DriverVer: [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} ExtensionVer: [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? \ No newline at end of file From 62944347efe3ecd07d1135d9cd2c86a1f72d0171 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Fri, 29 Dec 2017 12:00:00 -0800 Subject: [PATCH 11/36] Fix tests with locales --- test/functional/sqlsrv/MsCommon.inc | 10 ++++++++++ test/functional/sqlsrv/TC34_PrepAndExec.phpt | 9 ++------- test/functional/sqlsrv/TC42_FetchField.phpt | 9 ++------- test/functional/sqlsrv/TC43_FetchData.phpt | 9 ++------- test/functional/sqlsrv/TC44_FetchArray.phpt | 10 ++-------- test/functional/sqlsrv/TC45_FetchObject.phpt | 9 ++------- test/functional/sqlsrv/TC46_FetchNextResult.phpt | 10 ++-------- test/functional/sqlsrv/TC48_FetchScrollable.phpt | 9 ++------- test/functional/sqlsrv/TC51_StreamRead.phpt | 9 ++------- test/functional/sqlsrv/TC55_StreamScrollable.phpt | 10 ++-------- test/functional/sqlsrv/test_stream_large_data.phpt | 9 ++------- 11 files changed, 30 insertions(+), 73 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index e01802e1..db7b3e10 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -442,6 +442,16 @@ function handleErrors() } } +function setUSLocale() +{ + if (!isWindows()) { + // macOS the locale names are different in Linux or macOS + $locale = strtoupper(PHP_OS) === 'LINUX' ? "en_US.ISO-8859-1" : "en_US.ISO8859-1"; + + setlocale(LC_ALL, $locale); + } +} + // non-UTF8 locale support in ODBC 17 and above only // if AE enabled, only supported in Windows (AE limitations) function isLocaleSupported() diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index d77fef2c..06d2f14a 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -8,9 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -90,10 +88,7 @@ function prepareAndExecute($noPasses) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); $testName = "Statement - Prepare and Execute"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index dc715b19..ef030b16 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -8,9 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -68,10 +66,7 @@ function fetchFields() } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); $testName = "Fetch - Field"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC43_FetchData.phpt b/test/functional/sqlsrv/TC43_FetchData.phpt index 5e03407c..6e8e60f3 100644 --- a/test/functional/sqlsrv/TC43_FetchData.phpt +++ b/test/functional/sqlsrv/TC43_FetchData.phpt @@ -5,9 +5,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -97,10 +95,7 @@ function checkData($col, $actual, $expected) return ($success); } -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); $testName = "Fetch - Field Data"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC44_FetchArray.phpt b/test/functional/sqlsrv/TC44_FetchArray.phpt index 556bd562..ab7e88c8 100644 --- a/test/functional/sqlsrv/TC44_FetchArray.phpt +++ b/test/functional/sqlsrv/TC44_FetchArray.phpt @@ -8,9 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -153,11 +151,7 @@ function checkData($row, $stmt, $index, $mode) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - -global $testName; +setUSLocale(); $testName = "Fetch - Array"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index 1c4e8f30..588620c5 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -7,9 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -128,10 +126,7 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); $testName = "Fetch - Object"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index bcd5e9e8..58d8fdfa 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -7,9 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -86,11 +84,7 @@ function fetchFields() } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - -global $testName; +setUSLocale(); $testName = "Fetch - Next Result"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index 09012e67..b8b32a5b 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -7,9 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -137,10 +135,7 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); $testName = "Fetch - Scrollable"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC51_StreamRead.phpt b/test/functional/sqlsrv/TC51_StreamRead.phpt index 6268bceb..4d6e79bc 100644 --- a/test/functional/sqlsrv/TC51_StreamRead.phpt +++ b/test/functional/sqlsrv/TC51_StreamRead.phpt @@ -7,9 +7,7 @@ can be successfully retrieved as streams. PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -126,10 +124,7 @@ function checkData($col, $actual, $expected) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); global $testName; $testName = "Stream - Read"; diff --git a/test/functional/sqlsrv/TC55_StreamScrollable.phpt b/test/functional/sqlsrv/TC55_StreamScrollable.phpt index 14d8b345..6df4f3a7 100644 --- a/test/functional/sqlsrv/TC55_StreamScrollable.phpt +++ b/test/functional/sqlsrv/TC55_StreamScrollable.phpt @@ -7,9 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -163,11 +161,7 @@ function checkData($col, $actual, $expected) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - -global $testName; +setUSLocale(); $testName = "Stream - Scrollable"; // error message expected with AE enabled diff --git a/test/functional/sqlsrv/test_stream_large_data.phpt b/test/functional/sqlsrv/test_stream_large_data.phpt index d5a26070..1cf59696 100644 --- a/test/functional/sqlsrv/test_stream_large_data.phpt +++ b/test/functional/sqlsrv/test_stream_large_data.phpt @@ -3,10 +3,7 @@ streaming large amounts of data into a database and getting it out as a string e --SKIPIF-- --FILE-- @@ -254,9 +251,7 @@ function CompareLengths($filesizes, $lens1, $lens2, $count, $useUTF8) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} +setUSLocale(); // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) if (isLocaleSupported()) { From f642954d3536e89511f343904d064e9a295c6e80 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 2 Jan 2018 14:42:08 -0800 Subject: [PATCH 12/36] Renamed setUSLocale as per review --- test/functional/sqlsrv/MsCommon.inc | 2 +- test/functional/sqlsrv/TC34_PrepAndExec.phpt | 4 ++-- test/functional/sqlsrv/TC42_FetchField.phpt | 4 ++-- test/functional/sqlsrv/TC43_FetchData.phpt | 4 ++-- test/functional/sqlsrv/TC44_FetchArray.phpt | 4 ++-- test/functional/sqlsrv/TC45_FetchObject.phpt | 4 ++-- test/functional/sqlsrv/TC46_FetchNextResult.phpt | 4 ++-- test/functional/sqlsrv/TC48_FetchScrollable.phpt | 4 ++-- test/functional/sqlsrv/TC51_StreamRead.phpt | 4 ++-- test/functional/sqlsrv/TC55_StreamScrollable.phpt | 4 ++-- test/functional/sqlsrv/test_stream_large_data.phpt | 4 ++-- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index db7b3e10..117e9de4 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -442,7 +442,7 @@ function handleErrors() } } -function setUSLocale() +function setUSAnsiLocale() { if (!isWindows()) { // macOS the locale names are different in Linux or macOS diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index 06d2f14a..1af83b51 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -8,7 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -88,7 +88,7 @@ function prepareAndExecute($noPasses) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Statement - Prepare and Execute"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index ef030b16..f41102da 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -8,7 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -66,7 +66,7 @@ function fetchFields() } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Field"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC43_FetchData.phpt b/test/functional/sqlsrv/TC43_FetchData.phpt index 6e8e60f3..adeec7d2 100644 --- a/test/functional/sqlsrv/TC43_FetchData.phpt +++ b/test/functional/sqlsrv/TC43_FetchData.phpt @@ -5,7 +5,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -95,7 +95,7 @@ function checkData($col, $actual, $expected) return ($success); } -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Field Data"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC44_FetchArray.phpt b/test/functional/sqlsrv/TC44_FetchArray.phpt index ab7e88c8..217c6e1a 100644 --- a/test/functional/sqlsrv/TC44_FetchArray.phpt +++ b/test/functional/sqlsrv/TC44_FetchArray.phpt @@ -8,7 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -151,7 +151,7 @@ function checkData($row, $stmt, $index, $mode) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Array"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index 588620c5..dc138cb7 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -7,7 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -126,7 +126,7 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Object"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index 58d8fdfa..05f83552 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -7,7 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -84,7 +84,7 @@ function fetchFields() } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Next Result"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index b8b32a5b..9019d03b 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -7,7 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -135,7 +135,7 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Scrollable"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC51_StreamRead.phpt b/test/functional/sqlsrv/TC51_StreamRead.phpt index 4d6e79bc..5ac598a3 100644 --- a/test/functional/sqlsrv/TC51_StreamRead.phpt +++ b/test/functional/sqlsrv/TC51_StreamRead.phpt @@ -7,7 +7,7 @@ can be successfully retrieved as streams. PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -124,7 +124,7 @@ function checkData($col, $actual, $expected) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); global $testName; $testName = "Stream - Read"; diff --git a/test/functional/sqlsrv/TC55_StreamScrollable.phpt b/test/functional/sqlsrv/TC55_StreamScrollable.phpt index 6df4f3a7..0965c6d0 100644 --- a/test/functional/sqlsrv/TC55_StreamScrollable.phpt +++ b/test/functional/sqlsrv/TC55_StreamScrollable.phpt @@ -7,7 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -161,7 +161,7 @@ function checkData($col, $actual, $expected) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Stream - Scrollable"; // error message expected with AE enabled diff --git a/test/functional/sqlsrv/test_stream_large_data.phpt b/test/functional/sqlsrv/test_stream_large_data.phpt index 1cf59696..b7db404a 100644 --- a/test/functional/sqlsrv/test_stream_large_data.phpt +++ b/test/functional/sqlsrv/test_stream_large_data.phpt @@ -3,7 +3,7 @@ streaming large amounts of data into a database and getting it out as a string e --SKIPIF-- --FILE-- @@ -251,7 +251,7 @@ function CompareLengths($filesizes, $lens1, $lens2, $count, $useUTF8) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) if (isLocaleSupported()) { From 00a2e82ca8691de1767e0102cea5e42203435599 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 2 Jan 2018 15:26:33 -0800 Subject: [PATCH 13/36] Changed connection order to ODBC drivers --- source/shared/core_conn.cpp | 10 +++++----- source/shared/core_sqlsrv.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/shared/core_conn.cpp b/source/shared/core_conn.cpp index 6f9b0710..ff4139fb 100644 --- a/source/shared/core_conn.cpp +++ b/source/shared/core_conn.cpp @@ -50,7 +50,7 @@ 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 13 for SQL Server};", "Driver={ODBC Driver 11 for SQL Server};", "Driver={ODBC Driver 17 for SQL Server};" }; +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};" }; // default options if only the server is specified const char CONNECTION_STRING_DEFAULT_OPTIONS[] = "Mars_Connection={Yes};"; @@ -183,11 +183,11 @@ sqlsrv_conn* core_sqlsrv_connect( _In_ sqlsrv_context& henv_cp, _In_ sqlsrv_cont // https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server#microsoft-odbc-driver-11-for-sql-server-on-linux DRIVER_VERSION odbc_version = ODBC_DRIVER_UNKNOWN; - if( core_search_odbc_driver_unix( ODBC_DRIVER_13 ) ) { - odbc_version = ODBC_DRIVER_13; - } - else if ( core_search_odbc_driver_unix( ODBC_DRIVER_17 ) ) { + if( core_search_odbc_driver_unix( ODBC_DRIVER_17 ) ) { odbc_version = ODBC_DRIVER_17; + } + else if ( core_search_odbc_driver_unix( ODBC_DRIVER_13 ) ) { + odbc_version = ODBC_DRIVER_13; } CHECK_CUSTOM_ERROR( odbc_version == ODBC_DRIVER_UNKNOWN, conn, SQLSRV_ERROR_DRIVER_NOT_INSTALLED, get_processor_arch() ) { diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index 2e2cc371..9d5d6770 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -1043,10 +1043,10 @@ enum SERVER_VERSION { enum DRIVER_VERSION { ODBC_DRIVER_UNKNOWN = -1, FIRST = 0, - ODBC_DRIVER_13 = FIRST, - ODBC_DRIVER_11 = 1, - ODBC_DRIVER_17 = 2, - LAST = ODBC_DRIVER_17 + ODBC_DRIVER_17 = FIRST, + ODBC_DRIVER_13 = 1, + ODBC_DRIVER_11 = 2, + LAST = ODBC_DRIVER_11 }; // forward decl From 79b49fd93b23316b40d2d8968f10c3f7ce551e9e Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 2 Jan 2018 17:53:30 -0800 Subject: [PATCH 14/36] Fixed regex for ODBC driver names (#653) --- test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt | 2 +- test/functional/pdo_sqlsrv/pdo_get_set_attr.phpt | 2 +- test/functional/sqlsrv/sqlsrv_client_info.phpt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt b/test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt index 2bbfc3e6..a98dafda 100644 --- a/test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt +++ b/test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt @@ -20,7 +20,7 @@ try { --EXPECTREGEX-- Array \( - \[(DriverDllName|DriverName)\] => (msodbcsql1[1-9].dll|libmsodbcsql-[1-9]{2}.[0-9].so.[0-9].[0-9]) + \[(DriverDllName|DriverName)\] => (msodbcsql1[1-9].dll|(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)) \[DriverODBCVer\] => [0-9]{1,2}\.[0-9]{1,2} \[DriverVer\] => [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} \[ExtensionVer\] => [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? diff --git a/test/functional/pdo_sqlsrv/pdo_get_set_attr.phpt b/test/functional/pdo_sqlsrv/pdo_get_set_attr.phpt index 06c69b01..e6ee2ccb 100644 --- a/test/functional/pdo_sqlsrv/pdo_get_set_attr.phpt +++ b/test/functional/pdo_sqlsrv/pdo_get_set_attr.phpt @@ -125,7 +125,7 @@ SQLSTATE\[IMSSP\]: A read-only attribute was designated on the PDO object. Get Result PDO::ATTR_CLIENT_VERSION : array\(4\) { \[\"(DriverDllName|DriverName)\"\]=> - string\(15\) \"msodbcsql[0-9]{2}\.dll|string\(24\) \"libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]\" + (string\([0-9]+\) \"msodbcsql1[1-9].dll\"|string\([0-9]+\) \"(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)\") \["DriverODBCVer"\]=> string\(5\) \"[0-9]{1,2}\.[0-9]{1,2}\" \["DriverVer"\]=> diff --git a/test/functional/sqlsrv/sqlsrv_client_info.phpt b/test/functional/sqlsrv/sqlsrv_client_info.phpt index 1b8f7b31..bfcc2d0e 100644 --- a/test/functional/sqlsrv/sqlsrv_client_info.phpt +++ b/test/functional/sqlsrv/sqlsrv_client_info.phpt @@ -15,7 +15,7 @@ var_dump( $client_info ); --EXPECTREGEX-- array\(4\) { \[\"(DriverDllName|DriverName)\"\]=> - (string\(15\) \"msodbcsql1[1-9].dll\"|string\(24\) \"libmsodbcsql-[1-9]{2}.[0-9].so.[0-9].[0-9]\") + (string\([0-9]+\) \"msodbcsql1[1-9].dll\"|string\([0-9]+\) \"(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)\") \[\"DriverODBCVer\"\]=> string\(5\) \"[0-9]{1,2}\.[0-9]{1,2}\" \[\"DriverVer\"\]=> From cc303c59044388ba77d5b7a326ee05e5ea5bbef9 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 3 Jan 2018 13:02:26 -0800 Subject: [PATCH 15/36] Use https for fwlinks --- source/pdo_sqlsrv/pdo_util.cpp | 2 +- source/sqlsrv/util.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/pdo_sqlsrv/pdo_util.cpp b/source/pdo_sqlsrv/pdo_util.cpp index e0d2302c..3053a86b 100644 --- a/source/pdo_sqlsrv/pdo_util.cpp +++ b/source/pdo_sqlsrv/pdo_util.cpp @@ -59,7 +59,7 @@ pdo_error PDO_ERRORS[] = { { IMSSP, (SQLCHAR*) "This extension requires the Microsoft ODBC Driver for SQL Server to " "communicate with SQL Server. Access the following URL to download the ODBC Driver for SQL Server " "for %1!s!: " - "http://go.microsoft.com/fwlink/?LinkId=163712", -1, true } + "https://go.microsoft.com/fwlink/?LinkId=163712", -1, true } }, { SQLSRV_ERROR_ZEND_HASH, diff --git a/source/sqlsrv/util.cpp b/source/sqlsrv/util.cpp index 0b734254..d12872e6 100644 --- a/source/sqlsrv/util.cpp +++ b/source/sqlsrv/util.cpp @@ -302,7 +302,7 @@ ss_error SS_ERRORS[] = { SQLSRV_ERROR_DRIVER_NOT_INSTALLED, { IMSSP, (SQLCHAR*) "This extension requires the Microsoft ODBC Driver for SQL Server. " "Access the following URL to download the ODBC Driver for SQL Server for %1!s!: " - "http://go.microsoft.com/fwlink/?LinkId=163712", -49, true } + "https://go.microsoft.com/fwlink/?LinkId=163712", -49, true } }, { From c416fa72c228aa5aadf0bbee53ae846d67d1b715 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 4 Jan 2018 08:53:20 -0800 Subject: [PATCH 16/36] Modified tests to reset locale --- test/functional/sqlsrv/MsCommon.inc | 8 ++++++++ test/functional/sqlsrv/TC34_PrepAndExec.phpt | 1 + test/functional/sqlsrv/TC42_FetchField.phpt | 1 + test/functional/sqlsrv/TC43_FetchData.phpt | 1 + test/functional/sqlsrv/TC44_FetchArray.phpt | 1 + test/functional/sqlsrv/TC45_FetchObject.phpt | 1 + test/functional/sqlsrv/TC46_FetchNextResult.phpt | 1 + test/functional/sqlsrv/TC48_FetchScrollable.phpt | 1 + test/functional/sqlsrv/TC51_StreamRead.phpt | 1 + test/functional/sqlsrv/TC55_StreamScrollable.phpt | 1 + test/functional/sqlsrv/test_stream_large_data.phpt | 1 + 11 files changed, 18 insertions(+) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index 117e9de4..12201417 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -452,6 +452,14 @@ function setUSAnsiLocale() } } +function resetLocaleToDefault() +{ + // Like setUSAnsiLocale() above, this method is only needed in non-Windows environment + if (!isWindows()) { + setlocale(LC_ALL, null); + } +} + // non-UTF8 locale support in ODBC 17 and above only // if AE enabled, only supported in Windows (AE limitations) function isLocaleSupported() diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index 1af83b51..3e4f5672 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -107,6 +107,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); prepareAndExecute(5); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index f41102da..d605bcea 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -85,6 +85,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchFields(); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC43_FetchData.phpt b/test/functional/sqlsrv/TC43_FetchData.phpt index adeec7d2..ffa3ce1c 100644 --- a/test/functional/sqlsrv/TC43_FetchData.phpt +++ b/test/functional/sqlsrv/TC43_FetchData.phpt @@ -115,6 +115,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchFields(); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC44_FetchArray.phpt b/test/functional/sqlsrv/TC44_FetchArray.phpt index 217c6e1a..66e26c02 100644 --- a/test/functional/sqlsrv/TC44_FetchArray.phpt +++ b/test/functional/sqlsrv/TC44_FetchArray.phpt @@ -170,6 +170,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchRow(1, 4); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index dc138cb7..c93c9aa9 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -145,6 +145,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchRow(0, 2); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index 05f83552..0da23e5b 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -103,6 +103,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchFields(); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index 9019d03b..0b3df349 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -154,6 +154,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchRow(10); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC51_StreamRead.phpt b/test/functional/sqlsrv/TC51_StreamRead.phpt index 5ac598a3..6412f458 100644 --- a/test/functional/sqlsrv/TC51_StreamRead.phpt +++ b/test/functional/sqlsrv/TC51_StreamRead.phpt @@ -148,6 +148,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); streamRead(20, 1); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC55_StreamScrollable.phpt b/test/functional/sqlsrv/TC55_StreamScrollable.phpt index 0965c6d0..c3127efa 100644 --- a/test/functional/sqlsrv/TC55_StreamScrollable.phpt +++ b/test/functional/sqlsrv/TC55_StreamScrollable.phpt @@ -184,6 +184,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); streamScroll(20, 1); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/test_stream_large_data.phpt b/test/functional/sqlsrv/test_stream_large_data.phpt index b7db404a..909e3e69 100644 --- a/test/functional/sqlsrv/test_stream_large_data.phpt +++ b/test/functional/sqlsrv/test_stream_large_data.phpt @@ -264,6 +264,7 @@ else { // test utf8 setUTF8Data(true); +resetLocaleToDefault(); runtest(); ?> From 3955553e66da85fab2cdb0ccc002dddcd78c77fb Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 4 Jan 2018 10:18:43 -0800 Subject: [PATCH 17/36] Modified one test expected value --- test/functional/sqlsrv/0065.phpt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/functional/sqlsrv/0065.phpt b/test/functional/sqlsrv/0065.phpt index a9678bbb..36d4ed09 100644 --- a/test/functional/sqlsrv/0065.phpt +++ b/test/functional/sqlsrv/0065.phpt @@ -78,8 +78,11 @@ if ($t === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != "So?e sä???? ?SCII-te×t") { - die("varchar(100) doesn't match So?e sä???? ?SCII-te×t"); +// $t may be different in Windows and other platforms +// what matters is that there are some '?' in $t +$arr = explode('?', $t); +if (count($arr) == 1) { + die("varchar(100) value \'$t\' is unexpected"); } $t = sqlsrv_get_field($s, 1, SQLSRV_PHPTYPE_STRING('utf-8')); @@ -87,7 +90,7 @@ if ($t === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != $utf8) { +if ($t !== $utf8) { die("nvarchar(100) doesn't match the inserted UTF-8 text."); } @@ -96,7 +99,7 @@ if ($t === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != $utf8) { +if ($t !== $utf8) { die("nvarchar(max) doesn't match the inserted UTF-8 text."); } @@ -129,7 +132,7 @@ if ($s === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != $utf8) { +if ($t !== $utf8) { die("Incorrect results from Utf8OutProc\n"); } @@ -148,7 +151,7 @@ if ($s === false) { // retrieve all the results while (sqlsrv_next_result($s)); -if ($t != $utf8) { +if ($t !== $utf8) { die("Incorrect results from Utf8OutWithResultsetProc\n"); } @@ -169,7 +172,7 @@ if ($s === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != $utf8) { +if ($t !== $utf8) { die("Incorrect results from Utf8InOutProc 1\n"); } From 6c9c55a01cd81f2a9e8de30cc21e3cc26be9f89c Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 4 Jan 2018 15:21:10 -0800 Subject: [PATCH 18/36] Modified 0065 as per review --- test/functional/sqlsrv/0065.phpt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/functional/sqlsrv/0065.phpt b/test/functional/sqlsrv/0065.phpt index 36d4ed09..985b8e2b 100644 --- a/test/functional/sqlsrv/0065.phpt +++ b/test/functional/sqlsrv/0065.phpt @@ -78,11 +78,16 @@ if ($t === false) { die(print_r(sqlsrv_errors(), true)); } -// $t may be different in Windows and other platforms -// what matters is that there are some '?' in $t -$arr = explode('?', $t); -if (count($arr) == 1) { - die("varchar(100) value \'$t\' is unexpected"); +// If connected with AE, $t may be different in Windows and other platforms +// this is a workaround for now -- to make sure there are some '?' in $t +if (!AE\isColEncrypted() && $t !== "So?e sä???? ?SCII-te×t") { + die("varchar(100) \'$t\' doesn't match So?e sä???? ?SCII-te×t"); +} else { + $arr = explode('?', $t); + if (count($arr) == 1) { + // this means there is no question mark in $t + die("varchar(100) value \'$t\' is unexpected"); + } } $t = sqlsrv_get_field($s, 1, SQLSRV_PHPTYPE_STRING('utf-8')); From d4012c56049d5bdca7f242b31268fbd565e534e6 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 19 Dec 2017 14:35:28 -0800 Subject: [PATCH 19/36] Testing locale issues --- test/functional/sqlsrv/MsCommon.inc | 21 ++++++++------------- test/functional/sqlsrv/MsHelper.inc | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index 964e5efe..7d5123c4 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -84,18 +84,6 @@ function isDaasMode() return ($daasMode ? true : false); } -// function isAEQualified($conn) -// { - // $msodbcsql_ver = sqlsrv_client_info($conn)['DriverVer']; - // $server_ver = sqlsrv_server_info($conn)['SQLServerVersion']; - // $msodbcsql_maj = explode(".", $msodbcsql_ver)[0]; - // $msodbcsql_min = explode(".", $msodbcsql_ver)[1]; - // if ($msodbcsql_maj < 17 || explode('.', $server_ver)[0] < 13) { - // return false; - // } - // return true; -// } - function startTest($testName) { if (traceMode()) { @@ -455,10 +443,17 @@ function handleErrors() } // non-UTF8 locale support in ODBC 17 and above only +// if AE enabled, only supported in Windows (AE limitations) function isLocaleSupported() { + if (isWindows()) { + return true; + } + if (AE\isDataEncrypted()) { + return false; + } + // now check ODBC version $conn = AE\connect(); - $msodbcsql_ver = sqlsrv_client_info($conn)['DriverVer']; if (explode(".", $msodbcsql_ver)[0] < 17) { return false; diff --git a/test/functional/sqlsrv/MsHelper.inc b/test/functional/sqlsrv/MsHelper.inc index 988253b1..6792bfe2 100644 --- a/test/functional/sqlsrv/MsHelper.inc +++ b/test/functional/sqlsrv/MsHelper.inc @@ -330,7 +330,7 @@ function getSeqPlaceholders($num) */ function isColEncrypted() { - global $keystore, $dataEncrypted; + global $keystore; if ($keystore === KEYSTORE_NONE) { return false; } else { From 9abc2fb58c6916a5dd127b5d0957b4fd843c7d39 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 20 Dec 2017 08:28:34 -0800 Subject: [PATCH 20/36] Modified local supported method --- test/functional/sqlsrv/MsCommon.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index 7d5123c4..e01802e1 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -449,7 +449,7 @@ function isLocaleSupported() if (isWindows()) { return true; } - if (AE\isDataEncrypted()) { + if (AE\isColEncrypted()) { return false; } // now check ODBC version From 3459baedcf912e4373fba275d08e4beff4940cee Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 20 Dec 2017 09:31:44 -0800 Subject: [PATCH 21/36] Modified three tests to test with or without UTF-8 data --- test/functional/sqlsrv/TC42_FetchField.phpt | 40 +++++++++++++++---- test/functional/sqlsrv/TC45_FetchObject.phpt | 34 ++++++++++++---- .../sqlsrv/TC48_FetchScrollable.phpt | 39 ++++++++++++++---- 3 files changed, 90 insertions(+), 23 deletions(-) diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index b1395b5a..baddc6b9 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -6,20 +6,22 @@ retrieving fields from a table including rows with all supported SQL types (28 t --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8')); } else { $conn1 = AE\connect(); @@ -63,16 +65,38 @@ function fetchFields() dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } +// locale must be set before 1st connection +if (!isWindows()) { + setlocale(LC_ALL, "en_US.ISO-8859-1"); +} + +$testName = "Fetch - Field"; + +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + fetchFields(); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); fetchFields(); } catch (Exception $e) { echo $e->getMessage(); } +endTest($testName); ?> --EXPECT-- Test "Fetch - Field" completed successfully. +Test "Fetch - Field" completed successfully. diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index ec20c417..26767834 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -5,7 +5,13 @@ Verifies data retrieval via "sqlsrv_fetch_object". --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8' )); } else { $conn1 = AE\connect(); @@ -73,8 +75,6 @@ function fetchRow($minFetchMode, $maxFetchMode) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } @@ -127,12 +127,30 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } } +$testName = "Fetch - Object"; +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + fetchRow(0, 2); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); fetchRow(0, 2); } catch (Exception $e) { echo $e->getMessage(); } +endTest($testName); ?> --EXPECT-- Test "Fetch - Object" completed successfully. +Test "Fetch - Object" completed successfully. diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index 44090245..09012e67 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -5,19 +5,22 @@ Verifies data retrieval with scrollable result sets. --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8')); } else { $conn1 = AE\connect(); @@ -72,8 +75,6 @@ function fetchRow($noRows) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } function fetchArray($stmt, $rows, $fields) @@ -135,12 +136,36 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } } +// locale must be set before 1st connection +if (!isWindows()) { + setlocale(LC_ALL, "en_US.ISO-8859-1"); +} + +$testName = "Fetch - Scrollable"; + +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + fetchRow(10); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); fetchRow(10); } catch (Exception $e) { echo $e->getMessage(); } +endTest($testName); ?> --EXPECT-- Test "Fetch - Scrollable" completed successfully. +Test "Fetch - Scrollable" completed successfully. From b4a7163cda29f1ad5b510e6d44f1f38cb4339e96 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 20 Dec 2017 10:18:46 -0800 Subject: [PATCH 22/36] Added skipif and modified the check of isLocaleSupported() --- test/functional/sqlsrv/MsCommon.inc | 2 + test/functional/sqlsrv/TC34_PrepAndExec.phpt | 43 +++++++++++++++---- test/functional/sqlsrv/TC42_FetchField.phpt | 4 +- test/functional/sqlsrv/TC43_FetchData.phpt | 5 ++- test/functional/sqlsrv/TC44_FetchArray.phpt | 5 ++- test/functional/sqlsrv/TC45_FetchObject.phpt | 14 ++++-- .../sqlsrv/TC46_FetchNextResult.phpt | 5 ++- test/functional/sqlsrv/TC51_StreamRead.phpt | 5 ++- .../sqlsrv/TC55_StreamScrollable.phpt | 5 ++- .../sqlsrv/test_stream_large_data.phpt | 6 +-- 10 files changed, 66 insertions(+), 28 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index e01802e1..14fe90ee 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -98,6 +98,8 @@ function startTest($testName) */ function endTest($testName) { + // reset the utf-8 flag + setUTF8Data(false); echo "Test \"$testName\" completed successfully.\n"; } diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index d8e5d210..d77fef2c 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -6,18 +6,25 @@ Validates that a prepared statement can be successfully executed more than once. --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8')); + } else { + $conn1 = AE\connect(); + } $tableName = 'TC34test'; AE\createTestTable($conn1, $tableName); @@ -80,20 +87,38 @@ function prepareAndExecute($noPasses) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } +// locale must be set before 1st connection if (!isWindows()) { - setUTF8Data(true); + setlocale(LC_ALL, "en_US.ISO-8859-1"); } + +$testName = "Statement - Prepare and Execute"; + +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + prepareAndExecute(5); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); prepareAndExecute(5); } catch (Exception $e) { echo $e->getMessage(); } -setUTF8Data(false); +endTest($testName); ?> --EXPECT-- Test "Statement - Prepare and Execute" completed successfully. +Test "Statement - Prepare and Execute" completed successfully. diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index baddc6b9..dc715b19 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -8,10 +8,10 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- 'UTF-8' )); + $conn1 = AE\connect(array('CharacterSet'=>'UTF-8')); } else { $conn1 = AE\connect(); } @@ -89,7 +89,7 @@ function fetchObject($stmt, $rows, $fields, $useClass) $obj = sqlsrv_fetch_object($stmt); } if ($obj === false) { - fatalError("Row $i is missing"); + fatalError("In fetchObject: Row $i is missing"); } $values[$i] = $obj; } @@ -103,7 +103,7 @@ function fetchArray($stmt, $rows, $fields) for ($i = 0; $i < $rows; $i++) { $row = sqlsrv_fetch_array($stmt); if ($row === false) { - fatalError("Row $i is missing"); + fatalError("In fetchArray: Row $i is missing"); } $values[$i] = $row; } @@ -127,7 +127,13 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } } +// locale must be set before 1st connection +if (!isWindows()) { + setlocale(LC_ALL, "en_US.ISO-8859-1"); +} + $testName = "Fetch - Object"; + // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) startTest($testName); if (isLocaleSupported()) { diff --git a/test/functional/sqlsrv/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index 6848d2e6..bcd5e9e8 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -7,9 +7,10 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- Date: Wed, 20 Dec 2017 21:06:07 -0800 Subject: [PATCH 23/36] Changed helper methods as per review --- test/functional/sqlsrv/MsCommon.inc | 2 -- test/functional/sqlsrv/MsHelper.inc | 12 ++---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index 14fe90ee..e01802e1 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -98,8 +98,6 @@ function startTest($testName) */ function endTest($testName) { - // reset the utf-8 flag - setUTF8Data(false); echo "Test \"$testName\" completed successfully.\n"; } diff --git a/test/functional/sqlsrv/MsHelper.inc b/test/functional/sqlsrv/MsHelper.inc index 6792bfe2..f7cecd4d 100644 --- a/test/functional/sqlsrv/MsHelper.inc +++ b/test/functional/sqlsrv/MsHelper.inc @@ -331,11 +331,7 @@ function getSeqPlaceholders($num) function isColEncrypted() { global $keystore; - if ($keystore === KEYSTORE_NONE) { - return false; - } else { - return true; - } + return ($keystore !== KEYSTORE_NONE); } /** @@ -345,11 +341,7 @@ function isColEncrypted() function isDataEncrypted() { global $keystore, $dataEncrypted; - if ($keystore === KEYSTORE_NONE || !$dataEncrypted) { - return false; - } else { - return true; - } + return ($keystore !== KEYSTORE_NONE && $dataEncrypted); } /** From 4146ffd7915dd97219edd3edef0b53bda6128910 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 21 Dec 2017 11:02:11 -0800 Subject: [PATCH 24/36] Update version.h Renamed RC RC1 for PECL --- source/shared/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/shared/version.h b/source/shared/version.h index c8c7b127..cb13a805 100644 --- a/source/shared/version.h +++ b/source/shared/version.h @@ -35,7 +35,7 @@ // for stable releases should be empty // "-RC" for release candidates // "-preview" for ETP -#define SEMVER_PRERELEASE "RC" +#define SEMVER_PRERELEASE "RC1" // Semantic versioning build metadata, build meta data is not counted in precedence order. #define SEMVER_BUILDMETA From 57573bacff4e99eb02794a6e8f63e2d0750a8c35 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 21 Dec 2017 12:52:36 -0800 Subject: [PATCH 25/36] Added Control Flow Guard to configs --- source/pdo_sqlsrv/config.w32 | 3 ++- source/sqlsrv/config.w32 | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/pdo_sqlsrv/config.w32 b/source/pdo_sqlsrv/config.w32 index b8c72c02..29288b41 100644 --- a/source/pdo_sqlsrv/config.w32 +++ b/source/pdo_sqlsrv/config.w32 @@ -30,11 +30,12 @@ if( PHP_PDO_SQLSRV != "no" ) { CHECK_HEADER_ADD_INCLUDE("sql.h", "CFLAGS_PDO_SQLSRV_ODBC"); CHECK_HEADER_ADD_INCLUDE("sqlext.h", "CFLAGS_PDO_SQLSRV_ODBC"); ADD_SOURCES( configure_module_dirname + "\\shared", shared_src_class, "pdo_sqlsrv" ); - ADD_FLAG( "LDFLAGS_PDO_SQLSRV", "/NXCOMPAT /DYNAMICBASE /debug" ); + ADD_FLAG( "LDFLAGS_PDO_SQLSRV", "/NXCOMPAT /DYNAMICBASE /debug /guard:cf" ); ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/EHsc" ); ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/GS" ); ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/Zi" ); ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/O2" ); + ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/guard:cf" ); ADD_FLAG( "CFLAGS_PDO_SQLSRV", "/D ZEND_WIN32_FORCE_INLINE" ); ADD_EXTENSION_DEP('pdo_sqlsrv', 'pdo'); EXTENSION("pdo_sqlsrv", pdo_sqlsrv_src_class, PHP_PDO_SQLSRV_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); diff --git a/source/sqlsrv/config.w32 b/source/sqlsrv/config.w32 index 727b17e7..6e3df93a 100644 --- a/source/sqlsrv/config.w32 +++ b/source/sqlsrv/config.w32 @@ -30,12 +30,13 @@ if( PHP_SQLSRV != "no" ) { ADD_SOURCES( configure_module_dirname + "\\shared", shared_src_class, "sqlsrv" ); CHECK_HEADER_ADD_INCLUDE("sql.h", "CFLAGS_SQLSRV_ODBC"); CHECK_HEADER_ADD_INCLUDE("sqlext.h", "CFLAGS_SQLSRV_ODBC"); - ADD_FLAG( "LDFLAGS_SQLSRV", "/NXCOMPAT /DYNAMICBASE /debug" ); + ADD_FLAG( "LDFLAGS_SQLSRV", "/NXCOMPAT /DYNAMICBASE /debug /guard:cf" ); ADD_FLAG( "CFLAGS_SQLSRV", "/D ZEND_WIN32_FORCE_INLINE" ); ADD_FLAG( "CFLAGS_SQLSRV", "/EHsc" ); ADD_FLAG( "CFLAGS_SQLSRV", "/GS" ); ADD_FLAG( "CFLAGS_SQLSRV", "/Zi" ); ADD_FLAG( "CFLAGS_SQLSRV", "/O2" ); + ADD_FLAG( "CFLAGS_SQLSRV", "/guard:cf" ); EXTENSION("sqlsrv", sqlsrv_src_class , PHP_SQLSRV_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); } else { WARNING("sqlsrv not enabled; libraries and headers not found"); From 25be013b3f88483b9a69209f6042d553572c4b24 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 28 Dec 2017 10:30:17 -0800 Subject: [PATCH 26/36] Adjusted regex for odbc name with dylib --- test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt | 2 +- test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt index 54aa2e80..0e7798eb 100644 --- a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt +++ b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt @@ -32,7 +32,7 @@ PDO::ATTR_ERRMODE: int\(0\) PDO::ATTR_ERRMODE: int\(2\) Array \( - \[DriverDllName\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9] + \[DriverDllName\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? \[DriverODBCVer\] => [0-9]{1,2}\.[0-9]{1,2} \[DriverVer\] => [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} \[ExtensionVer\] => [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? diff --git a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt index d9586d8d..aadd707a 100644 --- a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt +++ b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt @@ -29,7 +29,7 @@ else sqlsrv_close( $conn); ?> --EXPECTREGEX-- -DriverDllName: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9] +DriverDllName: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? DriverODBCVer: [0-9]{1,2}\.[0-9]{1,2} DriverVer: [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} ExtensionVer: [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? \ No newline at end of file From 4b945f2077f84bd4ab82f8bfe99113edc6ea0d6a Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 28 Dec 2017 11:45:03 -0800 Subject: [PATCH 27/36] Added alternative for driver name --- test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt | 2 +- test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt index 0e7798eb..c2d05004 100644 --- a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt +++ b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt @@ -32,7 +32,7 @@ PDO::ATTR_ERRMODE: int\(0\) PDO::ATTR_ERRMODE: int\(2\) Array \( - \[DriverDllName\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? + \[DriverDllName\]|\[DriverName\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? \[DriverODBCVer\] => [0-9]{1,2}\.[0-9]{1,2} \[DriverVer\] => [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} \[ExtensionVer\] => [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? diff --git a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt index aadd707a..ed70a5ec 100644 --- a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt +++ b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt @@ -29,7 +29,7 @@ else sqlsrv_close( $conn); ?> --EXPECTREGEX-- -DriverDllName: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? +DriverDllName|DriverName: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? DriverODBCVer: [0-9]{1,2}\.[0-9]{1,2} DriverVer: [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} ExtensionVer: [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? \ No newline at end of file From 057abfbf0eaaa7bef78a7c2239599c5bf2126780 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 28 Dec 2017 12:03:24 -0800 Subject: [PATCH 28/36] Yet another alternative for driver name --- test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt | 2 +- test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt index c2d05004..eb9a44c1 100644 --- a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt +++ b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt @@ -32,7 +32,7 @@ PDO::ATTR_ERRMODE: int\(0\) PDO::ATTR_ERRMODE: int\(2\) Array \( - \[DriverDllName\]|\[DriverName\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? + \[DriverDllName\]|\[DriverName\] => (msodbcsql[0-9]{2}\.dll|(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)) \[DriverODBCVer\] => [0-9]{1,2}\.[0-9]{1,2} \[DriverVer\] => [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} \[ExtensionVer\] => [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? diff --git a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt index ed70a5ec..e979b422 100644 --- a/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt +++ b/test/bvt/sqlsrv/msdn_sqlsrv_client_info.phpt @@ -29,7 +29,7 @@ else sqlsrv_close( $conn); ?> --EXPECTREGEX-- -DriverDllName|DriverName: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9](.dylib)? +DriverDllName|DriverName: (msodbcsql[0-9]{2}\.dll|(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)) DriverODBCVer: [0-9]{1,2}\.[0-9]{1,2} DriverVer: [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} ExtensionVer: [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? \ No newline at end of file From 3fa17d0f5ee20b09aac07e22b22f1d7f05123e5a Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Fri, 29 Dec 2017 12:00:00 -0800 Subject: [PATCH 29/36] Fix tests with locales --- test/functional/sqlsrv/MsCommon.inc | 10 ++++++++++ test/functional/sqlsrv/TC34_PrepAndExec.phpt | 9 ++------- test/functional/sqlsrv/TC42_FetchField.phpt | 9 ++------- test/functional/sqlsrv/TC43_FetchData.phpt | 9 ++------- test/functional/sqlsrv/TC44_FetchArray.phpt | 10 ++-------- test/functional/sqlsrv/TC45_FetchObject.phpt | 9 ++------- test/functional/sqlsrv/TC46_FetchNextResult.phpt | 10 ++-------- test/functional/sqlsrv/TC48_FetchScrollable.phpt | 9 ++------- test/functional/sqlsrv/TC51_StreamRead.phpt | 9 ++------- test/functional/sqlsrv/TC55_StreamScrollable.phpt | 10 ++-------- test/functional/sqlsrv/test_stream_large_data.phpt | 9 ++------- 11 files changed, 30 insertions(+), 73 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index e01802e1..db7b3e10 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -442,6 +442,16 @@ function handleErrors() } } +function setUSLocale() +{ + if (!isWindows()) { + // macOS the locale names are different in Linux or macOS + $locale = strtoupper(PHP_OS) === 'LINUX' ? "en_US.ISO-8859-1" : "en_US.ISO8859-1"; + + setlocale(LC_ALL, $locale); + } +} + // non-UTF8 locale support in ODBC 17 and above only // if AE enabled, only supported in Windows (AE limitations) function isLocaleSupported() diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index d77fef2c..06d2f14a 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -8,9 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -90,10 +88,7 @@ function prepareAndExecute($noPasses) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); $testName = "Statement - Prepare and Execute"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index dc715b19..ef030b16 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -8,9 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -68,10 +66,7 @@ function fetchFields() } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); $testName = "Fetch - Field"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC43_FetchData.phpt b/test/functional/sqlsrv/TC43_FetchData.phpt index 5e03407c..6e8e60f3 100644 --- a/test/functional/sqlsrv/TC43_FetchData.phpt +++ b/test/functional/sqlsrv/TC43_FetchData.phpt @@ -5,9 +5,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -97,10 +95,7 @@ function checkData($col, $actual, $expected) return ($success); } -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); $testName = "Fetch - Field Data"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC44_FetchArray.phpt b/test/functional/sqlsrv/TC44_FetchArray.phpt index 556bd562..ab7e88c8 100644 --- a/test/functional/sqlsrv/TC44_FetchArray.phpt +++ b/test/functional/sqlsrv/TC44_FetchArray.phpt @@ -8,9 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -153,11 +151,7 @@ function checkData($row, $stmt, $index, $mode) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - -global $testName; +setUSLocale(); $testName = "Fetch - Array"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index 1c4e8f30..588620c5 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -7,9 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -128,10 +126,7 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); $testName = "Fetch - Object"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index bcd5e9e8..58d8fdfa 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -7,9 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -86,11 +84,7 @@ function fetchFields() } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - -global $testName; +setUSLocale(); $testName = "Fetch - Next Result"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index 09012e67..b8b32a5b 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -7,9 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -137,10 +135,7 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); $testName = "Fetch - Scrollable"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC51_StreamRead.phpt b/test/functional/sqlsrv/TC51_StreamRead.phpt index 6268bceb..4d6e79bc 100644 --- a/test/functional/sqlsrv/TC51_StreamRead.phpt +++ b/test/functional/sqlsrv/TC51_StreamRead.phpt @@ -7,9 +7,7 @@ can be successfully retrieved as streams. PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -126,10 +124,7 @@ function checkData($col, $actual, $expected) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - +setUSLocale(); global $testName; $testName = "Stream - Read"; diff --git a/test/functional/sqlsrv/TC55_StreamScrollable.phpt b/test/functional/sqlsrv/TC55_StreamScrollable.phpt index 14d8b345..6df4f3a7 100644 --- a/test/functional/sqlsrv/TC55_StreamScrollable.phpt +++ b/test/functional/sqlsrv/TC55_StreamScrollable.phpt @@ -7,9 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -163,11 +161,7 @@ function checkData($col, $actual, $expected) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} - -global $testName; +setUSLocale(); $testName = "Stream - Scrollable"; // error message expected with AE enabled diff --git a/test/functional/sqlsrv/test_stream_large_data.phpt b/test/functional/sqlsrv/test_stream_large_data.phpt index d5a26070..1cf59696 100644 --- a/test/functional/sqlsrv/test_stream_large_data.phpt +++ b/test/functional/sqlsrv/test_stream_large_data.phpt @@ -3,10 +3,7 @@ streaming large amounts of data into a database and getting it out as a string e --SKIPIF-- --FILE-- @@ -254,9 +251,7 @@ function CompareLengths($filesizes, $lens1, $lens2, $count, $useUTF8) } // locale must be set before 1st connection -if (!isWindows()) { - setlocale(LC_ALL, "en_US.ISO-8859-1"); -} +setUSLocale(); // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) if (isLocaleSupported()) { From 49ca00e1bdcfcb093a513ac1723d8879cd62581d Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 2 Jan 2018 14:42:08 -0800 Subject: [PATCH 30/36] Renamed setUSLocale as per review --- test/functional/sqlsrv/MsCommon.inc | 2 +- test/functional/sqlsrv/TC34_PrepAndExec.phpt | 4 ++-- test/functional/sqlsrv/TC42_FetchField.phpt | 4 ++-- test/functional/sqlsrv/TC43_FetchData.phpt | 4 ++-- test/functional/sqlsrv/TC44_FetchArray.phpt | 4 ++-- test/functional/sqlsrv/TC45_FetchObject.phpt | 4 ++-- test/functional/sqlsrv/TC46_FetchNextResult.phpt | 4 ++-- test/functional/sqlsrv/TC48_FetchScrollable.phpt | 4 ++-- test/functional/sqlsrv/TC51_StreamRead.phpt | 4 ++-- test/functional/sqlsrv/TC55_StreamScrollable.phpt | 4 ++-- test/functional/sqlsrv/test_stream_large_data.phpt | 4 ++-- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index db7b3e10..117e9de4 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -442,7 +442,7 @@ function handleErrors() } } -function setUSLocale() +function setUSAnsiLocale() { if (!isWindows()) { // macOS the locale names are different in Linux or macOS diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index 06d2f14a..1af83b51 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -8,7 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -88,7 +88,7 @@ function prepareAndExecute($noPasses) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Statement - Prepare and Execute"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index ef030b16..f41102da 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -8,7 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -66,7 +66,7 @@ function fetchFields() } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Field"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC43_FetchData.phpt b/test/functional/sqlsrv/TC43_FetchData.phpt index 6e8e60f3..adeec7d2 100644 --- a/test/functional/sqlsrv/TC43_FetchData.phpt +++ b/test/functional/sqlsrv/TC43_FetchData.phpt @@ -5,7 +5,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -95,7 +95,7 @@ function checkData($col, $actual, $expected) return ($success); } -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Field Data"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC44_FetchArray.phpt b/test/functional/sqlsrv/TC44_FetchArray.phpt index ab7e88c8..217c6e1a 100644 --- a/test/functional/sqlsrv/TC44_FetchArray.phpt +++ b/test/functional/sqlsrv/TC44_FetchArray.phpt @@ -8,7 +8,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -151,7 +151,7 @@ function checkData($row, $stmt, $index, $mode) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Array"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index 588620c5..dc138cb7 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -7,7 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -126,7 +126,7 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Object"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index 58d8fdfa..05f83552 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -7,7 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -84,7 +84,7 @@ function fetchFields() } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Next Result"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index b8b32a5b..9019d03b 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -7,7 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -135,7 +135,7 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Fetch - Scrollable"; // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) diff --git a/test/functional/sqlsrv/TC51_StreamRead.phpt b/test/functional/sqlsrv/TC51_StreamRead.phpt index 4d6e79bc..5ac598a3 100644 --- a/test/functional/sqlsrv/TC51_StreamRead.phpt +++ b/test/functional/sqlsrv/TC51_StreamRead.phpt @@ -7,7 +7,7 @@ can be successfully retrieved as streams. PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -124,7 +124,7 @@ function checkData($col, $actual, $expected) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); global $testName; $testName = "Stream - Read"; diff --git a/test/functional/sqlsrv/TC55_StreamScrollable.phpt b/test/functional/sqlsrv/TC55_StreamScrollable.phpt index 6df4f3a7..0965c6d0 100644 --- a/test/functional/sqlsrv/TC55_StreamScrollable.phpt +++ b/test/functional/sqlsrv/TC55_StreamScrollable.phpt @@ -7,7 +7,7 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- @@ -161,7 +161,7 @@ function checkData($col, $actual, $expected) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); $testName = "Stream - Scrollable"; // error message expected with AE enabled diff --git a/test/functional/sqlsrv/test_stream_large_data.phpt b/test/functional/sqlsrv/test_stream_large_data.phpt index 1cf59696..b7db404a 100644 --- a/test/functional/sqlsrv/test_stream_large_data.phpt +++ b/test/functional/sqlsrv/test_stream_large_data.phpt @@ -3,7 +3,7 @@ streaming large amounts of data into a database and getting it out as a string e --SKIPIF-- --FILE-- @@ -251,7 +251,7 @@ function CompareLengths($filesizes, $lens1, $lens2, $count, $useUTF8) } // locale must be set before 1st connection -setUSLocale(); +setUSAnsiLocale(); // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) if (isLocaleSupported()) { From 522c7fecab9f7d01f4a7851ade972dcac52d4108 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 2 Jan 2018 15:26:33 -0800 Subject: [PATCH 31/36] Changed connection order to ODBC drivers --- source/shared/core_conn.cpp | 10 +++++----- source/shared/core_sqlsrv.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/shared/core_conn.cpp b/source/shared/core_conn.cpp index 6f9b0710..ff4139fb 100644 --- a/source/shared/core_conn.cpp +++ b/source/shared/core_conn.cpp @@ -50,7 +50,7 @@ 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 13 for SQL Server};", "Driver={ODBC Driver 11 for SQL Server};", "Driver={ODBC Driver 17 for SQL Server};" }; +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};" }; // default options if only the server is specified const char CONNECTION_STRING_DEFAULT_OPTIONS[] = "Mars_Connection={Yes};"; @@ -183,11 +183,11 @@ sqlsrv_conn* core_sqlsrv_connect( _In_ sqlsrv_context& henv_cp, _In_ sqlsrv_cont // https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server#microsoft-odbc-driver-11-for-sql-server-on-linux DRIVER_VERSION odbc_version = ODBC_DRIVER_UNKNOWN; - if( core_search_odbc_driver_unix( ODBC_DRIVER_13 ) ) { - odbc_version = ODBC_DRIVER_13; - } - else if ( core_search_odbc_driver_unix( ODBC_DRIVER_17 ) ) { + if( core_search_odbc_driver_unix( ODBC_DRIVER_17 ) ) { odbc_version = ODBC_DRIVER_17; + } + else if ( core_search_odbc_driver_unix( ODBC_DRIVER_13 ) ) { + odbc_version = ODBC_DRIVER_13; } CHECK_CUSTOM_ERROR( odbc_version == ODBC_DRIVER_UNKNOWN, conn, SQLSRV_ERROR_DRIVER_NOT_INSTALLED, get_processor_arch() ) { diff --git a/source/shared/core_sqlsrv.h b/source/shared/core_sqlsrv.h index 2e2cc371..9d5d6770 100644 --- a/source/shared/core_sqlsrv.h +++ b/source/shared/core_sqlsrv.h @@ -1043,10 +1043,10 @@ enum SERVER_VERSION { enum DRIVER_VERSION { ODBC_DRIVER_UNKNOWN = -1, FIRST = 0, - ODBC_DRIVER_13 = FIRST, - ODBC_DRIVER_11 = 1, - ODBC_DRIVER_17 = 2, - LAST = ODBC_DRIVER_17 + ODBC_DRIVER_17 = FIRST, + ODBC_DRIVER_13 = 1, + ODBC_DRIVER_11 = 2, + LAST = ODBC_DRIVER_11 }; // forward decl From dbfbd8851dfaea89a59d1371fe996900e1a16cc1 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Tue, 2 Jan 2018 17:53:30 -0800 Subject: [PATCH 32/36] Fixed regex for ODBC driver names (#653) --- test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt | 2 +- test/functional/pdo_sqlsrv/pdo_get_set_attr.phpt | 2 +- test/functional/sqlsrv/sqlsrv_client_info.phpt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt b/test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt index 2bbfc3e6..a98dafda 100644 --- a/test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt +++ b/test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt @@ -20,7 +20,7 @@ try { --EXPECTREGEX-- Array \( - \[(DriverDllName|DriverName)\] => (msodbcsql1[1-9].dll|libmsodbcsql-[1-9]{2}.[0-9].so.[0-9].[0-9]) + \[(DriverDllName|DriverName)\] => (msodbcsql1[1-9].dll|(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)) \[DriverODBCVer\] => [0-9]{1,2}\.[0-9]{1,2} \[DriverVer\] => [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} \[ExtensionVer\] => [0-9].[0-9]\.[0-9](-(RC[0-9]?|preview))?(\.[0-9]+)?(\+[0-9]+)? diff --git a/test/functional/pdo_sqlsrv/pdo_get_set_attr.phpt b/test/functional/pdo_sqlsrv/pdo_get_set_attr.phpt index 06c69b01..e6ee2ccb 100644 --- a/test/functional/pdo_sqlsrv/pdo_get_set_attr.phpt +++ b/test/functional/pdo_sqlsrv/pdo_get_set_attr.phpt @@ -125,7 +125,7 @@ SQLSTATE\[IMSSP\]: A read-only attribute was designated on the PDO object. Get Result PDO::ATTR_CLIENT_VERSION : array\(4\) { \[\"(DriverDllName|DriverName)\"\]=> - string\(15\) \"msodbcsql[0-9]{2}\.dll|string\(24\) \"libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]\" + (string\([0-9]+\) \"msodbcsql1[1-9].dll\"|string\([0-9]+\) \"(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)\") \["DriverODBCVer"\]=> string\(5\) \"[0-9]{1,2}\.[0-9]{1,2}\" \["DriverVer"\]=> diff --git a/test/functional/sqlsrv/sqlsrv_client_info.phpt b/test/functional/sqlsrv/sqlsrv_client_info.phpt index 1b8f7b31..bfcc2d0e 100644 --- a/test/functional/sqlsrv/sqlsrv_client_info.phpt +++ b/test/functional/sqlsrv/sqlsrv_client_info.phpt @@ -15,7 +15,7 @@ var_dump( $client_info ); --EXPECTREGEX-- array\(4\) { \[\"(DriverDllName|DriverName)\"\]=> - (string\(15\) \"msodbcsql1[1-9].dll\"|string\(24\) \"libmsodbcsql-[1-9]{2}.[0-9].so.[0-9].[0-9]\") + (string\([0-9]+\) \"msodbcsql1[1-9].dll\"|string\([0-9]+\) \"(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)\") \[\"DriverODBCVer\"\]=> string\(5\) \"[0-9]{1,2}\.[0-9]{1,2}\" \[\"DriverVer\"\]=> From 5869d333a0cb46fa61dde2d39ce7ec29d00f6fda Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 3 Jan 2018 13:02:26 -0800 Subject: [PATCH 33/36] Use https for fwlinks --- source/pdo_sqlsrv/pdo_util.cpp | 2 +- source/sqlsrv/util.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/pdo_sqlsrv/pdo_util.cpp b/source/pdo_sqlsrv/pdo_util.cpp index e0d2302c..3053a86b 100644 --- a/source/pdo_sqlsrv/pdo_util.cpp +++ b/source/pdo_sqlsrv/pdo_util.cpp @@ -59,7 +59,7 @@ pdo_error PDO_ERRORS[] = { { IMSSP, (SQLCHAR*) "This extension requires the Microsoft ODBC Driver for SQL Server to " "communicate with SQL Server. Access the following URL to download the ODBC Driver for SQL Server " "for %1!s!: " - "http://go.microsoft.com/fwlink/?LinkId=163712", -1, true } + "https://go.microsoft.com/fwlink/?LinkId=163712", -1, true } }, { SQLSRV_ERROR_ZEND_HASH, diff --git a/source/sqlsrv/util.cpp b/source/sqlsrv/util.cpp index 0b734254..d12872e6 100644 --- a/source/sqlsrv/util.cpp +++ b/source/sqlsrv/util.cpp @@ -302,7 +302,7 @@ ss_error SS_ERRORS[] = { SQLSRV_ERROR_DRIVER_NOT_INSTALLED, { IMSSP, (SQLCHAR*) "This extension requires the Microsoft ODBC Driver for SQL Server. " "Access the following URL to download the ODBC Driver for SQL Server for %1!s!: " - "http://go.microsoft.com/fwlink/?LinkId=163712", -49, true } + "https://go.microsoft.com/fwlink/?LinkId=163712", -49, true } }, { From e8db777bf16d93a64d7c23aefc6d8c647987d360 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 4 Jan 2018 08:53:20 -0800 Subject: [PATCH 34/36] Modified tests to reset locale --- test/functional/sqlsrv/MsCommon.inc | 8 ++++++++ test/functional/sqlsrv/TC34_PrepAndExec.phpt | 1 + test/functional/sqlsrv/TC42_FetchField.phpt | 1 + test/functional/sqlsrv/TC43_FetchData.phpt | 1 + test/functional/sqlsrv/TC44_FetchArray.phpt | 1 + test/functional/sqlsrv/TC45_FetchObject.phpt | 1 + test/functional/sqlsrv/TC46_FetchNextResult.phpt | 1 + test/functional/sqlsrv/TC48_FetchScrollable.phpt | 1 + test/functional/sqlsrv/TC51_StreamRead.phpt | 1 + test/functional/sqlsrv/TC55_StreamScrollable.phpt | 1 + test/functional/sqlsrv/test_stream_large_data.phpt | 1 + 11 files changed, 18 insertions(+) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index 117e9de4..12201417 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -452,6 +452,14 @@ function setUSAnsiLocale() } } +function resetLocaleToDefault() +{ + // Like setUSAnsiLocale() above, this method is only needed in non-Windows environment + if (!isWindows()) { + setlocale(LC_ALL, null); + } +} + // non-UTF8 locale support in ODBC 17 and above only // if AE enabled, only supported in Windows (AE limitations) function isLocaleSupported() diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index 1af83b51..3e4f5672 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -107,6 +107,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); prepareAndExecute(5); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index f41102da..d605bcea 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -85,6 +85,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchFields(); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC43_FetchData.phpt b/test/functional/sqlsrv/TC43_FetchData.phpt index adeec7d2..ffa3ce1c 100644 --- a/test/functional/sqlsrv/TC43_FetchData.phpt +++ b/test/functional/sqlsrv/TC43_FetchData.phpt @@ -115,6 +115,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchFields(); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC44_FetchArray.phpt b/test/functional/sqlsrv/TC44_FetchArray.phpt index 217c6e1a..66e26c02 100644 --- a/test/functional/sqlsrv/TC44_FetchArray.phpt +++ b/test/functional/sqlsrv/TC44_FetchArray.phpt @@ -170,6 +170,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchRow(1, 4); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index dc138cb7..c93c9aa9 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -145,6 +145,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchRow(0, 2); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index 05f83552..0da23e5b 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -103,6 +103,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchFields(); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index 9019d03b..0b3df349 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -154,6 +154,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); fetchRow(10); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC51_StreamRead.phpt b/test/functional/sqlsrv/TC51_StreamRead.phpt index 5ac598a3..6412f458 100644 --- a/test/functional/sqlsrv/TC51_StreamRead.phpt +++ b/test/functional/sqlsrv/TC51_StreamRead.phpt @@ -148,6 +148,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); streamRead(20, 1); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/TC55_StreamScrollable.phpt b/test/functional/sqlsrv/TC55_StreamScrollable.phpt index 0965c6d0..c3127efa 100644 --- a/test/functional/sqlsrv/TC55_StreamScrollable.phpt +++ b/test/functional/sqlsrv/TC55_StreamScrollable.phpt @@ -184,6 +184,7 @@ endTest($testName); startTest($testName); try { setUTF8Data(true); + resetLocaleToDefault(); streamScroll(20, 1); } catch (Exception $e) { echo $e->getMessage(); diff --git a/test/functional/sqlsrv/test_stream_large_data.phpt b/test/functional/sqlsrv/test_stream_large_data.phpt index b7db404a..909e3e69 100644 --- a/test/functional/sqlsrv/test_stream_large_data.phpt +++ b/test/functional/sqlsrv/test_stream_large_data.phpt @@ -264,6 +264,7 @@ else { // test utf8 setUTF8Data(true); +resetLocaleToDefault(); runtest(); ?> From 7b51ebc25a6cf1d46cc121006821bf3fd1c46079 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 4 Jan 2018 10:18:43 -0800 Subject: [PATCH 35/36] Modified one test expected value --- test/functional/sqlsrv/0065.phpt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/functional/sqlsrv/0065.phpt b/test/functional/sqlsrv/0065.phpt index a9678bbb..36d4ed09 100644 --- a/test/functional/sqlsrv/0065.phpt +++ b/test/functional/sqlsrv/0065.phpt @@ -78,8 +78,11 @@ if ($t === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != "So?e sä???? ?SCII-te×t") { - die("varchar(100) doesn't match So?e sä???? ?SCII-te×t"); +// $t may be different in Windows and other platforms +// what matters is that there are some '?' in $t +$arr = explode('?', $t); +if (count($arr) == 1) { + die("varchar(100) value \'$t\' is unexpected"); } $t = sqlsrv_get_field($s, 1, SQLSRV_PHPTYPE_STRING('utf-8')); @@ -87,7 +90,7 @@ if ($t === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != $utf8) { +if ($t !== $utf8) { die("nvarchar(100) doesn't match the inserted UTF-8 text."); } @@ -96,7 +99,7 @@ if ($t === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != $utf8) { +if ($t !== $utf8) { die("nvarchar(max) doesn't match the inserted UTF-8 text."); } @@ -129,7 +132,7 @@ if ($s === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != $utf8) { +if ($t !== $utf8) { die("Incorrect results from Utf8OutProc\n"); } @@ -148,7 +151,7 @@ if ($s === false) { // retrieve all the results while (sqlsrv_next_result($s)); -if ($t != $utf8) { +if ($t !== $utf8) { die("Incorrect results from Utf8OutWithResultsetProc\n"); } @@ -169,7 +172,7 @@ if ($s === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != $utf8) { +if ($t !== $utf8) { die("Incorrect results from Utf8InOutProc 1\n"); } From ab1c236543deae7ab68cee94ad5f4bb47998f75e Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 4 Jan 2018 15:21:10 -0800 Subject: [PATCH 36/36] Modified 0065 as per review --- test/functional/sqlsrv/0065.phpt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/functional/sqlsrv/0065.phpt b/test/functional/sqlsrv/0065.phpt index 36d4ed09..985b8e2b 100644 --- a/test/functional/sqlsrv/0065.phpt +++ b/test/functional/sqlsrv/0065.phpt @@ -78,11 +78,16 @@ if ($t === false) { die(print_r(sqlsrv_errors(), true)); } -// $t may be different in Windows and other platforms -// what matters is that there are some '?' in $t -$arr = explode('?', $t); -if (count($arr) == 1) { - die("varchar(100) value \'$t\' is unexpected"); +// If connected with AE, $t may be different in Windows and other platforms +// this is a workaround for now -- to make sure there are some '?' in $t +if (!AE\isColEncrypted() && $t !== "So?e sä???? ?SCII-te×t") { + die("varchar(100) \'$t\' doesn't match So?e sä???? ?SCII-te×t"); +} else { + $arr = explode('?', $t); + if (count($arr) == 1) { + // this means there is no question mark in $t + die("varchar(100) value \'$t\' is unexpected"); + } } $t = sqlsrv_get_field($s, 1, SQLSRV_PHPTYPE_STRING('utf-8'));