From 3fb4089ba71dfe6f30994b222ca056d2db929cfa Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Tue, 12 May 2009 22:18:15 +0000 Subject: MFH - Fixed bug #48188 --- ext/pdo_pgsql/pgsql_statement.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ext/pdo_pgsql/pgsql_statement.c') 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); -- cgit v1.2.1