diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-17 12:05:37 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-12-22 15:56:34 +0100 |
commit | caa710037e663fd78f67533b29611183090068b2 (patch) | |
tree | 7acbcdf527eb148899d6cb90e9f2cb233a3ec2ed /ext/pdo_pgsql/tests | |
parent | 57d69b51373bfb1aa5117022c63c93c612e707f6 (diff) | |
download | php-git-caa710037e663fd78f67533b29611183090068b2.tar.gz |
Rewrite PDO result binding
Instead of requiring the type to be determined in advance by the
describer function and then requiring get_col to return a buffer
of appropriate type, allow get_col to return an arbitrary zval.
See UPGRADING.INTERNALS for a more detailed description of the
change.
This makes the result fetching simpler, more efficient and more
flexible. The general possibility already existed via the special
PDO_PARAM_ZVAL type, but the usage was very inconvenient and/or
inefficient. Now it's possible to easily implement behavior like
"return int if it fits, otherwise string" and to avoid any kind
of complex management of temporary buffers.
This also fixes bug #40913 (our second highest voted bug of all
time, for some reason). PARAM_LOB result bindings will now
consistently return a stream resource, independently of the used
database driver.
I've tried my best to update all PDO drivers for this change, but
some of the changes may be broken, as I cannot test or even build
some of these drivers (in particular PDO dblib and PDO oci).
Fixes are appreciated -- a working CI setup would be even more
appreciated ;)
Diffstat (limited to 'ext/pdo_pgsql/tests')
-rw-r--r-- | ext/pdo_pgsql/tests/bug62498.phpt | 36 | ||||
-rw-r--r-- | ext/pdo_pgsql/tests/debug_emulated_prepares.phpt | 6 |
2 files changed, 21 insertions, 21 deletions
diff --git a/ext/pdo_pgsql/tests/bug62498.phpt b/ext/pdo_pgsql/tests/bug62498.phpt index 1620e7e77a..2970278204 100644 --- a/ext/pdo_pgsql/tests/bug62498.phpt +++ b/ext/pdo_pgsql/tests/bug62498.phpt @@ -56,14 +56,14 @@ array(9) { string(13) "bugtest_62498" ["native_type"]=> string(4) "int2" + ["pdo_type"]=> + int(2) ["name"]=> string(7) "int2col" ["len"]=> int(2) ["precision"]=> int(-1) - ["pdo_type"]=> - int(1) } [1]=> array(8) { @@ -75,14 +75,14 @@ array(9) { string(13) "bugtest_62498" ["native_type"]=> string(4) "int4" + ["pdo_type"]=> + int(2) ["name"]=> string(7) "int4col" ["len"]=> int(4) ["precision"]=> int(-1) - ["pdo_type"]=> - int(1) } [2]=> array(8) { @@ -94,14 +94,14 @@ array(9) { string(13) "bugtest_62498" ["native_type"]=> string(4) "int8" + ["pdo_type"]=> + int(2) ["name"]=> string(7) "int8col" ["len"]=> int(8) ["precision"]=> int(-1) - ["pdo_type"]=> - int(1) } [3]=> array(8) { @@ -113,14 +113,14 @@ array(9) { string(13) "bugtest_62498" ["native_type"]=> string(7) "varchar" + ["pdo_type"]=> + int(3) ["name"]=> string(9) "stringcol" ["len"]=> int(-1) ["precision"]=> int(259) - ["pdo_type"]=> - int(2) } [4]=> array(8) { @@ -132,14 +132,14 @@ array(9) { string(13) "bugtest_62498" ["native_type"]=> string(4) "bool" + ["pdo_type"]=> + int(1) ["name"]=> string(7) "boolcol" ["len"]=> int(1) ["precision"]=> int(-1) - ["pdo_type"]=> - int(5) } [5]=> array(8) { @@ -151,14 +151,14 @@ array(9) { string(13) "bugtest_62498" ["native_type"]=> string(4) "date" + ["pdo_type"]=> + int(3) ["name"]=> string(7) "datecol" ["len"]=> int(4) ["precision"]=> int(-1) - ["pdo_type"]=> - int(2) } [6]=> array(8) { @@ -170,14 +170,14 @@ array(9) { string(13) "bugtest_62498" ["native_type"]=> string(4) "text" + ["pdo_type"]=> + int(3) ["name"]=> string(7) "textcol" ["len"]=> int(-1) ["precision"]=> int(-1) - ["pdo_type"]=> - int(2) } [7]=> array(8) { @@ -189,14 +189,14 @@ array(9) { string(13) "bugtest_62498" ["native_type"]=> string(9) "timestamp" + ["pdo_type"]=> + int(3) ["name"]=> string(5) "tscol" ["len"]=> int(8) ["precision"]=> int(-1) - ["pdo_type"]=> - int(2) } [8]=> array(8) { @@ -208,14 +208,14 @@ array(9) { string(13) "bugtest_62498" ["native_type"]=> string(5) "bytea" + ["pdo_type"]=> + int(4) ["name"]=> string(8) "byteacol" ["len"]=> int(-1) ["precision"]=> int(-1) - ["pdo_type"]=> - int(3) } } Done diff --git a/ext/pdo_pgsql/tests/debug_emulated_prepares.phpt b/ext/pdo_pgsql/tests/debug_emulated_prepares.phpt index dfbbcb4ad4..5c8f590351 100644 --- a/ext/pdo_pgsql/tests/debug_emulated_prepares.phpt +++ b/ext/pdo_pgsql/tests/debug_emulated_prepares.phpt @@ -31,17 +31,17 @@ Key: Name: [5] :bool paramno=-1 name=[5] ":bool" is_param=1 -param_type=2 +param_type=3 Key: Name: [4] :int paramno=-1 name=[4] ":int" is_param=1 -param_type=1 +param_type=2 Key: Name: [7] :string paramno=-1 name=[7] ":string" is_param=1 -param_type=2 +param_type=3 Key: Name: [5] :null paramno=-1 name=[5] ":null" |