Streamlined two very similar large column name tests (#815)
* Streamlined two very similar large column name tests * Added random number of test table names to avoid operand clash issues * Replaced to with for based on review
This commit is contained in:
parent
9479d03baf
commit
35631cffae
|
@ -10,7 +10,7 @@ Updated PECL release packages. Here is the list of updates:
|
|||
- Added support for Azure Key Vault for Always Encrypted for basic CRUD functionalities such that Always Encrypted feature is available to all supported Windows, Linux or macOS platforms
|
||||
- Added support for macOS High Sierra (requires [MS ODBC Driver 17+](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017))
|
||||
- Added support for Ubuntu 18.04 LTS (requires MS ODBC Driver 17.2)
|
||||
- Added support for Linux and macOS to Connection Resiliency (requires MS ODBC Driver 17.2)
|
||||
- Added support for Linux and macOS for Connection Resiliency (requires MS ODBC Driver 17.2)
|
||||
|
||||
### Fixed
|
||||
- Issue [#577](https://github.com/Microsoft/msphpsql/issues/577) - Idle Connection Resiliency doesn't work with Column Encryption enabled connection (fixed in MS ODBC Driver 17.1)
|
||||
|
|
|
@ -19,7 +19,7 @@ function sendStream($minType, $maxType, $atExec)
|
|||
startTest($testName);
|
||||
|
||||
setup();
|
||||
$tableName = "TC52test";
|
||||
$tableName = "TC52test" . rand(0, 100);
|
||||
$fileName = "TC52test.dat";
|
||||
$conn1 = AE\connect();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ function sendStream($minType, $maxType)
|
|||
startTest($testName);
|
||||
|
||||
setup();
|
||||
$tableName = "TC54test";
|
||||
$tableName = "TC54test" . rand(0, 100);
|
||||
$fileName = "TC53test.dat";
|
||||
$conn1 = AE\connect();
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function LargeColumnNameTest($columnName, $expectfail)
|
||||
function largeColumnNameTest($columnName, $expectFail = false)
|
||||
{
|
||||
setup();
|
||||
|
||||
|
@ -20,26 +20,32 @@ function LargeColumnNameTest($columnName, $expectfail)
|
|||
|
||||
dropTable($conn, $tableName);
|
||||
|
||||
sqlsrv_query($conn, "CREATE TABLE [$tableName] ([$columnName] int)");
|
||||
|
||||
sqlsrv_query($conn, "INSERT INTO [$tableName] ([$columnName]) VALUES (5)");
|
||||
|
||||
$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");
|
||||
|
||||
if (null == $stmt) {
|
||||
echo "$";
|
||||
echo "stmt = null";
|
||||
echo "\n";
|
||||
$stmt = sqlsrv_query($conn, "CREATE TABLE [$tableName] ([$columnName] int)");
|
||||
if ($stmt == null) {
|
||||
if (!$expectFail) {
|
||||
fatalError("Possible regression: Unable to create test $tableName.");
|
||||
} else {
|
||||
$expected = 'is too long. Maximum length is 128.';
|
||||
if (strpos(sqlsrv_errors()[0]['message'], $expected) === false) {
|
||||
print_r(sqlsrv_errors());
|
||||
}
|
||||
echo "$";
|
||||
echo "stmt = null";
|
||||
echo "\n";
|
||||
}
|
||||
} else {
|
||||
sqlsrv_query($conn, "INSERT INTO [$tableName] ([$columnName]) VALUES (5)");
|
||||
|
||||
$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");
|
||||
|
||||
if (null == sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
if (!$expectfail) {
|
||||
if (!$expectFail) {
|
||||
fatalError("Possible regression: Unable to retrieve inserted value.");
|
||||
}
|
||||
}
|
||||
sqlsrv_free_stmt($stmt);
|
||||
}
|
||||
|
||||
|
||||
dropTable($conn, $tableName);
|
||||
|
||||
sqlsrv_close($conn);
|
||||
|
@ -56,17 +62,16 @@ function repro()
|
|||
|
||||
startTest($testName);
|
||||
|
||||
$columnName = "a";
|
||||
|
||||
try {
|
||||
for ($a = 1; $a <= 129; $a++) {
|
||||
LargeColumnNameTest($columnName, $a > 128);
|
||||
$columnName .= "A";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
// The maximum size of a column name is 128 characters
|
||||
$maxlen = 128;
|
||||
$columnName = str_repeat('a', $maxlen);
|
||||
|
||||
largeColumnNameTest($columnName);
|
||||
|
||||
// Now add another character to the name
|
||||
$columnName .= "A";
|
||||
|
||||
largeColumnNameTest($columnName, true);
|
||||
|
||||
endTest($testName);
|
||||
}
|
||||
|
|
|
@ -10,35 +10,44 @@ PHPT_EXEC=true
|
|||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function LargeColumnNameTest($columnName, $expectfail)
|
||||
function largeColumnNameTest($columnName, $expectFail = false)
|
||||
{
|
||||
setup();
|
||||
|
||||
$conn = connect(array( 'CharacterSet'=>'UTF-8' ));
|
||||
$conn = connect(array('CharacterSet'=>'UTF-8'));
|
||||
|
||||
$tableName = "LargeColumnNameTest";
|
||||
|
||||
dropTable($conn, $tableName);
|
||||
|
||||
sqlsrv_query($conn, "CREATE TABLE [$tableName] ([$columnName] int)");
|
||||
|
||||
sqlsrv_query($conn, "INSERT INTO [$tableName] ([$columnName]) VALUES (5)");
|
||||
|
||||
$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");
|
||||
|
||||
if (null == $stmt) {
|
||||
echo "$";
|
||||
echo "stmt = null";
|
||||
echo "\n";
|
||||
$stmt = sqlsrv_query($conn, "CREATE TABLE [$tableName] ([$columnName] int)");
|
||||
if ($stmt == null) {
|
||||
if (!$expectFail) {
|
||||
fatalError("Possible regression: Unable to create test $tableName.");
|
||||
} else {
|
||||
$expected = 'is too long. Maximum length is 128.';
|
||||
if (strpos(sqlsrv_errors()[0]['message'], $expected) === false) {
|
||||
print_r(sqlsrv_errors());
|
||||
}
|
||||
echo "$";
|
||||
echo "stmt = null";
|
||||
echo "\n";
|
||||
}
|
||||
} else {
|
||||
sqlsrv_query($conn, "INSERT INTO [$tableName] ([$columnName]) VALUES (5)");
|
||||
|
||||
$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");
|
||||
|
||||
if (null == sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
if (!$expectfail) {
|
||||
if (!$expectFail) {
|
||||
fatalError("Possible regression: Unable to retrieve inserted value.");
|
||||
}
|
||||
}
|
||||
sqlsrv_free_stmt($stmt);
|
||||
}
|
||||
|
||||
dropTable($conn, $tableName);
|
||||
|
||||
sqlsrv_close($conn);
|
||||
}
|
||||
|
||||
|
@ -53,16 +62,16 @@ function repro()
|
|||
|
||||
startTest($testName);
|
||||
|
||||
$columnName = "银";
|
||||
// The maximum size of a column name is 128 characters
|
||||
$maxlen = 128;
|
||||
$columnName = str_repeat('银', $maxlen);
|
||||
|
||||
try {
|
||||
for ($a = 1; $a <= 129; $a++) {
|
||||
LargeColumnNameTest($columnName, $a > 128);
|
||||
$columnName .= "银";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
largeColumnNameTest($columnName);
|
||||
|
||||
// Now add another character to the name
|
||||
$columnName .= "银";
|
||||
|
||||
largeColumnNameTest($columnName, true);
|
||||
|
||||
endTest($testName);
|
||||
}
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
--TEST--
|
||||
PHP - Large Unicode Column Name Test
|
||||
--DESCRIPTION--
|
||||
Verifies that long column names are supported (up to 128 chars).
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('MsCommon.inc');
|
||||
|
||||
function LargeColumnNameTest($columnName, $expectfail)
|
||||
{
|
||||
setup();
|
||||
|
||||
$conn = connect(array( 'CharacterSet'=>'UTF-8' ));
|
||||
|
||||
$tableName = "LargeColumnNameTest";
|
||||
|
||||
dropTable($conn, $tableName);
|
||||
|
||||
sqlsrv_query($conn, "CREATE TABLE [$tableName] ([$columnName] int)");
|
||||
|
||||
sqlsrv_query($conn, "INSERT INTO [$tableName] ([$columnName]) VALUES (5)");
|
||||
|
||||
$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");
|
||||
|
||||
if (null == $stmt) {
|
||||
echo "$";
|
||||
echo "stmt = null";
|
||||
echo "\n";
|
||||
} else {
|
||||
if (null == sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||
if (!$expectfail) {
|
||||
fatalError("Possible regression: Unable to retrieve inserted value.");
|
||||
}
|
||||
}
|
||||
sqlsrv_free_stmt($stmt);
|
||||
}
|
||||
|
||||
sqlsrv_close($conn);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// repro
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
function repro()
|
||||
{
|
||||
$testName = "PHP - Large Unicode Column Name Test";
|
||||
|
||||
startTest($testName);
|
||||
|
||||
$columnName = "银";
|
||||
|
||||
try {
|
||||
for ($a = 1; $a <= 129; $a++) {
|
||||
LargeColumnNameTest($columnName, $a > 128);
|
||||
$columnName .= "银";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
endTest($testName);
|
||||
}
|
||||
|
||||
repro();
|
||||
?>
|
||||
--EXPECT--
|
||||
$stmt = null
|
||||
Test "PHP - Large Unicode Column Name Test" completed successfully.
|
Loading…
Reference in a new issue