Merge pull request #721 from v-kaywon/aetests2

Add tests for SQLSRV output parameters with different sizes, precision and scale
This commit is contained in:
Yuki Wong 2018-03-15 15:34:33 -07:00 committed by GitHub
commit e55d3c8eed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 1370 additions and 0 deletions

View file

@ -0,0 +1,278 @@
--TEST--
Test for retrieving encrypted data of binary types with different sizes as output parameters
--DESCRIPTION--
Test implicit conversions between different binary types of different sizes
With Always Encrypted, implicit conversion works if:
1. From a binary(m) column to a SQLSRV_SQLTYPE_BINARY(n) output parameter where m == n
2. From a binary(m) column to a SQLSRV_SQLTYPE_VARBINARY(n) output parameter where m == n
3. From a varbinary(m) column to a SQLSRV_SQLTYPE_BINARY(n) output parameter where m == n
4. From a varbinary(m) column to a SQLSRV_SQLTYPE_VARBINARY(n) output parameter where m == n
Without AlwaysEncrypted, implicit conversion works if:
1. From a binary(m) column to a SQLSRV_SQLTYPE_BINARY(n) output parameter where m, n == any value
2. From a binary(m) column to a SQLSRV_SQLTYPE_VARBINARY(n) output parameter where m <= n (exclude SQLSRV_SQLTYPE_VARBINARY('max'))
3. From a varbinary(m) column to a SQLSRV_SQLTYPE_BINARY(n) output parameter where m, n == any value
4. From a varbinary(m) column to a SQLSRV_SQLTYPE_VARBINARY(n) output parameter where m, n == any value
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
--FILE--
<?php
require_once('MsCommon.inc');
$dataTypes = array("binary", "varbinary", "varbinary(max)");
$lengths = array(1, 8, 64, 512, 4000);
$sqlTypes = array("SQLSRV_SQLTYPE_BINARY", "SQLSRV_SQLTYPE_VARBINARY", "SQLSRV_SQLTYPE_VARBINARY('max')");
$sqltypeLengths = $lengths;
$directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$inputValues = array("d", "f");
$conn = AE\connect();
foreach ($dataTypes as $dataType) {
$maxcol = strpos($dataType, "(max)");
foreach ($lengths as $m) {
if ($maxcol) {
$typeFull = $dataType;
} else {
$typeFull = "$dataType($m)";
}
echo "\nTesting $typeFull:\n";
// create and populate table containing binary(m) or varbinary(m) columns
$tbname = "test_" . str_replace(array('(', ')'), '', $dataType) . $m;
$colMetaArr = array(new AE\ColumnMeta($typeFull, "c_det"), new AE\ColumnMeta($typeFull, "c_rand", null, false));
AE\createTable($conn, $tbname, $colMetaArr);
$inputs = array(new AE\BindParamOption($inputValues[0], null, "SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY)"),
new AE\BindParamOption($inputValues[1], null, "SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY)"));
$r;
$stmt = AE\insertRow($conn, $tbname, array($colMetaArr[0]->colName => $inputs[0], $colMetaArr[1]->colName => $inputs[1]), $r, AE\INSERT_PREPARE_PARAMS);
// create a stored procedure and sql string for calling the stored procedure
$spname = 'selectAllColumns';
createProc($conn, $spname, "@c_det $typeFull OUTPUT, @c_rand $typeFull OUTPUT", "SELECT @c_det = c_det, @c_rand = c_rand FROM $tbname");
$sql = AE\getCallProcSqlPlaceholders($spname, 2);
// retrieve by specifying SQLSRV_SQLTYPE_BINARY(n) or SQLSRV_SQLTYPE_VARBINARY(n) as SQLSRV_PARAM_OUT or SQLSRV_PARAM_INOUT
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
foreach ($sqlTypes as $sqlType) {
$maxsqltype = strpos($sqlType, "max");
foreach ($sqltypeLengths as $n) {
$sqltypeconst;
$sqltypeFull;
if ($maxsqltype) {
$sqltypeconst = SQLSRV_SQLTYPE_VARBINARY('max');
$sqltypeFull = $sqlType;
} else {
$sqltypeconst = call_user_func($sqlType, $n);
$sqltypeFull = "$sqlType($n)";
}
$c_detOut = '';
$c_randOut = '';
$stmt = sqlsrv_prepare($conn, $sql, array(array(&$c_detOut, constant($dir), SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY), $sqltypeconst), array(&$c_randOut, constant($dir), SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY), $sqltypeconst)));
$r = sqlsrv_execute($stmt);
// check the case when SQLSRV_SQLTYPE length (n) is not the same as the column length (m)
// with AE: should not work
// without AE: should work, except when a SQLSRV_SQLTYPE_VARBINARY length (n) is less than a binary column length (m) for SQLSRV_PARAM_OUT
if (($n != $m || $maxsqltype || $maxcol) && !($maxcol && $maxsqltype)) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $typeFull to output $sqltypeFull should not be supported\n";
} else {
if (sqlsrv_errors()[0]['SQLSTATE'] != "22018") {
echo "AE: Conversion from $typeFull to output $sqltypeFull expects an operand type clash error, actual error is incorrect\n";
var_dump(sqlsrv_errors());
}
}
} else {
if (!AE\isColEncrypted() && strpos($sqltypeFull, "VARBINARY") !== false && $dataType == "binary" && $m > $n && strpos($sqltypeFull, "max") === false && $dir == "SQLSRV_PARAM_OUT") {
if ($r !== false) {
echo "Conversions from $typeFull to output $sqltypeFull should not be supported\n";
}
} else {
if ($r === false) {
if (strpos($sqltypeFull, "VARBINARY") !== false || $dataType != "binary" || $m <= $n) {
echo "Conversions from $typeFull to output $sqltypeFull should be supported\n";
}
}
if (trim($c_detOut) != $inputValues[0] || trim($c_randOut) != $inputValues[1]) {
echo "Conversion from $typeFull to output $sqltypeFull causes data corruption\n";
}
}
}
// check the case then SQLSRV_SQLTYPE length (n) is the same as the column length (m)
// should work with AE or non AE
} else {
if ($r === false) {
echo "Conversion from $typeFull to output $sqltypeFull should be supported\n";
var_dump(sqlsrv_errors());
} else {
if (trim($c_detOut) == $inputValues[0] && trim($c_randOut) == $inputValues[1]) {
echo "****Conversion from $typeFull to output $sqltypeFull is supported****\n";
} else {
echo "Conversion from $typeFull to output $sqltypeFull causes data corruption\n";
}
}
}
// cleanup
sqlsrv_free_stmt($stmt);
}
}
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
}
sqlsrv_close($conn);
?>
--EXPECT--
Testing binary(1):
Testing as SQLSRV_PARAM_OUT:
****Conversion from binary(1) to output SQLSRV_SQLTYPE_BINARY(1) is supported****
****Conversion from binary(1) to output SQLSRV_SQLTYPE_VARBINARY(1) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from binary(1) to output SQLSRV_SQLTYPE_BINARY(1) is supported****
****Conversion from binary(1) to output SQLSRV_SQLTYPE_VARBINARY(1) is supported****
Testing binary(8):
Testing as SQLSRV_PARAM_OUT:
****Conversion from binary(8) to output SQLSRV_SQLTYPE_BINARY(8) is supported****
****Conversion from binary(8) to output SQLSRV_SQLTYPE_VARBINARY(8) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from binary(8) to output SQLSRV_SQLTYPE_BINARY(8) is supported****
****Conversion from binary(8) to output SQLSRV_SQLTYPE_VARBINARY(8) is supported****
Testing binary(64):
Testing as SQLSRV_PARAM_OUT:
****Conversion from binary(64) to output SQLSRV_SQLTYPE_BINARY(64) is supported****
****Conversion from binary(64) to output SQLSRV_SQLTYPE_VARBINARY(64) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from binary(64) to output SQLSRV_SQLTYPE_BINARY(64) is supported****
****Conversion from binary(64) to output SQLSRV_SQLTYPE_VARBINARY(64) is supported****
Testing binary(512):
Testing as SQLSRV_PARAM_OUT:
****Conversion from binary(512) to output SQLSRV_SQLTYPE_BINARY(512) is supported****
****Conversion from binary(512) to output SQLSRV_SQLTYPE_VARBINARY(512) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from binary(512) to output SQLSRV_SQLTYPE_BINARY(512) is supported****
****Conversion from binary(512) to output SQLSRV_SQLTYPE_VARBINARY(512) is supported****
Testing binary(4000):
Testing as SQLSRV_PARAM_OUT:
****Conversion from binary(4000) to output SQLSRV_SQLTYPE_BINARY(4000) is supported****
****Conversion from binary(4000) to output SQLSRV_SQLTYPE_VARBINARY(4000) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from binary(4000) to output SQLSRV_SQLTYPE_BINARY(4000) is supported****
****Conversion from binary(4000) to output SQLSRV_SQLTYPE_VARBINARY(4000) is supported****
Testing varbinary(1):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varbinary(1) to output SQLSRV_SQLTYPE_BINARY(1) is supported****
****Conversion from varbinary(1) to output SQLSRV_SQLTYPE_VARBINARY(1) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varbinary(1) to output SQLSRV_SQLTYPE_BINARY(1) is supported****
****Conversion from varbinary(1) to output SQLSRV_SQLTYPE_VARBINARY(1) is supported****
Testing varbinary(8):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varbinary(8) to output SQLSRV_SQLTYPE_BINARY(8) is supported****
****Conversion from varbinary(8) to output SQLSRV_SQLTYPE_VARBINARY(8) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varbinary(8) to output SQLSRV_SQLTYPE_BINARY(8) is supported****
****Conversion from varbinary(8) to output SQLSRV_SQLTYPE_VARBINARY(8) is supported****
Testing varbinary(64):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varbinary(64) to output SQLSRV_SQLTYPE_BINARY(64) is supported****
****Conversion from varbinary(64) to output SQLSRV_SQLTYPE_VARBINARY(64) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varbinary(64) to output SQLSRV_SQLTYPE_BINARY(64) is supported****
****Conversion from varbinary(64) to output SQLSRV_SQLTYPE_VARBINARY(64) is supported****
Testing varbinary(512):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varbinary(512) to output SQLSRV_SQLTYPE_BINARY(512) is supported****
****Conversion from varbinary(512) to output SQLSRV_SQLTYPE_VARBINARY(512) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varbinary(512) to output SQLSRV_SQLTYPE_BINARY(512) is supported****
****Conversion from varbinary(512) to output SQLSRV_SQLTYPE_VARBINARY(512) is supported****
Testing varbinary(4000):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varbinary(4000) to output SQLSRV_SQLTYPE_BINARY(4000) is supported****
****Conversion from varbinary(4000) to output SQLSRV_SQLTYPE_VARBINARY(4000) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varbinary(4000) to output SQLSRV_SQLTYPE_BINARY(4000) is supported****
****Conversion from varbinary(4000) to output SQLSRV_SQLTYPE_VARBINARY(4000) is supported****
Testing varbinary(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
Testing varbinary(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
Testing varbinary(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
Testing varbinary(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
Testing varbinary(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****
****Conversion from varbinary(max) to output SQLSRV_SQLTYPE_VARBINARY('max') is supported****

View file

@ -0,0 +1,316 @@
--TEST--
Test for retrieving encrypted data of char types with different sizes as output parameters
--DESCRIPTION--
Test implicit conversions between different char types of different sizes
With Always Encrypted, implicit conversion works if:
1. From a char(m) column to a SQLSRV_SQLTYPE_CHAR(n) output parameter where m == n
2. From a char(m) column to a SQLSRV_SQLTYPE_VARCHAR(n) output parameter where m == n
3. From a varchar(m) column to a SQLSRV_SQLTYPE_CHAR(n) output parameter where m == n
4. From a varchar(m) column to a SQLSRV_SQLTYPE_VARCHAR(n) output parameter where m == n
Without AlwaysEncrypted, implicit conversion works if:
1. From a char(m) column to a SQLSRV_SQLTYPE_CHAR(n) output parameter where m, n == any value
2. From a char(m) column to a SQLSRV_SQLTYPE_VARCHAR(n) output parameter where m <= n (exclude SQLSRV_SQLTYPE_VARCHAR('max'))
3. From a varchar(m) column to a SQLSRV_SQLTYPE_CHAR(n) output parameter where m, n == any value
4. From a varchar(m) column to a SQLSRV_SQLTYPE_VARCHAR(n) output parameter where m, n == any value
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
--FILE--
<?php
require_once('MsCommon.inc');
$dataTypes = array("char", "varchar", "varchar(max)");
$lengths = array(1, 8, 64, 512, 4096, 8000);
$sqlTypes = array("SQLSRV_SQLTYPE_CHAR", "SQLSRV_SQLTYPE_VARCHAR", "SQLSRV_SQLTYPE_VARCHAR('max')");
$sqltypeLengths = $lengths;
$directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$inputValue = "d";
$conn = AE\connect();
foreach ($dataTypes as $dataType) {
$maxcol = strpos($dataType, "(max)");
foreach ($lengths as $m) {
if ($maxcol) {
$typeFull = $dataType;
} else {
$typeFull = "$dataType($m)";
}
echo "\nTesting $typeFull:\n";
// create and populate table containing char(m) or varchar(m) columns
$tbname = getTempTableName("test_" . str_replace(array('(', ')'), '', $dataType) . $m, false);
$colMetaArr = array(new AE\ColumnMeta($typeFull, "c1", null, false));
AE\createTable($conn, $tbname, $colMetaArr);
$stmt = AE\insertRow($conn, $tbname, array($colMetaArr[0]->colName => $inputValue));
// create a stored procedure and sql string for calling the stored procedure
$spname = 'selectAllColumns';
createProc($conn, $spname, "@c1 $typeFull OUTPUT", "SELECT @c1 = c1 FROM $tbname");
$sql = AE\getCallProcSqlPlaceholders($spname, 1);
// retrieve by specifying SQLSRV_SQLTYPE_CHAR(n) or SQLSRV_SQLTYPE_VARCHAR(n) as SQLSRV_PARAM_OUT or SQLSRV_PARAM_INOUT
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
foreach ($sqlTypes as $sqlType) {
$maxsqltype = strpos($sqlType, "max");
foreach ($sqltypeLengths as $n) {
$sqltypeconst;
$sqltypeFull;
if ($maxsqltype) {
$sqltypeconst = SQLSRV_SQLTYPE_VARCHAR('max');
$sqltypeFull = $sqlType;
} else {
$sqltypeconst = call_user_func($sqlType, $n);
$sqltypeFull = "$sqlType($n)";
}
$c1 = '';
$stmt = sqlsrv_prepare($conn, $sql, array(array(&$c1, constant($dir), null, $sqltypeconst)));
$r = sqlsrv_execute($stmt);
// check the case when SQLSRV_SQLTYPE length (n) is not the same as the column length (m)
// with AE: should not work
// without AE: should work, except when a SQLSRV_SQLTYPE_VARCHAR length (n) is less than a char column length (m)
if (($n != $m || $maxsqltype || $maxcol) && !($maxcol && $maxsqltype)) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $typeFull to output $sqltypeFull should not be supported\n";
} else {
if (sqlsrv_errors()[0]['SQLSTATE'] != "22018") {
echo "AE: Conversion from $typeFull to output $sqltypeFull expects an operand type clash error, actual error is incorrect\n";
var_dump(sqlsrv_errors());
}
}
} else {
if (!AE\isColEncrypted() && strpos($sqltypeFull, "VARCHAR") !== false && $dataType == "char" && $m > $n && strpos($sqltypeFull, "max") === false && $dir == "SQLSRV_PARAM_OUT") {
if ($r !== false) {
echo "Conversions from $typeFull to output $sqltypeFull should not be supported\n";
var_dump($c1);
}
} else {
if ($r === false) {
if (strpos($sqltypeFull, "VARCHAR") !== false || $dataType != "char" || $m <= $n) {
echo "Conversions from $typeFull to output $sqltypeFull should be supported\n";
}
}
if (trim($c1) != $inputValue) {
echo "Conversion from $typeFull to output $sqltypeFull causes data corruption\n";
}
}
}
// check the case then SQLSRV_SQLTYPE length (n) is the same as the column length (m)
// should work with AE or non AE
} else {
if ($r === false) {
echo "Conversion from $typeFull to output $sqltypeFull should be supported\n";
} else {
if (trim($c1) == $inputValue) {
echo "****Conversion from $typeFull to output $sqltypeFull is supported****\n";
} else {
echo "Conversion from $typeFull to output $sqltypeFull causes data corruption\n";
}
}
}
// cleanup
sqlsrv_free_stmt($stmt);
}
}
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
}
sqlsrv_close($conn);
?>
--EXPECT--
Testing char(1):
Testing as SQLSRV_PARAM_OUT:
****Conversion from char(1) to output SQLSRV_SQLTYPE_CHAR(1) is supported****
****Conversion from char(1) to output SQLSRV_SQLTYPE_VARCHAR(1) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from char(1) to output SQLSRV_SQLTYPE_CHAR(1) is supported****
****Conversion from char(1) to output SQLSRV_SQLTYPE_VARCHAR(1) is supported****
Testing char(8):
Testing as SQLSRV_PARAM_OUT:
****Conversion from char(8) to output SQLSRV_SQLTYPE_CHAR(8) is supported****
****Conversion from char(8) to output SQLSRV_SQLTYPE_VARCHAR(8) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from char(8) to output SQLSRV_SQLTYPE_CHAR(8) is supported****
****Conversion from char(8) to output SQLSRV_SQLTYPE_VARCHAR(8) is supported****
Testing char(64):
Testing as SQLSRV_PARAM_OUT:
****Conversion from char(64) to output SQLSRV_SQLTYPE_CHAR(64) is supported****
****Conversion from char(64) to output SQLSRV_SQLTYPE_VARCHAR(64) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from char(64) to output SQLSRV_SQLTYPE_CHAR(64) is supported****
****Conversion from char(64) to output SQLSRV_SQLTYPE_VARCHAR(64) is supported****
Testing char(512):
Testing as SQLSRV_PARAM_OUT:
****Conversion from char(512) to output SQLSRV_SQLTYPE_CHAR(512) is supported****
****Conversion from char(512) to output SQLSRV_SQLTYPE_VARCHAR(512) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from char(512) to output SQLSRV_SQLTYPE_CHAR(512) is supported****
****Conversion from char(512) to output SQLSRV_SQLTYPE_VARCHAR(512) is supported****
Testing char(4096):
Testing as SQLSRV_PARAM_OUT:
****Conversion from char(4096) to output SQLSRV_SQLTYPE_CHAR(4096) is supported****
****Conversion from char(4096) to output SQLSRV_SQLTYPE_VARCHAR(4096) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from char(4096) to output SQLSRV_SQLTYPE_CHAR(4096) is supported****
****Conversion from char(4096) to output SQLSRV_SQLTYPE_VARCHAR(4096) is supported****
Testing char(8000):
Testing as SQLSRV_PARAM_OUT:
****Conversion from char(8000) to output SQLSRV_SQLTYPE_CHAR(8000) is supported****
****Conversion from char(8000) to output SQLSRV_SQLTYPE_VARCHAR(8000) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from char(8000) to output SQLSRV_SQLTYPE_CHAR(8000) is supported****
****Conversion from char(8000) to output SQLSRV_SQLTYPE_VARCHAR(8000) is supported****
Testing varchar(1):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(1) to output SQLSRV_SQLTYPE_CHAR(1) is supported****
****Conversion from varchar(1) to output SQLSRV_SQLTYPE_VARCHAR(1) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(1) to output SQLSRV_SQLTYPE_CHAR(1) is supported****
****Conversion from varchar(1) to output SQLSRV_SQLTYPE_VARCHAR(1) is supported****
Testing varchar(8):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(8) to output SQLSRV_SQLTYPE_CHAR(8) is supported****
****Conversion from varchar(8) to output SQLSRV_SQLTYPE_VARCHAR(8) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(8) to output SQLSRV_SQLTYPE_CHAR(8) is supported****
****Conversion from varchar(8) to output SQLSRV_SQLTYPE_VARCHAR(8) is supported****
Testing varchar(64):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(64) to output SQLSRV_SQLTYPE_CHAR(64) is supported****
****Conversion from varchar(64) to output SQLSRV_SQLTYPE_VARCHAR(64) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(64) to output SQLSRV_SQLTYPE_CHAR(64) is supported****
****Conversion from varchar(64) to output SQLSRV_SQLTYPE_VARCHAR(64) is supported****
Testing varchar(512):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(512) to output SQLSRV_SQLTYPE_CHAR(512) is supported****
****Conversion from varchar(512) to output SQLSRV_SQLTYPE_VARCHAR(512) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(512) to output SQLSRV_SQLTYPE_CHAR(512) is supported****
****Conversion from varchar(512) to output SQLSRV_SQLTYPE_VARCHAR(512) is supported****
Testing varchar(4096):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(4096) to output SQLSRV_SQLTYPE_CHAR(4096) is supported****
****Conversion from varchar(4096) to output SQLSRV_SQLTYPE_VARCHAR(4096) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(4096) to output SQLSRV_SQLTYPE_CHAR(4096) is supported****
****Conversion from varchar(4096) to output SQLSRV_SQLTYPE_VARCHAR(4096) is supported****
Testing varchar(8000):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(8000) to output SQLSRV_SQLTYPE_CHAR(8000) is supported****
****Conversion from varchar(8000) to output SQLSRV_SQLTYPE_VARCHAR(8000) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(8000) to output SQLSRV_SQLTYPE_CHAR(8000) is supported****
****Conversion from varchar(8000) to output SQLSRV_SQLTYPE_VARCHAR(8000) is supported****
Testing varchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing varchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing varchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing varchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing varchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing varchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****
****Conversion from varchar(max) to output SQLSRV_SQLTYPE_VARCHAR('max') is supported****

View file

@ -0,0 +1,265 @@
--TEST--
Test for retrieving encrypted data of decimal types with different precisions and scales as output parameters
--DESCRIPTION--
Test implicit conversions between different precisions and scales
With Always Encrypted, no implicit conversion works for decimal datatypes, the precision and scale specified in the SQLSRV_SQLTYPE must be identical to the precision and scale defined in the column
Without AlwaysEncrypted, implicit conversion between precisions or scales works if:
1. From a decimal(m1, m2) column to a SQLSRV_SQLTYPE_DECIMAL(n1, n2) output parameter where n1 - n2 >= m1 - m2
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
--FILE--
<?php
require_once('MsCommon.inc');
$dataTypes = array("decimal", "numeric");
$precisions = array(/*1 => array(0, 1),
4 => array(0, 1, 4),
16 => array(0, 1, 4, 16),*/
19 => array(/*0,*/ 1, 4, 16, 19),
38 => array(/*0,*/ 1, 4, 16, 37/*,38*/));
$sqlTypes = array("SQLSRV_SQLTYPE_DECIMAL", "SQLSRV_SQLTYPE_NUMERIC");
$sqltypePrecisions = $precisions;
$inputValuesInit = array(92233720368547758089223372036854775808, -92233720368547758089223372036854775808);
$maxInPrecision = 38;
$directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$conn = AE\connect();
foreach ($dataTypes as $dataType) {
foreach ($precisions as $m1 => $inScales) {
foreach ($inScales as $m2) {
// change the number of integers in the input values to be $m1 - $m2
$precDiff = $maxInPrecision - ($m1 - $m2);
$inputValues = $inputValuesInit;
foreach ($inputValues as &$inputValue) {
$inputValue = $inputValue / pow(10, $precDiff);
}
$typeFull = "$dataType($m1, $m2)";
echo "\nTesting $typeFull:\n";
// create and populate table containing decimal(m1, m2) or numeric(m1, m2) columns
$tbname = "test_" . $dataType . $m1 . $m2;
$colMetaArr = array(new AE\ColumnMeta($typeFull, "c_det"), new AE\ColumnMeta($typeFull, "c_rand", null, false));
AE\createTable($conn, $tbname, $colMetaArr);
$stmt = AE\insertRow($conn, $tbname, array($colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1]));
// create a stored procedure and sql string for calling the stored procedure
$spname = 'selectAllColumns';
createProc($conn, $spname, "@c_det $typeFull OUTPUT, @c_rand $typeFull OUTPUT", "SELECT @c_det = c_det, @c_rand = c_rand FROM $tbname");
$sql = AE\getCallProcSqlPlaceholders($spname, 2);
// retrieve by specifying SQLSRV_SQLTYPE_DECIMAL(n1, n2) or SQLSRV_SQLTYPE_NUMERIC(n1, n2) as SQLSRV_PARAM_OUT or SQLSRV_PARAM_INOUT
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
foreach ($sqlTypes as $sqlType) {
foreach ($sqltypePrecisions as $n1 => $sqltypeScales) {
foreach ($sqltypeScales as $n2) {
// compute the epsilon for comparing doubles
// float in PHP only has a precision of roughtly 14 digits: http://php.net/manual/en/language.types.float.php
// the smaller precision and scale (n1 and n2 vs m1 and m2) take precedence
$epsilon;
$smallerprec = min($m1, $n1);
$smallerscale = min($m2, $n2);
if ($smallerprec < 14) {
$epsilon = pow(10, $smallerscale * -1);
} else {
$numint = $smallerprec - $smallerscale;
if ($numint < 14) {
$epsilon = pow(10, (14 - $numint) * -1);
} else {
$epsilon = pow(10, $numint - 14);
}
}
$sqltypeFull = "$sqlType($n1, $n2)";
$sqltypeconst = call_user_func($sqlType, $n1, $n2);
$c_detOut = 0.0;
$c_randOut = 0.0;
$stmt = sqlsrv_prepare($conn, $sql, array(array(&$c_detOut, constant($dir), null, $sqltypeconst), array(&$c_randOut, constant($dir), null, $sqltypeconst)));
$r = sqlsrv_execute($stmt);
// check the case when the SQLSRV_SQLTYPE precision (n1) is not the same as the column precision (m1)
// or the SQLSRV_SQLTYPE scale (n2) is not the same as the column precision (m2)
// with AE: should not work
// without AE: should not work if n1 - n2 < m1 - m2
if ($n1 != $m1 || $n2 != $m2) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $typeFull to output $sqltypeFull should not be supported\n";
} else {
if (sqlsrv_errors()[0]['SQLSTATE'] != "22018") {
echo "AE: Conversion from $typeFull to output $sqltypeFull expects an operand type clash error, actual error is incorrect\n";
var_dump(sqlsrv_errors());
}
}
} else {
if ($n1 - $n2 < $m1 - $m2) {
if ($r !== false) {
echo "Conversion from $typeFull to output $sqltypeFull should not be supported\n";
}
} else {
if ($r === false) {
echo "Conversion from $typeFull to output $sqltypeFull should be supported\n";
} else {
if (abs($c_detOut - $inputValues[0]) > $epsilon || abs($c_randOut - $inputValues[1]) > $epsilon) {
echo "Conversion from $typeFull to output $sqltypeFull causes data corruption\n";
}
}
}
}
// check the case when the SQLSRV_SQLTYPE precision (n1) and scale (n2) are the same as the column precision (m1) and scale (m2)
// should work with AE or non AE
} else {
if ($r === false) {
echo "Conversion from $typeFull to output $sqltypeFull should be supported\n";
} else {
if (abs($c_detOut - $inputValues[0]) < $epsilon && abs($c_randOut - $inputValues[1]) < $epsilon) {
echo "****Conversion from $typeFull to output $sqltypeFull is supported****\n";
} else {
echo "Conversion from $typeFull to output $sqltypeFull causes data corruption\n";
}
}
}
// cleanup
sqlsrv_free_stmt($stmt);
}
}
}
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
}
}
sqlsrv_close($conn);
?>
--EXPECT--
Testing decimal(19, 1):
Testing as SQLSRV_PARAM_OUT:
****Conversion from decimal(19, 1) to output SQLSRV_SQLTYPE_DECIMAL(19, 1) is supported****
****Conversion from decimal(19, 1) to output SQLSRV_SQLTYPE_NUMERIC(19, 1) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from decimal(19, 1) to output SQLSRV_SQLTYPE_DECIMAL(19, 1) is supported****
****Conversion from decimal(19, 1) to output SQLSRV_SQLTYPE_NUMERIC(19, 1) is supported****
Testing decimal(19, 4):
Testing as SQLSRV_PARAM_OUT:
****Conversion from decimal(19, 4) to output SQLSRV_SQLTYPE_DECIMAL(19, 4) is supported****
****Conversion from decimal(19, 4) to output SQLSRV_SQLTYPE_NUMERIC(19, 4) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from decimal(19, 4) to output SQLSRV_SQLTYPE_DECIMAL(19, 4) is supported****
****Conversion from decimal(19, 4) to output SQLSRV_SQLTYPE_NUMERIC(19, 4) is supported****
Testing decimal(19, 16):
Testing as SQLSRV_PARAM_OUT:
****Conversion from decimal(19, 16) to output SQLSRV_SQLTYPE_DECIMAL(19, 16) is supported****
****Conversion from decimal(19, 16) to output SQLSRV_SQLTYPE_NUMERIC(19, 16) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from decimal(19, 16) to output SQLSRV_SQLTYPE_DECIMAL(19, 16) is supported****
****Conversion from decimal(19, 16) to output SQLSRV_SQLTYPE_NUMERIC(19, 16) is supported****
Testing decimal(19, 19):
Testing as SQLSRV_PARAM_OUT:
****Conversion from decimal(19, 19) to output SQLSRV_SQLTYPE_DECIMAL(19, 19) is supported****
****Conversion from decimal(19, 19) to output SQLSRV_SQLTYPE_NUMERIC(19, 19) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from decimal(19, 19) to output SQLSRV_SQLTYPE_DECIMAL(19, 19) is supported****
****Conversion from decimal(19, 19) to output SQLSRV_SQLTYPE_NUMERIC(19, 19) is supported****
Testing decimal(38, 1):
Testing as SQLSRV_PARAM_OUT:
****Conversion from decimal(38, 1) to output SQLSRV_SQLTYPE_DECIMAL(38, 1) is supported****
****Conversion from decimal(38, 1) to output SQLSRV_SQLTYPE_NUMERIC(38, 1) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from decimal(38, 1) to output SQLSRV_SQLTYPE_DECIMAL(38, 1) is supported****
****Conversion from decimal(38, 1) to output SQLSRV_SQLTYPE_NUMERIC(38, 1) is supported****
Testing decimal(38, 4):
Testing as SQLSRV_PARAM_OUT:
****Conversion from decimal(38, 4) to output SQLSRV_SQLTYPE_DECIMAL(38, 4) is supported****
****Conversion from decimal(38, 4) to output SQLSRV_SQLTYPE_NUMERIC(38, 4) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from decimal(38, 4) to output SQLSRV_SQLTYPE_DECIMAL(38, 4) is supported****
****Conversion from decimal(38, 4) to output SQLSRV_SQLTYPE_NUMERIC(38, 4) is supported****
Testing decimal(38, 16):
Testing as SQLSRV_PARAM_OUT:
****Conversion from decimal(38, 16) to output SQLSRV_SQLTYPE_DECIMAL(38, 16) is supported****
****Conversion from decimal(38, 16) to output SQLSRV_SQLTYPE_NUMERIC(38, 16) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from decimal(38, 16) to output SQLSRV_SQLTYPE_DECIMAL(38, 16) is supported****
****Conversion from decimal(38, 16) to output SQLSRV_SQLTYPE_NUMERIC(38, 16) is supported****
Testing decimal(38, 37):
Testing as SQLSRV_PARAM_OUT:
****Conversion from decimal(38, 37) to output SQLSRV_SQLTYPE_DECIMAL(38, 37) is supported****
****Conversion from decimal(38, 37) to output SQLSRV_SQLTYPE_NUMERIC(38, 37) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from decimal(38, 37) to output SQLSRV_SQLTYPE_DECIMAL(38, 37) is supported****
****Conversion from decimal(38, 37) to output SQLSRV_SQLTYPE_NUMERIC(38, 37) is supported****
Testing numeric(19, 1):
Testing as SQLSRV_PARAM_OUT:
****Conversion from numeric(19, 1) to output SQLSRV_SQLTYPE_DECIMAL(19, 1) is supported****
****Conversion from numeric(19, 1) to output SQLSRV_SQLTYPE_NUMERIC(19, 1) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from numeric(19, 1) to output SQLSRV_SQLTYPE_DECIMAL(19, 1) is supported****
****Conversion from numeric(19, 1) to output SQLSRV_SQLTYPE_NUMERIC(19, 1) is supported****
Testing numeric(19, 4):
Testing as SQLSRV_PARAM_OUT:
****Conversion from numeric(19, 4) to output SQLSRV_SQLTYPE_DECIMAL(19, 4) is supported****
****Conversion from numeric(19, 4) to output SQLSRV_SQLTYPE_NUMERIC(19, 4) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from numeric(19, 4) to output SQLSRV_SQLTYPE_DECIMAL(19, 4) is supported****
****Conversion from numeric(19, 4) to output SQLSRV_SQLTYPE_NUMERIC(19, 4) is supported****
Testing numeric(19, 16):
Testing as SQLSRV_PARAM_OUT:
****Conversion from numeric(19, 16) to output SQLSRV_SQLTYPE_DECIMAL(19, 16) is supported****
****Conversion from numeric(19, 16) to output SQLSRV_SQLTYPE_NUMERIC(19, 16) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from numeric(19, 16) to output SQLSRV_SQLTYPE_DECIMAL(19, 16) is supported****
****Conversion from numeric(19, 16) to output SQLSRV_SQLTYPE_NUMERIC(19, 16) is supported****
Testing numeric(19, 19):
Testing as SQLSRV_PARAM_OUT:
****Conversion from numeric(19, 19) to output SQLSRV_SQLTYPE_DECIMAL(19, 19) is supported****
****Conversion from numeric(19, 19) to output SQLSRV_SQLTYPE_NUMERIC(19, 19) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from numeric(19, 19) to output SQLSRV_SQLTYPE_DECIMAL(19, 19) is supported****
****Conversion from numeric(19, 19) to output SQLSRV_SQLTYPE_NUMERIC(19, 19) is supported****
Testing numeric(38, 1):
Testing as SQLSRV_PARAM_OUT:
****Conversion from numeric(38, 1) to output SQLSRV_SQLTYPE_DECIMAL(38, 1) is supported****
****Conversion from numeric(38, 1) to output SQLSRV_SQLTYPE_NUMERIC(38, 1) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from numeric(38, 1) to output SQLSRV_SQLTYPE_DECIMAL(38, 1) is supported****
****Conversion from numeric(38, 1) to output SQLSRV_SQLTYPE_NUMERIC(38, 1) is supported****
Testing numeric(38, 4):
Testing as SQLSRV_PARAM_OUT:
****Conversion from numeric(38, 4) to output SQLSRV_SQLTYPE_DECIMAL(38, 4) is supported****
****Conversion from numeric(38, 4) to output SQLSRV_SQLTYPE_NUMERIC(38, 4) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from numeric(38, 4) to output SQLSRV_SQLTYPE_DECIMAL(38, 4) is supported****
****Conversion from numeric(38, 4) to output SQLSRV_SQLTYPE_NUMERIC(38, 4) is supported****
Testing numeric(38, 16):
Testing as SQLSRV_PARAM_OUT:
****Conversion from numeric(38, 16) to output SQLSRV_SQLTYPE_DECIMAL(38, 16) is supported****
****Conversion from numeric(38, 16) to output SQLSRV_SQLTYPE_NUMERIC(38, 16) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from numeric(38, 16) to output SQLSRV_SQLTYPE_DECIMAL(38, 16) is supported****
****Conversion from numeric(38, 16) to output SQLSRV_SQLTYPE_NUMERIC(38, 16) is supported****
Testing numeric(38, 37):
Testing as SQLSRV_PARAM_OUT:
****Conversion from numeric(38, 37) to output SQLSRV_SQLTYPE_DECIMAL(38, 37) is supported****
****Conversion from numeric(38, 37) to output SQLSRV_SQLTYPE_NUMERIC(38, 37) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from numeric(38, 37) to output SQLSRV_SQLTYPE_DECIMAL(38, 37) is supported****
****Conversion from numeric(38, 37) to output SQLSRV_SQLTYPE_NUMERIC(38, 37) is supported****

