]> granicus.if.org Git - php/commitdiff
- Fixed bug #48188
authorMatteo Beccati <mbeccati@php.net>
Tue, 12 May 2009 22:17:50 +0000 (22:17 +0000)
committerMatteo Beccati <mbeccati@php.net>
Tue, 12 May 2009 22:17:50 +0000 (22:17 +0000)
ext/pdo_pgsql/pgsql_statement.c
ext/pdo_pgsql/php_pdo_pgsql_int.h
ext/pdo_pgsql/tests/bug44861.phpt

index b1fccebcdf461360238e8d5206ad0482995537f5..aa69035f641b0b3dffbca6a832d173e8f38b5a8b 100644 (file)
@@ -131,6 +131,13 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
 
        if (S->cursor_name) {
                char *q = NULL;
+
+               if (S->is_prepared) {
+                       spprintf(&q, 0, "CLOSE %s", S->cursor_name);
+                       S->result = PQexec(H->server, q);
+                       efree(q);
+               }
+
                spprintf(&q, 0, "DECLARE %s SCROLL CURSOR WITH HOLD FOR %s", S->cursor_name, stmt->active_query_string);
                S->result = PQexec(H->server, q);
                efree(q);
@@ -142,6 +149,9 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
                        return 0;
                }
 
+               /* the cursor was declared correctly */
+               S->is_prepared = 1;
+
                /* fetch to be able to get the number of tuples later, but don't advance the cursor pointer */
                spprintf(&q, 0, "FETCH FORWARD 0 FROM %s", S->cursor_name);
                S->result = PQexec(H->server, q);
index 42e96e10a7b2fc060db24f667cf28c99374a47a8..f1464d2c3bdf2e6d27d6b6b7e5bcfa8691d33232 100644 (file)
@@ -65,8 +65,8 @@ typedef struct {
        int *param_lengths;
        int *param_formats;
        Oid *param_types;
-       zend_bool is_prepared;
 #endif
+       zend_bool is_prepared;
 } pdo_pgsql_stmt;
 
 typedef struct {
index f6233f115bc07327cb92757f0badbc496366c702..89166759faa80c5329a4fc38b0b6dcaa43dd91ba 100644 (file)
@@ -38,6 +38,12 @@ $res = $dbh->prepare("SELECT ?", $aParams);
 $res->execute(array("it's working"));
 var_dump($res->fetch(PDO::FETCH_NUM));
 
+
+// Test bug #48188, trying to execute again
+$res->execute(array("try again"));
+var_dump($res->fetchColumn());
+var_dump($res->fetchColumn());
+
 ?>
 --EXPECT--
 string(4) "row1"
@@ -76,3 +82,5 @@ array(1) {
   [0]=>
   string(12) "it's working"
 }
+string(9) "try again"
+bool(false)