File tree Expand file tree Collapse file tree 2 files changed +82
-0
lines changed Expand file tree Collapse file tree 2 files changed +82
-0
lines changed Original file line number Diff line number Diff line change @@ -470,3 +470,50 @@ ROLLBACK;
470
470
DROP TABLE foo;
471
471
DROP TABLE baz;
472
472
DROP TABLE barbaz;
473
+ -- verify that cursors created during an aborted subtransaction are
474
+ -- closed, but that we do not rollback the effect of any FETCHs
475
+ -- performed in the aborted subtransaction
476
+ begin;
477
+ savepoint x;
478
+ create table abc (a int);
479
+ insert into abc values (5);
480
+ insert into abc values (10);
481
+ declare foo cursor for select * from abc;
482
+ fetch from foo;
483
+ a
484
+ ---
485
+ 5
486
+ (1 row)
487
+
488
+ rollback to x;
489
+ -- should fail
490
+ fetch from foo;
491
+ ERROR: cursor "foo" does not exist
492
+ commit;
493
+ begin;
494
+ create table abc (a int);
495
+ insert into abc values (5);
496
+ insert into abc values (10);
497
+ insert into abc values (15);
498
+ declare foo cursor for select * from abc;
499
+ fetch from foo;
500
+ a
501
+ ---
502
+ 5
503
+ (1 row)
504
+
505
+ savepoint x;
506
+ fetch from foo;
507
+ a
508
+ ----
509
+ 10
510
+ (1 row)
511
+
512
+ rollback to x;
513
+ fetch from foo;
514
+ a
515
+ ----
516
+ 15
517
+ (1 row)
518
+
519
+ abort;
Original file line number Diff line number Diff line change @@ -290,3 +290,38 @@ ROLLBACK;
290
290
DROP TABLE foo;
291
291
DROP TABLE baz;
292
292
DROP TABLE barbaz;
293
+
294
+ -- verify that cursors created during an aborted subtransaction are
295
+ -- closed, but that we do not rollback the effect of any FETCHs
296
+ -- performed in the aborted subtransaction
297
+ begin ;
298
+
299
+ savepoint x;
300
+ create table abc (a int );
301
+ insert into abc values (5 );
302
+ insert into abc values (10 );
303
+ declare foo cursor for select * from abc;
304
+ fetch from foo;
305
+ rollback to x;
306
+
307
+ -- should fail
308
+ fetch from foo;
309
+ commit ;
310
+
311
+ begin ;
312
+
313
+ create table abc (a int );
314
+ insert into abc values (5 );
315
+ insert into abc values (10 );
316
+ insert into abc values (15 );
317
+ declare foo cursor for select * from abc;
318
+
319
+ fetch from foo;
320
+
321
+ savepoint x;
322
+ fetch from foo;
323
+ rollback to x;
324
+
325
+ fetch from foo;
326
+
327
+ abort;
You can’t perform that action at this time.
0 commit comments