View file

@ -0,0 +1,125 @@
--TEST--
Test for retrieving encrypted data of float types with different number of bits as output parameters
--DESCRIPTION--
Test implicit conversions between different number of bits
With Always Encrypted, implicit conversion works if:
1. From a float(m) column to a SQLSRV_SQLTYPE_FLOAT output parameter where m > 24
Without Always Encrypted, implicit conversion between different number of bits works
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
--FILE--
<?php
require_once('MsCommon.inc');
$dataType = "float";
$bits = array(1, 12, 24, 36, 53);
$sqlType = "SQLSRV_SQLTYPE_FLOAT";
$inputValues = array(9223372036854775808.9223372036854775808, -9223372036854775808.9223372036854775808);
$directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$epsilon = 100000;
$conn = AE\connect();
foreach ($bits as $m) {
$typeFull = "$dataType($m)";
echo "\nTesting $typeFull:\n";
// create and populate table containing float(m) columns
$tbname = "test_" . $dataType . $m;
$colMetaArr = array(new AE\ColumnMeta($typeFull, "c_det"), new AE\ColumnMeta($typeFull, "c_rand", null, false));
AE\createTable($conn, $tbname, $colMetaArr);
$stmt = AE\insertRow($conn, $tbname, array($colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1]));
// create a stored procedure and sql string for calling the stored procedure
$spname = 'selectAllColumns';
createProc($conn, $spname, "@c_det $typeFull OUTPUT, @c_rand $typeFull OUTPUT", "SELECT @c_det = c_det, @c_rand = c_rand FROM $tbname");
$sql = AE\getCallProcSqlPlaceholders($spname, 2);
// retrieve by specifying SQLSRV_SQLTYPE_FLOAT as SQLSRV_PARAM_OUT or SQLSRV_PARAM_INOUT
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
$c_detOut = 0.0;
$c_randOut = 0.0;
$stmt = sqlsrv_prepare($conn, $sql, array(array(&$c_detOut, constant($dir), null, constant($sqlType)), array(&$c_randOut, constant($dir), null, constant($sqlType))));
$r = sqlsrv_execute($stmt);
// check the case when the column number of bits is less than 25
// when the number of bits is between 1 and 24, it corresponds to a storage size of 4 bytes
// when the number of bits is between 25 and 53, it corresponds to a storage size of 8 bytes
// with AE: should not work because SQLSRV_SQLTYPE_FLOAT maps to float(53) and conversion from a larger float to a smaller float is not supported
// without AE: should work
if ($m < 25) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion between $typeFull to output $sqlType should not be supported\n";
} else {
if (sqlsrv_errors()[0]['SQLSTATE'] != "22018") {
echo "AE: Conversion from $typeFull to output $sqlType expects an operand type clash error, actual error is incorrect\n";
var_dump(sqlsrv_errors());
} else {
echo "Test successfully done\n";
}
}
} else {
if ($r === false) {
echo "Conversion from $typeFull to output $sqlType should be supported\n";
} else {
if (abs($c_detOut - $inputValues[0]) > $epsilon || abs($c_randOut - $inputValues[1]) > $epsilon) {
echo "Conversion from $typeFull to output $sqlType causes data corruption\n";
} else {
echo "Test successfully done\n";
}
}
}
// check the case when the column number of bits 25 or more
// should work with or without AE
} else {
if ($r === false) {
echo "Conversion from $typeFull to output $sqlType should be supported\n";
} else {
if (abs($c_detOut - $inputValues[0]) < $epsilon && abs($c_randOut - $inputValues[1]) < $epsilon) {
echo "****Conversion from $typeFull to output $sqlType is supported****\n";
} else {
echo "Conversion from $typeFull to output $sqlType causes data corruption\n";
}
}
}
// cleanup
sqlsrv_free_stmt($stmt);
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
sqlsrv_close($conn);
?>
--EXPECT--
Testing float(1):
Testing as SQLSRV_PARAM_OUT:
Test successfully done
Testing as SQLSRV_PARAM_INOUT:
Test successfully done
Testing float(12):
Testing as SQLSRV_PARAM_OUT:
Test successfully done
Testing as SQLSRV_PARAM_INOUT:
Test successfully done
Testing float(24):
Testing as SQLSRV_PARAM_OUT:
Test successfully done
Testing as SQLSRV_PARAM_INOUT:
Test successfully done
Testing float(36):
Testing as SQLSRV_PARAM_OUT:
****Conversion from float(36) to output SQLSRV_SQLTYPE_FLOAT is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from float(36) to output SQLSRV_SQLTYPE_FLOAT is supported****
Testing float(53):
Testing as SQLSRV_PARAM_OUT:
****Conversion from float(53) to output SQLSRV_SQLTYPE_FLOAT is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from float(53) to output SQLSRV_SQLTYPE_FLOAT is supported****

