summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Beccati <mbeccati@php.net>2009-05-12 22:18:15 +0000
committerMatteo Beccati <mbeccati@php.net>2009-05-12 22:18:15 +0000
commit3fb4089ba71dfe6f30994b222ca056d2db929cfa (patch)
tree4d243a82a9b9640c0452de9c7a3285d4f555e476
parent7be13beddbf2ef403b23634d4c4e46b07c200907 (diff)
downloadphp-git-3fb4089ba71dfe6f30994b222ca056d2db929cfa.tar.gz
MFH
- Fixed bug #48188
-rw-r--r--NEWS2
-rw-r--r--ext/pdo_pgsql/pgsql_statement.c10
-rw-r--r--ext/pdo_pgsql/php_pdo_pgsql_int.h2
-rw-r--r--ext/pdo_pgsql/tests/bug44861.phpt8
4 files changed, 21 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 6a2dc2a962..c114fd66b1 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ PHP NEWS
- Fixed bug #48227 (NumberFormatter::format leaks memory). (Felipe)
- Fixed bug #48200 (compile failure with mbstring.c when
--enable-zend-multibyte is used). (Jani)
+- Fixed bug #48188 (Cannot execute a scrollable cursors twice with
+ PDO_PGSQL). (Matteo)
07 May 2009, PHP 5.3.0 RC 2
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index 8cebfa8914..f74abf06c6 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -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);
diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h
index 644e08b9f3..e73320661c 100644
--- a/ext/pdo_pgsql/php_pdo_pgsql_int.h
+++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h
@@ -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 {
diff --git a/ext/pdo_pgsql/tests/bug44861.phpt b/ext/pdo_pgsql/tests/bug44861.phpt
index f6233f115b..89166759fa 100644
--- a/ext/pdo_pgsql/tests/bug44861.phpt
+++ b/ext/pdo_pgsql/tests/bug44861.phpt
@@ -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)