php-sqlsrv/test/functional/sqlsrv/TC84_LargeColumnName.phpt

84 lines
2 KiB
Plaintext
Raw Normal View History

2017-05-04 01:00:31 +02:00
--TEST--
PHP - Large Column Name Test
2017-05-04 18:16:29 +02:00
--DESCRIPTION--
2017-05-04 01:00:31 +02:00
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');
2017-05-04 01:00:31 +02:00
function largeColumnNameTest($columnName, $expectFail = false)
2017-05-04 01:00:31 +02:00
{
setup();
2017-05-04 01:00:31 +02:00
$conn = connect();
2017-05-04 01:00:31 +02:00
$tableName = "LargeColumnNameTest";
dropTable($conn, $tableName);
2017-05-04 01:00:31 +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
$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");
2017-05-04 01:00:31 +02:00
if (null == sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
if (!$expectFail) {
fatalError("Possible regression: Unable to retrieve inserted value.");
}
2017-05-04 01:00:31 +02:00
}
sqlsrv_free_stmt($stmt);
}
dropTable($conn, $tableName);
2017-05-04 01:00:31 +02:00
sqlsrv_close($conn);
}
//--------------------------------------------------------------------
// repro
2017-05-04 01:00:31 +02:00
//
//--------------------------------------------------------------------
function repro()
2017-05-04 01:00:31 +02:00
{
$testName = "PHP - Large Column Name Test";
startTest($testName);
2017-05-04 01:00:31 +02:00
// The maximum size of a column name is 128 characters
$maxlen = 128;
$columnName = str_repeat('a', $maxlen);
2017-05-04 01:00:31 +02:00
largeColumnNameTest($columnName);
// Now add another character to the name
$columnName .= "A";
largeColumnNameTest($columnName, true);
endTest($testName);
2017-05-04 01:00:31 +02:00
}
repro();
2017-05-04 01:00:31 +02:00
?>
--EXPECT--
$stmt = null
Test "PHP - Large Column Name Test" completed successfully.