View file

@ -0,0 +1,113 @@
--TEST--
Test for retrieving encrypted data of int types as output parameters
--DESCRIPTION--
Test implicit conversions between different integer types
With Always Encrypted, implicit conversion works if the column type and the SQLSRV_SQLTYPE are the same
Without AlwaysEncrypted, implicit conversion between different integer types works
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
--FILE--
<?php
require_once('MsCommon.inc');
$dataTypes = array("bit", "tinyint", "smallint", "int", "bigint");
$sqlTypes = array("SQLSRV_SQLTYPE_BIT", "SQLSRV_SQLTYPE_TINYINT", "SQLSRV_SQLTYPE_SMALLINT", "SQLSRV_SQLTYPE_INT", "SQLSRV_SQLTYPE_BIGINT");
$directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$inputValues = array(1, 0);
$conn = AE\connect();
foreach ($dataTypes as $dataType) {
echo "\nTesting $dataType:\n";
// create and populate table containing bit, tinyint, smallint, int, or bigint columns
$tbname = "test_" . $dataType;
$colMetaArr = array( new AE\ColumnMeta($dataType, "c_det"), new AE\ColumnMeta($dataType, "c_rand", null, false));
AE\createTable($conn, $tbname, $colMetaArr);
$stmt = AE\insertRow($conn, $tbname, array($colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1]));
// create a stored procedure and sql string for calling the stored procedure
$spname = 'selectAllColumns';
createProc($conn, $spname, "@c_det $dataType OUTPUT, @c_rand $dataType OUTPUT", "SELECT @c_det = c_det, @c_rand = c_rand FROM $tbname");
$sql = AE\getCallProcSqlPlaceholders($spname, 2);
// retrieve by specifying different SQLSRV_SQLTYPE ingeter constants as SQLSRV_PARAM_OUT or SQLSRV_PARAM_INOUT
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
foreach ($sqlTypes as $sqlType) {
$c_detOut = 0;
$c_randOut = 0;
$stmt = sqlsrv_prepare($conn, $sql, array(array(&$c_detOut, constant($dir), null, constant($sqlType)), array(&$c_randOut, constant($dir), null, constant($sqlType))));
$r = sqlsrv_execute($stmt);
// check the case if the column type is not the same as the SQLSRV_SQLTYPE
if ($sqlType != "SQLSRV_SQLTYPE_" . strtoupper($dataType)) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $dataType to output $sqlType should not be supported\n";
} else {
if (sqlsrv_errors()[0]['SQLSTATE'] != "22018") {
echo "AE: Conversion from $dataType to output $sqlType expects an operand type clash error, actual error is incorrect\n";
var_dump(sqlsrv_errors());
}
}
} else {
if ($r === false) {
echo "Conversion from $dataType to output $sqlType should be supported\n";
} else {
if ($c_detOut != $inputValues[0] || $c_randOut != $inputValues[1]) {
echo "Conversion from $dataType to output $sqlType causes data corruption\n";
}
}
}
// check the case if the column type is the same as the SQLSRV_SQLTYPE
} else {
if ($r === false) {
echo "Conversion from $dataType to output $sqlType should be supported\n";
} else {
if ($c_detOut == $inputValues[0] && $c_randOut == $inputValues[1]) {
echo "****Conversion from $dataType to output $sqlType is supported****\n";
} else {
echo "Conversion from $dataType to output $sqlType causes data corruption\n";
}
}
}
// cleanup
sqlsrv_free_stmt($stmt);
}
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
sqlsrv_close($conn);
?>
--EXPECT--
Testing bit:
Testing as SQLSRV_PARAM_OUT:
****Conversion from bit to output SQLSRV_SQLTYPE_BIT is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from bit to output SQLSRV_SQLTYPE_BIT is supported****
Testing tinyint:
Testing as SQLSRV_PARAM_OUT:
****Conversion from tinyint to output SQLSRV_SQLTYPE_TINYINT is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from tinyint to output SQLSRV_SQLTYPE_TINYINT is supported****
Testing smallint:
Testing as SQLSRV_PARAM_OUT:
****Conversion from smallint to output SQLSRV_SQLTYPE_SMALLINT is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from smallint to output SQLSRV_SQLTYPE_SMALLINT is supported****
Testing int:
Testing as SQLSRV_PARAM_OUT:
****Conversion from int to output SQLSRV_SQLTYPE_INT is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from int to output SQLSRV_SQLTYPE_INT is supported****
Testing bigint:
Testing as SQLSRV_PARAM_OUT:
****Conversion from bigint to output SQLSRV_SQLTYPE_BIGINT is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from bigint to output SQLSRV_SQLTYPE_BIGINT is supported****

