forked from orioledb/orioledb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subtransactions.out
777 lines (734 loc) · 36.9 KB
/
subtransactions.out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
--
-- Tests for (sub)transactions
--
CREATE SCHEMA subtransactions;
SET SESSION search_path = 'subtransactions';
CREATE EXTENSION orioledb;
CREATE TABLE o_subtrans (
id integer NOT NULL,
value text NOT NULL,
PRIMARY KEY (id)
) USING orioledb;
---
-- Tests for relfilenode undo
---
-- TRUNCATE undo
BEGIN;
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
COMMIT;
SELECT * FROM o_subtrans;
id | value
----+-------
(0 rows)
BEGIN;
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
ROLLBACK;
SELECT * FROM o_subtrans;
id | value
----+-------
(0 rows)
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT i, repeat('abc', i % 5) FROM generate_series(0, 555, 5) i;
SAVEPOINT s1;
UPDATE o_subtrans SET value = value || 'def' WHERE id % 10 = 5;
DELETE FROM o_subtrans WHERE id % 10 = 0;
SAVEPOINT s2;
INSERT INTO o_subtrans
SELECT i, repeat('abc', i % 5) FROM generate_series(0, 555, 10) i;
SAVEPOINT s3;
INSERT INTO o_subtrans
SELECT i, repeat('abc', i % 5) FROM generate_series(3, 555, 10) i;
UPDATE o_subtrans SET value = value || 'qwer';
SAVEPOINT s4;
UPDATE o_subtrans SET value = value || 'asdf';
SAVEPOINT s5;
DELETE FROM o_subtrans WHERE id % 4 = 3;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{13,33,53,73,93,113,133,153,173,193,213,233,253,273,293,313,333,353,373,393,413,433,453,473,493,513,533,553} | abcabcabcqwerasdf
{5,25,45,65,85,105,125,145,165,185,205,225,245,265,285,305,325,345,365,385,405,425,445,465,485,505,525,545} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
ROLLBACK TO s5;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{3,13,23,33,43,53,63,73,83,93,103,113,123,133,143,153,163,173,183,193,203,213,223,233,243,253,263,273,283,293,303,313,323,333,343,353,363,373,383,393,403,413,423,433,443,453,463,473,483,493,503,513,523,533,543,553} | abcabcabcqwerasdf
{5,15,25,35,45,55,65,75,85,95,105,115,125,135,145,155,165,175,185,195,205,215,225,235,245,255,265,275,285,295,305,315,325,335,345,355,365,375,385,395,405,415,425,435,445,455,465,475,485,495,505,515,525,535,545,555} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
ROLLBACK TO s4;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------
{3,13,23,33,43,53,63,73,83,93,103,113,123,133,143,153,163,173,183,193,203,213,223,233,243,253,263,273,283,293,303,313,323,333,343,353,363,373,383,393,403,413,423,433,443,453,463,473,483,493,503,513,523,533,543,553} | abcabcabcqwer
{5,15,25,35,45,55,65,75,85,95,105,115,125,135,145,155,165,175,185,195,205,215,225,235,245,255,265,275,285,295,305,315,325,335,345,355,365,375,385,395,405,415,425,435,445,455,465,475,485,495,505,515,525,535,545,555} | defqwer
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwer
(3 rows)
ROLLBACK TO s3;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} |
{5,15,25,35,45,55,65,75,85,95,105,115,125,135,145,155,165,175,185,195,205,215,225,235,245,255,265,275,285,295,305,315,325,335,345,355,365,375,385,395,405,415,425,435,445,455,465,475,485,495,505,515,525,535,545,555} | def
(2 rows)
ROLLBACK TO s2;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------
{5,15,25,35,45,55,65,75,85,95,105,115,125,135,145,155,165,175,185,195,205,215,225,235,245,255,265,275,285,295,305,315,325,335,345,355,365,375,385,395,405,415,425,435,445,455,465,475,485,495,505,515,525,535,545,555} | def
(1 row)
ROLLBACK TO s1;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------
{0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,255,260,265,270,275,280,285,290,295,300,305,310,315,320,325,330,335,340,345,350,355,360,365,370,375,380,385,390,395,400,405,410,415,420,425,430,435,440,445,450,455,460,465,470,475,480,485,490,495,500,505,510,515,520,525,530,535,540,545,550,555} |
(1 row)
COMMIT;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------
{0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,255,260,265,270,275,280,285,290,295,300,305,310,315,320,325,330,335,340,345,350,355,360,365,370,375,380,385,390,395,400,405,410,415,420,425,430,435,440,445,450,455,460,465,470,475,480,485,490,495,500,505,510,515,520,525,530,535,540,545,550,555} |
(1 row)
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT i, repeat('abc', i % 5) FROM generate_series(0, 555, 5) i;
SAVEPOINT s1;
UPDATE o_subtrans SET value = value || 'def' WHERE id % 10 = 5;
DELETE FROM o_subtrans WHERE id % 10 = 0;
SAVEPOINT s2;
INSERT INTO o_subtrans
SELECT i, repeat('abc', i % 5) FROM generate_series(0, 555, 10) i;
SAVEPOINT s3;
INSERT INTO o_subtrans
SELECT i, repeat('abc', i % 5) FROM generate_series(3, 555, 10) i;
UPDATE o_subtrans SET value = value || 'qwer';
SAVEPOINT s4;
UPDATE o_subtrans SET value = value || 'asdf';
SAVEPOINT s5;
DELETE FROM o_subtrans WHERE id % 4 = 3;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{13,33,53,73,93,113,133,153,173,193,213,233,253,273,293,313,333,353,373,393,413,433,453,473,493,513,533,553} | abcabcabcqwerasdf
{5,25,45,65,85,105,125,145,165,185,205,225,245,265,285,305,325,345,365,385,405,425,445,465,485,505,525,545} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
ROLLBACK TO s5;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{3,13,23,33,43,53,63,73,83,93,103,113,123,133,143,153,163,173,183,193,203,213,223,233,243,253,263,273,283,293,303,313,323,333,343,353,363,373,383,393,403,413,423,433,443,453,463,473,483,493,503,513,523,533,543,553} | abcabcabcqwerasdf
{5,15,25,35,45,55,65,75,85,95,105,115,125,135,145,155,165,175,185,195,205,215,225,235,245,255,265,275,285,295,305,315,325,335,345,355,365,375,385,395,405,415,425,435,445,455,465,475,485,495,505,515,525,535,545,555} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
ROLLBACK TO s4;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------
{3,13,23,33,43,53,63,73,83,93,103,113,123,133,143,153,163,173,183,193,203,213,223,233,243,253,263,273,283,293,303,313,323,333,343,353,363,373,383,393,403,413,423,433,443,453,463,473,483,493,503,513,523,533,543,553} | abcabcabcqwer
{5,15,25,35,45,55,65,75,85,95,105,115,125,135,145,155,165,175,185,195,205,215,225,235,245,255,265,275,285,295,305,315,325,335,345,355,365,375,385,395,405,415,425,435,445,455,465,475,485,495,505,515,525,535,545,555} | defqwer
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwer
(3 rows)
ROLLBACK TO s3;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} |
{5,15,25,35,45,55,65,75,85,95,105,115,125,135,145,155,165,175,185,195,205,215,225,235,245,255,265,275,285,295,305,315,325,335,345,355,365,375,385,395,405,415,425,435,445,455,465,475,485,495,505,515,525,535,545,555} | def
(2 rows)
ROLLBACK TO s2;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------
{5,15,25,35,45,55,65,75,85,95,105,115,125,135,145,155,165,175,185,195,205,215,225,235,245,255,265,275,285,295,305,315,325,335,345,355,365,375,385,395,405,415,425,435,445,455,465,475,485,495,505,515,525,535,545,555} | def
(1 row)
ROLLBACK TO s1;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------
{0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,255,260,265,270,275,280,285,290,295,300,305,310,315,320,325,330,335,340,345,350,355,360,365,370,375,380,385,390,395,400,405,410,415,420,425,430,435,440,445,450,455,460,465,470,475,480,485,490,495,500,505,510,515,520,525,530,535,540,545,550,555} |
(1 row)
ROLLBACK;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
-----------+-------
(0 rows)
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT i, repeat('abc', i % 5) FROM generate_series(0, 555, 5) i;
SAVEPOINT s1;
UPDATE o_subtrans SET value = value || 'def' WHERE id % 10 = 5;
DELETE FROM o_subtrans WHERE id % 10 = 0;
SAVEPOINT s2;
INSERT INTO o_subtrans
SELECT i, repeat('abc', i % 5) FROM generate_series(0, 555, 10) i;
SAVEPOINT s3;
INSERT INTO o_subtrans
SELECT i, repeat('abc', i % 5) FROM generate_series(3, 555, 10) i;
UPDATE o_subtrans SET value = value || 'qwer';
SAVEPOINT s4;
UPDATE o_subtrans SET value = value || 'asdf';
SAVEPOINT s5;
DELETE FROM o_subtrans WHERE id % 4 = 3;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{13,33,53,73,93,113,133,153,173,193,213,233,253,273,293,313,333,353,373,393,413,433,453,473,493,513,533,553} | abcabcabcqwerasdf
{5,25,45,65,85,105,125,145,165,185,205,225,245,265,285,305,325,345,365,385,405,425,445,465,485,505,525,545} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
RELEASE s5;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{13,33,53,73,93,113,133,153,173,193,213,233,253,273,293,313,333,353,373,393,413,433,453,473,493,513,533,553} | abcabcabcqwerasdf
{5,25,45,65,85,105,125,145,165,185,205,225,245,265,285,305,325,345,365,385,405,425,445,465,485,505,525,545} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
RELEASE s4;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{13,33,53,73,93,113,133,153,173,193,213,233,253,273,293,313,333,353,373,393,413,433,453,473,493,513,533,553} | abcabcabcqwerasdf
{5,25,45,65,85,105,125,145,165,185,205,225,245,265,285,305,325,345,365,385,405,425,445,465,485,505,525,545} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
RELEASE s3;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{13,33,53,73,93,113,133,153,173,193,213,233,253,273,293,313,333,353,373,393,413,433,453,473,493,513,533,553} | abcabcabcqwerasdf
{5,25,45,65,85,105,125,145,165,185,205,225,245,265,285,305,325,345,365,385,405,425,445,465,485,505,525,545} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
RELEASE s2;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{13,33,53,73,93,113,133,153,173,193,213,233,253,273,293,313,333,353,373,393,413,433,453,473,493,513,533,553} | abcabcabcqwerasdf
{5,25,45,65,85,105,125,145,165,185,205,225,245,265,285,305,325,345,365,385,405,425,445,465,485,505,525,545} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
RELEASE s1;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{13,33,53,73,93,113,133,153,173,193,213,233,253,273,293,313,333,353,373,393,413,433,453,473,493,513,533,553} | abcabcabcqwerasdf
{5,25,45,65,85,105,125,145,165,185,205,225,245,265,285,305,325,345,365,385,405,425,445,465,485,505,525,545} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
COMMIT;
SELECT array_agg(id), value
FROM o_subtrans GROUP BY value ORDER BY value;
array_agg | value
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------
{13,33,53,73,93,113,133,153,173,193,213,233,253,273,293,313,333,353,373,393,413,433,453,473,493,513,533,553} | abcabcabcqwerasdf
{5,25,45,65,85,105,125,145,165,185,205,225,245,265,285,305,325,345,365,385,405,425,445,465,485,505,525,545} | defqwerasdf
{0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500,510,520,530,540,550} | qwerasdf
(3 rows)
-- INSERT/DELETE undo
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT i, repeat('qwer', i % 3) FROM generate_series(1, 10, 1) AS i;
DELETE FROM o_subtrans WHERE id <= 5;
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
COMMIT;
SELECT * FROM o_subtrans;
id | value
----+-------
(0 rows)
BEGIN;
INSERT INTO o_subtrans
SELECT i, repeat('qwer', i % 3) FROM generate_series(1, 10, 1) AS i;
DELETE FROM o_subtrans WHERE id <= 5;
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
ROLLBACK;
SELECT * FROM o_subtrans;
id | value
----+-------
(0 rows)
-- UPDATE undo
INSERT INTO o_subtrans
SELECT i, repeat('qwer', i % 3)FROM generate_series(1, 10, 1) AS i;
BEGIN;
UPDATE o_subtrans SET value = value || 'abc';
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
COMMIT;
SELECT * FROM o_subtrans;
id | value
----+-------
(0 rows)
INSERT INTO o_subtrans
SELECT i, repeat('qwer', i % 3) FROM generate_series(1, 10, 1) AS i;
BEGIN;
UPDATE o_subtrans SET value = value || 'abc';
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
TRUNCATE o_subtrans;
ROLLBACK;
SELECT * FROM o_subtrans;
id | value
----+----------
1 | qwer
2 | qwerqwer
3 |
4 | qwer
5 | qwerqwer
6 |
7 | qwer
8 | qwerqwer
9 |
10 | qwer
(10 rows)
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT i, repeat('qwer', i % 3) FROM generate_series(1, 5, 1) AS i;
SAVEPOINT s1;
INSERT INTO o_subtrans
SELECT i, repeat('asdf', i % 3) FROM generate_series(6, 10, 1) AS i;
SELECT * FROM o_subtrans;
id | value
----+----------
1 | qwer
2 | qwerqwer
3 |
4 | qwer
5 | qwerqwer
6 |
7 | asdf
8 | asdfasdf
9 |
10 | asdf
(10 rows)
ROLLBACK TO s1;
SELECT * FROM o_subtrans;
id | value
----+----------
1 | qwer
2 | qwerqwer
3 |
4 | qwer
5 | qwerqwer
(5 rows)
COMMIT;
SELECT * FROM o_subtrans;
id | value
----+----------
1 | qwer
2 | qwerqwer
3 |
4 | qwer
5 | qwerqwer
(5 rows)
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT i, repeat('qwer', i % 3) FROM generate_series(1, 5, 1) AS i;
SAVEPOINT s1;
INSERT INTO o_subtrans
SELECT i, repeat('asdf', i % 3) FROM generate_series(6, 10, 1) AS i;
SELECT * FROM o_subtrans;
id | value
----+----------
1 | qwer
2 | qwerqwer
3 |
4 | qwer
5 | qwerqwer
6 |
7 | asdf
8 | asdfasdf
9 |
10 | asdf
(10 rows)
ROLLBACK TO s1;
SELECT * FROM o_subtrans;
id | value
----+----------
1 | qwer
2 | qwerqwer
3 |
4 | qwer
5 | qwerqwer
(5 rows)
ROLLBACK;
SELECT * FROM o_subtrans;
id | value
----+-------
(0 rows)
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT i, repeat('qwer', i % 3) FROM generate_series(1, 5, 1) AS i;
DELETE FROM o_subtrans WHERE id BETWEEN 1 AND 5;
SAVEPOINT s1;
INSERT INTO o_subtrans
SELECT i, repeat('zxcv', i % 3) FROM generate_series(1, 5, 1) AS i;
UPDATE o_subtrans SET value = repeat('rtyu', id % 4) WHERE id BETWEEN 1 AND 5;
INSERT INTO o_subtrans
SELECT i, repeat('asdf', i % 3) FROM generate_series(6, 10, 1) AS i;
UPDATE o_subtrans SET value = repeat('ghjk', id % 5) WHERE id BETWEEN 1 AND 5;
UPDATE o_subtrans SET value = repeat('bnm,', id % 6) WHERE id BETWEEN 1 AND 5;
SAVEPOINT s2;
DELETE FROM o_subtrans WHERE id BETWEEN 6 AND 10;
SELECT * FROM o_subtrans;
id | value
----+----------------------
1 | bnm,
2 | bnm,bnm,
3 | bnm,bnm,bnm,
4 | bnm,bnm,bnm,bnm,
5 | bnm,bnm,bnm,bnm,bnm,
(5 rows)
ROLLBACK TO s2;
COMMIT;
SELECT * FROM o_subtrans;
id | value
----+----------------------
1 | bnm,
2 | bnm,bnm,
3 | bnm,bnm,bnm,
4 | bnm,bnm,bnm,bnm,
5 | bnm,bnm,bnm,bnm,bnm,
6 |
7 | asdf
8 | asdfasdf
9 |
10 | asdf
(10 rows)
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT i, repeat('qwer', i % 3) FROM generate_series(1, 5, 1) AS i;
DELETE FROM o_subtrans WHERE id BETWEEN 1 AND 5;
SAVEPOINT s1;
INSERT INTO o_subtrans
SELECT i, repeat('zxcv', i % 3) FROM generate_series(1, 5, 1) AS i;
UPDATE o_subtrans SET value = repeat('rtyu', id % 4) WHERE id BETWEEN 1 AND 5;
INSERT INTO o_subtrans
SELECT i, repeat('asdf', i % 3) FROM generate_series(6, 10, 1) AS i;
UPDATE o_subtrans SET value = repeat('ghjk', id % 5) WHERE id BETWEEN 1 AND 5;
UPDATE o_subtrans SET value = repeat('bnm,', id % 6) WHERE id BETWEEN 1 AND 5;
SAVEPOINT s2;
DELETE FROM o_subtrans WHERE id BETWEEN 6 AND 10;
SELECT * FROM o_subtrans;
id | value
----+----------------------
1 | bnm,
2 | bnm,bnm,
3 | bnm,bnm,bnm,
4 | bnm,bnm,bnm,bnm,
5 | bnm,bnm,bnm,bnm,bnm,
(5 rows)
ROLLBACK TO s1;
COMMIT;
SELECT * FROM o_subtrans;
id | value
----+-------
(0 rows)
TRUNCATE o_subtrans;
BEGIN;
SAVEPOINT s1;
SET TRANSACTION READ ONLY;
SAVEPOINT s2;
SET TRANSACTION READ WRITE;
ERROR: cannot set transaction read-write mode inside a read-only transaction
ROLLBACK;
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT id, repeat('abcdef', id % 7) FROM generate_series(0, 500, 5) id;
SAVEPOINT s1;
DELETE FROM o_subtrans WHERE id % 10 = 0;
SAVEPOINT s2;
INSERT INTO o_subtrans
SELECT id, repeat('abcdef', id % 7) FROM generate_series(0, 500, 10) id;
SAVEPOINT s3;
UPDATE o_subtrans SET value = '12345' || value;
ROLLBACK TO s3;
ROLLBACK TO s2;
COMMIT;
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT id, repeat('abcdef', id % 7) FROM generate_series(0, 500, 5) id;
SAVEPOINT s1;
DELETE FROM o_subtrans WHERE id % 10 = 0;
SAVEPOINT s2;
INSERT INTO o_subtrans
SELECT id, repeat('abcdef', id % 7) FROM generate_series(0, 500, 10) id;
DELETE FROM o_subtrans WHERE id % 10 = 0;
UPDATE o_subtrans SET value = '12345' || value;
ROLLBACK TO s2;
SELECT * FROM o_subtrans WHERE id = 10;
id | value
----+-------
(0 rows)
ROLLBACK TO s1;
SELECT * FROM o_subtrans WHERE id = 10;
id | value
----+--------------------
10 | abcdefabcdefabcdef
(1 row)
COMMIT;
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT id, repeat('abcdef', id % 7) FROM generate_series(0, 500, 5) id;
SAVEPOINT s1;
DELETE FROM o_subtrans WHERE id % 5 = 0;
COMMIT;
BEGIN;
INSERT INTO o_subtrans
SELECT id, repeat('abcdef', id % 7) FROM generate_series(0, 500, 5) id;
DELETE FROM o_subtrans WHERE id % 5 = 0;
ROLLBACK;
TRUNCATE o_subtrans;
INSERT INTO o_subtrans
SELECT id, repeat('abcdef', id % 7) FROM generate_series(0, 500, 5) id;
DELETE FROM o_subtrans WHERE id % 5 = 0;
BEGIN;
INSERT INTO o_subtrans
SELECT id, repeat('abcdef', id % 7) FROM generate_series(0, 500, 10) id;
DELETE FROM o_subtrans WHERE id % 5 = 0;
SELECT id, repeat('abcdef', id % 7) FROM generate_series(0, 500, 5) id;
id | repeat
-----+--------------------------------------
0 |
5 | abcdefabcdefabcdefabcdefabcdef
10 | abcdefabcdefabcdef
15 | abcdef
20 | abcdefabcdefabcdefabcdefabcdefabcdef
25 | abcdefabcdefabcdefabcdef
30 | abcdefabcdef
35 |
40 | abcdefabcdefabcdefabcdefabcdef
45 | abcdefabcdefabcdef
50 | abcdef
55 | abcdefabcdefabcdefabcdefabcdefabcdef
60 | abcdefabcdefabcdefabcdef
65 | abcdefabcdef
70 |
75 | abcdefabcdefabcdefabcdefabcdef
80 | abcdefabcdefabcdef
85 | abcdef
90 | abcdefabcdefabcdefabcdefabcdefabcdef
95 | abcdefabcdefabcdefabcdef
100 | abcdefabcdef
105 |
110 | abcdefabcdefabcdefabcdefabcdef
115 | abcdefabcdefabcdef
120 | abcdef
125 | abcdefabcdefabcdefabcdefabcdefabcdef
130 | abcdefabcdefabcdefabcdef
135 | abcdefabcdef
140 |
145 | abcdefabcdefabcdefabcdefabcdef
150 | abcdefabcdefabcdef
155 | abcdef
160 | abcdefabcdefabcdefabcdefabcdefabcdef
165 | abcdefabcdefabcdefabcdef
170 | abcdefabcdef
175 |
180 | abcdefabcdefabcdefabcdefabcdef
185 | abcdefabcdefabcdef
190 | abcdef
195 | abcdefabcdefabcdefabcdefabcdefabcdef
200 | abcdefabcdefabcdefabcdef
205 | abcdefabcdef
210 |
215 | abcdefabcdefabcdefabcdefabcdef
220 | abcdefabcdefabcdef
225 | abcdef
230 | abcdefabcdefabcdefabcdefabcdefabcdef
235 | abcdefabcdefabcdefabcdef
240 | abcdefabcdef
245 |
250 | abcdefabcdefabcdefabcdefabcdef
255 | abcdefabcdefabcdef
260 | abcdef
265 | abcdefabcdefabcdefabcdefabcdefabcdef
270 | abcdefabcdefabcdefabcdef
275 | abcdefabcdef
280 |
285 | abcdefabcdefabcdefabcdefabcdef
290 | abcdefabcdefabcdef
295 | abcdef
300 | abcdefabcdefabcdefabcdefabcdefabcdef
305 | abcdefabcdefabcdefabcdef
310 | abcdefabcdef
315 |
320 | abcdefabcdefabcdefabcdefabcdef
325 | abcdefabcdefabcdef
330 | abcdef
335 | abcdefabcdefabcdefabcdefabcdefabcdef
340 | abcdefabcdefabcdefabcdef
345 | abcdefabcdef
350 |
355 | abcdefabcdefabcdefabcdefabcdef
360 | abcdefabcdefabcdef
365 | abcdef
370 | abcdefabcdefabcdefabcdefabcdefabcdef
375 | abcdefabcdefabcdefabcdef
380 | abcdefabcdef
385 |
390 | abcdefabcdefabcdefabcdefabcdef
395 | abcdefabcdefabcdef
400 | abcdef
405 | abcdefabcdefabcdefabcdefabcdefabcdef
410 | abcdefabcdefabcdefabcdef
415 | abcdefabcdef
420 |
425 | abcdefabcdefabcdefabcdefabcdef
430 | abcdefabcdefabcdef
435 | abcdef
440 | abcdefabcdefabcdefabcdefabcdefabcdef
445 | abcdefabcdefabcdefabcdef
450 | abcdefabcdef
455 |
460 | abcdefabcdefabcdefabcdefabcdef
465 | abcdefabcdefabcdef
470 | abcdef
475 | abcdefabcdefabcdefabcdefabcdefabcdef
480 | abcdefabcdefabcdefabcdef
485 | abcdefabcdef
490 |
495 | abcdefabcdefabcdefabcdefabcdef
500 | abcdefabcdefabcdef
(101 rows)
COMMIT;
-- Subtransaction check
TRUNCATE o_subtrans;
BEGIN;
INSERT INTO o_subtrans
SELECT i, repeat('a', i) FROM generate_series(1, 10, 1) AS i;
SAVEPOINT s1;
TRUNCATE o_subtrans;
CREATE TABLE o_subtrans_1
(
id int8 not null,
PRIMARY KEY(id)
) USING orioledb;
SAVEPOINT s2;
CREATE TABLE o_subtrans_2
(
id int8 not null,
PRIMARY KEY(id)
) USING orioledb;
TRUNCATE o_subtrans;
SAVEPOINT s3;
CREATE TABLE o_subtrans_3
(
id int8 not null,
PRIMARY KEY(id)
) USING orioledb;
TRUNCATE o_subtrans;
DROP TABLE o_subtrans;
ROLLBACK TO s3;
ROLLBACK TO s2;
CREATE TABLE o_subtrans_4
(
id int8 not null,
PRIMARY KEY(id)
) USING orioledb;
ROLLBACK;
SELECT * FROM o_subtrans;
id | value
----+-------
(0 rows)
DROP TABLE o_subtrans_1;
ERROR: table "o_subtrans_1" does not exist
DROP TABLE o_subtrans_2;
ERROR: table "o_subtrans_2" does not exist
DROP TABLE o_subtrans_3;
ERROR: table "o_subtrans_3" does not exist
DROP TABLE o_subtrans_4;
ERROR: table "o_subtrans_4" does not exist
-- Test some interesting cases to check that orioledb doesn't break them
BEGIN;
SAVEPOINT one;
ROLLBACK TO one;
RELEASE one;
SAVEPOINT two;
RELEASE two;
SAVEPOINT three;
ROLLBACK TO three;
RELEASE three;
COMMIT;
BEGIN;
SAVEPOINT one;
ROLLBACK TO one;
RELEASE one;
SAVEPOINT two;
RELEASE two;
SAVEPOINT three;
SAVEPOINT four;
SAVEPOINT five;
SAVEPOINT six;
ROLLBACK TO four;
ROLLBACK TO four;
RELEASE four;
ROLLBACK TO three;
RELEASE three;
COMMIT;
BEGIN;
-- Check subtransaction vs cursors
CREATE TABLE o_test_1(
val_1 int
) USING orioledb;
INSERT INTO o_test_1 VALUES (10);
DECLARE abc CURSOR for SELECT * FROM o_test_1;
SAVEPOINT s1;
FETCH FROM abc;
val_1
-------
10
(1 row)
ROLLBACK TO s1;
FETCH FROM abc;
val_1
-------
(0 rows)
ROLLBACK;
DROP EXTENSION orioledb CASCADE;
NOTICE: drop cascades to table o_subtrans
DROP SCHEMA subtransactions CASCADE;
RESET search_path;