418{
434 char *use_role =
NULL;
435 int numWorkers = 1;
452
454
468 {
"jobs", 1,
NULL,
'j'},
488
489
490
491
537
539 };
540
544
545
546
547
548
550
552
553 if (argc > 1)
554 {
555 if (
strcmp(argv[1],
"--help") == 0 ||
strcmp(argv[1],
"-?") == 0)
556 {
559 }
560 if (
strcmp(argv[1],
"--version") == 0 ||
strcmp(argv[1],
"-V") == 0)
561 {
564 }
565 }
566
568
569 while ((
c =
getopt_long(argc, argv,
"abBcCd:e:E:f:F:h:j:n:N:Op:RsS:t:T:U:vwWxXZ:",
571 {
573 {
574 case 'a':
576 break;
577
578 case 'b':
580 break;
581
582 case 'B':
584 break;
585
586 case 'c':
588 break;
589
590 case 'C':
592 break;
593
594 case 'd':
596 break;
597
598 case 'e':
601 break;
602
603 case 'E':
605 break;
606
607 case 'f':
609 break;
610
611 case 'F':
613 break;
614
615 case 'h':
617 break;
618
619 case 'j':
622 &numWorkers))
624 break;
625
626 case 'n':
629 break;
630
631 case 'N':
633 break;
634
635 case 'O':
637 break;
638
639 case 'p':
641 break;
642
643 case 'R':
644
645 break;
646
647 case 's':
649 break;
650
651 case 'S':
653 break;
654
655 case 't':
658 break;
659
660 case 'T':
662 break;
663
664 case 'U':
666 break;
667
668 case 'v':
671 break;
672
673 case 'w':
675 break;
676
677 case 'W':
679 break;
680
681 case 'x':
683 break;
684
685 case 'Z':
689 break;
690
691 case 0:
692
693 break;
694
695 case 2:
697 break;
698
699 case 3:
701 break;
702
703 case 4:
705 break;
706
707 case 5:
709 break;
710
711 case 6:
713 break;
714
715 case 7:
717 break;
718
719 case 8:
724 break;
725
726 case 9:
727
728
729
730
731
734 break;
735
736 case 10:
740 break;
741
742 case 11:
745 break;
746
747 case 12:
751 break;
752
753 case 13:
756 break;
757
758 case 14:
761 break;
762
763 case 15:
766 break;
767
768 case 16:
770 break;
771
772 case 17:
775 break;
776
777 case 18:
779 break;
780
781 case 19:
783 break;
784
785 case 20:
787 break;
788
789 case 21:
791 break;
792
793 case 22:
795 break;
796
797 case 25:
799 break;
800
801 default:
802
805 }
806 }
807
808
809
810
811
814
815
817 {
818 pg_log_error(
"too many command-line arguments (first is \"%s\")",
822 }
823
824
827
828
832
833
840
841
844
845
849
850
853
855 pg_fatal(
"option %s is not supported with parallel backup",
856 "--include-foreign-data");
857
858
861
863 pg_fatal(
"option %s requires option %s",
864 "--if-exists", "-c/--clean");
865
866
867
868
869
870
877
878
879
880
881
882
884 pg_fatal(
"option %s requires option %s, %s, or %s",
885 "--on-conflict-do-nothing",
886 "--inserts", "--rows-per-insert", "--column-inserts");
887
888
890
891
893 {
895
896
897
898
902 pg_fatal(
"could not generate restrict key");
905 }
907 pg_fatal(
"option %s can only be used with %s",
908 "--restrict-key", "--format=plain");
909
910
911
912
913
914
917 {
918#ifdef HAVE_LIBZ
920#else
922#endif
923 }
924
925
926
927
930 pg_fatal(
"unrecognized compression algorithm: \"%s\"",
932
934 &compression_spec);
937 pg_fatal(
"invalid compression specification: %s",
939
943
944
945
946
947
948
950 pg_log_warning(
"compression option \"%s\" is not currently supported by pg_dump",
951 "workers");
952
953
954
955
956
959
960
962 pg_fatal(
"parallel backup only supported by the directory format");
963
964
967
968
970
971
973
974
976
977
978
979
980
981
982 fout->minRemoteVersion = 100000;
984
985 fout->numWorkers = numWorkers;
986
987
988
989
990
993
994
995
996
997
1000
1001
1002
1003
1004
1005
1007
1009
1010
1012 {
1017 pg_fatal(
"no matching schemas were found");
1018 }
1021 false);
1022
1023
1024
1034 pg_fatal(
"no matching tables were found");
1035
1038 false, false);
1041 false, true);
1042
1045 false, false);
1048 false, true);
1049
1052
1053
1054
1055
1057 {
1062 pg_fatal(
"no matching extensions were found");
1063 }
1066 false);
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1080
1081
1082
1083
1085
1086
1087
1088
1089
1091
1093 {
1098 }
1099
1102
1103
1104
1105
1106
1107
1108
1110 {
1112
1115
1116
1117
1118
1119 shdepend->dataObj->filtercond =
"WHERE classid = 'pg_largeobject'::regclass "
1120 "AND dbid = (SELECT oid FROM pg_database "
1121 " WHERE datname = current_database())";
1122
1123
1124
1125
1126
1127
1128
1129
1130 if (
fout->remoteVersion < 160000)
1131 {
1133
1136 }
1137 }
1138
1139
1140
1141
1142
1143
1144
1145
1146
1149
1150
1151
1152
1154
1155
1156
1157
1164
1165
1168
1169
1171
1172
1174
1175
1177
1178
1179
1180
1182
1183
1184
1185
1186
1187
1188
1189
1191
1194
1195
1196
1197
1198
1199
1200
1201
1202
1206
1207
1210
1211
1214
1215
1216
1217
1220
1221
1255
1257
1259
1261
1262
1264
1265
1266
1267
1268
1269
1272
1273
1274
1275
1276
1277
1278
1279
1282
1284
1286}
1287
1288
1289static void
1291{
1292 printf(
_(
"%s exports a PostgreSQL database as an SQL script or to other formats.\n\n"),
progname);
1295
1296 printf(
_(
"\nGeneral options:\n"));
1297 printf(
_(
" -f, --file=FILENAME output file or directory name\n"));
1298 printf(
_(
" -F, --format=c|d|t|p output file format (custom, directory, tar,\n"
1299 " plain text (default))\n"));
1300 printf(
_(
" -j, --jobs=NUM use this many parallel jobs to dump\n"));
1301 printf(
_(
" -v, --verbose verbose mode\n"));
1302 printf(
_(
" -V, --version output version information, then exit\n"));
1303 printf(
_(
" -Z, --compress=METHOD[:DETAIL]\n"
1304 " compress as specified\n"));
1305 printf(
_(
" --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock\n"));
1306 printf(
_(
" --no-sync do not wait for changes to be written safely to disk\n"));
1307 printf(
_(
" --sync-method=METHOD set method for syncing files to disk\n"));
1308 printf(
_(
" -?, --help show this help, then exit\n"));
1309
1310 printf(
_(
"\nOptions controlling the output content:\n"));
1311 printf(
_(
" -a, --data-only dump only the data, not the schema or statistics\n"));
1312 printf(
_(
" -b, --large-objects include large objects in dump\n"));
1313 printf(
_(
" --blobs (same as --large-objects, deprecated)\n"));
1314 printf(
_(
" -B, --no-large-objects exclude large objects in dump\n"));
1315 printf(
_(
" --no-blobs (same as --no-large-objects, deprecated)\n"));
1316 printf(
_(
" -c, --clean clean (drop) database objects before recreating\n"));
1317 printf(
_(
" -C, --create include commands to create database in dump\n"));
1318 printf(
_(
" -e, --extension=PATTERN dump the specified extension(s) only\n"));
1319 printf(
_(
" -E, --encoding=ENCODING dump the data in encoding ENCODING\n"));
1320 printf(
_(
" -n, --schema=PATTERN dump the specified schema(s) only\n"));
1321 printf(
_(
" -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
1322 printf(
_(
" -O, --no-owner skip restoration of object ownership in\n"
1323 " plain-text format\n"));
1324 printf(
_(
" -s, --schema-only dump only the schema, no data or statistics\n"));
1325 printf(
_(
" -S, --superuser=NAME superuser user name to use in plain-text format\n"));
1326 printf(
_(
" -t, --table=PATTERN dump only the specified table(s)\n"));
1327 printf(
_(
" -T, --exclude-table=PATTERN do NOT dump the specified table(s)\n"));
1328 printf(
_(
" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
1329 printf(
_(
" --binary-upgrade for use by upgrade utilities only\n"));
1330 printf(
_(
" --column-inserts dump data as INSERT commands with column names\n"));
1331 printf(
_(
" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
1332 printf(
_(
" --disable-triggers disable triggers during data-only restore\n"));
1333 printf(
_(
" --enable-row-security enable row security (dump only content user has\n"
1334 " access to)\n"));
1335 printf(
_(
" --exclude-extension=PATTERN do NOT dump the specified extension(s)\n"));
1336 printf(
_(
" --exclude-table-and-children=PATTERN\n"
1337 " do NOT dump the specified table(s), including\n"
1338 " child and partition tables\n"));
1339 printf(
_(
" --exclude-table-data=PATTERN do NOT dump data for the specified table(s)\n"));
1340 printf(
_(
" --exclude-table-data-and-children=PATTERN\n"
1341 " do NOT dump data for the specified table(s),\n"
1342 " including child and partition tables\n"));
1343 printf(
_(
" --extra-float-digits=NUM override default setting for extra_float_digits\n"));
1344 printf(
_(
" --filter=FILENAME include or exclude objects and data from dump\n"
1345 " based on expressions in FILENAME\n"));
1346 printf(
_(
" --if-exists use IF EXISTS when dropping objects\n"));
1347 printf(
_(
" --include-foreign-data=PATTERN\n"
1348 " include data of foreign tables on foreign\n"
1349 " servers matching PATTERN\n"));
1350 printf(
_(
" --inserts dump data as INSERT commands, rather than COPY\n"));
1351 printf(
_(
" --load-via-partition-root load partitions via the root table\n"));
1352 printf(
_(
" --no-comments do not dump comment commands\n"));
1353 printf(
_(
" --no-data do not dump data\n"));
1354 printf(
_(
" --no-policies do not dump row security policies\n"));
1355 printf(
_(
" --no-publications do not dump publications\n"));
1356 printf(
_(
" --no-schema do not dump schema\n"));
1357 printf(
_(
" --no-security-labels do not dump security label assignments\n"));
1358 printf(
_(
" --no-statistics do not dump statistics\n"));
1359 printf(
_(
" --no-subscriptions do not dump subscriptions\n"));
1360 printf(
_(
" --no-table-access-method do not dump table access methods\n"));
1361 printf(
_(
" --no-tablespaces do not dump tablespace assignments\n"));
1362 printf(
_(
" --no-toast-compression do not dump TOAST compression methods\n"));
1363 printf(
_(
" --no-unlogged-table-data do not dump unlogged table data\n"));
1364 printf(
_(
" --on-conflict-do-nothing add ON CONFLICT DO NOTHING to INSERT commands\n"));
1365 printf(
_(
" --quote-all-identifiers quote all identifiers, even if not key words\n"));
1366 printf(
_(
" --restrict-key=RESTRICT_KEY use provided string as psql \\restrict key\n"));
1367 printf(
_(
" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
1368 printf(
_(
" --section=SECTION dump named section (pre-data, data, or post-data)\n"));
1369 printf(
_(
" --sequence-data include sequence data in dump\n"));
1370 printf(
_(
" --serializable-deferrable wait until the dump can run without anomalies\n"));
1371 printf(
_(
" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
1372 printf(
_(
" --statistics dump the statistics\n"));
1373 printf(
_(
" --statistics-only dump only the statistics, not schema or data\n"));
1374 printf(
_(
" --strict-names require table and/or schema include patterns to\n"
1375 " match at least one entity each\n"));
1376 printf(
_(
" --table-and-children=PATTERN dump only the specified table(s), including\n"
1377 " child and partition tables\n"));
1378 printf(
_(
" --use-set-session-authorization\n"
1379 " use SET SESSION AUTHORIZATION commands instead of\n"
1380 " ALTER OWNER commands to set ownership\n"));
1381
1382 printf(
_(
"\nConnection options:\n"));
1383 printf(
_(
" -d, --dbname=DBNAME database to dump\n"));
1384 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
1385 printf(
_(
" -p, --port=PORT database server port number\n"));
1386 printf(
_(
" -U, --username=NAME connect as specified database user\n"));
1387 printf(
_(
" -w, --no-password never prompt for password\n"));
1388 printf(
_(
" -W, --password force password prompt (should happen automatically)\n"));
1389 printf(
_(
" --role=ROLENAME do SET ROLE before dump\n"));
1390
1391 printf(
_(
"\nIf no database name is supplied, then the PGDATABASE environment\n"
1392 "variable value is used.\n\n"));
1395}
1396
1397static void
1400{
1403
1405
1406
1407
1408
1410 {
1412 pg_fatal(
"invalid client encoding \"%s\" specified",
1414 }
1415
1416
1417
1418
1419
1420
1422
1423
1424
1425
1426
1427
1428
1429
1431
1432
1433
1434
1437
1438
1439
1440
1441
1442
1445
1446
1447 if (use_role)
1448 {
1450
1454
1455
1458 }
1459
1460
1462
1463
1465
1466
1467
1468
1469
1470
1472 {
1474
1479 }
1480 else
1482
1483
1484
1485
1486
1488
1489
1490
1491
1497
1498
1499
1500
1503
1504
1505
1506
1509 else
1511
1512
1513
1514
1515
1516
1518
1519
1520
1521
1522
1524
1525
1526
1527
1529
1530
1531
1532
1533
1534
1535
1536
1537
1540 "SET TRANSACTION ISOLATION LEVEL "
1541 "SERIALIZABLE, READ ONLY, DEFERRABLE");
1542 else
1544 "SET TRANSACTION ISOLATION LEVEL "
1545 "REPEATABLE READ, READ ONLY");
1546
1547
1548
1549
1550
1551
1554
1556 {
1558
1563 }
1566}
1567
1568
1569static void
1571{
1572
1573
1574
1575
1576
1577
1582}
1583
1584static char *
1586{
1587 char *query = "SELECT pg_catalog.pg_export_snapshot()";
1590
1594
1596}
1597
1600{
1602
1604
1606 {
1607
1610 }
1627 else
1630}
1631
1632
1633
1634
1635
1636static void
1641{
1646
1648 return;
1649
1651
1652
1653
1654
1655
1656
1658 {
1661
1663 "SELECT oid FROM pg_catalog.pg_namespace n\n");
1669 pg_fatal(
"improper qualified name (too many dotted names): %s",
1674
1677 pg_fatal(
"no matching schemas were found for pattern \"%s\"", cell->
val);
1678
1680 {
1682 }
1683
1686 }
1687
1689}
1690
1691
1692
1693
1694
1695static void
1700{
1705
1707 return;
1708
1710
1711
1712
1713
1714
1716 {
1718
1720 "SELECT oid FROM pg_catalog.pg_extension e\n");
1725 pg_fatal(
"improper qualified name (too many dotted names): %s",
1727
1730 pg_fatal(
"no matching extensions were found for pattern \"%s\"", cell->
val);
1731
1733 {
1735 }
1736
1739 }
1740
1742}
1743
1744
1745
1746
1747
1748static void
1752{
1757
1759 return;
1760
1762
1763
1764
1765
1766
1767
1769 {
1771
1773 "SELECT oid FROM pg_catalog.pg_foreign_server s\n");
1778 pg_fatal(
"improper qualified name (too many dotted names): %s",
1780
1783 pg_fatal(
"no matching foreign servers were found for pattern \"%s\"", cell->
val);
1784
1787
1790 }
1791
1793}
1794
1795
1796
1797
1798
1799
1800static void
1804{
1809
1811 return;
1812
1814
1815
1816
1817
1818
1819
1821 {
1824
1825
1826
1827
1828
1829
1830
1831
1832
1834 {
1836 }
1837
1839 "SELECT c.oid"
1840 "\nFROM pg_catalog.pg_class c"
1841 "\n LEFT JOIN pg_catalog.pg_namespace n"
1842 "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace"
1843 "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY"
1844 "\n (array['%c', '%c', '%c', '%c', '%c', '%c', '%c'])\n",
1850 false,
"n.nspname",
"c.relname",
NULL,
1851 "pg_catalog.pg_table_is_visible(c.oid)", &
dbbuf,
1854 pg_fatal(
"improper relation name (too many dotted names): %s",
1859
1861 {
1863 "\nSELECT i.inhrelid"
1864 "\nFROM partition_tree p"
1865 "\n JOIN pg_catalog.pg_inherits i"
1866 "\n ON p.relid OPERATOR(pg_catalog.=) i.inhparent"
1867 "\n)"
1868 "\nSELECT relid FROM partition_tree");
1869 }
1870
1876 pg_fatal(
"no matching tables were found for pattern \"%s\"", cell->
val);
1877
1879 {
1881 }
1882
1885 }
1886
1888}
1889
1890
1891
1892
1893
1894
1895
1896static void
1898{
1899 const char *db;
1900
1903 pg_fatal(
"You are currently not connected to a database.");
1904
1906 pg_fatal(
"cross-database references are not implemented: %s",
1907 pattern);
1908}
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921static bool
1923{
1925
1927 return false;
1928
1930
1931
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951 if (
fout->dopt->binary_upgrade)
1953 else
1955
1956 return true;
1957}
1958
1959
1960
1961
1962
1963static void
1965{
1966
1967
1968
1969
1970
1972
1973
1974
1975
1976
1977
1983 nsinfo->dobj.catId.oid) ?
1986 {
1987
1988
1989
1990
1991
1993 }
1996 {
1997
1999 }
2001 {
2002
2003
2004
2005
2006
2007
2008
2009
2015
2016
2017
2018
2019
2020
2022 }
2023 else
2025
2026
2027
2028
2029 if (
nsinfo->dobj.dump_contains &&
2033
2034
2035
2036
2037
2038
2039
2040
2042}
2043
2044
2045
2046
2047
2048static void
2050{
2052 return;
2053
2054
2055
2056
2057
2060 tbinfo->dobj.catId.oid) ?
2062 else
2063 tbinfo->dobj.dump =
tbinfo->dobj.namespace->dobj.dump_contains;
2064
2065
2066
2067
2072}
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087static void
2089{
2090
2093 {
2095
2099 else
2101 return;
2102 }
2103
2104
2106 {
2108
2109
2110
2111
2112
2113
2114
2115 }
2116
2118 return;
2119
2120
2121 tyinfo->dobj.dump =
tyinfo->dobj.namespace->dobj.dump_contains;
2122}
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132static void
2134{
2135
2136
2137 if (
dinfo->dobj.namespace)
2138
2139 dinfo->dobj.dump =
dinfo->dobj.namespace->dobj.dump_contains;
2140 else
2143}
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154static void
2156{
2158 return;
2159
2160
2161
2162
2163
2166 else
2167 cast->dobj.dump =
fout->dopt->include_everything ?
2169}
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179static void
2181{
2183 return;
2184
2185
2186
2187
2188
2189
2190
2191
2192 if (!
fout->dopt->include_everything)
2194 else
2195 {
2198 else
2200 }
2201}
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211static void
2213{
2215 return;
2216
2217
2218
2219
2220
2223 else
2226}
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239static void
2241{
2242
2243
2244
2245
2246
2249 else
2250 {
2251
2257 else
2261
2262
2267 }
2268}
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278static void
2280{
2282 return;
2283
2284 dobj->
dump =
fout->dopt->include_everything ?
2286}
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296static void
2298{
2300 return;
2301
2302 sobj->dobj.dump =
sobj->dobj.namespace->dobj.dump_contains;
2306}
2307
2308
2309
2310
2311
2312
2313
2314static void
2316{
2318 return;
2319
2320
2321
2322
2323
2324 if (dobj->namespace)
2326 else
2327 dobj->
dump =
fout->dopt->include_everything ?
2329}
2330
2331
2332
2333
2334
2335
2336static int
2338{
2343
2344
2345
2346
2347
2351 int ret;
2354
2355 pg_log_info(
"dumping contents of table \"%s.%s\"",
2356 tbinfo->dobj.namespace->dobj.name, classname);
2357
2358
2359
2360
2361
2362
2363
2365
2366
2367
2368
2369
2370
2371
2373 (
fout->dopt->binary_upgrade &&
fout->remoteVersion < 120000 &&
2375 {
2376
2379
2381
2383 {
2386 }
2387 else
2389
2393 }
2394 else
2395 {
2399 }
2403
2404 for (;;)
2405 {
2407
2408 if (ret < 0)
2409 break;
2410
2412 {
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 }
2464
2465 if (ret == -2)
2466 {
2467
2468 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetCopyData() failed.", classname);
2472 }
2473
2474
2477 {
2478 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetResult() failed.", classname);
2482 }
2484
2485
2487 pg_log_warning(
"unexpected extra results during COPY of table \"%s\"",
2488 classname);
2489
2491
2492
2495
2496 return 1;
2497}
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507static int
2509{
2515 char *attgenerated;
2517 int nfields,
2521
2522
2525
2526
2527
2528
2529
2530
2531
2532
2535 nfields = 0;
2537 {
2539 continue;
2541 continue;
2542 if (nfields > 0)
2546 else
2548 attgenerated[nfields] =
tbinfo->attgenerated[
i];
2549 nfields++;
2550 }
2551
2552 if (nfields == 0)
2558
2560
2561 while (1)
2562 {
2565
2566
2569 pg_fatal(
"wrong number of fields retrieved from table \"%s\"",
2571
2572
2573
2574
2575
2576
2577
2578
2580 {
2582
2584
2585
2586
2587
2588
2589
2590 if (
tbinfo->ispartition &&
2594 else
2596
2599
2600
2601 if (nfields == 0)
2602 {
2604 }
2605 else
2606 {
2607
2609 {
2611 for (int field = 0; field < nfields; field++)
2612 {
2613 if (field > 0)
2617 }
2619 }
2620
2621 if (
tbinfo->needs_override)
2623
2625 }
2626 }
2627
2628 for (
int tuple = 0; tuple <
PQntuples(res); tuple++)
2629 {
2630
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643 if (nfields == 0)
2644 continue;
2645
2646
2651 else
2653
2654 for (int field = 0; field < nfields; field++)
2655 {
2656 if (field > 0)
2658 if (attgenerated[field])
2659 {
2661 continue;
2662 }
2664 {
2666 continue;
2667 }
2668
2669
2671 {
2679 {
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691 const char *s =
PQgetvalue(res, tuple, field);
2692
2695 else
2697 }
2698 break;
2699
2704 break;
2705
2709 else
2711 break;
2712
2713 default:
2714
2720 break;
2721 }
2722 }
2723
2724
2726
2727
2729 {
2732 else
2734
2736 }
2737 }
2738
2740 {
2742 break;
2743 }
2745 }
2746
2747
2749 {
2752 else
2754 }
2755
2757
2759
2764
2765
2768
2769 return 1;
2770}
2771
2772
2773
2774
2775
2778{
2780
2783
2786 {
2789 }
2790
2792}
2793
2794
2795
2796
2797
2798
2799
2800
2801static bool
2803{
2805
2808
2811 return true;
2813 {
2817 return true;
2818 }
2819
2820 return false;
2821}
2822
2823
2824
2825
2826
2827
2828
2829static void
2831{
2838 char *copyStmt;
2840
2841
2843
2844
2845
2846
2847
2848
2849
2850 if (
tbinfo->ispartition &&
2853 {
2856
2864 }
2865 else
2867
2869 {
2870
2872
2878 }
2879 else
2880 {
2881
2884 }
2885
2886
2887
2888
2889
2890
2892 {
2894
2897 .namespace =
tbinfo->dobj.namespace->dobj.name,
2898 .owner =
tbinfo->rolname,
2899 .description = "TABLE DATA",
2902 .copyStmt = copyStmt,
2903 .deps = &(
tbinfo->dobj.dumpId),
2904 .nDeps = 1,
2905 .dumpFn = dumpFn,
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2921
2922
2923
2924
2925
2926
2927 if (sizeof(te->dataLength) == 4 &&
2929 te->dataLength < 0))
2931 }
2932
2935}
2936
2937
2938
2939
2940
2941
2942
2943
2944static void
2946{
2949
2950
2951 if (!
tbinfo->relispopulated)
2952 return;
2953
2955
2958
2964 .namespace =
tbinfo->dobj.namespace->dobj.name,
2965 .owner =
tbinfo->rolname,
2966 .description = "MATERIALIZED VIEW DATA",
2968 .createStmt = q->
data,
2969 .deps =
tdinfo->dobj.dependencies,
2970 .nDeps =
tdinfo->dobj.nDeps));
2971
2973}
2974
2975
2976
2977
2978
2979static void
2981{
2983
2985 {
2987 (!relkind || tblinfo[
i].relkind == relkind))
2989 }
2990}
2991
2992
2993
2994
2995
2996
2997
2998static void
3000{
3002
3003
3004
3005
3006
3008 return;
3009
3010
3012 return;
3013
3015 return;
3016
3020 tbinfo->foreign_server)))
3021 return;
3022
3024 return;
3025
3026
3029 return;
3030
3031
3034 return;
3035
3036
3038
3043 else
3045
3046
3047
3048
3049
3050 tdinfo->dobj.catId.tableoid = 0;
3058
3059
3061
3063
3064
3065
3066
3067
3068
3069
3070
3072 {
3075 }
3076
3077
3078 tbinfo->interesting =
true;
3079}
3080
3081
3082
3083
3084
3085
3086
3087
3088static void
3090{
3093 int ntups,
3098
3100
3102 "( "
3103 "SELECT d1.objid, d2.refobjid, c2.relkind AS refrelkind "
3104 "FROM pg_depend d1 "
3105 "JOIN pg_class c1 ON c1.oid = d1.objid "
3107 " JOIN pg_rewrite r1 ON r1.ev_class = d1.objid "
3108 "JOIN pg_depend d2 ON d2.classid = 'pg_rewrite'::regclass "
3109 "AND d2.objid = r1.oid "
3110 "AND d2.refobjid <> d1.objid "
3111 "JOIN pg_class c2 ON c2.oid = d2.refobjid "
3114 "WHERE d1.classid = 'pg_class'::regclass "
3115 "UNION "
3116 "SELECT w.objid, d3.refobjid, c3.relkind "
3117 "FROM w "
3118 "JOIN pg_rewrite r3 ON r3.ev_class = w.refobjid "
3119 "JOIN pg_depend d3 ON d3.classid = 'pg_rewrite'::regclass "
3120 "AND d3.objid = r3.oid "
3121 "AND d3.refobjid <> w.refobjid "
3122 "JOIN pg_class c3 ON c3.oid = d3.refobjid "
3125 ") "
3126 "SELECT 'pg_class'::regclass::oid AS classid, objid, refobjid "
3127 "FROM w "
3129
3131
3133
3137
3138 for (
i = 0;
i < ntups;
i++)
3139 {
3146
3151
3154 continue;
3155
3161 continue;
3163
3166 continue;
3167
3173 continue;
3175
3177
3179 tbinfo->relispopulated =
false;
3180 }
3181
3183
3185}
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199static void
3201{
3205
3206
3209 {
3211 {
3214
3215
3218 continue;
3222 continue;
3223
3224
3225
3226
3227
3229 ftable->dataObj->dobj.dumpId);
3230 }
3231 }
3233}
3234
3235
3236
3237
3238
3239
3240static void
3242{
3275 *collate,
3276 *ctype,
3277 *locale,
3283 minmxid;
3285
3287
3288
3289
3290
3292 "datdba, "
3293 "pg_encoding_to_char(encoding) AS encoding, "
3294 "datcollate, datctype, datfrozenxid, "
3295 "datacl, acldefault('d', datdba) AS acldefault, "
3296 "datistemplate, datconnlimit, ");
3298 if (
fout->remoteVersion >= 170000)
3300 else if (
fout->remoteVersion >= 150000)
3302 else
3304 if (
fout->remoteVersion >= 160000)
3306 else
3309 "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
3310 "shobj_description(oid, 'pg_database') AS description "
3311 "FROM pg_database "
3312 "WHERE datname = current_database()");
3313
3315
3334
3345 else
3349 else
3358
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3373 {
3375 "CREATE DATABASE %s WITH TEMPLATE = template0 "
3376 "OID = %u STRATEGY = FILE_COPY",
3378 }
3379 else
3380 {
3383 }
3385 {
3388 }
3389
3397 else
3398 pg_fatal(
"unrecognized locale provider: %s",
3400
3401 if (
strlen(collate) > 0 &&
strcmp(collate, ctype) == 0)
3402 {
3405 }
3406 else
3407 {
3409 {
3412 }
3414 {
3417 }
3418 }
3419 if (locale)
3420 {
3423 else
3425
3427 }
3428
3430 {
3433 }
3434
3435
3436
3437
3438
3440 {
3442 {
3447 }
3448 }
3449
3450
3451
3452
3453
3454
3455
3456
3457
3463
3466
3468
3477 .dropStmt =
delQry->data));
3478
3479
3481
3482
3483 {
3484
3485
3486
3487
3488
3490
3492 {
3494
3495
3496
3497
3498
3502
3506 .description = "COMMENT",
3508 .createStmt =
dbQry->data,
3510 .nDeps = 1));
3511 }
3512 }
3513
3514
3516 {
3519
3521
3530 .description = "SECURITY LABEL",
3534 .nDeps = 1));
3537 }
3538
3539
3540
3541
3542
3545
3549
3550
3551
3552
3553
3554
3555
3556
3557
3560
3564
3566 {
3569
3570
3571
3572
3573
3574
3575
3576
3578 "SET datistemplate = false WHERE datname = ");
3581 }
3582
3583
3584
3585
3586
3587
3588
3590
3591
3592
3593
3594
3596 {
3599 "SET datfrozenxid = '%u', datminmxid = '%u'\n"
3600 "WHERE datname = ",
3601 frozenxid, minmxid);
3604 }
3605
3613 .dropStmt =
delQry->data,
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3627 {
3638
3640 "FROM pg_catalog.pg_class\n"
3641 "WHERE oid IN (%u, %u, %u, %u);\n",
3644
3646
3651
3657 {
3662
3665
3668 {
3671 }
3672 else
3673 {
3676 }
3677
3679 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
3680 "WHERE oid = %u;\n",
3684
3688 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
3689 relfilenumber);
3693 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
3694 relfilenumber);
3695 }
3696
3698 "TRUNCATE pg_catalog.pg_largeobject;\n");
3700 "TRUNCATE pg_catalog.pg_largeobject_metadata;\n");
3701
3704
3710
3711 if (
fout->remoteVersion >= 160000)
3717
3719
3725 }
3726
3728
3734}
3735
3736
3737
3738
3739
3740static void
3743{
3747
3748
3750 "WHERE setrole = 0 AND setdatabase = '%u'::oid",
3751 dboid);
3752
3754
3758 outbuf);
3759
3761
3762
3764 "FROM pg_db_role_setting s, pg_roles r "
3765 "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
3766 dboid);
3767
3769
3774 outbuf);
3775
3777
3779}
3780
3781
3782
3783
3784static void
3786{
3789
3791
3795
3800 .createStmt = qry->
data));
3801
3803}
3804
3805
3806
3807
3808
3809static void
3811{
3814
3815 pg_log_info(
"saving \"standard_conforming_strings = %s\"",
3817
3820
3825 .createStmt = qry->
data));
3826
3828}
3829
3830
3831
3832
3833static void
3835{
3842
3843
3844
3845
3846
3847
3848
3849
3851 "SELECT pg_catalog.current_schemas(false)");
3852
3854 pg_fatal(
"could not parse result of current_schemas()");
3855
3856
3857
3858
3859
3860
3861
3863 {
3867 }
3868
3872
3874
3879 .createStmt = qry->
data));
3880
3881
3883
3888}
3889
3890
3891
3892
3893
3894
3895static void
3897{
3901 int ntups;
3903 int n;
3908
3910
3911
3912
3913
3914
3916 "SELECT oid, lomowner, lomacl, "
3917 "acldefault('L', lomowner) AS acldefault "
3918 "FROM pg_largeobject_metadata ");
3919
3920
3921
3922
3923
3924
3925
3926
3929 "WHERE oid IN "
3930 "(SELECT objoid FROM pg_description "
3932 "UNION SELECT objoid FROM pg_seclabel "
3934
3936 "ORDER BY lomowner, lomacl::pg_catalog.text, oid");
3937
3939
3944
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955 for (
i = 0;
i < ntups;
i += n)
3956 {
3963
3964
3965 n = 1;
3967 {
3970 break;
3971 n++;
3972 }
3973
3974
3976
3981
3982 if (n > 1)
3985 else
3990 loinfo->dacl.privtype = 0;
3995
3996 for (int k = 1; k < n; k++)
3997 {
3999
4001
4002
4006 }
4007
4008
4010
4011
4014
4015
4016
4017
4018
4019
4020
4023
4024
4025
4026
4027
4034
4038 }
4039
4042}
4043
4044
4045
4046
4047
4048
4049static void
4051{
4053
4054
4055
4056
4057
4058 for (
int i = 0;
i <
loinfo->numlos;
i++)
4060
4064 .owner =
loinfo->rolname,
4065 .description = "BLOB METADATA",
4067 .createStmt =
cquery->data,
4068 .dropStmt = "-- dummy"));
4069
4070
4071
4072
4073
4076 {
4077 for (
int i = 0;
i <
loinfo->numlos;
i++)
4078 {
4081
4082
4086
4090 catId, 0,
loinfo->dobj.dumpId);
4091
4095 catId, 0,
loinfo->dobj.dumpId);
4096 }
4097 }
4098
4099
4100
4101
4102
4103
4104
4105
4107 {
4109
4110
4112
4114 {
4116
4119
4123 }
4124 else
4125 {
4129 }
4130 }
4131
4133}
4134
4135
4136
4137
4138
4139static int
4141{
4145
4147
4148 for (
int i = 0;
i <
loinfo->numlos;
i++)
4149 {
4151 int loFd;
4152 int cnt;
4153
4154
4156 if (loFd == -1)
4157 pg_fatal(
"could not open large object %u: %s",
4159
4161
4162
4163 do
4164 {
4166 if (cnt < 0)
4167 pg_fatal(
"error reading large object %u: %s",
4169
4171 } while (cnt > 0);
4172
4174
4176 }
4177
4178 return 1;
4179}
4180
4181
4182
4183
4184
4185void
4187{
4204 ntups;
4205
4206
4208 return;
4209
4212
4213
4214
4215
4218 {
4220
4221
4223 continue;
4224
4225
4228 continue;
4229
4230
4234
4235
4237 {
4239
4240
4241
4242
4243
4244
4245
4246
4249 polinfo->dobj.catId.tableoid = 0;
4261 }
4262 }
4264
4265
4266
4267
4268
4269
4270
4271 pg_log_info(
"reading row-level security policies");
4272
4274 "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
4277 "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
4278 " pg_catalog.array_to_string(ARRAY(SELECT pg_catalog.quote_ident(rolname) from pg_catalog.pg_roles WHERE oid = ANY(pol.polroles)), ', ') END AS polroles, "
4279 "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
4280 "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
4281 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
4282 "JOIN pg_catalog.pg_policy pol ON (src.tbloid = pol.polrelid)",
4284
4286
4288 if (ntups > 0)
4289 {
4299
4301
4302 for (
j = 0;
j < ntups;
j++)
4303 {
4306
4308
4318
4321
4324 else
4326
4329 else
4331
4334 else
4337 }
4338 }
4339
4341
4344}
4345
4346
4347
4348
4349
4350static void
4352{
4359 const char *cmd;
4360 char *tag;
4361
4362
4364 return;
4365
4366
4367
4368
4369
4370
4372 {
4374
4377
4378
4379
4380
4381
4382
4386 .namespace =
polinfo->dobj.namespace->dobj.name,
4387 .owner =
tbinfo->rolname,
4388 .description = "ROW SECURITY",
4390 .createStmt = query->
data,
4391 .deps = &(
tbinfo->dobj.dumpId),
4392 .nDeps = 1));
4393
4395 return;
4396 }
4397
4399 cmd = "";
4400 else if (
polinfo->polcmd ==
'r')
4401 cmd = " FOR SELECT";
4402 else if (
polinfo->polcmd ==
'a')
4403 cmd = " FOR INSERT";
4404 else if (
polinfo->polcmd ==
'w')
4405 cmd = " FOR UPDATE";
4406 else if (
polinfo->polcmd ==
'd')
4407 cmd = " FOR DELETE";
4408 else
4409 pg_fatal(
"unexpected policy command type: %c",
4411
4415
4417
4419
4421 !
polinfo->polpermissive ?
" AS RESTRICTIVE" :
"", cmd);
4422
4425
4428
4431
4433
4436
4439
4441
4445 .
namespace =
polinfo->dobj.namespace->dobj.name,
4446 .owner =
tbinfo->rolname,
4447 .description = "POLICY",
4449 .createStmt = query->
data,
4450 .dropStmt =
delqry->data));
4451
4456
4462}
4463
4464
4465
4466
4467
4468void
4470{
4488 ntups;
4489
4491 return;
4492
4494
4495
4497 "p.pubowner, p.puballtables, p.pubinsert, "
4498 "p.pubupdate, p.pubdelete, ");
4499
4500 if (
fout->remoteVersion >= 110000)
4502 else
4504
4505 if (
fout->remoteVersion >= 130000)
4507 else
4509
4510 if (
fout->remoteVersion >= 180000)
4512 else
4514
4515 if (
fout->remoteVersion >= 190000)
4517 else
4519
4521
4523
4525
4526 if (ntups == 0)
4528
4541
4543
4544 for (
i = 0;
i < ntups;
i++)
4545 {
4570 {
4572 };
4573
4574
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591 if (
fout->remoteVersion >= 190000)
4592 {
4595
4598 "SELECT prrelid\n"
4599 "FROM pg_catalog.pg_publication_rel\n"
4600 "WHERE prpubid = %u AND prexcept",
4602
4604
4606
4608 {
4611
4613
4615
4618 }
4619
4621 }
4622 }
4623
4626
4628}
4629
4630
4631
4632
4633
4634static void
4636{
4641 bool first = true;
4642
4643
4645 return;
4646
4649
4651
4654
4657
4659 {
4661
4663
4664
4666 {
4668
4671 else
4674 }
4677
4680 }
4681 else if (
pubinfo->puballsequences)
4683
4686 {
4688 first = false;
4689 }
4690
4692 {
4693 if (!first)
4695
4697 first = false;
4698 }
4699
4701 {
4702 if (!first)
4704
4706 first = false;
4707 }
4708
4710 {
4711 if (!first)
4713
4715 first = false;
4716 }
4717
4719
4722
4725
4727
4732 .description = "PUBLICATION",
4734 .createStmt = query->
data,
4735 .dropStmt =
delq->data));
4736
4741
4746
4750}
4751
4752
4753
4754
4755
4756void
4758{
4769 ntups;
4770
4772 return;
4773
4775
4776
4778 "SELECT tableoid, oid, pnpubid, pnnspid "
4779 "FROM pg_catalog.pg_publication_namespace");
4781
4783
4788
4789
4792
4793 for (
i = 0;
i < ntups;
i++)
4794 {
4799
4800
4801
4802
4803
4806 continue;
4809 continue;
4810
4811
4821
4822
4824
4826 }
4827
4830}
4831
4832
4833
4834
4835
4836void
4838{
4851 ntups;
4852
4854 return;
4855
4857
4858
4859 if (
fout->remoteVersion >= 150000)
4860 {
4862 "SELECT tableoid, oid, prpubid, prrelid, "
4863 "pg_catalog.pg_get_expr(prqual, prrelid) AS prrelqual, "
4864 "(CASE\n"
4865 " WHEN pr.prattrs IS NOT NULL THEN\n"
4866 " (SELECT array_agg(attname)\n"
4867 " FROM\n"
4868 " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
4869 " pg_catalog.pg_attribute\n"
4870 " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
4871 " ELSE NULL END) prattrs "
4872 "FROM pg_catalog.pg_publication_rel pr");
4873 if (
fout->remoteVersion >= 190000)
4875 }
4876 else
4878 "SELECT tableoid, oid, prpubid, prrelid, "
4879 "NULL AS prrelqual, NULL AS prattrs "
4880 "FROM pg_catalog.pg_publication_rel");
4882
4884
4891
4892
4895
4896 for (
i = 0;
i < ntups;
i++)
4897 {
4902
4903
4904
4905
4906
4909 continue;
4912 continue;
4913
4914
4926 else
4928
4930 {
4931 char **attnames;
4934
4937 pg_fatal(
"could not parse %s array",
"prattrs");
4940 {
4941 if (k > 0)
4943
4945 }
4949 }
4950 else
4952
4953
4955
4957 }
4958
4961}
4962
4963
4964
4965
4966
4967static void
4969{
4974 char *tag;
4975
4976
4978 return;
4979
4981
4983
4986
4987
4988
4989
4990
4996 .description = "PUBLICATION TABLES IN SCHEMA",
4998 .createStmt = query->
data));
4999
5000
5001
5004}
5005
5006
5007
5008
5009
5010static void
5012{
5017 char *tag;
5018
5019
5021 return;
5022
5024
5026
5031
5034
5036 {
5037
5038
5039
5040
5041
5043 }
5045
5046
5047
5048
5049
5050
5051
5052
5056 .
namespace =
tbinfo->dobj.namespace->dobj.name,
5058 .description = "PUBLICATION TABLE",
5060 .createStmt = query->
data));
5061
5062
5063
5066}
5067
5068
5069
5070
5071static bool
5073{
5076
5078
5080 return true;
5081
5082 return false;
5083}
5084
5085
5086
5087
5088
5089
5090static void
5092{
5095
5097 "SELECT set_config(name, '%s', false) "
5098 "FROM pg_settings "
5099 "WHERE name = 'restrict_nonsystem_relation_kind'",
5102
5105}
5106
5107
5108
5109
5110
5111void
5113{
5141 ntups;
5142
5144 return;
5145
5147 {
5148 int n;
5149
5151 "SELECT count(*) FROM pg_subscription "
5152 "WHERE subdbid = (SELECT oid FROM pg_database"
5153 " WHERE datname = current_database())",
5156 if (n > 0)
5157 pg_log_warning(
"subscriptions not dumped because current user is not a superuser");
5159 return;
5160 }
5161
5163
5164
5166 "SELECT s.tableoid, s.oid, s.subname,\n"
5167 " s.subowner,\n"
5168 " s.subconninfo, s.subslotname, s.subsynccommit,\n"
5169 " s.subpublications,\n");
5170
5171 if (
fout->remoteVersion >= 140000)
5173 else
5175
5176 if (
fout->remoteVersion >= 140000)
5178 else
5180
5181 if (
fout->remoteVersion >= 150000)
5183 " s.subtwophasestate,\n"
5184 " s.subdisableonerr,\n");
5185 else
5187 " '%c' AS subtwophasestate,\n"
5188 " false AS subdisableonerr,\n",
5190
5191 if (
fout->remoteVersion >= 160000)
5193 " s.subpasswordrequired,\n"
5194 " s.subrunasowner,\n"
5195 " s.suborigin,\n");
5196 else
5198 " 't' AS subpasswordrequired,\n"
5199 " 't' AS subrunasowner,\n"
5200 " '%s' AS suborigin,\n",
5202
5205 " s.subenabled,\n");
5206 else
5208 " false AS subenabled,\n");
5209
5210 if (
fout->remoteVersion >= 170000)
5212 " s.subfailover,\n");
5213 else
5215 " false AS subfailover,\n");
5216
5217 if (
fout->remoteVersion >= 190000)
5219 " s.subretaindeadtuples,\n");
5220 else
5222 " false AS subretaindeadtuples,\n");
5223
5224 if (
fout->remoteVersion >= 190000)
5226 " s.submaxretention,\n");
5227 else
5229
5230 if (
fout->remoteVersion >= 190000)
5232 " s.subwalrcvtimeout,\n");
5233 else
5235 " '-1' AS subwalrcvtimeout,\n");
5236
5237 if (
fout->remoteVersion >= 190000)
5239 else
5241
5243 "FROM pg_subscription s\n");
5244
5245 if (
fout->remoteVersion >= 190000)
5247 "LEFT JOIN pg_catalog.pg_foreign_server fs \n"
5248 " ON fs.oid = s.subserver \n");
5249
5252 "LEFT JOIN pg_catalog.pg_replication_origin_status o \n"
5253 " ON o.external_id = 'pg_' || s.oid::text \n");
5254
5256 "WHERE s.subdbid = (SELECT oid FROM pg_database\n"
5257 " WHERE datname = current_database())");
5258
5260
5262
5263
5264
5265
5266
5289
5291
5292 for (
i = 0;
i < ntups;
i++)
5293 {
5301
5305 subinfo[
i].subservername =
NULL;
5306 else
5326 else
5331 else
5343 else
5346
5347
5349 }
5351
5353}
5354
5355
5356
5357
5358
5359
5360void
5362{
5371 int ntups;
5373
5375 fout->remoteVersion < 170000)
5376 return;
5377
5379 "SELECT srsubid, srrelid, srsubstate, srsublsn "
5380 "FROM pg_catalog.pg_subscription_rel "
5381 "ORDER BY srsubid",
5384 if (ntups == 0)
5386
5387
5392
5394 for (
int i = 0;
i < ntups;
i++)
5395 {
5399
5400
5401
5402
5403
5405 {
5407 if (subinfo ==
NULL)
5409
5411 }
5412
5414 if (tblinfo ==
NULL)
5415 pg_fatal(
"failed sanity check, relation with OID %u not found",
5416 relid);
5417
5418
5420 subrinfo[
i].dobj.catId.tableoid = relid;
5430 else
5432
5433
5435 }
5436
5439}
5440
5441
5442
5443
5444
5445
5446static void
5448{
5452 char *tag;
5453
5454
5456 return;
5457
5458 Assert(
fout->dopt->binary_upgrade &&
fout->remoteVersion >= 170000);
5459
5461
5463
5465 {
5466
5467
5468
5469
5470
5472 "\n-- For binary upgrade, must preserve the subscriber table.\n");
5474 "SELECT pg_catalog.binary_upgrade_add_sub_rel_state(");
5477 ", %u, '%c'",
5480
5483 else
5485
5487 }
5488
5489
5490
5491
5492
5493
5494
5495
5499 .
namespace =
subrinfo->tblinfo->dobj.namespace->dobj.name,
5501 .description = "SUBSCRIPTION TABLE",
5503 .createStmt = query->
data));
5504
5505
5506
5509}
5510
5511
5512
5513
5514
5515static void
5517{
5526
5527
5529 return;
5530
5533
5535
5538
5542 {
5544 }
5545 else
5546 {
5549 }
5550
5551
5553 pg_fatal(
"could not parse %s array",
"subpublications");
5554
5557 {
5560
5562 }
5563
5564 appendPQExpBuffer(query,
" PUBLICATION %s WITH (connect = false, slot_name = ", publications->
data);
5567 else
5569
5572
5577 else
5579
5582
5585
5588
5591
5594
5597
5600
5603
5606
5609
5611
5612
5613
5614
5615
5617 {
5619 {
5620
5621
5622
5623
5624
5625
5626
5627
5628
5630 "\n-- For binary upgrade, must preserve the remote_lsn for the subscriber's replication origin.\n");
5632 "SELECT pg_catalog.binary_upgrade_replorigin_advance(");
5635 }
5636
5638 {
5639
5640
5641
5642
5644 "\n-- For binary upgrade, must preserve the subscriber's running state.\n");
5646 }
5647 }
5648
5653 .description = "SUBSCRIPTION",
5655 .createStmt = query->
data,
5656 .dropStmt =
delq->data));
5657
5662
5667
5670
5674}
5675
5676
5677
5678
5679
5680static void
5685 const char *keyword,
5686 const char *objname)
5687{
5689 {
5693 int ntups;
5696
5697
5699
5702 "SELECT e.extname "
5703 "FROM pg_catalog.pg_depend d, pg_catalog.pg_extension e "
5704 "WHERE d.refobjid = e.oid AND classid = '%s'::pg_catalog.regclass "
5705 "AND objid = '%u'::pg_catalog.oid AND deptype = 'x' "
5706 "AND refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass",
5712 for (
i = 0;
i < ntups;
i++)
5713 {
5717 }
5718
5722 }
5723}
5724
5727{
5728
5729
5730
5731
5732
5733
5734
5735
5739
5740 do
5741 {
5744 "SELECT EXISTS(SELECT 1 "
5745 "FROM pg_catalog.pg_type "
5746 "WHERE oid = '%u'::pg_catalog.oid);",
5752
5754}
5755
5756static void
5762{
5769
5772 "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5774
5778 else
5780
5783
5785 {
5787 "\n-- For binary upgrade, must preserve pg_type array oid\n");
5789 "SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5791 }
5792
5793
5794
5795
5797 {
5798 if (
fout->remoteVersion >= 140000)
5799 {
5801 "SELECT t.oid, t.typarray "
5802 "FROM pg_catalog.pg_type t "
5803 "JOIN pg_catalog.pg_range r "
5804 "ON t.oid = r.rngmultitypid "
5805 "WHERE r.rngtypid = '%u'::pg_catalog.oid;",
5807
5809
5812
5814 }
5815 else
5816 {
5819 }
5820
5822 "\n-- For binary upgrade, must preserve multirange pg_type oid\n");
5824 "SELECT pg_catalog.binary_upgrade_set_next_multirange_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5827 "\n-- For binary upgrade, must preserve multirange pg_type array oid\n");
5829 "SELECT pg_catalog.binary_upgrade_set_next_multirange_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5831 }
5832
5834}
5835
5836static void
5840{
5842
5846}
5847
5848
5849
5850
5851static int
5853{
5856
5858}
5859
5860
5861
5862
5863
5864
5865
5866
5867static void
5869{
5871 const char *query;
5872
5873 query = "SELECT c.oid, c.relkind, c.relfilenode, c.reltoastrelid, "
5874 "ct.relfilenode, i.indexrelid, cti.relfilenode "
5875 "FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_index i "
5876 "ON (c.reltoastrelid = i.indrelid AND i.indisvalid) "
5877 "LEFT JOIN pg_catalog.pg_class ct ON (c.reltoastrelid = ct.oid) "
5878 "LEFT JOIN pg_catalog.pg_class AS cti ON (i.indexrelid = cti.oid) "
5879 "ORDER BY c.oid;";
5880
5882
5886
5888 {
5896 }
5897
5899}
5900
5901static void
5904{
5907
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5925
5927 "\n-- For binary upgrade, must preserve pg_class oids and relfilenodes\n");
5928
5931 {
5933 "SELECT pg_catalog.binary_upgrade_set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
5935
5936
5937
5938
5939
5940
5944 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
5946
5947
5948
5949
5950
5953 {
5955 "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
5958 "SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
5960
5961
5963 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5966 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5968 }
5969 }
5970 else
5971 {
5972
5974 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5977 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5979 }
5980
5982}
5983
5984
5985
5986
5987
5988
5989
5990
5991static void
5994 const char *objtype,
5995 const char *objname,
5997{
6000
6002 return;
6003
6004
6005
6006
6007
6008
6009
6011 {
6014 break;
6016 }
6018 pg_fatal(
"could not find parent extension for %s %s",
6019 objtype, objname);
6020
6022 "\n-- For binary upgrade, handle extension membership the hard way\n");
6025 objtype);
6029}
6030
6031
6032
6033
6034
6035void
6037{
6039 int ntups;
6049
6051
6052
6053
6054
6055
6057 "n.nspowner, "
6058 "n.nspacl, "
6059 "acldefault('n', n.nspowner) AS acldefault "
6060 "FROM pg_namespace n");
6061
6063
6065
6067
6074
6075 for (
i = 0;
i < ntups;
i++)
6076 {
6077 const char *nspowner;
6078
6091
6092
6094
6095
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6116 {
6119
6120
6131
6132 nsinfo[
i].dacl.privtype =
'i';
6135
6138 }
6139 }
6140
6143}
6144
6145
6146
6147
6148
6151{
6153
6158}
6159
6160
6161
6162
6163
6164
6165
6166
6169{
6172 int ntups;
6184
6186
6188 "x.extname, n.nspname, x.extrelocatable, x.extversion, x.extconfig, x.extcondition "
6189 "FROM pg_extension x "
6190 "JOIN pg_namespace n ON n.oid = x.extnamespace");
6191
6193
6195 if (ntups == 0)
6197
6199
6208
6209 for (
i = 0;
i < ntups;
i++)
6210 {
6221
6222
6224 }
6225
6229
6231
6233}
6234
6235
6236
6237
6238
6239
6240
6241
6242void
6244{
6246 int ntups;
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6282 "typnamespace, typacl, "
6283 "acldefault('T', typowner) AS acldefault, "
6284 "typowner, "
6285 "typelem, typrelid, typarray, "
6286 "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
6287 "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
6288 "typtype, typisdefined, "
6289 "typname[0] = '_' AND typelem != 0 AND "
6290 "(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray "
6291 "FROM pg_type");
6292
6294
6296
6298
6313
6314 for (
i = 0;
i < ntups;
i++)
6315 {
6334
6337 else
6339
6342 else
6344
6346
6348 tyinfo[
i].isMultirange =
true;
6349 else
6350 tyinfo[
i].isMultirange =
false;
6351
6352
6354
6355
6358
6359
6360
6361
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6382 {
6391
6392
6393
6394
6395
6396
6398 }
6399 }
6400
6402
6404}
6405
6406
6407
6408
6409
6410void
6412{
6414 int ntups;
6427
6428
6429
6430
6431
6432
6434 "oprnamespace, "
6435 "oprowner, "
6436 "oprkind, "
6437 "oprleft, "
6438 "oprright, "
6439 "oprcode::oid AS oprcode "
6440 "FROM pg_operator");
6441
6443
6445
6447
6457
6458 for (
i = 0;
i < ntups;
i++)
6459 {
6472
6473
6475 }
6476
6478
6480}
6481
6482
6483
6484
6485
6486void
6488{
6490 int ntups;
6500
6502
6503
6504
6505
6506
6507
6509 "collnamespace, "
6510 "collowner, "
6511 "collencoding "
6512 "FROM pg_collation");
6513
6515
6517
6519
6526
6527 for (
i = 0;
i < ntups;
i++)
6528 {
6538
6539
6541 }
6542
6544
6546}
6547
6548
6549
6550
6551
6552void
6554{
6556 int ntups;
6565
6567
6568
6569
6570
6571
6572
6574 "connamespace, "
6575 "conowner "
6576 "FROM pg_conversion");
6577
6579
6581
6583
6589
6590 for (
i = 0;
i < ntups;
i++)
6591 {
6600
6601
6603 }
6604
6606
6608}
6609
6610
6611
6612
6613
6614void
6616{
6618 int ntups;
6627
6629
6630
6631
6632
6635 "amtype, "
6636 "amhandler::pg_catalog.regproc AS amhandler ");
6638
6640
6642
6644
6650
6651 for (
i = 0;
i < ntups;
i++)
6652 {
6661
6662
6664 }
6665
6667
6669}
6670
6671
6672
6673
6674
6675
6676void
6678{
6680 int ntups;
6690
6691
6692
6693
6694
6695
6697 "opcnamespace, "
6698 "opcowner "
6699 "FROM pg_opclass");
6700
6702
6704
6706
6713
6714 for (
i = 0;
i < ntups;
i++)
6715 {
6725
6726
6728 }
6729
6731
6733}
6734
6735
6736
6737
6738
6739void
6741{
6743 int ntups;
6753
6755
6756
6757
6758
6759
6760
6762 "opfnamespace, "
6763 "opfowner "
6764 "FROM pg_opfamily");
6765
6767
6769
6771
6778
6779 for (
i = 0;
i < ntups;
i++)
6780 {
6790
6791
6793 }
6794
6796
6798}
6799
6800
6801
6802
6803
6804void
6806{
6809 int ntups;
6823
6824
6825
6826
6827
6828 agg_check = (
fout->remoteVersion >= 110000 ?
"p.prokind = 'a'"
6829 : "p.proisagg");
6830
6832 "p.proname AS aggname, "
6833 "p.pronamespace AS aggnamespace, "
6834 "p.pronargs, p.proargtypes, "
6835 "p.proowner, "
6836 "p.proacl AS aggacl, "
6837 "acldefault('f', p.proowner) AS acldefault "
6838 "FROM pg_proc p "
6839 "LEFT JOIN pg_init_privs pip ON "
6840 "(p.oid = pip.objoid "
6841 "AND pip.classoid = 'pg_proc'::regclass "
6842 "AND pip.objsubid = 0) "
6843 "WHERE %s AND ("
6844 "p.pronamespace != "
6845 "(SELECT oid FROM pg_namespace "
6846 "WHERE nspname = 'pg_catalog') OR "
6847 "p.proacl IS DISTINCT FROM pip.initprivs",
6851 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6852 "classid = 'pg_proc'::regclass AND "
6853 "objid = p.oid AND "
6854 "refclassid = 'pg_extension'::regclass AND "
6855 "deptype = 'e')");
6857
6859
6861
6863
6873
6874 for (
i = 0;
i < ntups;
i++)
6875 {
6885 agginfo[
i].aggfn.dacl.privtype = 0;
6893 else
6894 {
6899 }
6900 agginfo[
i].aggfn.postponed_def =
false;
6901
6902
6904
6905
6908 }
6909
6911
6913}
6914
6915
6916
6917
6918
6919void
6921{
6924 int ntups;
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6963 : "NOT p.proisagg");
6964
6966 "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
6967 "p.pronargs, p.proargtypes, p.prorettype, "
6968 "p.proacl, "
6969 "acldefault('f', p.proowner) AS acldefault, "
6970 "p.pronamespace, "
6971 "p.proowner "
6972 "FROM pg_proc p "
6973 "LEFT JOIN pg_init_privs pip ON "
6974 "(p.oid = pip.objoid "
6975 "AND pip.classoid = 'pg_proc'::regclass "
6976 "AND pip.objsubid = 0) "
6977 "WHERE %s"
6978 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6979 "WHERE classid = 'pg_proc'::regclass AND "
6980 "objid = p.oid AND deptype = 'i')"
6981 "\n AND ("
6982 "\n pronamespace != "
6983 "(SELECT oid FROM pg_namespace "
6984 "WHERE nspname = 'pg_catalog')"
6985 "\n OR EXISTS (SELECT 1 FROM pg_cast"
6986 "\n WHERE pg_cast.oid > %u "
6987 "\n AND p.oid = pg_cast.castfunc)"
6988 "\n OR EXISTS (SELECT 1 FROM pg_transform"
6989 "\n WHERE pg_transform.oid > %u AND "
6990 "\n (p.oid = pg_transform.trffromsql"
6991 "\n OR p.oid = pg_transform.trftosql))",
6997 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6998 "classid = 'pg_proc'::regclass AND "
6999 "objid = p.oid AND "
7000 "refclassid = 'pg_extension'::regclass AND "
7001 "deptype = 'e')");
7003 "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
7005
7007
7009
7011
7023
7024 for (
i = 0;
i < ntups;
i++)
7025 {
7031 finfo[
i].
dobj.namespace =
7041 if (finfo[
i].nargs == 0)
7043 else
7044 {
7047 finfo[
i].argtypes, finfo[
i].nargs);
7048 }
7050
7051
7053
7054
7057 }
7058
7060
7062}
7063
7064
7065
7066
7067
7068
7069
7070
7073 char *reltuples,
int32 relallvisible,
7074 int32 relallfrozen,
char relkind,
7075 char **indAttNames, int nindAttNames)
7076{
7077 if (!
fout->dopt->dumpStatistics)
7079
7086 {
7089
7100 dobj->namespace = rel->namespace;
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7121 {
7127 break;
7131 break;
7132 default:
7133 pg_fatal(
"cannot dump statistics for relation kind \"%c\"",
7135 }
7136
7137 return info;
7138 }
7140}
7141
7142
7143
7144
7145
7146
7147
7148
7151{
7154 int ntups;
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7217 "SELECT c.tableoid, c.oid, c.relname, "
7218 "c.relnamespace, c.relkind, c.reltype, "
7219 "c.relowner, "
7220 "c.relchecks, "
7221 "c.relhasindex, c.relhasrules, c.relpages, "
7222 "c.reltuples, c.relallvisible, ");
7223
7224 if (
fout->remoteVersion >= 180000)
7226 else
7228
7230 "c.relhastriggers, c.relpersistence, "
7231 "c.reloftype, "
7232 "c.relacl, "
7233 "acldefault(CASE"
7235
7237 fout->remoteVersion >= 200000 ?
7238 " THEN 'g'::\"char\"" :
7239 " THEN NULL");
7242 " THEN 's'::\"char\""
7243 " ELSE 'r'::\"char\" END, c.relowner) AS acldefault, "
7245 "(SELECT ftserver FROM pg_catalog.pg_foreign_table WHERE ftrelid = c.oid) "
7246 "ELSE 0 END AS foreignserver, "
7247 "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, "
7248 "tc.oid AS toid, "
7249 "tc.relpages AS toastpages, "
7250 "tc.reloptions AS toast_reloptions, "
7251 "d.refobjid AS owning_tab, "
7252 "d.refobjsubid AS owning_col, "
7253 "tsp.spcname AS reltablespace, ");
7254
7255 if (
fout->remoteVersion >= 120000)
7257 "false AS relhasoids, ");
7258 else
7260 "c.relhasoids, ");
7261
7263 "c.relispopulated, ");
7264
7266 "c.relreplident, ");
7267
7269 "c.relrowsecurity, c.relforcerowsecurity, ");
7270
7272 "c.relminmxid, tc.relminmxid AS tminmxid, ");
7273
7275 "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
7276 "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
7277 "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
7278
7280 "am.amname, ");
7281
7283 "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
7284
7286 "c.relispartition AS ispartition ");
7287
7288
7289
7290
7291
7292
7293
7295 "\nFROM pg_class c\n"
7296 "LEFT JOIN pg_depend d ON "
7298 "d.classid = 'pg_class'::regclass AND d.objid = c.oid AND "
7299 "d.objsubid = 0 AND "
7300 "d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
7301 "LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
7302
7303
7304
7305
7307 "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
7308
7309
7310
7311
7312
7313
7315 "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid"
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7330 "WHERE c.relkind IN ("
7339 "ORDER BY c.oid");
7340
7342
7344
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7357
7398
7400 {
7401
7402
7403
7404
7405
7406
7407
7412 }
7413
7415
7416 for (
i = 0;
i < ntups;
i++)
7417 {
7420
7426 tblinfo[
i].
dobj.namespace =
7429
7441 else
7444 {
7447 }
7448 else
7449 {
7452 }
7469 else
7476 else
7480
7482 !(
fout->remoteVersion >= 200000))
7483 {
7486
7487
7494
7496
7499 }
7500 else
7502
7503
7504
7505
7506
7507
7510 else
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7528
7531
7532
7534
7535
7539
7540
7541 if (tblinfo[
i].interesting)
7542 {
7544
7546 tblinfo[
i].relpages,
7548 relallvisible, relallfrozen,
7549 tblinfo[
i].relkind,
NULL, 0);
7551 tblinfo[
i].
stats = stats;
7552 }
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7572 {
7573
7574
7575
7576
7577
7578 if (query->
len == 0)
7581 else
7582 {
7585
7586
7587 if (query->
len >= 100000)
7588 {
7589
7593 }
7594 }
7595 }
7596 }
7597
7598 if (query->
len != 0)
7599 {
7600
7603 }
7604
7606 {
7608 }
7609
7611
7613
7614 return tblinfo;
7615}
7616
7617
7618
7619
7620
7621
7622
7623
7624void
7626{
7628
7629
7630
7631
7632
7634 {
7637
7639 continue;
7640
7642 if (owning_tab ==
NULL)
7643 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668 if (
seqinfo->is_identity_sequence)
7670 else
7672
7673
7675 {
7678 }
7679 }
7680}
7681
7682
7683
7684
7685
7686
7687
7688
7691{
7693 int ntups;
7697
7700
7701
7703
7705
7707
7709
7711
7714
7715 for (
i = 0;
i < ntups;
i++)
7716 {
7719 }
7720
7722
7724
7726}
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745void
7747{
7750 int ntups;
7751
7752
7753 if (
fout->remoteVersion < 110000)
7754 return;
7755
7756 if (!
fout->dopt->dumpData)
7757 return;
7758
7760
7761
7762
7763
7764
7765
7766
7767
7768
7770 "SELECT partrelid FROM pg_partitioned_table WHERE\n"
7771 "(SELECT c.oid FROM pg_opclass c JOIN pg_am a "
7772 "ON c.opcmethod = a.oid\n"
7773 "WHERE opcname = 'enum_ops' "
7774 "AND opcnamespace = 'pg_catalog'::regnamespace "
7775 "AND amname = 'hash') = ANY(partclass)");
7776
7778
7780
7781 for (
int i = 0;
i < ntups;
i++)
7782 {
7785
7788 pg_fatal(
"failed sanity check, table OID %u appearing in pg_partitioned_table not found",
7790 tbinfo->unsafe_partitions =
true;
7791 }
7792
7794
7796}
7797
7798
7799
7800
7801
7802
7803
7804
7805void
7807{
7811 int ntups;
7843
7844
7845
7846
7847
7848
7849
7850
7851
7854 {
7856
7858 continue;
7859
7860
7861
7862
7863 if (!
tbinfo->interesting)
7864 continue;
7865
7866
7870 }
7872
7874 "SELECT t.tableoid, t.oid, i.indrelid, "
7875 "t.relname AS indexname, "
7876 "t.relpages, t.reltuples, t.relallvisible, ");
7877
7878 if (
fout->remoteVersion >= 180000)
7880 else
7882
7884 "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
7885 "i.indkey, i.indisclustered, "
7886 "c.contype, c.conname, "
7887 "c.condeferrable, c.condeferred, "
7888 "c.tableoid AS contableoid, "
7889 "c.oid AS conoid, "
7890 "pg_catalog.pg_get_constraintdef(c.oid, false) AS condef, "
7891 "CASE WHEN i.indexprs IS NOT NULL THEN "
7892 "(SELECT pg_catalog.array_agg(attname ORDER BY attnum)"
7893 " FROM pg_catalog.pg_attribute "
7894 " WHERE attrelid = i.indexrelid) "
7895 "ELSE NULL END AS indattnames, "
7896 "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
7897 "t.reloptions AS indreloptions, ");
7898
7899
7901 "i.indisreplident, ");
7902
7903 if (
fout->remoteVersion >= 110000)
7905 "inh.inhparent AS parentidx, "
7906 "i.indnkeyatts AS indnkeyatts, "
7907 "i.indnatts AS indnatts, "
7908 "(SELECT pg_catalog.array_agg(attnum ORDER BY attnum) "
7909 " FROM pg_catalog.pg_attribute "
7910 " WHERE attrelid = i.indexrelid AND "
7911 " attstattarget >= 0) AS indstatcols, "
7912 "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attnum) "
7913 " FROM pg_catalog.pg_attribute "
7914 " WHERE attrelid = i.indexrelid AND "
7915 " attstattarget >= 0) AS indstatvals, ");
7916 else
7918 "0 AS parentidx, "
7919 "i.indnatts AS indnkeyatts, "
7920 "i.indnatts AS indnatts, "
7921 "'' AS indstatcols, "
7922 "'' AS indstatvals, ");
7923
7924 if (
fout->remoteVersion >= 150000)
7926 "i.indnullsnotdistinct, ");
7927 else
7929 "false AS indnullsnotdistinct, ");
7930
7931 if (
fout->remoteVersion >= 180000)
7933 "c.conperiod ");
7934 else
7936 "NULL AS conperiod ");
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947 if (
fout->remoteVersion >= 110000)
7948 {
7950 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7951 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7952 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7953 "JOIN pg_catalog.pg_class t2 ON (t2.oid = i.indrelid) "
7954 "LEFT JOIN pg_catalog.pg_constraint c "
7955 "ON (i.indrelid = c.conrelid AND "
7956 "i.indexrelid = c.conindid AND "
7957 "c.contype IN ('p','u','x')) "
7958 "LEFT JOIN pg_catalog.pg_inherits inh "
7959 "ON (inh.inhrelid = indexrelid) "
7960 "WHERE (i.indisvalid OR t2.relkind = 'p') "
7961 "AND i.indisready "
7962 "ORDER BY i.indrelid, indexname",
7964 }
7965 else
7966 {
7967
7968
7969
7970
7972 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7973 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7974 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7975 "LEFT JOIN pg_catalog.pg_constraint c "
7976 "ON (i.indrelid = c.conrelid AND "
7977 "i.indexrelid = c.conindid AND "
7978 "c.contype IN ('p','u','x')) "
7979 "WHERE i.indisvalid AND i.indisready "
7980 "ORDER BY i.indrelid, indexname",
7982 }
7983
7985
7987
8017
8019
8020
8021
8022
8023
8025 for (
int j = 0;
j < ntups;)
8026 {
8030
8031
8034 break;
8035
8036
8037
8038
8039
8041 {
8044 break;
8045 }
8048
8051 pg_fatal(
"unexpected index data for table \"%s\"",
8053
8054
8057
8059 {
8060 char contype;
8062 char **indAttNames =
NULL;
8063 int nindAttNames = 0;
8068
8092 {
8094 };
8095
8098 else
8100
8102 {
8104 &indAttNames, &nindAttNames))
8105 pg_fatal(
"could not parse %s array",
"indattnames");
8106 }
8107
8111 indAttNames, nindAttNames);
8112
8114 if (contype == 'p' || contype == 'u' || contype == 'x')
8115 {
8116
8117
8118
8119
8121
8133 if (contype == 'x')
8135 else
8144
8148 }
8149 else
8150 {
8151
8153 }
8154 }
8155 }
8156
8158
8161}
8162
8163
8164
8165
8166
8167
8168
8169
8170void
8172{
8176 int ntups;
8185
8187
8188 if (
fout->remoteVersion < 130000)
8190 "stxnamespace, stxowner, stxrelid, NULL AS stxstattarget "
8191 "FROM pg_catalog.pg_statistic_ext");
8192 else
8194 "stxnamespace, stxowner, stxrelid, stxstattarget "
8195 "FROM pg_catalog.pg_statistic_ext");
8196
8198
8200
8208
8210
8211 for (
i = 0;
i < ntups;
i++)
8212 {
8225 else
8227
8228
8230
8231 if (
fout->dopt->dumpStatistics)
8233 }
8234
8237}
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248void
8250{
8254 int ntups;
8265
8266
8267
8268
8269
8270
8271
8272
8273
8276 {
8278
8280 continue;
8281
8282
8286 }
8288
8290 "SELECT c.tableoid, c.oid, "
8291 "conrelid, conname, confrelid, ");
8292 if (
fout->remoteVersion >= 110000)
8294 else
8297 "pg_catalog.pg_get_constraintdef(c.oid) AS condef\n"
8298 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8299 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
8300 "WHERE contype = 'f' ",
8302 if (
fout->remoteVersion >= 110000)
8304 "AND conparentid = 0 ");
8306 "ORDER BY conrelid, conname");
8307
8309
8311
8319
8321
8323 for (
int j = 0;
j < ntups;
j++)
8324 {
8327
8328
8329
8330
8331
8333 {
8335 {
8337 if (
tbinfo->dobj.catId.oid == conrelid)
8338 break;
8339 }
8341 pg_fatal(
"unrecognized table OID %u", conrelid);
8342 }
8343
8360
8361
8362
8363
8364
8365
8366
8369 {
8371
8373 {
8374 for (
int k = 0; k <
reftable->numIndexes; k++)
8375 {
8377
8378
8379 if (
reftable->indexes[k].dobj.catId.oid != indexOid)
8380 continue;
8381
8384 break;
8385 }
8386 }
8387 }
8388 }
8389
8391
8394}
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407static void
8409{
8411
8413
8414 for (cell =
refidx->partattaches.head; cell; cell = cell->
next)
8415 {
8417
8419
8420 if (
attach->partitionIdx->partattaches.head !=
NULL)
8422 }
8423}
8424
8425
8426
8427
8428
8429
8430static void
8432{
8442 int ntups;
8443
8445 {
8446
8447
8448
8449
8450
8452 "PREPARE getDomainConstraints(pg_catalog.oid) AS\n"
8453 "SELECT tableoid, oid, conname, "
8454 "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
8455 "convalidated, contype "
8456 "FROM pg_catalog.pg_constraint "
8457 "WHERE contypid = $1 AND contype IN (%s) "
8458 "ORDER BY conname",
8459 fout->remoteVersion < 170000 ?
"'c'" :
"'c', 'n'");
8460
8462
8464 }
8465
8467 "EXECUTE getDomainConstraints('%u')",
8469
8471
8473
8480
8483
8484
8485 for (
int i = 0,
j = 0;
i < ntups;
i++)
8486 {
8490
8492 {
8495 }
8496 else
8497 {
8500
8502 constraint =
tyinfo->notnull;
8503 }
8504
8510 constraint->
dobj.namespace =
tyinfo->dobj.namespace;
8513 constraint->
contype = contype;
8520
8522
8523
8524
8525
8526
8527
8528
8531 }
8532
8534
8536}
8537
8538
8539
8540
8541
8542void
8544{
8546 int ntups;
8557
8559 "tableoid, oid, rulename, "
8560 "ev_class AS ruletable, ev_type, is_instead, "
8561 "ev_enabled "
8562 "FROM pg_rewrite "
8563 "ORDER BY oid");
8564
8566
8568
8570
8578
8579 for (
i = 0;
i < ntups;
i++)
8580 {
8582
8591 pg_fatal(
"failed sanity check, parent table with OID %u of pg_rewrite entry with OID %u not found",
8599 {
8600
8601
8602
8603
8604
8605
8606
8610 {
8613
8615 }
8616 else
8617 {
8621 }
8622 }
8623 else
8625 }
8626
8628
8630}
8631
8632
8633
8634
8635
8636
8637
8638
8639void
8641{
8645 int ntups;
8655
8656
8657
8658
8659
8660
8661
8662
8663
8666 {
8668
8669 if (!
tbinfo->hastriggers ||
8671 continue;
8672
8673
8677 }
8679
8680 if (
fout->remoteVersion >= 150000)
8681 {
8682
8683
8684
8685
8686
8687
8688
8689
8691 "SELECT t.tgrelid, t.tgname, "
8692 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8693 "t.tgenabled, t.tableoid, t.oid, "
8694 "t.tgparentid <> 0 AS tgispartition\n"
8695 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8696 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8697 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8698 "WHERE ((NOT t.tgisinternal AND t.tgparentid = 0) "
8699 "OR t.tgenabled != u.tgenabled) "
8700 "ORDER BY t.tgrelid, t.tgname",
8702 }
8703 else if (
fout->remoteVersion >= 130000)
8704 {
8705
8706
8707
8708
8709
8710
8711
8712
8714 "SELECT t.tgrelid, t.tgname, "
8715 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8716 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition\n"
8717 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8718 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8719 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8720 "WHERE (NOT t.tgisinternal OR t.tgenabled != u.tgenabled) "
8721 "ORDER BY t.tgrelid, t.tgname",
8723 }
8724 else if (
fout->remoteVersion >= 110000)
8725 {
8726
8727
8728
8729
8730
8731
8732
8734 "SELECT t.tgrelid, t.tgname, "
8735 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8736 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition "
8737 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8738 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8739 "LEFT JOIN pg_catalog.pg_depend AS d ON "
8740 " d.classid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8741 " d.refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8742 " d.objid = t.oid "
8743 "LEFT JOIN pg_catalog.pg_trigger AS pt ON pt.oid = refobjid "
8744 "WHERE (NOT t.tgisinternal OR t.tgenabled != pt.tgenabled) "
8745 "ORDER BY t.tgrelid, t.tgname",
8747 }
8748 else
8749 {
8750
8752 "SELECT t.tgrelid, t.tgname, "
8753 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8754 "t.tgenabled, false as tgispartition, "
8755 "t.tableoid, t.oid "
8756 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8757 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8758 "WHERE NOT tgisinternal "
8759 "ORDER BY t.tgrelid, t.tgname",
8761 }
8762
8764
8766
8774
8776
8777
8778
8779
8780
8782 for (
int j = 0;
j < ntups;)
8783 {
8787
8788
8791 break;
8792
8793
8794
8795
8796
8798 {
8801 break;
8802 }
8805
8806
8809
8811 {
8822 }
8823 }
8824
8826
8829}
8830
8831
8832
8833
8834
8835void
8837{
8850 int ntups;
8851
8853
8855 "SELECT e.tableoid, e.oid, evtname, evtenabled, "
8856 "evtevent, evtowner, "
8857 "array_to_string(array("
8858 "select quote_literal(x) "
8859 " from unnest(evttags) as t(x)), ', ') as evttags, "
8860 "e.evtfoid::regproc as evtfname "
8861 "FROM pg_event_trigger e "
8862 "ORDER BY e.oid");
8863
8865
8867
8869
8878
8879 for (
i = 0;
i < ntups;
i++)
8880 {
8892
8893
8895 }
8896
8898
8900}
8901
8902
8903
8904
8905
8906
8907
8908
8909void
8911{
8913 int ntups;
8927
8929 "lanname, lanpltrusted, lanplcallfoid, "
8930 "laninline, lanvalidator, "
8931 "lanacl, "
8932 "acldefault('l', lanowner) AS acldefault, "
8933 "lanowner "
8934 "FROM pg_language "
8935 "WHERE lanispl "
8936 "ORDER BY oid");
8937
8939
8941
8943
8954
8955 for (
i = 0;
i < ntups;
i++)
8956 {
8961
8972
8973
8975
8976
8979 }
8980
8982
8984}
8985
8986
8987
8988
8989
8990
8991
8992
8993void
8995{
8997 int ntups;
9008
9009 if (
fout->remoteVersion >= 140000)
9010 {
9012 "castsource, casttarget, castfunc, castcontext, "
9013 "castmethod "
9014 "FROM pg_cast c "
9015 "WHERE NOT EXISTS ( "
9016 "SELECT 1 FROM pg_range r "
9017 "WHERE c.castsource = r.rngtypid "
9018 "AND c.casttarget = r.rngmultitypid "
9019 ") "
9020 "ORDER BY 3,4");
9021 }
9022 else
9023 {
9025 "castsource, casttarget, castfunc, castcontext, "
9026 "castmethod "
9027 "FROM pg_cast ORDER BY 3,4");
9028 }
9029
9031
9033
9035
9043
9044 for (
i = 0;
i < ntups;
i++)
9045 {
9049
9059
9060
9061
9062
9063
9064
9072
9073
9075 }
9076
9078
9080}
9081
9082static char *
9084{
9088
9090 appendPQExpBuffer(query,
"SELECT lanname FROM pg_language WHERE oid = %u", langid);
9095
9097}
9098
9099
9100
9101
9102
9103void
9105{
9107 int ntups;
9117
9119
9121 "trftype, trflang, trffromsql::oid, trftosql::oid "
9122 "FROM pg_transform "
9123 "ORDER BY 3,4");
9124
9126
9128
9130
9137
9138 for (
i = 0;
i < ntups;
i++)
9139 {
9143
9152
9153
9154
9155
9156
9157
9166
9167
9169 }
9170
9172
9174}
9175
9176
9177
9178
9179
9180
9181
9182
9183void
9185{
9192 int ntups;
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9232 {
9234
9235
9237 continue;
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247 if (!
tbinfo->interesting &&
9248 !(
fout->dopt->binary_upgrade &&
9251 continue;
9252
9253
9257
9259 {
9260
9264 }
9265 }
9268
9269
9270
9271
9272
9273
9274
9275
9277 "SELECT\n"
9278 "a.attrelid,\n"
9279 "a.attnum,\n"
9280 "a.attname,\n"
9281 "a.attstattarget,\n"
9282 "a.attstorage,\n"
9283 "t.typstorage,\n"
9284 "a.atthasdef,\n"
9285 "a.attisdropped,\n"
9286 "a.attlen,\n"
9287 "a.attalign,\n"
9288 "a.attislocal,\n"
9289 "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n"
9290 "array_to_string(a.attoptions, ', ') AS attoptions,\n"
9291 "CASE WHEN a.attcollation <> t.typcollation "
9292 "THEN a.attcollation ELSE 0 END AS attcollation,\n"
9293 "pg_catalog.array_to_string(ARRAY("
9294 "SELECT pg_catalog.quote_ident(option_name) || "
9295 "' ' || pg_catalog.quote_literal(option_value) "
9296 "FROM pg_catalog.pg_options_to_table(attfdwoptions) "
9297 "ORDER BY option_name"
9298 "), E',\n ') AS attfdwoptions,\n");
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318 if (
fout->remoteVersion >= 180000)
9320 "co.conname AS notnull_name,\n"
9321 "CASE WHEN co.convalidated THEN pt.description"
9322 " ELSE NULL END AS notnull_comment,\n"
9323 "CASE WHEN NOT co.convalidated THEN co.oid "
9324 "ELSE NULL END AS notnull_invalidoid,\n"
9325 "co.connoinherit AS notnull_noinherit,\n"
9326 "co.conislocal AS notnull_islocal,\n");
9327 else
9329 "CASE WHEN a.attnotnull THEN '' ELSE NULL END AS notnull_name,\n"
9330 "NULL AS notnull_comment,\n"
9331 "NULL AS notnull_invalidoid,\n"
9332 "false AS notnull_noinherit,\n"
9333 "CASE WHEN a.attislocal THEN true\n"
9334 " WHEN a.attnotnull AND NOT a.attislocal THEN true\n"
9335 " ELSE false\n"
9336 "END AS notnull_islocal,\n");
9337
9338 if (
fout->remoteVersion >= 140000)
9340 "a.attcompression AS attcompression,\n");
9341 else
9343 "'' AS attcompression,\n");
9344
9346 "a.attidentity,\n");
9347
9348 if (
fout->remoteVersion >= 110000)
9350 "CASE WHEN a.atthasmissing AND NOT a.attisdropped "
9351 "THEN a.attmissingval ELSE null END AS attmissingval,\n");
9352 else
9354 "NULL AS attmissingval,\n");
9355
9356 if (
fout->remoteVersion >= 120000)
9358 "a.attgenerated\n");
9359 else
9361 "'' AS attgenerated\n");
9362
9363
9365 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9366 "JOIN pg_catalog.pg_attribute a ON (src.tbloid = a.attrelid) "
9367 "LEFT JOIN pg_catalog.pg_type t "
9368 "ON (a.atttypid = t.oid)\n",
9370
9371
9372
9373
9374
9375 if (
fout->remoteVersion >= 180000)
9377 " LEFT JOIN pg_catalog.pg_constraint co ON "
9378 "(a.attrelid = co.conrelid\n"
9379 " AND co.contype = 'n' AND "
9380 "co.conkey = array[a.attnum])\n"
9381 " LEFT JOIN pg_catalog.pg_description pt ON "
9382 "(pt.classoid = co.tableoid AND pt.objoid = co.oid)\n");
9383
9385 "WHERE a.attnum > 0::pg_catalog.int2\n");
9386
9387
9388
9389
9390
9391 if (
fout->dopt->binary_upgrade &&
fout->remoteVersion < 120000)
9393 "OR (a.attnum = -2::pg_catalog.int2 AND src.tbloid = "
9395
9397 "ORDER BY a.attrelid, a.attnum");
9398
9400
9402
9427
9428
9431
9432
9433
9434
9435
9437 for (int r = 0; r < ntups;)
9438 {
9441 int numatts;
9443
9444
9445 for (numatts = 1; numatts < ntups - r; numatts++)
9447 break;
9448
9449
9450
9451
9452
9454 {
9456 if (
tbinfo->dobj.catId.oid == attrelid)
9457 break;
9458 }
9460 pg_fatal(
"unrecognized table OID %u", attrelid);
9461
9464 !(
fout->dopt->binary_upgrade &&
9467 pg_fatal(
"unexpected column data for table \"%s\"",
9469
9470
9471 tbinfo->numatts = numatts;
9495
9496 for (
int j = 0;
j < numatts;
j++, r++)
9497 {
9499 !(
fout->dopt->binary_upgrade &&
fout->remoteVersion < 120000 &&
9501 pg_fatal(
"invalid column numbering in table \"%s\"",
9506 tbinfo->attstattarget[
j] = -1;
9507 else
9518
9519
9528
9539 }
9540
9542 {
9543
9547 }
9548 }
9549
9550
9553
9555
9556
9557
9558
9559
9561 {
9565
9567
9569
9571 "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc\n"
9572 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9573 "JOIN pg_catalog.pg_attrdef a ON (src.tbloid = a.adrelid)\n"
9574 "ORDER BY a.adrelid, a.adnum",
9576
9578
9581
9584 {
9590
9591
9592
9593
9594
9596 {
9598 {
9601 break;
9602 }
9605 }
9606
9608 pg_fatal(
"invalid adnum value %d for table \"%s\"",
9609 adnum,
tbinfo->dobj.name);
9610
9611
9612
9613
9614
9615 if (
tbinfo->attisdropped[adnum - 1])
9616 continue;
9617
9623 attrdefs[
j].
adnum = adnum;
9625
9627 attrdefs[
j].
dobj.namespace =
tbinfo->dobj.namespace;
9628
9630
9631
9632
9633
9634
9635
9636
9637
9638 if (
tbinfo->attgenerated[adnum - 1])
9639 {
9640
9641
9642
9643
9644
9645
9646
9647
9649 }
9651 {
9652
9653
9654
9655
9657 }
9659 {
9660
9662 }
9663 else
9664 {
9666 }
9667
9668 if (!attrdefs[
j].separate)
9669 {
9670
9671
9672
9673
9674
9675
9677 attrdefs[
j].dobj.dumpId);
9678 }
9679
9680 tbinfo->attrdefs[adnum - 1] = &attrdefs[
j];
9681 }
9682
9684 }
9685
9686
9687
9688
9689
9691 {
9700
9701 pg_log_info(
"finding invalid not-null constraints");
9702
9705 "SELECT c.tableoid, c.oid, conrelid, conname, "
9706 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9707 "conislocal, convalidated "
9708 "FROM unnest('%s'::pg_catalog.oid[]) AS src(conoid)\n"
9709 "JOIN pg_catalog.pg_constraint c ON (src.conoid = c.oid)\n"
9710 "ORDER BY c.conrelid, c.conname",
9712
9714
9717
9724
9725
9728 {
9732
9733
9736 break;
9737
9738
9739
9740
9741
9743 {
9745 if (
tbinfo->dobj.catId.oid == conrelid)
9746 break;
9747 }
9749 pg_fatal(
"unrecognized table OID %u", conrelid);
9750
9752 {
9768
9769
9770
9771
9772
9773
9774
9776
9778 }
9779 }
9781 }
9782
9783
9784
9785
9786
9788 {
9798
9800
9803 "SELECT c.tableoid, c.oid, conrelid, conname, "
9804 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9805 "conislocal, convalidated "
9806 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9807 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
9808 "WHERE contype = 'c' "
9809 "ORDER BY c.conrelid, c.conname",
9811
9813
9816
9824
9825
9828 {
9832
9833
9836 break;
9837
9838
9839
9840
9841
9843 {
9845 if (
tbinfo->dobj.catId.oid == conrelid)
9846 break;
9847 }
9849 pg_fatal(
"unrecognized table OID %u", conrelid);
9850
9852 {
9854 "expected %d check constraints on table \"%s\" but found %d",
9859 }
9860
9862
9864 {
9866
9882
9883
9884
9885
9886
9887
9889
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9904
9905
9906
9907
9908
9909 }
9910 }
9911
9913 }
9914
9918}
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967static void
9976{
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9989 {
9991
9993 {
9997 }
9998 else
10000
10001
10002
10003
10004
10005 tbinfo->notnull_invalid[
j] =
true;
10006
10007
10009 return;
10010 }
10011
10012
10013
10014
10015
10018 tbinfo->notnull_invalid[
j] =
false;
10019
10020
10021
10022
10023
10024
10025
10026 if (
fout->remoteVersion < 180000)
10027 {
10028
10029
10030
10031
10034 else
10035 tbinfo->notnull_constrs[
j] =
"";
10036 }
10037 else
10038 {
10041 else
10042 {
10043
10044
10045
10046
10047
10050 !
tbinfo->notnull_islocal[
j]) ||
10052 {
10055 }
10056 else
10057 {
10059
10060
10065 tbinfo->notnull_constrs[
j] =
"";
10066 else
10067 {
10070 }
10072 }
10073 }
10074 }
10075}
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094bool
10096{
10098 return true;
10099 if (
tbinfo->attisdropped[colno])
10100 return false;
10101 return (
tbinfo->attislocal[colno] ||
tbinfo->ispartition);
10102}
10103
10104
10105
10106
10107
10108
10109void
10111{
10113 int ntups;
10126
10128
10129
10130
10131
10132
10133
10135 "prsstart::oid, prstoken::oid, "
10136 "prsend::oid, prsheadline::oid, prslextype::oid "
10137 "FROM pg_ts_parser");
10138
10140
10142
10144
10154
10155 for (
i = 0;
i < ntups;
i++)
10156 {
10169
10170
10172 }
10173
10175
10177}
10178
10179
10180
10181
10182
10183void
10185{
10187 int ntups;
10198
10200
10202 "dictnamespace, dictowner, "
10203 "dicttemplate, dictinitoption "
10204 "FROM pg_ts_dict");
10205
10207
10209
10211
10219
10220 for (
i = 0;
i < ntups;
i++)
10221 {
10233 else
10235
10236
10238 }
10239
10241
10243}
10244
10245
10246
10247
10248
10249void
10251{
10253 int ntups;
10263
10265
10267 "tmplnamespace, tmplinit::oid, tmpllexize::oid "
10268 "FROM pg_ts_template");
10269
10271
10273
10275
10282
10283 for (
i = 0;
i < ntups;
i++)
10284 {
10294
10295
10297 }
10298
10300
10302}
10303
10304
10305
10306
10307
10308void
10310{
10312 int ntups;
10322
10324
10326 "cfgnamespace, cfgowner, cfgparser "
10327 "FROM pg_ts_config");
10328
10330
10332
10334
10341
10342 for (
i = 0;
i < ntups;
i++)
10343 {
10353
10354
10356 }
10357
10359
10361}
10362
10363
10364
10365
10366
10367void
10369{
10371 int ntups;
10385
10387
10389 "fdwowner, "
10390 "fdwhandler::pg_catalog.regproc, "
10391 "fdwvalidator::pg_catalog.regproc, ");
10392
10393 if (
fout->remoteVersion >= 190000)
10395 else
10397
10399 "fdwacl, "
10400 "acldefault('F', fdwowner) AS acldefault, "
10401 "array_to_string(ARRAY("
10402 "SELECT quote_ident(option_name) || ' ' || "
10403 "quote_literal(option_value) "
10404 "FROM pg_options_to_table(fdwoptions) "
10405 "ORDER BY option_name"
10406 "), E',\n ') AS fdwoptions "
10407 "FROM pg_foreign_data_wrapper");
10408
10410
10412
10414
10425
10426 for (
i = 0;
i < ntups;
i++)
10427 {
10443
10444
10446
10447
10450 }
10451
10453
10455}
10456
10457
10458
10459
10460
10461void
10463{
10465 int ntups;
10479
10481
10483 "srvowner, "
10484 "srvfdw, srvtype, srvversion, srvacl, "
10485 "acldefault('S', srvowner) AS acldefault, "
10486 "array_to_string(ARRAY("
10487 "SELECT quote_ident(option_name) || ' ' || "
10488 "quote_literal(option_value) "
10489 "FROM pg_options_to_table(srvoptions) "
10490 "ORDER BY option_name"
10491 "), E',\n ') AS srvoptions "
10492 "FROM pg_foreign_server");
10493
10495
10497
10499
10510
10511 for (
i = 0;
i < ntups;
i++)
10512 {
10528
10529
10531
10532
10534
10535
10538 }
10539
10541
10543}
10544
10545
10546
10547
10548
10549void
10551{
10564 ntups;
10565
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10581 "SELECT oid, tableoid, "
10582 "defaclrole, "
10583 "defaclnamespace, "
10584 "defaclobjtype, "
10585 "defaclacl, "
10586 "CASE WHEN defaclnamespace = 0 THEN "
10587 "acldefault(CASE WHEN defaclobjtype = 'S' "
10588 "THEN 's'::\"char\" ELSE defaclobjtype END, "
10589 "defaclrole) ELSE '{}' END AS acldefault "
10590 "FROM pg_default_acl");
10591
10593
10595
10597
10605
10606 for (
i = 0;
i < ntups;
i++)
10607 {
10609
10614
10616
10619 else
10621
10628
10629
10631
10632
10634 }
10635
10637
10639}
10640
10641
10642
10643
10644
10645
10646static const char *
10648{
10650
10651
10652
10653
10655 {
10658
10659 while (low <= high)
10660 {
10662
10665 else if (roleoid >
middle->roleoid)
10667 else
10669 }
10670 }
10671
10672 pg_fatal(
"role with OID %u does not exist", roleoid);
10674}
10675
10676
10677
10678
10679
10680
10681
10682static void
10684{
10686 const char *query;
10688
10689 query = "SELECT oid, rolname FROM pg_catalog.pg_roles ORDER BY 1";
10690
10692
10694
10696
10698 {
10701 }
10702
10704}
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717static void
10719{
10722 int ntups,
10724
10725
10727 "SELECT DISTINCT attrelid FROM pg_attribute "
10728 "WHERE attacl IS NOT NULL");
10729
10731
10733 for (
i = 0;
i < ntups;
i++)
10734 {
10737
10739
10740 if (tblinfo)
10741 {
10744 }
10745 }
10747
10748
10750 "SELECT objoid, classoid, objsubid, privtype, initprivs "
10751 "FROM pg_init_privs");
10752
10754
10756 for (
i = 0;
i < ntups;
i++)
10757 {
10765
10767 objId.
oid = objoid;
10769
10770 if (dobj)
10771 {
10772
10773 if (objsubid != 0)
10774 {
10776 {
10777
10779 ((
TableInfo *) dobj)->hascolumnACLs =
true;
10780 }
10781 else
10783 classoid, objoid, objsubid);
10784 continue;
10785 }
10786
10787
10788
10789
10790
10793 continue;
10794
10795
10804 {
10806
10809 }
10810 else
10812 classoid, objoid, objsubid);
10813 }
10814 }
10816
10818}
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843static void
10845 const char *
name,
const char *
namespace,
10846 const char *owner,
CatalogId catalogId,
10847 int subid,
DumpId dumpId,
10849{
10853
10854
10856 return;
10857
10858
10860 {
10862 return;
10863 }
10864 else
10865 {
10866
10868 return;
10869 }
10870
10871
10874
10875
10877 {
10879 break;
10882 }
10883
10885 {
10887
10888
10889
10890
10891
10892
10893
10895 {
10898 }
10901 }
10902
10903
10905 {
10908
10910 if (namespace && *namespace)
10915
10917
10918
10919
10920
10921
10922
10925 .namespace = namespace,
10926 .owner = owner,
10927 .description = "COMMENT",
10929 .createStmt = query->
data,
10930 .deps = &dumpId,
10931 .nDeps = 1));
10932
10935 }
10936}
10937
10938
10939
10940
10941
10942
10943static inline void
10945 const char *
name,
const char *
namespace,
10946 const char *owner,
CatalogId catalogId,
10947 int subid,
DumpId dumpId)
10948{
10950 catalogId, subid, dumpId,
NULL);
10951}
10952
10953
10954
10955
10956
10957
10958
10959static void
10961 const char *argtype,
const char *
argval)
10962{
10964
10967
10970}
10971
10972
10973
10974
10975
10976
10979{
10984 int count = 0;
10989
10990
10991 if (!te)
10993
10994
10995
10996
10997
10998
10999
11000
11001
11003 {
11006 }
11007
11011
11012
11013
11014
11015
11016
11017
11019 {
11022 continue;
11023
11024 if (
fout->remoteVersion >= 190000)
11025 {
11027 char relid[32];
11028
11031 }
11032 else
11033 {
11036 }
11037
11038 count++;
11039 }
11040
11044
11045
11046 if (count > 0)
11047 {
11049
11051
11052 if (
fout->remoteVersion >= 190000)
11053 {
11056 }
11057 else
11058 {
11063 }
11064
11067 }
11068
11072 return res;
11073}
11074
11075
11076
11077
11078
11079
11080
11081
11082static char *
11084{
11087 static int rownum;
11109
11110
11111
11112
11113
11116
11121
11123 pg_fatal(
"statistics dumped out of order (current: %d %s %s, expected: %d %s %s)",
11126
11129 {
11130 if (
fout->remoteVersion >= 190000)
11132 "PREPARE getAttributeStats(pg_catalog.oid[]) AS\n");
11133 else
11135 "PREPARE getAttributeStats(pg_catalog.name[], pg_catalog.name[]) AS\n");
11136
11138 "SELECT s.schemaname, s.tablename, s.attname, s.inherited, "
11139 "s.null_frac, s.avg_width, s.n_distinct, "
11140 "s.most_common_vals, s.most_common_freqs, "
11141 "s.histogram_bounds, s.correlation, "
11142 "s.most_common_elems, s.most_common_elem_freqs, "
11143 "s.elem_count_histogram, ");
11144
11145 if (
fout->remoteVersion >= 170000)
11147 "s.range_length_histogram, "
11148 "s.range_empty_frac, "
11149 "s.range_bounds_histogram ");
11150 else
11152 "NULL AS range_length_histogram,"
11153 "NULL AS range_empty_frac,"
11154 "NULL AS range_bounds_histogram ");
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166 if (
fout->remoteVersion >= 190000)
11168 "FROM pg_catalog.pg_stats s "
11169 "JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
11170 "ON s.tableid = u.tableid "
11171 "ORDER BY u.ord, s.attname, s.inherited");
11172 else
11174 "FROM pg_catalog.pg_stats s "
11175 "JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
11176 "ON s.schemaname = u.schemaname "
11177 "AND s.tablename = u.tablename "
11178 "WHERE s.tablename = ANY($2) "
11179 "ORDER BY u.ord, s.attname, s.inherited");
11180
11182
11185 }
11186
11188
11189
11192 fout->remoteVersion);
11200
11201
11202
11203
11204
11205
11206
11207
11208
11211 else
11213
11216
11217 if (
fout->remoteVersion >= 180000)
11219
11221
11222
11224 {
11227 rownum = 0;
11228 }
11229
11247
11248
11249 for (; rownum <
PQntuples(res); rownum++)
11250 {
11252
11253
11256 break;
11257
11260 fout->remoteVersion);
11265
11267 pg_fatal(
"unexpected null attname");
11269
11270
11271
11272
11273
11274
11275 if (
rsinfo->nindAttNames == 0)
11276 {
11279 }
11280 else
11281 {
11282 bool found = false;
11283
11284 for (
int i = 0;
i <
rsinfo->nindAttNames;
i++)
11285 {
11287 {
11290 found = true;
11291 break;
11292 }
11293 }
11294
11295 if (!found)
11297 }
11298
11332 if (
fout->remoteVersion >= 170000)
11333 {
11343 }
11345 }
11346
11349}
11350
11351
11352
11353
11354
11355
11356
11357
11358static void
11360{
11362
11363
11364 if (!
fout->dopt->dumpStatistics)
11365 return;
11366
11369 .namespace = dobj->namespace->dobj.
name,
11370 .description = "STATISTICS DATA",
11371 .section =
rsinfo->section,
11375 .nDeps = dobj->
nDeps));
11376}
11377
11378
11379
11380
11381
11382
11383
11384static void
11387{
11393
11394
11396 return;
11397
11398
11400 return;
11401
11402
11406
11407
11409 return;
11410
11413
11415 {
11418
11419 if (objsubid == 0)
11420 {
11424
11430
11433 .namespace =
tbinfo->dobj.namespace->dobj.name,
11434 .owner =
tbinfo->rolname,
11435 .description = "COMMENT",
11437 .createStmt = query->
data,
11438 .deps = &(
tbinfo->dobj.dumpId),
11439 .nDeps = 1));
11440 }
11442 {
11447
11455
11458 .namespace =
tbinfo->dobj.namespace->dobj.name,
11459 .owner =
tbinfo->rolname,
11460 .description = "COMMENT",
11462 .createStmt = query->
data,
11463 .deps = &(
tbinfo->dobj.dumpId),
11464 .nDeps = 1));
11465 }
11466
11469 }
11470
11473}
11474
11475
11476
11477
11478
11479
11480
11481
11482static int
11484{
11488 int nmatch;
11489
11490
11491
11492
11495 while (low <= high)
11496 {
11497 middle = low + (high - low) / 2;
11498
11501 else if (classoid >
middle->classoid)
11505 else if (objoid >
middle->objoid)
11507 else
11508 break;
11509 }
11510
11511 if (low > high)
11512 {
11514 return 0;
11515 }
11516
11517
11518
11519
11520
11521
11522 nmatch = 1;
11524 {
11525 if (classoid !=
middle[-1].classoid ||
11526 objoid !=
middle[-1].objoid)
11527 break;
11529 nmatch++;
11530 }
11531
11533
11536 {
11537 if (classoid !=
middle->classoid ||
11538 objoid !=
middle->objoid)
11539 break;
11541 nmatch++;
11542 }
11543
11544 return nmatch;
11545}
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559static void
11561{
11568 int ntups;
11571
11573
11575 "FROM pg_catalog.pg_description "
11576 "ORDER BY classoid, objoid, objsubid");
11577
11579
11580
11581
11586
11588
11592
11593 for (
i = 0;
i < ntups;
i++)
11594 {
11596 int subid;
11597
11601
11602
11603 if (dobj ==
NULL ||
11608 continue;
11609
11610
11611
11612
11613
11614
11617 {
11619
11623 }
11624 else
11626
11632 }
11633
11636}
11637
11638
11639
11640
11641
11642
11643
11644static void
11646{
11647
11648
11649
11650
11651
11653
11654
11655 if (dobj->
dump == 0)
11656 return;
11657
11659 {
11662 break;
11665 break;
11668 break;
11671 break;
11674 break;
11677 break;
11680 break;
11683 break;
11686 break;
11689 break;
11692 break;
11695 break;
11698 break;
11701 break;
11704 break;
11707 break;
11710 break;
11714 break;
11717 break;
11720 break;
11723 break;
11726 break;
11729 break;
11732 break;
11735 break;
11738 break;
11741 break;
11744 break;
11747 break;
11749
11750 break;
11753 break;
11756 break;
11759 break;
11762 break;
11765 break;
11768 break;
11771 break;
11774 break;
11777 {
11780
11783 pg_fatal(
"missing metadata for large objects \"%s\"",
11785
11788 .owner =
loinfo->rolname,
11789 .description = "BLOBS",
11792 .nDeps = dobj->
nDeps,
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11806 }
11807 break;
11810 break;
11813 break;
11816 break;
11820 break;
11823 break;
11826 break;
11829 break;
11832
11833 break;
11834 }
11835}
11836
11837
11838
11839
11840
11841static void
11843{
11848
11849
11851 return;
11852
11855
11857
11859 {
11862 }
11863 else
11864 {
11865
11867 "-- *not* dropping schema, since initdb creates it\n");
11869 "-- *not* creating schema, since initdb creates it\n");
11870 }
11871
11875
11880 .description = "SCHEMA",
11882 .createStmt = q->
data,
11883 .dropStmt =
delq->data));
11884
11885
11887 {
11889
11896 }
11897
11902
11907
11909
11912}
11913
11914
11915
11916
11917
11918static void
11920{
11925
11926
11928 return;
11929
11932
11934
11936
11938 {
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11951 }
11952 else
11953 {
11954
11955
11956
11957
11958
11959
11960
11961
11963 int n;
11964
11965 appendPQExpBufferStr(q,
"-- For binary upgrade, create an empty extension and insert objects into it\n");
11966
11967
11968
11969
11970
11971
11973
11975 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
11983
11984
11985
11986
11987
11988
11991 else
11996 else
12000 n = 0;
12002 {
12004
12007 {
12008 if (n++ > 0)
12011 }
12012 }
12015 }
12016
12020 .description = "EXTENSION",
12022 .createStmt = q->
data,
12023 .dropStmt =
delq->data));
12024
12025
12030
12032
12035}
12036
12037
12038
12039
12040
12041static void
12043{
12045
12046
12048 return;
12049
12050
12063 else
12064 pg_log_warning(
"typtype of data type \"%s\" appears to be invalid",
12066}
12067
12068
12069
12070
12071
12072static void
12074{
12080 int num,
12088
12090 {
12091
12093 "PREPARE dumpEnumType(pg_catalog.oid) AS\n"
12094 "SELECT oid, enumlabel "
12095 "FROM pg_catalog.pg_enum "
12096 "WHERE enumtypid = $1 "
12097 "ORDER BY enumsortorder");
12098
12100
12102 }
12103
12105 "EXECUTE dumpEnumType('%u')",
12106 tyinfo->dobj.catId.oid);
12107
12109
12111
12114
12115
12116
12117
12118
12120
12124 false, false);
12125
12128
12130 {
12132
12133
12134 for (
i = 0;
i < num;
i++)
12135 {
12141 }
12142 }
12143
12145
12147 {
12150
12151
12152 for (
i = 0;
i < num;
i++)
12153 {
12156
12160 "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
12161 enum_oid);
12165 }
12166 }
12167
12171 tyinfo->dobj.namespace->dobj.name);
12172
12176 .namespace =
tyinfo->dobj.namespace->dobj.name,
12177 .owner =
tyinfo->rolname,
12178 .description = "TYPE",
12180 .createStmt = q->
data,
12181 .dropStmt =
delq->data));
12182
12183
12188
12193
12197 tyinfo->dobj.namespace->dobj.name,
12199
12206}
12207
12208
12209
12210
12211
12212static void
12214{
12223 char *procname;
12224
12226 {
12227
12229 "PREPARE dumpRangeType(pg_catalog.oid) AS\n");
12230
12232 "SELECT ");
12233
12234 if (
fout->remoteVersion >= 140000)
12236 "pg_catalog.format_type(rngmultitypid, NULL) AS rngmultitype, ");
12237 else
12239 "NULL AS rngmultitype, ");
12240
12242 "pg_catalog.format_type(rngsubtype, NULL) AS rngsubtype, "
12243 "opc.opcname AS opcname, "
12244 "(SELECT nspname FROM pg_catalog.pg_namespace nsp "
12245 " WHERE nsp.oid = opc.opcnamespace) AS opcnsp, "
12246 "opc.opcdefault, "
12247 "CASE WHEN rngcollation = st.typcollation THEN 0 "
12248 " ELSE rngcollation END AS collation, "
12249 "rngcanonical, rngsubdiff "
12250 "FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
12251 " pg_catalog.pg_opclass opc "
12252 "WHERE st.oid = rngsubtype AND opc.oid = rngsubopc AND "
12253 "rngtypid = $1");
12254
12256
12258 }
12259
12261 "EXECUTE dumpRangeType('%u')",
12262 tyinfo->dobj.catId.oid);
12263
12265
12268
12269
12270
12271
12272
12274
12278 false, true);
12279
12282
12285
12289
12290
12292 {
12295
12299 }
12300
12303 {
12305
12306 if (coll)
12309 }
12310
12312 if (
strcmp(procname,
"-") != 0)
12314
12316 if (
strcmp(procname,
"-") != 0)
12318
12320
12324 tyinfo->dobj.namespace->dobj.name);
12325
12329 .namespace =
tyinfo->dobj.namespace->dobj.name,
12330 .owner =
tyinfo->rolname,
12331 .description = "TYPE",
12333 .createStmt = q->
data,
12334 .dropStmt =
delq->data));
12335
12336
12341
12346
12350 tyinfo->dobj.namespace->dobj.name,
12352
12359}
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370static void
12372{
12378
12381
12383
12387 false, false);
12388
12391
12395 tyinfo->dobj.namespace->dobj.name);
12396
12400 .namespace =
tyinfo->dobj.namespace->dobj.name,
12401 .owner =
tyinfo->rolname,
12402 .description = "TYPE",
12404 .createStmt = q->
data,
12405 .dropStmt =
delq->data));
12406
12407
12412
12417
12421 tyinfo->dobj.namespace->dobj.name,
12423
12428}
12429
12430
12431
12432
12433
12434static void
12436{
12444 char *typlen;
12446 char *typoutput;
12447 char *typreceive;
12448 char *typsend;
12452 char *typsubscript;
12461 char *typdelim;
12462 char *typbyval;
12464 char *typstorage;
12468
12470 {
12471
12473 "PREPARE dumpBaseType(pg_catalog.oid) AS\n"
12474 "SELECT typlen, "
12475 "typinput, typoutput, typreceive, typsend, "
12476 "typreceive::pg_catalog.oid AS typreceiveoid, "
12477 "typsend::pg_catalog.oid AS typsendoid, "
12478 "typanalyze, "
12479 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
12480 "typdelim, typbyval, typalign, typstorage, "
12481 "typmodin, typmodout, "
12482 "typmodin::pg_catalog.oid AS typmodinoid, "
12483 "typmodout::pg_catalog.oid AS typmodoutoid, "
12484 "typcategory, typispreferred, "
12485 "(typcollation <> 0) AS typcollatable, "
12486 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault, ");
12487
12488 if (
fout->remoteVersion >= 140000)
12490 "typsubscript, "
12491 "typsubscript::pg_catalog.oid AS typsubscriptoid ");
12492 else
12494 "'-' AS typsubscript, 0 AS typsubscriptoid ");
12495
12497 "WHERE oid = $1");
12498
12500
12502 }
12503
12505 "EXECUTE dumpBaseType('%u')",
12506 tyinfo->dobj.catId.oid);
12507
12509
12535 {
12538 }
12539 else
12541
12544
12545
12546
12547
12548
12549
12551
12552
12553
12554
12555
12559 false, false);
12560
12562 "CREATE TYPE %s (\n"
12563 " INTERNALLENGTH = %s",
12565 (
strcmp(typlen,
"-1") == 0) ?
"variable" : typlen);
12566
12567
12580
12583
12585 {
12589 else
12591 }
12592
12595
12600
12602 {
12605 }
12606
12609
12610 if (typdelim &&
strcmp(typdelim,
",") != 0)
12611 {
12614 }
12615
12624
12633
12634 if (
strcmp(typbyval,
"t") == 0)
12636
12638
12642 tyinfo->dobj.namespace->dobj.name);
12643
12647 .namespace =
tyinfo->dobj.namespace->dobj.name,
12648 .owner =
tyinfo->rolname,
12649 .description = "TYPE",
12651 .createStmt = q->
data,
12652 .dropStmt =
delq->data));
12653
12654
12659
12664
12668 tyinfo->dobj.namespace->dobj.name,
12670
12677}
12678
12679
12680
12681
12682
12683static void
12685{
12699
12701 {
12702
12704 "PREPARE dumpDomain(pg_catalog.oid) AS\n");
12705
12707 "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
12708 "pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
12709 "t.typdefault, "
12710 "CASE WHEN t.typcollation <> u.typcollation "
12711 "THEN t.typcollation ELSE 0 END AS typcollation "
12712 "FROM pg_catalog.pg_type t "
12713 "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
12714 "WHERE t.oid = $1");
12715
12717
12719 }
12720
12722 "EXECUTE dumpDomain('%u')",
12723 tyinfo->dobj.catId.oid);
12724
12726
12732 {
12735 }
12736 else
12739
12743 true,
12744 false);
12745
12748
12750 "CREATE DOMAIN %s AS %s",
12753
12754
12756 {
12758
12760 if (coll)
12762 }
12763
12764
12765
12766
12767
12768
12769
12771 {
12774 else
12775 {
12777
12779 {
12781
12782
12784
12787 else
12791 }
12792 }
12793 }
12794
12796 {
12800 else
12802 }
12803
12805
12806
12807
12808
12809 for (
i = 0;
i <
tyinfo->nDomChecks;
i++)
12810 {
12812
12816 }
12817
12819
12821
12825 tyinfo->dobj.namespace->dobj.name);
12826
12830 .namespace =
tyinfo->dobj.namespace->dobj.name,
12831 .owner =
tyinfo->rolname,
12832 .description = "DOMAIN",
12834 .createStmt = q->
data,
12835 .dropStmt =
delq->data));
12836
12837
12842
12847
12851 tyinfo->dobj.namespace->dobj.name,
12853
12854
12855 for (
i = 0;
i <
tyinfo->nDomChecks;
i++)
12856 {
12859
12860
12862 continue;
12863
12867
12870 tyinfo->dobj.namespace->dobj.name,
12873
12875 }
12876
12877
12878
12879
12880
12882 {
12884
12887
12890 tyinfo->dobj.namespace->dobj.name,
12894 }
12895
12901}
12902
12903
12904
12905
12906
12907
12908static void
12910{
12919 int ntups;
12928
12930 {
12931
12932
12933
12934
12935
12936
12937
12938
12940 "PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
12941 "SELECT a.attname, a.attnum, "
12942 "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
12943 "a.attlen, a.attalign, a.attisdropped, "
12944 "CASE WHEN a.attcollation <> at.typcollation "
12945 "THEN a.attcollation ELSE 0 END AS attcollation "
12946 "FROM pg_catalog.pg_type ct "
12947 "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
12948 "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
12949 "WHERE ct.oid = $1 "
12950 "ORDER BY a.attnum");
12951
12953
12955 }
12956
12958 "EXECUTE dumpCompositeType('%u')",
12959 tyinfo->dobj.catId.oid);
12960
12962
12964
12971
12973 {
12976 false, false);
12978 }
12979
12982
12985
12987 for (
i = 0;
i < ntups;
i++)
12988 {
12993 bool attisdropped;
12995
13002
13004 continue;
13005
13006
13010
13011 if (!attisdropped)
13012 {
13014
13015
13017 {
13019
13021 if (coll)
13024 }
13025 }
13026 else
13027 {
13028
13029
13030
13031
13032
13033
13035
13036
13038 "\n-- For binary upgrade, recreate dropped column.\n");
13040 "SET attlen = %s, "
13041 "attalign = '%s', attbyval = false\n"
13047
13052 }
13053 }
13056
13058
13062 tyinfo->dobj.namespace->dobj.name);
13063
13067 .namespace =
tyinfo->dobj.namespace->dobj.name,
13068 .owner =
tyinfo->rolname,
13069 .description = "TYPE",
13071 .createStmt = q->
data,
13072 .dropStmt =
delq->data));
13073
13074
13075
13080
13085
13089 tyinfo->dobj.namespace->dobj.name,
13091
13092
13095
13103}
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114static void
13117{
13123 int ntups;
13127
13128
13129 if (
fout->dopt->no_comments)
13130 return;
13131
13132
13135
13136
13138 return;
13139
13140
13143
13149 {
13151
13153 for (
i = 0;
i < ntups;
i++)
13154 {
13157 {
13159 break;
13160 }
13161 }
13163 {
13165
13170
13177
13180 .namespace =
tyinfo->dobj.namespace->dobj.name,
13181 .owner =
tyinfo->rolname,
13182 .description = "COMMENT",
13184 .createStmt = query->
data,
13185 .deps = &(
tyinfo->dobj.dumpId),
13186 .nDeps = 1));
13187 }
13188
13191 }
13192
13195}
13196
13197
13198
13199
13200
13201
13202
13203static void
13205{
13208
13209
13211 return;
13212
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13226 stinfo->baseType->dobj.catId.oid,
13227 false, false);
13228
13231
13235 .namespace =
stinfo->dobj.namespace->dobj.name,
13236 .owner =
stinfo->baseType->rolname,
13237 .description = "SHELL TYPE",
13239 .createStmt = q->
data));
13240
13242}
13243
13244
13245
13246
13247
13248
13249static void
13251{
13260
13261
13263 return;
13264
13265
13266
13267
13268
13269
13270
13271
13272
13276
13278 {
13282 }
13283
13285 {
13289 }
13290
13291
13292
13293
13294
13295
13299
13302
13304
13307
13309 {
13311 plang->lanpltrusted ?
"TRUSTED " :
"",
13321 }
13322 else
13323 {
13324
13325
13326
13327
13328
13329
13330
13331
13332
13335 }
13337
13341
13345 .owner =
plang->lanowner,
13346 .description = "PROCEDURAL LANGUAGE",
13348 .createStmt =
defqry->data,
13349 .dropStmt =
delqry->data,
13350 ));
13351
13352
13357
13362
13367
13369
13372}
13373
13374
13375
13376
13377
13378
13379
13380
13381static char *
13383{
13385
13390 else
13393}
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404static char *
13406{
13409
13413 else
13415 for (
j = 0;
j < finfo->
nargs;
j++)
13416 {
13419
13423 }
13426}
13427
13428
13429
13430
13431
13432
13433static void
13435{
13447 char *prosrc;
13454 char *prokind;
13467 const char *keyword;
13468
13469
13471 return;
13472
13477
13479 {
13480
13482 "PREPARE dumpFunc(pg_catalog.oid) AS\n");
13483
13485 "SELECT\n"
13486 "proretset,\n"
13487 "prosrc,\n"
13488 "probin,\n"
13489 "provolatile,\n"
13490 "proisstrict,\n"
13491 "prosecdef,\n"
13492 "lanname,\n"
13493 "proconfig,\n"
13494 "procost,\n"
13495 "prorows,\n"
13496 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
13497 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
13498 "pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
13499 "proleakproof,\n");
13500
13502 "array_to_string(protrftypes, ' ') AS protrftypes,\n");
13503
13505 "proparallel,\n");
13506
13507 if (
fout->remoteVersion >= 110000)
13509 "prokind,\n");
13510 else
13512 "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n");
13513
13514 if (
fout->remoteVersion >= 120000)
13516 "prosupport,\n");
13517 else
13519 "'-' AS prosupport,\n");
13520
13521 if (
fout->remoteVersion >= 140000)
13523 "pg_get_function_sqlbody(p.oid) AS prosqlbody\n");
13524 else
13526 "NULL AS prosqlbody\n");
13527
13529 "FROM pg_catalog.pg_proc p, pg_catalog.pg_language l\n"
13530 "WHERE p.oid = $1 "
13531 "AND l.oid = p.prolang");
13532
13534
13536 }
13537
13539 "EXECUTE dumpFunc('%u')",
13541
13543
13546 {
13550 }
13551 else
13552 {
13556 }
13572
13573
13574
13575
13576
13578 {
13580 }
13581 else if (
probin[0] !=
'\0')
13582 {
13585 if (prosrc[0] != '\0')
13586 {
13588
13589
13590
13591
13592
13596 else
13598 }
13599 }
13600 else
13601 {
13603
13606 else
13608 }
13609
13611 {
13613 pg_fatal(
"could not parse %s array",
"proconfig");
13614 }
13615 else
13616 {
13619 }
13620
13623
13625
13629
13631 keyword = "PROCEDURE";
13632 else
13633 keyword = "FUNCTION";
13634
13637
13639 keyword,
13643
13645 ;
13648 else
13653
13655
13657 {
13660
13664 {
13669 }
13670
13672 }
13673
13676
13678 {
13684 pg_fatal(
"unrecognized provolatile value for function \"%s\"",
13686 }
13687
13690
13693
13696
13697
13698
13699
13700
13701
13703 {
13705 {
13706
13709 }
13710 else
13711 {
13712
13715 }
13716 }
13720
13722 {
13723
13725 }
13726
13728 {
13734 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
13736 }
13737
13739 {
13740
13742 char *pos;
13743
13746 continue;
13747 *pos++ = '\0';
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13767 {
13770
13771
13772
13774 {
13775
13779 {
13783 }
13784 }
13786 }
13787 else
13789 }
13790
13792
13794 "pg_catalog.pg_proc", keyword,
13796
13800 finfo->
dobj.namespace->dobj.
name);
13801
13805 .
namespace = finfo->
dobj.namespace->dobj.
name,
13807 .description = keyword,
13810 .createStmt = q->
data,
13812
13813
13818
13823
13829
13831
13841}
13842
13843
13844
13845
13846
13847static void
13849{
13858
13859
13861 return;
13862
13863
13865 {
13868 pg_fatal(
"could not find function definition for function with OID %u",
13870 }
13871
13876
13881
13884
13885 switch (
cast->castmethod)
13886 {
13889 break;
13892 break;
13895 {
13897
13898
13899
13900
13901
13905 }
13906 else
13907 pg_log_warning(
"bogus value in pg_cast.castfunc or pg_cast.castmethod field");
13908 break;
13909 default:
13911 }
13912
13913 if (
cast->castcontext ==
'a')
13915 else if (
cast->castcontext ==
'i')
13918
13921
13924
13928
13932 .description = "CAST",
13934 .createStmt =
defqry->data,
13935 .dropStmt =
delqry->data));
13936
13937
13941 cast->dobj.catId, 0,
cast->dobj.dumpId);
13942
13947}
13948
13949
13950
13951
13952static void
13954{
13964
13965
13967 return;
13968
13969
13971 {
13974 pg_fatal(
"could not find function definition for function with OID %u",
13976 }
13978 {
13981 pg_fatal(
"could not find function definition for function with OID %u",
13983 }
13984
13989
13992
13995
13998
14000 pg_log_warning(
"bogus transform definition, at least one of trffromsql and trftosql should be nonzero");
14001
14003 {
14005 {
14007
14008
14009
14010
14011
14015 }
14016 else
14018 }
14019
14021 {
14024
14026 {
14028
14029
14030
14031
14032
14036 }
14037 else
14039 }
14040
14042
14045
14048
14052
14056 .description = "TRANSFORM",
14058 .createStmt =
defqry->data,
14059 .dropStmt =
delqry->data,
14062
14063
14068
14074}
14075
14076
14077
14078
14079
14080
14081static void
14083{
14101 char *oprkind;
14102 char *oprcode;
14103 char *oprleft;
14104 char *oprright;
14113
14114
14116 return;
14117
14118
14119
14120
14121
14123 return;
14124
14130
14132 {
14133
14135 "PREPARE dumpOpr(pg_catalog.oid) AS\n"
14136 "SELECT oprkind, "
14137 "oprcode::pg_catalog.regprocedure, "
14138 "oprleft::pg_catalog.regtype, "
14139 "oprright::pg_catalog.regtype, "
14140 "oprcom, "
14141 "oprnegate, "
14142 "oprrest::pg_catalog.regprocedure, "
14143 "oprjoin::pg_catalog.regprocedure, "
14144 "oprcanmerge, oprcanhash "
14145 "FROM pg_catalog.pg_operator "
14146 "WHERE oid = $1");
14147
14149
14151 }
14152
14154 "EXECUTE dumpOpr('%u')",
14156
14158
14169
14180
14181
14182 if (
strcmp(oprkind,
"r") == 0)
14183 pg_log_warning(
"postfix operators are not supported anymore (operator \"%s\")",
14184 oprcode);
14185
14188 {
14191 }
14192
14195
14196
14197
14198
14199
14200
14201 if (
strcmp(oprkind,
"r") == 0 ||
14202 strcmp(oprkind,
"b") == 0)
14203 {
14206 }
14207 else
14209
14210 if (
strcmp(oprkind,
"l") == 0 ||
14211 strcmp(oprkind,
"b") == 0)
14212 {
14215 }
14216 else
14218
14221 {
14224 }
14225
14228 {
14231 }
14232
14235
14238
14241 {
14244 }
14245
14248 {
14251 }
14252
14256
14260
14263 "OPERATOR",
oprid->data,
14264 oprinfo->dobj.namespace->dobj.name);
14265
14269 .namespace =
oprinfo->dobj.namespace->dobj.name,
14271 .description = "OPERATOR",
14273 .createStmt = q->
data,
14274 .dropStmt =
delq->data));
14275
14276
14281
14283
14289}
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300static char *
14302{
14306
14307
14308 if (
strcmp(proc,
"-") == 0)
14310
14312
14315 {
14317 {
14319 break;
14320 }
14323 }
14325}
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341static char *
14343{
14345
14346
14349
14352 {
14356 }
14357
14358 return psprintf(
"OPERATOR(%s.%s)",
14361}
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371static char *
14373{
14375 char query[128];
14377
14379 "SELECT '%u'::pg_catalog.regproc", funcOid);
14381
14383
14385
14387}
14388
14389
14390
14391
14392
14393static void
14395{
14400
14401
14403 return;
14404
14407
14409
14411
14413 {
14416 break;
14419 break;
14420 default:
14426 return;
14427 }
14428
14430
14433
14437
14441 .description = "ACCESS METHOD",
14443 .createStmt = q->
data,
14444 .dropStmt =
delq->data));
14445
14446
14451
14455}
14456
14457
14458
14459
14460
14461static void
14463{
14470 int ntups;
14486 char *opcintype;
14489 char *opcfamily;
14492 char *amname;
14495 char *sortfamily;
14503
14504
14506 return;
14507
14512
14513
14515 "opckeytype::pg_catalog.regtype, "
14516 "opcdefault, opcfamily, "
14517 "opfname AS opcfamilyname, "
14518 "nspname AS opcfamilynsp, "
14519 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS amname "
14520 "FROM pg_catalog.pg_opclass c "
14521 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily "
14522 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14523 "WHERE c.oid = '%u'::pg_catalog.oid",
14525
14527
14535
14536
14540
14544
14546
14551
14552
14558 opcintype,
14561 {
14565 }
14567
14569
14571 {
14575 }
14576
14578
14579
14580
14581
14582
14583
14584
14587 "amopopr::pg_catalog.regoperator, "
14588 "opfname AS sortfamily, "
14589 "nspname AS sortfamilynsp "
14590 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14591 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14592 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14593 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14594 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14595 "AND refobjid = '%u'::pg_catalog.oid "
14596 "AND amopfamily = '%s'::pg_catalog.oid "
14597 "ORDER BY amopstrategy",
14599 opcfamily);
14600
14602
14604
14609
14610 for (
i = 0;
i < ntups;
i++)
14611 {
14616
14619
14622
14623 if (
strlen(sortfamily) > 0)
14624 {
14628 }
14629
14631 }
14632
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14646
14648 "amproc::pg_catalog.regprocedure, "
14649 "amproclefttype::pg_catalog.regtype, "
14650 "amprocrighttype::pg_catalog.regtype "
14651 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14652 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14653 "AND refobjid = '%u'::pg_catalog.oid "
14654 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14655 "AND objid = ap.oid "
14656 "ORDER BY amprocnum",
14658
14660
14662
14667
14668 for (
i = 0;
i < ntups;
i++)
14669 {
14674
14677
14679
14682
14684
14686 }
14687
14689
14690
14691
14692
14693
14694
14695
14698
14700
14704
14708 opcinfo->dobj.namespace->dobj.name);
14709
14713 .namespace =
opcinfo->dobj.namespace->dobj.name,
14715 .description = "OPERATOR CLASS",
14717 .createStmt = q->
data,
14718 .dropStmt =
delq->data));
14719
14720
14725
14733}
14734
14735
14736
14737
14738
14739
14740
14741
14742static void
14744{
14753 int ntups;
14763 char *amname;
14766 char *sortfamily;
14774
14775
14777 return;
14778
14783
14784
14785
14786
14787
14789 "amopopr::pg_catalog.regoperator, "
14790 "opfname AS sortfamily, "
14791 "nspname AS sortfamilynsp "
14792 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14793 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14794 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14795 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14796 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14797 "AND refobjid = '%u'::pg_catalog.oid "
14798 "AND amopfamily = '%u'::pg_catalog.oid "
14799 "ORDER BY amopstrategy",
14802
14804
14806
14808 "amproc::pg_catalog.regprocedure, "
14809 "amproclefttype::pg_catalog.regtype, "
14810 "amprocrighttype::pg_catalog.regtype "
14811 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14812 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14813 "AND refobjid = '%u'::pg_catalog.oid "
14814 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14815 "AND objid = ap.oid "
14816 "ORDER BY amprocnum",
14818
14820
14821
14823
14825 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opfmethod) AS amname "
14826 "FROM pg_catalog.pg_opfamily "
14827 "WHERE oid = '%u'::pg_catalog.oid",
14829
14831
14833
14834
14836
14841
14842
14847
14849
14850
14852 {
14857
14859
14860
14861
14862
14864
14869
14870 for (
i = 0;
i < ntups;
i++)
14871 {
14876
14879
14882
14883 if (
strlen(sortfamily) > 0)
14884 {
14888 }
14889
14891 }
14892
14893
14894
14895
14897
14902
14903 for (
i = 0;
i < ntups;
i++)
14904 {
14909
14912
14916
14918 }
14919
14921 }
14922
14926
14930 opfinfo->dobj.namespace->dobj.name);
14931
14935 .namespace =
opfinfo->dobj.namespace->dobj.name,
14937 .description = "OPERATOR FAMILY",
14939 .createStmt = q->
data,
14940 .dropStmt =
delq->data));
14941
14942
14947
14955}
14956
14957
14958
14959
14960
14961static void
14963{
14981
14982
14984 return;
14985
14989
14991
14992
14994
14996 "collprovider, "
14997 "collversion, ");
14998
14999 if (
fout->remoteVersion >= 120000)
15001 "collisdeterministic, ");
15002 else
15004 "true AS collisdeterministic, ");
15005
15006 if (
fout->remoteVersion >= 170000)
15008 "colllocale, ");
15009 else if (
fout->remoteVersion >= 150000)
15011 "colliculocale AS colllocale, ");
15012 else
15014 "NULL AS colllocale, ");
15015
15016 if (
fout->remoteVersion >= 160000)
15018 "collicurules, ");
15019 else
15021 "NULL AS collicurules, ");
15022
15024 "collcollate, "
15025 "collctype "
15026 "FROM pg_catalog.pg_collation c "
15027 "WHERE c.oid = '%u'::pg_catalog.oid",
15029
15031
15038
15040
15043 else
15045
15048 else
15050
15051
15052
15053
15054
15055 if (
fout->remoteVersion < 150000)
15056 {
15061 }
15062
15065 else
15067
15070 else
15072
15075
15078
15087
15089 else
15090 pg_fatal(
"unrecognized collation provider: %s",
15092
15095
15097 {
15100
15101
15102 }
15104 {
15107
15111 }
15113 {
15114 if (
fout->remoteVersion >= 150000)
15115 {
15118
15122 }
15123 else
15124 {
15128
15131 }
15132
15134 {
15137 }
15138 }
15140 {
15143
15145 {
15148 }
15149 else
15150 {
15155 }
15156 }
15157 else
15159
15160
15161
15162
15163
15165 {
15167
15170 {
15175 }
15176 }
15177
15179
15183 collinfo->dobj.namespace->dobj.name);
15184
15188 .namespace =
collinfo->dobj.namespace->dobj.name,
15190 .description = "COLLATION",
15192 .createStmt = q->
data,
15193 .dropStmt =
delq->data));
15194
15195
15200
15202
15207}
15208
15209
15210
15211
15212
15213static void
15215{
15230
15231
15233 return;
15234
15238
15240
15241
15243 "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
15244 "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
15245 "conproc, condefault "
15246 "FROM pg_catalog.pg_conversion c "
15247 "WHERE c.oid = '%u'::pg_catalog.oid",
15249
15251
15256
15261
15264
15271
15273
15277 convinfo->dobj.namespace->dobj.name);
15278
15282 .namespace =
convinfo->dobj.namespace->dobj.name,
15284 .description = "CONVERSION",
15286 .createStmt = q->
data,
15287 .dropStmt =
delq->data));
15288
15289
15294
15296
15301}
15302
15303
15304
15305
15306
15307
15308
15309static char *
15311{
15314
15318 else
15320
15321 if (
agginfo->aggfn.nargs == 0)
15323 else
15324 {
15328 (
j > 0) ?
", " :
"",
15333 }
15335}
15336
15337
15338
15339
15340
15341static void
15343{
15367 const char *aggsortop;
15370 const char *aggtranstype;
15371 const char *aggtransspace;
15378
15379
15381 return;
15382
15387
15389 {
15390
15392 "PREPARE dumpAgg(pg_catalog.oid) AS\n");
15393
15395 "SELECT "
15396 "aggtransfn,\n"
15397 "aggfinalfn,\n"
15398 "aggtranstype::pg_catalog.regtype,\n"
15399 "agginitval,\n"
15400 "aggsortop,\n"
15401 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
15402 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
15403
15405 "aggkind,\n"
15406 "aggmtransfn,\n"
15407 "aggminvtransfn,\n"
15408 "aggmfinalfn,\n"
15409 "aggmtranstype::pg_catalog.regtype,\n"
15410 "aggfinalextra,\n"
15411 "aggmfinalextra,\n"
15412 "aggtransspace,\n"
15413 "aggmtransspace,\n"
15414 "aggminitval,\n");
15415
15417 "aggcombinefn,\n"
15418 "aggserialfn,\n"
15419 "aggdeserialfn,\n"
15420 "proparallel,\n");
15421
15422 if (
fout->remoteVersion >= 110000)
15424 "aggfinalmodify,\n"
15425 "aggmfinalmodify\n");
15426 else
15428 "'0' AS aggfinalmodify,\n"
15429 "'0' AS aggmfinalmodify\n");
15430
15432 "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
15433 "WHERE a.aggfnoid = p.oid "
15434 "AND p.oid = $1");
15435
15437
15439 }
15440
15442 "EXECUTE dumpAgg('%u')",
15443 agginfo->aggfn.dobj.catId.oid);
15444
15446
15449
15471
15472 {
15475
15480 }
15481
15483
15484
15486
15491
15492
15495
15496 if (
strcmp(aggtransspace,
"0") != 0)
15497 {
15499 aggtransspace);
15500 }
15501
15503 {
15506 }
15507
15509 {
15515 {
15517 {
15520 break;
15523 break;
15526 break;
15527 default:
15528 pg_fatal(
"unrecognized aggfinalmodify value for aggregate \"%s\"",
15530 break;
15531 }
15532 }
15533 }
15534
15537
15540
15543
15545 {
15550 }
15551
15553 {
15556 }
15557
15559 {
15562 }
15563
15565 {
15571 {
15573 {
15576 break;
15579 break;
15582 break;
15583 default:
15584 pg_fatal(
"unrecognized aggmfinalmodify value for aggregate \"%s\"",
15586 break;
15587 }
15588 }
15589 }
15590
15593 {
15597 }
15598
15601
15603 {
15609 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
15611 }
15612
15616
15620
15624 agginfo->aggfn.dobj.namespace->dobj.name);
15625
15630 .
namespace =
agginfo->aggfn.dobj.namespace->dobj.name,
15631 .owner =
agginfo->aggfn.rolname,
15632 .description = "AGGREGATE",
15634 .createStmt = q->
data,
15635 .dropStmt =
delq->data));
15636
15637
15640 agginfo->aggfn.dobj.namespace->dobj.name,
15643
15646 agginfo->aggfn.dobj.namespace->dobj.name,
15649
15650
15651
15652
15653
15654
15656
15658
15662 agginfo->aggfn.dobj.namespace->dobj.name,
15664
15668
15670
15675}
15676
15677
15678
15679
15680
15681static void
15683{
15688
15689
15691 return;
15692
15695
15697
15700
15712
15715
15719 prsinfo->dobj.namespace->dobj.name);
15720
15724 .namespace =
prsinfo->dobj.namespace->dobj.name,
15725 .description = "TEXT SEARCH PARSER",
15727 .createStmt = q->
data,
15728 .dropStmt =
delq->data));
15729
15730
15733 prsinfo->dobj.namespace->dobj.name,
"",
15735
15739}
15740
15741
15742
15743
15744
15745static void
15747{
15754 char *nspname;
15756
15757
15759 return;
15760
15764
15766
15767
15769 "FROM pg_ts_template p, pg_namespace n "
15770 "WHERE p.oid = '%u' AND n.oid = tmplnamespace",
15775
15778
15782
15784
15785
15788
15790
15793
15797 dictinfo->dobj.namespace->dobj.name);
15798
15802 .namespace =
dictinfo->dobj.namespace->dobj.name,
15804 .description = "TEXT SEARCH DICTIONARY",
15806 .createStmt = q->
data,
15807 .dropStmt =
delq->data));
15808
15809
15814
15819}
15820
15821
15822
15823
15824
15825static void
15827{
15832
15833
15835 return;
15836
15839
15841
15844
15850
15853
15857 tmplinfo->dobj.namespace->dobj.name);
15858
15862 .namespace =
tmplinfo->dobj.namespace->dobj.name,
15863 .description = "TEXT SEARCH TEMPLATE",
15865 .createStmt = q->
data,
15866 .dropStmt =
delq->data));
15867
15868
15871 tmplinfo->dobj.namespace->dobj.name,
"",
15873
15877}
15878
15879
15880
15881
15882
15883static void
15885{
15892 char *nspname;
15894 int ntups,
15898
15899
15901 return;
15902
15906
15908
15909
15911 "FROM pg_ts_parser p, pg_namespace n "
15912 "WHERE p.oid = '%u' AND n.oid = prsnamespace",
15917
15920
15923
15925
15928 "SELECT\n"
15929 " ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
15930 " WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
15931 " m.mapdict::pg_catalog.regdictionary AS dictname\n"
15932 "FROM pg_catalog.pg_ts_config_map AS m\n"
15933 "WHERE m.mapcfg = '%u'\n"
15934 "ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
15936
15939
15942
15943 for (
i = 0;
i < ntups;
i++)
15944 {
15947
15950 {
15951
15956
15959 }
15960 else
15962 }
15963
15964 if (ntups > 0)
15966
15968
15971
15974 "TEXT SEARCH CONFIGURATION",
qcfgname,
15975 cfginfo->dobj.namespace->dobj.name);
15976
15980 .namespace =
cfginfo->dobj.namespace->dobj.name,
15982 .description = "TEXT SEARCH CONFIGURATION",
15984 .createStmt = q->
data,
15985 .dropStmt =
delq->data));
15986
15987
15992
15997}
15998
15999
16000
16001
16002
16003static void
16005{
16010
16011
16013 return;
16014
16017
16019
16022
16025
16028
16031
16034
16036
16039
16044
16049 .description = "FOREIGN DATA WRAPPER",
16051 .createStmt = q->
data,
16052 .dropStmt =
delq->data));
16053
16054
16059
16060
16065
16067
16070}
16071
16072
16073
16074
16075
16076static void
16078{
16085 char *fdwname;
16086
16087
16089 return;
16090
16094
16096
16097
16099 "FROM pg_foreign_data_wrapper w "
16100 "WHERE w.oid = '%u'",
16104
16107 {
16110 }
16112 {
16115 }
16116
16119
16122
16124
16127
16131
16136 .description = "SERVER",
16138 .createStmt = q->
data,
16139 .dropStmt =
delq->data));
16140
16141
16146
16147
16152
16153
16159
16161
16163
16167}
16168
16169
16170
16171
16172
16173
16174
16175
16176static void
16178 const char *servername, const char *namespace,
16179 const char *owner,
16181{
16187 int ntups;
16191
16196
16197
16198
16199
16200
16201
16202
16203
16204
16206 "SELECT usename, "
16207 "array_to_string(ARRAY("
16208 "SELECT quote_ident(option_name) || ' ' || "
16209 "quote_literal(option_value) "
16210 "FROM pg_options_to_table(umoptions) "
16211 "ORDER BY option_name"
16212 "), E',\n ') AS umoptions "
16213 "FROM pg_user_mappings "
16214 "WHERE srvid = '%u' "
16215 "ORDER BY usename",
16217
16219
16223
16224 for (
i = 0;
i < ntups;
i++)
16225 {
16228
16231
16235
16238
16240
16244
16248
16251 .namespace = namespace,
16252 .owner = owner,
16253 .description = "USER MAPPING",
16255 .createStmt = q->
data,
16256 .dropStmt =
delq->data));
16257 }
16258
16260
16265}
16266
16267
16268
16269
16270static void
16272{
16277
16278
16280 return;
16281
16284
16286 {
16289 break;
16291 type =
"SEQUENCES";
16292 break;
16294 type =
"FUNCTIONS";
16295 break;
16298 break;
16301 break;
16303 type =
"LARGE OBJECTS";
16304 break;
16305 default:
16306
16307 pg_fatal(
"unrecognized object type in default privileges: %d",
16310 }
16311
16313
16314
16321 fout->remoteVersion,
16322 q))
16323 pg_fatal(
"could not parse default ACL list (%s)",
16325
16329 .namespace =
daclinfo->dobj.namespace ?
16334 .createStmt = q->
data));
16335
16338}
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16365 const char *nspname, const char *tag, const char *owner,
16367{
16370 const char *
acls = dacl->
acl;
16373 const char *initprivs = dacl->
initprivs;
16376
16377
16380
16381
16384
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16401 initprivs && *initprivs != '\0')
16402 {
16406 "",
fout->remoteVersion, sql))
16407 pg_fatal(
"could not parse initial ACL list (%s) or default (%s) for object \"%s\" (%s)",
16409 appendPQExpBufferStr(sql,
"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
16410 }
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420 if (initprivs && *initprivs != '\0')
16421 {
16425 }
16426 else
16428
16431 "",
fout->remoteVersion, sql))
16432 pg_fatal(
"could not parse ACL list (%s) or default (%s) for object \"%s\" (%s)",
16434
16436 {
16439 int nDeps = 0;
16440
16441 if (tag)
16445 else
16447
16451
16453
16456 .namespace = nspname,
16457 .owner = owner,
16458 .description = "ACL",
16460 .createStmt = sql->
data,
16462 .nDeps = nDeps));
16463
16465 }
16466
16468
16470}
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490static void
16492 const char *namespace, const char *owner,
16494{
16500
16501
16503 return;
16504
16505
16506
16507
16508
16510 {
16512 return;
16513 }
16514 else
16515 {
16516
16518 return;
16519 }
16520
16521
16523
16525
16527 {
16528
16529
16530
16531 if (labels[
i].objsubid != subid)
16532 continue;
16533
16535 "SECURITY LABEL FOR %s ON %s ",
16537 if (namespace && *namespace)
16542 }
16543
16544 if (query->
len > 0)
16545 {
16547
16551 .namespace = namespace,
16552 .owner = owner,
16553 .description = "SECURITY LABEL",
16555 .createStmt = query->
data,
16556 .deps = &dumpId,
16557 .nDeps = 1));
16559 }
16560
16562}
16563
16564
16565
16566
16567
16568
16569
16570static void
16572{
16579
16580
16582 return;
16583
16584
16586 return;
16587
16588
16591 &labels);
16592
16593
16595 return;
16596
16599
16601 {
16602 const char *colname;
16606
16608 if (objsubid == 0)
16609 {
16612 }
16613 else
16614 {
16616
16620 }
16625 }
16626 if (query->
len > 0)
16627 {
16633 .namespace =
tbinfo->dobj.namespace->dobj.name,
16634 .owner =
tbinfo->rolname,
16635 .description = "SECURITY LABEL",
16637 .createStmt = query->
data,
16638 .deps = &(
tbinfo->dobj.dumpId),
16639 .nDeps = 1));
16640 }
16643}
16644
16645
16646
16647
16648
16649
16650
16651
16652static int
16654{
16658 int nmatch;
16659
16661 {
16663 return 0;
16664 }
16665
16666
16667
16668
16671 while (low <= high)
16672 {
16673 middle = low + (high - low) / 2;
16674
16677 else if (classoid >
middle->classoid)
16681 else if (objoid >
middle->objoid)
16683 else
16684 break;
16685 }
16686
16687 if (low > high)
16688 {
16690 return 0;
16691 }
16692
16693
16694
16695
16696
16697
16698 nmatch = 1;
16700 {
16701 if (classoid !=
middle[-1].classoid ||
16702 objoid !=
middle[-1].objoid)
16703 break;
16705 nmatch++;
16706 }
16707
16709
16712 {
16713 if (classoid !=
middle->classoid ||
16714 objoid !=
middle->objoid)
16715 break;
16717 nmatch++;
16718 }
16719
16720 return nmatch;
16721}
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731static void
16733{
16741 int ntups;
16744
16746
16748 "SELECT label, provider, classoid, objoid, objsubid "
16749 "FROM pg_catalog.pg_seclabels "
16750 "ORDER BY classoid, objoid, objsubid");
16751
16753
16754
16760
16762
16766
16767 for (
i = 0;
i < ntups;
i++)
16768 {
16770 int subid;
16771
16775
16776
16777 if (dobj ==
NULL ||
16782 continue;
16783
16784
16785
16786
16787
16788
16791 {
16793
16797 }
16798 else
16800
16807 }
16808
16811}
16812
16813
16814
16815
16816
16817static void
16819{
16823
16824
16826 return;
16827
16829 {
16832 else
16834 }
16835
16836
16839 {
16840 const char *objtype;
16841
16842 switch (
tbinfo->relkind)
16843 {
16845 objtype = "SEQUENCE";
16846 break;
16848 objtype = "PROPERTY GRAPH";
16849 break;
16850 default:
16851 objtype = "TABLE";
16852 break;
16853 }
16854
16858 tbinfo->dobj.namespace->dobj.name,
16860 }
16861
16862
16863
16864
16865
16866
16867
16869 {
16873
16875 {
16876
16878 "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16891 "SELECT at.attname, "
16892 "at.attacl, "
16893 "'{}' AS acldefault, "
16894 "pip.privtype, pip.initprivs "
16895 "FROM pg_catalog.pg_attribute at "
16896 "LEFT JOIN pg_catalog.pg_init_privs pip ON "
16897 "(at.attrelid = pip.objoid "
16898 "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
16899 "AND at.attnum = pip.objsubid) "
16900 "WHERE at.attrelid = $1 AND "
16901 "NOT at.attisdropped "
16902 "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
16903 "ORDER BY at.attnum");
16904
16906
16908 }
16909
16911 "EXECUTE getColumnACLs('%u')",
16912 tbinfo->dobj.catId.oid);
16913
16915
16917 {
16925
16929 coldacl.initprivs = initprivs;
16931
16932
16933
16934
16935
16936
16939 tbinfo->dobj.namespace->dobj.name,
16942 }
16945 }
16946
16948}
16949
16950
16951
16952
16953
16954
16955
16958{
16963
16964
16966 "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
16967 tbinfo->dobj.catId.oid);
16968
16970
16972 {
16974 pg_fatal(
"query to obtain definition of view \"%s\" returned no data",
16976 else
16977 pg_fatal(
"query to obtain definition of view \"%s\" returned more than one definition",
16979 }
16980
16982
16984 pg_fatal(
"definition of view \"%s\" appears to be empty (length zero)",
16986
16987
16990
16993
16995}
16996
16997
16998
16999
17000
17001
17002
17003
17004
17007{
17010
17012
17014 {
17018
17020
17021
17022
17023
17024
17026 {
17028
17030 if (coll)
17033 }
17034
17036 }
17037
17039}
17040
17041
17042
17043
17044
17045static void
17047{
17054 int numParents;
17060 k;
17061
17062
17064
17067
17069 pg_log_warning(
"WITH OIDS is not supported anymore (table \"%s\")",
17071
17074
17075
17077 {
17079
17080
17081
17082
17083
17085
17088 tbinfo->dobj.catId.oid);
17089
17091
17094 else
17095 {
17097 {
17101 }
17103 }
17106
17110 }
17112 {
17116
17118
17121 tbinfo->dobj.catId.oid);
17122
17124 "SELECT pg_catalog.pg_get_propgraphdef('%u'::pg_catalog.oid) AS pgdef",
17125 tbinfo->dobj.catId.oid);
17126
17128
17130 {
17132 pg_fatal(
"query to obtain definition of property graph \"%s\" returned no data",
17134 else
17135 pg_fatal(
"query to obtain definition of property graph \"%s\" returned more than one definition",
17137 }
17138
17140
17142 pg_fatal(
"definition of property graph \"%s\" appears to be empty (length zero)",
17144
17146
17149
17151 }
17152 else
17153 {
17158
17159
17160
17161
17162
17163 switch (
tbinfo->relkind)
17164 {
17166 {
17169
17171
17172
17174 "SELECT pg_get_partkeydef('%u')",
17175 tbinfo->dobj.catId.oid);
17180 break;
17181 }
17183 {
17188
17190
17191
17193 "SELECT fs.srvname, "
17194 "pg_catalog.array_to_string(ARRAY("
17195 "SELECT pg_catalog.quote_ident(option_name) || "
17196 "' ' || pg_catalog.quote_literal(option_value) "
17197 "FROM pg_catalog.pg_options_to_table(ftoptions) "
17198 "ORDER BY option_name"
17199 "), E',\n ') AS ftoptions "
17200 "FROM pg_catalog.pg_foreign_table ft "
17201 "JOIN pg_catalog.pg_foreign_server fs "
17202 "ON (fs.oid = ft.ftserver) "
17203 "WHERE ft.ftrelid = '%u'",
17204 tbinfo->dobj.catId.oid);
17212
17214 break;
17215 }
17218 break;
17219 default:
17221 break;
17222 }
17223
17224 numParents =
tbinfo->numParents;
17226
17229 tbinfo->dobj.catId.oid);
17230
17231
17232
17233
17234
17238 "UNLOGGED " : "",
17241
17242
17243
17244
17245
17250
17252 {
17253
17256 {
17257
17258
17259
17260
17261
17262
17264 {
17267
17268
17269
17270
17271
17273 tbinfo->attrdefs[
j]->dobj.dump &&
17274 !
tbinfo->attrdefs[
j]->separate);
17275
17276
17277
17278
17279
17280
17282 (
tbinfo->notnull_islocal[
j] ||
17285
17286
17287
17288
17289
17293 continue;
17294
17295
17298 else
17302
17303
17305
17307 {
17308
17309
17310
17311
17312
17313
17315
17316 continue;
17317 }
17318
17319
17320
17321
17322
17323
17325 {
17328 }
17329
17331 {
17334 tbinfo->attrdefs[
j]->adef_expr);
17337 tbinfo->attrdefs[
j]->adef_expr);
17338 else
17340 tbinfo->attrdefs[
j]->adef_expr);
17341 }
17342
17344 {
17345 if (
tbinfo->notnull_constrs[
j][0] ==
'\0')
17347 else
17350
17351 if (
tbinfo->notnull_noinh[
j])
17353 }
17354
17355
17357 {
17359
17361 if (coll)
17364 }
17365 }
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17381 {
17382
17385 else
17389
17390 if (
tbinfo->notnull_constrs[
j][0] ==
'\0')
17393 else
17397
17398 if (
tbinfo->notnull_noinh[
j])
17400 }
17401 }
17402
17403
17404
17405
17406
17407
17408
17409
17410
17412 {
17414
17417 continue;
17418
17421 else
17423
17427
17429 }
17430
17434 {
17435
17436
17437
17438
17440 }
17441
17442
17443
17444
17445
17446 if (numParents > 0 && !
tbinfo->ispartition &&
17448 {
17450 for (k = 0; k < numParents; k++)
17451 {
17453
17454 if (k > 0)
17457 }
17459 }
17460
17463
17466 }
17467
17470 {
17472
17475 {
17478 }
17480 {
17485 }
17487 }
17488
17489
17492
17493
17494
17495
17496
17498 {
17500
17505 }
17506 else
17508
17509
17512 "pg_catalog.pg_class",
17513 "MATERIALIZED VIEW",
17515
17516
17517
17518
17519
17521 {
17523 {
17524 if (
tbinfo->attmissingval[
j][0] !=
'\0')
17525 {
17528 "SELECT pg_catalog.binary_upgrade_set_missing_value(");
17535 }
17536 }
17537 }
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17564 {
17567
17568
17569
17570
17571
17572
17573
17577 {
17579 {
17581 {
17583 "UPDATE pg_catalog.pg_attribute\n"
17584 "SET attlen = v.dlen, "
17585 "attalign = v.dalign, "
17586 "attbyval = false\n"
17587 "FROM (VALUES ");
17589 }
17590 else
17597
17602 }
17603 }
17605 {
17607 "WHERE attrelid = ");
17610 " AND attname = v.dname;\n");
17611
17613 }
17614
17615
17616
17617
17618
17621 {
17622 if (!
tbinfo->attisdropped[
j] &&
17624 {
17626 {
17629 "SET attislocal = false\n"
17630 "WHERE attrelid = ");
17633 " AND attname IN (");
17635 }
17636 else
17639 }
17640 }
17643
17644
17645
17646
17647
17648
17649
17654 {
17655
17656
17657
17658
17659
17660
17661
17662
17663
17666 {
17667 if (
tbinfo->notnull_constrs[
j][0] !=
'\0')
17668 {
17670 {
17672 "SET conislocal = false\n"
17673 "WHERE contype = 'n' AND conrelid = ");
17676 "conname IN (");
17678 }
17679 else
17682 }
17683 else
17684 {
17686 {
17688 "SET conislocal = false\n"
17689 "WHERE contype = 'n' AND conrelid = ");
17692 "conkey IN (");
17694 }
17695 else
17698 }
17699 }
17700 }
17705
17706 if (extra->
len > 0)
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17723 for (k = 0; k <
tbinfo->ncheck; k++)
17724 {
17726
17728 continue;
17729
17736
17738 {
17740 "SET conislocal = false\n"
17741 "WHERE contype = 'c' AND conrelid = ");
17746 }
17747 else
17750 }
17752 {
17755 }
17756
17757 if (numParents > 0 && !
tbinfo->ispartition)
17758 {
17760 for (k = 0; k < numParents; k++)
17761 {
17763
17767 }
17768 }
17769
17771 {
17777 }
17778 }
17779
17780
17781
17782
17783
17784
17785
17786
17790 {
17793 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17794 "WHERE oid = ",
17798
17800 {
17801
17802
17803
17804
17805 appendPQExpBufferStr(q,
"\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
17807 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17808 "WHERE oid = '%u';\n",
17809 tbinfo->toast_frozenxid,
17811 }
17812 }
17813
17814
17815
17816
17817
17818
17819
17820
17823 {
17826 "SET relispopulated = 't'\n"
17827 "WHERE oid = ");
17830 }
17831
17832
17833
17834
17835
17837 {
17838
17840 continue;
17841
17842
17843
17844
17845
17846
17847 if (
tbinfo->attstattarget[
j] >= 0)
17848 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STATISTICS %d;\n",
17852
17853
17854
17855
17856
17858 {
17859 switch (
tbinfo->attstorage[
j])
17860 {
17863 break;
17866 break;
17869 break;
17872 break;
17873 default:
17875 }
17876
17877
17878
17879
17881 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STORAGE %s;\n",
17885 }
17886
17887
17888
17889
17891 {
17893
17894 switch (
tbinfo->attcompression[
j])
17895 {
17896 case 'p':
17898 break;
17899 case 'l':
17901 break;
17902 default:
17904 break;
17905 }
17906
17908 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET COMPRESSION %s;\n",
17912 }
17913
17914
17915
17916
17917 if (
tbinfo->attoptions[
j][0] !=
'\0')
17922
17923
17924
17925
17927 tbinfo->attfdwoptions[
j][0] !=
'\0')
17929 "ALTER FOREIGN TABLE ONLY %s ALTER COLUMN %s OPTIONS (\n"
17930 " %s\n"
17931 ");\n",
17935 }
17936
17940 }
17941
17942
17943
17944
17949 {
17951 {
17952
17953 }
17955 {
17958 }
17960 {
17963 }
17964 }
17965
17966 if (
tbinfo->forcerowsec)
17969
17971
17975 tbinfo->dobj.namespace->dobj.name);
17976
17978 {
17980 char *tableam =
NULL;
17981
17982
17983
17984
17985
17986
17987
17988
17991
17994 tableam =
tbinfo->amname;
17995
17998 .namespace =
tbinfo->dobj.namespace->dobj.name,
18000 .tableam = tableam,
18001 .relkind =
tbinfo->relkind,
18002 .owner =
tbinfo->rolname,
18004 .section =
tbinfo->postponed_def ?
18006 .createStmt = q->
data,
18008 }
18009
18010
18013
18014
18017
18018
18019
18020
18021
18023 fout->remoteVersion >= 180000)
18024 {
18027
18029 {
18032 {
18034 {
18037 }
18038 else
18039 {
18042 }
18043
18048
18051
18054 .namespace =
tbinfo->dobj.namespace->dobj.name,
18055 .owner =
tbinfo->rolname,
18056 .description = "COMMENT",
18059 .deps = &(
tbinfo->dobj.dumpId),
18060 .nDeps = 1));
18061 }
18062 }
18063
18066 }
18067
18068
18070 {
18072
18074 continue;
18075
18078 }
18079
18085}
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102static void
18104{
18108 char *partbound;
18109
18110
18112 return;
18113
18115
18117 {
18118
18120 "PREPARE dumpTableAttach(pg_catalog.oid) AS\n");
18121
18123 "SELECT pg_get_expr(c.relpartbound, c.oid) "
18124 "FROM pg_class c "
18125 "WHERE c.oid = $1");
18126
18128
18130 }
18131
18133 "EXECUTE dumpTableAttach('%u')",
18135
18138
18139
18141 "ALTER TABLE ONLY %s ",
18144 "ATTACH PARTITION %s %s;\n",
18146 partbound);
18147
18148
18149
18150
18151
18152
18153
18154
18157 .namespace =
attachinfo->dobj.namespace->dobj.name,
18159 .description = "TABLE ATTACH",
18161 .createStmt = q->
data));
18162
18165}
18166
18167
18168
18169
18170static void
18172{
18175 int adnum =
adinfo->adnum;
18179 char *tag;
18181
18182
18184 return;
18185
18186
18188 return;
18189
18192
18194
18196
18198 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET DEFAULT %s;\n",
18201
18205
18207
18211 .
namespace =
tbinfo->dobj.namespace->dobj.name,
18212 .owner =
tbinfo->rolname,
18213 .description = "DEFAULT",
18215 .createStmt = q->
data,
18216 .dropStmt =
delq->data));
18217
18222}
18223
18224
18225
18226
18227
18228
18229
18230
18231static const char *
18233{
18235 return tblInfo->attnames[attrnum - 1];
18236 switch (attrnum)
18237 {
18239 return "ctid";
18241 return "xmin";
18243 return "cmin";
18245 return "xmax";
18247 return "cmax";
18249 return "tableoid";
18250 }
18251 pg_fatal(
"invalid column number %d for table \"%s\"",
18252 attrnum,
tblInfo->dobj.name);
18254}
18255
18256
18257
18258
18259
18260static void
18262{
18270
18271
18273 return;
18274
18277
18280
18281
18282
18283
18284
18285
18286
18287
18289 {
18290 char *indstatcols =
indxinfo->indstatcols;
18291 char *indstatvals =
indxinfo->indstatvals;
18296
18300
18301
18303
18304
18305
18306
18307
18308
18309
18310
18312 {
18315
18318 }
18319
18320
18321
18322
18323
18324 if (
strlen(indstatcols) != 0 ||
strlen(indstatvals) != 0)
18325 {
18327
18329 pg_fatal(
"could not parse index statistic columns");
18331 pg_fatal(
"could not parse index statistic values");
18333 pg_fatal(
"mismatched number of columns and values for index statistics");
18334
18336 {
18338
18339
18340
18341
18342
18347 }
18348 }
18349
18350
18352 "pg_catalog.pg_class",
18354
18355
18357 {
18360
18363 }
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18376
18380 .namespace =
tbinfo->dobj.namespace->dobj.name,
18381 .tablespace =
indxinfo->tablespace,
18382 .owner =
tbinfo->rolname,
18383 .description = "INDEX",
18385 .createStmt = q->
data,
18386 .dropStmt =
delq->data));
18387
18390 }
18391
18392
18395 tbinfo->dobj.namespace->dobj.name,
18400
18405}
18406
18407
18408
18409
18410
18411static void
18413{
18414
18415 if (!
fout->dopt->dumpSchema)
18416 return;
18417
18419 {
18421
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18440 .namespace =
attachinfo->dobj.namespace->dobj.name,
18441 .owner =
attachinfo->parentIdx->indextable->rolname,
18442 .description = "INDEX ATTACH",
18444 .createStmt = q->
data));
18445
18447 }
18448}
18449
18450
18451
18452
18453
18454static void
18456{
18464
18465
18467 return;
18468
18472
18474
18476 "pg_catalog.pg_get_statisticsobjdef('%u'::pg_catalog.oid)",
18478
18480
18482
18483
18485
18486
18487
18488
18489
18491 {
18496 }
18497
18500
18507 .description = "STATISTICS",
18509 .createStmt = q->
data,
18510 .dropStmt =
delq->data));
18511
18512
18519
18525}
18526
18527
18528
18529
18530
18531static void
18533{
18537 int nstats;
18538
18539
18541 return;
18542
18544 {
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18562 "PREPARE getExtStatsStats(pg_catalog.name, pg_catalog.name) AS\n"
18563 "SELECT ");
18564
18565
18566
18567
18568
18569
18570
18571 if (
fout->remoteVersion >= 150000)
18573 else
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602 if (
fout->remoteVersion >= 190000)
18604 else
18606 "( "
18607 "SELECT json_agg( "
18608 " json_build_object( "
18610 " string_to_array(kv.key, ', ')::integer[], "
18612 " kv.value::bigint )) "
18613 "FROM json_each_text(e.n_distinct::text::json) AS kv"
18614 ") AS n_distinct, "
18615 "( "
18616 "SELECT json_agg( "
18617 " json_build_object( "
18619 " string_to_array( "
18620 " split_part(kv.key, ' => ', 1), "
18621 " ', ')::integer[], "
18623 " split_part(kv.key, ' => ', 2)::integer, "
18625 " kv.value::double precision )) "
18626 "FROM json_each_text(e.dependencies::text::json) AS kv "
18627 ") AS dependencies, ");
18628
18629
18630 if (
fout->remoteVersion >= 130000)
18632 "e.most_common_vals, e.most_common_freqs, "
18633 "e.most_common_base_freqs, ");
18634 else
18636 "NULL AS most_common_vals, NULL AS most_common_freqs, "
18637 "NULL AS most_common_base_freqs, ");
18638
18639
18640 if (
fout->remoteVersion >= 140000)
18641 {
18642
18643
18644
18645
18646
18648 "( "
18649 "SELECT jsonb_pretty(jsonb_agg("
18650 "nullif(j.obj, '{}'::jsonb))) "
18651 "FROM pg_stats_ext_exprs AS ee "
18652 "CROSS JOIN LATERAL jsonb_strip_nulls("
18653 " jsonb_build_object( "
18654 " 'null_frac', ee.null_frac::text, "
18655 " 'avg_width', ee.avg_width::text, "
18656 " 'n_distinct', ee.n_distinct::text, "
18657 " 'most_common_vals', ee.most_common_vals::text, "
18658 " 'most_common_freqs', ee.most_common_freqs::text, "
18659 " 'histogram_bounds', ee.histogram_bounds::text, "
18660 " 'correlation', ee.correlation::text, "
18661 " 'most_common_elems', ee.most_common_elems::text, "
18662 " 'most_common_elem_freqs', ee.most_common_elem_freqs::text, "
18663 " 'elem_count_histogram', ee.elem_count_histogram::text");
18664
18665
18666 if (
fout->remoteVersion >= 190000)
18668 ", "
18669 " 'range_length_histogram', ee.range_length_histogram::text, "
18670 " 'range_empty_frac', ee.range_empty_frac::text, "
18671 " 'range_bounds_histogram', ee.range_bounds_histogram::text");
18672
18674 " )) AS j(obj)"
18675 "WHERE ee.statistics_schemaname = $1 "
18676 "AND ee.statistics_name = $2 ");
18677
18678 if (
fout->remoteVersion >= 150000)
18680
18682 }
18683 else
18685
18686
18687 if (
fout->remoteVersion >= 120000)
18689 "FROM pg_catalog.pg_stats_ext AS e "
18690 "WHERE e.statistics_schemaname = $1 "
18691 "AND e.statistics_name = $2 ");
18692 else
18694 "FROM ( "
18695 "SELECT s.stxndistinct AS n_distinct, "
18696 " s.stxdependencies AS dependencies "
18697 "FROM pg_catalog.pg_statistic_ext AS s "
18698 "JOIN pg_catalog.pg_namespace AS n "
18699 "ON n.oid = s.stxnamespace "
18700 "WHERE n.nspname = $1 "
18701 "AND s.stxname = $2 "
18702 ") AS e ");
18703
18704
18706
18708
18710
18712 }
18713
18715
18721
18723
18725
18727
18728 if (nstats > 0)
18729 {
18731
18739
18740 for (
int i = 0;
i < nstats;
i++)
18741 {
18743
18745 pg_fatal(
"inherited cannot be NULL");
18746
18748 "SELECT * FROM pg_catalog.pg_restore_extended_stats(\n");
18750 fout->remoteVersion);
18751
18752
18757
18758
18765
18769
18773
18777
18781
18785
18789
18791 }
18792
18797 .description = "EXTENDED STATISTICS DATA",
18799 .createStmt = out->
data,
18801 .nDeps = 1));
18803 }
18805}
18806
18807
18808
18809
18810
18811static void
18813{
18820
18821
18823 return;
18824
18827
18830
18831 if (
coninfo->contype ==
'p' ||
18834 {
18835
18837 int k;
18838
18840
18842 pg_fatal(
"missing index for constraint \"%s\"",
18844
18848
18853
18855 {
18856
18858 }
18859 else
18860 {
18862 coninfo->contype ==
'p' ?
"PRIMARY KEY" :
"UNIQUE");
18863
18864
18865
18866
18867
18868
18869
18873 for (k = 0; k <
indxinfo->indnkeyattrs; k++)
18874 {
18877
18879 break;
18881
18883 (k == 0) ? "" : ", ",
18885 }
18888
18891
18893 {
18896
18898 break;
18900
18902 (k ==
indxinfo->indnkeyattrs) ?
"" :
", ",
18904 }
18905
18907
18909 {
18913 }
18914
18916 {
18920 }
18921
18923 }
18924
18925
18926
18927
18928
18929
18930
18931
18933 {
18936
18939 }
18940
18941
18943 {
18946
18949 }
18950
18951
18953 "pg_catalog.pg_class", "INDEX",
18955
18960
18962
18966 .
namespace =
tbinfo->dobj.namespace->dobj.name,
18967 .tablespace =
indxinfo->tablespace,
18968 .owner =
tbinfo->rolname,
18969 .description = "CONSTRAINT",
18971 .createStmt = q->
data,
18972 .dropStmt =
delq->data));
18973 }
18974 else if (
coninfo->contype ==
'f')
18975 {
18977
18978
18979
18980
18981
18982
18983
18985
18986
18987
18988
18989
18995
19000
19002
19006 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19007 .owner =
tbinfo->rolname,
19008 .description = "FK CONSTRAINT",
19010 .createStmt = q->
data,
19011 .dropStmt =
delq->data));
19012 }
19014 {
19015
19016
19017
19019 {
19020 const char *keyword;
19021
19023 keyword = "CHECK CONSTRAINT";
19024 else
19025 keyword = "CONSTRAINT";
19026
19027
19033
19038
19040
19044 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19045 .owner =
tbinfo->rolname,
19046 .description = keyword,
19048 .createStmt = q->
data,
19049 .dropStmt =
delq->data));
19050 }
19051 }
19053 {
19054
19056
19058
19059
19061 {
19062 const char *keyword;
19063
19065 keyword = "CHECK CONSTRAINT";
19066 else
19067 keyword = "CONSTRAINT";
19068
19074
19079
19081
19085 .
namespace =
tyinfo->dobj.namespace->dobj.name,
19086 .owner =
tyinfo->rolname,
19087 .description = keyword,
19089 .createStmt = q->
data,
19090 .dropStmt =
delq->data));
19091
19093 {
19096
19099
19101 tyinfo->dobj.namespace->dobj.name,
19106 }
19107 }
19108 }
19109 else
19110 {
19111 pg_fatal(
"unrecognized constraint type: %c",
19113 }
19114
19115
19119
19123}
19124
19125
19126
19127
19128
19129
19130
19131
19132static void
19134{
19138
19140
19143
19146 tbinfo->dobj.namespace->dobj.name,
19150
19153}
19154
19157{
19159 {
19162 }
19163
19166}
19167
19168
19169
19170
19171static int
19173{
19176
19178}
19179
19180
19181
19182
19183
19184
19185
19186static void
19188{
19190 const char *query;
19191
19192
19193
19194
19195
19196 if (
fout->remoteVersion < 180000 ||
19197 (!
fout->dopt->dumpData && !
fout->dopt->sequence_data))
19198 query = "SELECT seqrelid, format_type(seqtypid, NULL), "
19199 "seqstart, seqincrement, "
19200 "seqmax, seqmin, "
19201 "seqcache, seqcycle, "
19202 "NULL, 'f' "
19203 "FROM pg_catalog.pg_sequence "
19204 "ORDER BY seqrelid";
19205 else
19206 query = "SELECT seqrelid, format_type(seqtypid, NULL), "
19207 "seqstart, seqincrement, "
19208 "seqmax, seqmin, "
19209 "seqcache, seqcycle, "
19210 "last_value, is_called "
19211 "FROM pg_catalog.pg_sequence, "
19212 "pg_get_sequence_data(seqrelid) "
19213 "ORDER BY seqrelid;";
19214
19216
19219
19221 {
19233 }
19234
19236}
19237
19238
19239
19240
19241
19242static void
19244{
19255
19257
19258
19259
19260
19261
19263
19267
19268
19271 {
19274 }
19276 {
19279 }
19281 {
19284 }
19285 else
19286 {
19287 pg_fatal(
"unrecognized sequence type: %d",
seq->seqtype);
19289 }
19290
19291
19292
19293
19294 if (!
tbinfo->is_identity_sequence)
19295 {
19298 }
19299
19301
19303 {
19305 tbinfo->dobj.catId.oid);
19306
19307
19308
19309
19310
19311 }
19312
19313 if (
tbinfo->is_identity_sequence)
19314 {
19316
19318 "ALTER TABLE %s ",
19321 "ALTER COLUMN %s ADD GENERATED ",
19329
19330
19331
19332
19333
19337 "UNLOGGED" : "LOGGED");
19338 }
19339 else
19340 {
19342 "CREATE %sSEQUENCE %s\n",
19344 "UNLOGGED " : "",
19346
19349 }
19350
19352
19354
19357 else
19359
19362 else
19364
19367 seq->cache, (
seq->cycled ?
"\n CYCLE" :
""));
19368
19369 if (
tbinfo->is_identity_sequence)
19371 else
19373
19374
19375
19379 tbinfo->dobj.namespace->dobj.name);
19380
19384 .namespace =
tbinfo->dobj.namespace->dobj.name,
19385 .owner =
tbinfo->rolname,
19386 .description = "SEQUENCE",
19388 .createStmt = query->
data,
19389 .dropStmt =
delqry->data));
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19404 {
19406
19407 if (owning_tab ==
NULL)
19408 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
19410
19412 {
19420
19424 .namespace =
tbinfo->dobj.namespace->dobj.name,
19425 .owner =
tbinfo->rolname,
19426 .description = "SEQUENCE OWNED BY",
19428 .createStmt = query->
data,
19429 .deps = &(
tbinfo->dobj.dumpId),
19430 .nDeps = 1));
19431 }
19432 }
19433
19434
19439
19444
19448}
19449
19450
19451
19452
19453
19454static void
19456{
19461
19462
19463 if (!
fout->dopt->dumpData && !
fout->dopt->sequence_data)
19464 return;
19465
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476 if (
fout->remoteVersion < 180000)
19477 {
19479
19481 "SELECT last_value, is_called FROM %s",
19483
19485
19487 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19488 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19491
19494
19496 }
19497 else
19498 {
19501
19504
19508
19510 pg_fatal(
"failed to get data for sequence \"%s\"; user may lack "
19511 "SELECT privilege on the sequence or the sequence may "
19512 "have been concurrently dropped",
19514
19517 }
19518
19523 last, (
called ?
"true" :
"false"));
19524
19528 .namespace =
tbinfo->dobj.namespace->dobj.name,
19529 .owner =
tbinfo->rolname,
19530 .description = "SEQUENCE SET",
19532 .createStmt = query->
data,
19533 .deps = &(
tbinfo->dobj.dumpId),
19534 .nDeps = 1));
19535
19537}
19538
19539
19540
19541
19542
19543static void
19545{
19553 char *tag;
19554
19555
19557 return;
19558
19563
19565
19568
19571
19572
19574 "pg_catalog.pg_trigger", "TRIGGER",
19576
19577 if (
tginfo->tgispartition)
19578 {
19580
19581
19582
19583
19584
19585
19586
19592 switch (
tginfo->tgenabled)
19593 {
19594 case 'f':
19595 case 'D':
19597 break;
19598 case 't':
19599 case 'O':
19601 break;
19602 case 'R':
19604 break;
19605 case 'A':
19607 break;
19608 }
19611 }
19612 else if (
tginfo->tgenabled !=
't' &&
tginfo->tgenabled !=
'O')
19613 {
19617 switch (
tginfo->tgenabled)
19618 {
19619 case 'D':
19620 case 'f':
19622 break;
19623 case 'A':
19625 break;
19626 case 'R':
19628 break;
19629 default:
19631 break;
19632 }
19635 }
19636
19639
19641
19645 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19646 .owner =
tbinfo->rolname,
19647 .description = "TRIGGER",
19649 .createStmt = query->
data,
19650 .dropStmt =
delqry->data));
19651
19656
19663}
19664
19665
19666
19667
19668
19669static void
19671{
19676
19677
19679 return;
19680
19683
19685
19690
19692 {
19696 }
19697
19701
19702 if (
evtinfo->evtenabled !=
'O')
19703 {
19707 {
19708 case 'D':
19710 break;
19711 case 'A':
19713 break;
19714 case 'R':
19716 break;
19717 default:
19719 break;
19720 }
19722 }
19723
19726
19730
19735 .description = "EVENT TRIGGER",
19737 .createStmt = query->
data,
19738 .dropStmt =
delqry->data));
19739
19744
19749
19753}
19754
19755
19756
19757
19758
19759static void
19761{
19771 char *tag;
19772
19773
19775 return;
19776
19777
19778
19779
19780
19782 return;
19783
19784
19785
19786
19787
19789
19794
19796
19798 {
19800
19801
19802
19803
19804
19808 {
19812 }
19820 }
19821 else
19822 {
19823
19825 "SELECT pg_catalog.pg_get_ruledef('%u'::pg_catalog.oid)",
19827
19829
19831 pg_fatal(
"query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
19833
19835
19837 }
19838
19839
19840
19841
19842
19844 {
19847 {
19848 case 'A':
19851 break;
19852 case 'R':
19855 break;
19856 case 'D':
19859 break;
19860 }
19861 }
19862
19864 {
19865
19866
19867
19868
19869
19871
19877 }
19878 else
19879 {
19884 }
19885
19888
19890
19894 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19895 .owner =
tbinfo->rolname,
19896 .description = "RULE",
19898 .createStmt = cmd->
data,
19899 .dropStmt =
delcmd->data));
19900
19901
19904 tbinfo->dobj.namespace->dobj.name,
19907
19914}
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926void
19929{
19932 int ntups,
19938
19939
19941 return;
19942
19944
19945
19947 "classid, objid, refobjid "
19948 "FROM pg_depend "
19949 "WHERE refclassid = 'pg_extension'::regclass "
19950 "AND deptype = 'e' "
19951 "ORDER BY 3");
19952
19954
19956
19960
19961
19962
19963
19964
19965
19967
19968 for (
i = 0;
i < ntups;
i++)
19969 {
19972
19976
19980
19982 {
19983
19985 continue;
19986 }
19987
19989 }
19990
19992
19994}
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019void
20022{
20026 int ntups,
20030
20031
20033 return;
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20047 {
20050 char *extcondition =
curext->extcondition;
20055
20056
20057
20058
20059
20062 curext->dobj.catId.oid))
20063 continue;
20064
20065
20066
20067
20068
20071 curext->dobj.catId.oid))
20072 continue;
20073
20074 if (
strlen(extconfig) != 0 ||
strlen(extcondition) != 0)
20075 {
20077
20079 pg_fatal(
"could not parse %s array",
"extconfig");
20081 pg_fatal(
"could not parse %s array",
"extcondition");
20083 pg_fatal(
"mismatched number of configurations and conditions for extension");
20084
20086 {
20091
20094 continue;
20095
20096
20097
20098
20099
20101 {
20102
20107
20108
20109 if (
configtbl->dobj.namespace->dobj.dump &
20112 }
20113
20114
20119
20120
20122 configtbl->dobj.namespace->dobj.catId.oid))
20124
20126 {
20129 {
20132 }
20133 }
20134 }
20135 }
20140 }
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20152
20154 "SELECT conrelid, confrelid "
20155 "FROM pg_constraint "
20156 "JOIN pg_depend ON (objid = confrelid) "
20157 "WHERE contype = 'f' "
20158 "AND refclassid = 'pg_extension'::regclass "
20159 "AND classid = 'pg_class'::regclass;");
20160
20163
20166
20167
20168 for (
i = 0;
i < ntups;
i++)
20169 {
20171 confrelid;
20173 *contable;
20174
20179
20182 contable ==
NULL ||
20184 continue;
20185
20186
20187
20188
20189
20192 }
20195}
20196
20197
20198
20199
20200static void
20202{
20205 int ntups,
20214
20216
20218
20219
20220
20221
20222
20223
20224
20225
20226
20228 "classid, objid, refclassid, refobjid, deptype "
20229 "FROM pg_depend "
20230 "WHERE deptype != 'p' AND deptype != 'e'\n");
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20243 "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
20244 "FROM pg_depend d, pg_amop o "
20245 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20246 "classid = 'pg_amop'::regclass AND objid = o.oid "
20247 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
20248
20249
20251 "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
20252 "FROM pg_depend d, pg_amproc p "
20253 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20254 "classid = 'pg_amproc'::regclass AND objid = p.oid "
20255 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
20256
20257
20258
20259
20260
20261 if (
fout->remoteVersion >= 190000)
20263 "SELECT 'pg_class'::regclass AS classid, pgepgid AS objid, refclassid, refobjid, deptype "
20264 "FROM pg_depend d, pg_propgraph_element pge "
20265 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20266 "classid = 'pg_propgraph_element'::regclass AND objid = pge.oid\n");
20267
20268
20270
20272
20274
20280
20281
20282
20283
20284
20285
20287
20288 for (
i = 0;
i < ntups;
i++)
20289 {
20292 char deptype;
20293
20299
20300 if (dobj ==
NULL ||
20304
20305
20306
20307
20308
20310 {
20311#ifdef NOT_USED
20314#endif
20315 continue;
20316 }
20317
20319
20321 {
20322#ifdef NOT_USED
20325#endif
20326 continue;
20327 }
20328
20329
20330
20331
20332
20333
20334
20335 if (deptype == 'x')
20337
20338
20339
20340
20341
20342
20343
20344
20345 if (deptype == 'i' &&
20349 else
20350
20352 }
20353
20355
20357}
20358
20359
20360
20361
20362
20363
20366{
20368
20370
20375
20380
20382}
20383
20384
20385
20386
20387
20388static void
20391{
20395
20397 {
20399
20400
20401
20402
20403
20405 {
20431
20433 break;
20438
20441 break;
20455
20457 break;
20459
20460 if (((
RuleInfo *) dobj)->separate)
20462 break;
20465
20468 break;
20470
20471 break;
20473
20475 break;
20477
20479 {
20482 }
20483 else
20485 break;
20486 }
20487 }
20488}
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514static void
20516{
20519
20520
20522 {
20525 int nDeps;
20526 int allocDeps;
20527
20528
20530 continue;
20531
20533 continue;
20534
20537 continue;
20538
20539 if (dobj->
nDeps <= 0)
20540 continue;
20541
20542 allocDeps = 64;
20544 nDeps = 0;
20545
20547 &dependencies, &nDeps, &allocDeps);
20548
20549 if (nDeps > 0)
20550 {
20554 }
20555 else
20557 }
20558}
20559
20560
20561static void
20563 DumpId **dependencies,
int *nDeps,
int *allocDeps)
20564{
20566
20567
20568
20569
20570
20573 return;
20574
20576 {
20578
20580 {
20581
20582 if (*nDeps >= *allocDeps)
20583 {
20584 *allocDeps *= 2;
20586 }
20587 (*dependencies)[*nDeps] =
depid;
20588 (*nDeps)++;
20589 }
20590 else
20591 {
20592
20593
20594
20595
20596
20598
20601 dependencies, nDeps, allocDeps);
20602 }
20603 }
20604}
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616static const char *
20618{
20623
20624 if (oid == 0)
20625 {
20627 return "*";
20629 return "NONE";
20630 }
20631
20632
20636
20638 appendPQExpBuffer(query,
"SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
20639 oid);
20640
20642
20643
20645
20648
20649
20650
20651
20652
20653
20654
20657
20659}
20660
20661
20662
20663
20664
20665
20666
20667static const char *
20669{
20670 int numatts =
ti->numatts;
20671 char **attnames =
ti->attnames;
20672 bool *attisdropped =
ti->attisdropped;
20673 char *attgenerated =
ti->attgenerated;
20676
20679 for (
i = 0;
i < numatts;
i++)
20680 {
20681 if (attisdropped[
i])
20682 continue;
20683 if (attgenerated[
i])
20684 continue;
20689 }
20690
20692 return "";
20693
20695 return buffer->
data;
20696}
20697
20698
20699
20700
20701static bool
20703{
20704
20705 return (reloptions !=
NULL &&
strlen(reloptions) > 2);
20706}
20707
20708
20709
20710
20711
20712
20713static void
20716{
20717 bool res;
20718
20720 fout->std_strings);
20721 if (!res)
20723}
20724
20725
20726
20727
20728
20729
20730
20731
20732static void
20734{
20736 char *objname;
20739
20741
20743 {
20745 {
20746 switch (objtype)
20747 {
20749 break;
20757 "include",
20760 break;
20761
20764 break;
20767 break;
20771 break;
20775 break;
20778 objname);
20780 break;
20781 }
20782 }
20784 {
20785 switch (objtype)
20786 {
20788 break;
20795 "exclude",
20798 break;
20799
20802 break;
20805 objname);
20806 break;
20809 objname);
20810 break;
20813 break;
20816 break;
20819 objname);
20820 break;
20821 }
20822 }
20823 else
20824 {
20827 }
20828
20829 if (objname)
20831 }
20832
20834}
Acl * acldefault(ObjectType objtype, Oid ownerId)
#define InvalidAttrNumber
int lo_read(int fd, char *buf, int len)
void recordAdditionalCatalogID(CatalogId catId, DumpableObject *dobj)
void recordExtensionMembership(CatalogId catId, ExtensionInfo *ext)
FuncInfo * findFuncByOid(Oid oid)
TableInfo * findTableByOid(Oid oid)
ExtensionInfo * findExtensionByOid(Oid oid)
CollInfo * findCollationByOid(Oid oid)
SubscriptionInfo * findSubscriptionByOid(Oid oid)
OprInfo * findOprByOid(Oid oid)
NamespaceInfo * findNamespaceByOid(Oid oid)
void addObjectDependency(DumpableObject *dobj, DumpId refId)
DumpableObject * findObjectByDumpId(DumpId dumpId)
void parseOidArray(const char *str, Oid *array, int arraysize)
ExtensionInfo * findOwningExtension(CatalogId catalogId)
TableInfo * getSchemaData(Archive *fout, int *numTablesPtr)
TypeInfo * findTypeByOid(Oid oid)
DumpId createDumpId(void)
DumpableObject * findObjectByCatalogId(CatalogId catalogId)
void AssignDumpId(DumpableObject *dobj)
void getDumpableObjects(DumpableObject ***objs, int *numObjs)
PublicationInfo * findPublicationByOid(Oid oid)
void on_exit_close_archive(Archive *AHX)
void init_parallel_dump_utils(void)
static void cleanup(void)
static const gbtree_vinfo tinfo
#define ngettext(s, p, n)
#define Assert(condition)
#define PG_TEXTDOMAIN(domain)
#define OidIsValid(objectId)
void set_pglocale_pgservice(const char *argv0, const char *app)
char * supports_compression(const pg_compress_specification compression_spec)
char * validate_compress_specification(pg_compress_specification *spec)
bool parse_compress_algorithm(char *name, pg_compress_algorithm *algorithm)
void parse_compress_specification(pg_compress_algorithm algorithm, char *specification, pg_compress_specification *result)
#define PG_COMPRESSION_OPTION_WORKERS
void parse_compress_options(const char *option, char **algorithm, char **detail)
#define ALWAYS_SECURE_SEARCH_PATH_SQL
char * generate_restrict_key(void)
bool buildACLCommands(const char *name, const char *subname, const char *nspname, const char *type, const char *acls, const char *baseacls, const char *owner, const char *prefix, int remoteVersion, PQExpBuffer sql)
bool valid_restrict_key(const char *restrict_key)
void buildShSecLabelQuery(const char *catalog_name, Oid objectId, PQExpBuffer sql)
void makeAlterConfigCommand(PGconn *conn, const char *configitem, const char *type, const char *name, const char *type2, const char *name2, PQExpBuffer buf)
bool buildDefaultACLCommands(const char *type, const char *nspname, const char *acls, const char *acldefault, const char *owner, int remoteVersion, PQExpBuffer sql)
char * sanitize_line(const char *str, bool want_hyphen)
bool variable_is_guc_list_quote(const char *name)
void quoteAclUserName(PQExpBuffer output, const char *input)
void emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer, const char *objtype, const char *objname)
char * PQdb(const PGconn *conn)
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
int PQclientEncoding(const PGconn *conn)
char * PQerrorMessage(const PGconn *conn)
int PQsetClientEncoding(PGconn *conn, const char *encoding)
void PQfreemem(void *ptr)
Oid PQftype(const PGresult *res, int field_num)
int PQfnumber(const PGresult *res, const char *field_name)
int PQgetCopyData(PGconn *conn, char **buffer, int async)
int lo_close(PGconn *conn, int fd)
int lo_open(PGconn *conn, Oid lobjId, int mode)
void * pg_malloc(size_t size)
char * pg_strdup(const char *in)
#define pg_realloc_array(pointer, type, count)
#define pg_malloc_array(type, count)
#define pg_malloc0_object(type)
#define pg_malloc_object(type)
#define pg_malloc0_array(type, count)
@ DATA_DIR_SYNC_METHOD_FSYNC
void filter_init(FilterStateData *fstate, const char *filename, exit_function f_exit)
void filter_free(FilterStateData *fstate)
const char * filter_object_type_name(FilterObjectType fot)
bool filter_read_item(FilterStateData *fstate, char **objname, FilterCommandType *comtype, FilterObjectType *objtype)
void pg_log_filter_error(FilterStateData *fstate, const char *fmt,...)
@ FILTER_OBJECT_TYPE_TABLE_DATA_AND_CHILDREN
@ FILTER_OBJECT_TYPE_SCHEMA
@ FILTER_OBJECT_TYPE_INDEX
@ FILTER_OBJECT_TYPE_TRIGGER
@ FILTER_OBJECT_TYPE_FOREIGN_DATA
@ FILTER_OBJECT_TYPE_DATABASE
@ FILTER_OBJECT_TYPE_FUNCTION
@ FILTER_OBJECT_TYPE_TABLE_DATA
@ FILTER_OBJECT_TYPE_NONE
@ FILTER_OBJECT_TYPE_TABLE_AND_CHILDREN
@ FILTER_OBJECT_TYPE_EXTENSION
@ FILTER_OBJECT_TYPE_TABLE
@ FILTER_COMMAND_TYPE_NONE
@ FILTER_COMMAND_TYPE_EXCLUDE
@ FILTER_COMMAND_TYPE_INCLUDE
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
static DataDirSyncMethod sync_method
static int pg_cmp_u32(uint32 a, uint32 b)
void pg_logging_increase_verbosity(void)
void pg_logging_init(const char *argv0)
void pg_logging_set_level(enum pg_log_level new_level)
#define pg_log_error(...)
#define pg_log_error_hint(...)
#define pg_log_error_detail(...)
char * pstrdup(const char *in)
void pfree(void *pointer)
bool option_parse_int(const char *optarg, const char *optname, int min_range, int max_range, int *result)
bool parse_sync_method(const char *optarg, DataDirSyncMethod *sync_method)
#define check_mut_excl_opts(set, opt,...)
static AmcheckOptions opts
int EndLO(Archive *AHX, Oid oid)
void ProcessArchiveRestoreOptions(Archive *AHX)
RestoreOptions * NewRestoreOptions(void)
#define appendStringLiteralAH(buf, str, AH)
int StartLO(Archive *AHX, Oid oid)
enum _archiveFormat ArchiveFormat
void ConnectDatabaseAhx(Archive *AHX, const ConnParams *cparams, bool isReconnect)
void CloseArchive(Archive *AHX)
Archive * CreateArchive(const char *FileSpec, const ArchiveFormat fmt, const pg_compress_specification compression_spec, bool dosync, ArchiveMode mode, SetupWorkerPtrType setupDumpWorker, DataDirSyncMethod sync_method)
@ PREPQUERY_DUMPTABLEATTACH
@ PREPQUERY_DUMPRANGETYPE
@ PREPQUERY_DUMPEXTSTATSOBJSTATS
@ PREPQUERY_GETATTRIBUTESTATS
@ PREPQUERY_DUMPCOMPOSITETYPE
@ PREPQUERY_GETCOLUMNACLS
@ PREPQUERY_GETDOMAINCONSTRAINTS
int archprintf(Archive *AH, const char *fmt,...) pg_attribute_printf(2
void SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)
void RestoreArchive(Archive *AHX)
void archputs(const char *s, Archive *AH)
void InitDumpOptions(DumpOptions *opts)
void WriteData(Archive *AHX, const void *data, size_t dLen)
int TocIDRequired(ArchiveHandle *AH, DumpId id)
TocEntry * ArchiveEntry(Archive *AHX, CatalogId catalogId, DumpId dumpId, ArchiveOpts *opts)
#define ARCHIVE_OPTS(...)
int(* DataDumperPtr)(Archive *AH, const void *userArg)
void ExecuteSqlStatement(Archive *AHX, const char *query)
PGresult * ExecuteSqlQuery(Archive *AHX, const char *query, ExecStatusType status)
PGresult * ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)
void exit_nicely(int code)
void set_dump_section(const char *arg, int *dumpSections)
static PgChecksumMode mode
static void expand_schema_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names)
static const CatalogId nilCatalogId
static void dumpEncoding(Archive *AH)
void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
static DumpId dumpACL(Archive *fout, DumpId objDumpId, DumpId altDumpId, const char *type, const char *name, const char *subname, const char *nspname, const char *tag, const char *owner, const DumpableAcl *dacl)
static SimpleStringList schema_include_patterns
static void dumpAttrDef(Archive *fout, const AttrDefInfo *adinfo)
ExtensionInfo * getExtensions(Archive *fout, int *numExtensions)
static void selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void collectBinaryUpgradeClassOids(Archive *fout)
static PQExpBuffer createDummyViewAsClause(Archive *fout, const TableInfo *tbinfo)
static void dumpUserMappings(Archive *fout, const char *servername, const char *namespace, const char *owner, CatalogId catalogId, DumpId dumpId)
static void dumpPublicationNamespace(Archive *fout, const PublicationSchemaInfo *pubsinfo)
static void addBoundaryDependencies(DumpableObject **dobjs, int numObjs, DumpableObject *boundaryObjs)
void getPublicationNamespaces(Archive *fout)
static void dumpSearchPath(Archive *AH)
static void selectDumpableTable(TableInfo *tbinfo, Archive *fout)
static DumpableObject * createBoundaryObjects(void)
static char * convertTSFunction(Archive *fout, Oid funcOid)
static void dumpDatabase(Archive *fout)
static SimpleStringList table_include_patterns
static void append_depends_on_extension(Archive *fout, PQExpBuffer create, const DumpableObject *dobj, const char *catalog, const char *keyword, const char *objname)
static Oid get_next_possible_free_pg_type_oid(Archive *fout, PQExpBuffer upgrade_query)
static void dumpNamespace(Archive *fout, const NamespaceInfo *nspinfo)
static bool forcePartitionRootLoad(const TableInfo *tbinfo)
static void dumpCast(Archive *fout, const CastInfo *cast)
static SimpleOidList schema_exclude_oids
static bool have_extra_float_digits
static void dumpIndex(Archive *fout, const IndxInfo *indxinfo)
void getPartitioningInfo(Archive *fout)
static int nbinaryUpgradeClassOids
static void dumpBaseType(Archive *fout, const TypeInfo *tyinfo)
static char * dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
static SimpleOidList extension_include_oids
static void dumpTSDictionary(Archive *fout, const TSDictInfo *dictinfo)
static void dumpAgg(Archive *fout, const AggInfo *agginfo)
static int extra_float_digits
static int SequenceItemCmp(const void *p1, const void *p2)
static void dumpRelationStats(Archive *fout, const RelStatsInfo *rsinfo)
static void dumpTableComment(Archive *fout, const TableInfo *tbinfo, const char *reltypename)
static SimpleStringList extension_include_patterns
static void selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
InhInfo * getInherits(Archive *fout, int *numInherits)
void getForeignDataWrappers(Archive *fout)
static void dumpTrigger(Archive *fout, const TriggerInfo *tginfo)
static void binary_upgrade_set_type_oids_by_rel(Archive *fout, PQExpBuffer upgrade_buffer, const TableInfo *tbinfo)
static void dumpTable(Archive *fout, const TableInfo *tbinfo)
static SimpleOidList extension_exclude_oids
static SimpleStringList table_exclude_patterns
static PQExpBuffer createViewAsClause(Archive *fout, const TableInfo *tbinfo)
static void dumpStatisticsExt(Archive *fout, const StatsExtInfo *statsextinfo)
void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
static void dumpRangeType(Archive *fout, const TypeInfo *tyinfo)
void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
static void dumpComment(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId)
static char * getFormattedOperatorName(const char *oproid)
static char * format_function_signature(Archive *fout, const FuncInfo *finfo, bool honor_quotes)
static pg_compress_algorithm compression_algorithm
static void dumpStdStrings(Archive *AH)
static void dumpConstraint(Archive *fout, const ConstraintInfo *coninfo)
static void dumpType(Archive *fout, const TypeInfo *tyinfo)
static void dumpTableAttach(Archive *fout, const TableAttachInfo *attachinfo)
void getTypes(Archive *fout)
static void dumpAccessMethod(Archive *fout, const AccessMethodInfo *aminfo)
static void dumpOpr(Archive *fout, const OprInfo *oprinfo)
static void selectDumpableStatisticsObject(StatsExtInfo *sobj, Archive *fout)
static void selectDumpablePublicationObject(DumpableObject *dobj, Archive *fout)
static void dumpSequenceData(Archive *fout, const TableDataInfo *tdinfo)
static void dumpFunc(Archive *fout, const FuncInfo *finfo)
static void selectDumpableDefaultACL(DefaultACLInfo *dinfo, DumpOptions *dopt)
static void BuildArchiveDependencies(Archive *fout)
static RelStatsInfo * getRelationStatistics(Archive *fout, DumpableObject *rel, int32 relpages, char *reltuples, int32 relallvisible, int32 relallfrozen, char relkind, char **indAttNames, int nindAttNames)
static const char *const SeqTypeNames[]
void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo)
static const char * getAttrName(int attrnum, const TableInfo *tblInfo)
static void dumpForeignServer(Archive *fout, const ForeignServerInfo *srvinfo)
static RoleNameItem * rolenames
static void collectRoleNames(Archive *fout)
static PGresult * fetchAttributeStats(Archive *fout)
static void appendReloptionsArrayAH(PQExpBuffer buffer, const char *reloptions, const char *prefix, Archive *fout)
void getOpclasses(Archive *fout)
void getForeignServers(Archive *fout)
void getFuncs(Archive *fout)
static void dumpTableData(Archive *fout, const TableDataInfo *tdinfo)
static void prohibit_crossdb_refs(PGconn *conn, const char *dbname, const char *pattern)
static int dumpTableData_copy(Archive *fout, const void *dcontext)
#define MAX_BLOBS_PER_ARCHIVE_ENTRY
static const char * getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts)
static void getDependencies(Archive *fout)
static void buildMatViewRefreshDependencies(Archive *fout)
void getTSDictionaries(Archive *fout)
static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, PQExpBuffer upgrade_buffer, Oid pg_type_oid, bool force_array_type, bool include_multirange_type)
#define DUMP_DEFAULT_ROWS_PER_INSERT
void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
static SeqType parse_sequence_type(const char *name)
static const char * getRoleName(const char *roleoid_str)
static void dumpShellType(Archive *fout, const ShellTypeInfo *stinfo)
static SequenceItem * sequences
static void refreshMatViewData(Archive *fout, const TableDataInfo *tdinfo)
static int findComments(Oid classoid, Oid objoid, CommentItem **items)
static SimpleStringList foreign_servers_include_patterns
static void selectDumpableCast(CastInfo *cast, Archive *fout)
void getCasts(Archive *fout)
static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo)
static void dumpPolicy(Archive *fout, const PolicyInfo *polinfo)
void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
static void setupDumpWorker(Archive *AH)
static void addConstrChildIdxDeps(DumpableObject *dobj, const IndxInfo *refidx)
void getTSConfigurations(Archive *fout)
static int findSecLabels(Oid classoid, Oid objoid, SecLabelItem **items)
static SimpleStringList table_include_patterns_and_children
static char * convertRegProcReference(const char *proc)
static void getAdditionalACLs(Archive *fout)
static void getTableDataFKConstraints(void)
static void getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, char relkind)
static SimpleOidList table_exclude_oids
void getAccessMethods(Archive *fout)
void getConversions(Archive *fout)
void getRules(Archive *fout)
static void dumpDomain(Archive *fout, const TypeInfo *tyinfo)
void getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
static void collectComments(Archive *fout)
static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo)
static void dumpOpfamily(Archive *fout, const OpfamilyInfo *opfinfo)
static void dumpDefaultACL(Archive *fout, const DefaultACLInfo *daclinfo)
static void selectDumpableObject(DumpableObject *dobj, Archive *fout)
static void dumpTSTemplate(Archive *fout, const TSTemplateInfo *tmplinfo)
static void dumpIndexAttach(Archive *fout, const IndexAttachInfo *attachinfo)
static void dumpSubscriptionTable(Archive *fout, const SubRelInfo *subrinfo)
void getCollations(Archive *fout)
static char * format_function_arguments(const FuncInfo *finfo, const char *funcargs, bool is_agg)
static void dumpTransform(Archive *fout, const TransformInfo *transform)
void getAggregates(Archive *fout)
static void dumpLO(Archive *fout, const LoInfo *loinfo)
void getNamespaces(Archive *fout)
static void dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo)
void getPublications(Archive *fout)
static void binary_upgrade_extension_member(PQExpBuffer upgrade_buffer, const DumpableObject *dobj, const char *objtype, const char *objname, const char *objnamespace)
static void dumpDumpableObject(Archive *fout, DumpableObject *dobj)
static void getLOs(Archive *fout)
static void dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, const char *dbname, Oid dboid)
void getTSParsers(Archive *fout)
static void setup_connection(Archive *AH, const char *dumpencoding, const char *dumpsnapshot, char *use_role)
static void dumpTableConstraintComment(Archive *fout, const ConstraintInfo *coninfo)
static void dumpUndefinedType(Archive *fout, const TypeInfo *tyinfo)
static void selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
static const char * fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer)
static void expand_table_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names, bool with_child_tables)
static void findDumpableDependencies(ArchiveHandle *AH, const DumpableObject *dobj, DumpId **dependencies, int *nDeps, int *allocDeps)
static void determineNotNullFlags(Archive *fout, PGresult *res, int r, TableInfo *tbinfo, int j, int i_notnull_name, int i_notnull_comment, int i_notnull_invalidoid, int i_notnull_noinherit, int i_notnull_islocal, PQExpBuffer *invalidnotnulloids)
static void dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
static void dumpTSParser(Archive *fout, const TSParserInfo *prsinfo)
static void expand_foreign_server_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids)
TableInfo * getTables(Archive *fout, int *numTables)
static void dumpRule(Archive *fout, const RuleInfo *rinfo)
static void dumpCompositeType(Archive *fout, const TypeInfo *tyinfo)
static void dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
static void dumpExtension(Archive *fout, const ExtensionInfo *extinfo)
#define fmtQualifiedDumpable(obj)
static bool nonemptyReloptions(const char *reloptions)
static SimpleStringList extension_exclude_patterns
static BinaryUpgradeClassOidItem * binaryUpgradeClassOids
static SimpleOidList table_include_oids
static void dumpStatisticsExtStats(Archive *fout, const StatsExtInfo *statsextinfo)
void getExtendedStatistics(Archive *fout)
static NamespaceInfo * findNamespace(Oid nsoid)
static char * get_synchronized_snapshot(Archive *fout)
static int dumpLOs(Archive *fout, const void *arg)
static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
static void appendNamedArgument(PQExpBuffer out, Archive *fout, const char *argname, const char *argtype, const char *argval)
void processExtensionTables(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
static void dumpEventTrigger(Archive *fout, const EventTriggerInfo *evtinfo)
static int BinaryUpgradeClassOidItemCmp(const void *p1, const void *p2)
static void dumpCommentExtended(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId, const char *initdb_comment)
void getDefaultACLs(Archive *fout)
static SimpleStringList tabledata_exclude_patterns
static void dumpConversion(Archive *fout, const ConvInfo *convinfo)
static void dumpForeignDataWrapper(Archive *fout, const FdwInfo *fdwinfo)
static void dumpProcLang(Archive *fout, const ProcLangInfo *plang)
static void dumpSecLabel(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId)
void getSubscriptions(Archive *fout)
static void collectSecLabels(Archive *fout)
static void selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
static void collectSequences(Archive *fout)
static Oid g_last_builtin_oid
#define MAX_ATTR_STATS_RELS
void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
void getTransforms(Archive *fout)
void getEventTriggers(Archive *fout)
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode)
static void read_dump_filters(const char *filename, DumpOptions *dopt)
static void dumpTSConfig(Archive *fout, const TSConfigInfo *cfginfo)
static SecLabelItem * seclabels
static SimpleStringList tabledata_exclude_patterns_and_children
static char * get_language_name(Archive *fout, Oid langid)
static bool checkExtensionMembership(DumpableObject *dobj, Archive *fout)
static CommentItem * comments
static int dumpTableData_insert(Archive *fout, const void *dcontext)
static SimpleOidList tabledata_exclude_oids
static SimpleStringList table_exclude_patterns_and_children
static void binary_upgrade_set_pg_class_oids(Archive *fout, PQExpBuffer upgrade_buffer, Oid pg_class_oid)
void getTSTemplates(Archive *fout)
static void set_restrict_relation_kind(Archive *AH, const char *value)
static char * format_aggregate_signature(const AggInfo *agginfo, Archive *fout, bool honor_quotes)
void getProcLangs(Archive *fout)
static void dumpSequence(Archive *fout, const TableInfo *tbinfo)
bool shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
static TableInfo * getRootTableInfo(const TableInfo *tbinfo)
void getSubscriptionRelations(Archive *fout)
void getOperators(Archive *fout)
static SimpleOidList foreign_servers_include_oids
static void dumpCollation(Archive *fout, const CollInfo *collinfo)
static void dumpTableSecLabel(Archive *fout, const TableInfo *tbinfo, const char *reltypename)
static void dumpCompositeTypeColComments(Archive *fout, const TypeInfo *tyinfo, PGresult *res)
static void expand_extension_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names)
void getOpfamilies(Archive *fout)
static void selectDumpableType(TypeInfo *tyinfo, Archive *fout)
static SimpleOidList schema_include_oids
static void dumpOpclass(Archive *fout, const OpclassInfo *opcinfo)
static SimpleStringList schema_exclude_patterns
#define DUMP_COMPONENT_COMMENT
#define DUMP_COMPONENT_DATA
#define DUMP_COMPONENT_USERMAP
#define DUMP_COMPONENT_POLICY
#define DUMP_COMPONENT_SECLABEL
#define DUMP_COMPONENT_ALL
#define DUMP_COMPONENT_ACL
#define DUMP_COMPONENT_NONE
#define DUMP_COMPONENTS_REQUIRING_LOCK
void sortDumpableObjects(DumpableObject **objs, int numObjs, DumpId preBoundaryId, DumpId postBoundaryId)
#define DUMP_COMPONENT_DEFINITION
@ DO_PUBLICATION_TABLE_IN_SCHEMA
void sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs)
#define DUMP_COMPONENT_STATISTICS
static int statistics_only
static int with_statistics
PGDLLIMPORT char * optarg
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define pg_encoding_to_char
#define pg_log_warning(...)
int pg_strcasecmp(const char *s1, const char *s2)
const char * get_progname(const char *argv0)
void printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
PQExpBuffer createPQExpBuffer(void)
void initPQExpBuffer(PQExpBuffer str)
void resetPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen)
void destroyPQExpBuffer(PQExpBuffer str)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
void termPQExpBuffer(PQExpBuffer str)
char * psprintf(const char *fmt,...)
#define RelFileNumberIsValid(relnumber)
bool quote_all_identifiers
void simple_string_list_append(SimpleStringList *list, const char *val)
void simple_ptr_list_append(SimplePtrList *list, void *ptr)
bool simple_oid_list_member(SimpleOidList *list, Oid val)
void simple_oid_list_append(SimpleOidList *list, Oid val)
PGconn * GetConnection(void)
const char * fmtId(const char *rawid)
void setFmtEncoding(int encoding)
void appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
void appendPGArray(PQExpBuffer buffer, const char *value)
bool processSQLNamePattern(PGconn *conn, PQExpBuffer buf, const char *pattern, bool have_where, bool force_escape, const char *schemavar, const char *namevar, const char *altnamevar, const char *visibilityrule, PQExpBuffer dbnamebuf, int *dotcnt)
bool parsePGArray(const char *atext, char ***itemarray, int *nitems)
bool appendReloptionsArray(PQExpBuffer buffer, const char *reloptions, const char *prefix, int encoding, bool std_strings)
void appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
RelFileNumber toast_index_relfilenumber
RelFileNumber toast_relfilenumber
RelFileNumber relfilenumber
struct SimplePtrListCell * next
char val[FLEXIBLE_ARRAY_MEMBER]
struct SimpleStringListCell * next
SimpleStringListCell * head
char * suboriginremotelsn
int disable_dollar_quoting
int serializable_deferrable
int no_unlogged_table_data
const char * lockWaitTimeout
int load_via_partition_root
DumpComponents components
DumpableObjectType objType
DumpComponents dump_contains
pg_compress_specification compression_spec
int disable_dollar_quoting
const char * lockWaitTimeout
struct _relStatsInfo * stats
bool is_identity_sequence
struct _tableInfo ** parents
struct _tableDataInfo * dataObj
const void * defnDumperArg
#define MinTransactionIdAttributeNumber
#define MaxCommandIdAttributeNumber
#define MaxTransactionIdAttributeNumber
#define TableOidAttributeNumber
#define SelfItemPointerAttributeNumber
#define MinCommandIdAttributeNumber
static StringInfo copybuf
static void * fn(void *arg)
#define FirstNormalObjectId
static char * error_detail
bool SplitGUCList(char *rawstring, char separator, List **namelist)