View file

@ -0,0 +1,273 @@
--TEST--
Test for retrieving encrypted data of nchar types with different sizes as output parameters
--DESCRIPTION--
Test implicit conversions between different nchar types of different sizes
With Always Encrypted, implicit conversion works if:
1. From a nchar(m) column to a SQLSRV_SQLTYPE_NCHAR(n) output parameter where m == n
2. From a nchar(m) column to a SQLSRV_SQLTYPE_NVARCHAR(n) output parameter where m == n
3. From a nvarchar(m) column to a SQLSRV_SQLTYPE_NCHAR(n) output parameter where m == n
4. From a nvarchar(m) column to a SQLSRV_SQLTYPE_NVARCHAR(n) output parameter where m == n
Without AlwaysEncrypted, implicit conversion works if:
1. From a nchar(m) column to a SQLSRV_SQLTYPE_NCHAR(n) output parameter where m, n == any value
2. From a nchar(m) column to a SQLSRV_SQLTYPE_NVARCHAR(n) output parameter where m <= n (exclude SQLSRV_SQLTYPE_NVARCHAR('max'))
3. From a nvarchar(m) column to a SQLSRV_SQLTYPE_NCHAR(n) output parameter where m, n == any value
4. From a nvarchar(m) column to a SQLSRV_SQLTYPE_NVARCHAR(n) output parameter where m, n == any value
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
--FILE--
<?php
require_once('MsCommon.inc');
$dataTypes = array("nchar", "nvarchar", "nvarchar(max)");
$lengths = array(1, 8, 64, 512, 4000);
$sqlTypes = array("SQLSRV_SQLTYPE_NCHAR", "SQLSRV_SQLTYPE_NVARCHAR", "SQLSRV_SQLTYPE_NVARCHAR('max')");
$sqltypeLengths = $lengths;
$directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$inputValue = "d";
$conn = AE\connect();
foreach ($dataTypes as $dataType) {
$maxcol = strpos($dataType, "(max)");
foreach ($lengths as $m) {
if ($maxcol) {
$typeFull = $dataType;
} else {
$typeFull = "$dataType($m)";
}
echo "\nTesting $typeFull:\n";
// create and populate table containing nchar(m) or nvarchar(m) columns
$tbname = "test_" . str_replace(array('(', ')'), '', $dataType) . $m;
$colMetaArr = array(new AE\ColumnMeta($typeFull, "c1", null, false));
AE\createTable($conn, $tbname, $colMetaArr);
$stmt = AE\insertRow($conn, $tbname, array($colMetaArr[0]->colName => $inputValue));
// create a stored procedure and sql string for calling the stored procedure
$spname = 'selectAllColumns';
createProc($conn, $spname, "@c1 $typeFull OUTPUT", "SELECT @c1 = c1 FROM $tbname");
$sql = AE\getCallProcSqlPlaceholders($spname, 1);
// retrieve by specifying SQLSRV_SQLTYPE_NCHAR(n) or SQLSRV_SQLTYPE_NVARCHAR(n) as SQLSRV_PARAM_OUT or SQLSRV_PARAM_INOUT
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
foreach ($sqlTypes as $sqlType) {
$maxsqltype = strpos($sqlType, "max");
foreach ($sqltypeLengths as $n) {
$sqltypeconst;
$sqltypeFull;
if ($maxsqltype) {
$sqltypeconst = SQLSRV_SQLTYPE_NVARCHAR('max');
$sqltypeFull = $sqlType;
} else {
$sqltypeconst = call_user_func($sqlType, $n);
$sqltypeFull = "$sqlType($n)";
}
$c1 = '';
$stmt = sqlsrv_prepare($conn, $sql, array(array(&$c1, constant($dir), null, $sqltypeconst)));
$r = sqlsrv_execute($stmt);
// check the case when SQLSRV_SQLTYPE length (n) is not the same as the column length (m)
// with AE: should not work
// without AE: should work, except when a SQLSRV_SQLTYPE_NVARCHAR length (n) is less than a nchar column length (m)
if (($n != $m || $maxsqltype || $maxcol) && !($maxcol && $maxsqltype)) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $typeFull to output $sqltypeFull should not be supported\n";
} else {
if (sqlsrv_errors()[0]['SQLSTATE'] != "22018") {
echo "AE: Conversion from $typeFull to output $sqltypeFull expects an operand type clash error, actual error is incorrect\n";
var_dump(sqlsrv_errors());
}
}
} else {
if (!AE\isColEncrypted() && strpos($sqltypeFull, "NVARCHAR") !== false && $dataType == "nchar" && $m > $n && strpos($sqltypeFull, "max") === false && $dir == "SQLSRV_PARAM_OUT") {
if ($r !== false) {
echo "Conversions from $typeFull to output $sqltypeFull should not be supported\n";
}
} else {
if ($r === false) {
if (strpos($sqltypeFull, "NVARCHAR") !== false || $dataType != "nchar" || $m <= $n) {
echo "Conversions from $typeFull to output $sqltypeFull should be supported\n";
}
}
if (trim($c1) != $inputValue) {
echo "Conversion from $typeFull to output $sqltypeFull causes data corruption\n";
}
}
}
// check the case then SQLSRV_SQLTYPE length (n) is the same as the column length (m)
// should work with AE or non AE
} else {
if ($r === false) {
echo "Conversion from $typeFull to output $sqltypeFull should be supported\n";
} else {
if (trim($c1) == $inputValue) {
echo "****Conversion from $typeFull to output $sqltypeFull is supported****\n";
} else {
echo "Conversion from $typeFull to output $sqltypeFull causes data corruption\n";
}
}
}
// cleanup
sqlsrv_free_stmt($stmt);
}
}
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
}
sqlsrv_close($conn);
?>
--EXPECT--
Testing nchar(1):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nchar(1) to output SQLSRV_SQLTYPE_NCHAR(1) is supported****
****Conversion from nchar(1) to output SQLSRV_SQLTYPE_NVARCHAR(1) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nchar(1) to output SQLSRV_SQLTYPE_NCHAR(1) is supported****
****Conversion from nchar(1) to output SQLSRV_SQLTYPE_NVARCHAR(1) is supported****
Testing nchar(8):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nchar(8) to output SQLSRV_SQLTYPE_NCHAR(8) is supported****
****Conversion from nchar(8) to output SQLSRV_SQLTYPE_NVARCHAR(8) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nchar(8) to output SQLSRV_SQLTYPE_NCHAR(8) is supported****
****Conversion from nchar(8) to output SQLSRV_SQLTYPE_NVARCHAR(8) is supported****
Testing nchar(64):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nchar(64) to output SQLSRV_SQLTYPE_NCHAR(64) is supported****
****Conversion from nchar(64) to output SQLSRV_SQLTYPE_NVARCHAR(64) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nchar(64) to output SQLSRV_SQLTYPE_NCHAR(64) is supported****
****Conversion from nchar(64) to output SQLSRV_SQLTYPE_NVARCHAR(64) is supported****
Testing nchar(512):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nchar(512) to output SQLSRV_SQLTYPE_NCHAR(512) is supported****
****Conversion from nchar(512) to output SQLSRV_SQLTYPE_NVARCHAR(512) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nchar(512) to output SQLSRV_SQLTYPE_NCHAR(512) is supported****
****Conversion from nchar(512) to output SQLSRV_SQLTYPE_NVARCHAR(512) is supported****
Testing nchar(4000):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nchar(4000) to output SQLSRV_SQLTYPE_NCHAR(4000) is supported****
****Conversion from nchar(4000) to output SQLSRV_SQLTYPE_NVARCHAR(4000) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nchar(4000) to output SQLSRV_SQLTYPE_NCHAR(4000) is supported****
****Conversion from nchar(4000) to output SQLSRV_SQLTYPE_NVARCHAR(4000) is supported****
Testing nvarchar(1):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nvarchar(1) to output SQLSRV_SQLTYPE_NCHAR(1) is supported****
****Conversion from nvarchar(1) to output SQLSRV_SQLTYPE_NVARCHAR(1) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nvarchar(1) to output SQLSRV_SQLTYPE_NCHAR(1) is supported****
****Conversion from nvarchar(1) to output SQLSRV_SQLTYPE_NVARCHAR(1) is supported****
Testing nvarchar(8):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nvarchar(8) to output SQLSRV_SQLTYPE_NCHAR(8) is supported****
****Conversion from nvarchar(8) to output SQLSRV_SQLTYPE_NVARCHAR(8) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nvarchar(8) to output SQLSRV_SQLTYPE_NCHAR(8) is supported****
****Conversion from nvarchar(8) to output SQLSRV_SQLTYPE_NVARCHAR(8) is supported****
Testing nvarchar(64):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nvarchar(64) to output SQLSRV_SQLTYPE_NCHAR(64) is supported****
****Conversion from nvarchar(64) to output SQLSRV_SQLTYPE_NVARCHAR(64) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nvarchar(64) to output SQLSRV_SQLTYPE_NCHAR(64) is supported****
****Conversion from nvarchar(64) to output SQLSRV_SQLTYPE_NVARCHAR(64) is supported****
Testing nvarchar(512):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nvarchar(512) to output SQLSRV_SQLTYPE_NCHAR(512) is supported****
****Conversion from nvarchar(512) to output SQLSRV_SQLTYPE_NVARCHAR(512) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nvarchar(512) to output SQLSRV_SQLTYPE_NCHAR(512) is supported****
****Conversion from nvarchar(512) to output SQLSRV_SQLTYPE_NVARCHAR(512) is supported****
Testing nvarchar(4000):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nvarchar(4000) to output SQLSRV_SQLTYPE_NCHAR(4000) is supported****
****Conversion from nvarchar(4000) to output SQLSRV_SQLTYPE_NVARCHAR(4000) is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nvarchar(4000) to output SQLSRV_SQLTYPE_NCHAR(4000) is supported****
****Conversion from nvarchar(4000) to output SQLSRV_SQLTYPE_NVARCHAR(4000) is supported****
Testing nvarchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
Testing nvarchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
Testing nvarchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
Testing nvarchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
Testing nvarchar(max):
Testing as SQLSRV_PARAM_OUT:
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
Testing as SQLSRV_PARAM_INOUT:
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****
****Conversion from nvarchar(max) to output SQLSRV_SQLTYPE_NVARCHAR('max') is supported****