Bug #81173 [NEW]: Fatal error. PHP7-8 PG Prepared statement name collision
| From: | kachalin dot alexey at gmail dot com | Date: | Sat, 19 Jun 2021 11:57:13 +0000 |
| Subject: | Bug #81173 [NEW]: Fatal error. PHP7-8 PG Prepared statement name collision | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-234502@lists.php.net to get a copy of this message | ||
From: kachalin dot alexey at gmail dot com
Operating system: Ubuntu
PHP version: 8.0.7
Package: PostgreSQL related
Bug Type: Bug
Bug description:Fatal error. PHP7-8 PG Prepared statement name collision
Description:
------------
Brifely
Prepared SQL name collision, because the name implicitly truncated to 63
first characters of given name.
Current behavior:
Fatal errors and warnings.
Desirable behavior:
No any error or warning.
Uncomment a "//$string63 = 'smallLengthSQL'; line to check execution
with any error.
Affected version.
All 7 and 8.
Latest check on 8.1.
Notice
Don't forget to put your PG server credentials for connection.
Test script:
---------------
<?php
$host = '';
$port = '';// 5432
$db = '';
$user = '';
$pass = '';
$connectString = "host=$host port=$port dbname=$db user=$user
password=$pass";
$pg_pconnect = pg_pconnect($connectString);
$string63 =
'5c6b58ebdd4464734a57a87431ba24b38d2e49ae5c6b58ebdd4464734a57a87';//
length - 63
//$string63 = 'smallLengthSQL';// Uncomment for expected result.
$sqlPreparedNameA = $string63 . '_A';// length - 65 for error case.
$sqlPreparedNameB = $string63 . '_B';// length - 65 for error case.
$sqlPreparedBodyA = 'SELECT $1 as result_1' ;
$sqlPreparedBodyB = 'SELECT $1 as result_1, $2 as result_2';
$pg_prepareA = pg_prepare($pg_pconnect, $sqlPreparedNameA,
$sqlPreparedBodyA);
$pg_prepareA = pg_prepare($pg_pconnect, $sqlPreparedNameB,
$sqlPreparedBodyB);
$pg_executeA = pg_execute($pg_pconnect, $sqlPreparedNameA, array("Result
A1" ));
$pg_executeB = pg_execute($pg_pconnect, $sqlPreparedNameB, array("Result
B1", "Result B2"));
$resultA = pg_fetch_all($pg_executeA);
$resultB = pg_fetch_all($pg_executeB);
var_dump($resultA);
var_dump($resultB);
Expected result:
----------------
array(1) {
[0]=>
array(1) {
["result_1"]=>
string(9) "Result A1"
}
}
array(1) {
[0]=>
array(2) {
["result_1"]=>
string(9) "Result B1"
["result_2"]=>
string(9) "Result B2"
}
}
Actual result:
--------------
Warning: pg_prepare(): Query failed: ERROR: prepared statement
"5c6b58ebdd4464734a57a87431ba24b38d2e49ae5c6b58ebdd4464734a57a87_B"
already exists in
Warning: pg_execute(): Query failed: ERROR: bind message supplies 2
parameters, but prepared statement
"5c6b58ebdd4464734a57a87431ba24b38d2e49ae5c6b58ebdd4464734a57a87_B"
requires 1 in
Fatal error: Uncaught TypeError: pg_fetch_all(): Argument #1 ($result)
must be of type PgSql\Result, bool given in
--
Edit bug report at https://bugs.php.net/bug.php?id=81173&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81173&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81173&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81173&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81173&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81173&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81173&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81173&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81173&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81173&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81173&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81173&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81173&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81173&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81173&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81173&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81173&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81173&r=mysqlcfg