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
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
|
# Copyright (c) 2021-2025, PostgreSQL Global Development Group
use strict;
use warnings FATAL => 'all';
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
###############################################################
# Definition of the pg_dump runs to make.
#
# Each of these runs are named and those names are used below
# to define how each test should (or shouldn't) treat a result
# from a given run.
#
# test_key indicates that a given run should simply use the same
# set of like/unlike tests as another run, and which run that is.
#
# compile_option indicates if the commands run depend on a compilation
# option, if any. This can be used to control if tests should be
# skipped when a build dependency is not satisfied.
#
# dump_cmd is the pg_dump command to run, which is an array of
# the full command and arguments to run. Note that this is run
# using $node->command_ok(), so the port does not need to be
# specified and is pulled from $PGPORT, which is set by the
# PostgreSQL::Test::Cluster system.
#
# compress_cmd is the utility command for (de)compression, if any.
# Note that this should generally be used on pg_dump's output
# either to generate a text file to run the through the tests, or
# to test pg_restore's ability to parse manually compressed files
# that otherwise pg_dump does not compress on its own (e.g. *.toc).
#
# glob_patterns is an optional array consisting of strings compilable
# with glob() to check the files generated after a dump.
#
# command_like is an optional utility that can be used to compare
# the output generated by a command on the contents of an existing
# dump, like the TOC description of a pg_restore command.
#
# restore_cmd is the pg_restore command to run, if any. Note
# that this should generally be used when the pg_dump goes to
# a non-text file and that the restore can then be used to
# generate a text file to run through the tests from the
# non-text file generated by pg_dump.
#
# TODO: Have pg_restore actually restore to an independent
# database and then pg_dump *that* database (or something along
# those lines) to validate that part of the process.
my $supports_icu = ($ENV{with_icu} eq 'yes');
my $supports_gzip = check_pg_config("#define HAVE_LIBZ 1");
my $supports_lz4 = check_pg_config("#define USE_LZ4 1");
my $supports_zstd = check_pg_config("#define USE_ZSTD 1");
my %pgdump_runs = (
binary_upgrade => {
dump_cmd => [
'pg_dump', '--no-sync',
'--format' => 'custom',
'--file' => "$tempdir/binary_upgrade.dump",
'--no-password',
'--no-data',
'--sequence-data',
'--binary-upgrade',
'--dbname' => 'postgres', # alternative way to specify database
],
restore_cmd => [
'pg_restore',
'--format' => 'custom',
'--verbose',
'--file' => "$tempdir/binary_upgrade.sql",
"$tempdir/binary_upgrade.dump",
],
},
# Do not use --no-sync to give test coverage for data sync.
compression_gzip_custom => {
test_key => 'compression',
compile_option => 'gzip',
dump_cmd => [
'pg_dump',
'--format' => 'custom',
'--compress' => '1',
'--file' => "$tempdir/compression_gzip_custom.dump",
'postgres',
],
restore_cmd => [
'pg_restore',
'--file' => "$tempdir/compression_gzip_custom.sql",
"$tempdir/compression_gzip_custom.dump",
],
command_like => {
command => [
'pg_restore', '--list',
"$tempdir/compression_gzip_custom.dump",
],
expected => qr/Compression: gzip/,
name => 'data content is gzip-compressed'
},
},
# Do not use --no-sync to give test coverage for data sync.
compression_gzip_dir => {
test_key => 'compression',
compile_option => 'gzip',
dump_cmd => [
'pg_dump',
'--jobs' => '2',
'--format' => 'directory',
'--compress' => 'gzip:1',
'--file' => "$tempdir/compression_gzip_dir",
'postgres',
],
# Give coverage for manually compressed blobs.toc files during
# restore.
compress_cmd => {
program => $ENV{'GZIP_PROGRAM'},
args => [ '-f', "$tempdir/compression_gzip_dir/blobs_*.toc", ],
},
# Verify that only data files were compressed
glob_patterns => [
"$tempdir/compression_gzip_dir/toc.dat",
"$tempdir/compression_gzip_dir/*.dat.gz",
],
restore_cmd => [
'pg_restore',
'--jobs' => '2',
'--file' => "$tempdir/compression_gzip_dir.sql",
"$tempdir/compression_gzip_dir",
],
},
compression_gzip_plain => {
test_key => 'compression',
compile_option => 'gzip',
dump_cmd => [
'pg_dump',
'--format' => 'plain',
'--compress' => '1',
'--file' => "$tempdir/compression_gzip_plain.sql.gz",
'postgres',
],
# Decompress the generated file to run through the tests.
compress_cmd => {
program => $ENV{'GZIP_PROGRAM'},
args => [ '-d', "$tempdir/compression_gzip_plain.sql.gz", ],
},
},
# Do not use --no-sync to give test coverage for data sync.
compression_lz4_custom => {
test_key => 'compression',
compile_option => 'lz4',
dump_cmd => [
'pg_dump',
'--format' => 'custom',
'--compress' => 'lz4',
'--file' => "$tempdir/compression_lz4_custom.dump",
'postgres',
],
restore_cmd => [
'pg_restore',
'--file' => "$tempdir/compression_lz4_custom.sql",
"$tempdir/compression_lz4_custom.dump",
],
command_like => {
command => [
'pg_restore', '--list',
"$tempdir/compression_lz4_custom.dump",
],
expected => qr/Compression: lz4/,
name => 'data content is lz4 compressed'
},
},
# Do not use --no-sync to give test coverage for data sync.
compression_lz4_dir => {
test_key => 'compression',
compile_option => 'lz4',
dump_cmd => [
'pg_dump',
'--jobs' => '2',
'--format' => 'directory',
'--compress' => 'lz4:1',
'--file' => "$tempdir/compression_lz4_dir",
'postgres',
],
# Verify that data files were compressed
glob_patterns => [
"$tempdir/compression_lz4_dir/toc.dat",
"$tempdir/compression_lz4_dir/*.dat.lz4",
],
restore_cmd => [
'pg_restore',
'--jobs' => '2',
'--file' => "$tempdir/compression_lz4_dir.sql",
"$tempdir/compression_lz4_dir",
],
},
compression_lz4_plain => {
test_key => 'compression',
compile_option => 'lz4',
dump_cmd => [
'pg_dump',
'--format' => 'plain',
'--compress' => 'lz4',
'--file' => "$tempdir/compression_lz4_plain.sql.lz4",
'postgres',
],
# Decompress the generated file to run through the tests.
compress_cmd => {
program => $ENV{'LZ4'},
args => [
'-d', '-f',
"$tempdir/compression_lz4_plain.sql.lz4",
"$tempdir/compression_lz4_plain.sql",
],
},
},
compression_zstd_custom => {
test_key => 'compression',
compile_option => 'zstd',
dump_cmd => [
'pg_dump',
'--format' => 'custom',
'--compress' => 'zstd',
'--file' => "$tempdir/compression_zstd_custom.dump",
'postgres',
],
restore_cmd => [
'pg_restore',
'--file' => "$tempdir/compression_zstd_custom.sql",
"$tempdir/compression_zstd_custom.dump",
],
command_like => {
command => [
'pg_restore', '--list',
"$tempdir/compression_zstd_custom.dump",
],
expected => qr/Compression: zstd/,
name => 'data content is zstd compressed'
},
},
compression_zstd_dir => {
test_key => 'compression',
compile_option => 'zstd',
dump_cmd => [
'pg_dump',
'--jobs' => '2',
'--format' => 'directory',
'--compress' => 'zstd:1',
'--file' => "$tempdir/compression_zstd_dir",
'postgres',
],
# Give coverage for manually compressed blobs.toc files during
# restore.
compress_cmd => {
program => $ENV{'ZSTD'},
args => [
'-z', '-f',
'--rm', "$tempdir/compression_zstd_dir/blobs_*.toc",
],
},
# Verify that data files were compressed
glob_patterns => [
"$tempdir/compression_zstd_dir/toc.dat",
"$tempdir/compression_zstd_dir/*.dat.zst",
],
restore_cmd => [
'pg_restore',
'--jobs' => '2',
'--file' => "$tempdir/compression_zstd_dir.sql",
"$tempdir/compression_zstd_dir",
],
},
# Exercise long mode for test coverage
compression_zstd_plain => {
test_key => 'compression',
compile_option => 'zstd',
dump_cmd => [
'pg_dump',
'--format' => 'plain',
'--compress' => 'zstd:long',
'--file' => "$tempdir/compression_zstd_plain.sql.zst",
'postgres',
],
# Decompress the generated file to run through the tests.
compress_cmd => {
program => $ENV{'ZSTD'},
args => [
'-d', '-f',
"$tempdir/compression_zstd_plain.sql.zst", "-o",
"$tempdir/compression_zstd_plain.sql",
],
},
},
clean => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/clean.sql",
'--clean',
'--dbname' => 'postgres', # alternative way to specify database
],
},
clean_if_exists => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/clean_if_exists.sql",
'--clean',
'--if-exists',
'--encoding' => 'UTF8', # no-op, just for testing
'postgres',
],
},
column_inserts => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/column_inserts.sql",
'--data-only',
'--column-inserts', 'postgres',
],
},
createdb => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/createdb.sql",
'--create',
'--no-reconnect', # no-op, just for testing
'--verbose',
'postgres',
],
},
data_only => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/data_only.sql",
'--data-only',
'--superuser' => 'test_superuser',
'--disable-triggers',
'--verbose', # no-op, just make sure it works
'postgres',
],
},
defaults => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/defaults.sql",
'postgres',
],
},
defaults_no_public => {
database => 'regress_pg_dump_test',
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/defaults_no_public.sql",
'regress_pg_dump_test',
],
},
defaults_no_public_clean => {
database => 'regress_pg_dump_test',
dump_cmd => [
'pg_dump', '--no-sync',
'--clean',
'--file' => "$tempdir/defaults_no_public_clean.sql",
'regress_pg_dump_test',
],
},
defaults_public_owner => {
database => 'regress_public_owner',
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/defaults_public_owner.sql",
'regress_public_owner',
],
},
# Do not use --no-sync to give test coverage for data sync.
# By default, the custom format compresses its data file
# when the code is compiled with gzip support, and lets them
# uncompressed when not compiled with it.
defaults_custom_format => {
test_key => 'defaults',
dump_cmd => [
'pg_dump',
'--format' => 'custom',
'--file' => "$tempdir/defaults_custom_format.dump",
'postgres',
],
restore_cmd => [
'pg_restore',
'--format' => 'custom',
'--file' => "$tempdir/defaults_custom_format.sql",
"$tempdir/defaults_custom_format.dump",
],
command_like => {
command => [
'pg_restore', '--list',
"$tempdir/defaults_custom_format.dump",
],
expected => $supports_gzip
? qr/Compression: gzip/
: qr/Compression: none/,
name => 'data content is gzip-compressed by default if available',
},
},
# Do not use --no-sync to give test coverage for data sync.
# By default, the directory format compresses its data files
# when the code is compiled with gzip support, and lets them
# uncompressed when not compiled with it.
defaults_dir_format => {
test_key => 'defaults',
dump_cmd => [
'pg_dump',
'--format' => 'directory',
'--file' => "$tempdir/defaults_dir_format",
'postgres',
],
restore_cmd => [
'pg_restore',
'--format' => 'directory',
'--file' => "$tempdir/defaults_dir_format.sql",
"$tempdir/defaults_dir_format",
],
command_like => {
command =>
[ 'pg_restore', '--list', "$tempdir/defaults_dir_format", ],
expected => $supports_gzip ? qr/Compression: gzip/
: qr/Compression: none/,
name => 'data content is gzip-compressed by default',
},
glob_patterns => [
"$tempdir/defaults_dir_format/toc.dat",
"$tempdir/defaults_dir_format/blobs_*.toc",
$supports_gzip ? "$tempdir/defaults_dir_format/*.dat.gz"
: "$tempdir/defaults_dir_format/*.dat",
],
},
# Do not use --no-sync to give test coverage for data sync.
defaults_parallel => {
test_key => 'defaults',
dump_cmd => [
'pg_dump',
'--format' => 'directory',
'--jobs' => 2,
'--file' => "$tempdir/defaults_parallel",
'postgres',
],
restore_cmd => [
'pg_restore',
'--file' => "$tempdir/defaults_parallel.sql",
"$tempdir/defaults_parallel",
],
},
# Do not use --no-sync to give test coverage for data sync.
defaults_tar_format => {
test_key => 'defaults',
dump_cmd => [
'pg_dump',
'--format' => 'tar',
'--file' => "$tempdir/defaults_tar_format.tar",
'postgres',
],
restore_cmd => [
'pg_restore',
'--format' => 'tar',
'--file' => "$tempdir/defaults_tar_format.sql",
"$tempdir/defaults_tar_format.tar",
],
},
exclude_dump_test_schema => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/exclude_dump_test_schema.sql",
'--exclude-schema' => 'dump_test',
'postgres',
],
},
exclude_test_table => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/exclude_test_table.sql",
'--exclude-table' => 'dump_test.test_table',
'postgres',
],
},
exclude_measurement => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/exclude_measurement.sql",
'--exclude-table-and-children' => 'dump_test.measurement',
'postgres',
],
},
exclude_measurement_data => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/exclude_measurement_data.sql",
'--exclude-table-data-and-children' => 'dump_test.measurement',
'--no-unlogged-table-data',
'postgres',
],
},
exclude_test_table_data => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/exclude_test_table_data.sql",
'--exclude-table-data' => 'dump_test.test_table',
'--no-unlogged-table-data',
'postgres',
],
},
inserts => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/inserts.sql",
'--data-only',
'--inserts', 'postgres',
],
},
pg_dumpall_globals => {
dump_cmd => [
'pg_dumpall',
'--verbose',
'--file' => "$tempdir/pg_dumpall_globals.sql",
'--globals-only',
'--no-sync',
],
},
pg_dumpall_globals_clean => {
dump_cmd => [
'pg_dumpall',
'--file' => "$tempdir/pg_dumpall_globals_clean.sql",
'--globals-only',
'--clean',
'--no-sync',
],
},
pg_dumpall_dbprivs => {
dump_cmd => [
'pg_dumpall', '--no-sync',
'--file' => "$tempdir/pg_dumpall_dbprivs.sql",
],
},
pg_dumpall_exclude => {
dump_cmd => [
'pg_dumpall',
'--verbose',
'--file' => "$tempdir/pg_dumpall_exclude.sql",
'--exclude-database' => '*dump_test*',
'--no-sync',
],
},
no_toast_compression => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/no_toast_compression.sql",
'--no-toast-compression',
'postgres',
],
},
no_large_objects => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/no_large_objects.sql",
'--no-large-objects',
'postgres',
],
},
no_policies => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/no_policies.sql",
'--no-policies',
'postgres',
],
},
no_privs => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/no_privs.sql",
'--no-privileges',
'postgres',
],
},
no_owner => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/no_owner.sql",
'--no-owner',
'postgres',
],
},
no_table_access_method => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/no_table_access_method.sql",
'--no-table-access-method',
'postgres',
],
},
only_dump_test_schema => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/only_dump_test_schema.sql",
'--schema' => 'dump_test',
'postgres',
],
},
only_dump_test_table => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/only_dump_test_table.sql",
'--table' => 'dump_test.test_table',
'--lock-wait-timeout' =>
(1000 * $PostgreSQL::Test::Utils::timeout_default),
'postgres',
],
},
only_dump_measurement => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/only_dump_measurement.sql",
'--table-and-children' => 'dump_test.measurement',
'--lock-wait-timeout' =>
(1000 * $PostgreSQL::Test::Utils::timeout_default),
'postgres',
],
},
role => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/role.sql",
'--role' => 'regress_dump_test_role',
'--schema' => 'dump_test_second_schema',
'postgres',
],
},
role_parallel => {
test_key => 'role',
dump_cmd => [
'pg_dump', '--no-sync',
'--format' => 'directory',
'--jobs' => '2',
'--file' => "$tempdir/role_parallel",
'--role' => 'regress_dump_test_role',
'--schema' => 'dump_test_second_schema',
'postgres',
],
restore_cmd => [
'pg_restore',
'--file' => "$tempdir/role_parallel.sql",
"$tempdir/role_parallel",
],
},
rows_per_insert => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/rows_per_insert.sql",
'--data-only',
'--rows-per-insert' => '4',
'--table' => 'dump_test.test_table',
'--table' => 'dump_test.test_fourth_table',
'postgres',
],
},
schema_only => {
dump_cmd => [
'pg_dump', '--no-sync',
'--format' => 'plain',
'--file' => "$tempdir/schema_only.sql",
'--schema-only',
'postgres',
],
},
section_pre_data => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/section_pre_data.sql",
'--section' => 'pre-data',
'postgres',
],
},
section_data => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/section_data.sql",
'--section' => 'data',
'postgres',
],
},
section_post_data => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/section_post_data.sql",
'--section' => 'post-data',
'postgres',
],
},
test_schema_plus_large_objects => {
dump_cmd => [
'pg_dump', '--no-sync',
'--file' => "$tempdir/test_schema_plus_large_objects.sql",
'--schema' => 'dump_test',
'--large-objects',
'--no-large-objects',
'postgres',
],
},
no_statistics => {
dump_cmd => [
'pg_dump', '--no-sync',
"--file=$tempdir/no_statistics.sql", '--no-statistics',
'postgres',
],
},
no_data_no_schema => {
dump_cmd => [
'pg_dump', '--no-sync',
"--file=$tempdir/no_data_no_schema.sql", '--no-data',
'--no-schema', 'postgres',
],
},
statistics_only => {
dump_cmd => [
'pg_dump', '--no-sync',
"--file=$tempdir/statistics_only.sql", '--statistics-only',
'postgres',
],
},
schema_only_with_statistics => {
dump_cmd => [
'pg_dump', '--no-sync',
"--file=$tempdir/schema_only_with_statistics.sql",
'--schema-only', '--with-statistics', 'postgres',
],
},
no_schema => {
dump_cmd => [
'pg_dump', '--no-sync',
"--file=$tempdir/no_schema.sql", '--no-schema',
'postgres',
],
},);
###############################################################
# Definition of the tests to run.
#
# Each test is defined using the log message that will be used.
#
# A regexp should be defined for each test which provides the
# basis for the test. That regexp will be run against the output
# file of each of the runs which the test is to be run against
# and the success of the result will depend on if the regexp
# result matches the expected 'like' or 'unlike' case.
#
# The runs listed as 'like' will be checked if they match the
# regexp and, if so, the test passes. All runs which are not
# listed as 'like' will be checked to ensure they don't match
# the regexp; if they do, the test will fail.
#
# The below hashes provide convenience sets of runs. Individual
# runs can be excluded from a general hash by placing that run
# into the 'unlike' section.
#
# For example, there is an 'exclude_test_table' run which runs a
# full pg_dump but with an exclude flag to not include the test
# table. The CREATE TABLE test which creates the test table is
# defined with %full_runs but then has 'exclude_test_table' in
# its 'unlike' list, excluding that test.
#
# There can then be a 'create_sql' and 'create_order' for a
# given test. The 'create_sql' commands are collected up in
# 'create_order' and then run against the database prior to any
# of the pg_dump runs happening. This is what "seeds" the
# system with objects to be dumped out.
#
# There can be a flag called 'lz4', which can be set if the test
# case depends on LZ4. Tests marked with this flag are skipped if
# the build used does not support LZ4.
#
# Building of this hash takes a bit of time as all of the regexps
# included in it are compiled. This greatly improves performance
# as the regexps are used for each run the test applies to.
# Tests which target the 'dump_test' schema, specifically.
my %dump_test_schema_runs = (
only_dump_test_schema => 1,
only_dump_measurement => 1,
test_schema_plus_large_objects => 1,);
# Tests which are considered 'full' dumps by pg_dump, but there
# are flags used to exclude specific items (ACLs, LOs, etc).
my %full_runs = (
binary_upgrade => 1,
clean => 1,
clean_if_exists => 1,
compression => 1,
createdb => 1,
defaults => 1,
exclude_dump_test_schema => 1,
exclude_test_table => 1,
exclude_test_table_data => 1,
exclude_measurement => 1,
exclude_measurement_data => 1,
no_toast_compression => 1,
no_large_objects => 1,
no_owner => 1,
no_policies => 1,
no_privs => 1,
no_statistics => 1,
no_table_access_method => 1,
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
schema_only => 1,
schema_only_with_statistics => 1,);
# This is where the actual tests are defined.
my %tests = (
'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT' => {
create_order => 14,
create_sql => 'ALTER DEFAULT PRIVILEGES
FOR ROLE regress_dump_test_role IN SCHEMA dump_test
GRANT SELECT ON TABLES TO regress_dump_test_role;',
regexp => qr/^
\QALTER DEFAULT PRIVILEGES \E
\QFOR ROLE regress_dump_test_role IN SCHEMA dump_test \E
\QGRANT SELECT ON TABLES TO regress_dump_test_role;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_privs => 1,
only_dump_measurement => 1,
},
},
'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role GRANT EXECUTE ON FUNCTIONS'
=> {
create_order => 15,
create_sql => 'ALTER DEFAULT PRIVILEGES
FOR ROLE regress_dump_test_role IN SCHEMA dump_test
GRANT EXECUTE ON FUNCTIONS TO regress_dump_test_role;',
regexp => qr/^
\QALTER DEFAULT PRIVILEGES \E
\QFOR ROLE regress_dump_test_role IN SCHEMA dump_test \E
\QGRANT ALL ON FUNCTIONS TO regress_dump_test_role;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_privs => 1,
only_dump_measurement => 1,
},
},
'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role REVOKE' => {
create_order => 55,
create_sql => 'ALTER DEFAULT PRIVILEGES
FOR ROLE regress_dump_test_role
REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC;',
regexp => qr/^
\QALTER DEFAULT PRIVILEGES \E
\QFOR ROLE regress_dump_test_role \E
\QREVOKE ALL ON FUNCTIONS FROM PUBLIC;\E
/xm,
like => { %full_runs, section_post_data => 1, },
unlike => { no_privs => 1, },
},
'ALTER DEFAULT PRIVILEGES FOR ROLE regress_dump_test_role REVOKE SELECT'
=> {
create_order => 56,
create_sql => 'ALTER DEFAULT PRIVILEGES
FOR ROLE regress_dump_test_role
REVOKE SELECT ON TABLES FROM regress_dump_test_role;',
regexp => qr/^
\QALTER DEFAULT PRIVILEGES \E
\QFOR ROLE regress_dump_test_role \E
\QREVOKE ALL ON TABLES FROM regress_dump_test_role;\E\n
\QALTER DEFAULT PRIVILEGES \E
\QFOR ROLE regress_dump_test_role \E
\QGRANT INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,MAINTAIN,UPDATE ON TABLES TO regress_dump_test_role;\E
/xm,
like => { %full_runs, section_post_data => 1, },
unlike => { no_privs => 1, },
},
'ALTER ROLE regress_dump_test_role' => {
regexp => qr/^
\QALTER ROLE regress_dump_test_role WITH \E
\QNOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB NOLOGIN \E
\QNOREPLICATION NOBYPASSRLS;\E
/xm,
like => {
pg_dumpall_dbprivs => 1,
pg_dumpall_globals => 1,
pg_dumpall_globals_clean => 1,
pg_dumpall_exclude => 1,
},
},
'ALTER COLLATION test0 OWNER TO' => {
regexp => qr/^\QALTER COLLATION public.test0 OWNER TO \E.+;/m,
collation => 1,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_owner => 1, },
},
'ALTER FOREIGN DATA WRAPPER dummy OWNER TO' => {
regexp => qr/^ALTER FOREIGN DATA WRAPPER dummy OWNER TO .+;/m,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_owner => 1, },
},
'ALTER SERVER s1 OWNER TO' => {
regexp => qr/^ALTER SERVER s1 OWNER TO .+;/m,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_owner => 1, },
},
'ALTER FUNCTION dump_test.pltestlang_call_handler() OWNER TO' => {
regexp => qr/^
\QALTER FUNCTION dump_test.pltestlang_call_handler() \E
\QOWNER TO \E
.+;/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_owner => 1,
only_dump_measurement => 1,
},
},
'ALTER OPERATOR FAMILY dump_test.op_family OWNER TO' => {
regexp => qr/^
\QALTER OPERATOR FAMILY dump_test.op_family USING btree \E
\QOWNER TO \E
.+;/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_owner => 1,
only_dump_measurement => 1,
},
},
'ALTER OPERATOR FAMILY dump_test.op_family USING btree' => {
create_order => 75,
create_sql =>
'ALTER OPERATOR FAMILY dump_test.op_family USING btree ADD
OPERATOR 1 <(bigint,int4),
OPERATOR 2 <=(bigint,int4),
OPERATOR 3 =(bigint,int4),
OPERATOR 4 >=(bigint,int4),
OPERATOR 5 >(bigint,int4),
FUNCTION 1 (int4, int4) btint4cmp(int4,int4),
FUNCTION 2 (int4, int4) btint4sortsupport(internal),
FUNCTION 4 (int4, int4) btequalimage(oid);',
# note: it's correct that btint8sortsupport and bigint btequalimage
# are included here:
regexp => qr/^
\QALTER OPERATOR FAMILY dump_test.op_family USING btree ADD\E\n\s+
\QOPERATOR 1 <(bigint,integer) ,\E\n\s+
\QOPERATOR 2 <=(bigint,integer) ,\E\n\s+
\QOPERATOR 3 =(bigint,integer) ,\E\n\s+
\QOPERATOR 4 >=(bigint,integer) ,\E\n\s+
\QOPERATOR 5 >(bigint,integer) ,\E\n\s+
\QFUNCTION 1 (integer, integer) btint4cmp(integer,integer) ,\E\n\s+
\QFUNCTION 2 (bigint, bigint) btint8sortsupport(internal) ,\E\n\s+
\QFUNCTION 2 (integer, integer) btint4sortsupport(internal) ,\E\n\s+
\QFUNCTION 4 (bigint, bigint) btequalimage(oid) ,\E\n\s+
\QFUNCTION 4 (integer, integer) btequalimage(oid);\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'ALTER OPERATOR CLASS dump_test.op_class OWNER TO' => {
regexp => qr/^
\QALTER OPERATOR CLASS dump_test.op_class USING btree \E
\QOWNER TO \E
.+;/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_owner => 1,
only_dump_measurement => 1,
},
},
'ALTER PUBLICATION pub1 OWNER TO' => {
regexp => qr/^ALTER PUBLICATION pub1 OWNER TO .+;/m,
like => { %full_runs, section_post_data => 1, },
unlike => { no_owner => 1, },
},
'ALTER LARGE OBJECT ... OWNER TO' => {
regexp => qr/^ALTER LARGE OBJECT \d+ OWNER TO .+;/m,
like => {
%full_runs,
column_inserts => 1,
data_only => 1,
inserts => 1,
no_schema => 1,
section_data => 1,
test_schema_plus_large_objects => 1,
},
unlike => {
no_large_objects => 1,
no_owner => 1,
schema_only => 1,
schema_only_with_statistics => 1,
},
},
'ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO' => {
regexp => qr/^ALTER PROCEDURAL LANGUAGE pltestlang OWNER TO .+;/m,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_owner => 1, },
},
'ALTER SCHEMA dump_test OWNER TO' => {
regexp => qr/^ALTER SCHEMA dump_test OWNER TO .+;/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_owner => 1,
only_dump_measurement => 1,
},
},
'ALTER SCHEMA dump_test_second_schema OWNER TO' => {
regexp => qr/^ALTER SCHEMA dump_test_second_schema OWNER TO .+;/m,
like => {
%full_runs,
role => 1,
section_pre_data => 1,
},
unlike => { no_owner => 1, },
},
'ALTER SCHEMA public OWNER TO' => {
create_order => 15,
create_sql =>
'ALTER SCHEMA public OWNER TO "regress_quoted \"" role";',
regexp => qr/^ALTER SCHEMA public OWNER TO .+;/m,
like => {
%full_runs, section_pre_data => 1,
},
unlike => { no_owner => 1, },
},
'ALTER SCHEMA public OWNER TO (w/o ACL changes)' => {
database => 'regress_public_owner',
create_order => 100,
create_sql =>
'ALTER SCHEMA public OWNER TO "regress_quoted \"" role";',
regexp => qr/^(GRANT|REVOKE)/m,
like => {},
},
'ALTER SEQUENCE test_table_col1_seq' => {
regexp => qr/^
\QALTER SEQUENCE dump_test.test_table_col1_seq OWNED BY dump_test.test_table.col1;\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE ONLY test_table ADD CONSTRAINT ... PRIMARY KEY' => {
regexp => qr/^
\QALTER TABLE ONLY dump_test.test_table\E \n^\s+
\QADD CONSTRAINT test_table_pkey PRIMARY KEY (col1);\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'CONSTRAINT NOT NULL / NOT VALID' => {
create_sql => 'CREATE TABLE dump_test.test_table_nn (
col1 int);
CREATE TABLE dump_test.test_table_nn_2 (
col1 int NOT NULL);
CREATE TABLE dump_test.test_table_nn_chld1 (
) INHERITS (dump_test.test_table_nn);
CREATE TABLE dump_test.test_table_nn_chld2 (
col1 int
) INHERITS (dump_test.test_table_nn);
CREATE TABLE dump_test.test_table_nn_chld3 (
) INHERITS (dump_test.test_table_nn, dump_test.test_table_nn_2);
ALTER TABLE dump_test.test_table_nn ADD CONSTRAINT nn NOT NULL col1 NOT VALID;
ALTER TABLE dump_test.test_table_nn_chld1 VALIDATE CONSTRAINT nn;
ALTER TABLE dump_test.test_table_nn_chld2 VALIDATE CONSTRAINT nn;',
regexp => qr/^
\QALTER TABLE dump_test.test_table_nn\E \n^\s+
\QADD CONSTRAINT nn NOT NULL col1 NOT VALID;\E
/xm,
like => {
%full_runs, %dump_test_schema_runs, section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CONSTRAINT NOT NULL / NOT VALID (child1)' => {
regexp => qr/^
\QCREATE TABLE dump_test.test_table_nn_chld1 (\E\n
^\s+\QCONSTRAINT nn NOT NULL col1\E$
/xm,
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
binary_upgrade => 1,
},
},
'CONSTRAINT NOT NULL / NOT VALID (child2)' => {
regexp => qr/^
\QCREATE TABLE dump_test.test_table_nn_chld2 (\E\n
^\s+\Qcol1 integer CONSTRAINT nn NOT NULL\E$
/xm,
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CONSTRAINT NOT NULL / NOT VALID (child3)' => {
regexp => qr/^
\QCREATE TABLE dump_test.test_table_nn_chld3 (\E\n
^\Q)\E$
/xm,
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
binary_upgrade => 1,
},
},
'CONSTRAINT PRIMARY KEY / WITHOUT OVERLAPS' => {
create_sql => 'CREATE TABLE dump_test.test_table_tpk (
col1 int4range,
col2 tstzrange,
CONSTRAINT test_table_tpk_pkey PRIMARY KEY (col1, col2 WITHOUT OVERLAPS));',
regexp => qr/^
\QALTER TABLE ONLY dump_test.test_table_tpk\E \n^\s+
\QADD CONSTRAINT test_table_tpk_pkey PRIMARY KEY (col1, col2 WITHOUT OVERLAPS);\E
/xm,
like => {
%full_runs, %dump_test_schema_runs, section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CONSTRAINT UNIQUE / WITHOUT OVERLAPS' => {
create_sql => 'CREATE TABLE dump_test.test_table_tuq (
col1 int4range,
col2 tstzrange,
CONSTRAINT test_table_tuq_uq UNIQUE (col1, col2 WITHOUT OVERLAPS));',
regexp => qr/^
\QALTER TABLE ONLY dump_test.test_table_tuq\E \n^\s+
\QADD CONSTRAINT test_table_tuq_uq UNIQUE (col1, col2 WITHOUT OVERLAPS);\E
/xm,
like => {
%full_runs, %dump_test_schema_runs, section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE (partitioned) ADD CONSTRAINT ... FOREIGN KEY' => {
create_order => 4,
create_sql => 'CREATE TABLE dump_test.test_table_fk (
col1 int references dump_test.test_table)
PARTITION BY RANGE (col1);
CREATE TABLE dump_test.test_table_fk_1
PARTITION OF dump_test.test_table_fk
FOR VALUES FROM (0) TO (10);',
regexp => qr/
\QADD CONSTRAINT test_table_fk_col1_fkey FOREIGN KEY (col1) REFERENCES dump_test.test_table\E
/xm,
like => {
%full_runs, %dump_test_schema_runs, section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE ONLY test_table ALTER COLUMN col1 SET STATISTICS 90' => {
create_order => 93,
create_sql =>
'ALTER TABLE dump_test.test_table ALTER COLUMN col1 SET STATISTICS 90;',
regexp => qr/^
\QALTER TABLE ONLY dump_test.test_table ALTER COLUMN col1 SET STATISTICS 90;\E\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE ONLY test_table ALTER COLUMN col2 SET STORAGE' => {
create_order => 94,
create_sql =>
'ALTER TABLE dump_test.test_table ALTER COLUMN col2 SET STORAGE EXTERNAL;',
regexp => qr/^
\QALTER TABLE ONLY dump_test.test_table ALTER COLUMN col2 SET STORAGE EXTERNAL;\E\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE ONLY test_table ALTER COLUMN col3 SET STORAGE' => {
create_order => 95,
create_sql =>
'ALTER TABLE dump_test.test_table ALTER COLUMN col3 SET STORAGE MAIN;',
regexp => qr/^
\QALTER TABLE ONLY dump_test.test_table ALTER COLUMN col3 SET STORAGE MAIN;\E\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE ONLY test_table ALTER COLUMN col4 SET n_distinct' => {
create_order => 95,
create_sql =>
'ALTER TABLE dump_test.test_table ALTER COLUMN col4 SET (n_distinct = 10);',
regexp => qr/^
\QALTER TABLE ONLY dump_test.test_table ALTER COLUMN col4 SET (n_distinct=10);\E\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE ONLY dump_test.measurement ATTACH PARTITION measurement_y2006m2'
=> {
regexp => qr/^
\QALTER TABLE ONLY dump_test.measurement ATTACH PARTITION dump_test_second_schema.measurement_y2006m2 \E
\QFOR VALUES FROM ('2006-02-01') TO ('2006-03-01');\E\n
/xm,
like => {
%full_runs,
role => 1,
section_pre_data => 1,
binary_upgrade => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_measurement => 1,
},
},
'ALTER TABLE test_table CLUSTER ON test_table_pkey' => {
create_order => 96,
create_sql =>
'ALTER TABLE dump_test.test_table CLUSTER ON test_table_pkey',
regexp => qr/^
\QALTER TABLE dump_test.test_table CLUSTER ON test_table_pkey;\E\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE test_table DISABLE TRIGGER ALL' => {
regexp => qr/^
\QSET SESSION AUTHORIZATION 'test_superuser';\E\n\n
\QALTER TABLE dump_test.test_table DISABLE TRIGGER ALL;\E\n\n
\QCOPY dump_test.test_table (col1, col2, col3, col4) FROM stdin;\E
\n(?:\d\t\\N\t\\N\t\\N\n){9}\\\.\n\n\n
\QALTER TABLE dump_test.test_table ENABLE TRIGGER ALL;\E/xm,
like => { data_only => 1, },
},
'ALTER FOREIGN TABLE foreign_table ALTER COLUMN c1 OPTIONS' => {
regexp => qr/^
\QALTER FOREIGN TABLE ONLY dump_test.foreign_table ALTER COLUMN c1 OPTIONS (\E\n
\s+\Qcolumn_name 'col1'\E\n
\Q);\E\n
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE test_table OWNER TO' => {
regexp => qr/^\QALTER TABLE dump_test.test_table OWNER TO \E.+;/m,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
no_owner => 1,
},
},
'ALTER TABLE test_table ENABLE ROW LEVEL SECURITY' => {
create_order => 23,
create_sql => 'ALTER TABLE dump_test.test_table
ENABLE ROW LEVEL SECURITY;',
regexp =>
qr/^\QALTER TABLE dump_test.test_table ENABLE ROW LEVEL SECURITY;\E/m,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
no_policies => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE test_second_table OWNER TO' => {
regexp =>
qr/^\QALTER TABLE dump_test.test_second_table OWNER TO \E.+;/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_owner => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE measurement OWNER TO' => {
regexp => qr/^\QALTER TABLE dump_test.measurement OWNER TO \E.+;/m,
like => {
%full_runs,
%dump_test_schema_runs,
section_pre_data => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_dump_test_schema => 1,
no_owner => 1,
exclude_measurement => 1,
},
},
'ALTER TABLE measurement_y2006m2 OWNER TO' => {
regexp =>
qr/^\QALTER TABLE dump_test_second_schema.measurement_y2006m2 OWNER TO \E.+;/m,
like => {
%full_runs,
role => 1,
section_pre_data => 1,
only_dump_measurement => 1,
},
unlike => {
no_owner => 1,
exclude_measurement => 1,
},
},
'ALTER FOREIGN TABLE foreign_table OWNER TO' => {
regexp =>
qr/^\QALTER FOREIGN TABLE dump_test.foreign_table OWNER TO \E.+;/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_owner => 1,
only_dump_measurement => 1,
},
},
'ALTER TEXT SEARCH CONFIGURATION alt_ts_conf1 OWNER TO' => {
regexp =>
qr/^\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 OWNER TO \E.+;/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_owner => 1,
only_dump_measurement => 1,
},
},
'ALTER TEXT SEARCH DICTIONARY alt_ts_dict1 OWNER TO' => {
regexp =>
qr/^\QALTER TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 OWNER TO \E.+;/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_owner => 1,
only_dump_measurement => 1,
},
},
'LO create (using lo_from_bytea)' => {
create_order => 50,
create_sql =>
'SELECT pg_catalog.lo_from_bytea(0, \'\\x310a320a330a340a350a360a370a380a390a\');',
regexp => qr/^SELECT pg_catalog\.lo_create\('\d+'\);/m,
like => {
%full_runs,
column_inserts => 1,
data_only => 1,
inserts => 1,
no_schema => 1,
section_data => 1,
test_schema_plus_large_objects => 1,
},
unlike => {
schema_only => 1,
schema_only_with_statistics => 1,
no_large_objects => 1,
},
},
'LO load (using lo_from_bytea)' => {
regexp => qr/^
\QSELECT pg_catalog.lo_open\E \('\d+',\ \d+\);\n
\QSELECT pg_catalog.lowrite(0, \E
\Q'\x310a320a330a340a350a360a370a380a390a');\E\n
\QSELECT pg_catalog.lo_close(0);\E
/xm,
like => {
%full_runs,
column_inserts => 1,
data_only => 1,
inserts => 1,
no_schema => 1,
section_data => 1,
test_schema_plus_large_objects => 1,
},
unlike => {
binary_upgrade => 1,
no_large_objects => 1,
schema_only => 1,
schema_only_with_statistics => 1,
},
},
'LO create (with no data)' => {
create_sql => 'SELECT pg_catalog.lo_create(0);',
regexp => qr/^
\QSELECT pg_catalog.lo_open\E \('\d+',\ \d+\);\n
\QSELECT pg_catalog.lo_close(0);\E
/xm,
like => {
%full_runs,
column_inserts => 1,
data_only => 1,
inserts => 1,
no_schema => 1,
section_data => 1,
test_schema_plus_large_objects => 1,
},
unlike => {
binary_upgrade => 1,
no_large_objects => 1,
schema_only => 1,
schema_only_with_statistics => 1,
},
},
'COMMENT ON DATABASE postgres' => {
regexp => qr/^COMMENT ON DATABASE postgres IS .+;/m,
# Should appear in the same tests as "CREATE DATABASE postgres"
like => { createdb => 1, },
},
'COMMENT ON EXTENSION plpgsql' => {
regexp => qr/^COMMENT ON EXTENSION plpgsql IS .+;/m,
# this shouldn't ever get emitted anymore
like => {},
},
'COMMENT ON SCHEMA public' => {
regexp => qr/^COMMENT ON SCHEMA public IS .+;/m,
# regress_public_owner emits this, due to create_sql of next test
like => {
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
},
},
'COMMENT ON SCHEMA public IS NULL' => {
database => 'regress_public_owner',
create_order => 100,
create_sql => 'COMMENT ON SCHEMA public IS NULL;',
regexp => qr/^COMMENT ON SCHEMA public IS '';/m,
like => { defaults_public_owner => 1 },
},
'COMMENT ON TABLE dump_test.test_table' => {
create_order => 36,
create_sql => 'COMMENT ON TABLE dump_test.test_table
IS \'comment on table\';',
regexp =>
qr/^\QCOMMENT ON TABLE dump_test.test_table IS 'comment on table';\E/m,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON COLUMN dump_test.test_table.col1' => {
create_order => 36,
create_sql => 'COMMENT ON COLUMN dump_test.test_table.col1
IS \'comment on column\';',
regexp => qr/^
\QCOMMENT ON COLUMN dump_test.test_table.col1 IS 'comment on column';\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON COLUMN dump_test.composite.f1' => {
create_order => 44,
create_sql => 'COMMENT ON COLUMN dump_test.composite.f1
IS \'comment on column of type\';',
regexp => qr/^
\QCOMMENT ON COLUMN dump_test.composite.f1 IS 'comment on column of type';\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON COLUMN dump_test.test_second_table.col1' => {
create_order => 63,
create_sql => 'COMMENT ON COLUMN dump_test.test_second_table.col1
IS \'comment on column col1\';',
regexp => qr/^
\QCOMMENT ON COLUMN dump_test.test_second_table.col1 IS 'comment on column col1';\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON COLUMN dump_test.test_second_table.col2' => {
create_order => 64,
create_sql => 'COMMENT ON COLUMN dump_test.test_second_table.col2
IS \'comment on column col2\';',
regexp => qr/^
\QCOMMENT ON COLUMN dump_test.test_second_table.col2 IS 'comment on column col2';\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON CONVERSION dump_test.test_conversion' => {
create_order => 79,
create_sql => 'COMMENT ON CONVERSION dump_test.test_conversion
IS \'comment on test conversion\';',
regexp =>
qr/^\QCOMMENT ON CONVERSION dump_test.test_conversion IS 'comment on test conversion';\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON COLLATION test0' => {
create_order => 77,
create_sql => 'COMMENT ON COLLATION test0
IS \'comment on test0 collation\';',
regexp =>
qr/^\QCOMMENT ON COLLATION public.test0 IS 'comment on test0 collation';\E/m,
collation => 1,
like => { %full_runs, section_pre_data => 1, },
},
'COMMENT ON LARGE OBJECT ...' => {
create_order => 65,
create_sql => 'DO $$
DECLARE myoid oid;
BEGIN
SELECT loid FROM pg_largeobject INTO myoid;
EXECUTE \'COMMENT ON LARGE OBJECT \' || myoid || \' IS \'\'comment on large object\'\';\';
END;
$$;',
regexp => qr/^
\QCOMMENT ON LARGE OBJECT \E[0-9]+\Q IS 'comment on large object';\E
/xm,
like => {
%full_runs,
column_inserts => 1,
data_only => 1,
inserts => 1,
no_schema => 1,
section_data => 1,
test_schema_plus_large_objects => 1,
},
unlike => {
no_large_objects => 1,
schema_only => 1,
schema_only_with_statistics => 1,
},
},
'COMMENT ON PUBLICATION pub1' => {
create_order => 55,
create_sql => 'COMMENT ON PUBLICATION pub1
IS \'comment on publication\';',
regexp =>
qr/^COMMENT ON PUBLICATION pub1 IS 'comment on publication';/m,
like => { %full_runs, section_post_data => 1, },
},
'COMMENT ON SUBSCRIPTION sub1' => {
create_order => 55,
create_sql => 'COMMENT ON SUBSCRIPTION sub1
IS \'comment on subscription\';',
regexp =>
qr/^COMMENT ON SUBSCRIPTION sub1 IS 'comment on subscription';/m,
like => { %full_runs, section_post_data => 1, },
},
'COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1' => {
create_order => 84,
create_sql =>
'COMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1
IS \'comment on text search configuration\';',
regexp =>
qr/^\QCOMMENT ON TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 IS 'comment on text search configuration';\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1' => {
create_order => 84,
create_sql =>
'COMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1
IS \'comment on text search dictionary\';',
regexp =>
qr/^\QCOMMENT ON TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 IS 'comment on text search dictionary';\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1' => {
create_order => 84,
create_sql => 'COMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1
IS \'comment on text search parser\';',
regexp =>
qr/^\QCOMMENT ON TEXT SEARCH PARSER dump_test.alt_ts_prs1 IS 'comment on text search parser';\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1' => {
create_order => 84,
create_sql => 'COMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1
IS \'comment on text search template\';',
regexp =>
qr/^\QCOMMENT ON TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 IS 'comment on text search template';\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON TYPE dump_test.planets - ENUM' => {
create_order => 68,
create_sql => 'COMMENT ON TYPE dump_test.planets
IS \'comment on enum type\';',
regexp =>
qr/^\QCOMMENT ON TYPE dump_test.planets IS 'comment on enum type';\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON TYPE dump_test.textrange - RANGE' => {
create_order => 69,
create_sql => 'COMMENT ON TYPE dump_test.textrange
IS \'comment on range type\';',
regexp =>
qr/^\QCOMMENT ON TYPE dump_test.textrange IS 'comment on range type';\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON TYPE dump_test.int42 - Regular' => {
create_order => 70,
create_sql => 'COMMENT ON TYPE dump_test.int42
IS \'comment on regular type\';',
regexp =>
qr/^\QCOMMENT ON TYPE dump_test.int42 IS 'comment on regular type';\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COMMENT ON TYPE dump_test.undefined - Undefined' => {
create_order => 71,
create_sql => 'COMMENT ON TYPE dump_test.undefined
IS \'comment on undefined type\';',
regexp =>
qr/^\QCOMMENT ON TYPE dump_test.undefined IS 'comment on undefined type';\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'COPY test_table' => {
create_order => 4,
create_sql => 'INSERT INTO dump_test.test_table (col1) '
. 'SELECT generate_series FROM generate_series(1,9);',
regexp => qr/^
\QCOPY dump_test.test_table (col1, col2, col3, col4) FROM stdin;\E
\n(?:\d\t\\N\t\\N\t\\N\n){9}\\\.\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
data_only => 1,
no_schema => 1,
only_dump_test_table => 1,
section_data => 1,
},
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
exclude_test_table => 1,
exclude_test_table_data => 1,
schema_only => 1,
schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
'COPY fk_reference_test_table' => {
create_order => 22,
create_sql => 'INSERT INTO dump_test.fk_reference_test_table (col1) '
. 'SELECT generate_series FROM generate_series(1,5);',
regexp => qr/^
\QCOPY dump_test.fk_reference_test_table (col1) FROM stdin;\E
\n(?:\d\n){5}\\\.\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
data_only => 1,
exclude_test_table => 1,
exclude_test_table_data => 1,
no_schema => 1,
section_data => 1,
},
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
# In a data-only dump, we try to actually order according to FKs,
# so this check is just making sure that the referring table comes after
# the referred-to table.
'COPY fk_reference_test_table second' => {
regexp => qr/^
\QCOPY dump_test.test_table (col1, col2, col3, col4) FROM stdin;\E
\n(?:\d\t\\N\t\\N\t\\N\n){9}\\\.\n.*
\QCOPY dump_test.fk_reference_test_table (col1) FROM stdin;\E
\n(?:\d\n){5}\\\.\n
/xms,
like => {
data_only => 1,
no_schema => 1,
},
},
'COPY test_second_table' => {
create_order => 7,
create_sql => 'INSERT INTO dump_test.test_second_table (col1, col2) '
. 'SELECT generate_series, generate_series::text '
. 'FROM generate_series(1,9);',
regexp => qr/^
\QCOPY dump_test.test_second_table (col1, col2) FROM stdin;\E
\n(?:\d\t\d\n){9}\\\.\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
data_only => 1,
no_schema => 1,
section_data => 1,
},
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
'COPY test_third_table' => {
create_order => 7,
create_sql =>
'INSERT INTO dump_test.test_third_table VALUES (123, DEFAULT, 456);',
regexp => qr/^
\QCOPY dump_test.test_third_table (f1, "F3") FROM stdin;\E
\n123\t456\n\\\.\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
data_only => 1,
no_schema => 1,
section_data => 1,
},
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
'COPY test_fourth_table' => {
create_order => 7,
create_sql =>
'INSERT INTO dump_test.test_fourth_table DEFAULT VALUES;'
. 'INSERT INTO dump_test.test_fourth_table DEFAULT VALUES;',
regexp => qr/^
\QCOPY dump_test.test_fourth_table FROM stdin;\E
\n\n\n\\\.\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
data_only => 1,
no_schema => 1,
section_data => 1,
},
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
'COPY test_fifth_table' => {
create_order => 54,
create_sql =>
'INSERT INTO dump_test.test_fifth_table VALUES (NULL, true, false, \'11001\'::bit(5), \'NaN\');',
regexp => qr/^
\QCOPY dump_test.test_fifth_table (col1, col2, col3, col4, col5) FROM stdin;\E
\n\\N\tt\tf\t11001\tNaN\n\\\.\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
data_only => 1,
no_schema => 1,
section_data => 1,
},
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
'COPY test_table_identity' => {
create_order => 54,
create_sql =>
'INSERT INTO dump_test.test_table_identity (col2) VALUES (\'test\');',
regexp => qr/^
\QCOPY dump_test.test_table_identity (col1, col2) FROM stdin;\E
\n1\ttest\n\\\.\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
data_only => 1,
no_schema => 1,
section_data => 1,
},
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
'INSERT INTO test_table' => {
regexp => qr/^
(?:INSERT\ INTO\ dump_test\.test_table\ \(col1,\ col2,\ col3,\ col4\)\ VALUES\ \(\d,\ NULL,\ NULL,\ NULL\);\n){9}
/xm,
like => { column_inserts => 1, },
},
'test_table with 4-row INSERTs' => {
regexp => qr/^
(?:
INSERT\ INTO\ dump_test\.test_table\ VALUES\n
(?:\t\(\d,\ NULL,\ NULL,\ NULL\),\n){3}
\t\(\d,\ NULL,\ NULL,\ NULL\);\n
){2}
INSERT\ INTO\ dump_test\.test_table\ VALUES\n
\t\(\d,\ NULL,\ NULL,\ NULL\);
/xm,
like => { rows_per_insert => 1, },
},
'INSERT INTO test_second_table' => {
regexp => qr/^
(?:INSERT\ INTO\ dump_test\.test_second_table\ \(col1,\ col2\)
\ VALUES\ \(\d,\ '\d'\);\n){9}/xm,
like => { column_inserts => 1, },
},
'INSERT INTO test_third_table (colnames)' => {
regexp =>
qr/^INSERT INTO dump_test\.test_third_table \(f1, "F3"\) VALUES \(123, 456\);\n/m,
like => { column_inserts => 1, },
},
'INSERT INTO test_third_table' => {
regexp =>
qr/^INSERT INTO dump_test\.test_third_table VALUES \(123, DEFAULT, 456, DEFAULT\);\n/m,
like => { inserts => 1, },
},
'INSERT INTO test_fourth_table' => {
regexp =>
qr/^(?:INSERT INTO dump_test\.test_fourth_table DEFAULT VALUES;\n){2}/m,
like => { column_inserts => 1, inserts => 1, rows_per_insert => 1, },
},
'INSERT INTO test_fifth_table' => {
regexp =>
qr/^\QINSERT INTO dump_test.test_fifth_table (col1, col2, col3, col4, col5) VALUES (NULL, true, false, B'11001', 'NaN');\E/m,
like => { column_inserts => 1, },
},
'INSERT INTO test_table_identity' => {
regexp =>
qr/^\QINSERT INTO dump_test.test_table_identity (col1, col2) OVERRIDING SYSTEM VALUE VALUES (1, 'test');\E/m,
like => { column_inserts => 1, },
},
'CREATE ROLE regress_dump_test_role' => {
create_order => 1,
create_sql => 'CREATE ROLE regress_dump_test_role;',
regexp => qr/^CREATE ROLE regress_dump_test_role;/m,
like => {
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
pg_dumpall_globals => 1,
pg_dumpall_globals_clean => 1,
},
},
'CREATE ROLE regress_quoted...' => {
create_order => 1,
create_sql => 'CREATE ROLE "regress_quoted \"" role";',
regexp => qr/^CREATE ROLE "regress_quoted \\"" role";/m,
like => {
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
pg_dumpall_globals => 1,
pg_dumpall_globals_clean => 1,
},
},
'CREATE TABLESPACE regress_dump_tablespace' => {
create_order => 2,
create_sql => q(
SET allow_in_place_tablespaces = on;
CREATE TABLESPACE regress_dump_tablespace
OWNER regress_dump_test_role LOCATION ''),
regexp =>
qr/^CREATE TABLESPACE regress_dump_tablespace OWNER regress_dump_test_role LOCATION '';/m,
like => {
pg_dumpall_dbprivs => 1,
pg_dumpall_exclude => 1,
pg_dumpall_globals => 1,
pg_dumpall_globals_clean => 1,
},
},
'CREATE DATABASE regression_invalid...' => {
create_order => 1,
create_sql => q(
CREATE DATABASE regression_invalid;
UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid'),
regexp => qr/^CREATE DATABASE regression_invalid/m,
# invalid databases should never be dumped
like => {},
},
'CREATE ACCESS METHOD gist2' => {
create_order => 52,
create_sql =>
'CREATE ACCESS METHOD gist2 TYPE INDEX HANDLER gisthandler;',
regexp =>
qr/CREATE ACCESS METHOD gist2 TYPE INDEX HANDLER gisthandler;/m,
like => { %full_runs, section_pre_data => 1, },
},
'CREATE COLLATION test0 FROM "C"' => {
create_order => 76,
create_sql => 'CREATE COLLATION test0 FROM "C";',
regexp =>
qr/CREATE COLLATION public.test0 \(provider = libc, locale = 'C'(, version = '[^']*')?\);/m,
collation => 1,
like => { %full_runs, section_pre_data => 1, },
},
'CREATE COLLATION icu_collation' => {
create_order => 76,
create_sql =>
"CREATE COLLATION icu_collation (PROVIDER = icu, LOCALE = 'en-US-u-va-posix');",
regexp =>
qr/CREATE COLLATION public.icu_collation \(provider = icu, locale = 'en-US-u-va-posix'(, version = '[^']*')?\);/m,
icu => 1,
like => { %full_runs, section_pre_data => 1, },
},
'CREATE CAST FOR timestamptz' => {
create_order => 51,
create_sql =>
'CREATE CAST (timestamptz AS interval) WITH FUNCTION age(timestamptz) AS ASSIGNMENT;',
regexp =>
qr/CREATE CAST \(timestamp with time zone AS interval\) WITH FUNCTION pg_catalog\.age\(timestamp with time zone\) AS ASSIGNMENT;/m,
like => { %full_runs, section_pre_data => 1, },
},
'CREATE DATABASE postgres' => {
regexp => qr/^
\QCREATE DATABASE postgres WITH TEMPLATE = template0 \E
.+;/xm,
like => { createdb => 1, },
},
'CREATE DATABASE dump_test' => {
create_order => 47,
create_sql => 'CREATE DATABASE dump_test;',
regexp => qr/^
\QCREATE DATABASE dump_test WITH TEMPLATE = template0 \E
.+;/xm,
like => { pg_dumpall_dbprivs => 1, },
},
"CREATE DATABASE dump_test2 LOCALE = 'C'" => {
create_order => 47,
create_sql =>
"CREATE DATABASE dump_test2 LOCALE = 'C' TEMPLATE = template0;",
regexp => qr/^
\QCREATE DATABASE dump_test2 \E.*\QLOCALE = 'C';\E
/xm,
like => { pg_dumpall_dbprivs => 1, },
},
'CREATE EXTENSION ... plpgsql' => {
regexp => qr/^
\QCREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;\E
/xm,
# this shouldn't ever get emitted anymore
like => {},
},
'CREATE AGGREGATE dump_test.newavg' => {
create_order => 25,
create_sql => 'CREATE AGGREGATE dump_test.newavg (
sfunc = int4_avg_accum,
basetype = int4,
stype = _int8,
finalfunc = int8_avg,
finalfunc_modify = shareable,
initcond1 = \'{0,0}\'
);',
regexp => qr/^
\QCREATE AGGREGATE dump_test.newavg(integer) (\E
\n\s+\QSFUNC = int4_avg_accum,\E
\n\s+\QSTYPE = bigint[],\E
\n\s+\QINITCOND = '{0,0}',\E
\n\s+\QFINALFUNC = int8_avg,\E
\n\s+\QFINALFUNC_MODIFY = SHAREABLE\E
\n\);/xm,
like => {
%full_runs,
%dump_test_schema_runs,
exclude_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE CONVERSION dump_test.test_conversion' => {
create_order => 78,
create_sql =>
'CREATE DEFAULT CONVERSION dump_test.test_conversion FOR \'LATIN1\' TO \'UTF8\' FROM iso8859_1_to_utf8;',
regexp =>
qr/^\QCREATE DEFAULT CONVERSION dump_test.test_conversion FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;\E/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE DOMAIN dump_test.us_postal_code' => {
create_order => 29,
create_sql => 'CREATE DOMAIN dump_test.us_postal_code AS TEXT
COLLATE "C"
DEFAULT \'10014\'
CHECK(VALUE ~ \'^\d{5}$\' OR
VALUE ~ \'^\d{5}-\d{4}$\');
COMMENT ON CONSTRAINT us_postal_code_check
ON DOMAIN dump_test.us_postal_code IS \'check it\';',
regexp => qr/^
\QCREATE DOMAIN dump_test.us_postal_code AS text COLLATE pg_catalog."C" DEFAULT '10014'::text\E\n\s+
\QCONSTRAINT us_postal_code_check CHECK \E
\Q(((VALUE ~ '^\d{5}\E
\$\Q'::text) OR (VALUE ~ '^\d{5}-\d{4}\E\$
\Q'::text)));\E(.|\n)*
\QCOMMENT ON CONSTRAINT us_postal_code_check ON DOMAIN dump_test.us_postal_code IS 'check it';\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE FUNCTION dump_test.pltestlang_call_handler' => {
create_order => 17,
create_sql => 'CREATE FUNCTION dump_test.pltestlang_call_handler()
RETURNS LANGUAGE_HANDLER AS \'$libdir/plpgsql\',
\'plpgsql_call_handler\' LANGUAGE C;',
regexp => qr/^
\QCREATE FUNCTION dump_test.pltestlang_call_handler() \E
\QRETURNS language_handler\E
\n\s+\QLANGUAGE c\E
\n\s+AS\ \'\$
\Qlibdir\/plpgsql', 'plpgsql_call_handler';\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE FUNCTION dump_test.trigger_func' => {
create_order => 30,
create_sql => 'CREATE FUNCTION dump_test.trigger_func()
RETURNS trigger LANGUAGE plpgsql
AS $$ BEGIN RETURN NULL; END;$$;',
regexp => qr/^
\QCREATE FUNCTION dump_test.trigger_func() RETURNS trigger\E
\n\s+\QLANGUAGE plpgsql\E
\n\s+AS\ \$\$
\Q BEGIN RETURN NULL; END;\E
\$\$;/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE FUNCTION dump_test.event_trigger_func' => {
create_order => 32,
create_sql => 'CREATE FUNCTION dump_test.event_trigger_func()
RETURNS event_trigger LANGUAGE plpgsql
AS $$ BEGIN RETURN; END;$$;',
regexp => qr/^
\QCREATE FUNCTION dump_test.event_trigger_func() RETURNS event_trigger\E
\n\s+\QLANGUAGE plpgsql\E
\n\s+AS\ \$\$
\Q BEGIN RETURN; END;\E
\$\$;/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE OPERATOR FAMILY dump_test.op_family' => {
create_order => 73,
create_sql =>
'CREATE OPERATOR FAMILY dump_test.op_family USING btree;',
regexp => qr/^
\QCREATE OPERATOR FAMILY dump_test.op_family USING btree;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE OPERATOR CLASS dump_test.op_class' => {
create_order => 74,
create_sql => 'CREATE OPERATOR CLASS dump_test.op_class
FOR TYPE bigint USING btree FAMILY dump_test.op_family
AS STORAGE bigint,
OPERATOR 1 <(bigint,bigint),
OPERATOR 2 <=(bigint,bigint),
OPERATOR 3 =(bigint,bigint),
OPERATOR 4 >=(bigint,bigint),
OPERATOR 5 >(bigint,bigint),
FUNCTION 1 btint8cmp(bigint,bigint),
FUNCTION 2 btint8sortsupport(internal),
FUNCTION 4 btequalimage(oid);',
# note: it's correct that btint8sortsupport and btequalimage
# are NOT included here (they're optional support functions):
regexp => qr/^
\QCREATE OPERATOR CLASS dump_test.op_class\E\n\s+
\QFOR TYPE bigint USING btree FAMILY dump_test.op_family AS\E\n\s+
\QOPERATOR 1 <(bigint,bigint) ,\E\n\s+
\QOPERATOR 2 <=(bigint,bigint) ,\E\n\s+
\QOPERATOR 3 =(bigint,bigint) ,\E\n\s+
\QOPERATOR 4 >=(bigint,bigint) ,\E\n\s+
\QOPERATOR 5 >(bigint,bigint) ,\E\n\s+
\QFUNCTION 1 (bigint, bigint) btint8cmp(bigint,bigint);\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
# verify that a custom operator/opclass/range type is dumped in right order
'CREATE OPERATOR CLASS dump_test.op_class_custom' => {
create_order => 74,
create_sql => 'CREATE OPERATOR dump_test.~~ (
PROCEDURE = int4eq,
LEFTARG = int,
RIGHTARG = int);
CREATE OPERATOR CLASS dump_test.op_class_custom
FOR TYPE int USING btree AS
OPERATOR 3 dump_test.~~;
CREATE TYPE dump_test.range_type_custom AS RANGE (
subtype = int,
subtype_opclass = dump_test.op_class_custom);',
regexp => qr/^
\QCREATE OPERATOR dump_test.~~ (\E\n.+
\QCREATE OPERATOR FAMILY dump_test.op_class_custom USING btree;\E\n.+
\QCREATE OPERATOR CLASS dump_test.op_class_custom\E\n\s+
\QFOR TYPE integer USING btree FAMILY dump_test.op_class_custom AS\E\n\s+
\QOPERATOR 3 dump_test.~~(integer,integer);\E\n.+
\QCREATE TYPE dump_test.range_type_custom AS RANGE (\E\n\s+
\Qsubtype = integer,\E\n\s+
\Qmultirange_type_name = dump_test.multirange_type_custom,\E\n\s+
\Qsubtype_opclass = dump_test.op_class_custom\E\n
\Q);\E
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE OPERATOR CLASS dump_test.op_class_empty' => {
create_order => 89,
create_sql => 'CREATE OPERATOR CLASS dump_test.op_class_empty
FOR TYPE bigint USING btree FAMILY dump_test.op_family
AS STORAGE bigint;',
regexp => qr/^
\QCREATE OPERATOR CLASS dump_test.op_class_empty\E\n\s+
\QFOR TYPE bigint USING btree FAMILY dump_test.op_family AS\E\n\s+
\QSTORAGE bigint;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE EVENT TRIGGER test_event_trigger' => {
create_order => 33,
create_sql => 'CREATE EVENT TRIGGER test_event_trigger
ON ddl_command_start
EXECUTE FUNCTION dump_test.event_trigger_func();',
regexp => qr/^
\QCREATE EVENT TRIGGER test_event_trigger \E
\QON ddl_command_start\E
\n\s+\QEXECUTE FUNCTION dump_test.event_trigger_func();\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
'CREATE TRIGGER test_trigger' => {
create_order => 31,
create_sql => 'CREATE TRIGGER test_trigger
BEFORE INSERT ON dump_test.test_table
FOR EACH ROW WHEN (NEW.col1 > 10)
EXECUTE FUNCTION dump_test.trigger_func();',
regexp => qr/^
\QCREATE TRIGGER test_trigger BEFORE INSERT ON dump_test.test_table \E
\QFOR EACH ROW WHEN ((new.col1 > 10)) \E
\QEXECUTE FUNCTION dump_test.trigger_func();\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_post_data => 1,
},
unlike => {
exclude_test_table => 1,
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TYPE dump_test.planets AS ENUM' => {
create_order => 37,
create_sql => 'CREATE TYPE dump_test.planets
AS ENUM ( \'venus\', \'earth\', \'mars\' );',
regexp => qr/^
\QCREATE TYPE dump_test.planets AS ENUM (\E
\n\s+'venus',
\n\s+'earth',
\n\s+'mars'
\n\);/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TYPE dump_test.planets AS ENUM pg_upgrade' => {
regexp => qr/^
\QCREATE TYPE dump_test.planets AS ENUM (\E
\n\);.*^
\QALTER TYPE dump_test.planets ADD VALUE 'venus';\E
\n.*^
\QALTER TYPE dump_test.planets ADD VALUE 'earth';\E
\n.*^
\QALTER TYPE dump_test.planets ADD VALUE 'mars';\E
\n/xms,
like => { binary_upgrade => 1, },
},
'CREATE TYPE dump_test.textrange AS RANGE' => {
create_order => 38,
create_sql => 'CREATE TYPE dump_test.textrange
AS RANGE (subtype=text, collation="C");',
regexp => qr/^
\QCREATE TYPE dump_test.textrange AS RANGE (\E
\n\s+\Qsubtype = text,\E
\n\s+\Qmultirange_type_name = dump_test.textmultirange,\E
\n\s+\Qcollation = pg_catalog."C"\E
\n\);/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TYPE dump_test.int42' => {
create_order => 39,
create_sql => 'CREATE TYPE dump_test.int42;',
regexp => qr/^\QCREATE TYPE dump_test.int42;\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1' => {
create_order => 80,
create_sql =>
'CREATE TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 (copy=english);',
regexp => qr/^
\QCREATE TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 (\E\n
\s+\QPARSER = pg_catalog."default" );\E/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'ALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1 ...' => {
regexp => qr/^
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR asciiword WITH english_stem;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR word WITH english_stem;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR numword WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR email WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR url WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR host WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR sfloat WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR version WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR hword_numpart WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR hword_part WITH english_stem;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR hword_asciipart WITH english_stem;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR numhword WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR asciihword WITH english_stem;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR hword WITH english_stem;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR url_path WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR file WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR "float" WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR "int" WITH simple;\E\n
\n
\QALTER TEXT SEARCH CONFIGURATION dump_test.alt_ts_conf1\E\n
\s+\QADD MAPPING FOR uint WITH simple;\E\n
\n
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1' => {
create_order => 81,
create_sql =>
'CREATE TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 (lexize=dsimple_lexize);',
regexp => qr/^
\QCREATE TEXT SEARCH TEMPLATE dump_test.alt_ts_temp1 (\E\n
\s+\QLEXIZE = dsimple_lexize );\E/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TEXT SEARCH PARSER dump_test.alt_ts_prs1' => {
create_order => 82,
create_sql => 'CREATE TEXT SEARCH PARSER dump_test.alt_ts_prs1
(start = prsd_start, gettoken = prsd_nexttoken, end = prsd_end, lextypes = prsd_lextype);',
regexp => qr/^
\QCREATE TEXT SEARCH PARSER dump_test.alt_ts_prs1 (\E\n
\s+\QSTART = prsd_start,\E\n
\s+\QGETTOKEN = prsd_nexttoken,\E\n
\s+\QEND = prsd_end,\E\n
\s+\QLEXTYPES = prsd_lextype );\E\n
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1' => {
create_order => 83,
create_sql =>
'CREATE TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 (template=simple);',
regexp => qr/^
\QCREATE TEXT SEARCH DICTIONARY dump_test.alt_ts_dict1 (\E\n
\s+\QTEMPLATE = pg_catalog.simple );\E\n
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE FUNCTION dump_test.int42_in' => {
create_order => 40,
create_sql => 'CREATE FUNCTION dump_test.int42_in(cstring)
RETURNS dump_test.int42 AS \'int4in\'
LANGUAGE internal STRICT IMMUTABLE;',
regexp => qr/^
\QCREATE FUNCTION dump_test.int42_in(cstring) RETURNS dump_test.int42\E
\n\s+\QLANGUAGE internal IMMUTABLE STRICT\E
\n\s+AS\ \$\$int4in\$\$;
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE FUNCTION dump_test.int42_out' => {
create_order => 41,
create_sql => 'CREATE FUNCTION dump_test.int42_out(dump_test.int42)
RETURNS cstring AS \'int4out\'
LANGUAGE internal STRICT IMMUTABLE;',
regexp => qr/^
\QCREATE FUNCTION dump_test.int42_out(dump_test.int42) RETURNS cstring\E
\n\s+\QLANGUAGE internal IMMUTABLE STRICT\E
\n\s+AS\ \$\$int4out\$\$;
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE FUNCTION ... SUPPORT' => {
create_order => 41,
create_sql =>
'CREATE FUNCTION dump_test.func_with_support() RETURNS int LANGUAGE sql AS $$ SELECT 1 $$ SUPPORT varchar_support;',
regexp => qr/^
\QCREATE FUNCTION dump_test.func_with_support() RETURNS integer\E
\n\s+\QLANGUAGE sql SUPPORT varchar_support\E
\n\s+AS\ \$\$\Q SELECT 1 \E\$\$;
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'Check ordering of a function that depends on a primary key' => {
create_order => 41,
create_sql => '
CREATE TABLE dump_test.ordering_table (id int primary key, data int);
CREATE FUNCTION dump_test.ordering_func ()
RETURNS SETOF dump_test.ordering_table
LANGUAGE sql BEGIN ATOMIC
SELECT * FROM dump_test.ordering_table GROUP BY id; END;',
regexp => qr/^
\QALTER TABLE ONLY dump_test.ordering_table\E
\n\s+\QADD CONSTRAINT ordering_table_pkey PRIMARY KEY (id);\E
.*^
\QCREATE FUNCTION dump_test.ordering_func\E/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE PROCEDURE dump_test.ptest1' => {
create_order => 41,
create_sql => 'CREATE PROCEDURE dump_test.ptest1(a int)
LANGUAGE SQL AS $$ INSERT INTO dump_test.test_table (col1) VALUES (a) $$;',
regexp => qr/^
\QCREATE PROCEDURE dump_test.ptest1(IN a integer)\E
\n\s+\QLANGUAGE sql\E
\n\s+AS\ \$\$\Q INSERT INTO dump_test.test_table (col1) VALUES (a) \E\$\$;
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TYPE dump_test.int42 populated' => {
create_order => 42,
create_sql => 'CREATE TYPE dump_test.int42 (
internallength = 4,
input = dump_test.int42_in,
output = dump_test.int42_out,
alignment = int4,
default = 42,
passedbyvalue);',
regexp => qr/^
\QCREATE TYPE dump_test.int42 (\E
\n\s+\QINTERNALLENGTH = 4,\E
\n\s+\QINPUT = dump_test.int42_in,\E
\n\s+\QOUTPUT = dump_test.int42_out,\E
\n\s+\QDEFAULT = '42',\E
\n\s+\QALIGNMENT = int4,\E
\n\s+\QSTORAGE = plain,\E
\n\s+PASSEDBYVALUE\n\);
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TYPE dump_test.composite' => {
create_order => 43,
create_sql => 'CREATE TYPE dump_test.composite AS (
f1 int,
f2 dump_test.int42
);',
regexp => qr/^
\QCREATE TYPE dump_test.composite AS (\E
\n\s+\Qf1 integer,\E
\n\s+\Qf2 dump_test.int42\E
\n\);
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TYPE dump_test.undefined' => {
create_order => 39,
create_sql => 'CREATE TYPE dump_test.undefined;',
regexp => qr/^\QCREATE TYPE dump_test.undefined;\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE FOREIGN DATA WRAPPER dummy' => {
create_order => 35,
create_sql => 'CREATE FOREIGN DATA WRAPPER dummy;',
regexp => qr/CREATE FOREIGN DATA WRAPPER dummy;/m,
like => { %full_runs, section_pre_data => 1, },
},
'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy' => {
create_order => 36,
create_sql => 'CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;',
regexp => qr/CREATE SERVER s1 FOREIGN DATA WRAPPER dummy;/m,
like => { %full_runs, section_pre_data => 1, },
},
'CREATE FOREIGN TABLE dump_test.foreign_table SERVER s1' => {
create_order => 88,
create_sql =>
'CREATE FOREIGN TABLE dump_test.foreign_table (c1 int options (column_name \'col1\'))
SERVER s1 OPTIONS (schema_name \'x1\');',
regexp => qr/
\QCREATE FOREIGN TABLE dump_test.foreign_table (\E\n
\s+\Qc1 integer\E\n
\Q)\E\n
\QSERVER s1\E\n
\QOPTIONS (\E\n
\s+\Qschema_name 'x1'\E\n
\Q);\E\n
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE USER MAPPING FOR regress_dump_test_role SERVER s1' => {
create_order => 86,
create_sql =>
'CREATE USER MAPPING FOR regress_dump_test_role SERVER s1;',
regexp =>
qr/CREATE USER MAPPING FOR regress_dump_test_role SERVER s1;/m,
like => { %full_runs, section_pre_data => 1, },
},
'CREATE TRANSFORM FOR int' => {
create_order => 34,
create_sql =>
'CREATE TRANSFORM FOR int LANGUAGE SQL (FROM SQL WITH FUNCTION prsd_lextype(internal), TO SQL WITH FUNCTION int4recv(internal));',
regexp =>
qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog\.prsd_lextype\(internal\), TO SQL WITH FUNCTION pg_catalog\.int4recv\(internal\)\);/m,
like => { %full_runs, section_pre_data => 1, },
},
'CREATE LANGUAGE pltestlang' => {
create_order => 18,
create_sql => 'CREATE LANGUAGE pltestlang
HANDLER dump_test.pltestlang_call_handler;',
regexp => qr/^
\QCREATE PROCEDURAL LANGUAGE pltestlang \E
\QHANDLER dump_test.pltestlang_call_handler;\E
/xm,
like => { %full_runs, section_pre_data => 1, },
unlike => { exclude_dump_test_schema => 1, },
},
'CREATE MATERIALIZED VIEW matview' => {
create_order => 20,
create_sql => 'CREATE MATERIALIZED VIEW dump_test.matview (col1) AS
SELECT col1 FROM dump_test.test_table;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview AS\E
\n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE MATERIALIZED VIEW matview_second' => {
create_order => 21,
create_sql => 'CREATE MATERIALIZED VIEW
dump_test.matview_second (col1) AS
SELECT * FROM dump_test.matview;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_second AS\E
\n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview\E
\n\s+\QWITH NO DATA;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE MATERIALIZED VIEW matview_third' => {
create_order => 58,
create_sql => 'CREATE MATERIALIZED VIEW
dump_test.matview_third (col1) AS
SELECT * FROM dump_test.matview_second WITH NO DATA;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_third AS\E
\n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview_second\E
\n\s+\QWITH NO DATA;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE MATERIALIZED VIEW matview_fourth' => {
create_order => 59,
create_sql => 'CREATE MATERIALIZED VIEW
dump_test.matview_fourth (col1) AS
SELECT * FROM dump_test.matview_third WITH NO DATA;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_fourth AS\E
\n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.matview_third\E
\n\s+\QWITH NO DATA;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE MATERIALIZED VIEW matview_compression' => {
create_order => 20,
create_sql => 'CREATE MATERIALIZED VIEW
dump_test.matview_compression (col2) AS
SELECT col2 FROM dump_test.test_table;
ALTER MATERIALIZED VIEW dump_test.matview_compression
ALTER COLUMN col2 SET COMPRESSION lz4;',
regexp => qr/^
\QCREATE MATERIALIZED VIEW dump_test.matview_compression AS\E
\n\s+\QSELECT col2\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH NO DATA;\E
.*
\QALTER TABLE ONLY dump_test.matview_compression ALTER COLUMN col2 SET COMPRESSION lz4;\E\n
/xms,
lz4 => 1,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_toast_compression => 1,
only_dump_measurement => 1,
},
},
'Check ordering of a matview that depends on a primary key' => {
create_order => 42,
create_sql => '
CREATE MATERIALIZED VIEW dump_test.ordering_view AS
SELECT * FROM dump_test.ordering_table GROUP BY id;',
regexp => qr/^
\QALTER TABLE ONLY dump_test.ordering_table\E
\n\s+\QADD CONSTRAINT ordering_table_pkey PRIMARY KEY (id);\E
.*^
\QCREATE MATERIALIZED VIEW dump_test.ordering_view AS\E
\n\s+\QSELECT id,\E/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE POLICY p1 ON test_table' => {
create_order => 22,
create_sql => 'CREATE POLICY p1 ON dump_test.test_table
USING (true)
WITH CHECK (true);',
regexp => qr/^
\QCREATE POLICY p1 ON dump_test.test_table \E
\QUSING (true) WITH CHECK (true);\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
no_policies => 1,
only_dump_measurement => 1,
},
},
'CREATE POLICY p2 ON test_table FOR SELECT' => {
create_order => 24,
create_sql => 'CREATE POLICY p2 ON dump_test.test_table
FOR SELECT TO regress_dump_test_role USING (true);',
regexp => qr/^
\QCREATE POLICY p2 ON dump_test.test_table FOR SELECT TO regress_dump_test_role \E
\QUSING (true);\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
no_policies => 1,
only_dump_measurement => 1,
},
},
'CREATE POLICY p3 ON test_table FOR INSERT' => {
create_order => 25,
create_sql => 'CREATE POLICY p3 ON dump_test.test_table
FOR INSERT TO regress_dump_test_role WITH CHECK (true);',
regexp => qr/^
\QCREATE POLICY p3 ON dump_test.test_table FOR INSERT \E
\QTO regress_dump_test_role WITH CHECK (true);\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
no_policies => 1,
only_dump_measurement => 1,
},
},
'CREATE POLICY p4 ON test_table FOR UPDATE' => {
create_order => 26,
create_sql => 'CREATE POLICY p4 ON dump_test.test_table FOR UPDATE
TO regress_dump_test_role USING (true) WITH CHECK (true);',
regexp => qr/^
\QCREATE POLICY p4 ON dump_test.test_table FOR UPDATE TO regress_dump_test_role \E
\QUSING (true) WITH CHECK (true);\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
no_policies => 1,
only_dump_measurement => 1,
},
},
'CREATE POLICY p5 ON test_table FOR DELETE' => {
create_order => 27,
create_sql => 'CREATE POLICY p5 ON dump_test.test_table
FOR DELETE TO regress_dump_test_role USING (true);',
regexp => qr/^
\QCREATE POLICY p5 ON dump_test.test_table FOR DELETE \E
\QTO regress_dump_test_role USING (true);\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
no_policies => 1,
only_dump_measurement => 1,
},
},
'CREATE POLICY p6 ON test_table AS RESTRICTIVE' => {
create_order => 27,
create_sql => 'CREATE POLICY p6 ON dump_test.test_table AS RESTRICTIVE
USING (false);',
regexp => qr/^
\QCREATE POLICY p6 ON dump_test.test_table AS RESTRICTIVE \E
\QUSING (false);\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
no_policies => 1,
only_dump_measurement => 1,
},
},
'CREATE PUBLICATION pub1' => {
create_order => 50,
create_sql => 'CREATE PUBLICATION pub1;',
regexp => qr/^
\QCREATE PUBLICATION pub1 WITH (publish = 'insert, update, delete, truncate');\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
'CREATE PUBLICATION pub2' => {
create_order => 50,
create_sql => 'CREATE PUBLICATION pub2
FOR ALL TABLES
WITH (publish = \'\');',
regexp => qr/^
\QCREATE PUBLICATION pub2 FOR ALL TABLES WITH (publish = '');\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
'CREATE PUBLICATION pub3' => {
create_order => 50,
create_sql => 'CREATE PUBLICATION pub3;',
regexp => qr/^
\QCREATE PUBLICATION pub3 WITH (publish = 'insert, update, delete, truncate');\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
'CREATE PUBLICATION pub4' => {
create_order => 50,
create_sql => 'CREATE PUBLICATION pub4;',
regexp => qr/^
\QCREATE PUBLICATION pub4 WITH (publish = 'insert, update, delete, truncate');\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
'CREATE PUBLICATION pub5' => {
create_order => 50,
create_sql =>
'CREATE PUBLICATION pub5 WITH (publish_generated_columns = stored);',
regexp => qr/^
\QCREATE PUBLICATION pub5 WITH (publish = 'insert, update, delete, truncate', publish_generated_columns = stored);\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
'CREATE SUBSCRIPTION sub1' => {
create_order => 50,
create_sql => 'CREATE SUBSCRIPTION sub1
CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1
WITH (connect = false);',
regexp => qr/^
\QCREATE SUBSCRIPTION sub1 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub1', streaming = parallel);\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
'CREATE SUBSCRIPTION sub2' => {
create_order => 50,
create_sql => 'CREATE SUBSCRIPTION sub2
CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1
WITH (connect = false, origin = none, streaming = off);',
regexp => qr/^
\QCREATE SUBSCRIPTION sub2 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub2', streaming = off, origin = none);\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
'CREATE SUBSCRIPTION sub3' => {
create_order => 50,
create_sql => 'CREATE SUBSCRIPTION sub3
CONNECTION \'dbname=doesnotexist\' PUBLICATION pub1
WITH (connect = false, origin = any, streaming = on);',
regexp => qr/^
\QCREATE SUBSCRIPTION sub3 CONNECTION 'dbname=doesnotexist' PUBLICATION pub1 WITH (connect = false, slot_name = 'sub3', streaming = on);\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
# Regardless of whether the table or schema is excluded, publications must
# still be dumped, as excluded objects do not apply to publications. We
# perform table and schema exclusion via full_runs.
'ALTER PUBLICATION pub1 ADD TABLE test_table' => {
create_order => 51,
create_sql =>
'ALTER PUBLICATION pub1 ADD TABLE dump_test.test_table;',
regexp => qr/^
\QALTER PUBLICATION pub1 ADD TABLE ONLY dump_test.test_table;\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
# Regardless of whether the table or schema is excluded, publications must
# still be dumped, as excluded objects do not apply to publications. We
# perform table and schema exclusion via full_runs.
'ALTER PUBLICATION pub1 ADD TABLE test_second_table' => {
create_order => 52,
create_sql =>
'ALTER PUBLICATION pub1 ADD TABLE dump_test.test_second_table;',
regexp => qr/^
\QALTER PUBLICATION pub1 ADD TABLE ONLY dump_test.test_second_table;\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
# Regardless of whether the table or schema is excluded, publications must
# still be dumped, as excluded objects do not apply to publications. We
# perform table and schema exclusion via full_runs.
'ALTER PUBLICATION pub1 ADD TABLE test_sixth_table (col3, col2)' => {
create_order => 52,
create_sql =>
'ALTER PUBLICATION pub1 ADD TABLE dump_test.test_sixth_table (col3, col2);',
regexp => qr/^
\QALTER PUBLICATION pub1 ADD TABLE ONLY dump_test.test_sixth_table (col2, col3);\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
# Regardless of whether the table or schema is excluded, publications must
# still be dumped, as excluded objects do not apply to publications. We
# perform table and schema exclusion via full_runs.
'ALTER PUBLICATION pub1 ADD TABLE test_seventh_table (col3, col2) WHERE (col1 = 1)'
=> {
create_order => 52,
create_sql =>
'ALTER PUBLICATION pub1 ADD TABLE dump_test.test_seventh_table (col3, col2) WHERE (col1 = 1);',
regexp => qr/^
\QALTER PUBLICATION pub1 ADD TABLE ONLY dump_test.test_seventh_table (col2, col3) WHERE ((col1 = 1));\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
# Regardless of whether the table or schema is excluded, publications must
# still be dumped, as excluded objects do not apply to publications. We
# perform table and schema exclusion via full_runs.
'ALTER PUBLICATION pub3 ADD TABLES IN SCHEMA dump_test' => {
create_order => 51,
create_sql =>
'ALTER PUBLICATION pub3 ADD TABLES IN SCHEMA dump_test;',
regexp => qr/^
\QALTER PUBLICATION pub3 ADD TABLES IN SCHEMA dump_test;\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
# Regardless of whether the table or schema is excluded, publications must
# still be dumped, as excluded objects do not apply to publications. We
# perform table and schema exclusion via full_runs.
'ALTER PUBLICATION pub3 ADD TABLES IN SCHEMA public' => {
create_order => 52,
create_sql => 'ALTER PUBLICATION pub3 ADD TABLES IN SCHEMA public;',
regexp => qr/^
\QALTER PUBLICATION pub3 ADD TABLES IN SCHEMA public;\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
# Regardless of whether the table or schema is excluded, publications must
# still be dumped, as excluded objects do not apply to publications. We
# perform table and schema exclusion via full_runs.
'ALTER PUBLICATION pub3 ADD TABLE test_table' => {
create_order => 51,
create_sql =>
'ALTER PUBLICATION pub3 ADD TABLE dump_test.test_table;',
regexp => qr/^
\QALTER PUBLICATION pub3 ADD TABLE ONLY dump_test.test_table;\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
# Regardless of whether the table or schema is excluded, publications must
# still be dumped, as excluded objects do not apply to publications. We
# perform table and schema exclusion via full_runs.
'ALTER PUBLICATION pub4 ADD TABLE test_table WHERE (col1 > 0);' => {
create_order => 51,
create_sql =>
'ALTER PUBLICATION pub4 ADD TABLE dump_test.test_table WHERE (col1 > 0);',
regexp => qr/^
\QALTER PUBLICATION pub4 ADD TABLE ONLY dump_test.test_table WHERE ((col1 > 0));\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
# Regardless of whether the table or schema is excluded, publications must
# still be dumped, as excluded objects do not apply to publications. We
# perform table and schema exclusion via full_runs.
'ALTER PUBLICATION pub4 ADD TABLE test_second_table WHERE (col2 = \'test\');'
=> {
create_order => 52,
create_sql =>
'ALTER PUBLICATION pub4 ADD TABLE dump_test.test_second_table WHERE (col2 = \'test\');',
regexp => qr/^
\QALTER PUBLICATION pub4 ADD TABLE ONLY dump_test.test_second_table WHERE ((col2 = 'test'::text));\E
/xm,
like => { %full_runs, section_post_data => 1, },
},
'CREATE SCHEMA public' => {
regexp => qr/^CREATE SCHEMA public;/m,
# this shouldn't ever get emitted anymore
like => {},
},
'CREATE SCHEMA dump_test' => {
create_order => 2,
create_sql => 'CREATE SCHEMA dump_test;',
regexp => qr/^CREATE SCHEMA dump_test;/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE SCHEMA dump_test_second_schema' => {
create_order => 9,
create_sql => 'CREATE SCHEMA dump_test_second_schema;',
regexp => qr/^CREATE SCHEMA dump_test_second_schema;/m,
like => {
%full_runs,
role => 1,
section_pre_data => 1,
},
},
'CREATE TABLE test_table' => {
create_order => 3,
create_sql => 'CREATE TABLE dump_test.test_table (
col1 serial primary key,
col2 text COMPRESSION pglz,
col3 text,
col4 text,
CHECK (col1 <= 1000)
) WITH (autovacuum_enabled = false, fillfactor=80);
COMMENT ON CONSTRAINT test_table_col1_check
ON dump_test.test_table IS \'bounds check\';',
regexp => qr/^
\QCREATE TABLE dump_test.test_table (\E\n
\s+\Qcol1 integer NOT NULL,\E\n
\s+\Qcol2 text,\E\n
\s+\Qcol3 text,\E\n
\s+\Qcol4 text,\E\n
\s+\QCONSTRAINT test_table_col1_check CHECK ((col1 <= 1000))\E\n
\Q)\E\n
\QWITH (autovacuum_enabled='false', fillfactor='80');\E\n(.|\n)*
\QCOMMENT ON CONSTRAINT test_table_col1_check ON dump_test.test_table IS 'bounds check';\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_compression_method' => {
create_order => 110,
create_sql => 'CREATE TABLE dump_test.test_compression_method (
col1 text
);',
regexp => qr/^
\QCREATE TABLE dump_test.test_compression_method (\E\n
\s+\Qcol1 text\E\n
\Q);\E
/xm,
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
# Insert enough data to surpass DEFAULT_IO_BUFFER_SIZE during
# (de)compression operations
'COPY test_compression_method' => {
create_order => 111,
create_sql => 'INSERT INTO dump_test.test_compression_method (col1) '
. 'SELECT string_agg(a::text, \'\') FROM generate_series(1,4096) a;',
regexp => qr/^
\QCOPY dump_test.test_compression_method (col1) FROM stdin;\E
\n(?:\d{15277}\n){1}\\\.\n
/xm,
like => {
%full_runs,
data_only => 1,
no_schema => 1,
section_data => 1,
only_dump_test_schema => 1,
test_schema_plus_large_objects => 1,
},
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
schema_only_with_statistics => 1,
},
},
'CREATE TABLE fk_reference_test_table' => {
create_order => 21,
create_sql => 'CREATE TABLE dump_test.fk_reference_test_table (
col1 int primary key references dump_test.test_table
);',
regexp => qr/^
\QCREATE TABLE dump_test.fk_reference_test_table (\E
\n\s+\Qcol1 integer NOT NULL\E
\n\);
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_second_table' => {
create_order => 6,
create_sql => 'CREATE TABLE dump_test.test_second_table (
col1 int,
col2 text
);',
regexp => qr/^
\QCREATE TABLE dump_test.test_second_table (\E
\n\s+\Qcol1 integer,\E
\n\s+\Qcol2 text\E
\n\);
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_compression' => {
create_order => 3,
create_sql => 'CREATE TABLE dump_test.test_compression (
col1 int,
col2 text COMPRESSION lz4
);',
regexp => qr/^
\QCREATE TABLE dump_test.test_compression (\E\n
\s+\Qcol1 integer,\E\n
\s+\Qcol2 text\E\n
\);\n
.*
\QALTER TABLE ONLY dump_test.test_compression ALTER COLUMN col2 SET COMPRESSION lz4;\E\n
/xms,
lz4 => 1,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_toast_compression => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE measurement PARTITIONED BY' => {
create_order => 90,
create_sql => 'CREATE TABLE dump_test.measurement (
city_id serial not null,
logdate date not null,
peaktemp int CHECK (peaktemp >= -460),
unitsales int
) PARTITION BY RANGE (logdate);',
regexp => qr/^
\Q-- Name: measurement;\E.*\n
\Q--\E\n\n
\QCREATE TABLE dump_test.measurement (\E\n
\s+\Qcity_id integer NOT NULL,\E\n
\s+\Qlogdate date NOT NULL,\E\n
\s+\Qpeaktemp integer,\E\n
\s+\Qunitsales integer,\E\n
\s+\QCONSTRAINT measurement_peaktemp_check CHECK ((peaktemp >= '-460'::integer))\E\n
\)\n
\QPARTITION BY RANGE (logdate);\E\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
section_pre_data => 1,
only_dump_measurement => 1,
},
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
exclude_measurement => 1,
},
},
'Partition measurement_y2006m2 creation' => {
create_order => 91,
create_sql =>
'CREATE TABLE dump_test_second_schema.measurement_y2006m2
PARTITION OF dump_test.measurement (
unitsales DEFAULT 0 CHECK (unitsales >= 0)
)
FOR VALUES FROM (\'2006-02-01\') TO (\'2006-03-01\');',
regexp => qr/^
\QCREATE TABLE dump_test_second_schema.measurement_y2006m2 (\E\n
\s+\Qcity_id integer DEFAULT nextval('dump_test.measurement_city_id_seq'::regclass) CONSTRAINT measurement_city_id_not_null NOT NULL,\E\n
\s+\Qlogdate date CONSTRAINT measurement_logdate_not_null NOT NULL,\E\n
\s+\Qpeaktemp integer,\E\n
\s+\Qunitsales integer DEFAULT 0,\E\n
\s+\QCONSTRAINT measurement_peaktemp_check CHECK ((peaktemp >= '-460'::integer)),\E\n
\s+\QCONSTRAINT measurement_y2006m2_unitsales_check CHECK ((unitsales >= 0))\E\n
\);\n
/xm,
like => {
%full_runs,
section_pre_data => 1,
role => 1,
binary_upgrade => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_measurement => 1,
},
},
'Creation of row-level trigger in partitioned table' => {
create_order => 92,
create_sql => 'CREATE TRIGGER test_trigger
AFTER INSERT ON dump_test.measurement
FOR EACH ROW EXECUTE PROCEDURE dump_test.trigger_func()',
regexp => qr/^
\QCREATE TRIGGER test_trigger AFTER INSERT ON dump_test.measurement \E
\QFOR EACH ROW \E
\QEXECUTE FUNCTION dump_test.trigger_func();\E
/xm,
like => {
%full_runs, %dump_test_schema_runs,
section_post_data => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_measurement => 1,
},
},
'COPY measurement' => {
create_order => 93,
create_sql =>
'INSERT INTO dump_test.measurement (city_id, logdate, peaktemp, unitsales) '
. "VALUES (1, '2006-02-12', 35, 1);",
regexp => qr/^
\QCOPY dump_test_second_schema.measurement_y2006m2 (city_id, logdate, peaktemp, unitsales) FROM stdin;\E
\n(?:1\t2006-02-12\t35\t1\n)\\\.\n
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
data_only => 1,
no_schema => 1,
only_dump_measurement => 1,
section_data => 1,
only_dump_test_schema => 1,
role_parallel => 1,
role => 1,
},
unlike => {
binary_upgrade => 1,
schema_only => 1,
schema_only_with_statistics => 1,
exclude_measurement => 1,
only_dump_test_schema => 1,
test_schema_plus_large_objects => 1,
exclude_measurement => 1,
exclude_measurement_data => 1,
},
},
'Disabled trigger on partition is altered' => {
create_order => 93,
create_sql =>
'CREATE TABLE dump_test_second_schema.measurement_y2006m3
PARTITION OF dump_test.measurement
FOR VALUES FROM (\'2006-03-01\') TO (\'2006-04-01\');
ALTER TABLE dump_test_second_schema.measurement_y2006m3 DISABLE TRIGGER test_trigger;
CREATE TABLE dump_test_second_schema.measurement_y2006m4
PARTITION OF dump_test.measurement
FOR VALUES FROM (\'2006-04-01\') TO (\'2006-05-01\');
ALTER TABLE dump_test_second_schema.measurement_y2006m4 ENABLE REPLICA TRIGGER test_trigger;
CREATE TABLE dump_test_second_schema.measurement_y2006m5
PARTITION OF dump_test.measurement
FOR VALUES FROM (\'2006-05-01\') TO (\'2006-06-01\');
ALTER TABLE dump_test_second_schema.measurement_y2006m5 ENABLE ALWAYS TRIGGER test_trigger;
',
regexp => qr/^
\QALTER TABLE dump_test_second_schema.measurement_y2006m3 DISABLE TRIGGER test_trigger;\E
/xm,
like => {
%full_runs,
section_post_data => 1,
role => 1,
binary_upgrade => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_measurement => 1,
},
},
'Replica trigger on partition is altered' => {
regexp => qr/^
\QALTER TABLE dump_test_second_schema.measurement_y2006m4 ENABLE REPLICA TRIGGER test_trigger;\E
/xm,
like => {
%full_runs,
section_post_data => 1,
role => 1,
binary_upgrade => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_measurement => 1,
},
},
'Always trigger on partition is altered' => {
regexp => qr/^
\QALTER TABLE dump_test_second_schema.measurement_y2006m5 ENABLE ALWAYS TRIGGER test_trigger;\E
/xm,
like => {
%full_runs,
section_post_data => 1,
role => 1,
binary_upgrade => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_measurement => 1,
},
},
# We should never see the creation of a trigger on a partition
'Disabled trigger on partition is not created' => {
regexp => qr/CREATE TRIGGER test_trigger.*ON dump_test_second_schema/,
like => {},
},
# Triggers on partitions should not be dropped individually
'Triggers on partitions are not dropped' => {
regexp => qr/DROP TRIGGER test_trigger.*ON dump_test_second_schema/,
like => {}
},
'CREATE TABLE test_third_table_generated_cols' => {
create_order => 6,
create_sql => 'CREATE TABLE dump_test.test_third_table (
f1 int, junk int,
g1 int generated always as (f1 * 2) stored,
"F3" int,
g2 int generated always as ("F3" * 3) stored
);
ALTER TABLE dump_test.test_third_table DROP COLUMN junk;',
regexp => qr/^
\QCREATE TABLE dump_test.test_third_table (\E\n
\s+\Qf1 integer,\E\n
\s+\Qg1 integer GENERATED ALWAYS AS ((f1 * 2)) STORED,\E\n
\s+\Q"F3" integer,\E\n
\s+\Qg2 integer GENERATED ALWAYS AS (("F3" * 3)) STORED\E\n
\);\n
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_fourth_table_zero_col' => {
create_order => 6,
create_sql => 'CREATE TABLE dump_test.test_fourth_table (
);',
regexp => qr/^
\QCREATE TABLE dump_test.test_fourth_table (\E
\n\);
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_fifth_table' => {
create_order => 53,
create_sql => 'CREATE TABLE dump_test.test_fifth_table (
col1 integer,
col2 boolean,
col3 boolean,
col4 bit(5),
col5 float8
);',
regexp => qr/^
\QCREATE TABLE dump_test.test_fifth_table (\E
\n\s+\Qcol1 integer,\E
\n\s+\Qcol2 boolean,\E
\n\s+\Qcol3 boolean,\E
\n\s+\Qcol4 bit(5),\E
\n\s+\Qcol5 double precision\E
\n\);
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_sixth_table' => {
create_order => 6,
create_sql => 'CREATE TABLE dump_test.test_sixth_table (
col1 int,
col2 text,
col3 bytea
);',
regexp => qr/^
\QCREATE TABLE dump_test.test_sixth_table (\E
\n\s+\Qcol1 integer,\E
\n\s+\Qcol2 text,\E
\n\s+\Qcol3 bytea\E
\n\);
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_seventh_table' => {
create_order => 6,
create_sql => 'CREATE TABLE dump_test.test_seventh_table (
col1 int,
col2 text,
col3 bytea
);',
regexp => qr/^
\QCREATE TABLE dump_test.test_seventh_table (\E
\n\s+\Qcol1 integer,\E
\n\s+\Qcol2 text,\E
\n\s+\Qcol3 bytea\E
\n\);
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_table_identity' => {
create_order => 3,
create_sql => 'CREATE TABLE dump_test.test_table_identity (
col1 int generated always as identity primary key,
col2 text
);',
regexp => qr/^
\QCREATE TABLE dump_test.test_table_identity (\E\n
\s+\Qcol1 integer NOT NULL,\E\n
\s+\Qcol2 text\E\n
\);
.*
\QALTER TABLE dump_test.test_table_identity ALTER COLUMN col1 ADD GENERATED ALWAYS AS IDENTITY (\E\n
\s+\QSEQUENCE NAME dump_test.test_table_identity_col1_seq\E\n
\s+\QSTART WITH 1\E\n
\s+\QINCREMENT BY 1\E\n
\s+\QNO MINVALUE\E\n
\s+\QNO MAXVALUE\E\n
\s+\QCACHE 1\E\n
\);
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_table_generated' => {
create_order => 3,
create_sql => 'CREATE TABLE dump_test.test_table_generated (
col1 int primary key,
col2 int generated always as (col1 * 2) stored,
col3 int generated always as (col1 * 3) virtual
);',
regexp => qr/^
\QCREATE TABLE dump_test.test_table_generated (\E\n
\s+\Qcol1 integer NOT NULL,\E\n
\s+\Qcol2 integer GENERATED ALWAYS AS ((col1 * 2)) STORED,\E\n
\s+\Qcol3 integer GENERATED ALWAYS AS ((col1 * 3))\E\n
\);
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_table_generated_child1 (without local columns)' => {
create_order => 4,
create_sql => 'CREATE TABLE dump_test.test_table_generated_child1 ()
INHERITS (dump_test.test_table_generated);',
regexp => qr/^
\QCREATE TABLE dump_test.test_table_generated_child1 (\E\n
\)\n
\QINHERITS (dump_test.test_table_generated);\E\n
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'ALTER TABLE test_table_generated_child1' => {
regexp =>
qr/^\QALTER TABLE ONLY dump_test.test_table_generated_child1 ALTER COLUMN col2 \E/m,
# should not get emitted
like => {},
},
'CREATE TABLE test_table_generated_child2 (with local columns)' => {
create_order => 4,
create_sql => 'CREATE TABLE dump_test.test_table_generated_child2 (
col1 int,
col2 int
) INHERITS (dump_test.test_table_generated);',
regexp => qr/^
\QCREATE TABLE dump_test.test_table_generated_child2 (\E\n
\s+\Qcol1 integer,\E\n
\s+\Qcol2 integer\E\n
\)\n
\QINHERITS (dump_test.test_table_generated);\E\n
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE table_with_stats' => {
create_order => 98,
create_sql => 'CREATE TABLE dump_test.table_index_stats (
col1 int,
col2 int,
col3 int);
CREATE INDEX index_with_stats
ON dump_test.table_index_stats
((col1 + 1), col1, (col2 + 1), (col3 + 1));
ALTER INDEX dump_test.index_with_stats
ALTER COLUMN 1 SET STATISTICS 400;
ALTER INDEX dump_test.index_with_stats
ALTER COLUMN 3 SET STATISTICS 500;',
regexp => qr/^
\QALTER INDEX dump_test.index_with_stats ALTER COLUMN 1 SET STATISTICS 400;\E\n
\QALTER INDEX dump_test.index_with_stats ALTER COLUMN 3 SET STATISTICS 500;\E\n
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_inheritance_parent' => {
create_order => 90,
create_sql => 'CREATE TABLE dump_test.test_inheritance_parent (
col1 int NOT NULL,
col2 int CHECK (col2 >= 42)
);',
regexp => qr/^
\QCREATE TABLE dump_test.test_inheritance_parent (\E\n
\s+\Qcol1 integer NOT NULL,\E\n
\s+\Qcol2 integer,\E\n
\s+\QCONSTRAINT test_inheritance_parent_col2_check CHECK ((col2 >= 42))\E\n
\Q);\E\n
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE TABLE test_inheritance_child' => {
create_order => 91,
create_sql => 'CREATE TABLE dump_test.test_inheritance_child (
col1 int NOT NULL,
CONSTRAINT test_inheritance_child CHECK (col2 >= 142857)
) INHERITS (dump_test.test_inheritance_parent);',
regexp => qr/^
\QCREATE TABLE dump_test.test_inheritance_child (\E\n
\s+\Qcol1 integer NOT NULL,\E\n
\s+\QCONSTRAINT test_inheritance_child CHECK ((col2 >= 142857))\E\n
\)\n
\QINHERITS (dump_test.test_inheritance_parent);\E\n
/xm,
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE STATISTICS extended_stats_no_options' => {
create_order => 97,
create_sql => 'CREATE STATISTICS dump_test.test_ext_stats_no_options
ON col1, col2 FROM dump_test.test_table',
regexp => qr/^
\QCREATE STATISTICS dump_test.test_ext_stats_no_options ON col1, col2 FROM dump_test.test_table;\E
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
only_dump_measurement => 1,
},
},
'CREATE STATISTICS extended_stats_options' => {
create_order => 97,
create_sql => 'CREATE STATISTICS dump_test.test_ext_stats_opts
(ndistinct) ON col1, col2 FROM dump_test.test_fifth_table',
regexp => qr/^
\QCREATE STATISTICS dump_test.test_ext_stats_opts (ndistinct) ON col1, col2 FROM dump_test.test_fifth_table;\E
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'ALTER STATISTICS extended_stats_options' => {
create_order => 98,
create_sql =>
'ALTER STATISTICS dump_test.test_ext_stats_opts SET STATISTICS 1000',
regexp => qr/^
\QALTER STATISTICS dump_test.test_ext_stats_opts SET STATISTICS 1000;\E
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE STATISTICS extended_stats_expression' => {
create_order => 99,
create_sql => 'CREATE STATISTICS dump_test.test_ext_stats_expr
ON (2 * col1) FROM dump_test.test_fifth_table',
regexp => qr/^
\QCREATE STATISTICS dump_test.test_ext_stats_expr ON (2 * col1) FROM dump_test.test_fifth_table;\E
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE SEQUENCE test_table_col1_seq' => {
regexp => qr/^
\QCREATE SEQUENCE dump_test.test_table_col1_seq\E
\n\s+\QAS integer\E
\n\s+\QSTART WITH 1\E
\n\s+\QINCREMENT BY 1\E
\n\s+\QNO MINVALUE\E
\n\s+\QNO MAXVALUE\E
\n\s+\QCACHE 1;\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'CREATE INDEX ON ONLY measurement' => {
create_order => 92,
create_sql =>
'CREATE INDEX ON dump_test.measurement (city_id, logdate);',
regexp => qr/^
\QCREATE INDEX measurement_city_id_logdate_idx ON ONLY dump_test.measurement USING\E
/xm,
like => {
%full_runs, %dump_test_schema_runs, section_post_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_measurement => 1,
},
},
'ALTER TABLE measurement PRIMARY KEY' => {
all_runs => 1,
catch_all => 'CREATE ... commands',
create_order => 93,
create_sql =>
'ALTER TABLE dump_test.measurement ADD PRIMARY KEY (city_id, logdate);',
regexp => qr/^
\QALTER TABLE ONLY dump_test.measurement\E \n^\s+
\QADD CONSTRAINT measurement_pkey PRIMARY KEY (city_id, logdate);\E
/xm,
like => {
%full_runs,
%dump_test_schema_runs,
section_post_data => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_measurement => 1,
},
},
'CREATE INDEX ... ON measurement_y2006_m2' => {
regexp => qr/^
\QCREATE INDEX measurement_y2006m2_city_id_logdate_idx ON dump_test_second_schema.measurement_y2006m2 \E
/xm,
like => {
%full_runs,
role => 1,
section_post_data => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_measurement => 1,
},
},
'ALTER INDEX ... ATTACH PARTITION' => {
regexp => qr/^
\QALTER INDEX dump_test.measurement_city_id_logdate_idx ATTACH PARTITION dump_test_second_schema.measurement_y2006m2_city_id_logdate_idx\E
/xm,
like => {
%full_runs,
role => 1,
section_post_data => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_measurement => 1,
},
},
'ALTER INDEX ... ATTACH PARTITION (primary key)' => {
all_runs => 1,
catch_all => 'CREATE ... commands',
regexp => qr/^
\QALTER INDEX dump_test.measurement_pkey ATTACH PARTITION dump_test_second_schema.measurement_y2006m2_pkey\E
/xm,
like => {
%full_runs,
role => 1,
section_post_data => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_measurement => 1,
},
},
'CREATE VIEW test_view' => {
create_order => 61,
create_sql => 'CREATE VIEW dump_test.test_view
WITH (check_option = \'local\', security_barrier = true) AS
SELECT col1 FROM dump_test.test_table;',
regexp => qr/^
\QCREATE VIEW dump_test.test_view WITH (security_barrier='true') AS\E
\n\s+\QSELECT col1\E
\n\s+\QFROM dump_test.test_table\E
\n\s+\QWITH LOCAL CHECK OPTION;\E/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
'ALTER VIEW test_view SET DEFAULT' => {
create_order => 62,
create_sql =>
'ALTER VIEW dump_test.test_view ALTER COLUMN col1 SET DEFAULT 1;',
regexp => qr/^
\QALTER TABLE ONLY dump_test.test_view ALTER COLUMN col1 SET DEFAULT 1;\E/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
only_dump_measurement => 1,
},
},
# FIXME
'DROP SCHEMA public (for testing without public schema)' => {
database => 'regress_pg_dump_test',
create_order => 100,
create_sql => 'DROP SCHEMA public;',
regexp => qr/^DROP SCHEMA public;/m,
like => {},
},
'DROP SCHEMA public' => {
regexp => qr/^DROP SCHEMA public;/m,
# this shouldn't ever get emitted anymore
like => {},
},
'DROP SCHEMA IF EXISTS public' => {
regexp => qr/^DROP SCHEMA IF EXISTS public;/m,
# this shouldn't ever get emitted anymore
like => {},
},
'DROP EXTENSION plpgsql' => {
regexp => qr/^DROP EXTENSION plpgsql;/m,
# this shouldn't ever get emitted anymore
like => {},
},
'DROP FUNCTION dump_test.pltestlang_call_handler()' => {
regexp => qr/^DROP FUNCTION dump_test\.pltestlang_call_handler\(\);/m,
like => { clean => 1, },
},
'DROP LANGUAGE pltestlang' => {
regexp => qr/^DROP PROCEDURAL LANGUAGE pltestlang;/m,
like => { clean => 1, },
},
'DROP SCHEMA dump_test' => {
regexp => qr/^DROP SCHEMA dump_test;/m,
like => { clean => 1, },
},
'DROP SCHEMA dump_test_second_schema' => {
regexp => qr/^DROP SCHEMA dump_test_second_schema;/m,
like => { clean => 1, },
},
'DROP TABLE test_table' => {
regexp => qr/^DROP TABLE dump_test\.test_table;/m,
like => { clean => 1, },
},
'DROP TABLE fk_reference_test_table' => {
regexp => qr/^DROP TABLE dump_test\.fk_reference_test_table;/m,
like => { clean => 1, },
},
'DROP TABLE test_second_table' => {
regexp => qr/^DROP TABLE dump_test\.test_second_table;/m,
like => { clean => 1, },
},
'DROP EXTENSION IF EXISTS plpgsql' => {
regexp => qr/^DROP EXTENSION IF EXISTS plpgsql;/m,
# this shouldn't ever get emitted anymore
like => {},
},
'DROP FUNCTION IF EXISTS dump_test.pltestlang_call_handler()' => {
regexp => qr/^
\QDROP FUNCTION IF EXISTS dump_test.pltestlang_call_handler();\E
/xm,
like => { clean_if_exists => 1, },
},
'DROP LANGUAGE IF EXISTS pltestlang' => {
regexp => qr/^DROP PROCEDURAL LANGUAGE IF EXISTS pltestlang;/m,
like => { clean_if_exists => 1, },
},
'DROP SCHEMA IF EXISTS dump_test' => {
regexp => qr/^DROP SCHEMA IF EXISTS dump_test;/m,
like => { clean_if_exists => 1, },
},
'DROP SCHEMA IF EXISTS dump_test_second_schema' => {
regexp => qr/^DROP SCHEMA IF EXISTS dump_test_second_schema;/m,
like => { clean_if_exists => 1, },
},
'DROP TABLE IF EXISTS test_table' => {
regexp => qr/^DROP TABLE IF EXISTS dump_test\.test_table;/m,
like => { clean_if_exists => 1, },
},
'DROP TABLE IF EXISTS test_second_table' => {
regexp => qr/^DROP TABLE IF EXISTS dump_test\.test_second_table;/m,
like => { clean_if_exists => 1, },
},
'DROP ROLE regress_dump_test_role' => {
regexp => qr/^
\QDROP ROLE regress_dump_test_role;\E
/xm,
like => { pg_dumpall_globals_clean => 1, },
},
'DROP ROLE pg_' => {
regexp => qr/^
\QDROP ROLE pg_\E.+;
/xm,
# this shouldn't ever get emitted anywhere
like => {},
},
'GRANT USAGE ON SCHEMA dump_test_second_schema' => {
create_order => 10,
create_sql => 'GRANT USAGE ON SCHEMA dump_test_second_schema
TO regress_dump_test_role;',
regexp => qr/^
\QGRANT USAGE ON SCHEMA dump_test_second_schema TO regress_dump_test_role;\E
/xm,
like => {
%full_runs,
role => 1,
section_pre_data => 1,
},
unlike => { no_privs => 1, },
},
'GRANT USAGE ON FOREIGN DATA WRAPPER dummy' => {
create_order => 85,
create_sql => 'GRANT USAGE ON FOREIGN DATA WRAPPER dummy
TO regress_dump_test_role;',
regexp => qr/^
\QGRANT ALL ON FOREIGN DATA WRAPPER dummy TO regress_dump_test_role;\E
/xm,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_privs => 1, },
},
'GRANT USAGE ON FOREIGN SERVER s1' => {
create_order => 85,
create_sql => 'GRANT USAGE ON FOREIGN SERVER s1
TO regress_dump_test_role;',
regexp => qr/^
\QGRANT ALL ON FOREIGN SERVER s1 TO regress_dump_test_role;\E
/xm,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_privs => 1, },
},
'GRANT USAGE ON DOMAIN dump_test.us_postal_code' => {
create_order => 72,
create_sql =>
'GRANT USAGE ON DOMAIN dump_test.us_postal_code TO regress_dump_test_role;',
regexp => qr/^
\QGRANT ALL ON TYPE dump_test.us_postal_code TO regress_dump_test_role;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_privs => 1,
only_dump_measurement => 1,
},
},
'GRANT USAGE ON TYPE dump_test.int42' => {
create_order => 87,
create_sql =>
'GRANT USAGE ON TYPE dump_test.int42 TO regress_dump_test_role;',
regexp => qr/^
\QGRANT ALL ON TYPE dump_test.int42 TO regress_dump_test_role;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_privs => 1,
only_dump_measurement => 1,
},
},
'GRANT USAGE ON TYPE dump_test.planets - ENUM' => {
create_order => 66,
create_sql =>
'GRANT USAGE ON TYPE dump_test.planets TO regress_dump_test_role;',
regexp => qr/^
\QGRANT ALL ON TYPE dump_test.planets TO regress_dump_test_role;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_privs => 1,
only_dump_measurement => 1,
},
},
'GRANT USAGE ON TYPE dump_test.textrange - RANGE' => {
create_order => 67,
create_sql =>
'GRANT USAGE ON TYPE dump_test.textrange TO regress_dump_test_role;',
regexp => qr/^
\QGRANT ALL ON TYPE dump_test.textrange TO regress_dump_test_role;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_privs => 1,
only_dump_measurement => 1,
},
},
'GRANT CREATE ON DATABASE dump_test' => {
create_order => 48,
create_sql =>
'GRANT CREATE ON DATABASE dump_test TO regress_dump_test_role;',
regexp => qr/^
\QGRANT CREATE ON DATABASE dump_test TO regress_dump_test_role;\E
/xm,
like => { pg_dumpall_dbprivs => 1, },
},
'GRANT SELECT ON TABLE test_table' => {
create_order => 5,
create_sql => 'GRANT SELECT ON TABLE dump_test.test_table
TO regress_dump_test_role;',
regexp =>
qr/^\QGRANT SELECT ON TABLE dump_test.test_table TO regress_dump_test_role;\E/m,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
exclude_test_table => 1,
no_privs => 1,
only_dump_measurement => 1,
},
},
'GRANT SELECT ON TABLE measurement' => {
create_order => 91,
create_sql => 'GRANT SELECT ON TABLE dump_test.measurement
TO regress_dump_test_role;
GRANT SELECT(city_id) ON TABLE dump_test.measurement
TO "regress_quoted \"" role";',
regexp =>
qr/^\QGRANT SELECT ON TABLE dump_test.measurement TO regress_dump_test_role;\E\n.*
^\QGRANT SELECT(city_id) ON TABLE dump_test.measurement TO "regress_quoted \"" role";\E/xms,
like => {
%full_runs,
%dump_test_schema_runs,
section_pre_data => 1,
only_dump_measurement => 1,
},
unlike => {
exclude_dump_test_schema => 1,
no_privs => 1,
exclude_measurement => 1,
},
},
'GRANT SELECT ON TABLE measurement_y2006m2' => {
create_order => 94,
create_sql => 'GRANT SELECT ON TABLE
dump_test_second_schema.measurement_y2006m2,
dump_test_second_schema.measurement_y2006m3,
dump_test_second_schema.measurement_y2006m4,
dump_test_second_schema.measurement_y2006m5
TO regress_dump_test_role;',
regexp =>
qr/^\QGRANT SELECT ON TABLE dump_test_second_schema.measurement_y2006m2 TO regress_dump_test_role;\E/m,
like => {
%full_runs,
role => 1,
section_pre_data => 1,
only_dump_measurement => 1,
},
unlike => {
no_privs => 1,
exclude_measurement => 1,
},
},
'GRANT ALL ON LARGE OBJECT ...' => {
create_order => 60,
create_sql => 'DO $$
DECLARE myoid oid;
BEGIN
SELECT loid FROM pg_largeobject INTO myoid;
EXECUTE \'GRANT ALL ON LARGE OBJECT \' || myoid || \' TO regress_dump_test_role;\';
END;
$$;',
regexp => qr/^
\QGRANT ALL ON LARGE OBJECT \E[0-9]+\Q TO regress_dump_test_role;\E
/xm,
like => {
%full_runs,
column_inserts => 1,
data_only => 1,
inserts => 1,
no_schema => 1,
section_data => 1,
test_schema_plus_large_objects => 1,
binary_upgrade => 1,
},
unlike => {
no_large_objects => 1,
no_privs => 1,
schema_only => 1,
schema_only_with_statistics => 1,
},
},
'GRANT INSERT(col1) ON TABLE test_second_table' => {
create_order => 8,
create_sql =>
'GRANT INSERT (col1) ON TABLE dump_test.test_second_table
TO regress_dump_test_role;',
regexp => qr/^
\QGRANT INSERT(col1) ON TABLE dump_test.test_second_table TO regress_dump_test_role;\E
/xm,
like =>
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
unlike => {
exclude_dump_test_schema => 1,
no_privs => 1,
only_dump_measurement => 1,
},
},
'GRANT EXECUTE ON FUNCTION pg_sleep() TO regress_dump_test_role' => {
create_order => 16,
create_sql => 'GRANT EXECUTE ON FUNCTION pg_sleep(float8)
TO regress_dump_test_role;',
regexp => qr/^
\QGRANT ALL ON FUNCTION pg_catalog.pg_sleep(double precision) TO regress_dump_test_role;\E
/xm,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_privs => 1, },
},
'GRANT SELECT (proname ...) ON TABLE pg_proc TO public' => {
create_order => 46,
create_sql => 'GRANT SELECT (
tableoid,
oid,
proname,
pronamespace,
proowner,
prolang,
procost,
prorows,
provariadic,
prosupport,
prokind,
prosecdef,
proleakproof,
proisstrict,
proretset,
provolatile,
proparallel,
pronargs,
pronargdefaults,
prorettype,
proargtypes,
proallargtypes,
proargmodes,
proargnames,
proargdefaults,
protrftypes,
prosrc,
probin,
proconfig,
proacl
) ON TABLE pg_proc TO public;',
regexp => qr/
\QGRANT SELECT(tableoid) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(oid) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proname) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(pronamespace) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proowner) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(prolang) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(procost) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(prorows) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(provariadic) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(prosupport) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(prokind) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(prosecdef) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proleakproof) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proisstrict) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proretset) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(provolatile) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proparallel) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(pronargs) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(pronargdefaults) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(prorettype) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proargtypes) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proallargtypes) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proargmodes) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proargnames) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proargdefaults) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(protrftypes) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(prosrc) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(probin) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proconfig) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
\QGRANT SELECT(proacl) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E/xms,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_privs => 1, },
},
'GRANT USAGE ON SCHEMA public TO public' => {
regexp => qr/^
\Q--\E\n\n
\QGRANT USAGE ON SCHEMA public TO PUBLIC;\E
/xm,
# this shouldn't ever get emitted anymore
like => {},
},
'REFRESH MATERIALIZED VIEW matview' => {
regexp => qr/^\QREFRESH MATERIALIZED VIEW dump_test.matview;\E/m,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
'REFRESH MATERIALIZED VIEW matview_second' => {
regexp => qr/^
\QREFRESH MATERIALIZED VIEW dump_test.matview;\E
\n.*
\QREFRESH MATERIALIZED VIEW dump_test.matview_second;\E
/xms,
like =>
{ %full_runs, %dump_test_schema_runs, section_post_data => 1, },
unlike => {
binary_upgrade => 1,
exclude_dump_test_schema => 1,
schema_only => 1,
schema_only_with_statistics => 1,
only_dump_measurement => 1,
},
},
# FIXME
'REFRESH MATERIALIZED VIEW matview_third' => {
regexp => qr/^
\QREFRESH MATERIALIZED VIEW dump_test.matview_third;\E
/xms,
like => {},
},
# FIXME
'REFRESH MATERIALIZED VIEW matview_fourth' => {
regexp => qr/^
\QREFRESH MATERIALIZED VIEW dump_test.matview_fourth;\E
/xms,
like => {},
},
'REVOKE CONNECT ON DATABASE dump_test FROM public' => {
create_order => 49,
create_sql => 'REVOKE CONNECT ON DATABASE dump_test FROM public;',
regexp => qr/^
\QREVOKE CONNECT,TEMPORARY ON DATABASE dump_test FROM PUBLIC;\E\n
\QGRANT TEMPORARY ON DATABASE dump_test TO PUBLIC;\E\n
\QGRANT CREATE ON DATABASE dump_test TO regress_dump_test_role;\E
/xm,
like => { pg_dumpall_dbprivs => 1, },
},
'REVOKE EXECUTE ON FUNCTION pg_sleep() FROM public' => {
create_order => 15,
create_sql => 'REVOKE EXECUTE ON FUNCTION pg_sleep(float8)
FROM public;',
regexp => qr/^
\QREVOKE ALL ON FUNCTION pg_catalog.pg_sleep(double precision) FROM PUBLIC;\E
/xm,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_privs => 1, },
},
# With the exception of the public schema, we don't dump ownership changes
# for objects originating at initdb. Hence, any GRANT or REVOKE affecting
# owner privileges for those objects should reference the bootstrap
# superuser, not the dump-time owner.
'REVOKE EXECUTE ON FUNCTION pg_stat_reset FROM regress_dump_test_role' =>
{
create_order => 15,
create_sql => '
ALTER FUNCTION pg_stat_reset OWNER TO regress_dump_test_role;
REVOKE EXECUTE ON FUNCTION pg_stat_reset
FROM regress_dump_test_role;',
regexp => qr/^[^-].*pg_stat_reset.* regress_dump_test_role/m,
# this shouldn't ever get emitted
like => {},
},
'REVOKE SELECT ON TABLE pg_proc FROM public' => {
create_order => 45,
create_sql => 'REVOKE SELECT ON TABLE pg_proc FROM public;',
regexp =>
qr/^\QREVOKE SELECT ON TABLE pg_catalog.pg_proc FROM PUBLIC;\E/m,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_privs => 1, },
},
'REVOKE ALL ON SCHEMA public' => {
create_order => 16,
create_sql =>
'REVOKE ALL ON SCHEMA public FROM "regress_quoted \"" role";',
regexp =>
qr/^REVOKE ALL ON SCHEMA public FROM "regress_quoted \\"" role";/m,
like => { %full_runs, section_pre_data => 1, },
unlike => { no_privs => 1, },
},
'REVOKE USAGE ON LANGUAGE plpgsql FROM public' => {
create_order => 16,
create_sql => 'REVOKE USAGE ON LANGUAGE plpgsql FROM public;',
regexp => qr/^REVOKE ALL ON LANGUAGE plpgsql FROM PUBLIC;/m,
like => {
%full_runs,
%dump_test_schema_runs,
only_dump_test_table => 1,
role => 1,
section_pre_data => 1,
only_dump_measurement => 1,
},
unlike => { no_privs => 1, },
},
'CREATE ACCESS METHOD regress_test_table_am' => {
create_order => 11,
create_sql =>
'CREATE ACCESS METHOD regress_table_am TYPE TABLE HANDLER heap_tableam_handler;',
regexp => qr/^
\QCREATE ACCESS METHOD regress_table_am TYPE TABLE HANDLER heap_tableam_handler;\E
\n/xm,
like => {
%full_runs, section_pre_data => 1,
},
},
# It's a bit tricky to ensure that the proper SET of default table
# AM occurs. To achieve that we create a table with the standard
# AM, test AM, standard AM. That guarantees that there needs to be
# a SET interspersed. Then use a regex that prevents interspersed
# SET ...; statements, followed by the expected CREATE TABLE. Not
# pretty, but seems hard to do better in this framework.
'CREATE TABLE regress_pg_dump_table_am' => {
create_order => 12,
create_sql => '
CREATE TABLE dump_test.regress_pg_dump_table_am_0() USING heap;
CREATE TABLE dump_test.regress_pg_dump_table_am_1 (col1 int) USING regress_table_am;
CREATE TABLE dump_test.regress_pg_dump_table_am_2() USING heap;',
regexp => qr/^
\QSET default_table_access_method = regress_table_am;\E
(\n(?!SET[^;]+;)[^\n]*)*
\n\QCREATE TABLE dump_test.regress_pg_dump_table_am_1 (\E
\n\s+\Qcol1 integer\E
\n\);/xm,
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
no_table_access_method => 1,
only_dump_measurement => 1,
},
},
'CREATE MATERIALIZED VIEW regress_pg_dump_matview_am' => {
create_order => 13,
create_sql => '
CREATE MATERIALIZED VIEW dump_test.regress_pg_dump_matview_am_0 USING heap AS SELECT 1;
CREATE MATERIALIZED VIEW dump_test.regress_pg_dump_matview_am_1
USING regress_table_am AS SELECT count(*) FROM pg_class;
CREATE MATERIALIZED VIEW dump_test.regress_pg_dump_matview_am_2 USING heap AS SELECT 1;',
regexp => qr/^
\QSET default_table_access_method = regress_table_am;\E
(\n(?!SET[^;]+;)[^\n]*)*
\QCREATE MATERIALIZED VIEW dump_test.regress_pg_dump_matview_am_1 AS\E
\n\s+\QSELECT count(*) AS count\E
\n\s+\QFROM pg_class\E
\n\s+\QWITH NO DATA;\E\n/xm,
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
no_table_access_method => 1,
only_dump_measurement => 1,
},
},
#
# TABLE and MATVIEW stats will end up in SECTION_DATA.
# INDEX stats (expression columns only) will end up in SECTION_POST_DATA.
#
'statistics_import' => {
create_sql => '
CREATE TABLE dump_test.has_stats
AS SELECT g.g AS x, g.g / 2 AS y FROM generate_series(1,100) AS g(g);
CREATE MATERIALIZED VIEW dump_test.has_stats_mv AS SELECT * FROM dump_test.has_stats;
CREATE INDEX dup_test_post_data_ix ON dump_test.has_stats(x, (x - 1));
ANALYZE dump_test.has_stats, dump_test.has_stats_mv;',
regexp => qr/^
\QSELECT * FROM pg_catalog.pg_restore_relation_stats(\E\s+
'version',\s'\d+'::integer,\s+
'schemaname',\s'dump_test',\s+
'relname',\s'dup_test_post_data_ix',\s+
'relpages',\s'\d+'::integer,\s+
'reltuples',\s'\d+'::real,\s+
'relallvisible',\s'\d+'::integer,\s+
'relallfrozen',\s'\d+'::integer\s+
\);\s+
\QSELECT * FROM pg_catalog.pg_restore_attribute_stats(\E\s+
'version',\s'\d+'::integer,\s+
'schemaname',\s'dump_test',\s+
'relname',\s'dup_test_post_data_ix',\s+
'attnum',\s'2'::smallint,\s+
'inherited',\s'f'::boolean,\s+
'null_frac',\s'0'::real,\s+
'avg_width',\s'4'::integer,\s+
'n_distinct',\s'-1'::real,\s+
'histogram_bounds',\s'\{[0-9,]+\}'::text,\s+
'correlation',\s'1'::real\s+
\);/xm,
like => {
%full_runs,
%dump_test_schema_runs,
no_data_no_schema => 1,
no_schema => 1,
section_post_data => 1,
statistics_only => 1,
schema_only_with_statistics => 1,
},
unlike => {
exclude_dump_test_schema => 1,
no_statistics => 1,
only_dump_measurement => 1,
schema_only => 1,
},
},
#
# While attribute stats (aka pg_statistic stats) only appear for tables
# that have been analyzed, all tables will have relation stats because
# those come from pg_class.
#
'relstats_on_unanalyzed_tables' => {
regexp => qr/pg_catalog.pg_restore_relation_stats/,
like => {
%full_runs,
%dump_test_schema_runs,
no_data_no_schema => 1,
no_schema => 1,
only_dump_test_table => 1,
role => 1,
role_parallel => 1,
section_data => 1,
section_post_data => 1,
statistics_only => 1,
schema_only_with_statistics => 1,
},
unlike => {
no_statistics => 1,
schema_only => 1,
},
},
# CREATE TABLE with partitioned table and various AMs. One
# partition uses the same default as the parent, and a second
# uses its own AM.
'CREATE TABLE regress_pg_dump_table_part' => {
create_order => 19,
create_sql => '
CREATE TABLE dump_test.regress_pg_dump_table_am_parent (id int) PARTITION BY LIST (id);
ALTER TABLE dump_test.regress_pg_dump_table_am_parent SET ACCESS METHOD regress_table_am;
CREATE TABLE dump_test.regress_pg_dump_table_am_child_1
PARTITION OF dump_test.regress_pg_dump_table_am_parent FOR VALUES IN (1);
CREATE TABLE dump_test.regress_pg_dump_table_am_child_2
PARTITION OF dump_test.regress_pg_dump_table_am_parent FOR VALUES IN (2) USING heap;',
regexp => qr/^
\n\QCREATE TABLE dump_test.regress_pg_dump_table_am_parent (\E
(\n(?!SET[^;]+;)[^\n]*)*
\QALTER TABLE dump_test.regress_pg_dump_table_am_parent SET ACCESS METHOD regress_table_am;\E
(.*\n)*
\QSET default_table_access_method = regress_table_am;\E
(\n(?!SET[^;]+;)[^\n]*)*
\n\QCREATE TABLE dump_test.regress_pg_dump_table_am_child_1 (\E
(.*\n)*
\QSET default_table_access_method = heap;\E
(\n(?!SET[^;]+;)[^\n]*)*
\n\QCREATE TABLE dump_test.regress_pg_dump_table_am_child_2 (\E
(.*\n)*/xm,
like => {
%full_runs, %dump_test_schema_runs, section_pre_data => 1,
},
unlike => {
exclude_dump_test_schema => 1,
no_table_access_method => 1,
only_dump_measurement => 1,
},
});
#########################################
# Create a PG instance to test actually dumping from
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
$node->start;
my $port = $node->port;
# We need to see if this system supports CREATE COLLATION or not
# If it doesn't then we will skip all the COLLATION-related tests.
my $collation_support = 0;
my $collation_check_stderr;
$node->psql(
'postgres',
"CREATE COLLATION testing FROM \"C\"; DROP COLLATION testing;",
on_error_stop => 0,
stderr => \$collation_check_stderr);
if ($collation_check_stderr !~ /ERROR: /)
{
$collation_support = 1;
}
# ICU doesn't work with some encodings
my $encoding = $node->safe_psql('postgres', 'show server_encoding');
$supports_icu = 0 if $encoding eq 'SQL_ASCII';
# Create additional databases for mutations of schema public
$node->psql('postgres', 'create database regress_pg_dump_test;');
$node->psql('postgres', 'create database regress_public_owner;');
#########################################
# Set up schemas, tables, etc, to be dumped.
# Build up the create statements
my %create_sql = ();
foreach my $test (
sort {
if ($tests{$a}->{create_order} and $tests{$b}->{create_order})
{
$tests{$a}->{create_order} <=> $tests{$b}->{create_order};
}
elsif ($tests{$a}->{create_order})
{
-1;
}
elsif ($tests{$b}->{create_order})
{
1;
}
else
{
0;
}
} keys %tests)
{
my $test_db = 'postgres';
if (defined($tests{$test}->{database}))
{
$test_db = $tests{$test}->{database};
}
if (defined($tests{$test}->{icu}))
{
$tests{$test}->{collation} = 1;
}
if ($tests{$test}->{create_sql})
{
# Skip any collation-related commands if there is no collation support
if (!$collation_support && defined($tests{$test}->{collation}))
{
next;
}
# Skip any icu-related collation commands if build was without icu
if (!$supports_icu && defined($tests{$test}->{icu}))
{
next;
}
# Skip tests specific to LZ4 if this build does not support
# this option.
if (!$supports_lz4 && defined($tests{$test}->{lz4}))
{
next;
}
# Normalize command ending: strip all line endings, add
# semicolon if missing, add two newlines.
my $create_sql = $tests{$test}->{create_sql};
chomp $create_sql;
$create_sql .= ';' unless substr($create_sql, -1) eq ';';
$create_sql{$test_db} .= $create_sql . "\n\n";
}
}
# Send the combined set of commands to psql
foreach my $db (sort keys %create_sql)
{
$node->safe_psql($db, $create_sql{$db});
}
#########################################
# Test connecting to a non-existent database
command_fails_like(
[ 'pg_dump', '--port' => $port, 'qqq' ],
qr/pg_dump: error: connection to server .* failed: FATAL: database "qqq" does not exist/,
'connecting to a non-existent database');
#########################################
# Test connecting to an invalid database
$node->command_fails_like(
[ 'pg_dump', '--dbname' => 'regression_invalid' ],
qr/pg_dump: error: connection to server .* failed: FATAL: cannot connect to invalid database "regression_invalid"/,
'connecting to an invalid database');
#########################################
# Test connecting with an unprivileged user
command_fails_like(
[ 'pg_dump', '--port' => $port, '--role' => 'regress_dump_test_role' ],
qr/\Qpg_dump: error: query failed: ERROR: permission denied for\E/,
'connecting with an unprivileged user');
#########################################
# Test dumping a non-existent schema, table, and patterns with --strict-names
command_fails_like(
[ 'pg_dump', '--port' => $port, '--schema' => 'nonexistent' ],
qr/\Qpg_dump: error: no matching schemas were found\E/,
'dumping a non-existent schema');
command_fails_like(
[ 'pg_dump', '--port' => $port, '--table' => 'nonexistent' ],
qr/\Qpg_dump: error: no matching tables were found\E/,
'dumping a non-existent table');
command_fails_like(
[
'pg_dump',
'--port' => $port,
'--strict-names',
'--schema' => 'nonexistent*'
],
qr/\Qpg_dump: error: no matching schemas were found for pattern\E/,
'no matching schemas');
command_fails_like(
[
'pg_dump',
'--port' => $port,
'--strict-names',
'--table' => 'nonexistent*'
],
qr/\Qpg_dump: error: no matching tables were found for pattern\E/,
'no matching tables');
#########################################
# Test invalid multipart database names
$node->command_fails_like(
[ 'pg_dumpall', '--exclude-database' => '.' ],
qr/pg_dumpall: error: improper qualified name \(too many dotted names\): \./,
'pg_dumpall: option --exclude-database rejects multipart pattern "."');
$node->command_fails_like(
[ 'pg_dumpall', '--exclude-database' => 'myhost.mydb' ],
qr/pg_dumpall: error: improper qualified name \(too many dotted names\): myhost\.mydb/,
'pg_dumpall: option --exclude-database rejects multipart database names');
##############################################################
# Test dumping pg_catalog (for research -- cannot be reloaded)
$node->command_ok(
[ 'pg_dump', '--port' => $port, '--schema' => 'pg_catalog' ],
'pg_dump: option -n pg_catalog');
#########################################
# Test valid database exclusion patterns
$node->command_ok(
[
'pg_dumpall',
'--port' => $port,
'--exclude-database' => '"myhost.mydb"'
],
'pg_dumpall: option --exclude-database handles database names with embedded dots'
);
#########################################
# Test invalid multipart schema names
$node->command_fails_like(
[ 'pg_dump', '--schema' => 'myhost.mydb.myschema' ],
qr/pg_dump: error: improper qualified name \(too many dotted names\): myhost\.mydb\.myschema/,
'pg_dump: option --schema rejects three-part schema names');
$node->command_fails_like(
[ 'pg_dump', '--schema' => 'otherdb.myschema' ],
qr/pg_dump: error: cross-database references are not implemented: otherdb\.myschema/,
'pg_dump: option --schema rejects cross-database multipart schema names');
$node->command_fails_like(
[ 'pg_dump', '--schema' => '.' ],
qr/pg_dump: error: cross-database references are not implemented: \./,
'pg_dump: option --schema rejects degenerate two-part schema name: "."');
$node->command_fails_like(
[ 'pg_dump', '--schema' => '"some.other.db".myschema' ],
qr/pg_dump: error: cross-database references are not implemented: "some\.other\.db"\.myschema/,
'pg_dump: option --schema rejects cross-database multipart schema names with embedded dots'
);
$node->command_fails_like(
[ 'pg_dump', '--schema' => '..' ],
qr/pg_dump: error: improper qualified name \(too many dotted names\): \.\./,
'pg_dump: option --schema rejects degenerate three-part schema name: ".."'
);
#########################################
# Test invalid multipart relation names
$node->command_fails_like(
[ 'pg_dump', '--table' => 'myhost.mydb.myschema.mytable' ],
qr/pg_dump: error: improper relation name \(too many dotted names\): myhost\.mydb\.myschema\.mytable/,
'pg_dump: option --table rejects four-part table names');
$node->command_fails_like(
[ 'pg_dump', '--table' => 'otherdb.pg_catalog.pg_class' ],
qr/pg_dump: error: cross-database references are not implemented: otherdb\.pg_catalog\.pg_class/,
'pg_dump: option --table rejects cross-database three part table names');
command_fails_like(
[
'pg_dump',
'--port' => $port,
'--table' => '"some.other.db".pg_catalog.pg_class'
],
qr/pg_dump: error: cross-database references are not implemented: "some\.other\.db"\.pg_catalog\.pg_class/,
'pg_dump: option --table rejects cross-database three part table names with embedded dots'
);
#########################################
# Run all runs
foreach my $run (sort keys %pgdump_runs)
{
my $test_key = $run;
my $run_db = 'postgres';
# Skip command-level tests for gzip/lz4/zstd if the tool is not supported
if ($pgdump_runs{$run}->{compile_option}
&& (($pgdump_runs{$run}->{compile_option} eq 'gzip'
&& !$supports_gzip)
|| ($pgdump_runs{$run}->{compile_option} eq 'lz4'
&& !$supports_lz4)
|| ($pgdump_runs{$run}->{compile_option} eq 'zstd'
&& !$supports_zstd)))
{
note
"$run: skipped due to no $pgdump_runs{$run}->{compile_option} support";
next;
}
$node->command_ok(\@{ $pgdump_runs{$run}->{dump_cmd} },
"$run: pg_dump runs");
if ($pgdump_runs{$run}->{compress_cmd})
{
my ($compress_cmd) = $pgdump_runs{$run}->{compress_cmd};
my $compress_program = $compress_cmd->{program};
# Skip the rest of the test if the compression program is
# not defined.
next if (!defined($compress_program) || $compress_program eq '');
# Arguments may require globbing.
my @full_compress_cmd = ($compress_program);
foreach my $arg (@{ $compress_cmd->{args} })
{
push @full_compress_cmd, glob($arg);
}
command_ok(\@full_compress_cmd, "$run: compression commands");
}
if ($pgdump_runs{$run}->{glob_patterns})
{
my $glob_patterns = $pgdump_runs{$run}->{glob_patterns};
foreach my $glob_pattern (@{$glob_patterns})
{
my @glob_output = glob($glob_pattern);
is(scalar(@glob_output) > 0,
1, "$run: glob check for $glob_pattern");
}
}
if ($pgdump_runs{$run}->{command_like})
{
my $cmd_like = $pgdump_runs{$run}->{command_like};
$node->command_like(
\@{ $cmd_like->{command} },
$cmd_like->{expected},
"$run: " . $cmd_like->{name});
}
if ($pgdump_runs{$run}->{restore_cmd})
{
$node->command_ok(\@{ $pgdump_runs{$run}->{restore_cmd} },
"$run: pg_restore runs");
}
if ($pgdump_runs{$run}->{test_key})
{
$test_key = $pgdump_runs{$run}->{test_key};
}
my $output_file = slurp_file("$tempdir/${run}.sql");
#########################################
# Run all tests where this run is included
# as either a 'like' or 'unlike' test.
foreach my $test (sort keys %tests)
{
my $test_db = 'postgres';
if (defined($pgdump_runs{$run}->{database}))
{
$run_db = $pgdump_runs{$run}->{database};
}
if (defined($tests{$test}->{database}))
{
$test_db = $tests{$test}->{database};
}
# Check for proper test definitions
#
# There should be a "like" list, even if it is empty. (This
# makes the test more self-documenting.)
if (!defined($tests{$test}->{like}))
{
die "missing \"like\" in test \"$test\"";
}
# Check for useless entries in "unlike" list. Runs that are
# not listed in "like" don't need to be excluded in "unlike".
if ($tests{$test}->{unlike}->{$test_key}
&& !defined($tests{$test}->{like}->{$test_key}))
{
die "useless \"unlike\" entry \"$test_key\" in test \"$test\"";
}
# Skip any collation-related commands if there is no collation support
if (!$collation_support && defined($tests{$test}->{collation}))
{
next;
}
# Skip any icu-related collation commands if build was without icu
if (!$supports_icu && defined($tests{$test}->{icu}))
{
next;
}
# Skip tests specific to LZ4 if this build does not support
# this option.
if (!$supports_lz4 && defined($tests{$test}->{lz4}))
{
next;
}
if ($run_db ne $test_db)
{
next;
}
# Run the test listed as a like, unless it is specifically noted
# as an unlike (generally due to an explicit exclusion or similar).
if ($tests{$test}->{like}->{$test_key}
&& !defined($tests{$test}->{unlike}->{$test_key}))
{
if (!ok($output_file =~ $tests{$test}->{regexp},
"$run: should dump $test"))
{
diag("Review $run results in $tempdir");
}
}
else
{
if (!ok($output_file !~ $tests{$test}->{regexp},
"$run: should not dump $test"))
{
diag("Review $run results in $tempdir");
}
}
}
}
#########################################
# Stop the database instance, which will be removed at the end of the tests.
$node->stop('fast');
done_testing();
|