Modify sqlsrv tests to handle the new error message with stream data
This commit is contained in:
parent
a8c43e8d20
commit
0de708e3ab
|
@ -23,19 +23,26 @@ function runTest($fieldType)
|
||||||
sqlsrv_fetch($stmt)
|
sqlsrv_fetch($stmt)
|
||||||
|| die(print_r(sqlsrv_errors(), true));
|
|| die(print_r(sqlsrv_errors(), true));
|
||||||
|
|
||||||
($stream = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STREAM("char")))
|
// Do not support getting stream if AE enabled, so expect
|
||||||
|| die(print_r(sqlsrv_errors(), true));
|
// it to fail with the correct error message
|
||||||
|
$stream = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STREAM("char"));
|
||||||
stream_filter_append($originalStream, "convert.base64-encode")
|
if ($stream) {
|
||||||
|| die(print_r(error_get_last()));
|
stream_filter_append($originalStream, "convert.base64-encode")
|
||||||
|
|| die(print_r(error_get_last()));
|
||||||
while (($originalLine = fread($originalStream, 80)) &&
|
|
||||||
($dbLine = fread($stream, 80))) {
|
while (($originalLine = fread($originalStream, 80)) &&
|
||||||
if ($originalLine != $dbLine) {
|
($dbLine = fread($stream, 80))) {
|
||||||
die("Not identical");
|
if ($originalLine != $dbLine) {
|
||||||
|
die("Not identical");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (AE\isColEncrypted()) {
|
||||||
|
verifyError(sqlsrv_errors()[0], 'IMSSP', 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.');
|
||||||
|
} else {
|
||||||
|
fatalError('Fetching data stream failed!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dropTable($conn, $params['tableName']);
|
dropTable($conn, $params['tableName']);
|
||||||
|
|
||||||
sqlsrv_free_stmt($stmt) || die(print_r(sqlsrv_errors(), true));
|
sqlsrv_free_stmt($stmt) || die(print_r(sqlsrv_errors(), true));
|
||||||
|
|
|
@ -38,14 +38,17 @@ inserting and retrieving UTF-8 text.
|
||||||
|
|
||||||
$u = sqlsrv_get_field($s, 1, SQLSRV_PHPTYPE_STREAM('utf-8'));
|
$u = sqlsrv_get_field($s, 1, SQLSRV_PHPTYPE_STREAM('utf-8'));
|
||||||
if ($u === false) {
|
if ($u === false) {
|
||||||
die(print_r(sqlsrv_errors(), true));
|
if (AE\isColEncrypted()) {
|
||||||
|
verifyError(sqlsrv_errors()[0], 'IMSSP', 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.');
|
||||||
|
} else {
|
||||||
|
die(print_r(sqlsrv_errors(), true));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$utf8_2 = fread($u, 10000);
|
||||||
|
if ($utf8 != $utf8_2) {
|
||||||
|
fatalError("round trip failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$utf8_2 = fread($u, 10000);
|
|
||||||
if ($utf8 != $utf8_2) {
|
|
||||||
fatalError("round trip failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
dropTable($c, 'utf8test');
|
dropTable($c, 'utf8test');
|
||||||
|
|
||||||
echo "Test succeeded\n";
|
echo "Test succeeded\n";
|
||||||
|
|
|
@ -90,7 +90,8 @@ class ColumnMeta
|
||||||
{
|
{
|
||||||
$append = " ";
|
$append = " ";
|
||||||
|
|
||||||
if (isColEncrypted() && $this->encryptable) {
|
if ($this->encryptable && isDataEncrypted()) {
|
||||||
|
|
||||||
$cekName = getCekName();
|
$cekName = getCekName();
|
||||||
if (stripos($this->dataType, "char") !== false) {
|
if (stripos($this->dataType, "char") !== false) {
|
||||||
$append .= "COLLATE Latin1_General_BIN2 ";
|
$append .= "COLLATE Latin1_General_BIN2 ";
|
||||||
|
@ -325,13 +326,26 @@ function getSeqPlaceholders($num)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool false if $keystore specified in MsSetup.inc is none or data not encrypted,
|
* @return bool false if $keystore specified in MsSetup.inc is none; return true otherwise
|
||||||
* otherwise return true
|
|
||||||
*/
|
*/
|
||||||
function isColEncrypted()
|
function isColEncrypted()
|
||||||
{
|
{
|
||||||
global $keystore, $dataEncrypted;
|
global $keystore, $dataEncrypted;
|
||||||
if ($keystore == KEYSTORE_NONE || !$dataEncrypted) {
|
if ($keystore === KEYSTORE_NONE) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool false if $keystore specified in MsSetup.inc is none or data not encrypted;
|
||||||
|
* return true otherwise
|
||||||
|
*/
|
||||||
|
function isDataEncrypted()
|
||||||
|
{
|
||||||
|
global $keystore, $dataEncrypted;
|
||||||
|
if ($keystore === KEYSTORE_NONE || !$dataEncrypted) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1065,6 +1079,23 @@ function getColName($k)
|
||||||
return ("");
|
return ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isStreamData($k)
|
||||||
|
{
|
||||||
|
switch ($k) {
|
||||||
|
case 14: return (true); // varchar(max)
|
||||||
|
case 17: return (true); // nvarchar(max)
|
||||||
|
case 18: return (true); // text
|
||||||
|
case 19: return (true); // ntext
|
||||||
|
case 20: return (true); // binary
|
||||||
|
case 21: return (true); // varbinary(512)
|
||||||
|
case 22: return (true); // varbinary(max)
|
||||||
|
case 23: return (true); // image
|
||||||
|
case 27: return (true); // timestamp
|
||||||
|
case 28: return (true); // xml
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
function getColSize($k)
|
function getColSize($k)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,9 @@ function fetchFields()
|
||||||
$stmt1 = AE\selectFromTable($conn1, $tableName);
|
$stmt1 = AE\selectFromTable($conn1, $tableName);
|
||||||
$numFields = sqlsrv_num_fields($stmt1);
|
$numFields = sqlsrv_num_fields($stmt1);
|
||||||
|
|
||||||
|
$errState = 'IMSSP';
|
||||||
|
$errMessage = 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.';
|
||||||
|
|
||||||
trace("Retrieving $noRowsInserted rows with $numFields fields each ...");
|
trace("Retrieving $noRowsInserted rows with $numFields fields each ...");
|
||||||
for ($i = 0; $i < $noRowsInserted; $i++) {
|
for ($i = 0; $i < $noRowsInserted; $i++) {
|
||||||
$row = sqlsrv_fetch($stmt1);
|
$row = sqlsrv_fetch($stmt1);
|
||||||
|
@ -41,8 +44,16 @@ function fetchFields()
|
||||||
}
|
}
|
||||||
for ($j = 0; $j < $numFields; $j++) {
|
for ($j = 0; $j < $numFields; $j++) {
|
||||||
$fld = sqlsrv_get_field($stmt1, $j);
|
$fld = sqlsrv_get_field($stmt1, $j);
|
||||||
|
|
||||||
|
// With AE enabled, those fields that sqlsrv_get_field() will fetch
|
||||||
|
// as stream data will return a specific error message
|
||||||
|
$col = $j+1;
|
||||||
if ($fld === false) {
|
if ($fld === false) {
|
||||||
fatalError("Field $j of Row $i is missing\n", true);
|
if (AE\isColEncrypted() && isStreamData($col)) {
|
||||||
|
verifyError(sqlsrv_errors()[0], $errState, $errMessage);
|
||||||
|
} else {
|
||||||
|
fatalError("Field $j of Row $i is missing\n", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ function verifyStream($stmt, $row, $colIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($stream === false) {
|
if ($stream === false) {
|
||||||
fatalError("Failed to read field $col: $type");
|
verifyStreamError("Failed to read field $col: $type");
|
||||||
} else {
|
} else {
|
||||||
$value = '';
|
$value = '';
|
||||||
if ($stream) {
|
if ($stream) {
|
||||||
|
@ -88,6 +88,15 @@ function verifyStream($stmt, $row, $colIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function verifyStreamError($message)
|
||||||
|
{
|
||||||
|
global $errState, $errMessage;
|
||||||
|
if (AE\isColEncrypted()) {
|
||||||
|
verifyError(sqlsrv_errors()[0], $errState, $errMessage);
|
||||||
|
} else {
|
||||||
|
fatalError($message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkData($col, $actual, $expected)
|
function checkData($col, $actual, $expected)
|
||||||
{
|
{
|
||||||
|
@ -123,6 +132,10 @@ if (!isWindows()) {
|
||||||
global $testName;
|
global $testName;
|
||||||
$testName = "Stream - Read";
|
$testName = "Stream - Read";
|
||||||
|
|
||||||
|
// error message expected with AE enabled
|
||||||
|
$errState = 'IMSSP';
|
||||||
|
$errMessage = 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.';
|
||||||
|
|
||||||
// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above)
|
// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above)
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
if (isWindows() || isLocaleSupported()) {
|
if (isWindows() || isLocaleSupported()) {
|
||||||
|
|
|
@ -89,6 +89,16 @@ function streamScroll($noRows, $startRow)
|
||||||
sqlsrv_close($conn1);
|
sqlsrv_close($conn1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function verifyStreamError($message)
|
||||||
|
{
|
||||||
|
global $errState, $errMessage;
|
||||||
|
if (AE\isColEncrypted()) {
|
||||||
|
verifyError(sqlsrv_errors()[0], $errState, $errMessage);
|
||||||
|
} else {
|
||||||
|
fatalError($message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function verifyStream($stmt, $row, $colIndex)
|
function verifyStream($stmt, $row, $colIndex)
|
||||||
{
|
{
|
||||||
$col = $colIndex + 1;
|
$col = $colIndex + 1;
|
||||||
|
@ -104,7 +114,7 @@ function verifyStream($stmt, $row, $colIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($stream === false) {
|
if ($stream === false) {
|
||||||
fatalError("Failed to read field $col: $type");
|
verifyStreamError("Failed to read field $col: $type");
|
||||||
} else {
|
} else {
|
||||||
$value = '';
|
$value = '';
|
||||||
if ($stream) {
|
if ($stream) {
|
||||||
|
@ -159,6 +169,10 @@ if (!isWindows()) {
|
||||||
global $testName;
|
global $testName;
|
||||||
$testName = "Stream - Scrollable";
|
$testName = "Stream - Scrollable";
|
||||||
|
|
||||||
|
// error message expected with AE enabled
|
||||||
|
$errState = 'IMSSP';
|
||||||
|
$errMessage = 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.';
|
||||||
|
|
||||||
// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above)
|
// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above)
|
||||||
startTest($testName);
|
startTest($testName);
|
||||||
if (isWindows() || isLocaleSupported()) {
|
if (isWindows() || isLocaleSupported()) {
|
||||||
|
|
|
@ -272,14 +272,23 @@ function runTest($noPasses, $noRows, $tableName, $conn, $prepared, $release, $mo
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: // fetch fields
|
case 5: // fetch fields
|
||||||
|
$errState = 'IMSSP';
|
||||||
|
$errMessage = 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.';
|
||||||
|
|
||||||
$stmt = execQuery($conn, $tableName, $prepared);
|
$stmt = execQuery($conn, $tableName, $prepared);
|
||||||
$numFields = sqlsrv_num_fields($stmt);
|
$numFields = sqlsrv_num_fields($stmt);
|
||||||
while (sqlsrv_fetch($stmt)) {
|
while (sqlsrv_fetch($stmt)) {
|
||||||
$rowCount++;
|
$rowCount++;
|
||||||
for ($i = 0; $i < $numFields; $i++) {
|
for ($i = 0; $i < $numFields; $i++) {
|
||||||
$fld = sqlsrv_get_field($stmt, $i);
|
$fld = sqlsrv_get_field($stmt, $i);
|
||||||
|
$col = $i + 1;
|
||||||
|
|
||||||
if ($fld === false) {
|
if ($fld === false) {
|
||||||
die("Field $i of row $rowCount is missing");
|
if (AE\isColEncrypted() && isStreamData($col)) {
|
||||||
|
verifyError(sqlsrv_errors()[0], $errState, $errMessage);
|
||||||
|
} else {
|
||||||
|
fatalError("Field $i of row $rowCount is missing");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unset($fld);
|
unset($fld);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ foreach ($dataTypes as $dataType) {
|
||||||
$r;
|
$r;
|
||||||
$stmt = AE\insertRow($conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r);
|
$stmt = AE\insertRow($conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r);
|
||||||
|
|
||||||
if (!AE\isColEncrypted()) {
|
if (!AE\isDataEncrypted()) {
|
||||||
if ($r === false) {
|
if ($r === false) {
|
||||||
echo "Default type should be compatible with $dataType.\n";
|
echo "Default type should be compatible with $dataType.\n";
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
|
@ -44,7 +44,7 @@ sqlsrv_free_stmt($stmt);
|
||||||
|
|
||||||
//for AE only
|
//for AE only
|
||||||
echo "\nChecking ciphertext data:\n";
|
echo "\nChecking ciphertext data:\n";
|
||||||
if (AE\isColEncrypted()) {
|
if (AE\isDataEncrypted()) {
|
||||||
$conn1 = connect(null, true);
|
$conn1 = connect(null, true);
|
||||||
$selectSql = "SELECT SSN, FirstName, LastName, BirthDate FROM $tbname";
|
$selectSql = "SELECT SSN, FirstName, LastName, BirthDate FROM $tbname";
|
||||||
$stmt = sqlsrv_query($conn1, $selectSql);
|
$stmt = sqlsrv_query($conn1, $selectSql);
|
||||||
|
|
|
@ -43,7 +43,7 @@ AE\fetchAll($conn, $tbname);
|
||||||
sqlsrv_free_stmt($stmt);
|
sqlsrv_free_stmt($stmt);
|
||||||
|
|
||||||
// for AE only
|
// for AE only
|
||||||
if (AE\isColEncrypted()) {
|
if (AE\isDataEncrypted()) {
|
||||||
$conn1 = connect(null, true);
|
$conn1 = connect(null, true);
|
||||||
|
|
||||||
$selectSql = "SELECT * FROM $tbname";
|
$selectSql = "SELECT * FROM $tbname";
|
||||||
|
|
|
@ -14,7 +14,6 @@ $tbname = 'NVarcharAnalysis';
|
||||||
$colMetaArr = array( new AE\ColumnMeta("int", "CharCount", "IDENTITY(0,1)"), new AE\ColumnMeta("nvarchar(1000)"));
|
$colMetaArr = array( new AE\ColumnMeta("int", "CharCount", "IDENTITY(0,1)"), new AE\ColumnMeta("nvarchar(1000)"));
|
||||||
AE\createTable($conn, $tbname, $colMetaArr);
|
AE\createTable($conn, $tbname, $colMetaArr);
|
||||||
|
|
||||||
|
|
||||||
// insert 1000 rows
|
// insert 1000 rows
|
||||||
for ($i = 0; $i < 1000; $i++) {
|
for ($i = 0; $i < 1000; $i++) {
|
||||||
$data = str_repeat("*", $i);
|
$data = str_repeat("*", $i);
|
||||||
|
@ -33,7 +32,7 @@ while ($decrypted_row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||||
sqlsrv_free_stmt($stmt);
|
sqlsrv_free_stmt($stmt);
|
||||||
|
|
||||||
// for AE only
|
// for AE only
|
||||||
if (AE\isColEncrypted()) {
|
if (AE\isDataEncrypted()) {
|
||||||
$conn1 = connect(null, true);
|
$conn1 = connect(null, true);
|
||||||
$stmt = sqlsrv_query($conn1, $selectSql);
|
$stmt = sqlsrv_query($conn1, $selectSql);
|
||||||
while ($encrypted_row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
while ($encrypted_row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ while ($decrypted_row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||||
sqlsrv_free_stmt($stmt);
|
sqlsrv_free_stmt($stmt);
|
||||||
|
|
||||||
// for AE only
|
// for AE only
|
||||||
if (AE\isColEncrypted()) {
|
if (AE\isDataEncrypted()) {
|
||||||
$conn1 = connect(null, true);
|
$conn1 = connect(null, true);
|
||||||
$stmt = sqlsrv_query($conn1, $selectSql);
|
$stmt = sqlsrv_query($conn1, $selectSql);
|
||||||
while ($encrypted_row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
while ($encrypted_row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ foreach ($dataTypes as $dataType) {
|
||||||
$r;
|
$r;
|
||||||
$stmt = AE\insertRow($conn, $tbname, array( $colMetaArr[0]->colName => $inputs[0], $colMetaArr[1]->colName => $inputs[1] ), $r, AE\INSERT_PREPARE_PARAMS);
|
$stmt = AE\insertRow($conn, $tbname, array( $colMetaArr[0]->colName => $inputs[0], $colMetaArr[1]->colName => $inputs[1] ), $r, AE\INSERT_PREPARE_PARAMS);
|
||||||
|
|
||||||
if (!AE\isColEncrypted()) {
|
if (!AE\isDataEncrypted()) {
|
||||||
if ($r === false) {
|
if ($r === false) {
|
||||||
$isCompatible = false;
|
$isCompatible = false;
|
||||||
foreach ($compatList[$dataType] as $compatType) {
|
foreach ($compatList[$dataType] as $compatType) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ foreach ($dataTypes as $dataType) {
|
||||||
$r;
|
$r;
|
||||||
$stmt = AE\insertRow($conn, $tbname, array($colMetaArr[0]->colName => $inputs[0], $colMetaArr[1]->colName => $inputs[1]), $r, AE\INSERT_PREPARE_PARAMS);
|
$stmt = AE\insertRow($conn, $tbname, array($colMetaArr[0]->colName => $inputs[0], $colMetaArr[1]->colName => $inputs[1]), $r, AE\INSERT_PREPARE_PARAMS);
|
||||||
|
|
||||||
if (!AE\isColEncrypted()) {
|
if (!AE\isDataEncrypted()) {
|
||||||
if ($r === false) {
|
if ($r === false) {
|
||||||
$isCompatible = false;
|
$isCompatible = false;
|
||||||
foreach ($compatList[$dataType] as $compatType) {
|
foreach ($compatList[$dataType] as $compatType) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ foreach ($dataTypes as $dataType) {
|
||||||
$r;
|
$r;
|
||||||
$stmt = AE\insertRow($conn, $tbname, array( $colMetaArr[0]->colName => $inputs[0], $colMetaArr[1]->colName => $inputs[1] ), $r, AE\INSERT_PREPARE_PARAMS);
|
$stmt = AE\insertRow($conn, $tbname, array( $colMetaArr[0]->colName => $inputs[0], $colMetaArr[1]->colName => $inputs[1] ), $r, AE\INSERT_PREPARE_PARAMS);
|
||||||
|
|
||||||
if (!AE\isColEncrypted()) {
|
if (!AE\isDataEncrypted()) {
|
||||||
if ($r === false) {
|
if ($r === false) {
|
||||||
$isCompatible = false;
|
$isCompatible = false;
|
||||||
foreach ($compatList[$dataType] as $compatType) {
|
foreach ($compatList[$dataType] as $compatType) {
|
||||||
|
|
|
@ -76,9 +76,17 @@ binding parameters, including output parameters, using the simplified syntax.
|
||||||
$name = sqlsrv_get_field($stmt, 2, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
$name = sqlsrv_get_field($stmt, 2, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
||||||
echo "$name\n";
|
echo "$name\n";
|
||||||
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
|
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
|
||||||
while (!feof($stream)) {
|
if (!$stream) {
|
||||||
$str = fread($stream, 10000);
|
if (AE\isColEncrypted()) {
|
||||||
echo $str;
|
verifyError(sqlsrv_errors()[0], 'IMSSP', 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.');
|
||||||
|
} else {
|
||||||
|
fatalError('Fetching data stream failed!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (!feof($stream)) {
|
||||||
|
$str = fread($stream, 10000);
|
||||||
|
echo $str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
@ -121,14 +129,14 @@ binding parameters, including output parameters, using the simplified syntax.
|
||||||
sqlsrv_free_stmt($stmt);
|
sqlsrv_free_stmt($stmt);
|
||||||
sqlsrv_close($conn);
|
sqlsrv_close($conn);
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTREGEX--
|
||||||
1
|
1
|
||||||
12.0
|
12\.0
|
||||||
testtestte
|
testtestte
|
||||||
This is some text meant to test binding parameters to streams
|
(This is some text meant to test binding parameters to streams)?
|
||||||
2
|
2
|
||||||
13.0
|
13\.0
|
||||||
testtestte
|
testtestte
|
||||||
This is some more text meant to test binding parameters to streams
|
(This is some more text meant to test binding parameters to streams)?
|
||||||
3
|
3
|
||||||
4
|
4
|
||||||
|
|
|
@ -42,17 +42,25 @@ sqlsrv_query test. Performs same tasks as 0006.phpt, using sqlsrv_query.
|
||||||
|
|
||||||
while (sqlsrv_fetch($stmt)) {
|
while (sqlsrv_fetch($stmt)) {
|
||||||
$id = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
$id = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
||||||
echo "$id <br/>";
|
echo "$id\n";
|
||||||
$double = sqlsrv_get_field($stmt, 1, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
$double = sqlsrv_get_field($stmt, 1, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
||||||
echo "$double <br/>";
|
echo "$double\n";
|
||||||
$name = sqlsrv_get_field($stmt, 2, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
$name = sqlsrv_get_field($stmt, 2, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
||||||
echo "$name <br/>";
|
echo "$name\n";
|
||||||
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
|
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
|
||||||
while (!feof($stream)) {
|
if (!$stream) {
|
||||||
$str = fread($stream, 4000);
|
if (AE\isColEncrypted()) {
|
||||||
echo $str;
|
echo sqlsrv_errors()[0]['message'];
|
||||||
|
} else {
|
||||||
|
fatalError('Fetching data stream failed!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (!feof($stream)) {
|
||||||
|
$str = fread($stream, 4000);
|
||||||
|
echo $str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
echo "<br/>";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlsrv_query($conn, "DROP TABLE test_params");
|
sqlsrv_query($conn, "DROP TABLE test_params");
|
||||||
|
@ -61,5 +69,8 @@ sqlsrv_query test. Performs same tasks as 0006.phpt, using sqlsrv_query.
|
||||||
sqlsrv_close($conn);
|
sqlsrv_close($conn);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTREGEX--
|
||||||
1 <br/>12.0 <br/>testtestte <br/>This is some text meant to test binding parameters to streams<br/>%A
|
1
|
||||||
|
12\.0
|
||||||
|
testtestte
|
||||||
|
(This is some text meant to test binding parameters to streams|Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.)
|
||||||
|
|
|
@ -113,9 +113,17 @@ binding streams using full syntax.
|
||||||
$name = sqlsrv_get_field($stmt, 2, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
$name = sqlsrv_get_field($stmt, 2, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
||||||
echo "$name\n";
|
echo "$name\n";
|
||||||
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
|
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
|
||||||
while (!feof($stream)) {
|
if (!$stream) {
|
||||||
$str = fread($stream, 10000);
|
if (AE\isColEncrypted()) {
|
||||||
echo $str;
|
echo sqlsrv_errors()[0]['message'];
|
||||||
|
} else {
|
||||||
|
fatalError('Fetching data stream failed!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (!feof($stream)) {
|
||||||
|
$str = fread($stream, 10000);
|
||||||
|
echo $str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
@ -153,11 +161,11 @@ binding streams using full syntax.
|
||||||
dropTable($conn, $tableName);
|
dropTable($conn, $tableName);
|
||||||
sqlsrv_close($conn);
|
sqlsrv_close($conn);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTREGEX--
|
||||||
sqlsrv_query(2) failed.
|
sqlsrv_query\(2\) failed\.
|
||||||
sqlsrv_query(3) failed.
|
sqlsrv_query\(3\) failed\.
|
||||||
1
|
1
|
||||||
12.0
|
12\.0
|
||||||
testtestte
|
testtestte
|
||||||
This is some text meant to test binding parameters to streams
|
(This is some text meant to test binding parameters to streams|Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.)
|
||||||
Done
|
Done
|
|
@ -47,6 +47,7 @@ function execProc($conn, $tableName, $columnNames, $k, $data, $sqlType)
|
||||||
$spCode = "SET @p2 = ( SELECT c2 FROM $tableName WHERE c1 = @p1 )";
|
$spCode = "SET @p2 = ( SELECT c2 FROM $tableName WHERE c1 = @p1 )";
|
||||||
$procName = "testBindOutSp";
|
$procName = "testBindOutSp";
|
||||||
|
|
||||||
|
dropProc($conn, $procName);
|
||||||
$stmt1 = sqlsrv_query($conn, "CREATE PROC [$procName] ($spArgs) AS BEGIN $spCode END");
|
$stmt1 = sqlsrv_query($conn, "CREATE PROC [$procName] ($spArgs) AS BEGIN $spCode END");
|
||||||
sqlsrv_free_stmt($stmt1);
|
sqlsrv_free_stmt($stmt1);
|
||||||
|
|
||||||
|
|
|
@ -82,9 +82,19 @@ error messages when trying to retrieve past the end of a result set and when no
|
||||||
$name = sqlsrv_get_field($stmt, 2, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
$name = sqlsrv_get_field($stmt, 2, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
||||||
echo "$name\n";
|
echo "$name\n";
|
||||||
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
|
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
|
||||||
while (!feof($stream)) {
|
if (!$stream) {
|
||||||
$str = fread($stream, 10000);
|
if (AE\isColEncrypted()) {
|
||||||
echo $str;
|
verifyError(sqlsrv_errors()[0], 'IMSSP', 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.');
|
||||||
|
} else {
|
||||||
|
fatalError('Fetching data stream failed!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (!feof($stream)) {
|
||||||
|
$str = fread($stream, 10000);
|
||||||
|
if ($str !== "This is some text meant to test binding parameters to streams") {
|
||||||
|
fatalError("Incorrect data: \'$str\'!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
@ -127,11 +137,11 @@ Array
|
||||||
1
|
1
|
||||||
12.0
|
12.0
|
||||||
testtestte
|
testtestte
|
||||||
This is some text meant to test binding parameters to streams
|
|
||||||
2
|
2
|
||||||
13.0
|
13.0
|
||||||
testtestte
|
testtestte
|
||||||
This is some more text meant to test binding parameters to streams
|
|
||||||
Array
|
Array
|
||||||
(
|
(
|
||||||
[0] => Array
|
[0] => Array
|
||||||
|
|
Loading…
Reference in a new issue