Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1d895f4

Browse files
committed
- 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.
1 parent 04c5b69 commit 1d895f4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

contrib/dblink/dblink.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Darko Prenosil <Darko.Prenosil@finteh.hr>
99
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
1010
*
11-
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.55 2006/05/30 22:12:12 tgl Exp $
11+
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.56 2006/06/21 16:43:11 joe Exp $
1212
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
1313
* ALL RIGHTS RESERVED;
1414
*
@@ -361,6 +361,13 @@ dblink_open(PG_FUNCTION_ARGS)
361361
DBLINK_RES_INTERNALERROR("begin error");
362362
PQclear(res);
363363
rconn->newXactForCursor = TRUE;
364+
/*
365+
* Since transaction state was IDLE, we force cursor count to
366+
* initially be 0. This is needed as a previous ABORT might
367+
* have wiped out our transaction without maintaining the
368+
* cursor count for us.
369+
*/
370+
rconn->openCursorCount = 0;
364371
}
365372

366373
/* if we started a transaction, increment cursor count */

contrib/dblink/expected/dblink.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ SELECT dblink_close('myconn','rmt_foo_cursor');
509509
-- this should fail because there is no open transaction
510510
SELECT dblink_exec('myconn','DECLARE xact_test CURSOR FOR SELECT * FROM foo');
511511
ERROR: sql error
512-
DETAIL: ERROR: cursor "xact_test" already exists
512+
DETAIL: ERROR: DECLARE CURSOR may only be used in transaction blocks
513513

514514
-- reset remote transaction state
515515
SELECT dblink_exec('myconn','ABORT');

0 commit comments

Comments
 (0)