File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change 61
61
static int pgsql_stmt_dtor (pdo_stmt_t * stmt )
62
62
{
63
63
pdo_pgsql_stmt * S = (pdo_pgsql_stmt * )stmt -> driver_data ;
64
+ zend_bool server_obj_usable = IS_OBJ_VALID (EG (objects_store ).object_buckets [Z_OBJ_HANDLE (stmt -> database_object_handle )])
65
+ && !(GC_FLAGS (Z_OBJ (stmt -> database_object_handle )) & IS_OBJ_FREE_CALLED );
64
66
65
67
if (S -> result ) {
66
68
/* free the resource */
@@ -69,11 +71,11 @@ static int pgsql_stmt_dtor(pdo_stmt_t *stmt)
69
71
}
70
72
71
73
if (S -> stmt_name ) {
72
- pdo_pgsql_db_handle * H = S -> H ;
73
- char * q = NULL ;
74
- PGresult * res ;
74
+ if (S -> is_prepared && server_obj_usable ) {
75
+ pdo_pgsql_db_handle * H = S -> H ;
76
+ char * q = NULL ;
77
+ PGresult * res ;
75
78
76
- if (S -> is_prepared ) {
77
79
spprintf (& q , 0 , "DEALLOCATE %s" , S -> stmt_name );
78
80
res = PQexec (H -> server , q );
79
81
efree (q );
@@ -106,14 +108,16 @@ static int pgsql_stmt_dtor(pdo_stmt_t *stmt)
106
108
}
107
109
108
110
if (S -> cursor_name ) {
109
- pdo_pgsql_db_handle * H = S -> H ;
110
- char * q = NULL ;
111
- PGresult * res ;
111
+ if (server_obj_usable ) {
112
+ pdo_pgsql_db_handle * H = S -> H ;
113
+ char * q = NULL ;
114
+ PGresult * res ;
112
115
113
- spprintf (& q , 0 , "CLOSE %s" , S -> cursor_name );
114
- res = PQexec (H -> server , q );
115
- efree (q );
116
- if (res ) PQclear (res );
116
+ spprintf (& q , 0 , "CLOSE %s" , S -> cursor_name );
117
+ res = PQexec (H -> server , q );
118
+ efree (q );
119
+ if (res ) PQclear (res );
120
+ }
117
121
efree (S -> cursor_name );
118
122
S -> cursor_name = NULL ;
119
123
}
You can’t perform that action at this time.
0 commit comments