diff --git a/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_binary_size.phpt b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_binary_size.phpt new file mode 100644 index 00000000..f5663123 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_binary_size.phpt @@ -0,0 +1,128 @@ +--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, $input0, "PDO::PARAM_LOB", 0, "PDO::SQLSRV_ENCODING_BINARY"), + "c_rand" => new BindParamOp(2, $input1, "PDO::PARAM_LOB", 0, "PDO::SQLSRV_ENCODING_BINARY")), "prepareBindParam"); + + // fetch with PDO::bindColumn and PDO::FETCH_BOUND + $query = "SELECT c_det, c_rand FROM $tbname"; + foreach ($pdoParamTypes as $pdoParamType) { + $det = ""; + $rand = ""; + $stmt = $conn->prepare($query); + $stmt->execute(); + $stmt->bindColumn('c_det', $det, constant($pdoParamType)); + $stmt->bindColumn('c_rand', $rand, constant($pdoParamType)); + $row = $stmt->fetch(PDO::FETCH_BOUND); + + if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") { + if (!is_null($det) || !is_null($rand)) { + echo "Retrieving encrypted $type data as $pdoParamType should not work\n"; + } + } else { + if (strlen($det) == $length && strlen($rand) == $length) { + echo "****PDO param type $pdoParamType is compatible with encrypted $type****\n"; + } else { + echo "Data corruption when fetching encrypted $type as PDO param type $pdoParamType\n"; + print_r($stmt->errorInfo()); + } + } + } + dropTable($conn, $tbname); + } + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing binary(1): +****PDO param type PDO::PARAM_STR is compatible with encrypted binary(1)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted binary(1)**** + +Testing binary(8): +****PDO param type PDO::PARAM_STR is compatible with encrypted binary(8)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted binary(8)**** + +Testing binary(64): +****PDO param type PDO::PARAM_STR is compatible with encrypted binary(64)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted binary(64)**** + +Testing binary(512): +****PDO param type PDO::PARAM_STR is compatible with encrypted binary(512)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted binary(512)**** + +Testing binary(4000): +****PDO param type PDO::PARAM_STR is compatible with encrypted binary(4000)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted binary(4000)**** + +Testing varbinary(1): +****PDO param type PDO::PARAM_STR is compatible with encrypted varbinary(1)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted varbinary(1)**** + +Testing varbinary(8): +****PDO param type PDO::PARAM_STR is compatible with encrypted varbinary(8)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted varbinary(8)**** + +Testing varbinary(64): +****PDO param type PDO::PARAM_STR is compatible with encrypted varbinary(64)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted varbinary(64)**** + +Testing varbinary(512): +****PDO param type PDO::PARAM_STR is compatible with encrypted varbinary(512)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted varbinary(512)**** + +Testing varbinary(4000): +****PDO param type PDO::PARAM_STR is compatible with encrypted varbinary(4000)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted varbinary(4000)**** + +Testing varbinary(max): +****PDO param type PDO::PARAM_STR is compatible with encrypted varbinary(max)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted varbinary(max)**** + +Testing varbinary(max): +****PDO param type PDO::PARAM_STR is compatible with encrypted varbinary(max)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted varbinary(max)**** + +Testing varbinary(max): +****PDO param type PDO::PARAM_STR is compatible with encrypted varbinary(max)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted varbinary(max)**** + +Testing varbinary(max): +****PDO param type PDO::PARAM_STR is compatible with encrypted varbinary(max)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted varbinary(max)**** + +Testing varbinary(max): +****PDO param type PDO::PARAM_STR is compatible with encrypted varbinary(max)**** +****PDO param type PDO::PARAM_LOB is compatible with encrypted varbinary(max)**** \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_char_size.phpt b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_char_size.phpt new file mode 100644 index 00000000..38ec9f85 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_char_size.phpt @@ -0,0 +1,175 @@ +--TEST-- +Test for inserting and retrieving encrypted data of numeric types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + $input)); + + // fetch with PDO::bindColumn and PDO::FETCH_BOUND + $query = "SELECT c1 FROM $tbname"; + foreach ($pdoParamTypes as $pdoParamType) { + $det = ""; + $rand = ""; + $stmt = $conn->prepare($query); + $stmt->execute(); + $stmt->bindColumn('c1', $c1, constant($pdoParamType)); + $row = $stmt->fetch(PDO::FETCH_BOUND); + + if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") { + if (!empty($det) || !empty($rand)) { + echo "Fetching $type as PDO param type $pdoParamType should be empty\n"; + } + } else { + if (strlen($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"; + } + } + } + dropTable($conn, $tbname); + } + } + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing 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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_bindColumn_pdoparam_datetime.phpt b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_datetime.phpt new file mode 100644 index 00000000..d48d0024 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_datetime.phpt @@ -0,0 +1,77 @@ +--TEST-- +Test for inserting and retrieving encrypted data of datetime types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + $inputValues[0], "c_rand" => $inputValues[1])); + + // fetch with PDO::bindColumn and PDO::FETCH_BOUND + $query = "SELECT c_det, c_rand FROM $tbname"; + foreach ($pdoParamTypes as $pdoParamType) { + $det = ""; + $rand = ""; + $stmt = $conn->prepare($query); + $stmt->execute(); + $stmt->bindColumn('c_det', $det, constant($pdoParamType)); + $stmt->bindColumn('c_rand', $rand, constant($pdoParamType)); + $row = $stmt->fetch(PDO::FETCH_BOUND); + + if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") { + if (!is_null($det) || !is_null($rand)) { + echo "Retrieving encrypted $type data as $pdoParamType should not work\n"; + } + } else { + echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n"; + echo "c_det: $det\n"; + echo "c_rand: $rand\n"; + } + } + dropTable($conn, $tbname); + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing date: +****PDO param type PDO::PARAM_STR is compatible with encrypted date**** +c_det: 0001-01-01 +c_rand: 9999-12-31 +****PDO param type PDO::PARAM_LOB is compatible with encrypted date**** +c_det: 0001-01-01 +c_rand: 9999-12-31 + +Testing datetime: +****PDO param type PDO::PARAM_STR is compatible with encrypted datetime**** +c_det: 1753-01-01 00:00:00.000 +c_rand: 9999-12-31 23:59:59.997 +****PDO param type PDO::PARAM_LOB is compatible with encrypted datetime**** +c_det: 1753-01-01 00:00:00.000 +c_rand: 9999-12-31 23:59:59.997 + +Testing smalldatetime: +****PDO param type PDO::PARAM_STR 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_LOB is compatible with encrypted smalldatetime**** +c_det: 1900-01-01 00:00:00 +c_rand: 2079-06-05 23:59:00 \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_datetime_precision.phpt b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_datetime_precision.phpt new file mode 100644 index 00000000..83a4d6e9 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_datetime_precision.phpt @@ -0,0 +1,170 @@ +--TEST-- +Test for inserting and retrieving encrypted data of numeric 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); + insertRow($conn, $tbname, array("c_det" => $inputValues[0], "c_rand" => $inputValues[1])); + + // fetch with PDO::bindColumn and PDO::FETCH_BOUND + $query = "SELECT c_det, c_rand FROM $tbname"; + foreach ($pdoParamTypes as $pdoParamType) { + $det = ""; + $rand = ""; + $stmt = $conn->prepare($query); + $stmt->execute(); + $stmt->bindColumn('c_det', $det, constant($pdoParamType)); + $stmt->bindColumn('c_rand', $rand, constant($pdoParamType)); + $row = $stmt->fetch(PDO::FETCH_BOUND); + + if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") { + if (!is_null($det) || !is_null($rand)) { + echo "Retrieving encrypted $type data as $pdoParamType should not work\n"; + } + } else { + echo "****PDO param type $pdoParamType is compatible with encrypted $type****\n"; + echo "c_det: $det\n"; + echo "c_rand: $rand\n"; + } + } + dropTable($conn, $tbname); + } + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing datetime2(1): +****PDO param type PDO::PARAM_STR is compatible with encrypted datetime2(1)**** +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(1)**** +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_STR is compatible with encrypted datetime2(2)**** +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(2)**** +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_STR is compatible with encrypted datetime2(4)**** +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(4)**** +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_STR is compatible with encrypted datetime2(7)**** +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(7)**** +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_STR is compatible with encrypted datetimeoffset(1)**** +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(1)**** +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_STR is compatible with encrypted datetimeoffset(2)**** +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(2)**** +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_STR is compatible with encrypted datetimeoffset(4)**** +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(4)**** +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_STR is compatible with encrypted datetimeoffset(7)**** +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(7)**** +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_STR is compatible with encrypted time(1)**** +c_det: 00:00:00.0 +c_rand: 23:59:59.9 +****PDO param type PDO::PARAM_LOB is compatible with encrypted time(1)**** +c_det: 00:00:00.0 +c_rand: 23:59:59.9 + +Testing time(2): +****PDO param type PDO::PARAM_STR is compatible with encrypted time(2)**** +c_det: 00:00:00.00 +c_rand: 23:59:59.99 +****PDO param type PDO::PARAM_LOB is compatible with encrypted time(2)**** +c_det: 00:00:00.00 +c_rand: 23:59:59.99 + +Testing time(4): +****PDO param type PDO::PARAM_STR is compatible with encrypted time(4)**** +c_det: 00:00:00.0000 +c_rand: 23:59:59.9999 +****PDO param type PDO::PARAM_LOB is compatible with encrypted time(4)**** +c_det: 00:00:00.0000 +c_rand: 23:59:59.9999 + +Testing time(7): +****PDO param type PDO::PARAM_STR is compatible with encrypted time(7)**** +c_det: 00:00:00.0000000 +c_rand: 23:59:59.9999999 +****PDO param type PDO::PARAM_LOB is compatible with encrypted time(7)**** +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_bindColumn_pdoparam_decimal_precision.phpt b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_decimal_precision.phpt new file mode 100644 index 00000000..c8cecc0f --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_decimal_precision.phpt @@ -0,0 +1,233 @@ +--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 + // float in PHP only has a precision of roughtly 14 digits: http://php.net/manual/en/language.types.float.php + $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 and populate table + $tbname = "test_decimal"; + $colMetaArr = array(new ColumnMeta($type, "c_det"), new ColumnMeta($type, "c_rand", null, "randomized")); + createTable($conn, $tbname, $colMetaArr); + insertRow($conn, $tbname, array("c_det" => $inputValues[0], "c_rand" => $inputValues[1])); + + // fetch with PDO::bindColumn and PDO::FETCH_BOUND + $query = "SELECT c_det, c_rand FROM $tbname"; + foreach ($pdoParamTypes as $pdoParamType) { + $det = ""; + $rand = ""; + $stmt = $conn->prepare($query); + $stmt->execute(); + $stmt->bindColumn('c_det', $det, constant($pdoParamType)); + $stmt->bindColumn('c_rand', $rand, constant($pdoParamType)); + $row = $stmt->fetch(PDO::FETCH_BOUND); + + // assumes the correct behavior of fetching decimal types as PDO::PARAM_BOOL, PDO::PARAM_NULL and PDO::PARAM_INT is to return NULL + // behavior for fetching decimals as PARAM_BOOL and PARAM_INT varies depending on the number being fetched: + // 1. if the number is less than 1, returns 0 (even though the number being fetched is 0.9) + // 2. if the number is greater than 1 and the number of digits is less than 11, returns the correctly rounded integer (e.g., returns 922 when fetching 922.3) + // 3. if the number is greater than 1 and the number of digits is greater than 11, returns NULL + // see VSO item 2730 + if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") { + if (!is_null($det) || !is_null($rand)) { + echo "Fetching $type as PDO param type $pdoParamType should return NULL\n"; + } + } else { + if (abs($det - $inputValues[0]) > $epsilon || + abs($rand - $inputValues[1]) > $epsilon) { + echo "PDO param type $pdoParamType should be compatible with $type\n"; + } else { + echo "****PDO param type $pdoParamType is compatible with $type****\n"; + } + } + } + dropTable($conn, $tbname); + } + } + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing decimal(1, 0): +Fetching decimal(1, 0) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching decimal(1, 0) as PDO param type PDO::PARAM_INT should return NULL +****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): +Fetching decimal(1, 1) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching decimal(1, 1) as PDO param type PDO::PARAM_INT should return NULL +****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): +Fetching decimal(4, 0) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching decimal(4, 0) as PDO param type PDO::PARAM_INT should return NULL +****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): +Fetching decimal(4, 1) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching decimal(4, 1) as PDO param type PDO::PARAM_INT should return NULL +****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): +Fetching decimal(4, 4) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching decimal(4, 4) as PDO param type PDO::PARAM_INT should return NULL +****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_STR 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_STR 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_STR is compatible with decimal(16, 4)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(16, 4)**** + +Testing decimal(16, 16): +Fetching decimal(16, 16) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching decimal(16, 16) as PDO param type PDO::PARAM_INT should return NULL +****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_STR 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_STR 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_STR 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_STR is compatible with decimal(38, 16)**** +****PDO param type PDO::PARAM_LOB is compatible with decimal(38, 16)**** + +Testing decimal(38, 38): +Fetching decimal(38, 38) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching decimal(38, 38) as PDO param type PDO::PARAM_INT should return NULL +****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): +Fetching numeric(1, 0) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching numeric(1, 0) as PDO param type PDO::PARAM_INT should return NULL +****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): +Fetching numeric(1, 1) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching numeric(1, 1) as PDO param type PDO::PARAM_INT should return NULL +****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): +Fetching numeric(4, 0) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching numeric(4, 0) as PDO param type PDO::PARAM_INT should return NULL +****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): +Fetching numeric(4, 1) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching numeric(4, 1) as PDO param type PDO::PARAM_INT should return NULL +****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): +Fetching numeric(4, 4) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching numeric(4, 4) as PDO param type PDO::PARAM_INT should return NULL +****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_STR 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_STR 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_STR is compatible with numeric(16, 4)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(16, 4)**** + +Testing numeric(16, 16): +Fetching numeric(16, 16) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching numeric(16, 16) as PDO param type PDO::PARAM_INT should return NULL +****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_STR 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_STR 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_STR 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_STR is compatible with numeric(38, 16)**** +****PDO param type PDO::PARAM_LOB is compatible with numeric(38, 16)**** + +Testing numeric(38, 38): +Fetching numeric(38, 38) as PDO param type PDO::PARAM_BOOL should return NULL +Fetching numeric(38, 38) as PDO param type PDO::PARAM_INT should return NULL +****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_bindColumn_pdoparam_float_bits.phpt b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_float_bits.phpt new file mode 100644 index 00000000..f0fad384 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_float_bits.phpt @@ -0,0 +1,96 @@ +--TEST-- +Test for inserting and retrieving encrypted data of numeric types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + $inputValues[0], "c_rand" => $inputValues[1])); + + // fetch with PDO::bindColumn and PDO::FETCH_BOUND + $query = "SELECT c_det, c_rand FROM $tbname"; + foreach ($pdoParamTypes as $pdoParamType) { + $det = ""; + $rand = ""; + $stmt = $conn->prepare($query); + $stmt->execute(); + $stmt->bindColumn('c_det', $det, constant($pdoParamType)); + $stmt->bindColumn('c_rand', $rand, constant($pdoParamType)); + $row = $stmt->fetch(PDO::FETCH_BOUND); + + if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") { + if (!is_null($det) || !is_null($rand)) { + echo "Fetching $type as PDO param type $pdoParamType should return NULL\n"; + } + } else { + echo "****PDO param type $pdoParamType is compatible with encrypted $type****\n"; + echo "c_det: $det\n"; + echo "c_rand: $rand\n"; + } + } + dropTable($conn, $tbname); + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing float(1): +****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_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_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_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.2233720368548004E+18 +c_rand: -9.2233720368548004E+18 + +Testing float(53): +****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.2233720368548004E+18 +c_rand: -9.2233720368548004E+18 \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_nchar_size.phpt b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_nchar_size.phpt new file mode 100644 index 00000000..1eee9981 --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_nchar_size.phpt @@ -0,0 +1,156 @@ +--TEST-- +Test for inserting and retrieving encrypted data of numeric types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + $input)); + + // fetch with PDO::bindColumn and PDO::FETCH_BOUND + $query = "SELECT c1 FROM $tbname"; + foreach ($pdoParamTypes as $pdoParamType) { + $det = ""; + $rand = ""; + $stmt = $conn->prepare($query); + $stmt->execute(); + $stmt->bindColumn('c1', $c1, constant($pdoParamType)); + $row = $stmt->fetch(PDO::FETCH_BOUND); + if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") { + if (!empty($det) || !empty($rand)) { + echo "Fetching $type as PDO param type $pdoParamType should be empty\n"; + } + } else { + if (strlen($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"; + } + } + } + dropTable($conn, $tbname); + } + } + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--EXPECT-- +Testing 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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_bindColumn_pdoparam_numeric.phpt b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_numeric.phpt new file mode 100644 index 00000000..705d02cf --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_ae_bindColumn_pdoparam_numeric.phpt @@ -0,0 +1,138 @@ +--TEST-- +Test for inserting and retrieving encrypted data of numeric types +--DESCRIPTION-- +Use PDOstatement::bindParam with all PDO::PARAM_ types +--SKIPIF-- + +--FILE-- + $inputValues[0], "c_rand" => $inputValues[1])); + + // fetch with PDO::bindColumn and PDO::FETCH_BOUND + $query = "SELECT c_det, c_rand FROM $tbname"; + foreach ($pdoParamTypes as $pdoParamType) { + $det = ""; + $rand = ""; + $stmt = $conn->prepare($query); + $stmt->execute(); + $stmt->bindColumn('c_det', $det, constant($pdoParamType)); + $stmt->bindColumn('c_rand', $rand, constant($pdoParamType)); + $row = $stmt->fetch(PDO::FETCH_BOUND); + if ($row != false) { + if (is_null($det) || is_null($rand)) { + echo "PDO param type $pdoParamType is not compatible with encrypted $dataType\n"; + } else { + echo "****PDO param type $pdoParamType is compatible with encrypted $dataType****\n"; + echo "c_det: $det\n"; + echo "c_rand: $rand\n"; + } + } + } + dropTable($conn, $tbname); + } + unset($stmt); + unset($conn); +} catch (PDOException $e) { + echo $e->getMessage(); +} +?> +--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 not compatible with encrypted bit +****PDO param type PDO::PARAM_INT is compatible with encrypted bit**** +c_det: 1 +c_rand: 0 +****PDO param type PDO::PARAM_STR is compatible with encrypted bit**** +c_det: 1 +c_rand: 0 +****PDO param type PDO::PARAM_LOB is compatible with encrypted bit**** +c_det: 1 +c_rand: 0 + +Testing tinyint: +****PDO param type PDO::PARAM_BOOL is compatible with encrypted tinyint**** +c_det: 0 +c_rand: 255 +PDO param type PDO::PARAM_NULL is not compatible with encrypted tinyint +****PDO param type PDO::PARAM_INT is compatible with encrypted tinyint**** +c_det: 0 +c_rand: 255 +****PDO param type PDO::PARAM_STR is compatible with encrypted tinyint**** +c_det: 0 +c_rand: 255 +****PDO param type PDO::PARAM_LOB is compatible with encrypted tinyint**** +c_det: 0 +c_rand: 255 + +Testing smallint: +****PDO param type PDO::PARAM_BOOL is compatible with encrypted smallint**** +c_det: -32767 +c_rand: 32767 +PDO param type PDO::PARAM_NULL is not compatible with encrypted smallint +****PDO param type PDO::PARAM_INT is compatible with encrypted smallint**** +c_det: -32767 +c_rand: 32767 +****PDO param type PDO::PARAM_STR is compatible with encrypted smallint**** +c_det: -32767 +c_rand: 32767 +****PDO param type PDO::PARAM_LOB is compatible with encrypted smallint**** +c_det: -32767 +c_rand: 32767 + +Testing int: +****PDO param type PDO::PARAM_BOOL is compatible with encrypted int**** +c_det: -2147483647 +c_rand: 2147483647 +PDO param type PDO::PARAM_NULL is not compatible with encrypted int +****PDO param type PDO::PARAM_INT is compatible with encrypted int**** +c_det: -2147483647 +c_rand: 2147483647 +****PDO param type PDO::PARAM_STR is compatible with encrypted int**** +c_det: -2147483647 +c_rand: 2147483647 +****PDO param type PDO::PARAM_LOB is compatible with encrypted int**** +c_det: -2147483647 +c_rand: 2147483647 + +Testing bigint: +PDO param type PDO::PARAM_BOOL is not compatible with encrypted bigint +PDO param type PDO::PARAM_NULL is not compatible with encrypted bigint +PDO param type PDO::PARAM_INT is not compatible with encrypted bigint +****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 +c_rand: 2147 +PDO param type PDO::PARAM_NULL is not compatible with encrypted real +****PDO param type PDO::PARAM_INT is compatible with encrypted real**** +c_det: -2147 +c_rand: 2147 +****PDO param type PDO::PARAM_STR is compatible with encrypted real**** +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 \ No newline at end of file