2017-05-04 01:00:31 +02:00
|
|
|
--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
|
2017-10-04 23:22:56 +02:00
|
|
|
require_once('MsCommon.inc');
|
2017-05-04 01:00:31 +02:00
|
|
|
|
2018-07-14 01:11:35 +02:00
|
|
|
function largeColumnNameTest($columnName, $expectFail = false)
|
2017-05-04 01:00:31 +02:00
|
|
|
{
|
2017-10-04 23:22:56 +02:00
|
|
|
setup();
|
2017-05-04 01:00:31 +02:00
|
|
|
|
2018-07-14 01:11:35 +02:00
|
|
|
$conn = connect(array('CharacterSet'=>'UTF-8'));
|
2017-05-04 01:00:31 +02:00
|
|
|
|
|
|
|
$tableName = "LargeColumnNameTest";
|
|
|
|
|
2017-10-04 23:22:56 +02:00
|
|
|
dropTable($conn, $tableName);
|
2017-05-04 01:00:31 +02:00
|
|
|
|
2018-07-14 01:11:35 +02:00
|
|
|
$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)");
|
2017-05-04 01:00:31 +02:00
|
|
|
|
2018-07-14 01:11:35 +02:00
|
|
|
$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");
|
2017-05-04 01:00:31 +02:00
|
|
|
|
2017-10-04 23:22:56 +02:00
|
|
|
if (null == sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
2018-07-14 01:11:35 +02:00
|
|
|
if (!$expectFail) {
|
2017-10-04 23:22:56 +02:00
|
|
|
fatalError("Possible regression: Unable to retrieve inserted value.");
|
|
|
|
}
|
2017-05-04 01:00:31 +02:00
|
|
|
}
|
|
|
|
sqlsrv_free_stmt($stmt);
|
|
|
|
}
|
|
|
|
|
2018-07-14 01:11:35 +02:00
|
|
|
dropTable($conn, $tableName);
|
|
|
|
|
2017-05-04 01:00:31 +02:00
|
|
|
sqlsrv_close($conn);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2017-10-04 23:22:56 +02:00
|
|
|
// repro
|
2017-05-04 01:00:31 +02:00
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------
|
2017-10-04 23:22:56 +02:00
|
|
|
function repro()
|
2017-05-04 01:00:31 +02:00
|
|
|
{
|
|
|
|
$testName = "PHP - Large Unicode Column Name Test";
|
|
|
|
|
2017-10-04 23:22:56 +02:00
|
|
|
startTest($testName);
|
2017-05-04 01:00:31 +02:00
|
|
|
|
2018-07-14 01:11:35 +02:00
|
|
|
// The maximum size of a column name is 128 characters
|
|
|
|
$maxlen = 128;
|
|
|
|
$columnName = str_repeat('银', $maxlen);
|
2017-05-04 01:00:31 +02:00
|
|
|
|
2018-07-14 01:11:35 +02:00
|
|
|
largeColumnNameTest($columnName);
|
|
|
|
|
|
|
|
// Now add another character to the name
|
|
|
|
$columnName .= "银";
|
|
|
|
|
|
|
|
largeColumnNameTest($columnName, true);
|
2017-05-04 01:00:31 +02:00
|
|
|
|
2017-10-04 23:22:56 +02:00
|
|
|
endTest($testName);
|
2017-05-04 01:00:31 +02:00
|
|
|
}
|
|
|
|
|
2017-10-04 23:22:56 +02:00
|
|
|
repro();
|
2017-05-04 01:00:31 +02:00
|
|
|
?>
|
|
|
|
--EXPECT--
|
|
|
|
$stmt = null
|
|
|
|
Test "PHP - Large Unicode Column Name Test" completed successfully.
|