address review comments

This commit is contained in:
v-kaywon 2018-03-15 13:08:04 -07:00
parent e6af597cad
commit 600e338a1f
6 changed files with 47 additions and 45 deletions

View file

@ -26,10 +26,10 @@ $directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$inputValues = array("d", "f");
$conn = AE\connect();
foreach($dataTypes as $dataType) {
foreach ($dataTypes as $dataType) {
$maxcol = strpos($dataType, "(max)");
foreach($lengths as $m) {
if ($maxcol !== false) {
foreach ($lengths as $m) {
if ($maxcol) {
$typeFull = $dataType;
} else {
$typeFull = "$dataType($m)";
@ -43,7 +43,7 @@ foreach($dataTypes as $dataType) {
$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("c_det" => $inputs[0], "c_rand" => $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);
// create a stored procedure and sql string for calling the stored procedure
$spname = 'selectAllColumns';
@ -51,14 +51,14 @@ foreach($dataTypes as $dataType) {
$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) {
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
foreach($sqlTypes as $sqlType) {
foreach ($sqlTypes as $sqlType) {
$maxsqltype = strpos($sqlType, "max");
foreach($sqltypeLengths as $n) {
foreach ($sqltypeLengths as $n) {
$sqltypeconst;
$sqltypeFull;
if ($maxsqltype !== false) {
if ($maxsqltype) {
$sqltypeconst = SQLSRV_SQLTYPE_VARBINARY('max');
$sqltypeFull = $sqlType;
} else {
@ -77,8 +77,6 @@ foreach($dataTypes as $dataType) {
if (($n != $m || $maxsqltype || $maxcol) && !($maxcol && $maxsqltype)) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
var_dump($n);
var_dump($m);
echo "AE: Conversion from $typeFull to output $sqltypeFull should not be supported\n";
} else {
if (sqlsrv_errors()[0]['SQLSTATE'] != "22018") {
@ -121,6 +119,7 @@ foreach($dataTypes as $dataType) {
}
}
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
}

View file

@ -26,10 +26,10 @@ $directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$inputValue = "d";
$conn = AE\connect();
foreach($dataTypes as $dataType) {
foreach ($dataTypes as $dataType) {
$maxcol = strpos($dataType, "(max)");
foreach($lengths as $m) {
if ($maxcol !== false) {
foreach ($lengths as $m) {
if ($maxcol) {
$typeFull = $dataType;
} else {
$typeFull = "$dataType($m)";
@ -40,7 +40,7 @@ foreach($dataTypes as $dataType) {
$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("c1" => $inputValue));
$stmt = AE\insertRow($conn, $tbname, array($colMetaArr[0]->colName => $inputValue));
// create a stored procedure and sql string for calling the stored procedure
$spname = 'selectAllColumns';
@ -48,14 +48,14 @@ foreach($dataTypes as $dataType) {
$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) {
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
foreach($sqlTypes as $sqlType) {
foreach ($sqlTypes as $sqlType) {
$maxsqltype = strpos($sqlType, "max");
foreach($sqltypeLengths as $n) {
foreach ($sqltypeLengths as $n) {
$sqltypeconst;
$sqltypeFull;
if ($maxsqltype !== false) {
if ($maxsqltype) {
$sqltypeconst = SQLSRV_SQLTYPE_VARCHAR('max');
$sqltypeFull = $sqlType;
} else {
@ -73,8 +73,6 @@ foreach($dataTypes as $dataType) {
if (($n != $m || $maxsqltype || $maxcol) && !($maxcol && $maxsqltype)) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
var_dump($n);
var_dump($m);
echo "AE: Conversion from $typeFull to output $sqltypeFull should not be supported\n";
} else {
if (sqlsrv_errors()[0]['SQLSTATE'] != "22018") {
@ -117,6 +115,7 @@ foreach($dataTypes as $dataType) {
}
}
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
}

View file

@ -25,9 +25,9 @@ $directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$conn = AE\connect();
foreach($dataTypes as $dataType) {
foreach($precisions as $m1 => $inScales) {
foreach($inScales as $m2) {
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;
@ -41,7 +41,7 @@ foreach($dataTypes as $dataType) {
$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("c_det" => $inputValues[0], "c_rand" => $inputValues[1]));
$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';
@ -49,11 +49,11 @@ foreach($dataTypes as $dataType) {
$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) {
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
foreach($sqlTypes as $sqlType) {
foreach($sqltypePrecisions as $n1 => $sqltypeScales) {
foreach($sqltypeScales as $n2) {
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
@ -128,6 +128,7 @@ foreach($dataTypes as $dataType) {
}
}
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
}

View file

@ -19,7 +19,7 @@ $directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$epsilon = 100000;
$conn = AE\connect();
foreach($bits as $m) {
foreach ($bits as $m) {
$typeFull = "$dataType($m)";
echo "\nTesting $typeFull:\n";
@ -27,7 +27,7 @@ foreach($bits as $m) {
$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("c_det" => $inputValues[0], "c_rand" => $inputValues[1]));
$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';
@ -35,7 +35,7 @@ foreach($bits as $m) {
$sql = AE\getCallProcSqlPlaceholders($spname, 2);
// retrieve by specifying SQLSRV_SQLTYPE_FLOAT as SQLSRV_PARAM_OUT or SQLSRV_PARAM_INOUT
foreach($directions as $dir) {
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
$c_detOut = 0.0;
@ -44,7 +44,9 @@ foreach($bits as $m) {
$r = sqlsrv_execute($stmt);
// check the case when the column number of bits is less than 25
// with AE: should not work
// 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()) {
@ -85,6 +87,7 @@ foreach($bits as $m) {
// cleanup
sqlsrv_free_stmt($stmt);
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
sqlsrv_close($conn);

View file

@ -23,7 +23,7 @@ foreach ($dataTypes as $dataType) {
$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("c_det" => $inputValues[0], "c_rand" => $inputValues[1]));
$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';
@ -31,9 +31,9 @@ foreach ($dataTypes as $dataType) {
$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) {
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
foreach($sqlTypes as $sqlType) {
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))));
@ -75,6 +75,7 @@ foreach ($dataTypes as $dataType) {
sqlsrv_free_stmt($stmt);
}
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
sqlsrv_close($conn);

View file

@ -26,10 +26,10 @@ $directions = array("SQLSRV_PARAM_OUT", "SQLSRV_PARAM_INOUT");
$inputValue = "d";
$conn = AE\connect();
foreach($dataTypes as $dataType) {
foreach ($dataTypes as $dataType) {
$maxcol = strpos($dataType, "(max)");
foreach($lengths as $m) {
if ($maxcol !== false) {
foreach ($lengths as $m) {
if ($maxcol) {
$typeFull = $dataType;
} else {
$typeFull = "$dataType($m)";
@ -40,7 +40,7 @@ foreach($dataTypes as $dataType) {
$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("c1" => $inputValue));
$stmt = AE\insertRow($conn, $tbname, array($colMetaArr[0]->colName => $inputValue));
// create a stored procedure and sql string for calling the stored procedure
$spname = 'selectAllColumns';
@ -48,14 +48,14 @@ foreach($dataTypes as $dataType) {
$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) {
foreach ($directions as $dir) {
echo "Testing as $dir:\n";
foreach($sqlTypes as $sqlType) {
foreach ($sqlTypes as $sqlType) {
$maxsqltype = strpos($sqlType, "max");
foreach($sqltypeLengths as $n) {
foreach ($sqltypeLengths as $n) {
$sqltypeconst;
$sqltypeFull;
if ($maxsqltype !== false) {
if ($maxsqltype) {
$sqltypeconst = SQLSRV_SQLTYPE_NVARCHAR('max');
$sqltypeFull = $sqlType;
} else {
@ -73,8 +73,6 @@ foreach($dataTypes as $dataType) {
if (($n != $m || $maxsqltype || $maxcol) && !($maxcol && $maxsqltype)) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
var_dump($n);
var_dump($m);
echo "AE: Conversion from $typeFull to output $sqltypeFull should not be supported\n";
} else {
if (sqlsrv_errors()[0]['SQLSTATE'] != "22018") {
@ -116,6 +114,7 @@ foreach($dataTypes as $dataType) {
}
}
}
dropProc($conn, $spname);
dropTable($conn, $tbname);
}
}