summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Conway2006-06-21 16:43:46 +0000
committerJoe Conway2006-06-21 16:43:46 +0000
commit223657dbadc39715e071d08b745190b15d105e51 (patch)
treeb3f62636b72ba86a445891002d4eed5e202c33fb
parent42141afd10b2f4c3ea08a2ec7648de503fe4323c (diff)
- During dblink_open, if transaction state was IDLE, force cursor count to
initially be 0. This is needed as a previous ABORT might have wiped out an automatically opened transaction without maintaining the cursor count. - Fix regression test expected file for the correct ERROR message, which we now get given the above bug fix.
-rw-r--r--contrib/dblink/dblink.c7
-rw-r--r--contrib/dblink/expected/dblink.out2
2 files changed, 8 insertions, 1 deletions
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 15c0e51ec2..432be0b03f 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -361,6 +361,13 @@ dblink_open(PG_FUNCTION_ARGS)
DBLINK_RES_INTERNALERROR("begin error");
PQclear(res);
rconn->newXactForCursor = TRUE;
+ /*
+ * Since transaction state was IDLE, we force cursor count to
+ * initially be 0. This is needed as a previous ABORT might
+ * have wiped out our transaction without maintaining the
+ * cursor count for us.
+ */
+ rconn->openCursorCount = 0;
}
/* if we started a transaction, increment cursor count */
diff --git a/contrib/dblink/expected/dblink.out b/contrib/dblink/expected/dblink.out
index 55d2b9e7c4..f2e364a942 100644
--- a/contrib/dblink/expected/dblink.out
+++ b/contrib/dblink/expected/dblink.out
@@ -509,7 +509,7 @@ SELECT dblink_close('myconn','rmt_foo_cursor');
-- this should fail because there is no open transaction
SELECT dblink_exec('myconn','DECLARE xact_test CURSOR FOR SELECT * FROM foo');
ERROR: sql error
-DETAIL: ERROR: cursor "xact_test" already exists
+DETAIL: ERROR: DECLARE CURSOR may only be used in transaction blocks
-- reset remote transaction state
SELECT dblink_exec('myconn','ABORT');