Extended sqlsrv large stream test
This commit is contained in:
parent
a1a657f8c6
commit
cbd3c18cb6
|
@ -70,8 +70,6 @@ function fetchBinary($conn, $buffered)
|
||||||
|
|
||||||
if (!checkData($value, $hexValue)) {
|
if (!checkData($value, $hexValue)) {
|
||||||
echo "Fetched binary value as UTF-8 string ($buffered): $value\n";
|
echo "Fetched binary value as UTF-8 string ($buffered): $value\n";
|
||||||
var_dump($hexValue);
|
|
||||||
var_dump($value);
|
|
||||||
}
|
}
|
||||||
} catch (PdoException $e) {
|
} catch (PdoException $e) {
|
||||||
echo "Caught exception in fetchBinary ($buffered):\n";
|
echo "Caught exception in fetchBinary ($buffered):\n";
|
||||||
|
@ -98,11 +96,11 @@ function fetchAsString($conn, $buffered)
|
||||||
$row = $stmt->fetch(PDO::FETCH_BOUND);
|
$row = $stmt->fetch(PDO::FETCH_BOUND);
|
||||||
|
|
||||||
if (!checkData($value1, $strValue)) {
|
if (!checkData($value1, $strValue)) {
|
||||||
echo "Fetched string value: $value1\n";
|
echo "Fetched string value ($buffered): $value1\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkData($value2, $nstrValue)) {
|
if (!checkData($value2, $nstrValue)) {
|
||||||
echo "Fetched string value: $value2\n";
|
echo "Fetched string value ($buffered): $value2\n";
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Streaming Field Test
|
Test fetching varchar max and varbinary fields with client buffer
|
||||||
--DESCRIPTION--
|
--DESCRIPTION--
|
||||||
Verifies the streaming behavior and proper error handling with Always Encrypted
|
Test fetching varbinary and varchar max fields as streams or strings with client buffer
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_versions_old.inc'); ?>
|
<?php require('skipif_versions_old.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
|
@ -11,25 +11,44 @@ require_once('MsCommon.inc');
|
||||||
$conn = AE\connect();
|
$conn = AE\connect();
|
||||||
|
|
||||||
$tableName = "test_max_fields";
|
$tableName = "test_max_fields";
|
||||||
AE\createTable($conn, $tableName, array(new AE\ColumnMeta("varchar(max)", "varchar_max_col")));
|
|
||||||
|
|
||||||
$inValue = str_repeat("ÃÜðßZZýA©", 600);
|
$columns = array(new AE\ColumnMeta("varchar(max)", "varchar_max_col"),
|
||||||
$insertSql = "INSERT INTO $tableName (varchar_max_col) VALUES (?)";
|
new AE\ColumnMeta("varbinary(max)", "varbinary_max_col"));
|
||||||
$params = array($inValue);
|
|
||||||
|
AE\createTable($conn, $tableName, $columns);
|
||||||
|
|
||||||
|
$strValue = str_repeat("ÃÜðßZZýA©", 600);
|
||||||
|
|
||||||
|
$input = strtoupper(bin2hex('abcdefghijklmnopqrstuvwxyz'));
|
||||||
|
$binaryValue = str_repeat($input, 100);
|
||||||
|
|
||||||
|
$insertSql = "INSERT INTO $tableName (varchar_max_col, varbinary_max_col) VALUES (?, ?)";
|
||||||
|
|
||||||
|
$params = array($strValue, array($binaryValue, null, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR), SQLSRV_SQLTYPE_VARBINARY('max')));
|
||||||
|
|
||||||
$stmt = sqlsrv_prepare($conn, $insertSql, $params);
|
$stmt = sqlsrv_prepare($conn, $insertSql, $params);
|
||||||
if ($stmt) {
|
if ($stmt) {
|
||||||
sqlsrv_execute($stmt);
|
$res = sqlsrv_execute($stmt);
|
||||||
|
if (!$res) {
|
||||||
|
fatalError("Failed to insert data");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fatalError("Failed to prepare insert statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = "SELECT * FROM $tableName";
|
$query = "SELECT * FROM $tableName";
|
||||||
$stmt = sqlsrv_prepare($conn, $query);
|
$stmt = sqlsrv_prepare($conn, $query, null, array("Scrollable"=>SQLSRV_CURSOR_CLIENT_BUFFERED));
|
||||||
if ($stmt) {
|
if ($stmt) {
|
||||||
sqlsrv_execute($stmt);
|
$res = sqlsrv_execute($stmt);
|
||||||
|
if (!$res) {
|
||||||
|
fatalError("Failed to fetch data");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fatalError("Failed to prepare select statement");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sqlsrv_fetch($stmt)) {
|
if (!sqlsrv_fetch($stmt)) {
|
||||||
fatalError("Failed to fetch row ");
|
fatalError("Failed to fetch row");
|
||||||
}
|
}
|
||||||
|
|
||||||
$stream = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_CHAR));
|
$stream = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_CHAR));
|
||||||
|
@ -42,16 +61,25 @@ if ($stream !== false) {
|
||||||
$value .= fread($stream, 8192);
|
$value .= fread($stream, 8192);
|
||||||
}
|
}
|
||||||
fclose($stream);
|
fclose($stream);
|
||||||
if (checkData($value, $inValue)) { // compare the data to see if they match!
|
if (checkData($value, $strValue)) { // compare the data to see if they match!
|
||||||
$success = true;
|
$success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($success) {
|
if (!$success) {
|
||||||
echo "Done.\n";
|
|
||||||
} else {
|
|
||||||
fatalError("Failed to fetch stream ");
|
fatalError("Failed to fetch stream ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$value = sqlsrv_get_field($stmt, 1, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR));
|
||||||
|
if (!checkData($value, $binaryValue)) { // compare the data to see if they match!
|
||||||
|
echo("Expected:\n$binaryValue\nActual:\n$value\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Done.\n";
|
||||||
|
dropTable($conn, $tableName);
|
||||||
|
|
||||||
|
sqlsrv_free_stmt($stmt);
|
||||||
|
sqlsrv_close($conn);
|
||||||
|
|
||||||
function checkData($actual, $expected)
|
function checkData($actual, $expected)
|
||||||
{
|
{
|
||||||
$success = true;
|
$success = true;
|
||||||
|
|
Loading…
Reference in a new issue