diff --git a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_binary_size.phpt b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_binary_size.phpt new file mode 100644 index 00000000..8601aae9 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_binary_size.phpt @@ -0,0 +1,150 @@ +--TEST-- +Test for inserting and retrieving encrypted data of string types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + new BindParamOp(1, $input0, $pdoParamType, 0, "PDO::SQLSRV_ENCODING_BINARY"), + "c_rand" => new BindParamOp(2, $input1, $pdoParamType, 0, "PDO::SQLSRV_ENCODING_BINARY")), "prepareBindParam", $r); + } else { + $stmt = insertRow($conn, $tbname, array("c_det" => new BindParamOp(1, $input0, $pdoParamType), "c_rand" => new BindParamOp(2, $input1, $pdoParamType)), "prepareBindParam", $r); + } + + if ($pdoParamType == "PDO::PARAM_STR" || $pdoParamType == "PDO::PARAM_LOB") { + if ($r === false) { + echo "$pdoParamType(PDO::SQLSRV_ENCODING_BINARY) should be compatible with encrypted $type\n"; + } else { + $sql = "SELECT c_det, c_rand FROM $tbname"; + $stmt = $conn->query($sql); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if (strlen($row['c_det']) == $length && strlen($row['c_rand']) == $length) { + echo "****PDO param type $pdoParamType(PDO::SQLSRV_ENCODING_BINARY) is compatible with $type****\n"; + } else { + echo "PDO param type $pdoParamType is incompatible with $type\n"; + } + } + } elseif (!isAEConnected()) { + if ($r !== false) { + echo "PDO param type $pdoParamType should not be compatible with $type\n"; + } + } else { + if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_INT") { + if ($r !== false) { + echo "PDO param type $pdoParamType should not be compatible with $type\n"; + $sql = "SELECT c_det, c_rand FROM $tbname"; + $stmt = $conn->query($sql); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + //var_dump($row); + } else { + $sql = "SELECT c_det, c_rand FROM $tbname"; + $stmt = $conn->query($sql); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if (!is_null($row['c_det']) && !is_null($row['c_rand'])) { + "Data inserted with $pdoParamType should be null\n"; + } + } + } + } + $conn->query("TRUNCATE TABLE $tbname"); + } + dropTable($conn, $tbname); + } + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing binary(2): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with binary(2)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with binary(2)**** + +Testing binary(8): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with binary(8)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with binary(8)**** + +Testing binary(64): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with binary(64)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with binary(64)**** + +Testing binary(512): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with binary(512)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with binary(512)**** + +Testing binary(4000): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with binary(4000)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with binary(4000)**** + +Testing varbinary(2): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(2)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(2)**** + +Testing varbinary(8): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(8)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(8)**** + +Testing varbinary(64): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(64)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(64)**** + +Testing varbinary(512): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(512)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(512)**** + +Testing varbinary(4000): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(4000)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(4000)**** + +Testing varbinary(max): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(max)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(max)**** + +Testing varbinary(max): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(max)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(max)**** + +Testing varbinary(max): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(max)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(max)**** + +Testing varbinary(max): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(max)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(max)**** + +Testing varbinary(max): +****PDO param type PDO::PARAM_STR(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(max)**** +****PDO param type PDO::PARAM_LOB(PDO::SQLSRV_ENCODING_BINARY) is compatible with varbinary(max)**** \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_char_size.phpt b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_char_size.phpt new file mode 100644 index 00000000..e91fb7b8 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_char_size.phpt @@ -0,0 +1,280 @@ +--TEST-- +Test for inserting and retrieving encrypted data of string types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + new BindParamOp(1, $input, $pdoParamType)), "prepareBindParam", $r); + + if ($r === false) { + isIncompatibleTypesError($stmt, $type, $pdoParamType); + } else { + $sql = "SELECT c1 FROM $tbname"; + $stmt = $conn->query($sql); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if (strlen($row['c1']) == $length) { + echo "****PDO param type $pdoParamType is compatible with $encType encrypted $type****\n"; + } else { + echo "PDO param type $pdoParamType is incompatible with $encType encrypted $type\n"; + } + } + $conn->query("TRUNCATE TABLE $tbname"); + } + dropTable($conn, $tbname); + } + } + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing char(1): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted char(1)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted char(1) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted char(1)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted char(1)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted char(1)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted char(1)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted char(1) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted char(1)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted char(1)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted char(1)**** + +Testing char(8): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted char(8)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted char(8) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted char(8)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted char(8)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted char(8)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted char(8)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted char(8) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted char(8)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted char(8)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted char(8)**** + +Testing char(64): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted char(64)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted char(64) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted char(64)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted char(64)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted char(64)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted char(64)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted char(64) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted char(64)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted char(64)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted char(64)**** + +Testing char(512): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted char(512)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted char(512) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted char(512)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted char(512)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted char(512)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted char(512)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted char(512) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted char(512)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted char(512)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted char(512)**** + +Testing char(4096): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted char(4096)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted char(4096) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted char(4096)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted char(4096)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted char(4096)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted char(4096)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted char(4096) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted char(4096)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted char(4096)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted char(4096)**** + +Testing char(8000): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted char(8000)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted char(8000) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted char(8000)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted char(8000)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted char(8000)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted char(8000)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted char(8000) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted char(8000)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted char(8000)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted char(8000)**** + +Testing varchar(1): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(1)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(1) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(1)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(1)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(1)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(1)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(1) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(1)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(1)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(1)**** + +Testing varchar(8): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(8)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(8) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(8)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(8)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(8)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(8)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(8) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(8)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(8)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(8)**** + +Testing varchar(64): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(64)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(64) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(64)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(64)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(64)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(64)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(64) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(64)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(64)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(64)**** + +Testing varchar(512): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(512)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(512) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(512)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(512)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(512)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(512)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(512) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(512)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(512)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(512)**** + +Testing varchar(4096): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(4096)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(4096) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(4096)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(4096)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(4096)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(4096)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(4096) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(4096)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(4096)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(4096)**** + +Testing varchar(8000): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(8000)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(8000) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(8000)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(8000)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(8000)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(8000)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(8000) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(8000)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(8000)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(8000)**** + +Testing varchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(max)**** + +Testing varchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(max)**** + +Testing varchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(max)**** + +Testing varchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(max)**** + +Testing varchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(max)**** + +Testing varchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted varchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted varchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted varchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted varchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted varchar(max)**** \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_datetime.phpt b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_datetime.phpt index df3fbfc5..490b4c05 100644 --- a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_datetime.phpt +++ b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_datetime.phpt @@ -9,7 +9,7 @@ Use PDOstatement::bindParam with all PDO::PARAM_ types require_once("MsCommon_mid-refactor.inc"); require_once("AEData.inc"); -$dataTypes = array( "date", "datetime", "datetime2", "smalldatetime", "time", "datetimeoffset" ); +$dataTypes = array( "date", "datetime", "smalldatetime"); try { $conn = connect(); foreach ($dataTypes as $dataType) { @@ -43,14 +43,13 @@ try { } ?> --EXPECT-- - Testing date: ****PDO param type PDO::PARAM_BOOL is compatible with encrypted date**** c_det: 0001-01-01 c_rand: 9999-12-31 ****PDO param type PDO::PARAM_NULL is compatible with encrypted date**** -c_det: -c_rand: +c_det: +c_rand: ****PDO param type PDO::PARAM_INT is compatible with encrypted date**** c_det: 0001-01-01 c_rand: 9999-12-31 @@ -66,8 +65,8 @@ Testing datetime: c_det: 1753-01-01 00:00:00.000 c_rand: 9999-12-31 23:59:59.997 ****PDO param type PDO::PARAM_NULL is compatible with encrypted datetime**** -c_det: -c_rand: +c_det: +c_rand: ****PDO param type PDO::PARAM_INT is compatible with encrypted datetime**** c_det: 1753-01-01 00:00:00.000 c_rand: 9999-12-31 23:59:59.997 @@ -78,30 +77,13 @@ c_rand: 9999-12-31 23:59:59.997 c_det: 1753-01-01 00:00:00.000 c_rand: 9999-12-31 23:59:59.997 -Testing datetime2: -****PDO param type PDO::PARAM_BOOL is compatible with encrypted datetime2**** -c_det: 0001-01-01 00:00:00.0000000 -c_rand: 9999-12-31 23:59:59.9999999 -****PDO param type PDO::PARAM_NULL is compatible with encrypted datetime2**** -c_det: -c_rand: -****PDO param type PDO::PARAM_INT is compatible with encrypted datetime2**** -c_det: 0001-01-01 00:00:00.0000000 -c_rand: 9999-12-31 23:59:59.9999999 -****PDO param type PDO::PARAM_STR is compatible with encrypted datetime2**** -c_det: 0001-01-01 00:00:00.0000000 -c_rand: 9999-12-31 23:59:59.9999999 -****PDO param type PDO::PARAM_LOB is compatible with encrypted datetime2**** -c_det: 0001-01-01 00:00:00.0000000 -c_rand: 9999-12-31 23:59:59.9999999 - Testing smalldatetime: ****PDO param type PDO::PARAM_BOOL is compatible with encrypted smalldatetime**** c_det: 1900-01-01 00:00:00 c_rand: 2079-06-05 23:59:00 ****PDO param type PDO::PARAM_NULL is compatible with encrypted smalldatetime**** -c_det: -c_rand: +c_det: +c_rand: ****PDO param type PDO::PARAM_INT is compatible with encrypted smalldatetime**** c_det: 1900-01-01 00:00:00 c_rand: 2079-06-05 23:59:00 @@ -110,38 +92,4 @@ c_det: 1900-01-01 00:00:00 c_rand: 2079-06-05 23:59:00 ****PDO param type PDO::PARAM_LOB is compatible with encrypted smalldatetime**** c_det: 1900-01-01 00:00:00 -c_rand: 2079-06-05 23:59:00 - -Testing time: -****PDO param type PDO::PARAM_BOOL is compatible with encrypted time**** -c_det: 00:00:00.0000000 -c_rand: 23:59:59.9999999 -****PDO param type PDO::PARAM_NULL is compatible with encrypted time**** -c_det: -c_rand: -****PDO param type PDO::PARAM_INT is compatible with encrypted time**** -c_det: 00:00:00.0000000 -c_rand: 23:59:59.9999999 -****PDO param type PDO::PARAM_STR is compatible with encrypted time**** -c_det: 00:00:00.0000000 -c_rand: 23:59:59.9999999 -****PDO param type PDO::PARAM_LOB is compatible with encrypted time**** -c_det: 00:00:00.0000000 -c_rand: 23:59:59.9999999 - -Testing datetimeoffset: -****PDO param type PDO::PARAM_BOOL is compatible with encrypted datetimeoffset**** -c_det: 0001-01-01 00:00:00.0000000 -14:00 -c_rand: 9999-12-31 23:59:59.9999999 +14:00 -****PDO param type PDO::PARAM_NULL is compatible with encrypted datetimeoffset**** -c_det: -c_rand: -****PDO param type PDO::PARAM_INT is compatible with encrypted datetimeoffset**** -c_det: 0001-01-01 00:00:00.0000000 -14:00 -c_rand: 9999-12-31 23:59:59.9999999 +14:00 -****PDO param type PDO::PARAM_STR is compatible with encrypted datetimeoffset**** -c_det: 0001-01-01 00:00:00.0000000 -14:00 -c_rand: 9999-12-31 23:59:59.9999999 +14:00 -****PDO param type PDO::PARAM_LOB is compatible with encrypted datetimeoffset**** -c_det: 0001-01-01 00:00:00.0000000 -14:00 -c_rand: 9999-12-31 23:59:59.9999999 +14:00 +c_rand: 2079-06-05 23:59:00 \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_datetime_precision.phpt b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_datetime_precision.phpt new file mode 100644 index 00000000..7f1ebc43 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_datetime_precision.phpt @@ -0,0 +1,268 @@ +--TEST-- +Test for inserting and retrieving encrypted data of datetime types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + array("0001-01-01 00:00:00", "9999-12-31 23:59:59"), + "datetimeoffset" => array("0001-01-01 00:00:00 -14:00", "9999-12-31 23:59:59 +14:00"), + "time" => array("00:00:00", "23:59:59")); + +try { + $conn = connect("", array(), PDO::ERRMODE_SILENT); + foreach ($dataTypes as $dataType) { + foreach ($precisions as $precision) { + // change the input values depending on the precision + $inputValues[0] = $inputValuesInit[$dataType][0]; + $inputValues[1] = $inputValuesInit[$dataType][1]; + if ($precision != 0) { + if ($dataType == "datetime2") { + $inputValues[1] .= "." . str_repeat("9", $precision); + } else if ($dataType == "datetimeoffset") { + $inputPieces = explode(" ", $inputValues[1]); + $inputValues[1] = $inputPieces[0] . " " . $inputPieces[1] . "." . str_repeat("9", $precision) . " " . $inputPieces[2]; + } else if ($dataType == "time") { + $inputValues[0] .= "." . str_repeat("0", $precision); + $inputValues[1] .= "." . str_repeat("9", $precision); + } + } + $type = "$dataType($precision)"; + echo "\nTesting $type:\n"; + + //create and populate table + $tbname = "test_datetime"; + $colMetaArr = array(new ColumnMeta($type, "c_det"), new ColumnMeta($type, "c_rand", null, "randomized")); + createTable($conn, $tbname, $colMetaArr); + + // prepare statement for inserting into table + foreach ($pdoParamTypes as $pdoParamType) { + // insert a row + $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"; + fetchAll($conn, $tbname); + } + $conn->query("TRUNCATE TABLE $tbname"); + } + dropTable($conn, $tbname); + } + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing datetime2(1): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0 +c_rand: 9999-12-31 23:59:59.9 +****PDO param type PDO::PARAM_NULL is compatible with encrypted datetime2**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0 +c_rand: 9999-12-31 23:59:59.9 +****PDO param type PDO::PARAM_STR is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0 +c_rand: 9999-12-31 23:59:59.9 +****PDO param type PDO::PARAM_LOB is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0 +c_rand: 9999-12-31 23:59:59.9 + +Testing datetime2(2): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.00 +c_rand: 9999-12-31 23:59:59.99 +****PDO param type PDO::PARAM_NULL is compatible with encrypted datetime2**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.00 +c_rand: 9999-12-31 23:59:59.99 +****PDO param type PDO::PARAM_STR is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.00 +c_rand: 9999-12-31 23:59:59.99 +****PDO param type PDO::PARAM_LOB is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.00 +c_rand: 9999-12-31 23:59:59.99 + +Testing datetime2(4): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0000 +c_rand: 9999-12-31 23:59:59.9999 +****PDO param type PDO::PARAM_NULL is compatible with encrypted datetime2**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0000 +c_rand: 9999-12-31 23:59:59.9999 +****PDO param type PDO::PARAM_STR is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0000 +c_rand: 9999-12-31 23:59:59.9999 +****PDO param type PDO::PARAM_LOB is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0000 +c_rand: 9999-12-31 23:59:59.9999 + +Testing datetime2(7): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0000000 +c_rand: 9999-12-31 23:59:59.9999999 +****PDO param type PDO::PARAM_NULL is compatible with encrypted datetime2**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0000000 +c_rand: 9999-12-31 23:59:59.9999999 +****PDO param type PDO::PARAM_STR is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0000000 +c_rand: 9999-12-31 23:59:59.9999999 +****PDO param type PDO::PARAM_LOB is compatible with encrypted datetime2**** +c_det: 0001-01-01 00:00:00.0000000 +c_rand: 9999-12-31 23:59:59.9999999 + +Testing datetimeoffset(1): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0 -14:00 +c_rand: 9999-12-31 23:59:59.9 +14:00 +****PDO param type PDO::PARAM_NULL is compatible with encrypted datetimeoffset**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0 -14:00 +c_rand: 9999-12-31 23:59:59.9 +14:00 +****PDO param type PDO::PARAM_STR is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0 -14:00 +c_rand: 9999-12-31 23:59:59.9 +14:00 +****PDO param type PDO::PARAM_LOB is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0 -14:00 +c_rand: 9999-12-31 23:59:59.9 +14:00 + +Testing datetimeoffset(2): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.00 -14:00 +c_rand: 9999-12-31 23:59:59.99 +14:00 +****PDO param type PDO::PARAM_NULL is compatible with encrypted datetimeoffset**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.00 -14:00 +c_rand: 9999-12-31 23:59:59.99 +14:00 +****PDO param type PDO::PARAM_STR is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.00 -14:00 +c_rand: 9999-12-31 23:59:59.99 +14:00 +****PDO param type PDO::PARAM_LOB is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.00 -14:00 +c_rand: 9999-12-31 23:59:59.99 +14:00 + +Testing datetimeoffset(4): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0000 -14:00 +c_rand: 9999-12-31 23:59:59.9999 +14:00 +****PDO param type PDO::PARAM_NULL is compatible with encrypted datetimeoffset**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0000 -14:00 +c_rand: 9999-12-31 23:59:59.9999 +14:00 +****PDO param type PDO::PARAM_STR is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0000 -14:00 +c_rand: 9999-12-31 23:59:59.9999 +14:00 +****PDO param type PDO::PARAM_LOB is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0000 -14:00 +c_rand: 9999-12-31 23:59:59.9999 +14:00 + +Testing datetimeoffset(7): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0000000 -14:00 +c_rand: 9999-12-31 23:59:59.9999999 +14:00 +****PDO param type PDO::PARAM_NULL is compatible with encrypted datetimeoffset**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0000000 -14:00 +c_rand: 9999-12-31 23:59:59.9999999 +14:00 +****PDO param type PDO::PARAM_STR is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0000000 -14:00 +c_rand: 9999-12-31 23:59:59.9999999 +14:00 +****PDO param type PDO::PARAM_LOB is compatible with encrypted datetimeoffset**** +c_det: 0001-01-01 00:00:00.0000000 -14:00 +c_rand: 9999-12-31 23:59:59.9999999 +14:00 + +Testing time(1): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted time**** +c_det: 00:00:00.0 +c_rand: 23:59:59.9 +****PDO param type PDO::PARAM_NULL is compatible with encrypted time**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted time**** +c_det: 00:00:00.0 +c_rand: 23:59:59.9 +****PDO param type PDO::PARAM_STR is compatible with encrypted time**** +c_det: 00:00:00.0 +c_rand: 23:59:59.9 +****PDO param type PDO::PARAM_LOB is compatible with encrypted time**** +c_det: 00:00:00.0 +c_rand: 23:59:59.9 + +Testing time(2): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted time**** +c_det: 00:00:00.00 +c_rand: 23:59:59.99 +****PDO param type PDO::PARAM_NULL is compatible with encrypted time**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted time**** +c_det: 00:00:00.00 +c_rand: 23:59:59.99 +****PDO param type PDO::PARAM_STR is compatible with encrypted time**** +c_det: 00:00:00.00 +c_rand: 23:59:59.99 +****PDO param type PDO::PARAM_LOB is compatible with encrypted time**** +c_det: 00:00:00.00 +c_rand: 23:59:59.99 + +Testing time(4): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted time**** +c_det: 00:00:00.0000 +c_rand: 23:59:59.9999 +****PDO param type PDO::PARAM_NULL is compatible with encrypted time**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted time**** +c_det: 00:00:00.0000 +c_rand: 23:59:59.9999 +****PDO param type PDO::PARAM_STR is compatible with encrypted time**** +c_det: 00:00:00.0000 +c_rand: 23:59:59.9999 +****PDO param type PDO::PARAM_LOB is compatible with encrypted time**** +c_det: 00:00:00.0000 +c_rand: 23:59:59.9999 + +Testing time(7): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted time**** +c_det: 00:00:00.0000000 +c_rand: 23:59:59.9999999 +****PDO param type PDO::PARAM_NULL is compatible with encrypted time**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted time**** +c_det: 00:00:00.0000000 +c_rand: 23:59:59.9999999 +****PDO param type PDO::PARAM_STR is compatible with encrypted time**** +c_det: 00:00:00.0000000 +c_rand: 23:59:59.9999999 +****PDO param type PDO::PARAM_LOB is compatible with encrypted time**** +c_det: 00:00:00.0000000 +c_rand: 23:59:59.9999999 \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_decimal_precision.phpt b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_decimal_precision.phpt new file mode 100644 index 00000000..16934536 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_decimal_precision.phpt @@ -0,0 +1,270 @@ +--TEST-- +Test for inserting and retrieving encrypted data of numeric types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + array(0, 1), + 4 => array(0, 1, 4), + 16 => array(0, 1, 4, 16), + 38 => array(0, 1, 4, 16, 38)); +$inputValuesInit = array(92233720368547758089223372036854775808, -92233720368547758089223372036854775808); +$inputPrecision = 38; + +try { + $conn = connect("", array(), PDO::ERRMODE_SILENT); + foreach ($dataTypes as $dataType) { + foreach ($precisions as $precision => $scales) { + foreach ($scales as $scale) { + // change the input values depending on the precision and scale + $precDiff = $inputPrecision - ($precision - $scale); + $inputValues = $inputValuesInit; + foreach ($inputValues as &$inputValue) { + $inputValue = $inputValue / pow(10, $precDiff); + } + // epsilon for comparing doubles + $epsilon; + if ($precision < 14) { + $epsilon = pow(10, $scale * -1); + } else { + $numint = $precision - $scale; + if ($numint < 14) { + $epsilon = pow(10, (14 - $numint) * -1); + } else { + $epsilon = pow(10, $numint - 14); + } + } + + $type = "$dataType($precision, $scale)"; + echo "\nTesting $type:\n"; + + // create table + $tbname = "test_decimal"; + $colMetaArr = array(new ColumnMeta($type, "c_det"), new ColumnMeta($type, "c_rand", null, "randomized")); + createTable($conn, $tbname, $colMetaArr); + + // test each PDO::PARAM_ type + foreach ($pdoParamTypes as $pdoParamType) { + // insert a row + $r; + $stmt = insertRow($conn, $tbname, array("c_det" => new BindParamOp(1, $inputValues[0], $pdoParamType), + "c_rand" => new BindParamOp(2, $inputValues[1], $pdoParamType)), "prepareBindParam", $r); + + if ($pdoParamType == "PDO::PARAM_NULL") { + // null was inserted when the parameter was bound as PDO:PARAM_NULL + $sql = "SELECT c_det, c_rand FROM $tbname"; + $stmt = $conn->query($sql); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if (!is_null($row['c_det']) || !is_null($row['c_rand'])) { + echo "NULL should have been inserted with $pdoParamType\n"; + } + } elseif ($pdoParamType == "PDO::PARAM_STR" && $precision - $scale > 14) { + // without AE, when the input has greater than 14 digits to the left of the decimal, + // the double is translated by PHP to scientific notation + // inserting scientific notation as a string fails + if (!isAEConnected()) { + if ($r !== false) { + echo "PDO param type $pdoParamType should not be compatible with $type when the number of integers is greater than 14\n"; + } + } else { + $sql = "SELECT c_det, c_rand FROM $tbname"; + $stmt = $conn->query($sql); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if (abs($row['c_det'] - $inputValues[0]) > $epsilon || + abs($row['c_rand'] - $inputValues[1]) > $epsilon) { + echo "PDO param type $pdoParamType should be compatible with $type when Always Encrypted is enabled\n"; + } + } + } else { + $sql = "SELECT c_det, c_rand FROM $tbname"; + $stmt = $conn->query($sql); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if (abs($row['c_det'] - $inputValues[0]) > $epsilon || + abs($row['c_rand'] - $inputValues[1]) > $epsilon) { + // TODO: this is a workaround for the test to pass!!!!! + // with AE, doubles cannot be inserted into a decimal(38, 38) column + // remove the following if block to see the bug + // for more information see VSO task 2723 + if (isAEConnected() && $precision == 38 && $scale == 38) { + echo "****PDO param type $pdoParamType is compatible with $type****\n"; + } else { + echo "PDO param type $pdoParamType should be compatible with $type\n"; + } + } else { + echo "****PDO param type $pdoParamType is compatible with $type****\n"; + } + } + $conn->query("TRUNCATE TABLE $tbname"); + } + dropTable($conn, $tbname); + } + } + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing decimal(1, 0): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(1, 0)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(1, 0)**** +****PDO param type PDO::PARAM_STR is compatible with decimal(1, 0)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(1, 0)**** + +Testing decimal(1, 1): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(1, 1)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(1, 1)**** +****PDO param type PDO::PARAM_STR is compatible with decimal(1, 1)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(1, 1)**** + +Testing decimal(4, 0): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(4, 0)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(4, 0)**** +****PDO param type PDO::PARAM_STR is compatible with decimal(4, 0)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(4, 0)**** + +Testing decimal(4, 1): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(4, 1)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(4, 1)**** +****PDO param type PDO::PARAM_STR is compatible with decimal(4, 1)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(4, 1)**** + +Testing decimal(4, 4): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(4, 4)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(4, 4)**** +****PDO param type PDO::PARAM_STR is compatible with decimal(4, 4)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(4, 4)**** + +Testing decimal(16, 0): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(16, 0)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(16, 0)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(16, 0)**** + +Testing decimal(16, 1): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(16, 1)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(16, 1)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(16, 1)**** + +Testing decimal(16, 4): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(16, 4)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(16, 4)**** +****PDO param type PDO::PARAM_STR is compatible with decimal(16, 4)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(16, 4)**** + +Testing decimal(16, 16): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(16, 16)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(16, 16)**** +****PDO param type PDO::PARAM_STR is compatible with decimal(16, 16)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(16, 16)**** + +Testing decimal(38, 0): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(38, 0)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(38, 0)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(38, 0)**** + +Testing decimal(38, 1): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(38, 1)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(38, 1)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(38, 1)**** + +Testing decimal(38, 4): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(38, 4)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(38, 4)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(38, 4)**** + +Testing decimal(38, 16): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(38, 16)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(38, 16)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(38, 16)**** + +Testing decimal(38, 38): +****PDO param type PDO::PARAM_BOOL is compatible with decimal(38, 38)**** +****PDO param type PDO::PARAM_INT is compatible with decimal(38, 38)**** +****PDO param type PDO::PARAM_STR is compatible with decimal(38, 38)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(38, 38)**** + +Testing numeric(1, 0): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(1, 0)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(1, 0)**** +****PDO param type PDO::PARAM_STR is compatible with numeric(1, 0)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(1, 0)**** + +Testing numeric(1, 1): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(1, 1)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(1, 1)**** +****PDO param type PDO::PARAM_STR is compatible with numeric(1, 1)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(1, 1)**** + +Testing numeric(4, 0): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(4, 0)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(4, 0)**** +****PDO param type PDO::PARAM_STR is compatible with numeric(4, 0)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(4, 0)**** + +Testing numeric(4, 1): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(4, 1)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(4, 1)**** +****PDO param type PDO::PARAM_STR is compatible with numeric(4, 1)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(4, 1)**** + +Testing numeric(4, 4): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(4, 4)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(4, 4)**** +****PDO param type PDO::PARAM_STR is compatible with numeric(4, 4)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(4, 4)**** + +Testing numeric(16, 0): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(16, 0)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(16, 0)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(16, 0)**** + +Testing numeric(16, 1): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(16, 1)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(16, 1)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(16, 1)**** + +Testing numeric(16, 4): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(16, 4)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(16, 4)**** +****PDO param type PDO::PARAM_STR is compatible with numeric(16, 4)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(16, 4)**** + +Testing numeric(16, 16): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(16, 16)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(16, 16)**** +****PDO param type PDO::PARAM_STR is compatible with numeric(16, 16)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(16, 16)**** + +Testing numeric(38, 0): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(38, 0)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(38, 0)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(38, 0)**** + +Testing numeric(38, 1): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(38, 1)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(38, 1)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(38, 1)**** + +Testing numeric(38, 4): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(38, 4)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(38, 4)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(38, 4)**** + +Testing numeric(38, 16): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(38, 16)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(38, 16)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(38, 16)**** + +Testing numeric(38, 38): +****PDO param type PDO::PARAM_BOOL is compatible with numeric(38, 38)**** +****PDO param type PDO::PARAM_INT is compatible with numeric(38, 38)**** +****PDO param type PDO::PARAM_STR is compatible with numeric(38, 38)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(38, 38)**** \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_float_bits.phpt b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_float_bits.phpt new file mode 100644 index 00000000..d42c5281 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_float_bits.phpt @@ -0,0 +1,132 @@ +--TEST-- +Test for inserting and retrieving encrypted data of numeric types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + new BindParamOp(1, $inputValues[0], $pdoParamType), "c_rand" => new BindParamOp(2, $inputValues[1], $pdoParamType)), "prepareBindParam", $r); + if ($r === false) { + isIncompatibleTypesError($stmt, $type, $pdoParamType); + } else { + echo "****PDO param type $pdoParamType is compatible with encrypted $type****\n"; + fetchAll($conn, $tbname); + } + $conn->query("TRUNCATE TABLE $tbname"); + } + dropTable($conn, $tbname); + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing float(1): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted float(1)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 +****PDO param type PDO::PARAM_NULL is compatible with encrypted float(1)**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted float(1)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 +****PDO param type PDO::PARAM_STR is compatible with encrypted float(1)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 +****PDO param type PDO::PARAM_LOB is compatible with encrypted float(1)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 + +Testing float(12): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted float(12)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 +****PDO param type PDO::PARAM_NULL is compatible with encrypted float(12)**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted float(12)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 +****PDO param type PDO::PARAM_STR is compatible with encrypted float(12)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 +****PDO param type PDO::PARAM_LOB is compatible with encrypted float(12)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 + +Testing float(24): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted float(24)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 +****PDO param type PDO::PARAM_NULL is compatible with encrypted float(24)**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted float(24)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 +****PDO param type PDO::PARAM_STR is compatible with encrypted float(24)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 +****PDO param type PDO::PARAM_LOB is compatible with encrypted float(24)**** +c_det: 9.223372E+18 +c_rand: -9.223372E+18 + +Testing float(36): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted float(36)**** +c_det: 9.2233720368547758E+18 +c_rand: -9.2233720368547758E+18 +****PDO param type PDO::PARAM_NULL is compatible with encrypted float(36)**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted float(36)**** +c_det: 9.2233720368547758E+18 +c_rand: -9.2233720368547758E+18 +****PDO param type PDO::PARAM_STR is compatible with encrypted float(36)**** +c_det: 9.2233720368548004E+18 +c_rand: -9.2233720368548004E+18 +****PDO param type PDO::PARAM_LOB is compatible with encrypted float(36)**** +c_det: 9.2233720368547758E+18 +c_rand: -9.2233720368547758E+18 + +Testing float(53): +****PDO param type PDO::PARAM_BOOL is compatible with encrypted float(53)**** +c_det: 9.2233720368547758E+18 +c_rand: -9.2233720368547758E+18 +****PDO param type PDO::PARAM_NULL is compatible with encrypted float(53)**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted float(53)**** +c_det: 9.2233720368547758E+18 +c_rand: -9.2233720368547758E+18 +****PDO param type PDO::PARAM_STR is compatible with encrypted float(53)**** +c_det: 9.2233720368548004E+18 +c_rand: -9.2233720368548004E+18 +****PDO param type PDO::PARAM_LOB is compatible with encrypted float(53)**** +c_det: 9.2233720368547758E+18 +c_rand: -9.2233720368547758E+18 \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_nchar_size.phpt b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_nchar_size.phpt new file mode 100644 index 00000000..f665ed92 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_nchar_size.phpt @@ -0,0 +1,244 @@ +--TEST-- +Test for inserting and retrieving encrypted data of string types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + new BindParamOp(1, $input, $pdoParamType)), "prepareBindParam", $r); + + if ($r === false) { + isIncompatibleTypesError($stmt, $type, $pdoParamType); + } else { + $sql = "SELECT c1 FROM $tbname"; + $stmt = $conn->query($sql); + $row = $stmt->fetch(PDO::FETCH_ASSOC); + if (strlen($row['c1']) == $length) { + echo "****PDO param type $pdoParamType is compatible with $encType encrypted $type****\n"; + } else { + echo "PDO param type $pdoParamType is incompatible with $encType encrypted $type\n"; + } + } + $conn->query("TRUNCATE TABLE $tbname"); + } + dropTable($conn, $tbname); + } + } + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing nchar(1): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nchar(1)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nchar(1) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nchar(1)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nchar(1)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nchar(1)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nchar(1)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nchar(1) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nchar(1)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nchar(1)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nchar(1)**** + +Testing nchar(8): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nchar(8)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nchar(8) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nchar(8)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nchar(8)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nchar(8)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nchar(8)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nchar(8) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nchar(8)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nchar(8)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nchar(8)**** + +Testing nchar(64): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nchar(64)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nchar(64) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nchar(64)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nchar(64)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nchar(64)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nchar(64)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nchar(64) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nchar(64)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nchar(64)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nchar(64)**** + +Testing nchar(512): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nchar(512)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nchar(512) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nchar(512)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nchar(512)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nchar(512)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nchar(512)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nchar(512) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nchar(512)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nchar(512)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nchar(512)**** + +Testing nchar(4000): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nchar(4000)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nchar(4000) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nchar(4000)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nchar(4000)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nchar(4000)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nchar(4000)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nchar(4000) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nchar(4000)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nchar(4000)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nchar(4000)**** + +Testing nvarchar(1): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nvarchar(1)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nvarchar(1) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nvarchar(1)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nvarchar(1)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nvarchar(1)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nvarchar(1)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nvarchar(1) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nvarchar(1)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nvarchar(1)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nvarchar(1)**** + +Testing nvarchar(8): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nvarchar(8)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nvarchar(8) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nvarchar(8)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nvarchar(8)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nvarchar(8)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nvarchar(8)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nvarchar(8) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nvarchar(8)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nvarchar(8)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nvarchar(8)**** + +Testing nvarchar(64): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nvarchar(64)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nvarchar(64) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nvarchar(64)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nvarchar(64)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nvarchar(64)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nvarchar(64)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nvarchar(64) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nvarchar(64)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nvarchar(64)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nvarchar(64)**** + +Testing nvarchar(512): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nvarchar(512)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nvarchar(512) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nvarchar(512)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nvarchar(512)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nvarchar(512)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nvarchar(512)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nvarchar(512) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nvarchar(512)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nvarchar(512)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nvarchar(512)**** + +Testing nvarchar(4000): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nvarchar(4000)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nvarchar(4000) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nvarchar(4000)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nvarchar(4000)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nvarchar(4000)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nvarchar(4000)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nvarchar(4000) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nvarchar(4000)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nvarchar(4000)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nvarchar(4000)**** + +Testing nvarchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nvarchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nvarchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nvarchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nvarchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nvarchar(max)**** + +Testing nvarchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nvarchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nvarchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nvarchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nvarchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nvarchar(max)**** + +Testing nvarchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nvarchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nvarchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nvarchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nvarchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nvarchar(max)**** + +Testing nvarchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nvarchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nvarchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nvarchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nvarchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nvarchar(max)**** + +Testing nvarchar(max): +****PDO param type PDO::PARAM_BOOL is compatible with deterministic encrypted nvarchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with deterministic encrypted nvarchar(max) +****PDO param type PDO::PARAM_INT is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with deterministic encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_BOOL is compatible with randomized encrypted nvarchar(max)**** +PDO param type PDO::PARAM_NULL is incompatible with randomized encrypted nvarchar(max) +****PDO param type PDO::PARAM_INT is compatible with randomized encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_STR is compatible with randomized encrypted nvarchar(max)**** +****PDO param type PDO::PARAM_LOB is compatible with randomized encrypted nvarchar(max)**** \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_numeric.phpt b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_numeric.phpt index 6dc7f755..9e540021 100644 --- a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_numeric.phpt +++ b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_numeric.phpt @@ -8,7 +8,7 @@ Use PDOstatement::bindParam with all PDO::PARAM_ types new BindParamOp(1, (string)$inputValues[0], $pdoParamType), "c_rand" => new BindParamOp(2, (string)$inputValues[1], $pdoParamType)), "prepareBindParam", $r); - } else { - $stmt = insertRow($conn, $tbname, array( "c_det" => new BindParamOp(1, $inputValues[0], $pdoParamType), "c_rand" => new BindParamOp(2, $inputValues[1], $pdoParamType)), "prepareBindParam", $r); - } + $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 { @@ -46,14 +42,13 @@ try { } ?> --EXPECT-- - Testing bit: ****PDO param type PDO::PARAM_BOOL is compatible with encrypted bit**** c_det: 1 c_rand: 0 ****PDO param type PDO::PARAM_NULL is compatible with encrypted bit**** -c_det: -c_rand: +c_det: +c_rand: ****PDO param type PDO::PARAM_INT is compatible with encrypted bit**** c_det: 1 c_rand: 0 @@ -69,8 +64,8 @@ Testing tinyint: c_det: 0 c_rand: 1 ****PDO param type PDO::PARAM_NULL is compatible with encrypted tinyint**** -c_det: -c_rand: +c_det: +c_rand: ****PDO param type PDO::PARAM_INT is compatible with encrypted tinyint**** c_det: 0 c_rand: 255 @@ -86,8 +81,8 @@ Testing smallint: c_det: 1 c_rand: 1 ****PDO param type PDO::PARAM_NULL is compatible with encrypted smallint**** -c_det: -c_rand: +c_det: +c_rand: ****PDO param type PDO::PARAM_INT is compatible with encrypted smallint**** c_det: -32767 c_rand: 32767 @@ -103,8 +98,8 @@ Testing int: c_det: 1 c_rand: 1 ****PDO param type PDO::PARAM_NULL is compatible with encrypted int**** -c_det: -c_rand: +c_det: +c_rand: ****PDO param type PDO::PARAM_INT is compatible with encrypted int**** c_det: -2147483647 c_rand: 2147483647 @@ -115,64 +110,30 @@ c_rand: 2147483647 c_det: -2147483647 c_rand: 2147483647 -Testing decimal(18,5): -****PDO param type PDO::PARAM_BOOL is compatible with encrypted decimal(18,5)**** -c_det: -9223372036854.80000 -c_rand: 9223372036854.80000 -****PDO param type PDO::PARAM_NULL is compatible with encrypted decimal(18,5)**** -c_det: -c_rand: -****PDO param type PDO::PARAM_INT is compatible with encrypted decimal(18,5)**** -c_det: -9223372036854.80000 -c_rand: 9223372036854.80000 -****PDO param type PDO::PARAM_STR is compatible with encrypted decimal(18,5)**** -c_det: -9223372036854.80000 -c_rand: 9223372036854.80000 -****PDO param type PDO::PARAM_LOB is compatible with encrypted decimal(18,5)**** -c_det: -9223372036854.80000 -c_rand: 9223372036854.80000 - -Testing numeric(10,5): -****PDO param type PDO::PARAM_BOOL is compatible with encrypted numeric(10,5)**** -c_det: -21474.83647 -c_rand: 21474.83647 -****PDO param type PDO::PARAM_NULL is compatible with encrypted numeric(10,5)**** -c_det: -c_rand: -****PDO param type PDO::PARAM_INT is compatible with encrypted numeric(10,5)**** -c_det: -21474.83647 -c_rand: 21474.83647 -****PDO param type PDO::PARAM_STR is compatible with encrypted numeric(10,5)**** -c_det: -21474.83647 -c_rand: 21474.83647 -****PDO param type PDO::PARAM_LOB is compatible with encrypted numeric(10,5)**** -c_det: -21474.83647 -c_rand: 21474.83647 - -Testing float: -****PDO param type PDO::PARAM_BOOL is compatible with encrypted float**** -c_det: -9223372036.8547993 -c_rand: 9223372036.8547993 -****PDO param type PDO::PARAM_NULL is compatible with encrypted float**** -c_det: -c_rand: -****PDO param type PDO::PARAM_INT is compatible with encrypted float**** -c_det: -9223372036.8547993 -c_rand: 9223372036.8547993 -****PDO param type PDO::PARAM_STR is compatible with encrypted float**** -c_det: -9223372036.8547993 -c_rand: 9223372036.8547993 -****PDO param type PDO::PARAM_LOB is compatible with encrypted float**** -c_det: -9223372036.8547993 -c_rand: 9223372036.8547993 +Testing bigint: +****PDO param type PDO::PARAM_BOOL is compatible with encrypted bigint**** +c_det: 1 +c_rand: 1 +****PDO param type PDO::PARAM_NULL is compatible with encrypted bigint**** +c_det: +c_rand: +****PDO param type PDO::PARAM_INT is compatible with encrypted bigint**** +c_det: -922337203685479936 +c_rand: 922337203685479936 +****PDO param type PDO::PARAM_STR is compatible with encrypted bigint**** +c_det: -922337203685479936 +c_rand: 922337203685479936 +****PDO param type PDO::PARAM_LOB is compatible with encrypted bigint**** +c_det: -922337203685479936 +c_rand: 922337203685479936 Testing real: ****PDO param type PDO::PARAM_BOOL is compatible with encrypted real**** c_det: -2147.4829 c_rand: 2147.4829 ****PDO param type PDO::PARAM_NULL is compatible with encrypted real**** -c_det: -c_rand: +c_det: +c_rand: ****PDO param type PDO::PARAM_INT is compatible with encrypted real**** c_det: -2147.4829 c_rand: 2147.4829 @@ -181,4 +142,4 @@ c_det: -2147.4829 c_rand: 2147.4829 ****PDO param type PDO::PARAM_LOB is compatible with encrypted real**** c_det: -2147.4829 -c_rand: 2147.4829 +c_rand: 2147.4829 \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_string.phpt b/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_string.phpt deleted file mode 100644 index 44ec7d0a..00000000 --- a/test/functional/pdo_sqlsrv/pdo_ae_insert_pdoparam_string.phpt +++ /dev/null @@ -1,112 +0,0 @@ ---TEST-- -Test for inserting and retrieving encrypted data of string types ---DESCRIPTION-- -Use PDOstatement::bindParam with all PDO::PARAM_ types ---SKIPIF-- - ---FILE-- - 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"; - fetchAll($conn, $tbname); - } - $conn->query("TRUNCATE TABLE $tbname"); - } - dropTable($conn, $tbname); - } - unset($stmt); - unset($conn); -} catch (PDOException $e) { - echo $e->getMessage(); -} -?> ---EXPECT-- - -Testing char(5): -****PDO param type PDO::PARAM_BOOL is compatible with encrypted char(5)**** -c_det: -leng -c_rand: th, n -****PDO param type PDO::PARAM_NULL is compatible with encrypted char(5)**** -c_det: -c_rand: -****PDO param type PDO::PARAM_INT is compatible with encrypted char(5)**** -c_det: -leng -c_rand: th, n -****PDO param type PDO::PARAM_STR is compatible with encrypted char(5)**** -c_det: -leng -c_rand: th, n -****PDO param type PDO::PARAM_LOB is compatible with encrypted char(5)**** -c_det: -leng -c_rand: th, n - -Testing varchar(max): -****PDO param type PDO::PARAM_BOOL is compatible with encrypted varchar(max)**** -c_det: Use varchar(max) when the sizes of the column data entries vary considerably, and the size might exceed 8,000 bytes. -c_rand: Each non-null varchar(max) or nvarchar(max) column requires 24 bytes of additional fixed allocation which counts against the 8,060 byte row limit during a sort operation. -****PDO param type PDO::PARAM_NULL is compatible with encrypted varchar(max)**** -c_det: -c_rand: -****PDO param type PDO::PARAM_INT is compatible with encrypted varchar(max)**** -c_det: Use varchar(max) when the sizes of the column data entries vary considerably, and the size might exceed 8,000 bytes. -c_rand: Each non-null varchar(max) or nvarchar(max) column requires 24 bytes of additional fixed allocation which counts against the 8,060 byte row limit during a sort operation. -****PDO param type PDO::PARAM_STR is compatible with encrypted varchar(max)**** -c_det: Use varchar(max) when the sizes of the column data entries vary considerably, and the size might exceed 8,000 bytes. -c_rand: Each non-null varchar(max) or nvarchar(max) column requires 24 bytes of additional fixed allocation which counts against the 8,060 byte row limit during a sort operation. -****PDO param type PDO::PARAM_LOB is compatible with encrypted varchar(max)**** -c_det: Use varchar(max) when the sizes of the column data entries vary considerably, and the size might exceed 8,000 bytes. -c_rand: Each non-null varchar(max) or nvarchar(max) column requires 24 bytes of additional fixed allocation which counts against the 8,060 byte row limit during a sort operation. - -Testing nchar(5): -****PDO param type PDO::PARAM_BOOL is compatible with encrypted nchar(5)**** -c_det: -leng -c_rand: th Un -****PDO param type PDO::PARAM_NULL is compatible with encrypted nchar(5)**** -c_det: -c_rand: -****PDO param type PDO::PARAM_INT is compatible with encrypted nchar(5)**** -c_det: -leng -c_rand: th Un -****PDO param type PDO::PARAM_STR is compatible with encrypted nchar(5)**** -c_det: -leng -c_rand: th Un -****PDO param type PDO::PARAM_LOB is compatible with encrypted nchar(5)**** -c_det: -leng -c_rand: th Un - -Testing nvarchar(max): -****PDO param type PDO::PARAM_BOOL is compatible with encrypted nvarchar(max)**** -c_det: 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). -c_rand: Otherwise, the implicit conversion will result in a Unicode large-value (max). -****PDO param type PDO::PARAM_NULL is compatible with encrypted nvarchar(max)**** -c_det: -c_rand: -****PDO param type PDO::PARAM_INT is compatible with encrypted nvarchar(max)**** -c_det: 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). -c_rand: Otherwise, the implicit conversion will result in a Unicode large-value (max). -****PDO param type PDO::PARAM_STR is compatible with encrypted nvarchar(max)**** -c_det: 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). -c_rand: Otherwise, the implicit conversion will result in a Unicode large-value (max). -****PDO param type PDO::PARAM_LOB is compatible with encrypted nvarchar(max)**** -c_det: 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). -c_rand: Otherwise, the implicit conversion will result in a Unicode large-value (max).