add refactored ae related tests

This commit is contained in:
v-kaywon 2017-11-06 17:30:11 -08:00
parent e09dd9163d
commit 1e69c86d69
13 changed files with 411 additions and 562 deletions

View file

@ -3,44 +3,40 @@ Test for inserting and retrieving encrypted data of datetime types
--DESCRIPTION--
No PDO::PARAM_ type specified when binding parameters
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
include 'AEData.inc';
require_once("MsCommon_mid-refactor.inc");
require_once("AEData.inc");
$dataTypes = array( "date", "datetime", "datetime2", "smalldatetime", "time", "datetimeoffset" );
try
{
$conn = ae_connect();
try {
$conn = connect();
foreach ( $dataTypes as $dataType ) {
foreach ($dataTypes as $dataType) {
echo "\nTesting $dataType:\n";
// create table
$tbname = GetTempTableName( "", false );
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
create_table( $conn, $tbname, $colMetaArr );
$tbname = getTableName();
$colMetaArr = array( new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
// insert a row
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
$r;
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r );
if ( $r === false ) {
is_incompatible_types_error( $stmt, $dataType, "default type" );
}
else {
$stmt = insertRow($conn, $tbname, array("c_det" => $inputValues[0], "c_rand" => $inputValues[1] ), null, $r);
if ($r === false) {
isIncompatibleTypesError($stmt, $dataType, "default type");
} else {
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
fetch_all( $conn, $tbname );
fetchAll($conn, $tbname);
}
DropTable( $conn, $tbname );
dropTable($conn, $tbname);
}
unset( $stmt );
unset( $conn );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>

View file

@ -3,77 +3,60 @@ Test for inserting and retrieving encrypted data of money types
--DESCRIPTION--
No PDO::PARAM_ tpe specified when binding parameters
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
include 'AEData.inc';
$dataTypes = array( "smallmoney", "money" );
try
{
$conn = ae_connect();
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
foreach ( $dataTypes as $dataType ) {
require_once("MsCommon_mid-refactor.inc");
require_once("AEData.inc");
$dataTypes = array("smallmoney", "money");
try {
$conn = connect('', array(), PDO::ERRMODE_SILENT);
foreach ($dataTypes as $dataType) {
echo "\nTesting $dataType:\n";
$success = true;
// create table
$tbname = GetTempTableName( "", false );
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
create_table( $conn, $tbname, $colMetaArr );
$tbname = getTableName();
$colMetaArr = array( new columnMeta($dataType, "c_det"), new columnMeta($dataType, "c_rand", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
// insert a row
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
$r;
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r );
if ( !is_col_enc() )
{
if ( $r === false )
{
$stmt = insertRow($conn, $tbname, array("c_det" => $inputValues[0], "c_rand" => $inputValues[1] ), null, $r);
if (!isColEncrypted()) {
if ($r === false) {
echo "Default type should be compatible with $dataType.\n";
$success = false;
}
else
{
} else {
$sql = "SELECT * FROM $tbname";
$stmt = $conn->query( $sql );
$row = $stmt->fetch( PDO::FETCH_ASSOC );
if ( $row["c_det"] != $inputValues[0] || $row["c_rand"] != $inputValues[1] )
{
$stmt = $conn->query($sql);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ($row["c_det"] != $inputValues[0] || $row["c_rand"] != $inputValues[1]) {
echo "Incorrect output retrieved for datatype $dataType.\n";
$success = false;
}
}
}
else
{
if ( $r === false )
{
if ( $stmt->errorInfo()[0] != "22018" )
{
} else {
if ($r === false) {
if ($stmt->errorInfo()[0] != "22018") {
echo "Incorrect error returned.\n";
$success = false;
}
}
else
{
} else {
echo "$dataType is not compatible with any type.\n";
$success = false;
}
}
if ( $success )
if ($success) {
echo "Test successfully done.\n";
DropTable( $conn, $tbname );
}
dropTable($conn, $tbname);
}
unset( $stmt );
unset( $conn );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>

View file

@ -3,44 +3,37 @@ Test for inserting and retrieving encrypted data of numeric types
--DESCRIPTION--
No PDO::PARAM_ tpe specified when binding parameters
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
include 'AEData.inc';
$dataTypes = array( "bit", "tinyint", "smallint", "int", "bigint", "decimal(18,5)", "numeric(10,5)", "float", "real" );
try
{
$conn = ae_connect();
foreach ( $dataTypes as $dataType ) {
require_once("MsCommon_mid-refactor.inc");
require_once("AEData.inc");
$dataTypes = array("bit", "tinyint", "smallint", "int", "bigint", "decimal(18,5)", "numeric(10,5)", "float", "real");
try {
$conn = connect();
foreach ($dataTypes as $dataType) {
echo "\nTesting $dataType:\n";
// create table
$tbname = GetTempTableName( "", false );
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
create_table( $conn, $tbname, $colMetaArr );
$tbname = getTableName();
$colMetaArr = array( new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
// insert a row
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
$r;
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r );
if ( $r === false ) {
is_incompatible_types_error( $stmt, $dataType, "default type" );
}
else {
$stmt = insertRow($conn, $tbname, array( "c_det" => $inputValues[0], "c_rand" => $inputValues[1] ), null, $r);
if ($r === false) {
isIncompatibleTypesError($stmt, $dataType, "default type");
} else {
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
fetch_all( $conn, $tbname );
fetchAll($conn, $tbname);
}
DropTable( $conn, $tbname );
dropTable($conn, $tbname);
}
unset( $stmt );
unset( $conn );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>

View file

@ -3,49 +3,42 @@ Test for inserting and retrieving encrypted data of datetime types
--DESCRIPTION--
Use PDOstatement::bindParam with all PDO::PARAM_ types
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
include 'AEData.inc';
require_once("MsCommon_mid-refactor.inc");
require_once("AEData.inc");
$dataTypes = array( "date", "datetime", "datetime2", "smalldatetime", "time", "datetimeoffset" );
try
{
$conn = ae_connect();
foreach ( $dataTypes as $dataType ) {
try {
$conn = connect();
foreach ($dataTypes as $dataType) {
echo "\nTesting $dataType:\n";
// create table
$tbname = GetTempTableName( "", false );
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
create_table( $conn, $tbname, $colMetaArr );
$tbname = getTableName();
$colMetaArr = array( new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
// prepare statement for inserting into table
foreach ( $pdoParamTypes as $pdoParamType ) {
foreach ($pdoParamTypes as $pdoParamType) {
// insert a row
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
$r;
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r, "prepareBindParam", array( new bindParamOption( 1, $pdoParamType ), new bindParamOption( 2, $pdoParamType )));
if ( $r === false )
{
is_incompatible_types_error( $stmt, $dataType, $pdoParamType );
}
else {
$stmt = insertRow($conn, $tbname, array( "c_det" => new BindParamOp(1, $inputValues[0], $pdoParamType), "c_rand" => new BindParamOp(2, $inputValues[1], $pdoParamType)), "prepareBindParam", $r);
if ($r === false) {
isIncompatibleTypesError($stmt, $dataType, $pdoParamType);
} else {
echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n";
fetch_all( $conn, $tbname );
fetchAll($conn, $tbname);
}
$conn->query( "TRUNCATE TABLE $tbname" );
$conn->query("TRUNCATE TABLE $tbname");
}
DropTable( $conn, $tbname );
dropTable($conn, $tbname);
}
unset( $stmt );
unset( $conn );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>

View file

@ -3,84 +3,67 @@ Test for inserting and retrieving encrypted data of money types
--DESCRIPTION--
Use PDOstatement::bindParam with all PDO::PARAM_ types
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
include 'AEData.inc';
require_once("MsCommon_mid-refactor.inc");
require_once("AEData.inc");
$dataTypes = array( "smallmoney", "money" );
try
{
$conn = ae_connect();
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
foreach ( $dataTypes as $dataType ) {
try {
$conn = connect('', array(), PDO::ERRMODE_SILENT);
foreach ($dataTypes as $dataType) {
echo "\nTesting $dataType:\n";
$success = true;
// create table
$tbname = GetTempTableName( "", false );
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
create_table( $conn, $tbname, $colMetaArr );
$tbname = getTableName();
$colMetaArr = array(new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
// test each PDO::PARAM_ type
foreach ( $pdoParamTypes as $pdoParamType ) {
foreach ($pdoParamTypes as $pdoParamType) {
// insert a row
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
$r;
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r, "prepareBindParam", array( new bindParamOption( 1, $pdoParamType ), new bindParamOption( 2, $pdoParamType )));
if ( !is_col_enc() )
{
if ( $r === false )
{
$stmt = insertRow($conn, $tbname, array("c_det" => new BindParamOp(1, $inputValues[0], $pdoParamType), "c_rand" => new BindParamOp(2, $inputValues[1], $pdoParamType)), "prepareBindParam", $r);
if (!isColEncrypted()) {
if ($r === false) {
echo "$pdoParamType should be compatible with $dataType.\n";
$success = false;
}
else
{
} else {
$sql = "SELECT * FROM $tbname";
$stmt = $conn->query( $sql );
$row = $stmt->fetch( PDO::FETCH_ASSOC );
if ( ( $row["c_det"] != $inputValues[0] || $row["c_rand"] != $inputValues[1] ) && $pdoParamType != "PDO::PARAM_NULL" )
{
$stmt = $conn->query($sql);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (($row["c_det"] != $inputValues[0] || $row["c_rand"] != $inputValues[1]) && $pdoParamType != "PDO::PARAM_NULL") {
echo "Incorrect output retrieved for datatype $dataType.\n";
var_dump( $inputValues );
var_dump( $row );
var_dump($inputValues);
var_dump($row);
$success = false;
}
}
}
else
{
if ( $r === false )
{
if ( $stmt->errorInfo()[0] != "22018" )
{
} else {
if ($r === false) {
if ($stmt->errorInfo()[0] != "22018") {
echo "Incorrect error returned.\n";
$success = false;
}
}
else
{
} else {
echo "$dataType is not compatible with any type.\n";
$success = false;
}
}
$conn->query( "TRUNCATE TABLE $tbname" );
$conn->query("TRUNCATE TABLE $tbname");
}
if ( $success )
if ($success) {
echo "Test successfully done.\n";
DropTable( $conn, $tbname );
}
DropTable($conn, $tbname);
}
unset( $stmt );
unset( $conn );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>

View file

@ -3,49 +3,41 @@ Test for inserting and retrieving encrypted data of numeric types
--DESCRIPTION--
Use PDOstatement::bindParam with all PDO::PARAM_ types
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
include 'AEData.inc';
require_once("MsCommon_mid-refactor.inc");
require_once("AEData.inc");
$dataTypes = array( "bit", "tinyint", "smallint", "int", "decimal(18,5)", "numeric(10,5)", "float", "real" );
try
{
$conn = ae_connect();
foreach ( $dataTypes as $dataType ) {
try {
$conn = connect();
foreach ($dataTypes as $dataType) {
echo "\nTesting $dataType:\n";
// create table
$tbname = GetTempTableName( "", false );
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
create_table( $conn, $tbname, $colMetaArr );
$tbname = getTableName();
$colMetaArr = array(new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
// test each PDO::PARAM_ type
foreach ( $pdoParamTypes as $pdoParamType ) {
foreach ($pdoParamTypes as $pdoParamType) {
// insert a row
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
$r;
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r, "prepareBindParam", array( new bindParamOption( 1, $pdoParamType ), new bindParamOption( 2, $pdoParamType )));
if ( $r === false )
{
is_incompatible_types_error( $stmt, $dataType, $pdoParamType );
}
else {
$stmt = insertRow($conn, $tbname, array( "c_det" => new BindParamOp(1, $inputValues[0], $pdoParamType), "c_rand" => new BindParamOp(2, $inputValues[1], $pdoParamType)), "prepareBindParam", $r);
if ($r === false) {
isIncompatibleTypesError($stmt, $dataType, $pdoParamType);
} else {
echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n";
fetch_all( $conn, $tbname );
fetchAll($conn, $tbname);
}
$conn->query( "TRUNCATE TABLE $tbname" );
$conn->query("TRUNCATE TABLE $tbname");
}
DropTable( $conn, $tbname );
dropTable($conn, $tbname);
}
unset( $stmt );
unset( $conn );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>

View file

@ -3,50 +3,41 @@ Test for inserting and retrieving encrypted data of string types
--DESCRIPTION--
Use PDOstatement::bindParam with all PDO::PARAM_ types
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
include 'AEData.inc';
$dataTypes = array( "char(5)", "varchar(max)", "nchar(5)", "nvarchar(max)" );
try
{
$conn = ae_connect();
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT );
foreach ( $dataTypes as $dataType ) {
require_once("MsCommon_mid-refactor.inc");
require_once("AEData.inc");
$dataTypes = array("char(5)", "varchar(max)", "nchar(5)", "nvarchar(max)");
try {
$conn = connect('', array(), PDO::ERRMODE_SILENT);
foreach ($dataTypes as $dataType) {
echo "\nTesting $dataType:\n";
// create table
$tbname = GetTempTableName( "", false );
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
create_table( $conn, $tbname, $colMetaArr );
$tbname = getTableName();
$colMetaArr = array(new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
// prepare statement for inserting into table
foreach ( $pdoParamTypes as $pdoParamType ) {
foreach ($pdoParamTypes as $pdoParamType) {
// insert a row
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
$r;
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r, "prepareBindParam", array( new bindParamOption( 1, $pdoParamType ), new bindParamOption( 2, $pdoParamType )));
if ( $r === false )
{
is_incompatible_types_error( $stmt, $dataType, $pdoParamType );
}
else {
$stmt = insertRow($conn, $tbname, array( "c_det" => new BindParamOp(1, $inputValues[0], $pdoParamType),"c_rand" => new BindParamOp(2, $inputValues[1], $pdoParamType)), "prepareBindParam", $r);
if ($r === false) {
isIncompatibleTypesError($stmt, $dataType, $pdoParamType);
} else {
echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n";
fetch_all( $conn, $tbname );
fetchAll($conn, $tbname);
}
$conn->query( "TRUNCATE TABLE $tbname" );
$conn->query("TRUNCATE TABLE $tbname");
}
DropTable( $conn, $tbname );
dropTable($conn, $tbname);
}
unset( $stmt );
unset( $conn );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>

View file

@ -3,73 +3,60 @@ Test for inserting encrypted data and retrieving both encrypted and decrypted da
--DESCRIPTION--
Retrieving SQL query contains encrypted filter
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
try
{
$conn = ae_connect();
require_once("MsCommon_mid-refactor.inc");
try {
$conn = connect();
// Create the table
$tbname = 'Patients';
$colMetaArr = array( new columnMeta( "int", "PatientId", "IDENTITY(1,1)" ),
new columnMeta( "char(11)", "SSN"),
new columnMeta( "nvarchar(50)", "FirstName", "NULL" ),
new columnMeta( "nvarchar(50)", "LastName", "NULL"),
new columnMeta( "date", "BirthDate", null, "randomized" ));
create_table( $conn, $tbname, $colMetaArr );
$colMetaArr = array( new columnMeta("int", "PatientId", "IDENTITY(1,1)"),
new columnMeta("char(11)", "SSN"),
new columnMeta("nvarchar(50)", "FirstName", "NULL"),
new columnMeta("nvarchar(50)", "LastName", "NULL"),
new columnMeta("date", "BirthDate", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
// insert a row
$SSN = "795-73-9838";
$inputs = array( "SSN" => $SSN, "FirstName" => "Catherine", "LastName" => "Abel", "BirthDate" => "1996-10-19" );
$stmt = insert_row( $conn, $tbname, $inputs );
$stmt = insertRow($conn, $tbname, $inputs);
echo "Retrieving plaintext data:\n";
$selectSql = "SELECT SSN, FirstName, LastName, BirthDate FROM $tbname WHERE SSN = ?";
$stmt = $conn->prepare( $selectSql );
$stmt->bindParam( 1, $SSN );
$stmt = $conn->prepare($selectSql);
$stmt->bindParam(1, $SSN);
$stmt->execute();
$decrypted_row = $stmt->fetch( PDO::FETCH_ASSOC );
foreach ( $decrypted_row as $key => $value )
{
$decrypted_row = $stmt->fetch(PDO::FETCH_ASSOC);
foreach ($decrypted_row as $key => $value) {
print "$key: $value\n";
}
unset( $stmt );
}
catch( PDOException $e )
{
unset($stmt);
} catch (PDOException $e) {
echo $e->getMessage();
}
// for AE only
echo "\nChecking ciphertext data:\n";
if ( is_col_enc() )
{
try
{
$conn1 = ae_connect( null, null, true );
if (isColEncrypted()) {
try {
$conn1 = connect('', array(), PDO::ERRMODE_EXCEPTION, true);
$selectSql = "SELECT SSN, FirstName, LastName, BirthDate FROM $tbname";
$stmt = $conn1->query( $selectSql );
$encrypted_row = $stmt->fetch( PDO::FETCH_ASSOC );
foreach ( $encrypted_row as $key => $value )
{
if ( ctype_print( $value ))
$stmt = $conn1->query($selectSql);
$encrypted_row = $stmt->fetch(PDO::FETCH_ASSOC);
foreach ($encrypted_row as $key => $value) {
if (ctype_print($value)) {
print "Error: expected a binary array for $key\n";
}
}
unset( $stmt );
unset( $conn1 );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn1);
} catch (PDOException $e) {
echo $e->getMessage();
}
}
DropTable( $conn, $tbname );
unset( $conn );
dropTable($conn, $tbname);
unset($conn);
echo "Done\n";
?>
--EXPECT--

View file

@ -1,80 +1,64 @@
--TEST--
Test for inserting encrypted fixed size types data and retrieve both encrypted and decrypted data
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
try
{
$conn = ae_connect();
require_once("MsCommon_mid-refactor.inc");
try {
$conn = connect();
// Create the table
$tbname = 'FixedSizeAnalysis';
$colMetaArr = array( new columnMeta( "tinyint", "TinyIntData" ),
new columnMeta( "smallint", "SmallIntData" ),
new columnMeta( "int", "IntData" ),
new columnMeta( "bigint", "BigIntData" ),
new columnMeta( "decimal(38,0)", "DecimalData" ),
new columnMeta( "bit", "BitData" ),
new columnMeta( "datetime", "DateTimeData" ),
new columnMeta( "datetime2", "DateTime2Data" ));
create_table( $conn, $tbname, $colMetaArr );
// insert a row
$inputs = array( "TinyIntData" => 255,
"SmallIntData" => 32767,
"IntData" => 2147483647,
"BigIntData" => 92233720368547,
"DecimalData" => 79228162514264,
"BitData" => true,
"DateTimeData" => '9999-12-31 23:59:59.997',
"DateTime2Data" => '9999-12-31 23:59:59.9999999');
$paramOptions = array( new bindParamOption( 4, "PDO::PARAM_INT" ) );
$r;
$stmt = insert_row( $conn, $tbname, $inputs, $r, "prepareBindParam", $paramOptions );
print "Decrypted values:\n";
fetch_all( $conn, $tbname );
$colMetaArr = array("TinyIntData" => "tinyint",
"SmallIntData" => "smallint",
"IntData" => "int",
"BigIntData" => "bigint",
"DecimalData" => "decimal(18,0)",
"BitData" => "bit",
"DateTimeData" => "datetime",
"DateTime2Data" => "datetime2");
createTable($conn, $tbname, $colMetaArr);
unset( $stmt );
}
catch( PDOException $e )
{
// insert a row
$inputs = array( "TinyIntData" => 255,
"SmallIntData" => 32767,
"IntData" => 2147483647,
"BigIntData" => 92233720368547,
"DecimalData" => 79228162514264,
"BitData" => true,
"DateTimeData" => '9999-12-31 23:59:59.997',
"DateTime2Data" => '9999-12-31 23:59:59.9999999');
//$paramOptions = array( new bindParamOption(4, "PDO::PARAM_INT") );
$r;
$stmt = insertRow($conn, $tbname, $inputs, "prepareBindParam", $r);
print "Decrypted values:\n";
fetchAll($conn, $tbname);
unset($stmt);
} catch (PDOException $e) {
echo $e->getMessage();
}
// for AE only
if ( is_col_enc() )
{
try
{
$conn1 = ae_connect( null, null, true );
if (isColEncrypted()) {
try {
$conn1 = connect('', array(), PDO::ERRMODE_EXCEPTION, true);
$selectSql = "SELECT * FROM $tbname";
$stmt = $conn1->query( $selectSql );
$encrypted_row = $stmt->fetch( PDO::FETCH_ASSOC );
foreach ( $encrypted_row as $key => $value )
{
if ( ctype_print( $value ))
{
$stmt = $conn1->query($selectSql);
$encrypted_row = $stmt->fetch(PDO::FETCH_ASSOC);
foreach ($encrypted_row as $key => $value) {
if (ctype_print($value)) {
print "Error: expected a binary array for $key\n";
}
}
unset( $stmt );
unset( $conn1 );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn1);
} catch (PDOException $e) {
echo $e->getMessage();
}
}
DropTable( $conn, $tbname );
unset( $conn );
dropTable($conn, $tbname);
unset($conn);
echo "Done\n";
?>
--EXPECT--
@ -87,4 +71,4 @@ DecimalData: 79228162514264
BitData: 1
DateTimeData: 9999-12-31 23:59:59.997
DateTime2Data: 9999-12-31 23:59:59.9999999
Done
Done

View file

@ -1,79 +1,60 @@
--TEST--
Test for inserting encrypted nvarchar data of variable lengths and retrieving encrypted and decrypted data
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
require_once("MsCommon_mid-refactor.inc");
$testPass = true;
try
{
$conn = ae_connect();
try {
$conn = connect();
// Create the table
$tbname = 'NVarcharAnalysis';
$colMetaArr = array( new columnMeta( "int", "CharCount", "IDENTITY(0,1)" ), new columnMeta( "nvarchar(1000)" ));
create_table( $conn, $tbname, $colMetaArr );
$colMetaArr = array( new ColumnMeta("int", "CharCount", "IDENTITY(0,1)"), new columnMeta("nvarchar(1000)"));
createTable($conn, $tbname, $colMetaArr);
// insert 1000 rows
for ( $i = 0; $i < 1000; $i++ )
{
$data = str_repeat( "*", $i );
$stmt = insert_row( $conn, $tbname, array( get_default_colname( "nvarchar(1000)" ) => $data ) );
for ($i = 0; $i < 1000; $i++) {
$data = str_repeat("*", $i);
$stmt = insertRow($conn, $tbname, array(getDefaultColName("nvarchar(1000)") => $data));
}
$selectSql = "SELECT * FROM $tbname";
$stmt = $conn->query( $selectSql );
while ( $decrypted_row = $stmt->fetch( PDO::FETCH_ASSOC ))
{
if ( $decrypted_row[ 'CharCount' ] != strlen( $decrypted_row[ get_default_colname( "nvarchar(1000)" ) ] ))
{
$rowInd = $decrypted_row[ 'CharCount' ] + 1;
$stmt = $conn->query($selectSql);
while ($decrypted_row = $stmt->fetch(PDO::FETCH_ASSOC)) {
if ($decrypted_row['CharCount'] != strlen($decrypted_row[getDefaultColName("nvarchar(1000)")])) {
$rowInd = $decrypted_row['CharCount'] + 1;
echo "Failed to decrypted at row $rowInd\n";
$testPass = false;
}
}
unset( $stmt );
}
catch( PDOException $e )
{
unset($stmt);
} catch (PDOException $e) {
echo $e->getMessage();
}
// for AE only
if ( is_col_enc() )
{
try
{
$conn1 = ae_connect( null, null, true );
$stmt = $conn1->query( $selectSql );
while ( $decrypted_row = $stmt->fetch( PDO::FETCH_ASSOC ))
{
if ( $decrypted_row[ 'CharCount' ] == strlen( $decrypted_row[ get_default_colname( "nvarchar(1000)" ) ] ))
{
if (isColEncrypted()) {
try {
$conn1 = connect('', array(), PDO::ERRMODE_EXCEPTION, true);
$stmt = $conn1->query($selectSql);
while ($decrypted_row = $stmt->fetch(PDO::FETCH_ASSOC)) {
if ($decrypted_row[ 'CharCount' ] == strlen($decrypted_row[getDefaultColName("nvarchar(1000)")])) {
$rowInd = $decrypted_row[ 'CharCount' ] + 1;
echo "Failed to encrypted at row $rowInd\n";
$testPass = false;
}
}
unset( $stmt );
unset( $conn1 );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn1);
} catch (PDOException $e) {
echo $e->getMessage();
}
}
DropTable( $conn, $tbname );
unset( $conn );
if ( $testPass ) {
dropTable($conn, $tbname);
unset($conn);
if ($testPass) {
echo "Test successfully done.\n";
}
?>
--EXPECT--
Test successfully done.
Test successfully done.

View file

@ -1,78 +1,60 @@
--TEST--
Test for inserting encrypted varchar data of variable lengths and retrieving encrypted and decrypted data
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
require_once("MsCommon_mid-refactor.inc");
$testPass = true;
try
{
$conn = ae_connect();
try {
$conn = connect();
// Create the table
$tbname = 'VarcharAnalysis';
$colMetaArr = array( new columnMeta( "int", "CharCount", "IDENTITY(0,1)" ), new columnMeta( "varchar(1000)" ));
create_table( $conn, $tbname, $colMetaArr );
$colMetaArr = array( new ColumnMeta("int", "CharCount", "IDENTITY(0,1)"), new ColumnMeta("varchar(1000)"));
createTable($conn, $tbname, $colMetaArr);
// insert 1000 rows
for( $i = 0; $i < 1000; $i++ )
{
$data = str_repeat( "*", $i );
$stmt = insert_row( $conn, $tbname, array( get_default_colname( "varchar(1000)" ) => $data ) );
for ($i = 0; $i < 1000; $i++) {
$data = str_repeat("*", $i);
$stmt = insertRow($conn, $tbname, array(getDefaultColname("varchar(1000)") => $data));
}
$selectSql = "SELECT * FROM $tbname";
$stmt = $conn->query( $selectSql );
while ( $decrypted_row = $stmt->fetch( PDO::FETCH_ASSOC ))
{
if ( $decrypted_row[ 'CharCount' ] != strlen( $decrypted_row[ get_default_colname( "varchar(1000)" ) ] ))
{
$rowInd = $decrypted_row[ 'CharCount' ] + 1;
$stmt = $conn->query($selectSql);
while ($decrypted_row = $stmt->fetch(PDO::FETCH_ASSOC)) {
if ($decrypted_row['CharCount'] != strlen($decrypted_row[getDefaultColname("varchar(1000)")])) {
$rowInd = $decrypted_row['CharCount'] + 1;
echo "Failed to decrypted at row $rowInd\n";
$testPass = false;
}
}
unset( $stmt );
}
catch( PDOException $e )
{
unset($stmt);
} catch (PDOException $e) {
echo $e->getMessage();
}
// for AE only
if ( is_col_enc() )
{
try
{
$conn1 = ae_connect( null, null, true );
$stmt = $conn1->query( $selectSql );
while ( $decrypted_row = $stmt->fetch( PDO::FETCH_ASSOC ))
{
if ( $decrypted_row[ 'CharCount' ] == strlen( $decrypted_row[ get_default_colname( "varchar(1000)" ) ] ))
{
if (isColEncrypted()) {
try {
$conn1 = connect('', array(), PDO::ERRMODE_EXCEPTION, true);
$stmt = $conn1->query($selectSql);
while ($decrypted_row = $stmt->fetch(PDO::FETCH_ASSOC)) {
if ($decrypted_row['CharCount'] == strlen($decrypted_row[getDefaultColname("varchar(1000)")])) {
$rowInd = $decrypted_row[ 'CharCount' ] + 1;
echo "Failed to encrypted at row $rowInd\n";
$testPass = false;
}
}
unset( $stmt );
unset( $conn1 );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn1);
} catch (PDOException $e) {
echo $e->getMessage();
}
}
DropTable( $conn, $tbname );
unset( $conn );
if ( $testPass ) {
dropTable($conn, $tbname);
unset($conn);
if ($testPass) {
echo "Test successfully done.\n";
}
?>
--EXPECT--
Test successfully done.
Test successfully done.

View file

@ -3,44 +3,37 @@ Test for inserting and retrieving encrypted data of string types
--DESCRIPTION--
No PDO::PARAM_ type specified when binding parameters
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
include 'AEData.inc';
$dataTypes = array( "char(5)", "varchar(max)", "nchar(5)", "nvarchar(max)" );
try
{
$conn = ae_connect();
foreach ( $dataTypes as $dataType ) {
require_once("MsCommon_mid-refactor.inc");
require_once("AEData.inc");
$dataTypes = array("char(5)", "varchar(max)", "nchar(5)", "nvarchar(max)");
try {
$conn = connect();
foreach ($dataTypes as $dataType) {
echo "\nTesting $dataType:\n";
// create table
$tbname = GetTempTableName( "", false );
$colMetaArr = array( new columnMeta( $dataType, "c_det" ), new columnMeta( $dataType, "c_rand", null, "randomized" ));
create_table( $conn, $tbname, $colMetaArr );
$tbname = getTableName();
$colMetaArr = array( new columnMeta($dataType, "c_det"), new columnMeta($dataType, "c_rand", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
// insert a row
$inputValues = array_slice( ${explode( "(", $dataType )[0] . "_params"}, 1, 2 );
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
$r;
$stmt = insert_row( $conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r );
if ( $r === false ) {
is_incompatible_types_error( $stmt, $dataType, "default type" );
}
else {
$stmt = insertRow($conn, $tbname, array("c_det" => $inputValues[0], "c_rand" => $inputValues[1] ), null, $r);
if ($r === false) {
isIncompatibleTypesError($stmt, $dataType, "default type");
} else {
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
fetch_all( $conn, $tbname );
fetchAll($conn, $tbname);
}
DropTable( $conn, $tbname );
dropTable($conn, $tbname);
}
unset( $stmt );
unset( $conn );
}
catch( PDOException $e )
{
unset($stmt);
unset($conn);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>

View file

@ -1,84 +1,78 @@
--TEST--
Test for binding output params for encrypted data for all types
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
include 'MsCommon.inc';
$conn = ae_connect();
require_once("MsCommon_mid-refactor.inc");
$conn = connect();
// Create the table
$tbname = GetTempTableName( "", false );
$colMetaArr = array( new columnMeta( "int", "c1_int" ),
new columnMeta( "smallint", "c2_smallint" ),
new columnMeta( "tinyint", "c3_tinyint" ),
new columnMeta( "bit", "c4_bit" ),
new columnMeta( "bigint", "c5_bigint" ),
new columnMeta( "decimal(18,5)", "c6_decimal" ),
new columnMeta( "numeric(10,5)", "c7_numeric" ),
new columnMeta( "float", "c8_float" ),
new columnMeta( "real", "c9_real" ),
new columnMeta( "date", "c10_date" ),
new columnMeta( "datetime", "c11_datetime" ),
new columnMeta( "datetime2", "c12_datetime2" ),
new columnMeta( "datetimeoffset", "c13_datetimeoffset" ),
new columnMeta( "time", "c14_time" ),
new columnMeta( "char(5)", "c15_char" ),
new columnMeta( "varchar(max)", "c16_varchar" ),
new columnMeta( "nchar(5)", "c17_nchar" ),
new columnMeta( "nvarchar(max)", "c18_nvarchar" ));
create_table( $conn, $tbname, $colMetaArr );
$tbname = getTableName();
$colMetaArr = array("c1_int" => "int",
"c2_smallint" => "smallint",
"c3_tinyint" => "tinyint",
"c4_bit" => "bit",
"c5_bigint" => "bigint",
"c6_decimal" => "decimal(18,5)",
"c7_numeric" => "numeric(10,5)",
"c8_float" => "float",
"c9_real" => "real",
"c10_date" => "date",
"c11_datetime" => "datetime",
"c12_datetime2" => "datetime2",
"c13_datetimeoffset" => "datetimeoffset",
"c14_time" => "time",
"c15_char" => "char(5)",
"c16_varchar" => "varchar(max)",
"c17_nchar" => "nchar(5)",
"c18_nvarchar" => "nvarchar(max)");
createTable($conn, $tbname, $colMetaArr);
// Create a Store Procedure
$spname = 'selectAllColumns';
$spSql = "CREATE PROCEDURE $spname (
@c1_int int OUTPUT, @c2_smallint smallint OUTPUT,
@c3_tinyint tinyint OUTPUT, @c4_bit bit OUTPUT,
@c1_int int OUTPUT, @c2_smallint smallint OUTPUT,
@c3_tinyint tinyint OUTPUT, @c4_bit bit OUTPUT,
@c5_bigint bigint OUTPUT, @c6_decimal decimal(18,5) OUTPUT,
@c7_numeric numeric(10,5) OUTPUT, @c8_float float OUTPUT,
@c7_numeric numeric(10,5) OUTPUT, @c8_float float OUTPUT,
@c9_real real OUTPUT, @c10_date date OUTPUT,
@c11_datetime datetime OUTPUT, @c12_datetime2 datetime2 OUTPUT,
@c13_datetimeoffset datetimeoffset OUTPUT, @c14_time time OUTPUT,
@c15_char char(5) OUTPUT, @c16_varchar varchar(max) OUTPUT,
@c17_nchar nchar(5) OUTPUT, @c18_nvarchar nvarchar(max) OUTPUT) AS
SELECT @c1_int = c1_int, @c2_smallint = c2_smallint,
@c3_tinyint = c3_tinyint, @c4_bit = c4_bit,
@c5_bigint = c5_bigint, @c6_decimal = c6_decimal,
@c7_numeric = c7_numeric, @c8_float = c8_float,
@c9_real = c9_real, @c10_date = c10_date,
SELECT @c1_int = c1_int, @c2_smallint = c2_smallint,
@c3_tinyint = c3_tinyint, @c4_bit = c4_bit,
@c5_bigint = c5_bigint, @c6_decimal = c6_decimal,
@c7_numeric = c7_numeric, @c8_float = c8_float,
@c9_real = c9_real, @c10_date = c10_date,
@c11_datetime = c11_datetime, @c12_datetime2 = c12_datetime2,
@c13_datetimeoffset = c13_datetimeoffset, @c14_time = c14_time,
@c15_char = c15_char, @c16_varchar = c16_varchar,
@c17_nchar = c17_nchar, @c18_nvarchar = c18_nvarchar
FROM $tbname";
$conn->query( $spSql );
$conn->query($spSql);
// Insert data
$inputs = array( "c1_int" => 2147483647,
"c2_smallint" => 32767,
"c3_tinyint" => 255,
"c4_bit" => 1,
"c5_bigint" => 922337203685479936,
"c6_decimal" => 9223372036854.80000,
"c7_numeric" => 21474.83647,
$inputs = array( "c1_int" => 2147483647,
"c2_smallint" => 32767,
"c3_tinyint" => 255,
"c4_bit" => 1,
"c5_bigint" => 922337203685479936,
"c6_decimal" => 9223372036854.80000,
"c7_numeric" => 21474.83647,
"c8_float" => 9223372036.8548,
"c9_real" => 2147.483,
"c10_date" => '9999-12-31',
"c11_datetime" => '9999-12-31 23:59:59.997',
"c12_datetime2" => '9999-12-31 23:59:59.9999999',
"c13_datetimeoffset" => '9999-12-31 23:59:59.9999999 +14:00',
"c14_time" => '23:59:59.9999999',
"c15_char" => 'th, n',
"c16_varchar" => 'This large row size can cause errors (such as error 512) during some normal operations, such as a clustered index key update, or sorts of the full column set, which users cannot anticipate until performing an operation.',
"c17_nchar" => 'th Un',
"c9_real" => 2147.483,
"c10_date" => '9999-12-31',
"c11_datetime" => '9999-12-31 23:59:59.997',
"c12_datetime2" => '9999-12-31 23:59:59.9999999',
"c13_datetimeoffset" => '9999-12-31 23:59:59.9999999 +14:00',
"c14_time" => '23:59:59.9999999',
"c15_char" => 'th, n',
"c16_varchar" => 'This large row size can cause errors (such as error 512) during some normal operations, such as a clustered index key update, or sorts of the full column set, which users cannot anticipate until performing an operation.',
"c17_nchar" => 'th Un',
"c18_nvarchar" => 'When prefixing a string constant with the letter N, the implicit conversion will result in a Unicode string if the constant to convert does not exceed the max length for a Unicode string data type (4,000).' );
$paramOptions = array( new bindParamOption( 5, "PDO::PARAM_INT" ) );
$r;
$stmt = insert_row( $conn, $tbname, $inputs, $r, "prepareBindParam", $paramOptions );
$stmt = insertRow($conn, $tbname, $inputs, "prepareBindParam", $r);
// Call store procedure
$outSql = get_callProcSql_placeholders( $spname, count( $inputs ));
$outSql = getCallProcSqlPlaceholders($spname, count($inputs));
$intOut = 0;
$smallintOut = 0;
$tinyintOut = 0;
@ -97,7 +91,7 @@ $charOut = '';
$varcharOut = '';
$ncharOut = '';
$nvarcharOut = '';
$stmt = $conn->prepare( $outSql );
$stmt = $conn->prepare($outSql);
$stmt->bindParam(1, $intOut, PDO::PARAM_INT, PDO::SQLSRV_PARAM_OUT_DEFAULT_SIZE);
$stmt->bindParam(2, $smallintOut, PDO::PARAM_INT, PDO::SQLSRV_PARAM_OUT_DEFAULT_SIZE);
$stmt->bindParam(3, $tinyintOut, PDO::PARAM_INT, PDO::SQLSRV_PARAM_OUT_DEFAULT_SIZE);
@ -117,31 +111,28 @@ $stmt->bindParam(16, $varcharOut, PDO::PARAM_STR, 2048);
$stmt->bindParam(17, $ncharOut, PDO::PARAM_STR, 2048);
$stmt->bindParam(18, $nvarcharOut, PDO::PARAM_STR, 2048);
$stmt->execute();
print ( "intOut: " . $intOut . "\n" );
print ( "smallintOut: " . $smallintOut . "\n" );
print ( "tinyintOut: " . $tinyintOut . "\n" );
print ( "bitOut: " . $bitOut . "\n" );
print ( "bigintOut: " . $bigintOut . "\n" );
print ( "decimalOut: " . $decimalOut . "\n" );
print ( "numericOut: " . $numericOut . "\n" );
print ( "floatOut: " . $floatOut . "\n" );
print ( "realOut: " . $realOut . "\n" );
print ( "dateOut: " . $dateOut . "\n" );
print ( "datetimeOut: " . $datetimeOut . "\n" );
print ( "datetime2Out: " . $datetime2Out . "\n" );
print ( "datetimeoffsetOut: " . $datetimeoffsetOut . "\n" );
print ( "timeOut: " . $timeOut . "\n" );
print ( "charOut: " . $charOut . "\n" );
print ( "varcharOut: " . $varcharOut . "\n" );
print ( "ncharOut: " . $ncharOut . "\n" );
print ( "nvarcharOut: " . $nvarcharOut . "\n" );
$conn->query( "DROP PROCEDURE $spname" );
$conn->query( "DROP TABLE $tbname" );
unset( $stmt );
unset( $conn );
print("intOut: " . $intOut . "\n");
print("smallintOut: " . $smallintOut . "\n");
print("tinyintOut: " . $tinyintOut . "\n");
print("bitOut: " . $bitOut . "\n");
print("bigintOut: " . $bigintOut . "\n");
print("decimalOut: " . $decimalOut . "\n");
print("numericOut: " . $numericOut . "\n");
print("floatOut: " . $floatOut . "\n");
print("realOut: " . $realOut . "\n");
print("dateOut: " . $dateOut . "\n");
print("datetimeOut: " . $datetimeOut . "\n");
print("datetime2Out: " . $datetime2Out . "\n");
print("datetimeoffsetOut: " . $datetimeoffsetOut . "\n");
print("timeOut: " . $timeOut . "\n");
print("charOut: " . $charOut . "\n");
print("varcharOut: " . $varcharOut . "\n");
print("ncharOut: " . $ncharOut . "\n");
print("nvarcharOut: " . $nvarcharOut . "\n");
dropProc($conn, $spname);
dropTable($conn, $tbname);
unset($stmt);
unset($conn);
?>
--EXPECTREGEX--
intOut: 2147483647
@ -161,4 +152,4 @@ timeOut: 23:59:59\.9999999
charOut: th\, n
varcharOut: This large row size can cause errors \(such as error 512\) during some normal operations\, such as a clustered index key update\, or sorts of the full column set\, which users cannot anticipate until performing an operation\.
ncharOut: th Un
nvarcharOut: When prefixing a string constant with the letter N\, the implicit conversion will result in a Unicode string if the constant to convert does not exceed the max length for a Unicode string data type \(4,000\).
nvarcharOut: When prefixing a string constant with the letter N\, the implicit conversion will result in a Unicode string if the constant to convert does not exceed the max length for a Unicode string data type \(4,000\).