correct tests with streaming

This commit is contained in:
v-kaywon 2018-01-16 15:47:36 -08:00
parent 53e5a51760
commit 132dc7e9e9
10 changed files with 17 additions and 82 deletions

View file

@ -23,8 +23,6 @@ function runTest($fieldType)
sqlsrv_fetch($stmt)
|| die(print_r(sqlsrv_errors(), true));
// Do not support getting stream if AE enabled, so expect
// it to fail with the correct error message
$stream = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STREAM("char"));
if ($stream) {
stream_filter_append($originalStream, "convert.base64-encode")
@ -37,11 +35,7 @@ function runTest($fieldType)
}
}
} 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!');
}
fatalError('Fetching data stream failed!');
}
dropTable($conn, $params['tableName']);

View file

@ -38,11 +38,7 @@ inserting and retrieving UTF-8 text.
$u = sqlsrv_get_field($s, 1, SQLSRV_PHPTYPE_STREAM('utf-8'));
if ($u === false) {
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));
}
die(print_r(sqlsrv_errors(), true));
} else {
$utf8_2 = fread($u, 10000);
if ($utf8 != $utf8_2) {

View file

@ -33,9 +33,6 @@ function fetchFields()
$stmt1 = AE\selectFromTable($conn1, $tableName);
$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 ...");
for ($i = 0; $i < $noRowsInserted; $i++) {
$row = sqlsrv_fetch($stmt1);
@ -44,16 +41,9 @@ function fetchFields()
}
for ($j = 0; $j < $numFields; $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 (AE\isColEncrypted() && isStreamData($col)) {
verifyError(sqlsrv_errors()[0], $errState, $errMessage);
} else {
fatalError("Field $j of Row $i is missing\n", true);
}
fatalError("Field $j of Row $i is missing\n", true);
}
}
}

View file

@ -68,7 +68,7 @@ function verifyStream($stmt, $row, $colIndex)
}
}
if ($stream === false) {
verifyStreamError("Failed to read field $col: $type");
fatalError("Failed to read field $col: $type");
} else {
$value = '';
if ($stream) {
@ -87,16 +87,6 @@ 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)
{
$success = true;
@ -128,10 +118,6 @@ setUSAnsiLocale();
global $testName;
$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)
startTest($testName);
if (isLocaleSupported()) {

View file

@ -272,9 +272,6 @@ function runTest($noPasses, $noRows, $tableName, $conn, $prepared, $release, $mo
break;
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);
$numFields = sqlsrv_num_fields($stmt);
while (sqlsrv_fetch($stmt)) {
@ -284,11 +281,7 @@ function runTest($noPasses, $noRows, $tableName, $conn, $prepared, $release, $mo
$col = $i + 1;
if ($fld === false) {
if (AE\isColEncrypted() && isStreamData($col)) {
verifyError(sqlsrv_errors()[0], $errState, $errMessage);
} else {
fatalError("Field $i of row $rowCount is missing");
}
fatalError("Field $i of row $rowCount is missing");
}
unset($fld);
}

View file

@ -35,23 +35,15 @@ if (!sqlsrv_fetch($stmt)) {
$stream = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_CHAR));
$success = false;
if ($stream === false) {
$error = sqlsrv_errors()[0];
if (AE\isColEncrypted() && $error['SQLSTATE'] === "IMSSP" && $error['code'] === -109 &&
$error['message'] === "Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.") {
$success = true;
}
} else {
if ($stream !== false) {
$value = '';
if (!AE\isColEncrypted()) {
$num = 0;
while (!feof($stream)) {
$value .= fread($stream, 8192);
}
fclose($stream);
if (checkData($value, $inValue)) { // compare the data to see if they match!
$success = true;
}
$num = 0;
while (!feof($stream)) {
$value .= fread($stream, 8192);
}
fclose($stream);
if (checkData($value, $inValue)) { // compare the data to see if they match!
$success = true;
}
}
if ($success) {

View file

@ -80,11 +80,7 @@ binding parameters, including output parameters, using the simplified syntax.
echo "$name\n";
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
if (!$stream) {
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!');
}
fatalError('Fetching data stream failed!');
} else {
while (!feof($stream)) {
$str = fread($stream, 10000);

View file

@ -49,11 +49,7 @@ sqlsrv_query test. Performs same tasks as 0006.phpt, using sqlsrv_query.
echo "$name\n";
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
if (!$stream) {
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!');
}
fatalError('Fetching data stream failed!');
} else {
while (!feof($stream)) {
$str = fread($stream, 4000);

View file

@ -114,11 +114,7 @@ binding streams using full syntax.
echo "$name\n";
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
if (!$stream) {
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!');
}
fatalError('Fetching data stream failed!');
} else {
while (!feof($stream)) {
$str = fread($stream, 10000);

View file

@ -86,11 +86,7 @@ error messages when trying to retrieve past the end of a result set and when no
echo "$name\n";
$stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY));
if (!$stream) {
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!');
}
fatalError('Fetching data stream failed!');
} else {
while (!feof($stream)) {
$str = fread($stream, 10000);