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/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/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 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 diff --git a/source/sqlsrv/config.m4 b/source/sqlsrv/config.m4 index 829bc719..e03ab0f4 100644 --- a/source/sqlsrv/config.m4 +++ b/source/sqlsrv/config.m4 @@ -35,10 +35,10 @@ if test "$PHP_SQLSRV" != "no"; then HOST_OS_ARCH=`uname` if test "${HOST_OS_ARCH}" = "Darwin"; then - PDO_SQLSRV_SHARED_LIBADD="$PDO_SQLSRV_SHARED_LIBADD -Wl,-bind_at_load" + SQLSRV_SHARED_LIBADD="$SQLSRV_SHARED_LIBADD -Wl,-bind_at_load" MACOSX_DEPLOYMENT_TARGET=`sw_vers -productVersion` else - PDO_SQLSRV_SHARED_LIBADD="$PDO_SQLSRV_SHARED_LIBADD -Wl,-z,now" + SQLSRV_SHARED_LIBADD="$SQLSRV_SHARED_LIBADD -Wl,-z,now" fi PHP_REQUIRE_CXX() 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"); 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 } }, { diff --git a/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt b/test/bvt/pdo_sqlsrv/msdn_pdo_getAttribute.phpt index 54aa2e80..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\] => msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9] + \[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 d9586d8d..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: msodbcsql[0-9]{2}\.dll|libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9] +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 diff --git a/test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt b/test/functional/pdo_sqlsrv/pdo_getAttribute_clientInfo.phpt index e490f6f2..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]|libmsodbcsql.1[1-9].dylib) + \[(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 c8ae5454..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\(21\) \"libmsodbcsql\.1[1-9]\.dylib\" + (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/0065.phpt b/test/functional/sqlsrv/0065.phpt index a9678bbb..985b8e2b 100644 --- a/test/functional/sqlsrv/0065.phpt +++ b/test/functional/sqlsrv/0065.phpt @@ -78,8 +78,16 @@ 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"); +// 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')); @@ -87,7 +95,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 +104,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 +137,7 @@ if ($s === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != $utf8) { +if ($t !== $utf8) { die("Incorrect results from Utf8OutProc\n"); } @@ -148,7 +156,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 +177,7 @@ if ($s === false) { die(print_r(sqlsrv_errors(), true)); } -if ($t != $utf8) { +if ($t !== $utf8) { die("Incorrect results from Utf8InOutProc 1\n"); } diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index 964e5efe..12201417 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()) { @@ -454,11 +442,36 @@ function handleErrors() } } +function setUSAnsiLocale() +{ + 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); + } +} + +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() { + if (isWindows()) { + return true; + } + if (AE\isColEncrypted()) { + 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..f7cecd4d 100644 --- a/test/functional/sqlsrv/MsHelper.inc +++ b/test/functional/sqlsrv/MsHelper.inc @@ -330,12 +330,8 @@ function getSeqPlaceholders($num) */ function isColEncrypted() { - global $keystore, $dataEncrypted; - if ($keystore === KEYSTORE_NONE) { - return false; - } else { - return true; - } + global $keystore; + 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); } /** diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index d8e5d210..3e4f5672 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -6,18 +6,23 @@ 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 +85,36 @@ function prepareAndExecute($noPasses) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } -if (!isWindows()) { - setUTF8Data(true); +// locale must be set before 1st connection +setUSAnsiLocale(); +$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); + resetLocaleToDefault(); 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 b1395b5a..d605bcea 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -6,20 +6,20 @@ 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 +63,36 @@ function fetchFields() dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } +// locale must be set before 1st connection +setUSAnsiLocale(); +$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); + resetLocaleToDefault(); 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/TC43_FetchData.phpt b/test/functional/sqlsrv/TC43_FetchData.phpt index 58a7c9d6..ffa3ce1c 100644 --- a/test/functional/sqlsrv/TC43_FetchData.phpt +++ b/test/functional/sqlsrv/TC43_FetchData.phpt @@ -5,9 +5,8 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- getMessage(); diff --git a/test/functional/sqlsrv/TC44_FetchArray.phpt b/test/functional/sqlsrv/TC44_FetchArray.phpt index 7e338257..66e26c02 100644 --- a/test/functional/sqlsrv/TC44_FetchArray.phpt +++ b/test/functional/sqlsrv/TC44_FetchArray.phpt @@ -8,9 +8,8 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- getMessage(); diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index ec20c417..c93c9aa9 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -5,7 +5,11 @@ Verifies data retrieval via "sqlsrv_fetch_object". --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8' )); + if (useUTF8Data()) { + $conn1 = AE\connect(array('CharacterSet'=>'UTF-8')); } else { $conn1 = AE\connect(); } @@ -73,8 +73,6 @@ function fetchRow($minFetchMode, $maxFetchMode) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } @@ -89,7 +87,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 +101,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,12 +125,34 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } } +// locale must be set before 1st connection +setUSAnsiLocale(); +$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); + resetLocaleToDefault(); 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/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index 6848d2e6..0da23e5b 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -7,9 +7,8 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- getMessage(); diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index 44090245..0b3df349 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -5,19 +5,20 @@ Verifies data retrieval with scrollable result sets. --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8')); } else { $conn1 = AE\connect(); @@ -72,8 +73,6 @@ function fetchRow($noRows) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } function fetchArray($stmt, $rows, $fields) @@ -135,12 +134,34 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } } +// locale must be set before 1st connection +setUSAnsiLocale(); +$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); + resetLocaleToDefault(); fetchRow(10); } catch (Exception $e) { echo $e->getMessage(); } +endTest($testName); ?> --EXPECT-- Test "Fetch - Scrollable" completed successfully. +Test "Fetch - Scrollable" completed successfully. diff --git a/test/functional/sqlsrv/TC51_StreamRead.phpt b/test/functional/sqlsrv/TC51_StreamRead.phpt index f81f2c82..6412f458 100644 --- a/test/functional/sqlsrv/TC51_StreamRead.phpt +++ b/test/functional/sqlsrv/TC51_StreamRead.phpt @@ -7,9 +7,8 @@ can be successfully retrieved as streams. PHPT_EXEC=true --SKIPIF-- --FILE-- getMessage(); diff --git a/test/functional/sqlsrv/TC55_StreamScrollable.phpt b/test/functional/sqlsrv/TC55_StreamScrollable.phpt index 45d5a8a3..c3127efa 100644 --- a/test/functional/sqlsrv/TC55_StreamScrollable.phpt +++ b/test/functional/sqlsrv/TC55_StreamScrollable.phpt @@ -7,9 +7,8 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- getMessage(); diff --git a/test/functional/sqlsrv/sqlsrv_client_info.phpt b/test/functional/sqlsrv/sqlsrv_client_info.phpt index 7c80c779..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\(21\) \"libmsodbcsql.1[1-9].dylib\") + (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/test_stream_large_data.phpt b/test/functional/sqlsrv/test_stream_large_data.phpt index c14f9e27..909e3e69 100644 --- a/test/functional/sqlsrv/test_stream_large_data.phpt +++ b/test/functional/sqlsrv/test_stream_large_data.phpt @@ -3,11 +3,8 @@ streaming large amounts of data into a database and getting it out as a string e --SKIPIF-- --FILE--