File tree 3 files changed +20
-3
lines changed
3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ PHP NEWS
37
37
- PDO_PGSQL:
38
38
. Fixed GH-15986 (Double-free due to Pdo\Pgsql::setNoticeCallback()). (cmb,
39
39
nielsdos)
40
+ . Fixed GH-12940 (Using PQclosePrepared when available instead of
41
+ the DEALLOCATE command to free statements resources). (David Carlier)
40
42
41
43
- Reflection:
42
44
. Add missing ReflectionProperty::hasHook[s]() methods. (ilutov)
Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ if test "$PHP_PDO_PGSQL" != "no"; then
19
19
or later).] ) ] ,,
20
20
[ $PGSQL_LIBS] )
21
21
22
+ PHP_CHECK_LIBRARY([ pq] , [ PQclosePrepared] ,
23
+ [ AC_DEFINE ( [ HAVE_PQCLOSEPREPARED] , [ 1] ,
24
+ [ Define to 1 if libpq has the 'PQclosePrepared' function (PostgreSQL 17
25
+ or later).] ) ] ,,
26
+ [ $PGSQL_LIBS] )
27
+
22
28
PHP_CHECK_PDO_INCLUDES
23
29
24
30
PHP_NEW_EXTENSION([ pdo_pgsql] ,
Original file line number Diff line number Diff line change @@ -74,12 +74,17 @@ static int pgsql_stmt_dtor(pdo_stmt_t *stmt)
74
74
if (S -> stmt_name ) {
75
75
if (S -> is_prepared && server_obj_usable ) {
76
76
pdo_pgsql_db_handle * H = S -> H ;
77
- char * q = NULL ;
78
77
PGresult * res ;
79
-
78
+ #ifndef HAVE_PQCLOSEPREPARED
79
+ // TODO (??) libpq does not support close statement protocol < postgres 17
80
+ // check if we can circumvent this.
81
+ char * q = NULL ;
80
82
spprintf (& q , 0 , "DEALLOCATE %s" , S -> stmt_name );
81
83
res = PQexec (H -> server , q );
82
84
efree (q );
85
+ #else
86
+ res = PQclosePrepared (H -> server , S -> stmt_name );
87
+ #endif
83
88
if (res ) {
84
89
PQclear (res );
85
90
}
@@ -203,10 +208,14 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt)
203
208
* deallocate it and retry ONCE (thies 2005.12.15)
204
209
*/
205
210
if (sqlstate && !strcmp (sqlstate , "42P05" )) {
206
- char buf [100 ]; /* stmt_name == "pdo_crsr_%08x" */
207
211
PGresult * res ;
212
+ #ifndef HAVE_PQCLOSEPREPARED
213
+ char buf [100 ]; /* stmt_name == "pdo_crsr_%08x" */
208
214
snprintf (buf , sizeof (buf ), "DEALLOCATE %s" , S -> stmt_name );
209
215
res = PQexec (H -> server , buf );
216
+ #else
217
+ res = PQclosePrepared (H -> server , S -> stmt_name );
218
+ #endif
210
219
if (res ) {
211
220
PQclear (res );
212
221
}
You can’t perform that action at this time.
0 commit comments