Bug #37870 [Com]: Deallocation of prepared statement that hasn't been allocated under postgresql
Edit report at https://bugs.php.net/bug.php?id=37870&edit=1
ID: 37870
Comment by: aksuska at esoteritech dot com
Reported by: sagi at adamnet dot co dot il
Summary: Deallocation of prepared statement that hasn't been
allocated under postgresql
Status: Closed
Type: Bug
Package: PDO related
Operating System: Debian Sarge
PHP Version: CVS
Block user comment: N
Private report: N
New Comment:
I am experiencing the exact same problem: PDO deallocating a prepared statement that is never called
causes PostgreSQL error but PDO does not capture either the deallocation error nor the transaction
commit error so it causes a silent fail. This is in PHP 5.6.31 on CentOS. Curiously I do not
experience this problem with 5.6.32 on MAMP/Mac OS X.
Previous Comments:
------------------------------------------------------------------------
[2006-09-19 15:46:38] iliaa@php.net
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2006-08-31 16:56:16] konstantin dot ryabitsev at mcgill dot ca
Transaction failing quietly for no reason is a pretty nasty bug. We have just spent several hours
troubleshooting this problem, and I can confirm that the bug is 100% on target. If a prepared
transaction is never executed, the transaction will quietly fail.
------------------------------------------------------------------------
[2006-08-30 08:06:31] ce at netage dot bg
I would suggest the following patch:
--- pgsql_statement.c~ 2006-08-30 10:54:31.000000000 +0300
+++ pgsql_statement.c 2006-08-30 10:54:31.000000000 +0300
@@ -60,10 +60,13 @@ static int pgsql_stmt_dtor(pdo_stmt_t *s
char *q = NULL;
PGresult *res;
- spprintf(&q, 0, "DEALLOCATE %s", S->stmt_name);
- res = PQexec(H->server, q);
- efree(q);
- if (res) PQclear(res);
+ if (S->is_prepared)
+ {
+ spprintf(&q, 0, "DEALLOCATE %s", S->stmt_name);
+ res = PQexec(H->server, q);
+ efree(q);
+ if (res) PQclear(res);
+ }
efree(S->stmt_name);
S->stmt_name = NULL;
}
------------------------------------------------------------------------
[2006-08-20 10:01:15] sagi at adamnet dot co dot il
Same with the latest CVS version:
sagi@future:~/XXX/tmp$ /usr/local/php5-dev/bin/php -v
PHP 5.2.0RC3-dev (cli) (built: Aug 20 2006 12:46:20)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
sagi@future:~/XXX/tmp$ /usr/local/php5-dev/bin/php preptest.php
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[25P02]: In
failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of
transaction block' in /home/XXX/tmp/preptest.php:13
Stack trace:
#0 /home/XXX/tmp/preptest.php(13): PDO->query('SELECT 123')
#1 {main}
thrown in /home/XXX/tmp/preptest.php on line 13
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[25P02]: In
failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of
transaction block' in /home/XXX/tmp/preptest.php:13
Stack trace:
#0 /home/XXX/tmp/preptest.php(13): PDO->query('SELECT 123')
#1 {main}
thrown in /home/XXX/tmp/preptest.php on line 13
sagi@future:~/XXX/tmp$
------------------------------------------------------------------------
[2006-08-10 01:00:00] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=37870
--
Edit this bug report at https://bugs.php.net/bug.php?id=37870&edit=1
Thread (8 messages)