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
984
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
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
1499
1500
1501
1502
1505
1506
1507
1508
1510 {
1513 else
1515 }
1516
1517
1518
1519
1520
1521
1523
1524
1525
1526
1527
1529
1530
1531
1532
1534
1535
1536
1537
1538
1539
1540
1541
1542
1545 "SET TRANSACTION ISOLATION LEVEL "
1546 "SERIALIZABLE, READ ONLY, DEFERRABLE");
1547 else
1549 "SET TRANSACTION ISOLATION LEVEL "
1550 "REPEATABLE READ, READ ONLY");
1551
1552
1553
1554
1555
1556
1559
1561 {
1563
1568 }
1570 {
1572 pg_fatal(
"parallel dumps from standby servers are not supported by this server version");
1574 }
1575}
1576
1577
1578static void
1580{
1581
1582
1583
1584
1585
1586
1591}
1592
1593static char *
1595{
1596 char *query = "SELECT pg_catalog.pg_export_snapshot()";
1599
1603
1605}
1606
1609{
1611
1613
1615 {
1616
1619 }
1636 else
1639}
1640
1641
1642
1643
1644
1645static void
1650{
1655
1657 return;
1658
1660
1661
1662
1663
1664
1665
1667 {
1670
1672 "SELECT oid FROM pg_catalog.pg_namespace n\n");
1678 pg_fatal(
"improper qualified name (too many dotted names): %s",
1683
1686 pg_fatal(
"no matching schemas were found for pattern \"%s\"", cell->
val);
1687
1689 {
1691 }
1692
1695 }
1696
1698}
1699
1700
1701
1702
1703
1704static void
1709{
1714
1716 return;
1717
1719
1720
1721
1722
1723
1725 {
1727
1729 "SELECT oid FROM pg_catalog.pg_extension e\n");
1734 pg_fatal(
"improper qualified name (too many dotted names): %s",
1736
1739 pg_fatal(
"no matching extensions were found for pattern \"%s\"", cell->
val);
1740
1742 {
1744 }
1745
1748 }
1749
1751}
1752
1753
1754
1755
1756
1757static void
1761{
1766
1768 return;
1769
1771
1772
1773
1774
1775
1776
1778 {
1780
1782 "SELECT oid FROM pg_catalog.pg_foreign_server s\n");
1787 pg_fatal(
"improper qualified name (too many dotted names): %s",
1789
1792 pg_fatal(
"no matching foreign servers were found for pattern \"%s\"", cell->
val);
1793
1796
1799 }
1800
1802}
1803
1804
1805
1806
1807
1808
1809static void
1813{
1818
1820 return;
1821
1823
1824
1825
1826
1827
1828
1830 {
1833
1834
1835
1836
1837
1838
1839
1840
1841
1843 {
1845 }
1846
1848 "SELECT c.oid"
1849 "\nFROM pg_catalog.pg_class c"
1850 "\n LEFT JOIN pg_catalog.pg_namespace n"
1851 "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace"
1852 "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY"
1853 "\n (array['%c', '%c', '%c', '%c', '%c', '%c', '%c'])\n",
1859 false,
"n.nspname",
"c.relname",
NULL,
1860 "pg_catalog.pg_table_is_visible(c.oid)", &
dbbuf,
1863 pg_fatal(
"improper relation name (too many dotted names): %s",
1868
1870 {
1872 "\nSELECT i.inhrelid"
1873 "\nFROM partition_tree p"
1874 "\n JOIN pg_catalog.pg_inherits i"
1875 "\n ON p.relid OPERATOR(pg_catalog.=) i.inhparent"
1876 "\n)"
1877 "\nSELECT relid FROM partition_tree");
1878 }
1879
1885 pg_fatal(
"no matching tables were found for pattern \"%s\"", cell->
val);
1886
1888 {
1890 }
1891
1894 }
1895
1897}
1898
1899
1900
1901
1902
1903
1904
1905static void
1907{
1908 const char *db;
1909
1912 pg_fatal(
"You are currently not connected to a database.");
1913
1915 pg_fatal(
"cross-database references are not implemented: %s",
1916 pattern);
1917}
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930static bool
1932{
1934
1936 return false;
1937
1939
1940
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1965 else
1966 {
1969 else
1971 }
1972
1973 return true;
1974}
1975
1976
1977
1978
1979
1980static void
1982{
1983
1984
1985
1986
1987
1989
1990
1991
1992
1993
1994
2000 nsinfo->dobj.catId.oid) ?
2004 {
2005
2006
2007
2008
2009
2011 }
2014 {
2015
2017 }
2019 {
2020
2021
2022
2023
2024
2025
2026
2027
2033
2034
2035
2036
2037
2038
2040 }
2041 else
2043
2044
2045
2046
2047 if (
nsinfo->dobj.dump_contains &&
2051
2052
2053
2054
2055
2056
2057
2058
2060}
2061
2062
2063
2064
2065
2066static void
2068{
2070 return;
2071
2072
2073
2074
2075
2078 tbinfo->dobj.catId.oid) ?
2080 else
2081 tbinfo->dobj.dump =
tbinfo->dobj.namespace->dobj.dump_contains;
2082
2083
2084
2085
2090}
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105static void
2107{
2108
2111 {
2113
2117 else
2119 return;
2120 }
2121
2122
2124 {
2126
2127
2128
2129
2130
2131
2132
2133 }
2134
2136 return;
2137
2138
2139 tyinfo->dobj.dump =
tyinfo->dobj.namespace->dobj.dump_contains;
2140}
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150static void
2152{
2153
2154
2155 if (
dinfo->dobj.namespace)
2156
2157 dinfo->dobj.dump =
dinfo->dobj.namespace->dobj.dump_contains;
2158 else
2161}
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172static void
2174{
2176 return;
2177
2178
2179
2180
2181
2184 else
2187}
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197static void
2199{
2201 return;
2202
2203
2204
2205
2206
2207
2208
2209
2212 else
2213 {
2217 else
2219 }
2220}
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230static void
2232{
2233
2235 {
2237 return;
2238 }
2239
2241 return;
2242
2243
2244
2245
2246
2249 else
2252}
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265static void
2267{
2268
2269
2270
2271
2272
2275 else
2276 {
2277
2283 else
2287
2288
2293 }
2294}
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304static void
2306{
2308 return;
2309
2312}
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322static void
2324{
2326 return;
2327
2328 sobj->dobj.dump =
sobj->dobj.namespace->dobj.dump_contains;
2332}
2333
2334
2335
2336
2337
2338
2339
2340static void
2342{
2344 return;
2345
2346
2347
2348
2349
2350 if (dobj->namespace)
2352 else
2355}
2356
2357
2358
2359
2360
2361
2362static int
2364{
2369
2370
2371
2372
2373
2377 int ret;
2380
2381 pg_log_info(
"dumping contents of table \"%s.%s\"",
2382 tbinfo->dobj.namespace->dobj.name, classname);
2383
2384
2385
2386
2387
2388
2389
2391
2392
2393
2394
2395
2396
2397
2401 {
2402
2405
2407
2409 {
2412 }
2413 else
2415
2419 }
2420 else
2421 {
2425 }
2429
2430 for (;;)
2431 {
2433
2434 if (ret < 0)
2435 break;
2436
2438 {
2441 }
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488 }
2490
2491 if (ret == -2)
2492 {
2493
2494 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetCopyData() failed.", classname);
2498 }
2499
2500
2503 {
2504 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetResult() failed.", classname);
2508 }
2510
2511
2513 pg_log_warning(
"unexpected extra results during COPY of table \"%s\"",
2514 classname);
2515
2517
2518
2521
2522 return 1;
2523}
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533static int
2535{
2541 char *attgenerated;
2543 int nfields,
2547
2548
2551
2552
2553
2554
2555
2556
2557
2558
2561 nfields = 0;
2563 {
2565 continue;
2567 continue;
2568 if (nfields > 0)
2572 else
2574 attgenerated[nfields] =
tbinfo->attgenerated[
i];
2575 nfields++;
2576 }
2577
2578 if (nfields == 0)
2584
2586
2587 while (1)
2588 {
2591
2592
2595 pg_fatal(
"wrong number of fields retrieved from table \"%s\"",
2597
2598
2599
2600
2601
2602
2603
2604
2606 {
2608
2610
2611
2612
2613
2614
2615
2616 if (
tbinfo->ispartition &&
2620 else
2622
2625
2626
2627 if (nfields == 0)
2628 {
2630 }
2631 else
2632 {
2633
2635 {
2637 for (int field = 0; field < nfields; field++)
2638 {
2639 if (field > 0)
2643 }
2645 }
2646
2647 if (
tbinfo->needs_override)
2649
2651 }
2652 }
2653
2654 for (
int tuple = 0; tuple <
PQntuples(res); tuple++)
2655 {
2656
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669 if (nfields == 0)
2670 continue;
2671
2672
2677 else
2679
2680 for (int field = 0; field < nfields; field++)
2681 {
2682 if (field > 0)
2684 if (attgenerated[field])
2685 {
2687 continue;
2688 }
2690 {
2692 continue;
2693 }
2694
2695
2697 {
2705 {
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717 const char *s =
PQgetvalue(res, tuple, field);
2718
2721 else
2723 }
2724 break;
2725
2730 break;
2731
2735 else
2737 break;
2738
2739 default:
2740
2746 break;
2747 }
2748 }
2749
2750
2752
2753
2755 {
2758 else
2760
2762 }
2763 }
2764
2766 {
2768 break;
2769 }
2771 }
2772
2773
2775 {
2778 else
2780 }
2781
2783
2785
2790
2791
2794
2795 return 1;
2796}
2797
2798
2799
2800
2801
2804{
2806
2809
2812 {
2815 }
2816
2818}
2819
2820
2821
2822
2823
2824
2825
2826
2827static bool
2829{
2831
2834
2837 return true;
2839 {
2843 return true;
2844 }
2845
2846 return false;
2847}
2848
2849
2850
2851
2852
2853
2854
2855static void
2857{
2864 char *copyStmt;
2866
2867
2869
2870
2871
2872
2873
2874
2875
2876 if (
tbinfo->ispartition &&
2879 {
2882
2890 }
2891 else
2893
2895 {
2896
2898
2904 }
2905 else
2906 {
2907
2910 }
2911
2912
2913
2914
2915
2916
2918 {
2920
2923 .namespace =
tbinfo->dobj.namespace->dobj.name,
2924 .owner =
tbinfo->rolname,
2925 .description = "TABLE DATA",
2928 .copyStmt = copyStmt,
2929 .deps = &(
tbinfo->dobj.dumpId),
2930 .nDeps = 1,
2931 .dumpFn = dumpFn,
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2947
2948
2949
2950
2951
2952
2953 if (sizeof(te->dataLength) == 4 &&
2955 te->dataLength < 0))
2957 }
2958
2961}
2962
2963
2964
2965
2966
2967
2968
2969
2970static void
2972{
2975
2976
2977 if (!
tbinfo->relispopulated)
2978 return;
2979
2981
2984
2990 .namespace =
tbinfo->dobj.namespace->dobj.name,
2991 .owner =
tbinfo->rolname,
2992 .description = "MATERIALIZED VIEW DATA",
2994 .createStmt = q->
data,
2995 .deps =
tdinfo->dobj.dependencies,
2996 .nDeps =
tdinfo->dobj.nDeps));
2997
2999}
3000
3001
3002
3003
3004
3005static void
3007{
3009
3011 {
3013 (!relkind || tblinfo[
i].relkind == relkind))
3015 }
3016}
3017
3018
3019
3020
3021
3022
3023
3024static void
3026{
3028
3029
3030
3031
3032
3034 return;
3035
3036
3038 return;
3039
3041 return;
3042
3046 tbinfo->foreign_server)))
3047 return;
3048
3050 return;
3051
3052
3055 return;
3056
3057
3060 return;
3061
3062
3064
3069 else
3071
3072
3073
3074
3075
3076 tdinfo->dobj.catId.tableoid = 0;
3084
3085
3087
3089
3090
3091
3092
3093
3094
3095
3096
3098 {
3101 }
3102
3103
3104 tbinfo->interesting =
true;
3105}
3106
3107
3108
3109
3110
3111
3112
3113
3114static void
3116{
3119 int ntups,
3124
3125
3127 return;
3128
3130
3132 "( "
3133 "SELECT d1.objid, d2.refobjid, c2.relkind AS refrelkind "
3134 "FROM pg_depend d1 "
3135 "JOIN pg_class c1 ON c1.oid = d1.objid "
3137 " JOIN pg_rewrite r1 ON r1.ev_class = d1.objid "
3138 "JOIN pg_depend d2 ON d2.classid = 'pg_rewrite'::regclass "
3139 "AND d2.objid = r1.oid "
3140 "AND d2.refobjid <> d1.objid "
3141 "JOIN pg_class c2 ON c2.oid = d2.refobjid "
3144 "WHERE d1.classid = 'pg_class'::regclass "
3145 "UNION "
3146 "SELECT w.objid, d3.refobjid, c3.relkind "
3147 "FROM w "
3148 "JOIN pg_rewrite r3 ON r3.ev_class = w.refobjid "
3149 "JOIN pg_depend d3 ON d3.classid = 'pg_rewrite'::regclass "
3150 "AND d3.objid = r3.oid "
3151 "AND d3.refobjid <> w.refobjid "
3152 "JOIN pg_class c3 ON c3.oid = d3.refobjid "
3155 ") "
3156 "SELECT 'pg_class'::regclass::oid AS classid, objid, refobjid "
3157 "FROM w "
3159
3161
3163
3167
3168 for (
i = 0;
i < ntups;
i++)
3169 {
3176
3181
3184 continue;
3185
3191 continue;
3193
3196 continue;
3197
3203 continue;
3205
3207
3209 tbinfo->relispopulated =
false;
3210 }
3211
3213
3215}
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229static void
3231{
3235
3236
3239 {
3241 {
3244
3245
3248 continue;
3252 continue;
3253
3254
3255
3256
3257
3259 ftable->dataObj->dobj.dumpId);
3260 }
3261 }
3263}
3264
3265
3266
3267
3268
3269
3270static void
3272{
3305 *collate,
3306 *ctype,
3307 *locale,
3313 minmxid;
3315
3317
3318
3319
3320
3322 "datdba, "
3323 "pg_encoding_to_char(encoding) AS encoding, "
3324 "datcollate, datctype, datfrozenxid, "
3325 "datacl, acldefault('d', datdba) AS acldefault, "
3326 "datistemplate, datconnlimit, ");
3329 else
3335 else
3339 else
3342 "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
3343 "shobj_description(oid, 'pg_database') AS description "
3344 "FROM pg_database "
3345 "WHERE datname = current_database()");
3346
3348
3367
3378 else
3382 else
3391
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3406 {
3408 "CREATE DATABASE %s WITH TEMPLATE = template0 "
3409 "OID = %u STRATEGY = FILE_COPY",
3411 }
3412 else
3413 {
3416 }
3418 {
3421 }
3422
3430 else
3431 pg_fatal(
"unrecognized locale provider: %s",
3433
3434 if (
strlen(collate) > 0 &&
strcmp(collate, ctype) == 0)
3435 {
3438 }
3439 else
3440 {
3442 {
3445 }
3447 {
3450 }
3451 }
3452 if (locale)
3453 {
3456 else
3458
3460 }
3461
3463 {
3466 }
3467
3468
3469
3470
3471
3473 {
3475 {
3480 }
3481 }
3482
3483
3484
3485
3486
3487
3488
3489
3490
3496
3499
3501
3510 .dropStmt =
delQry->data));
3511
3512
3514
3515
3516 {
3517
3518
3519
3520
3521
3523
3525 {
3527
3528
3529
3530
3531
3535
3539 .description = "COMMENT",
3541 .createStmt =
dbQry->data,
3543 .nDeps = 1));
3544 }
3545 }
3546
3547
3549 {
3552
3554
3563 .description = "SECURITY LABEL",
3567 .nDeps = 1));
3570 }
3571
3572
3573
3574
3575
3578
3582
3583
3584
3585
3586
3587
3588
3589
3590
3593
3597
3599 {
3602
3603
3604
3605
3606
3607
3608
3609
3611 "SET datistemplate = false WHERE datname = ");
3614 }
3615
3616
3617
3618
3619
3620
3621
3623
3624
3625
3626
3627
3629 {
3632 "SET datfrozenxid = '%u', datminmxid = '%u'\n"
3633 "WHERE datname = ",
3634 frozenxid, minmxid);
3637 }
3638
3646 .dropStmt =
delQry->data,
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3660 {
3671
3674 "FROM pg_catalog.pg_class\n"
3675 "WHERE oid IN (%u, %u, %u, %u);\n",
3678 else
3680 "FROM pg_catalog.pg_class\n"
3681 "WHERE oid IN (%u, %u);\n",
3683
3685
3690
3696 {
3701
3704
3707 {
3710 }
3711 else
3712 {
3715 }
3716
3718 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
3719 "WHERE oid = %u;\n",
3723
3727 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
3728 relfilenumber);
3732 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
3733 relfilenumber);
3734 }
3735
3737 "TRUNCATE pg_catalog.pg_largeobject;\n");
3739 "TRUNCATE pg_catalog.pg_largeobject_metadata;\n");
3740
3743
3749
3756
3758
3764 }
3765
3767
3773}
3774
3775
3776
3777
3778
3779static void
3782{
3786
3787
3789 "WHERE setrole = 0 AND setdatabase = '%u'::oid",
3790 dboid);
3791
3793
3797 outbuf);
3798
3800
3801
3803 "FROM pg_db_role_setting s, pg_roles r "
3804 "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
3805 dboid);
3806
3808
3813 outbuf);
3814
3816
3818}
3819
3820
3821
3822
3823static void
3825{
3828
3830
3834
3839 .createStmt = qry->
data));
3840
3842}
3843
3844
3845
3846
3847
3848static void
3850{
3853
3854 pg_log_info(
"saving \"standard_conforming_strings = %s\"",
3856
3859
3864 .createStmt = qry->
data));
3865
3867}
3868
3869
3870
3871
3872static void
3874{
3881
3882
3883
3884
3885
3886
3887
3888
3890 "SELECT pg_catalog.current_schemas(false)");
3891
3893 pg_fatal(
"could not parse result of current_schemas()");
3894
3895
3896
3897
3898
3899
3900
3902 {
3906 }
3907
3911
3913
3918 .createStmt = qry->
data));
3919
3920
3922
3927}
3928
3929
3930
3931
3932
3933
3934static void
3936{
3940 int ntups;
3942 int n;
3947
3949
3950
3951
3952
3953
3955 "SELECT oid, lomowner, lomacl, "
3956 "acldefault('L', lomowner) AS acldefault "
3957 "FROM pg_largeobject_metadata ");
3958
3959
3960
3961
3962
3963
3964
3965
3968 "WHERE oid IN "
3969 "(SELECT objoid FROM pg_description "
3971 "UNION SELECT objoid FROM pg_seclabel "
3973
3975 "ORDER BY lomowner, lomacl::pg_catalog.text, oid");
3976
3978
3983
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994 for (
i = 0;
i < ntups;
i += n)
3995 {
4002
4003
4004 n = 1;
4006 {
4009 break;
4010 n++;
4011 }
4012
4013
4015
4020
4021 if (n > 1)
4024 else
4029 loinfo->dacl.privtype = 0;
4034
4035 for (int k = 1; k < n; k++)
4036 {
4038
4040
4041
4045 }
4046
4047
4049
4050
4053
4054
4055
4056
4057
4058
4059
4062
4063
4064
4065
4066
4073
4077 }
4078
4081}
4082
4083
4084
4085
4086
4087
4088static void
4090{
4092
4093
4094
4095
4096
4097 for (
int i = 0;
i <
loinfo->numlos;
i++)
4099
4103 .owner =
loinfo->rolname,
4104 .description = "BLOB METADATA",
4106 .createStmt =
cquery->data,
4107 .dropStmt = "-- dummy"));
4108
4109
4110
4111
4112
4115 {
4116 for (
int i = 0;
i <
loinfo->numlos;
i++)
4117 {
4120
4121
4125
4129 catId, 0,
loinfo->dobj.dumpId);
4130
4134 catId, 0,
loinfo->dobj.dumpId);
4135 }
4136 }
4137
4138
4139
4140
4141
4142
4143
4144
4146 {
4148
4149
4151
4153 {
4155
4158
4162 }
4163 else
4164 {
4168 }
4169 }
4170
4172}
4173
4174
4175
4176
4177
4178static int
4180{
4184
4186
4187 for (
int i = 0;
i <
loinfo->numlos;
i++)
4188 {
4190 int loFd;
4191 int cnt;
4192
4193
4195 if (loFd == -1)
4196 pg_fatal(
"could not open large object %u: %s",
4198
4200
4201
4202 do
4203 {
4205 if (cnt < 0)
4206 pg_fatal(
"error reading large object %u: %s",
4208
4210 } while (cnt > 0);
4211
4213
4215 }
4216
4217 return 1;
4218}
4219
4220
4221
4222
4223
4224void
4226{
4243 ntups;
4244
4245
4247 return;
4248
4249
4251 return;
4252
4255
4256
4257
4258
4261 {
4263
4264
4266 continue;
4267
4268
4271 continue;
4272
4273
4277
4278
4280 {
4282
4283
4284
4285
4286
4287
4288
4289
4292 polinfo->dobj.catId.tableoid = 0;
4304 }
4305 }
4307
4308
4309
4310
4311
4312
4313
4314 pg_log_info(
"reading row-level security policies");
4315
4317 "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
4320 else
4323 "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
4324 " 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, "
4325 "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
4326 "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
4327 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
4328 "JOIN pg_catalog.pg_policy pol ON (src.tbloid = pol.polrelid)",
4330
4332
4334 if (ntups > 0)
4335 {
4345
4347
4348 for (
j = 0;
j < ntups;
j++)
4349 {
4352
4354
4364
4367
4370 else
4372
4375 else
4377
4380 else
4383 }
4384 }
4385
4387
4390}
4391
4392
4393
4394
4395
4396static void
4398{
4405 const char *cmd;
4406 char *tag;
4407
4408
4410 return;
4411
4412
4413
4414
4415
4416
4418 {
4420
4423
4424
4425
4426
4427
4428
4432 .namespace =
polinfo->dobj.namespace->dobj.name,
4433 .owner =
tbinfo->rolname,
4434 .description = "ROW SECURITY",
4436 .createStmt = query->
data,
4437 .deps = &(
tbinfo->dobj.dumpId),
4438 .nDeps = 1));
4439
4441 return;
4442 }
4443
4445 cmd = "";
4446 else if (
polinfo->polcmd ==
'r')
4447 cmd = " FOR SELECT";
4448 else if (
polinfo->polcmd ==
'a')
4449 cmd = " FOR INSERT";
4450 else if (
polinfo->polcmd ==
'w')
4451 cmd = " FOR UPDATE";
4452 else if (
polinfo->polcmd ==
'd')
4453 cmd = " FOR DELETE";
4454 else
4455 pg_fatal(
"unexpected policy command type: %c",
4457
4461
4463
4465
4467 !
polinfo->polpermissive ?
" AS RESTRICTIVE" :
"", cmd);
4468
4471
4474
4477
4479
4482
4485
4487
4491 .
namespace =
polinfo->dobj.namespace->dobj.name,
4492 .owner =
tbinfo->rolname,
4493 .description = "POLICY",
4495 .createStmt = query->
data,
4496 .dropStmt =
delqry->data));
4497
4502
4508}
4509
4510
4511
4512
4513
4514void
4516{
4534 ntups;
4535
4537 return;
4538
4540
4541
4543 "p.pubowner, p.puballtables, p.pubinsert, "
4544 "p.pubupdate, p.pubdelete, ");
4545
4548 else
4550
4553 else
4555
4558 else
4560
4563 else
4565
4567
4569
4571
4572 if (ntups == 0)
4574
4587
4589
4590 for (
i = 0;
i < ntups;
i++)
4591 {
4616 {
4618 };
4619
4620
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4638 {
4641
4644 "SELECT prrelid\n"
4645 "FROM pg_catalog.pg_publication_rel\n"
4646 "WHERE prpubid = %u AND prexcept",
4648
4650
4652
4654 {
4657
4659
4661
4664 }
4665
4667 }
4668 }
4669
4672
4674}
4675
4676
4677
4678
4679
4680static void
4682{
4687 bool first = true;
4688
4689
4691 return;
4692
4695
4697
4700
4703
4705 {
4707
4709
4710
4712 {
4714
4717 else
4720 }
4723
4726 }
4727 else if (
pubinfo->puballsequences)
4729
4732 {
4734 first = false;
4735 }
4736
4738 {
4739 if (!first)
4741
4743 first = false;
4744 }
4745
4747 {
4748 if (!first)
4750
4752 first = false;
4753 }
4754
4756 {
4757 if (!first)
4759
4761 first = false;
4762 }
4763
4765
4768
4771
4773
4778 .description = "PUBLICATION",
4780 .createStmt = query->
data,
4781 .dropStmt =
delq->data));
4782
4787
4792
4796}
4797
4798
4799
4800
4801
4802void
4804{
4815 ntups;
4816
4818 return;
4819
4821
4822
4824 "SELECT tableoid, oid, pnpubid, pnnspid "
4825 "FROM pg_catalog.pg_publication_namespace");
4827
4829
4834
4835
4838
4839 for (
i = 0;
i < ntups;
i++)
4840 {
4845
4846
4847
4848
4849
4852 continue;
4855 continue;
4856
4857
4867
4868
4870
4872 }
4873
4876}
4877
4878
4879
4880
4881
4882void
4884{
4897 ntups;
4898
4900 return;
4901
4903
4904
4906 {
4908 "SELECT tableoid, oid, prpubid, prrelid, "
4909 "pg_catalog.pg_get_expr(prqual, prrelid) AS prrelqual, "
4910 "(CASE\n"
4911 " WHEN pr.prattrs IS NOT NULL THEN\n"
4912 " (SELECT array_agg(attname)\n"
4913 " FROM\n"
4914 " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
4915 " pg_catalog.pg_attribute\n"
4916 " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
4917 " ELSE NULL END) prattrs "
4918 "FROM pg_catalog.pg_publication_rel pr");
4921 }
4922 else
4924 "SELECT tableoid, oid, prpubid, prrelid, "
4925 "NULL AS prrelqual, NULL AS prattrs "
4926 "FROM pg_catalog.pg_publication_rel");
4928
4930
4937
4938
4941
4942 for (
i = 0;
i < ntups;
i++)
4943 {
4948
4949
4950
4951
4952
4955 continue;
4958 continue;
4959
4960
4972 else
4974
4976 {
4977 char **attnames;
4980
4983 pg_fatal(
"could not parse %s array",
"prattrs");
4986 {
4987 if (k > 0)
4989
4991 }
4995 }
4996 else
4998
4999
5001
5003 }
5004
5007}
5008
5009
5010
5011
5012
5013static void
5015{
5020 char *tag;
5021
5022
5024 return;
5025
5027
5029
5032
5033
5034
5035
5036
5042 .description = "PUBLICATION TABLES IN SCHEMA",
5044 .createStmt = query->
data));
5045
5046
5047
5050}
5051
5052
5053
5054
5055
5056static void
5058{
5063 char *tag;
5064
5065
5067 return;
5068
5070
5072
5077
5080
5082 {
5083
5084
5085
5086
5087
5089 }
5091
5092
5093
5094
5095
5096
5097
5098
5102 .
namespace =
tbinfo->dobj.namespace->dobj.name,
5104 .description = "PUBLICATION TABLE",
5106 .createStmt = query->
data));
5107
5108
5109
5112}
5113
5114
5115
5116
5117static bool
5119{
5122
5124
5126 return true;
5127
5128 return false;
5129}
5130
5131
5132
5133
5134
5135
5136static void
5138{
5141
5143 "SELECT set_config(name, '%s', false) "
5144 "FROM pg_settings "
5145 "WHERE name = 'restrict_nonsystem_relation_kind'",
5148
5151}
5152
5153
5154
5155
5156
5157void
5159{
5187 ntups;
5188
5190 return;
5191
5193 {
5194 int n;
5195
5197 "SELECT count(*) FROM pg_subscription "
5198 "WHERE subdbid = (SELECT oid FROM pg_database"
5199 " WHERE datname = current_database())",
5202 if (n > 0)
5203 pg_log_warning(
"subscriptions not dumped because current user is not a superuser");
5205 return;
5206 }
5207
5209
5210
5212 "SELECT s.tableoid, s.oid, s.subname,\n"
5213 " s.subowner,\n"
5214 " s.subconninfo, s.subslotname, s.subsynccommit,\n"
5215 " s.subpublications,\n");
5216
5219 else
5221
5224 else
5226
5229 " s.subtwophasestate,\n"
5230 " s.subdisableonerr,\n");
5231 else
5233 " '%c' AS subtwophasestate,\n"
5234 " false AS subdisableonerr,\n",
5236
5239 " s.subpasswordrequired,\n"
5240 " s.subrunasowner,\n"
5241 " s.suborigin,\n");
5242 else
5244 " 't' AS subpasswordrequired,\n"
5245 " 't' AS subrunasowner,\n"
5246 " '%s' AS suborigin,\n",
5248
5251 " s.subenabled,\n");
5252 else
5254 " false AS subenabled,\n");
5255
5258 " s.subfailover,\n");
5259 else
5261 " false AS subfailover,\n");
5262
5265 " s.subretaindeadtuples,\n");
5266 else
5268 " false AS subretaindeadtuples,\n");
5269
5272 " s.submaxretention,\n");
5273 else
5275
5278 " s.subwalrcvtimeout,\n");
5279 else
5281 " '-1' AS subwalrcvtimeout,\n");
5282
5285 else
5287
5289 "FROM pg_subscription s\n");
5290
5293 "LEFT JOIN pg_catalog.pg_foreign_server fs \n"
5294 " ON fs.oid = s.subserver \n");
5295
5298 "LEFT JOIN pg_catalog.pg_replication_origin_status o \n"
5299 " ON o.external_id = 'pg_' || s.oid::text \n");
5300
5302 "WHERE s.subdbid = (SELECT oid FROM pg_database\n"
5303 " WHERE datname = current_database())");
5304
5306
5308
5309
5310
5311
5312
5335
5337
5338 for (
i = 0;
i < ntups;
i++)
5339 {
5347
5351 subinfo[
i].subservername =
NULL;
5352 else
5372 else
5377 else
5389 else
5392
5393
5395 }
5397
5399}
5400
5401
5402
5403
5404
5405
5406void
5408{
5417 int ntups;
5419
5422 return;
5423
5425 "SELECT srsubid, srrelid, srsubstate, srsublsn "
5426 "FROM pg_catalog.pg_subscription_rel "
5427 "ORDER BY srsubid",
5430 if (ntups == 0)
5432
5433
5438
5440 for (
int i = 0;
i < ntups;
i++)
5441 {
5445
5446
5447
5448
5449
5451 {
5453 if (subinfo ==
NULL)
5455
5457 }
5458
5460 if (tblinfo ==
NULL)
5461 pg_fatal(
"failed sanity check, relation with OID %u not found",
5462 relid);
5463
5464
5466 subrinfo[
i].dobj.catId.tableoid = relid;
5476 else
5478
5479
5481 }
5482
5485}
5486
5487
5488
5489
5490
5491
5492static void
5494{
5498 char *tag;
5499
5500
5502 return;
5503
5505
5507
5509
5511 {
5512
5513
5514
5515
5516
5518 "\n-- For binary upgrade, must preserve the subscriber table.\n");
5520 "SELECT pg_catalog.binary_upgrade_add_sub_rel_state(");
5523 ", %u, '%c'",
5526
5529 else
5531
5533 }
5534
5535
5536
5537
5538
5539
5540
5541
5545 .
namespace =
subrinfo->tblinfo->dobj.namespace->dobj.name,
5547 .description = "SUBSCRIPTION TABLE",
5549 .createStmt = query->
data));
5550
5551
5552
5555}
5556
5557
5558
5559
5560
5561static void
5563{
5572
5573
5575 return;
5576
5579
5581
5584
5588 {
5590 }
5591 else
5592 {
5595 }
5596
5597
5599 pg_fatal(
"could not parse %s array",
"subpublications");
5600
5603 {
5606
5608 }
5609
5610 appendPQExpBuffer(query,
" PUBLICATION %s WITH (connect = false, slot_name = ", publications->
data);
5613 else
5615
5618
5623 else
5625
5628
5631
5634
5637
5640
5643
5646
5649
5652
5655
5657
5658
5659
5660
5661
5663 {
5665 {
5666
5667
5668
5669
5670
5671
5672
5673
5674
5676 "\n-- For binary upgrade, must preserve the remote_lsn for the subscriber's replication origin.\n");
5678 "SELECT pg_catalog.binary_upgrade_replorigin_advance(");
5681 }
5682
5684 {
5685
5686
5687
5688
5690 "\n-- For binary upgrade, must preserve the subscriber's running state.\n");
5692 }
5693 }
5694
5699 .description = "SUBSCRIPTION",
5701 .createStmt = query->
data,
5702 .dropStmt =
delq->data));
5703
5708
5713
5716
5720}
5721
5722
5723
5724
5725
5726static void
5731 const char *keyword,
5732 const char *objname)
5733{
5735 {
5739 int ntups;
5742
5743
5745
5748 "SELECT e.extname "
5749 "FROM pg_catalog.pg_depend d, pg_catalog.pg_extension e "
5750 "WHERE d.refobjid = e.oid AND classid = '%s'::pg_catalog.regclass "
5751 "AND objid = '%u'::pg_catalog.oid AND deptype = 'x' "
5752 "AND refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass",
5758 for (
i = 0;
i < ntups;
i++)
5759 {
5763 }
5764
5768 }
5769}
5770
5773{
5774
5775
5776
5777
5778
5779
5780
5781
5785
5786 do
5787 {
5790 "SELECT EXISTS(SELECT 1 "
5791 "FROM pg_catalog.pg_type "
5792 "WHERE oid = '%u'::pg_catalog.oid);",
5798
5800}
5801
5802static void
5808{
5815
5818 "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5820
5824 else
5826
5829
5831 {
5833 "\n-- For binary upgrade, must preserve pg_type array oid\n");
5835 "SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5837 }
5838
5839
5840
5841
5843 {
5845 {
5847 "SELECT t.oid, t.typarray "
5848 "FROM pg_catalog.pg_type t "
5849 "JOIN pg_catalog.pg_range r "
5850 "ON t.oid = r.rngmultitypid "
5851 "WHERE r.rngtypid = '%u'::pg_catalog.oid;",
5853
5855
5858
5860 }
5861 else
5862 {
5865 }
5866
5868 "\n-- For binary upgrade, must preserve multirange pg_type oid\n");
5870 "SELECT pg_catalog.binary_upgrade_set_next_multirange_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5873 "\n-- For binary upgrade, must preserve multirange pg_type array oid\n");
5875 "SELECT pg_catalog.binary_upgrade_set_next_multirange_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5877 }
5878
5880}
5881
5882static void
5886{
5888
5892}
5893
5894
5895
5896
5897static int
5899{
5902
5904}
5905
5906
5907
5908
5909
5910
5911
5912
5913static void
5915{
5917 const char *query;
5918
5919 query = "SELECT c.oid, c.relkind, c.relfilenode, c.reltoastrelid, "
5920 "ct.relfilenode, i.indexrelid, cti.relfilenode "
5921 "FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_index i "
5922 "ON (c.reltoastrelid = i.indrelid AND i.indisvalid) "
5923 "LEFT JOIN pg_catalog.pg_class ct ON (c.reltoastrelid = ct.oid) "
5924 "LEFT JOIN pg_catalog.pg_class AS cti ON (i.indexrelid = cti.oid) "
5925 "ORDER BY c.oid;";
5926
5928
5932
5934 {
5942 }
5943
5945}
5946
5947static void
5950{
5953
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5971
5973 "\n-- For binary upgrade, must preserve pg_class oids and relfilenodes\n");
5974
5977 {
5979 "SELECT pg_catalog.binary_upgrade_set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
5981
5982
5983
5984
5985
5986
5990 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
5992
5993
5994
5995
5996
5999 {
6001 "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
6004 "SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
6006
6007
6009 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
6012 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
6014 }
6015 }
6016 else
6017 {
6018
6020 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
6023 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
6025 }
6026
6028}
6029
6030
6031
6032
6033
6034
6035
6036
6037static void
6040 const char *objtype,
6041 const char *objname,
6043{
6046
6048 return;
6049
6050
6051
6052
6053
6054
6055
6057 {
6060 break;
6062 }
6064 pg_fatal(
"could not find parent extension for %s %s",
6065 objtype, objname);
6066
6068 "\n-- For binary upgrade, handle extension membership the hard way\n");
6071 objtype);
6075}
6076
6077
6078
6079
6080
6081void
6083{
6085 int ntups;
6095
6097
6098
6099
6100
6101
6103 "n.nspowner, "
6104 "n.nspacl, "
6105 "acldefault('n', n.nspowner) AS acldefault "
6106 "FROM pg_namespace n");
6107
6109
6111
6113
6120
6121 for (
i = 0;
i < ntups;
i++)
6122 {
6123 const char *nspowner;
6124
6137
6138
6140
6141
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6162 {
6165
6166
6177
6178 nsinfo[
i].dacl.privtype =
'i';
6181
6184 }
6185 }
6186
6189}
6190
6191
6192
6193
6194
6197{
6199
6204}
6205
6206
6207
6208
6209
6210
6211
6212
6215{
6218 int ntups;
6230
6232
6234 "x.extname, n.nspname, x.extrelocatable, x.extversion, x.extconfig, x.extcondition "
6235 "FROM pg_extension x "
6236 "JOIN pg_namespace n ON n.oid = x.extnamespace");
6237
6239
6241 if (ntups == 0)
6243
6245
6254
6255 for (
i = 0;
i < ntups;
i++)
6256 {
6267
6268
6270 }
6271
6275
6277
6279}
6280
6281
6282
6283
6284
6285
6286
6287
6288void
6290{
6292 int ntups;
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6328 "typnamespace, typacl, "
6329 "acldefault('T', typowner) AS acldefault, "
6330 "typowner, "
6331 "typelem, typrelid, typarray, "
6332 "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
6333 "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
6334 "typtype, typisdefined, "
6335 "typname[0] = '_' AND typelem != 0 AND "
6336 "(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray "
6337 "FROM pg_type");
6338
6340
6342
6344
6359
6360 for (
i = 0;
i < ntups;
i++)
6361 {
6380
6383 else
6385
6388 else
6390
6392
6394 tyinfo[
i].isMultirange =
true;
6395 else
6396 tyinfo[
i].isMultirange =
false;
6397
6398
6400
6401
6404
6405
6406
6407
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6428 {
6437
6438
6439
6440
6441
6442
6444 }
6445 }
6446
6448
6450}
6451
6452
6453
6454
6455
6456void
6458{
6460 int ntups;
6473
6474
6475
6476
6477
6478
6480 "oprnamespace, "
6481 "oprowner, "
6482 "oprkind, "
6483 "oprleft, "
6484 "oprright, "
6485 "oprcode::oid AS oprcode "
6486 "FROM pg_operator");
6487
6489
6491
6493
6503
6504 for (
i = 0;
i < ntups;
i++)
6505 {
6518
6519
6521 }
6522
6524
6526}
6527
6528
6529
6530
6531
6532void
6534{
6536 int ntups;
6546
6548
6549
6550
6551
6552
6553
6555 "collnamespace, "
6556 "collowner, "
6557 "collencoding "
6558 "FROM pg_collation");
6559
6561
6563
6565
6572
6573 for (
i = 0;
i < ntups;
i++)
6574 {
6584
6585
6587 }
6588
6590
6592}
6593
6594
6595
6596
6597
6598void
6600{
6602 int ntups;
6611
6613
6614
6615
6616
6617
6618
6620 "connamespace, "
6621 "conowner "
6622 "FROM pg_conversion");
6623
6625
6627
6629
6635
6636 for (
i = 0;
i < ntups;
i++)
6637 {
6646
6647
6649 }
6650
6652
6654}
6655
6656
6657
6658
6659
6660void
6662{
6664 int ntups;
6673
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6689 "amtype, "
6690 "amhandler::pg_catalog.regproc AS amhandler ");
6691 else
6693 "'i'::pg_catalog.\"char\" AS amtype, "
6694 "'-'::pg_catalog.regproc AS amhandler ");
6696
6698
6700
6702
6708
6709 for (
i = 0;
i < ntups;
i++)
6710 {
6719
6720
6722 }
6723
6725
6727}
6728
6729
6730
6731
6732
6733
6734void
6736{
6738 int ntups;
6748
6749
6750
6751
6752
6753
6755 "opcnamespace, "
6756 "opcowner "
6757 "FROM pg_opclass");
6758
6760
6762
6764
6771
6772 for (
i = 0;
i < ntups;
i++)
6773 {
6783
6784
6786 }
6787
6789
6791}
6792
6793
6794
6795
6796
6797void
6799{
6801 int ntups;
6811
6813
6814
6815
6816
6817
6818
6820 "opfnamespace, "
6821 "opfowner "
6822 "FROM pg_opfamily");
6823
6825
6827
6829
6836
6837 for (
i = 0;
i < ntups;
i++)
6838 {
6848
6849
6851 }
6852
6854
6856}
6857
6858
6859
6860
6861
6862void
6864{
6867 int ntups;
6880
6881
6882
6883
6884
6886 {
6888
6890 : "p.proisagg");
6891
6893 "p.proname AS aggname, "
6894 "p.pronamespace AS aggnamespace, "
6895 "p.pronargs, p.proargtypes, "
6896 "p.proowner, "
6897 "p.proacl AS aggacl, "
6898 "acldefault('f', p.proowner) AS acldefault "
6899 "FROM pg_proc p "
6900 "LEFT JOIN pg_init_privs pip ON "
6901 "(p.oid = pip.objoid "
6902 "AND pip.classoid = 'pg_proc'::regclass "
6903 "AND pip.objsubid = 0) "
6904 "WHERE %s AND ("
6905 "p.pronamespace != "
6906 "(SELECT oid FROM pg_namespace "
6907 "WHERE nspname = 'pg_catalog') OR "
6908 "p.proacl IS DISTINCT FROM pip.initprivs",
6912 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6913 "classid = 'pg_proc'::regclass AND "
6914 "objid = p.oid AND "
6915 "refclassid = 'pg_extension'::regclass AND "
6916 "deptype = 'e')");
6918 }
6919 else
6920 {
6922 "pronamespace AS aggnamespace, "
6923 "pronargs, proargtypes, "
6924 "proowner, "
6925 "proacl AS aggacl, "
6926 "acldefault('f', proowner) AS acldefault "
6927 "FROM pg_proc p "
6928 "WHERE proisagg AND ("
6929 "pronamespace != "
6930 "(SELECT oid FROM pg_namespace "
6931 "WHERE nspname = 'pg_catalog')");
6934 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6935 "classid = 'pg_proc'::regclass AND "
6936 "objid = p.oid AND "
6937 "refclassid = 'pg_extension'::regclass AND "
6938 "deptype = 'e')");
6940 }
6941
6943
6945
6947
6957
6958 for (
i = 0;
i < ntups;
i++)
6959 {
6969 agginfo[
i].aggfn.dacl.privtype = 0;
6977 else
6978 {
6983 }
6984 agginfo[
i].aggfn.postponed_def =
false;
6985
6986
6988
6989
6992 }
6993
6995
6997}
6998
6999
7000
7001
7002
7003void
7005{
7008 int ntups;
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7046 {
7048
7050 : "NOT p.proisagg");
7051
7053 "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
7054 "p.pronargs, p.proargtypes, p.prorettype, "
7055 "p.proacl, "
7056 "acldefault('f', p.proowner) AS acldefault, "
7057 "p.pronamespace, "
7058 "p.proowner "
7059 "FROM pg_proc p "
7060 "LEFT JOIN pg_init_privs pip ON "
7061 "(p.oid = pip.objoid "
7062 "AND pip.classoid = 'pg_proc'::regclass "
7063 "AND pip.objsubid = 0) "
7064 "WHERE %s"
7065 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
7066 "WHERE classid = 'pg_proc'::regclass AND "
7067 "objid = p.oid AND deptype = 'i')"
7068 "\n AND ("
7069 "\n pronamespace != "
7070 "(SELECT oid FROM pg_namespace "
7071 "WHERE nspname = 'pg_catalog')"
7072 "\n OR EXISTS (SELECT 1 FROM pg_cast"
7073 "\n WHERE pg_cast.oid > %u "
7074 "\n AND p.oid = pg_cast.castfunc)"
7075 "\n OR EXISTS (SELECT 1 FROM pg_transform"
7076 "\n WHERE pg_transform.oid > %u AND "
7077 "\n (p.oid = pg_transform.trffromsql"
7078 "\n OR p.oid = pg_transform.trftosql))",
7084 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
7085 "classid = 'pg_proc'::regclass AND "
7086 "objid = p.oid AND "
7087 "refclassid = 'pg_extension'::regclass AND "
7088 "deptype = 'e')");
7090 "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
7092 }
7093 else
7094 {
7096 "SELECT tableoid, oid, proname, prolang, "
7097 "pronargs, proargtypes, prorettype, proacl, "
7098 "acldefault('f', proowner) AS acldefault, "
7099 "pronamespace, "
7100 "proowner "
7101 "FROM pg_proc p "
7102 "WHERE NOT proisagg"
7103 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
7104 "WHERE classid = 'pg_proc'::regclass AND "
7105 "objid = p.oid AND deptype = 'i')"
7106 "\n AND ("
7107 "\n pronamespace != "
7108 "(SELECT oid FROM pg_namespace "
7109 "WHERE nspname = 'pg_catalog')"
7110 "\n OR EXISTS (SELECT 1 FROM pg_cast"
7111 "\n WHERE pg_cast.oid > '%u'::oid"
7112 "\n AND p.oid = pg_cast.castfunc)",
7114
7117 "\n OR EXISTS (SELECT 1 FROM pg_transform"
7118 "\n WHERE pg_transform.oid > '%u'::oid"
7119 "\n AND (p.oid = pg_transform.trffromsql"
7120 "\n OR p.oid = pg_transform.trftosql))",
7122
7125 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
7126 "classid = 'pg_proc'::regclass AND "
7127 "objid = p.oid AND "
7128 "refclassid = 'pg_extension'::regclass AND "
7129 "deptype = 'e')");
7131 }
7132
7134
7136
7138
7150
7151 for (
i = 0;
i < ntups;
i++)
7152 {
7158 finfo[
i].
dobj.namespace =
7168 if (finfo[
i].nargs == 0)
7170 else
7171 {
7174 finfo[
i].argtypes, finfo[
i].nargs);
7175 }
7177
7178
7180
7181
7184 }
7185
7187
7189}
7190
7191
7192
7193
7194
7195
7196
7197
7200 char *reltuples,
int32 relallvisible,
7201 int32 relallfrozen,
char relkind,
7202 char **indAttNames, int nindAttNames)
7203{
7206
7213 {
7216
7227 dobj->namespace = rel->namespace;
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7248 {
7254 break;
7258 break;
7259 default:
7260 pg_fatal(
"cannot dump statistics for relation kind \"%c\"",
7262 }
7263
7264 return info;
7265 }
7267}
7268
7269
7270
7271
7272
7273
7274
7275
7278{
7281 int ntups;
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7344 "SELECT c.tableoid, c.oid, c.relname, "
7345 "c.relnamespace, c.relkind, c.reltype, "
7346 "c.relowner, "
7347 "c.relchecks, "
7348 "c.relhasindex, c.relhasrules, c.relpages, "
7349 "c.reltuples, c.relallvisible, ");
7350
7353 else
7355
7357 "c.relhastriggers, c.relpersistence, "
7358 "c.reloftype, "
7359 "c.relacl, "
7361 " THEN 's'::\"char\" ELSE 'r'::\"char\" END, c.relowner) AS acldefault, "
7363 "(SELECT ftserver FROM pg_catalog.pg_foreign_table WHERE ftrelid = c.oid) "
7364 "ELSE 0 END AS foreignserver, "
7365 "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, "
7366 "tc.oid AS toid, "
7367 "tc.relpages AS toastpages, "
7368 "tc.reloptions AS toast_reloptions, "
7369 "d.refobjid AS owning_tab, "
7370 "d.refobjsubid AS owning_col, "
7371 "tsp.spcname AS reltablespace, ");
7372
7375 "false AS relhasoids, ");
7376 else
7378 "c.relhasoids, ");
7379
7382 "c.relispopulated, ");
7383 else
7385 "'t' as relispopulated, ");
7386
7389 "c.relreplident, ");
7390 else
7392 "'d' AS relreplident, ");
7393
7396 "c.relrowsecurity, c.relforcerowsecurity, ");
7397 else
7399 "false AS relrowsecurity, "
7400 "false AS relforcerowsecurity, ");
7401
7404 "c.relminmxid, tc.relminmxid AS tminmxid, ");
7405 else
7407 "0 AS relminmxid, 0 AS tminmxid, ");
7408
7411 "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
7412 "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
7413 "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
7414 else
7416 "c.reloptions, NULL AS checkoption, ");
7417
7420 "am.amname, ");
7421 else
7423 "NULL AS amname, ");
7424
7427 "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
7428 else
7430 "false AS is_identity_sequence, ");
7431
7434 "c.relispartition AS ispartition ");
7435 else
7437 "false AS ispartition ");
7438
7439
7440
7441
7442
7443
7444
7446 "\nFROM pg_class c\n"
7447 "LEFT JOIN pg_depend d ON "
7449 "d.classid = 'pg_class'::regclass AND d.objid = c.oid AND "
7450 "d.objsubid = 0 AND "
7451 "d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
7452 "LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
7453
7454
7455
7456
7459 "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
7460
7461
7462
7463
7464
7465
7467 "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid"
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7482 "WHERE c.relkind IN ("
7491 "ORDER BY c.oid");
7492
7494
7496
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7509
7550
7552 {
7553
7554
7555
7556
7557
7558
7559
7564 }
7565
7567
7568 for (
i = 0;
i < ntups;
i++)
7569 {
7572
7578 tblinfo[
i].
dobj.namespace =
7593 else
7596 {
7599 }
7600 else
7601 {
7604 }
7621 else
7628 else
7632
7633
7634
7635
7636
7637
7640 else
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7658
7661
7662
7664
7665
7669
7670
7671 if (tblinfo[
i].interesting)
7672 {
7674
7676 tblinfo[
i].relpages,
7678 relallvisible, relallfrozen,
7679 tblinfo[
i].relkind,
NULL, 0);
7681 tblinfo[
i].
stats = stats;
7682 }
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7702 {
7703
7704
7705
7706
7707
7708 if (query->
len == 0)
7711 else
7712 {
7715
7716
7717 if (query->
len >= 100000)
7718 {
7719
7723 }
7724 }
7725 }
7726 }
7727
7728 if (query->
len != 0)
7729 {
7730
7733 }
7734
7736 {
7738 }
7739
7741
7743
7744 return tblinfo;
7745}
7746
7747
7748
7749
7750
7751
7752
7753
7754void
7756{
7758
7759
7760
7761
7762
7764 {
7767
7769 continue;
7770
7772 if (owning_tab ==
NULL)
7773 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798 if (
seqinfo->is_identity_sequence)
7800 else
7802
7803
7805 {
7808 }
7809 }
7810}
7811
7812
7813
7814
7815
7816
7817
7818
7821{
7823 int ntups;
7827
7830
7831
7833
7835
7837
7839
7841
7844
7845 for (
i = 0;
i < ntups;
i++)
7846 {
7849 }
7850
7852
7854
7856}
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875void
7877{
7880 int ntups;
7881
7882
7884 return;
7885
7887 return;
7888
7890
7891
7892
7893
7894
7895
7896
7897
7898
7900 "SELECT partrelid FROM pg_partitioned_table WHERE\n"
7901 "(SELECT c.oid FROM pg_opclass c JOIN pg_am a "
7902 "ON c.opcmethod = a.oid\n"
7903 "WHERE opcname = 'enum_ops' "
7904 "AND opcnamespace = 'pg_catalog'::regnamespace "
7905 "AND amname = 'hash') = ANY(partclass)");
7906
7908
7910
7911 for (
int i = 0;
i < ntups;
i++)
7912 {
7915
7918 pg_fatal(
"failed sanity check, table OID %u appearing in pg_partitioned_table not found",
7920 tbinfo->unsafe_partitions =
true;
7921 }
7922
7924
7926}
7927
7928
7929
7930
7931
7932
7933
7934
7935void
7937{
7941 int ntups;
7973
7974
7975
7976
7977
7978
7979
7980
7981
7984 {
7986
7988 continue;
7989
7990
7991
7992
7993 if (!
tbinfo->interesting)
7994 continue;
7995
7996
8000 }
8002
8004 "SELECT t.tableoid, t.oid, i.indrelid, "
8005 "t.relname AS indexname, "
8006 "t.relpages, t.reltuples, t.relallvisible, ");
8007
8010 else
8012
8014 "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
8015 "i.indkey, i.indisclustered, "
8016 "c.contype, c.conname, "
8017 "c.condeferrable, c.condeferred, "
8018 "c.tableoid AS contableoid, "
8019 "c.oid AS conoid, "
8020 "pg_catalog.pg_get_constraintdef(c.oid, false) AS condef, "
8021 "CASE WHEN i.indexprs IS NOT NULL THEN "
8022 "(SELECT pg_catalog.array_agg(attname ORDER BY attnum)"
8023 " FROM pg_catalog.pg_attribute "
8024 " WHERE attrelid = i.indexrelid) "
8025 "ELSE NULL END AS indattnames, "
8026 "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
8027 "t.reloptions AS indreloptions, ");
8028
8029
8032 "i.indisreplident, ");
8033 else
8035 "false AS indisreplident, ");
8036
8039 "inh.inhparent AS parentidx, "
8040 "i.indnkeyatts AS indnkeyatts, "
8041 "i.indnatts AS indnatts, "
8042 "(SELECT pg_catalog.array_agg(attnum ORDER BY attnum) "
8043 " FROM pg_catalog.pg_attribute "
8044 " WHERE attrelid = i.indexrelid AND "
8045 " attstattarget >= 0) AS indstatcols, "
8046 "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attnum) "
8047 " FROM pg_catalog.pg_attribute "
8048 " WHERE attrelid = i.indexrelid AND "
8049 " attstattarget >= 0) AS indstatvals, ");
8050 else
8052 "0 AS parentidx, "
8053 "i.indnatts AS indnkeyatts, "
8054 "i.indnatts AS indnatts, "
8055 "'' AS indstatcols, "
8056 "'' AS indstatvals, ");
8057
8060 "i.indnullsnotdistinct, ");
8061 else
8063 "false AS indnullsnotdistinct, ");
8064
8067 "c.conperiod ");
8068 else
8070 "NULL AS conperiod ");
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8082 {
8084 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8085 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
8086 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
8087 "JOIN pg_catalog.pg_class t2 ON (t2.oid = i.indrelid) "
8088 "LEFT JOIN pg_catalog.pg_constraint c "
8089 "ON (i.indrelid = c.conrelid AND "
8090 "i.indexrelid = c.conindid AND "
8091 "c.contype IN ('p','u','x')) "
8092 "LEFT JOIN pg_catalog.pg_inherits inh "
8093 "ON (inh.inhrelid = indexrelid) "
8094 "WHERE (i.indisvalid OR t2.relkind = 'p') "
8095 "AND i.indisready "
8096 "ORDER BY i.indrelid, indexname",
8098 }
8099 else
8100 {
8101
8102
8103
8104
8106 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8107 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
8108 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
8109 "LEFT JOIN pg_catalog.pg_constraint c "
8110 "ON (i.indrelid = c.conrelid AND "
8111 "i.indexrelid = c.conindid AND "
8112 "c.contype IN ('p','u','x')) "
8113 "WHERE i.indisvalid AND i.indisready "
8114 "ORDER BY i.indrelid, indexname",
8116 }
8117
8119
8121
8151
8153
8154
8155
8156
8157
8159 for (
int j = 0;
j < ntups;)
8160 {
8163 char **indAttNames =
NULL;
8164 int nindAttNames = 0;
8166
8167
8170 break;
8171
8172
8173
8174
8175
8177 {
8180 break;
8181 }
8184
8187 pg_fatal(
"unexpected index data for table \"%s\"",
8189
8190
8193
8195 {
8196 char contype;
8202
8226 {
8228 };
8229
8232 else
8234
8236 {
8238 &indAttNames, &nindAttNames))
8239 pg_fatal(
"could not parse %s array",
"indattnames");
8240 }
8241
8245 indAttNames, nindAttNames);
8246
8248 if (contype == 'p' || contype == 'u' || contype == 'x')
8249 {
8250
8251
8252
8253
8255
8267 if (contype == 'x')
8269 else
8278
8282 }
8283 else
8284 {
8285
8287 }
8288 }
8289 }
8290
8292
8295}
8296
8297
8298
8299
8300
8301
8302
8303
8304void
8306{
8310 int ntups;
8319
8320
8322 return;
8323
8325
8328 "stxnamespace, stxowner, stxrelid, NULL AS stxstattarget "
8329 "FROM pg_catalog.pg_statistic_ext");
8330 else
8332 "stxnamespace, stxowner, stxrelid, stxstattarget "
8333 "FROM pg_catalog.pg_statistic_ext");
8334
8336
8338
8346
8348
8349 for (
i = 0;
i < ntups;
i++)
8350 {
8363 else
8365
8366
8368
8371 }
8372
8375}
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386void
8388{
8392 int ntups;
8403
8404
8405
8406
8407
8408
8409
8410
8411
8414 {
8416
8418 continue;
8419
8420
8424 }
8426
8428 "SELECT c.tableoid, c.oid, "
8429 "conrelid, conname, confrelid, ");
8432 else
8435 "pg_catalog.pg_get_constraintdef(c.oid) AS condef\n"
8436 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8437 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
8438 "WHERE contype = 'f' ",
8442 "AND conparentid = 0 ");
8444 "ORDER BY conrelid, conname");
8445
8447
8449
8457
8459
8461 for (
int j = 0;
j < ntups;
j++)
8462 {
8465
8466
8467
8468
8469
8471 {
8473 {
8475 if (
tbinfo->dobj.catId.oid == conrelid)
8476 break;
8477 }
8479 pg_fatal(
"unrecognized table OID %u", conrelid);
8480 }
8481
8498
8499
8500
8501
8502
8503
8504
8507 {
8509
8511 {
8512 for (
int k = 0; k <
reftable->numIndexes; k++)
8513 {
8515
8516
8517 if (
reftable->indexes[k].dobj.catId.oid != indexOid)
8518 continue;
8519
8522 break;
8523 }
8524 }
8525 }
8526 }
8527
8529
8532}
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545static void
8547{
8549
8551
8552 for (cell =
refidx->partattaches.head; cell; cell = cell->
next)
8553 {
8555
8557
8558 if (
attach->partitionIdx->partattaches.head !=
NULL)
8560 }
8561}
8562
8563
8564
8565
8566
8567
8568static void
8570{
8580 int ntups;
8581
8583 {
8584
8585
8586
8587
8588
8590 "PREPARE getDomainConstraints(pg_catalog.oid) AS\n"
8591 "SELECT tableoid, oid, conname, "
8592 "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
8593 "convalidated, contype "
8594 "FROM pg_catalog.pg_constraint "
8595 "WHERE contypid = $1 AND contype IN (%s) "
8596 "ORDER BY conname",
8598
8600
8602 }
8603
8605 "EXECUTE getDomainConstraints('%u')",
8607
8609
8611
8618
8621
8622
8623 for (
int i = 0,
j = 0;
i < ntups;
i++)
8624 {
8628
8630 {
8633 }
8634 else
8635 {
8638
8640 constraint =
tyinfo->notnull;
8641 }
8642
8648 constraint->
dobj.namespace =
tyinfo->dobj.namespace;
8651 constraint->
contype = contype;
8658
8660
8661
8662
8663
8664
8665
8666
8669 }
8670
8672
8674}
8675
8676
8677
8678
8679
8680void
8682{
8684 int ntups;
8695
8697 "tableoid, oid, rulename, "
8698 "ev_class AS ruletable, ev_type, is_instead, "
8699 "ev_enabled "
8700 "FROM pg_rewrite "
8701 "ORDER BY oid");
8702
8704
8706
8708
8716
8717 for (
i = 0;
i < ntups;
i++)
8718 {
8720
8729 pg_fatal(
"failed sanity check, parent table with OID %u of pg_rewrite entry with OID %u not found",
8737 {
8738
8739
8740
8741
8742
8743
8744
8748 {
8751
8753 }
8754 else
8755 {
8759 }
8760 }
8761 else
8763 }
8764
8766
8768}
8769
8770
8771
8772
8773
8774
8775
8776
8777void
8779{
8783 int ntups;
8793
8794
8795
8796
8797
8798
8799
8800
8801
8804 {
8806
8807 if (!
tbinfo->hastriggers ||
8809 continue;
8810
8811
8815 }
8817
8819 {
8820
8821
8822
8823
8824
8825
8826
8827
8829 "SELECT t.tgrelid, t.tgname, "
8830 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8831 "t.tgenabled, t.tableoid, t.oid, "
8832 "t.tgparentid <> 0 AS tgispartition\n"
8833 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8834 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8835 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8836 "WHERE ((NOT t.tgisinternal AND t.tgparentid = 0) "
8837 "OR t.tgenabled != u.tgenabled) "
8838 "ORDER BY t.tgrelid, t.tgname",
8840 }
8842 {
8843
8844
8845
8846
8847
8848
8849
8850
8852 "SELECT t.tgrelid, t.tgname, "
8853 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8854 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition\n"
8855 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8856 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8857 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8858 "WHERE (NOT t.tgisinternal OR t.tgenabled != u.tgenabled) "
8859 "ORDER BY t.tgrelid, t.tgname",
8861 }
8863 {
8864
8865
8866
8867
8868
8869
8870
8872 "SELECT t.tgrelid, t.tgname, "
8873 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8874 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition "
8875 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8876 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8877 "LEFT JOIN pg_catalog.pg_depend AS d ON "
8878 " d.classid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8879 " d.refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8880 " d.objid = t.oid "
8881 "LEFT JOIN pg_catalog.pg_trigger AS pt ON pt.oid = refobjid "
8882 "WHERE (NOT t.tgisinternal OR t.tgenabled != pt.tgenabled) "
8883 "ORDER BY t.tgrelid, t.tgname",
8885 }
8886 else
8887 {
8888
8890 "SELECT t.tgrelid, t.tgname, "
8891 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8892 "t.tgenabled, false as tgispartition, "
8893 "t.tableoid, t.oid "
8894 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8895 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8896 "WHERE NOT tgisinternal "
8897 "ORDER BY t.tgrelid, t.tgname",
8899 }
8900
8902
8904
8912
8914
8915
8916
8917
8918
8920 for (
int j = 0;
j < ntups;)
8921 {
8925
8926
8929 break;
8930
8931
8932
8933
8934
8936 {
8939 break;
8940 }
8943
8944
8947
8949 {
8960 }
8961 }
8962
8964
8967}
8968
8969
8970
8971
8972
8973void
8975{
8988 int ntups;
8989
8990
8992 return;
8993
8995
8997 "SELECT e.tableoid, e.oid, evtname, evtenabled, "
8998 "evtevent, evtowner, "
8999 "array_to_string(array("
9000 "select quote_literal(x) "
9001 " from unnest(evttags) as t(x)), ', ') as evttags, "
9002 "e.evtfoid::regproc as evtfname "
9003 "FROM pg_event_trigger e "
9004 "ORDER BY e.oid");
9005
9007
9009
9011
9020
9021 for (
i = 0;
i < ntups;
i++)
9022 {
9034
9035
9037 }
9038
9040
9042}
9043
9044
9045
9046
9047
9048
9049
9050
9051void
9053{
9055 int ntups;
9069
9071 "lanname, lanpltrusted, lanplcallfoid, "
9072 "laninline, lanvalidator, "
9073 "lanacl, "
9074 "acldefault('l', lanowner) AS acldefault, "
9075 "lanowner "
9076 "FROM pg_language "
9077 "WHERE lanispl "
9078 "ORDER BY oid");
9079
9081
9083
9085
9096
9097 for (
i = 0;
i < ntups;
i++)
9098 {
9103
9114
9115
9117
9118
9121 }
9122
9124
9126}
9127
9128
9129
9130
9131
9132
9133
9134
9135void
9137{
9139 int ntups;
9150
9152 {
9154 "castsource, casttarget, castfunc, castcontext, "
9155 "castmethod "
9156 "FROM pg_cast c "
9157 "WHERE NOT EXISTS ( "
9158 "SELECT 1 FROM pg_range r "
9159 "WHERE c.castsource = r.rngtypid "
9160 "AND c.casttarget = r.rngmultitypid "
9161 ") "
9162 "ORDER BY 3,4");
9163 }
9164 else
9165 {
9167 "castsource, casttarget, castfunc, castcontext, "
9168 "castmethod "
9169 "FROM pg_cast ORDER BY 3,4");
9170 }
9171
9173
9175
9177
9185
9186 for (
i = 0;
i < ntups;
i++)
9187 {
9191
9201
9202
9203
9204
9205
9206
9214
9215
9217 }
9218
9220
9222}
9223
9224static char *
9226{
9230
9232 appendPQExpBuffer(query,
"SELECT lanname FROM pg_language WHERE oid = %u", langid);
9237
9239}
9240
9241
9242
9243
9244
9245void
9247{
9249 int ntups;
9259
9260
9262 return;
9263
9265
9267 "trftype, trflang, trffromsql::oid, trftosql::oid "
9268 "FROM pg_transform "
9269 "ORDER BY 3,4");
9270
9272
9274
9276
9283
9284 for (
i = 0;
i < ntups;
i++)
9285 {
9289
9298
9299
9300
9301
9302
9303
9312
9313
9315 }
9316
9318
9320}
9321
9322
9323
9324
9325
9326
9327
9328
9329void
9331{
9338 int ntups;
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9378 {
9380
9381
9383 continue;
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393 if (!
tbinfo->interesting &&
9397 continue;
9398
9399
9403
9405 {
9406
9410 }
9411 }
9414
9415
9416
9417
9418
9419
9420
9421
9423 "SELECT\n"
9424 "a.attrelid,\n"
9425 "a.attnum,\n"
9426 "a.attname,\n"
9427 "a.attstattarget,\n"
9428 "a.attstorage,\n"
9429 "t.typstorage,\n"
9430 "a.atthasdef,\n"
9431 "a.attisdropped,\n"
9432 "a.attlen,\n"
9433 "a.attalign,\n"
9434 "a.attislocal,\n"
9435 "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n"
9436 "array_to_string(a.attoptions, ', ') AS attoptions,\n"
9437 "CASE WHEN a.attcollation <> t.typcollation "
9438 "THEN a.attcollation ELSE 0 END AS attcollation,\n"
9439 "pg_catalog.array_to_string(ARRAY("
9440 "SELECT pg_catalog.quote_ident(option_name) || "
9441 "' ' || pg_catalog.quote_literal(option_value) "
9442 "FROM pg_catalog.pg_options_to_table(attfdwoptions) "
9443 "ORDER BY option_name"
9444 "), E',\n ') AS attfdwoptions,\n");
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9466 "co.conname AS notnull_name,\n"
9467 "CASE WHEN co.convalidated THEN pt.description"
9468 " ELSE NULL END AS notnull_comment,\n"
9469 "CASE WHEN NOT co.convalidated THEN co.oid "
9470 "ELSE NULL END AS notnull_invalidoid,\n"
9471 "co.connoinherit AS notnull_noinherit,\n"
9472 "co.conislocal AS notnull_islocal,\n");
9473 else
9475 "CASE WHEN a.attnotnull THEN '' ELSE NULL END AS notnull_name,\n"
9476 "NULL AS notnull_comment,\n"
9477 "NULL AS notnull_invalidoid,\n"
9478 "false AS notnull_noinherit,\n"
9479 "CASE WHEN a.attislocal THEN true\n"
9480 " WHEN a.attnotnull AND NOT a.attislocal THEN true\n"
9481 " ELSE false\n"
9482 "END AS notnull_islocal,\n");
9483
9486 "a.attcompression AS attcompression,\n");
9487 else
9489 "'' AS attcompression,\n");
9490
9493 "a.attidentity,\n");
9494 else
9496 "'' AS attidentity,\n");
9497
9500 "CASE WHEN a.atthasmissing AND NOT a.attisdropped "
9501 "THEN a.attmissingval ELSE null END AS attmissingval,\n");
9502 else
9504 "NULL AS attmissingval,\n");
9505
9508 "a.attgenerated\n");
9509 else
9511 "'' AS attgenerated\n");
9512
9513
9515 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9516 "JOIN pg_catalog.pg_attribute a ON (src.tbloid = a.attrelid) "
9517 "LEFT JOIN pg_catalog.pg_type t "
9518 "ON (a.atttypid = t.oid)\n",
9520
9521
9522
9523
9524
9527 " LEFT JOIN pg_catalog.pg_constraint co ON "
9528 "(a.attrelid = co.conrelid\n"
9529 " AND co.contype = 'n' AND "
9530 "co.conkey = array[a.attnum])\n"
9531 " LEFT JOIN pg_catalog.pg_description pt ON "
9532 "(pt.classoid = co.tableoid AND pt.objoid = co.oid)\n");
9533
9535 "WHERE a.attnum > 0::pg_catalog.int2\n");
9536
9537
9538
9539
9540
9543 "OR (a.attnum = -2::pg_catalog.int2 AND src.tbloid = "
9545
9547 "ORDER BY a.attrelid, a.attnum");
9548
9550
9552
9577
9578
9581
9582
9583
9584
9585
9587 for (int r = 0; r < ntups;)
9588 {
9591 int numatts;
9593
9594
9595 for (numatts = 1; numatts < ntups - r; numatts++)
9597 break;
9598
9599
9600
9601
9602
9604 {
9606 if (
tbinfo->dobj.catId.oid == attrelid)
9607 break;
9608 }
9610 pg_fatal(
"unrecognized table OID %u", attrelid);
9611
9617 pg_fatal(
"unexpected column data for table \"%s\"",
9619
9620
9621 tbinfo->numatts = numatts;
9645
9646 for (
int j = 0;
j < numatts;
j++, r++)
9647 {
9651 pg_fatal(
"invalid column numbering in table \"%s\"",
9656 tbinfo->attstattarget[
j] = -1;
9657 else
9668
9669
9678
9689 }
9690
9692 {
9693
9697 }
9698 }
9699
9700
9703
9705
9706
9707
9708
9709
9711 {
9715
9717
9719
9721 "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc\n"
9722 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9723 "JOIN pg_catalog.pg_attrdef a ON (src.tbloid = a.adrelid)\n"
9724 "ORDER BY a.adrelid, a.adnum",
9726
9728
9731
9734 {
9740
9741
9742
9743
9744
9746 {
9748 {
9751 break;
9752 }
9755 }
9756
9758 pg_fatal(
"invalid adnum value %d for table \"%s\"",
9759 adnum,
tbinfo->dobj.name);
9760
9761
9762
9763
9764
9765 if (
tbinfo->attisdropped[adnum - 1])
9766 continue;
9767
9773 attrdefs[
j].
adnum = adnum;
9775
9777 attrdefs[
j].
dobj.namespace =
tbinfo->dobj.namespace;
9778
9780
9781
9782
9783
9784
9785
9786
9787
9788 if (
tbinfo->attgenerated[adnum - 1])
9789 {
9790
9791
9792
9793
9794
9795
9796
9797
9799 }
9801 {
9802
9803
9804
9805
9807 }
9809 {
9810
9812 }
9813 else
9814 {
9816 }
9817
9818 if (!attrdefs[
j].separate)
9819 {
9820
9821
9822
9823
9824
9825
9827 attrdefs[
j].dobj.dumpId);
9828 }
9829
9830 tbinfo->attrdefs[adnum - 1] = &attrdefs[
j];
9831 }
9832
9834 }
9835
9836
9837
9838
9839
9841 {
9850
9851 pg_log_info(
"finding invalid not-null constraints");
9852
9855 "SELECT c.tableoid, c.oid, conrelid, conname, "
9856 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9857 "conislocal, convalidated "
9858 "FROM unnest('%s'::pg_catalog.oid[]) AS src(conoid)\n"
9859 "JOIN pg_catalog.pg_constraint c ON (src.conoid = c.oid)\n"
9860 "ORDER BY c.conrelid, c.conname",
9862
9864
9867
9874
9875
9878 {
9882
9883
9886 break;
9887
9888
9889
9890
9891
9893 {
9895 if (
tbinfo->dobj.catId.oid == conrelid)
9896 break;
9897 }
9899 pg_fatal(
"unrecognized table OID %u", conrelid);
9900
9902 {
9918
9919
9920
9921
9922
9923
9924
9926
9928 }
9929 }
9931 }
9932
9933
9934
9935
9936
9938 {
9948
9950
9953 "SELECT c.tableoid, c.oid, conrelid, conname, "
9954 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9955 "conislocal, convalidated "
9956 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9957 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
9958 "WHERE contype = 'c' "
9959 "ORDER BY c.conrelid, c.conname",
9961
9963
9966
9974
9975
9978 {
9982
9983
9986 break;
9987
9988
9989
9990
9991
9993 {
9995 if (
tbinfo->dobj.catId.oid == conrelid)
9996 break;
9997 }
9999 pg_fatal(
"unrecognized table OID %u", conrelid);
10000
10002 {
10004 "expected %d check constraints on table \"%s\" but found %d",
10009 }
10010
10012
10014 {
10016
10032
10033
10034
10035
10036
10037
10039
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10054
10055
10056
10057
10058
10059 }
10060 }
10061
10063 }
10064
10068}
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117static void
10126{
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10139 {
10141
10143 {
10147 }
10148 else
10150
10151
10152
10153
10154
10155 tbinfo->notnull_invalid[
j] =
true;
10156
10157
10159 return;
10160 }
10161
10162
10163
10164
10165
10168 tbinfo->notnull_invalid[
j] =
false;
10169
10170
10171
10172
10173
10174
10175
10177 {
10178
10179
10180
10181
10184 else
10185 tbinfo->notnull_constrs[
j] =
"";
10186 }
10187 else
10188 {
10191 else
10192 {
10193
10194
10195
10196
10197
10200 !
tbinfo->notnull_islocal[
j]) ||
10202 {
10205 }
10206 else
10207 {
10209
10210
10215 tbinfo->notnull_constrs[
j] =
"";
10216 else
10217 {
10220 }
10222 }
10223 }
10224 }
10225}
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244bool
10246{
10248 return true;
10249 if (
tbinfo->attisdropped[colno])
10250 return false;
10251 return (
tbinfo->attislocal[colno] ||
tbinfo->ispartition);
10252}
10253
10254
10255
10256
10257
10258
10259void
10261{
10263 int ntups;
10276
10278
10279
10280
10281
10282
10283
10285 "prsstart::oid, prstoken::oid, "
10286 "prsend::oid, prsheadline::oid, prslextype::oid "
10287 "FROM pg_ts_parser");
10288
10290
10292
10294
10304
10305 for (
i = 0;
i < ntups;
i++)
10306 {
10319
10320
10322 }
10323
10325
10327}
10328
10329
10330
10331
10332
10333void
10335{
10337 int ntups;
10348
10350
10352 "dictnamespace, dictowner, "
10353 "dicttemplate, dictinitoption "
10354 "FROM pg_ts_dict");
10355
10357
10359
10361
10369
10370 for (
i = 0;
i < ntups;
i++)
10371 {
10383 else
10385
10386
10388 }
10389
10391
10393}
10394
10395
10396
10397
10398
10399void
10401{
10403 int ntups;
10413
10415
10417 "tmplnamespace, tmplinit::oid, tmpllexize::oid "
10418 "FROM pg_ts_template");
10419
10421
10423
10425
10432
10433 for (
i = 0;
i < ntups;
i++)
10434 {
10444
10445
10447 }
10448
10450
10452}
10453
10454
10455
10456
10457
10458void
10460{
10462 int ntups;
10472
10474
10476 "cfgnamespace, cfgowner, cfgparser "
10477 "FROM pg_ts_config");
10478
10480
10482
10484
10491
10492 for (
i = 0;
i < ntups;
i++)
10493 {
10503
10504
10506 }
10507
10509
10511}
10512
10513
10514
10515
10516
10517void
10519{
10521 int ntups;
10535
10537
10539 "fdwowner, "
10540 "fdwhandler::pg_catalog.regproc, "
10541 "fdwvalidator::pg_catalog.regproc, ");
10542
10545 else
10547
10549 "fdwacl, "
10550 "acldefault('F', fdwowner) AS acldefault, "
10551 "array_to_string(ARRAY("
10552 "SELECT quote_ident(option_name) || ' ' || "
10553 "quote_literal(option_value) "
10554 "FROM pg_options_to_table(fdwoptions) "
10555 "ORDER BY option_name"
10556 "), E',\n ') AS fdwoptions "
10557 "FROM pg_foreign_data_wrapper");
10558
10560
10562
10564
10575
10576 for (
i = 0;
i < ntups;
i++)
10577 {
10593
10594
10596
10597
10600 }
10601
10603
10605}
10606
10607
10608
10609
10610
10611void
10613{
10615 int ntups;
10629
10631
10633 "srvowner, "
10634 "srvfdw, srvtype, srvversion, srvacl, "
10635 "acldefault('S', srvowner) AS acldefault, "
10636 "array_to_string(ARRAY("
10637 "SELECT quote_ident(option_name) || ' ' || "
10638 "quote_literal(option_value) "
10639 "FROM pg_options_to_table(srvoptions) "
10640 "ORDER BY option_name"
10641 "), E',\n ') AS srvoptions "
10642 "FROM pg_foreign_server");
10643
10645
10647
10649
10660
10661 for (
i = 0;
i < ntups;
i++)
10662 {
10678
10679
10681
10682
10684
10685
10688 }
10689
10691
10693}
10694
10695
10696
10697
10698
10699void
10701{
10714 ntups;
10715
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10731 "SELECT oid, tableoid, "
10732 "defaclrole, "
10733 "defaclnamespace, "
10734 "defaclobjtype, "
10735 "defaclacl, "
10736 "CASE WHEN defaclnamespace = 0 THEN "
10737 "acldefault(CASE WHEN defaclobjtype = 'S' "
10738 "THEN 's'::\"char\" ELSE defaclobjtype END, "
10739 "defaclrole) ELSE '{}' END AS acldefault "
10740 "FROM pg_default_acl");
10741
10743
10745
10747
10755
10756 for (
i = 0;
i < ntups;
i++)
10757 {
10759
10764
10766
10769 else
10771
10778
10779
10781
10782
10784 }
10785
10787
10789}
10790
10791
10792
10793
10794
10795
10796static const char *
10798{
10800
10801
10802
10803
10805 {
10808
10809 while (low <= high)
10810 {
10812
10815 else if (roleoid >
middle->roleoid)
10817 else
10819 }
10820 }
10821
10822 pg_fatal(
"role with OID %u does not exist", roleoid);
10824}
10825
10826
10827
10828
10829
10830
10831
10832static void
10834{
10836 const char *query;
10838
10839 query = "SELECT oid, rolname FROM pg_catalog.pg_roles ORDER BY 1";
10840
10842
10844
10846
10848 {
10851 }
10852
10854}
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867static void
10869{
10872 int ntups,
10874
10875
10877 "SELECT DISTINCT attrelid FROM pg_attribute "
10878 "WHERE attacl IS NOT NULL");
10879
10881
10883 for (
i = 0;
i < ntups;
i++)
10884 {
10887
10889
10890 if (tblinfo)
10891 {
10894 }
10895 }
10897
10898
10900 {
10902 "SELECT objoid, classoid, objsubid, privtype, initprivs "
10903 "FROM pg_init_privs");
10904
10906
10908 for (
i = 0;
i < ntups;
i++)
10909 {
10917
10919 objId.
oid = objoid;
10921
10922 if (dobj)
10923 {
10924
10925 if (objsubid != 0)
10926 {
10928 {
10929
10931 ((
TableInfo *) dobj)->hascolumnACLs =
true;
10932 }
10933 else
10935 classoid, objoid, objsubid);
10936 continue;
10937 }
10938
10939
10940
10941
10942
10945 continue;
10946
10947
10956 {
10958
10961 }
10962 else
10964 classoid, objoid, objsubid);
10965 }
10966 }
10968 }
10969
10971}
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996static void
10998 const char *
name,
const char *
namespace,
10999 const char *owner,
CatalogId catalogId,
11000 int subid,
DumpId dumpId,
11002{
11006
11007
11009 return;
11010
11011
11013 {
11015 return;
11016 }
11017 else
11018 {
11019
11021 return;
11022 }
11023
11024
11027
11028
11030 {
11032 break;
11035 }
11036
11038 {
11040
11041
11042
11043
11044
11045
11046
11048 {
11051 }
11054 }
11055
11056
11058 {
11061
11063 if (namespace && *namespace)
11068
11070
11071
11072
11073
11074
11075
11078 .namespace = namespace,
11079 .owner = owner,
11080 .description = "COMMENT",
11082 .createStmt = query->
data,
11083 .deps = &dumpId,
11084 .nDeps = 1));
11085
11088 }
11089}
11090
11091
11092
11093
11094
11095
11096static inline void
11098 const char *
name,
const char *
namespace,
11099 const char *owner,
CatalogId catalogId,
11100 int subid,
DumpId dumpId)
11101{
11103 catalogId, subid, dumpId,
NULL);
11104}
11105
11106
11107
11108
11109
11110
11111
11112static void
11114 const char *argtype,
const char *
argval)
11115{
11117
11120
11123}
11124
11125
11126
11127
11128
11129
11132{
11137 int count = 0;
11142
11143
11144
11145
11146
11147
11148
11151
11152
11153 if (!te)
11155
11156
11157
11158
11159
11160
11161
11162
11163
11165 {
11168 }
11169
11173
11174
11175
11176
11177
11178
11179
11181 {
11184 continue;
11185
11187 {
11189 char relid[32];
11190
11193 }
11194 else
11195 {
11198 }
11199
11200 count++;
11201 }
11202
11206
11207
11208 if (count > 0)
11209 {
11211
11213
11215 {
11218 }
11219 else
11220 {
11225 }
11226
11229 }
11230
11234 return res;
11235}
11236
11237
11238
11239
11240
11241
11242
11243
11244static char *
11246{
11249 static int rownum;
11271
11272
11273
11274
11275
11278
11283
11285 pg_fatal(
"statistics dumped out of order (current: %d %s %s, expected: %d %s %s)",
11288
11291 {
11294 "PREPARE getAttributeStats(pg_catalog.oid[]) AS\n");
11295 else
11297 "PREPARE getAttributeStats(pg_catalog.name[], pg_catalog.name[]) AS\n");
11298
11300 "SELECT s.schemaname, s.tablename, s.attname, s.inherited, "
11301 "s.null_frac, s.avg_width, s.n_distinct, "
11302 "s.most_common_vals, s.most_common_freqs, "
11303 "s.histogram_bounds, s.correlation, "
11304 "s.most_common_elems, s.most_common_elem_freqs, "
11305 "s.elem_count_histogram, ");
11306
11309 "s.range_length_histogram, "
11310 "s.range_empty_frac, "
11311 "s.range_bounds_histogram ");
11312 else
11314 "NULL AS range_length_histogram,"
11315 "NULL AS range_empty_frac,"
11316 "NULL AS range_bounds_histogram ");
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11335 "FROM pg_catalog.pg_stats s "
11336 "JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
11337 "ON s.tableid = u.tableid "
11338 "ORDER BY u.ord, s.attname, s.inherited");
11341 "FROM pg_catalog.pg_stats s "
11342 "JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
11343 "ON s.schemaname = u.schemaname "
11344 "AND s.tablename = u.tablename "
11345 "WHERE s.tablename = ANY($2) "
11346 "ORDER BY u.ord, s.attname, s.inherited");
11347 else
11349 "FROM pg_catalog.pg_stats s "
11350 "WHERE s.schemaname = $1[1] "
11351 "AND s.tablename = $2[1] "
11352 "ORDER BY s.attname, s.inherited");
11353
11355
11358 }
11359
11361
11362
11373
11374
11375
11376
11377
11378
11379
11380
11381
11384 else
11386
11389
11392
11394
11395
11397 {
11400 rownum = 0;
11401 }
11402
11420
11421
11422 for (; rownum <
PQntuples(res); rownum++)
11423 {
11425
11426
11429 break;
11430
11438
11440 pg_fatal(
"unexpected null attname");
11442
11443
11444
11445
11446
11447
11448 if (
rsinfo->nindAttNames == 0)
11449 {
11452 }
11453 else
11454 {
11455 bool found = false;
11456
11457 for (
int i = 0;
i <
rsinfo->nindAttNames;
i++)
11458 {
11460 {
11463 found = true;
11464 break;
11465 }
11466 }
11467
11468 if (!found)
11470 }
11471
11506 {
11516 }
11518 }
11519
11522}
11523
11524
11525
11526
11527
11528
11529
11530
11531static void
11533{
11535
11536
11538 return;
11539
11542 .namespace = dobj->namespace->dobj.
name,
11543 .description = "STATISTICS DATA",
11544 .section =
rsinfo->section,
11548 .nDeps = dobj->
nDeps));
11549}
11550
11551
11552
11553
11554
11555
11556
11557static void
11560{
11566
11567
11569 return;
11570
11571
11573 return;
11574
11575
11579
11580
11582 return;
11583
11586
11588 {
11591
11592 if (objsubid == 0)
11593 {
11597
11603
11606 .namespace =
tbinfo->dobj.namespace->dobj.name,
11607 .owner =
tbinfo->rolname,
11608 .description = "COMMENT",
11610 .createStmt = query->
data,
11611 .deps = &(
tbinfo->dobj.dumpId),
11612 .nDeps = 1));
11613 }
11615 {
11620
11628
11631 .namespace =
tbinfo->dobj.namespace->dobj.name,
11632 .owner =
tbinfo->rolname,
11633 .description = "COMMENT",
11635 .createStmt = query->
data,
11636 .deps = &(
tbinfo->dobj.dumpId),
11637 .nDeps = 1));
11638 }
11639
11642 }
11643
11646}
11647
11648
11649
11650
11651
11652
11653
11654
11655static int
11657{
11661 int nmatch;
11662
11663
11664
11665
11668 while (low <= high)
11669 {
11670 middle = low + (high - low) / 2;
11671
11674 else if (classoid >
middle->classoid)
11678 else if (objoid >
middle->objoid)
11680 else
11681 break;
11682 }
11683
11684 if (low > high)
11685 {
11687 return 0;
11688 }
11689
11690
11691
11692
11693
11694
11695 nmatch = 1;
11697 {
11698 if (classoid !=
middle[-1].classoid ||
11699 objoid !=
middle[-1].objoid)
11700 break;
11702 nmatch++;
11703 }
11704
11706
11709 {
11710 if (classoid !=
middle->classoid ||
11711 objoid !=
middle->objoid)
11712 break;
11714 nmatch++;
11715 }
11716
11717 return nmatch;
11718}
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732static void
11734{
11741 int ntups;
11744
11746
11748 "FROM pg_catalog.pg_description "
11749 "ORDER BY classoid, objoid, objsubid");
11750
11752
11753
11754
11759
11761
11765
11766 for (
i = 0;
i < ntups;
i++)
11767 {
11769 int subid;
11770
11774
11775
11776 if (dobj ==
NULL ||
11781 continue;
11782
11783
11784
11785
11786
11787
11790 {
11792
11796 }
11797 else
11799
11805 }
11806
11809}
11810
11811
11812
11813
11814
11815
11816
11817static void
11819{
11820
11821
11822
11823
11824
11826
11827
11828 if (dobj->
dump == 0)
11829 return;
11830
11832 {
11835 break;
11838 break;
11841 break;
11844 break;
11847 break;
11850 break;
11853 break;
11856 break;
11859 break;
11862 break;
11865 break;
11868 break;
11871 break;
11874 break;
11877 break;
11880 break;
11883 break;
11887 break;
11890 break;
11893 break;
11896 break;
11899 break;
11902 break;
11905 break;
11908 break;
11911 break;
11914 break;
11917 break;
11920 break;
11922
11923 break;
11926 break;
11929 break;
11932 break;
11935 break;
11938 break;
11941 break;
11944 break;
11947 break;
11950 {
11953
11956 pg_fatal(
"missing metadata for large objects \"%s\"",
11958
11961 .owner =
loinfo->rolname,
11962 .description = "BLOBS",
11965 .nDeps = dobj->
nDeps,
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11979 }
11980 break;
11983 break;
11986 break;
11989 break;
11993 break;
11996 break;
11999 break;
12002 break;
12005
12006 break;
12007 }
12008}
12009
12010
12011
12012
12013
12014static void
12016{
12021
12022
12024 return;
12025
12028
12030
12032 {
12035 }
12036 else
12037 {
12038
12040 "-- *not* dropping schema, since initdb creates it\n");
12042 "-- *not* creating schema, since initdb creates it\n");
12043 }
12044
12048
12053 .description = "SCHEMA",
12055 .createStmt = q->
data,
12056 .dropStmt =
delq->data));
12057
12058
12060 {
12062
12069 }
12070
12075
12080
12082
12085}
12086
12087
12088
12089
12090
12091static void
12093{
12098
12099
12101 return;
12102
12105
12107
12109
12111 {
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12124 }
12125 else
12126 {
12127
12128
12129
12130
12131
12132
12133
12134
12136 int n;
12137
12138 appendPQExpBufferStr(q,
"-- For binary upgrade, create an empty extension and insert objects into it\n");
12139
12140
12141
12142
12143
12144
12146
12148 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
12156
12157
12158
12159
12160
12161
12164 else
12169 else
12173 n = 0;
12175 {
12177
12180 {
12181 if (n++ > 0)
12184 }
12185 }
12188 }
12189
12193 .description = "EXTENSION",
12195 .createStmt = q->
data,
12196 .dropStmt =
delq->data));
12197
12198
12203
12205
12208}
12209
12210
12211
12212
12213
12214static void
12216{
12218
12219
12221 return;
12222
12223
12236 else
12237 pg_log_warning(
"typtype of data type \"%s\" appears to be invalid",
12239}
12240
12241
12242
12243
12244
12245static void
12247{
12253 int num,
12261
12263 {
12264
12266 "PREPARE dumpEnumType(pg_catalog.oid) AS\n"
12267 "SELECT oid, enumlabel "
12268 "FROM pg_catalog.pg_enum "
12269 "WHERE enumtypid = $1 "
12270 "ORDER BY enumsortorder");
12271
12273
12275 }
12276
12278 "EXECUTE dumpEnumType('%u')",
12279 tyinfo->dobj.catId.oid);
12280
12282
12284
12287
12288
12289
12290
12291
12293
12297 false, false);
12298
12301
12303 {
12305
12306
12307 for (
i = 0;
i < num;
i++)
12308 {
12314 }
12315 }
12316
12318
12320 {
12323
12324
12325 for (
i = 0;
i < num;
i++)
12326 {
12329
12333 "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
12334 enum_oid);
12338 }
12339 }
12340
12344 tyinfo->dobj.namespace->dobj.name);
12345
12349 .namespace =
tyinfo->dobj.namespace->dobj.name,
12350 .owner =
tyinfo->rolname,
12351 .description = "TYPE",
12353 .createStmt = q->
data,
12354 .dropStmt =
delq->data));
12355
12356
12361
12366
12370 tyinfo->dobj.namespace->dobj.name,
12372
12379}
12380
12381
12382
12383
12384
12385static void
12387{
12396 char *procname;
12397
12399 {
12400
12402 "PREPARE dumpRangeType(pg_catalog.oid) AS\n");
12403
12405 "SELECT ");
12406
12409 "pg_catalog.format_type(rngmultitypid, NULL) AS rngmultitype, ");
12410 else
12412 "NULL AS rngmultitype, ");
12413
12415 "pg_catalog.format_type(rngsubtype, NULL) AS rngsubtype, "
12416 "opc.opcname AS opcname, "
12417 "(SELECT nspname FROM pg_catalog.pg_namespace nsp "
12418 " WHERE nsp.oid = opc.opcnamespace) AS opcnsp, "
12419 "opc.opcdefault, "
12420 "CASE WHEN rngcollation = st.typcollation THEN 0 "
12421 " ELSE rngcollation END AS collation, "
12422 "rngcanonical, rngsubdiff "
12423 "FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
12424 " pg_catalog.pg_opclass opc "
12425 "WHERE st.oid = rngsubtype AND opc.oid = rngsubopc AND "
12426 "rngtypid = $1");
12427
12429
12431 }
12432
12434 "EXECUTE dumpRangeType('%u')",
12435 tyinfo->dobj.catId.oid);
12436
12438
12441
12442
12443
12444
12445
12447
12451 false, true);
12452
12455
12458
12462
12463
12465 {
12468
12472 }
12473
12476 {
12478
12479 if (coll)
12482 }
12483
12485 if (
strcmp(procname,
"-") != 0)
12487
12489 if (
strcmp(procname,
"-") != 0)
12491
12493
12497 tyinfo->dobj.namespace->dobj.name);
12498
12502 .namespace =
tyinfo->dobj.namespace->dobj.name,
12503 .owner =
tyinfo->rolname,
12504 .description = "TYPE",
12506 .createStmt = q->
data,
12507 .dropStmt =
delq->data));
12508
12509
12514
12519
12523 tyinfo->dobj.namespace->dobj.name,
12525
12532}
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543static void
12545{
12551
12554
12556
12560 false, false);
12561
12564
12568 tyinfo->dobj.namespace->dobj.name);
12569
12573 .namespace =
tyinfo->dobj.namespace->dobj.name,
12574 .owner =
tyinfo->rolname,
12575 .description = "TYPE",
12577 .createStmt = q->
data,
12578 .dropStmt =
delq->data));
12579
12580
12585
12590
12594 tyinfo->dobj.namespace->dobj.name,
12596
12601}
12602
12603
12604
12605
12606
12607static void
12609{
12617 char *typlen;
12619 char *typoutput;
12620 char *typreceive;
12621 char *typsend;
12625 char *typsubscript;
12634 char *typdelim;
12635 char *typbyval;
12637 char *typstorage;
12641
12643 {
12644
12646 "PREPARE dumpBaseType(pg_catalog.oid) AS\n"
12647 "SELECT typlen, "
12648 "typinput, typoutput, typreceive, typsend, "
12649 "typreceive::pg_catalog.oid AS typreceiveoid, "
12650 "typsend::pg_catalog.oid AS typsendoid, "
12651 "typanalyze, "
12652 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
12653 "typdelim, typbyval, typalign, typstorage, "
12654 "typmodin, typmodout, "
12655 "typmodin::pg_catalog.oid AS typmodinoid, "
12656 "typmodout::pg_catalog.oid AS typmodoutoid, "
12657 "typcategory, typispreferred, "
12658 "(typcollation <> 0) AS typcollatable, "
12659 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault, ");
12660
12663 "typsubscript, "
12664 "typsubscript::pg_catalog.oid AS typsubscriptoid ");
12665 else
12667 "'-' AS typsubscript, 0 AS typsubscriptoid ");
12668
12670 "WHERE oid = $1");
12671
12673
12675 }
12676
12678 "EXECUTE dumpBaseType('%u')",
12679 tyinfo->dobj.catId.oid);
12680
12682
12708 {
12711 }
12712 else
12714
12717
12718
12719
12720
12721
12722
12724
12725
12726
12727
12728
12732 false, false);
12733
12735 "CREATE TYPE %s (\n"
12736 " INTERNALLENGTH = %s",
12738 (
strcmp(typlen,
"-1") == 0) ?
"variable" : typlen);
12739
12740
12753
12756
12758 {
12762 else
12764 }
12765
12768
12773
12775 {
12778 }
12779
12782
12783 if (typdelim &&
strcmp(typdelim,
",") != 0)
12784 {
12787 }
12788
12797
12806
12807 if (
strcmp(typbyval,
"t") == 0)
12809
12811
12815 tyinfo->dobj.namespace->dobj.name);
12816
12820 .namespace =
tyinfo->dobj.namespace->dobj.name,
12821 .owner =
tyinfo->rolname,
12822 .description = "TYPE",
12824 .createStmt = q->
data,
12825 .dropStmt =
delq->data));
12826
12827
12832
12837
12841 tyinfo->dobj.namespace->dobj.name,
12843
12850}
12851
12852
12853
12854
12855
12856static void
12858{
12872
12874 {
12875
12877 "PREPARE dumpDomain(pg_catalog.oid) AS\n");
12878
12880 "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
12881 "pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
12882 "t.typdefault, "
12883 "CASE WHEN t.typcollation <> u.typcollation "
12884 "THEN t.typcollation ELSE 0 END AS typcollation "
12885 "FROM pg_catalog.pg_type t "
12886 "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
12887 "WHERE t.oid = $1");
12888
12890
12892 }
12893
12895 "EXECUTE dumpDomain('%u')",
12896 tyinfo->dobj.catId.oid);
12897
12899
12905 {
12908 }
12909 else
12912
12916 true,
12917 false);
12918
12921
12923 "CREATE DOMAIN %s AS %s",
12926
12927
12929 {
12931
12933 if (coll)
12935 }
12936
12937
12938
12939
12940
12941
12942
12944 {
12947 else
12948 {
12950
12952 {
12954
12955
12957
12960 else
12964 }
12965 }
12966 }
12967
12969 {
12973 else
12975 }
12976
12978
12979
12980
12981
12982 for (
i = 0;
i <
tyinfo->nDomChecks;
i++)
12983 {
12985
12989 }
12990
12992
12994
12998 tyinfo->dobj.namespace->dobj.name);
12999
13003 .namespace =
tyinfo->dobj.namespace->dobj.name,
13004 .owner =
tyinfo->rolname,
13005 .description = "DOMAIN",
13007 .createStmt = q->
data,
13008 .dropStmt =
delq->data));
13009
13010
13015
13020
13024 tyinfo->dobj.namespace->dobj.name,
13026
13027
13028 for (
i = 0;
i <
tyinfo->nDomChecks;
i++)
13029 {
13032
13033
13035 continue;
13036
13040
13043 tyinfo->dobj.namespace->dobj.name,
13046
13048 }
13049
13050
13051
13052
13053
13055 {
13057
13060
13063 tyinfo->dobj.namespace->dobj.name,
13067 }
13068
13074}
13075
13076
13077
13078
13079
13080
13081static void
13083{
13092 int ntups;
13101
13103 {
13104
13105
13106
13107
13108
13109
13110
13111
13113 "PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
13114 "SELECT a.attname, a.attnum, "
13115 "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
13116 "a.attlen, a.attalign, a.attisdropped, "
13117 "CASE WHEN a.attcollation <> at.typcollation "
13118 "THEN a.attcollation ELSE 0 END AS attcollation "
13119 "FROM pg_catalog.pg_type ct "
13120 "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
13121 "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
13122 "WHERE ct.oid = $1 "
13123 "ORDER BY a.attnum");
13124
13126
13128 }
13129
13131 "EXECUTE dumpCompositeType('%u')",
13132 tyinfo->dobj.catId.oid);
13133
13135
13137
13144
13146 {
13149 false, false);
13151 }
13152
13155
13158
13160 for (
i = 0;
i < ntups;
i++)
13161 {
13166 bool attisdropped;
13168
13175
13177 continue;
13178
13179
13183
13184 if (!attisdropped)
13185 {
13187
13188
13190 {
13192
13194 if (coll)
13197 }
13198 }
13199 else
13200 {
13201
13202
13203
13204
13205
13206
13208
13209
13211 "\n-- For binary upgrade, recreate dropped column.\n");
13213 "SET attlen = %s, "
13214 "attalign = '%s', attbyval = false\n"
13220
13225 }
13226 }
13229
13231
13235 tyinfo->dobj.namespace->dobj.name);
13236
13240 .namespace =
tyinfo->dobj.namespace->dobj.name,
13241 .owner =
tyinfo->rolname,
13242 .description = "TYPE",
13244 .createStmt = q->
data,
13245 .dropStmt =
delq->data));
13246
13247
13248
13253
13258
13262 tyinfo->dobj.namespace->dobj.name,
13264
13265
13268
13276}
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287static void
13290{
13296 int ntups;
13300
13301
13303 return;
13304
13305
13308
13309
13311 return;
13312
13313
13316
13322 {
13324
13326 for (
i = 0;
i < ntups;
i++)
13327 {
13330 {
13332 break;
13333 }
13334 }
13336 {
13338
13343
13350
13353 .namespace =
tyinfo->dobj.namespace->dobj.name,
13354 .owner =
tyinfo->rolname,
13355 .description = "COMMENT",
13357 .createStmt = query->
data,
13358 .deps = &(
tyinfo->dobj.dumpId),
13359 .nDeps = 1));
13360 }
13361
13364 }
13365
13368}
13369
13370
13371
13372
13373
13374
13375
13376static void
13378{
13381
13382
13384 return;
13385
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13399 stinfo->baseType->dobj.catId.oid,
13400 false, false);
13401
13404
13408 .namespace =
stinfo->dobj.namespace->dobj.name,
13409 .owner =
stinfo->baseType->rolname,
13410 .description = "SHELL TYPE",
13412 .createStmt = q->
data));
13413
13415}
13416
13417
13418
13419
13420
13421
13422static void
13424{
13433
13434
13436 return;
13437
13438
13439
13440
13441
13442
13443
13444
13445
13449
13451 {
13455 }
13456
13458 {
13462 }
13463
13464
13465
13466
13467
13468
13472
13475
13477
13480
13482 {
13484 plang->lanpltrusted ?
"TRUSTED " :
"",
13494 }
13495 else
13496 {
13497
13498
13499
13500
13501
13502
13503
13504
13505
13508 }
13510
13514
13518 .owner =
plang->lanowner,
13519 .description = "PROCEDURAL LANGUAGE",
13521 .createStmt =
defqry->data,
13522 .dropStmt =
delqry->data,
13523 ));
13524
13525
13530
13535
13540
13542
13545}
13546
13547
13548
13549
13550
13551
13552
13553
13554static char *
13556{
13558
13563 else
13566}
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577static char *
13579{
13582
13586 else
13588 for (
j = 0;
j < finfo->
nargs;
j++)
13589 {
13592
13596 }
13599}
13600
13601
13602
13603
13604
13605
13606static void
13608{
13620 char *prosrc;
13627 char *prokind;
13640 const char *keyword;
13641
13642
13644 return;
13645
13650
13652 {
13653
13655 "PREPARE dumpFunc(pg_catalog.oid) AS\n");
13656
13658 "SELECT\n"
13659 "proretset,\n"
13660 "prosrc,\n"
13661 "probin,\n"
13662 "provolatile,\n"
13663 "proisstrict,\n"
13664 "prosecdef,\n"
13665 "lanname,\n"
13666 "proconfig,\n"
13667 "procost,\n"
13668 "prorows,\n"
13669 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
13670 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
13671 "pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
13672 "proleakproof,\n");
13673
13676 "array_to_string(protrftypes, ' ') AS protrftypes,\n");
13677 else
13679 "NULL AS protrftypes,\n");
13680
13683 "proparallel,\n");
13684 else
13686 "'u' AS proparallel,\n");
13687
13690 "prokind,\n");
13691 else
13693 "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n");
13694
13697 "prosupport,\n");
13698 else
13700 "'-' AS prosupport,\n");
13701
13704 "pg_get_function_sqlbody(p.oid) AS prosqlbody\n");
13705 else
13707 "NULL AS prosqlbody\n");
13708
13710 "FROM pg_catalog.pg_proc p, pg_catalog.pg_language l\n"
13711 "WHERE p.oid = $1 "
13712 "AND l.oid = p.prolang");
13713
13715
13717 }
13718
13720 "EXECUTE dumpFunc('%u')",
13722
13724
13727 {
13731 }
13732 else
13733 {
13737 }
13753
13754
13755
13756
13757
13759 {
13761 }
13762 else if (
probin[0] !=
'\0')
13763 {
13766 if (prosrc[0] != '\0')
13767 {
13769
13770
13771
13772
13773
13777 else
13779 }
13780 }
13781 else
13782 {
13784
13787 else
13789 }
13790
13792 {
13794 pg_fatal(
"could not parse %s array",
"proconfig");
13795 }
13796 else
13797 {
13800 }
13801
13804
13806
13810
13812 keyword = "PROCEDURE";
13813 else
13814 keyword = "FUNCTION";
13815
13818
13820 keyword,
13824
13826 ;
13829 else
13834
13836
13838 {
13841
13845 {
13850 }
13851
13853 }
13854
13857
13859 {
13865 pg_fatal(
"unrecognized provolatile value for function \"%s\"",
13867 }
13868
13871
13874
13877
13878
13879
13880
13881
13882
13884 {
13886 {
13887
13890 }
13891 else
13892 {
13893
13896 }
13897 }
13901
13903 {
13904
13906 }
13907
13909 {
13915 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
13917 }
13918
13920 {
13921
13923 char *pos;
13924
13927 continue;
13928 *pos++ = '\0';
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13948 {
13951
13952
13953
13955 {
13956
13960 {
13964 }
13965 }
13967 }
13968 else
13970 }
13971
13973
13975 "pg_catalog.pg_proc", keyword,
13977
13981 finfo->
dobj.namespace->dobj.
name);
13982
13986 .
namespace = finfo->
dobj.namespace->dobj.
name,
13988 .description = keyword,
13991 .createStmt = q->
data,
13993
13994
13999
14004
14010
14012
14022}
14023
14024
14025
14026
14027
14028static void
14030{
14039
14040
14042 return;
14043
14044
14046 {
14049 pg_fatal(
"could not find function definition for function with OID %u",
14051 }
14052
14057
14062
14065
14066 switch (
cast->castmethod)
14067 {
14070 break;
14073 break;
14076 {
14078
14079
14080
14081
14082
14086 }
14087 else
14088 pg_log_warning(
"bogus value in pg_cast.castfunc or pg_cast.castmethod field");
14089 break;
14090 default:
14092 }
14093
14094 if (
cast->castcontext ==
'a')
14096 else if (
cast->castcontext ==
'i')
14099
14102
14105
14109
14113 .description = "CAST",
14115 .createStmt =
defqry->data,
14116 .dropStmt =
delqry->data));
14117
14118
14122 cast->dobj.catId, 0,
cast->dobj.dumpId);
14123
14128}
14129
14130
14131
14132
14133static void
14135{
14145
14146
14148 return;
14149
14150
14152 {
14155 pg_fatal(
"could not find function definition for function with OID %u",
14157 }
14159 {
14162 pg_fatal(
"could not find function definition for function with OID %u",
14164 }
14165
14170
14173
14176
14179
14181 pg_log_warning(
"bogus transform definition, at least one of trffromsql and trftosql should be nonzero");
14182
14184 {
14186 {
14188
14189
14190
14191
14192
14196 }
14197 else
14199 }
14200
14202 {
14205
14207 {
14209
14210
14211
14212
14213
14217 }
14218 else
14220 }
14221
14223
14226
14229
14233
14237 .description = "TRANSFORM",
14239 .createStmt =
defqry->data,
14240 .dropStmt =
delqry->data,
14243
14244
14249
14255}
14256
14257
14258
14259
14260
14261
14262static void
14264{
14282 char *oprkind;
14283 char *oprcode;
14284 char *oprleft;
14285 char *oprright;
14294
14295
14297 return;
14298
14299
14300
14301
14302
14304 return;
14305
14311
14313 {
14314
14316 "PREPARE dumpOpr(pg_catalog.oid) AS\n"
14317 "SELECT oprkind, "
14318 "oprcode::pg_catalog.regprocedure, "
14319 "oprleft::pg_catalog.regtype, "
14320 "oprright::pg_catalog.regtype, "
14321 "oprcom, "
14322 "oprnegate, "
14323 "oprrest::pg_catalog.regprocedure, "
14324 "oprjoin::pg_catalog.regprocedure, "
14325 "oprcanmerge, oprcanhash "
14326 "FROM pg_catalog.pg_operator "
14327 "WHERE oid = $1");
14328
14330
14332 }
14333
14335 "EXECUTE dumpOpr('%u')",
14337
14339
14350
14361
14362
14363 if (
strcmp(oprkind,
"r") == 0)
14364 pg_log_warning(
"postfix operators are not supported anymore (operator \"%s\")",
14365 oprcode);
14366
14369 {
14372 }
14373
14376
14377
14378
14379
14380
14381
14382 if (
strcmp(oprkind,
"r") == 0 ||
14383 strcmp(oprkind,
"b") == 0)
14384 {
14387 }
14388 else
14390
14391 if (
strcmp(oprkind,
"l") == 0 ||
14392 strcmp(oprkind,
"b") == 0)
14393 {
14396 }
14397 else
14399
14402 {
14405 }
14406
14409 {
14412 }
14413
14416
14419
14422 {
14425 }
14426
14429 {
14432 }
14433
14437
14441
14444 "OPERATOR",
oprid->data,
14445 oprinfo->dobj.namespace->dobj.name);
14446
14450 .namespace =
oprinfo->dobj.namespace->dobj.name,
14452 .description = "OPERATOR",
14454 .createStmt = q->
data,
14455 .dropStmt =
delq->data));
14456
14457
14462
14464
14470}
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481static char *
14483{
14487
14488
14489 if (
strcmp(proc,
"-") == 0)
14491
14493
14496 {
14498 {
14500 break;
14501 }
14504 }
14506}
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522static char *
14524{
14526
14527
14530
14533 {
14537 }
14538
14539 return psprintf(
"OPERATOR(%s.%s)",
14542}
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552static char *
14554{
14556 char query[128];
14558
14560 "SELECT '%u'::pg_catalog.regproc", funcOid);
14562
14564
14566
14568}
14569
14570
14571
14572
14573
14574static void
14576{
14581
14582
14584 return;
14585
14588
14590
14592
14594 {
14597 break;
14600 break;
14601 default:
14607 return;
14608 }
14609
14611
14614
14618
14622 .description = "ACCESS METHOD",
14624 .createStmt = q->
data,
14625 .dropStmt =
delq->data));
14626
14627
14632
14636}
14637
14638
14639
14640
14641
14642static void
14644{
14651 int ntups;
14667 char *opcintype;
14670 char *opcfamily;
14673 char *amname;
14676 char *sortfamily;
14684
14685
14687 return;
14688
14693
14694
14696 "opckeytype::pg_catalog.regtype, "
14697 "opcdefault, opcfamily, "
14698 "opfname AS opcfamilyname, "
14699 "nspname AS opcfamilynsp, "
14700 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS amname "
14701 "FROM pg_catalog.pg_opclass c "
14702 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily "
14703 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14704 "WHERE c.oid = '%u'::pg_catalog.oid",
14706
14708
14716
14717
14721
14725
14727
14732
14733
14739 opcintype,
14742 {
14746 }
14748
14750
14752 {
14756 }
14757
14759
14760
14761
14762
14763
14764
14765
14768 "amopopr::pg_catalog.regoperator, "
14769 "opfname AS sortfamily, "
14770 "nspname AS sortfamilynsp "
14771 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14772 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14773 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14774 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14775 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14776 "AND refobjid = '%u'::pg_catalog.oid "
14777 "AND amopfamily = '%s'::pg_catalog.oid "
14778 "ORDER BY amopstrategy",
14780 opcfamily);
14781
14783
14785
14790
14791 for (
i = 0;
i < ntups;
i++)
14792 {
14797
14800
14803
14804 if (
strlen(sortfamily) > 0)
14805 {
14809 }
14810
14812 }
14813
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14827
14829 "amproc::pg_catalog.regprocedure, "
14830 "amproclefttype::pg_catalog.regtype, "
14831 "amprocrighttype::pg_catalog.regtype "
14832 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14833 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14834 "AND refobjid = '%u'::pg_catalog.oid "
14835 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14836 "AND objid = ap.oid "
14837 "ORDER BY amprocnum",
14839
14841
14843
14848
14849 for (
i = 0;
i < ntups;
i++)
14850 {
14855
14858
14860
14863
14865
14867 }
14868
14870
14871
14872
14873
14874
14875
14876
14879
14881
14885
14889 opcinfo->dobj.namespace->dobj.name);
14890
14894 .namespace =
opcinfo->dobj.namespace->dobj.name,
14896 .description = "OPERATOR CLASS",
14898 .createStmt = q->
data,
14899 .dropStmt =
delq->data));
14900
14901
14906
14914}
14915
14916
14917
14918
14919
14920
14921
14922
14923static void
14925{
14934 int ntups;
14944 char *amname;
14947 char *sortfamily;
14955
14956
14958 return;
14959
14964
14965
14966
14967
14968
14970 "amopopr::pg_catalog.regoperator, "
14971 "opfname AS sortfamily, "
14972 "nspname AS sortfamilynsp "
14973 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14974 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14975 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14976 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14977 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14978 "AND refobjid = '%u'::pg_catalog.oid "
14979 "AND amopfamily = '%u'::pg_catalog.oid "
14980 "ORDER BY amopstrategy",
14983
14985
14987
14989 "amproc::pg_catalog.regprocedure, "
14990 "amproclefttype::pg_catalog.regtype, "
14991 "amprocrighttype::pg_catalog.regtype "
14992 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14993 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14994 "AND refobjid = '%u'::pg_catalog.oid "
14995 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14996 "AND objid = ap.oid "
14997 "ORDER BY amprocnum",
14999
15001
15002
15004
15006 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opfmethod) AS amname "
15007 "FROM pg_catalog.pg_opfamily "
15008 "WHERE oid = '%u'::pg_catalog.oid",
15010
15012
15014
15015
15017
15022
15023
15028
15030
15031
15033 {
15038
15040
15041
15042
15043
15045
15050
15051 for (
i = 0;
i < ntups;
i++)
15052 {
15057
15060
15063
15064 if (
strlen(sortfamily) > 0)
15065 {
15069 }
15070
15072 }
15073
15074
15075
15076
15078
15083
15084 for (
i = 0;
i < ntups;
i++)
15085 {
15090
15093
15097
15099 }
15100
15102 }
15103
15107
15111 opfinfo->dobj.namespace->dobj.name);
15112
15116 .namespace =
opfinfo->dobj.namespace->dobj.name,
15118 .description = "OPERATOR FAMILY",
15120 .createStmt = q->
data,
15121 .dropStmt =
delq->data));
15122
15123
15128
15136}
15137
15138
15139
15140
15141
15142static void
15144{
15162
15163
15165 return;
15166
15170
15172
15173
15175
15178 "collprovider, "
15179 "collversion, ");
15180 else
15182 "'c' AS collprovider, "
15183 "NULL AS collversion, ");
15184
15187 "collisdeterministic, ");
15188 else
15190 "true AS collisdeterministic, ");
15191
15194 "colllocale, ");
15197 "colliculocale AS colllocale, ");
15198 else
15200 "NULL AS colllocale, ");
15201
15204 "collicurules, ");
15205 else
15207 "NULL AS collicurules, ");
15208
15210 "collcollate, "
15211 "collctype "
15212 "FROM pg_catalog.pg_collation c "
15213 "WHERE c.oid = '%u'::pg_catalog.oid",
15215
15217
15224
15226
15229 else
15231
15234 else
15236
15237
15238
15239
15240
15242 {
15247 }
15248
15251 else
15253
15256 else
15258
15261
15264
15273
15275 else
15276 pg_fatal(
"unrecognized collation provider: %s",
15278
15281
15283 {
15286
15287
15288 }
15290 {
15293
15297 }
15299 {
15301 {
15304
15308 }
15309 else
15310 {
15314
15317 }
15318
15320 {
15323 }
15324 }
15326 {
15329
15331 {
15334 }
15335 else
15336 {
15341 }
15342 }
15343 else
15345
15346
15347
15348
15349
15351 {
15353
15356 {
15361 }
15362 }
15363
15365
15369 collinfo->dobj.namespace->dobj.name);
15370
15374 .namespace =
collinfo->dobj.namespace->dobj.name,
15376 .description = "COLLATION",
15378 .createStmt = q->
data,
15379 .dropStmt =
delq->data));
15380
15381
15386
15388
15393}
15394
15395
15396
15397
15398
15399static void
15401{
15416
15417
15419 return;
15420
15424
15426
15427
15429 "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
15430 "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
15431 "conproc, condefault "
15432 "FROM pg_catalog.pg_conversion c "
15433 "WHERE c.oid = '%u'::pg_catalog.oid",
15435
15437
15442
15447
15450
15457
15459
15463 convinfo->dobj.namespace->dobj.name);
15464
15468 .namespace =
convinfo->dobj.namespace->dobj.name,
15470 .description = "CONVERSION",
15472 .createStmt = q->
data,
15473 .dropStmt =
delq->data));
15474
15475
15480
15482
15487}
15488
15489
15490
15491
15492
15493
15494
15495static char *
15497{
15500
15504 else
15506
15507 if (
agginfo->aggfn.nargs == 0)
15509 else
15510 {
15514 (
j > 0) ?
", " :
"",
15519 }
15521}
15522
15523
15524
15525
15526
15527static void
15529{
15553 const char *aggsortop;
15556 const char *aggtranstype;
15557 const char *aggtransspace;
15564
15565
15567 return;
15568
15573
15575 {
15576
15578 "PREPARE dumpAgg(pg_catalog.oid) AS\n");
15579
15581 "SELECT "
15582 "aggtransfn,\n"
15583 "aggfinalfn,\n"
15584 "aggtranstype::pg_catalog.regtype,\n"
15585 "agginitval,\n"
15586 "aggsortop,\n"
15587 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
15588 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
15589
15592 "aggkind,\n"
15593 "aggmtransfn,\n"
15594 "aggminvtransfn,\n"
15595 "aggmfinalfn,\n"
15596 "aggmtranstype::pg_catalog.regtype,\n"
15597 "aggfinalextra,\n"
15598 "aggmfinalextra,\n"
15599 "aggtransspace,\n"
15600 "aggmtransspace,\n"
15601 "aggminitval,\n");
15602 else
15604 "'n' AS aggkind,\n"
15605 "'-' AS aggmtransfn,\n"
15606 "'-' AS aggminvtransfn,\n"
15607 "'-' AS aggmfinalfn,\n"
15608 "0 AS aggmtranstype,\n"
15609 "false AS aggfinalextra,\n"
15610 "false AS aggmfinalextra,\n"
15611 "0 AS aggtransspace,\n"
15612 "0 AS aggmtransspace,\n"
15613 "NULL AS aggminitval,\n");
15614
15617 "aggcombinefn,\n"
15618 "aggserialfn,\n"
15619 "aggdeserialfn,\n"
15620 "proparallel,\n");
15621 else
15623 "'-' AS aggcombinefn,\n"
15624 "'-' AS aggserialfn,\n"
15625 "'-' AS aggdeserialfn,\n"
15626 "'u' AS proparallel,\n");
15627
15630 "aggfinalmodify,\n"
15631 "aggmfinalmodify\n");
15632 else
15634 "'0' AS aggfinalmodify,\n"
15635 "'0' AS aggmfinalmodify\n");
15636
15638 "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
15639 "WHERE a.aggfnoid = p.oid "
15640 "AND p.oid = $1");
15641
15643
15645 }
15646
15648 "EXECUTE dumpAgg('%u')",
15649 agginfo->aggfn.dobj.catId.oid);
15650
15652
15655
15677
15678 {
15681
15686 }
15687
15689
15690
15692
15697
15698
15701
15702 if (
strcmp(aggtransspace,
"0") != 0)
15703 {
15705 aggtransspace);
15706 }
15707
15709 {
15712 }
15713
15715 {
15721 {
15723 {
15726 break;
15729 break;
15732 break;
15733 default:
15734 pg_fatal(
"unrecognized aggfinalmodify value for aggregate \"%s\"",
15736 break;
15737 }
15738 }
15739 }
15740
15743
15746
15749
15751 {
15756 }
15757
15759 {
15762 }
15763
15765 {
15768 }
15769
15771 {
15777 {
15779 {
15782 break;
15785 break;
15788 break;
15789 default:
15790 pg_fatal(
"unrecognized aggmfinalmodify value for aggregate \"%s\"",
15792 break;
15793 }
15794 }
15795 }
15796
15799 {
15803 }
15804
15807
15809 {
15815 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
15817 }
15818
15822
15826
15830 agginfo->aggfn.dobj.namespace->dobj.name);
15831
15836 .
namespace =
agginfo->aggfn.dobj.namespace->dobj.name,
15837 .owner =
agginfo->aggfn.rolname,
15838 .description = "AGGREGATE",
15840 .createStmt = q->
data,
15841 .dropStmt =
delq->data));
15842
15843
15846 agginfo->aggfn.dobj.namespace->dobj.name,
15849
15852 agginfo->aggfn.dobj.namespace->dobj.name,
15855
15856
15857
15858
15859
15860
15862
15864
15868 agginfo->aggfn.dobj.namespace->dobj.name,
15870
15874
15876
15881}
15882
15883
15884
15885
15886
15887static void
15889{
15894
15895
15897 return;
15898
15901
15903
15906
15918
15921
15925 prsinfo->dobj.namespace->dobj.name);
15926
15930 .namespace =
prsinfo->dobj.namespace->dobj.name,
15931 .description = "TEXT SEARCH PARSER",
15933 .createStmt = q->
data,
15934 .dropStmt =
delq->data));
15935
15936
15939 prsinfo->dobj.namespace->dobj.name,
"",
15941
15945}
15946
15947
15948
15949
15950
15951static void
15953{
15960 char *nspname;
15962
15963
15965 return;
15966
15970
15972
15973
15975 "FROM pg_ts_template p, pg_namespace n "
15976 "WHERE p.oid = '%u' AND n.oid = tmplnamespace",
15981
15984
15988
15990
15991
15994
15996
15999
16003 dictinfo->dobj.namespace->dobj.name);
16004
16008 .namespace =
dictinfo->dobj.namespace->dobj.name,
16010 .description = "TEXT SEARCH DICTIONARY",
16012 .createStmt = q->
data,
16013 .dropStmt =
delq->data));
16014
16015
16020
16025}
16026
16027
16028
16029
16030
16031static void
16033{
16038
16039
16041 return;
16042
16045
16047
16050
16056
16059
16063 tmplinfo->dobj.namespace->dobj.name);
16064
16068 .namespace =
tmplinfo->dobj.namespace->dobj.name,
16069 .description = "TEXT SEARCH TEMPLATE",
16071 .createStmt = q->
data,
16072 .dropStmt =
delq->data));
16073
16074
16077 tmplinfo->dobj.namespace->dobj.name,
"",
16079
16083}
16084
16085
16086
16087
16088
16089static void
16091{
16098 char *nspname;
16100 int ntups,
16104
16105
16107 return;
16108
16112
16114
16115
16117 "FROM pg_ts_parser p, pg_namespace n "
16118 "WHERE p.oid = '%u' AND n.oid = prsnamespace",
16123
16126
16129
16131
16134 "SELECT\n"
16135 " ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
16136 " WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
16137 " m.mapdict::pg_catalog.regdictionary AS dictname\n"
16138 "FROM pg_catalog.pg_ts_config_map AS m\n"
16139 "WHERE m.mapcfg = '%u'\n"
16140 "ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
16142
16145
16148
16149 for (
i = 0;
i < ntups;
i++)
16150 {
16153
16156 {
16157
16162
16165 }
16166 else
16168 }
16169
16170 if (ntups > 0)
16172
16174
16177
16180 "TEXT SEARCH CONFIGURATION",
qcfgname,
16181 cfginfo->dobj.namespace->dobj.name);
16182
16186 .namespace =
cfginfo->dobj.namespace->dobj.name,
16188 .description = "TEXT SEARCH CONFIGURATION",
16190 .createStmt = q->
data,
16191 .dropStmt =
delq->data));
16192
16193
16198
16203}
16204
16205
16206
16207
16208
16209static void
16211{
16216
16217
16219 return;
16220
16223
16225
16228
16231
16234
16237
16240
16242
16245
16250
16255 .description = "FOREIGN DATA WRAPPER",
16257 .createStmt = q->
data,
16258 .dropStmt =
delq->data));
16259
16260
16265
16266
16271
16273
16276}
16277
16278
16279
16280
16281
16282static void
16284{
16291 char *fdwname;
16292
16293
16295 return;
16296
16300
16302
16303
16305 "FROM pg_foreign_data_wrapper w "
16306 "WHERE w.oid = '%u'",
16310
16313 {
16316 }
16318 {
16321 }
16322
16325
16328
16330
16333
16337
16342 .description = "SERVER",
16344 .createStmt = q->
data,
16345 .dropStmt =
delq->data));
16346
16347
16352
16353
16358
16359
16365
16367
16369
16373}
16374
16375
16376
16377
16378
16379
16380
16381
16382static void
16384 const char *servername, const char *namespace,
16385 const char *owner,
16387{
16393 int ntups;
16397
16402
16403
16404
16405
16406
16407
16408
16409
16410
16412 "SELECT usename, "
16413 "array_to_string(ARRAY("
16414 "SELECT quote_ident(option_name) || ' ' || "
16415 "quote_literal(option_value) "
16416 "FROM pg_options_to_table(umoptions) "
16417 "ORDER BY option_name"
16418 "), E',\n ') AS umoptions "
16419 "FROM pg_user_mappings "
16420 "WHERE srvid = '%u' "
16421 "ORDER BY usename",
16423
16425
16429
16430 for (
i = 0;
i < ntups;
i++)
16431 {
16434
16437
16441
16444
16446
16450
16454
16457 .namespace = namespace,
16458 .owner = owner,
16459 .description = "USER MAPPING",
16461 .createStmt = q->
data,
16462 .dropStmt =
delq->data));
16463 }
16464
16466
16471}
16472
16473
16474
16475
16476static void
16478{
16483
16484
16486 return;
16487
16490
16492 {
16495 break;
16497 type =
"SEQUENCES";
16498 break;
16500 type =
"FUNCTIONS";
16501 break;
16504 break;
16507 break;
16509 type =
"LARGE OBJECTS";
16510 break;
16511 default:
16512
16513 pg_fatal(
"unrecognized object type in default privileges: %d",
16516 }
16517
16519
16520
16527 fout->remoteVersion,
16528 q))
16529 pg_fatal(
"could not parse default ACL list (%s)",
16531
16535 .namespace =
daclinfo->dobj.namespace ?
16540 .createStmt = q->
data));
16541
16544}
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16571 const char *nspname, const char *tag, const char *owner,
16573{
16576 const char *
acls = dacl->
acl;
16579 const char *initprivs = dacl->
initprivs;
16582
16583
16586
16587
16590
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16607 initprivs && *initprivs != '\0')
16608 {
16613 pg_fatal(
"could not parse initial ACL list (%s) or default (%s) for object \"%s\" (%s)",
16615 appendPQExpBufferStr(sql,
"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
16616 }
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626 if (initprivs && *initprivs != '\0')
16627 {
16631 }
16632 else
16634
16638 pg_fatal(
"could not parse ACL list (%s) or default (%s) for object \"%s\" (%s)",
16640
16642 {
16645 int nDeps = 0;
16646
16647 if (tag)
16651 else
16653
16657
16659
16662 .namespace = nspname,
16663 .owner = owner,
16664 .description = "ACL",
16666 .createStmt = sql->
data,
16668 .nDeps = nDeps));
16669
16671 }
16672
16674
16676}
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696static void
16698 const char *namespace, const char *owner,
16700{
16706
16707
16709 return;
16710
16711
16712
16713
16714
16716 {
16718 return;
16719 }
16720 else
16721 {
16722
16724 return;
16725 }
16726
16727
16729
16731
16733 {
16734
16735
16736
16737 if (labels[
i].objsubid != subid)
16738 continue;
16739
16741 "SECURITY LABEL FOR %s ON %s ",
16743 if (namespace && *namespace)
16748 }
16749
16750 if (query->
len > 0)
16751 {
16753
16757 .namespace = namespace,
16758 .owner = owner,
16759 .description = "SECURITY LABEL",
16761 .createStmt = query->
data,
16762 .deps = &dumpId,
16763 .nDeps = 1));
16765 }
16766
16768}
16769
16770
16771
16772
16773
16774
16775
16776static void
16778{
16785
16786
16788 return;
16789
16790
16792 return;
16793
16794
16797 &labels);
16798
16799
16801 return;
16802
16805
16807 {
16808 const char *colname;
16812
16814 if (objsubid == 0)
16815 {
16818 }
16819 else
16820 {
16822
16826 }
16831 }
16832 if (query->
len > 0)
16833 {
16839 .namespace =
tbinfo->dobj.namespace->dobj.name,
16840 .owner =
tbinfo->rolname,
16841 .description = "SECURITY LABEL",
16843 .createStmt = query->
data,
16844 .deps = &(
tbinfo->dobj.dumpId),
16845 .nDeps = 1));
16846 }
16849}
16850
16851
16852
16853
16854
16855
16856
16857
16858static int
16860{
16864 int nmatch;
16865
16867 {
16869 return 0;
16870 }
16871
16872
16873
16874
16877 while (low <= high)
16878 {
16879 middle = low + (high - low) / 2;
16880
16883 else if (classoid >
middle->classoid)
16887 else if (objoid >
middle->objoid)
16889 else
16890 break;
16891 }
16892
16893 if (low > high)
16894 {
16896 return 0;
16897 }
16898
16899
16900
16901
16902
16903
16904 nmatch = 1;
16906 {
16907 if (classoid !=
middle[-1].classoid ||
16908 objoid !=
middle[-1].objoid)
16909 break;
16911 nmatch++;
16912 }
16913
16915
16918 {
16919 if (classoid !=
middle->classoid ||
16920 objoid !=
middle->objoid)
16921 break;
16923 nmatch++;
16924 }
16925
16926 return nmatch;
16927}
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937static void
16939{
16947 int ntups;
16950
16952
16954 "SELECT label, provider, classoid, objoid, objsubid "
16955 "FROM pg_catalog.pg_seclabels "
16956 "ORDER BY classoid, objoid, objsubid");
16957
16959
16960
16966
16968
16972
16973 for (
i = 0;
i < ntups;
i++)
16974 {
16976 int subid;
16977
16981
16982
16983 if (dobj ==
NULL ||
16988 continue;
16989
16990
16991
16992
16993
16994
16997 {
16999
17003 }
17004 else
17006
17013 }
17014
17017}
17018
17019
17020
17021
17022
17023static void
17025{
17029
17030
17032 return;
17033
17035 {
17038 else
17040 }
17041
17042
17045 {
17046 const char *objtype;
17047
17048 switch (
tbinfo->relkind)
17049 {
17051 objtype = "SEQUENCE";
17052 break;
17054 objtype = "PROPERTY GRAPH";
17055 break;
17056 default:
17057 objtype = "TABLE";
17058 break;
17059 }
17060
17064 tbinfo->dobj.namespace->dobj.name,
17066 }
17067
17068
17069
17070
17071
17072
17073
17075 {
17079
17081 {
17082
17084 "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
17085
17087 {
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17099 "SELECT at.attname, "
17100 "at.attacl, "
17101 "'{}' AS acldefault, "
17102 "pip.privtype, pip.initprivs "
17103 "FROM pg_catalog.pg_attribute at "
17104 "LEFT JOIN pg_catalog.pg_init_privs pip ON "
17105 "(at.attrelid = pip.objoid "
17106 "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
17107 "AND at.attnum = pip.objsubid) "
17108 "WHERE at.attrelid = $1 AND "
17109 "NOT at.attisdropped "
17110 "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
17111 "ORDER BY at.attnum");
17112 }
17113 else
17114 {
17116 "SELECT attname, attacl, '{}' AS acldefault, "
17117 "NULL AS privtype, NULL AS initprivs "
17118 "FROM pg_catalog.pg_attribute "
17119 "WHERE attrelid = $1 AND NOT attisdropped "
17120 "AND attacl IS NOT NULL "
17121 "ORDER BY attnum");
17122 }
17123
17125
17127 }
17128
17130 "EXECUTE getColumnACLs('%u')",
17131 tbinfo->dobj.catId.oid);
17132
17134
17136 {
17144
17148 coldacl.initprivs = initprivs;
17150
17151
17152
17153
17154
17155
17158 tbinfo->dobj.namespace->dobj.name,
17161 }
17164 }
17165
17167}
17168
17169
17170
17171
17172
17173
17174
17177{
17182
17183
17185 "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
17186 tbinfo->dobj.catId.oid);
17187
17189
17191 {
17193 pg_fatal(
"query to obtain definition of view \"%s\" returned no data",
17195 else
17196 pg_fatal(
"query to obtain definition of view \"%s\" returned more than one definition",
17198 }
17199
17201
17203 pg_fatal(
"definition of view \"%s\" appears to be empty (length zero)",
17205
17206
17209
17212
17214}
17215
17216
17217
17218
17219
17220
17221
17222
17223
17226{
17229
17231
17233 {
17237
17239
17240
17241
17242
17243
17245 {
17247
17249 if (coll)
17252 }
17253
17255 }
17256
17258}
17259
17260
17261
17262
17263
17264static void
17266{
17273 int numParents;
17279 k;
17280
17281
17283
17286
17288 pg_log_warning(
"WITH OIDS is not supported anymore (table \"%s\")",
17290
17293
17294
17296 {
17298
17299
17300
17301
17302
17304
17307 tbinfo->dobj.catId.oid);
17308
17310
17313 else
17314 {
17316 {
17320 }
17322 }
17325
17329 }
17331 {
17335
17337
17340 tbinfo->dobj.catId.oid);
17341
17343 "SELECT pg_catalog.pg_get_propgraphdef('%u'::pg_catalog.oid) AS pgdef",
17344 tbinfo->dobj.catId.oid);
17345
17347
17349 {
17351 pg_fatal(
"query to obtain definition of property graph \"%s\" returned no data",
17353 else
17354 pg_fatal(
"query to obtain definition of property graph \"%s\" returned more than one definition",
17356 }
17357
17359
17361 pg_fatal(
"definition of property graph \"%s\" appears to be empty (length zero)",
17363
17365
17368
17370 }
17371 else
17372 {
17377
17378
17379
17380
17381
17382 switch (
tbinfo->relkind)
17383 {
17385 {
17388
17390
17391
17393 "SELECT pg_get_partkeydef('%u')",
17394 tbinfo->dobj.catId.oid);
17399 break;
17400 }
17402 {
17407
17409
17410
17412 "SELECT fs.srvname, "
17413 "pg_catalog.array_to_string(ARRAY("
17414 "SELECT pg_catalog.quote_ident(option_name) || "
17415 "' ' || pg_catalog.quote_literal(option_value) "
17416 "FROM pg_catalog.pg_options_to_table(ftoptions) "
17417 "ORDER BY option_name"
17418 "), E',\n ') AS ftoptions "
17419 "FROM pg_catalog.pg_foreign_table ft "
17420 "JOIN pg_catalog.pg_foreign_server fs "
17421 "ON (fs.oid = ft.ftserver) "
17422 "WHERE ft.ftrelid = '%u'",
17423 tbinfo->dobj.catId.oid);
17431
17433 break;
17434 }
17437 break;
17438 default:
17440 break;
17441 }
17442
17443 numParents =
tbinfo->numParents;
17445
17448 tbinfo->dobj.catId.oid);
17449
17450
17451
17452
17453
17457 "UNLOGGED " : "",
17460
17461
17462
17463
17464
17469
17471 {
17472
17475 {
17476
17477
17478
17479
17480
17481
17483 {
17486
17487
17488
17489
17490
17492 tbinfo->attrdefs[
j]->dobj.dump &&
17493 !
tbinfo->attrdefs[
j]->separate);
17494
17495
17496
17497
17498
17499
17501 (
tbinfo->notnull_islocal[
j] ||
17504
17505
17506
17507
17508
17512 continue;
17513
17514
17517 else
17521
17522
17524
17526 {
17527
17528
17529
17530
17531
17532
17534
17535 continue;
17536 }
17537
17538
17539
17540
17541
17542
17544 {
17547 }
17548
17550 {
17553 tbinfo->attrdefs[
j]->adef_expr);
17556 tbinfo->attrdefs[
j]->adef_expr);
17557 else
17559 tbinfo->attrdefs[
j]->adef_expr);
17560 }
17561
17563 {
17564 if (
tbinfo->notnull_constrs[
j][0] ==
'\0')
17566 else
17569
17570 if (
tbinfo->notnull_noinh[
j])
17572 }
17573
17574
17576 {
17578
17580 if (coll)
17583 }
17584 }
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17600 {
17601
17604 else
17608
17609 if (
tbinfo->notnull_constrs[
j][0] ==
'\0')
17612 else
17616
17617 if (
tbinfo->notnull_noinh[
j])
17619 }
17620 }
17621
17622
17623
17624
17625
17626
17627
17628
17629
17631 {
17633
17636 continue;
17637
17640 else
17642
17646
17648 }
17649
17653 {
17654
17655
17656
17657
17659 }
17660
17661
17662
17663
17664
17665 if (numParents > 0 && !
tbinfo->ispartition &&
17667 {
17669 for (k = 0; k < numParents; k++)
17670 {
17672
17673 if (k > 0)
17676 }
17678 }
17679
17682
17685 }
17686
17689 {
17691
17694 {
17697 }
17699 {
17704 }
17706 }
17707
17708
17711
17712
17713
17714
17715
17717 {
17719
17724 }
17725 else
17727
17728
17731 "pg_catalog.pg_class",
17732 "MATERIALIZED VIEW",
17734
17735
17736
17737
17738
17740 {
17742 {
17743 if (
tbinfo->attmissingval[
j][0] !=
'\0')
17744 {
17747 "SELECT pg_catalog.binary_upgrade_set_missing_value(");
17754 }
17755 }
17756 }
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17783 {
17786
17787
17788
17789
17790
17791
17792
17796 {
17798 {
17800 {
17802 "UPDATE pg_catalog.pg_attribute\n"
17803 "SET attlen = v.dlen, "
17804 "attalign = v.dalign, "
17805 "attbyval = false\n"
17806 "FROM (VALUES ");
17808 }
17809 else
17816
17821 }
17822 }
17824 {
17826 "WHERE attrelid = ");
17829 " AND attname = v.dname;\n");
17830
17832 }
17833
17834
17835
17836
17837
17840 {
17841 if (!
tbinfo->attisdropped[
j] &&
17843 {
17845 {
17848 "SET attislocal = false\n"
17849 "WHERE attrelid = ");
17852 " AND attname IN (");
17854 }
17855 else
17858 }
17859 }
17862
17863
17864
17865
17866
17867
17868
17873 {
17874
17875
17876
17877
17878
17879
17880
17881
17882
17885 {
17886 if (
tbinfo->notnull_constrs[
j][0] !=
'\0')
17887 {
17889 {
17891 "SET conislocal = false\n"
17892 "WHERE contype = 'n' AND conrelid = ");
17895 "conname IN (");
17897 }
17898 else
17901 }
17902 else
17903 {
17905 {
17907 "SET conislocal = false\n"
17908 "WHERE contype = 'n' AND conrelid = ");
17911 "conkey IN (");
17913 }
17914 else
17917 }
17918 }
17919 }
17924
17925 if (extra->
len > 0)
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17942 for (k = 0; k <
tbinfo->ncheck; k++)
17943 {
17945
17947 continue;
17948
17955
17957 {
17959 "SET conislocal = false\n"
17960 "WHERE contype = 'c' AND conrelid = ");
17965 }
17966 else
17969 }
17971 {
17974 }
17975
17976 if (numParents > 0 && !
tbinfo->ispartition)
17977 {
17979 for (k = 0; k < numParents; k++)
17980 {
17982
17986 }
17987 }
17988
17990 {
17996 }
17997 }
17998
17999
18000
18001
18002
18003
18004
18005
18009 {
18012 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
18013 "WHERE oid = ",
18017
18019 {
18020
18021
18022
18023
18024 appendPQExpBufferStr(q,
"\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
18026 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
18027 "WHERE oid = '%u';\n",
18028 tbinfo->toast_frozenxid,
18030 }
18031 }
18032
18033
18034
18035
18036
18037
18038
18039
18042 {
18045 "SET relispopulated = 't'\n"
18046 "WHERE oid = ");
18049 }
18050
18051
18052
18053
18054
18056 {
18057
18059 continue;
18060
18061
18062
18063
18064
18065
18066 if (
tbinfo->attstattarget[
j] >= 0)
18067 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STATISTICS %d;\n",
18071
18072
18073
18074
18075
18077 {
18078 switch (
tbinfo->attstorage[
j])
18079 {
18082 break;
18085 break;
18088 break;
18091 break;
18092 default:
18094 }
18095
18096
18097
18098
18100 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STORAGE %s;\n",
18104 }
18105
18106
18107
18108
18110 {
18112
18113 switch (
tbinfo->attcompression[
j])
18114 {
18115 case 'p':
18117 break;
18118 case 'l':
18120 break;
18121 default:
18123 break;
18124 }
18125
18127 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET COMPRESSION %s;\n",
18131 }
18132
18133
18134
18135
18136 if (
tbinfo->attoptions[
j][0] !=
'\0')
18141
18142
18143
18144
18146 tbinfo->attfdwoptions[
j][0] !=
'\0')
18148 "ALTER FOREIGN TABLE ONLY %s ALTER COLUMN %s OPTIONS (\n"
18149 " %s\n"
18150 ");\n",
18154 }
18155
18159 }
18160
18161
18162
18163
18168 {
18170 {
18171
18172 }
18174 {
18177 }
18179 {
18182 }
18183 }
18184
18185 if (
tbinfo->forcerowsec)
18188
18190
18194 tbinfo->dobj.namespace->dobj.name);
18195
18197 {
18199 char *tableam =
NULL;
18200
18201
18202
18203
18204
18205
18206
18207
18210
18213 tableam =
tbinfo->amname;
18214
18217 .namespace =
tbinfo->dobj.namespace->dobj.name,
18219 .tableam = tableam,
18220 .relkind =
tbinfo->relkind,
18221 .owner =
tbinfo->rolname,
18223 .section =
tbinfo->postponed_def ?
18225 .createStmt = q->
data,
18227 }
18228
18229
18232
18233
18236
18237
18238
18239
18240
18243 {
18246
18248 {
18251 {
18253 {
18256 }
18257 else
18258 {
18261 }
18262
18267
18270
18273 .namespace =
tbinfo->dobj.namespace->dobj.name,
18274 .owner =
tbinfo->rolname,
18275 .description = "COMMENT",
18278 .deps = &(
tbinfo->dobj.dumpId),
18279 .nDeps = 1));
18280 }
18281 }
18282
18285 }
18286
18287
18289 {
18291
18293 continue;
18294
18297 }
18298
18304}
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321static void
18323{
18327 char *partbound;
18328
18329
18331 return;
18332
18334
18336 {
18337
18339 "PREPARE dumpTableAttach(pg_catalog.oid) AS\n");
18340
18342 "SELECT pg_get_expr(c.relpartbound, c.oid) "
18343 "FROM pg_class c "
18344 "WHERE c.oid = $1");
18345
18347
18349 }
18350
18352 "EXECUTE dumpTableAttach('%u')",
18354
18357
18358
18360 "ALTER TABLE ONLY %s ",
18363 "ATTACH PARTITION %s %s;\n",
18365 partbound);
18366
18367
18368
18369
18370
18371
18372
18373
18376 .namespace =
attachinfo->dobj.namespace->dobj.name,
18378 .description = "TABLE ATTACH",
18380 .createStmt = q->
data));
18381
18384}
18385
18386
18387
18388
18389static void
18391{
18394 int adnum =
adinfo->adnum;
18398 char *tag;
18400
18401
18403 return;
18404
18405
18407 return;
18408
18411
18413
18415
18417 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET DEFAULT %s;\n",
18420
18424
18426
18430 .
namespace =
tbinfo->dobj.namespace->dobj.name,
18431 .owner =
tbinfo->rolname,
18432 .description = "DEFAULT",
18434 .createStmt = q->
data,
18435 .dropStmt =
delq->data));
18436
18441}
18442
18443
18444
18445
18446
18447
18448
18449
18450static const char *
18452{
18454 return tblInfo->attnames[attrnum - 1];
18455 switch (attrnum)
18456 {
18458 return "ctid";
18460 return "xmin";
18462 return "cmin";
18464 return "xmax";
18466 return "cmax";
18468 return "tableoid";
18469 }
18470 pg_fatal(
"invalid column number %d for table \"%s\"",
18471 attrnum,
tblInfo->dobj.name);
18473}
18474
18475
18476
18477
18478
18479static void
18481{
18489
18490
18492 return;
18493
18496
18499
18500
18501
18502
18503
18504
18505
18506
18508 {
18509 char *indstatcols =
indxinfo->indstatcols;
18510 char *indstatvals =
indxinfo->indstatvals;
18515
18519
18520
18522
18523
18524
18525
18526
18527
18528
18529
18531 {
18534
18537 }
18538
18539
18540
18541
18542
18543 if (
strlen(indstatcols) != 0 ||
strlen(indstatvals) != 0)
18544 {
18546
18548 pg_fatal(
"could not parse index statistic columns");
18550 pg_fatal(
"could not parse index statistic values");
18552 pg_fatal(
"mismatched number of columns and values for index statistics");
18553
18555 {
18557
18558
18559
18560
18561
18566 }
18567 }
18568
18569
18571 "pg_catalog.pg_class",
18573
18574
18576 {
18579
18582 }
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18595
18599 .namespace =
tbinfo->dobj.namespace->dobj.name,
18600 .tablespace =
indxinfo->tablespace,
18601 .owner =
tbinfo->rolname,
18602 .description = "INDEX",
18604 .createStmt = q->
data,
18605 .dropStmt =
delq->data));
18606
18609 }
18610
18611
18614 tbinfo->dobj.namespace->dobj.name,
18619
18624}
18625
18626
18627
18628
18629
18630static void
18632{
18633
18635 return;
18636
18638 {
18640
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18659 .namespace =
attachinfo->dobj.namespace->dobj.name,
18660 .owner =
attachinfo->parentIdx->indextable->rolname,
18661 .description = "INDEX ATTACH",
18663 .createStmt = q->
data));
18664
18666 }
18667}
18668
18669
18670
18671
18672
18673static void
18675{
18683
18684
18686 return;
18687
18691
18693
18695 "pg_catalog.pg_get_statisticsobjdef('%u'::pg_catalog.oid)",
18697
18699
18701
18702
18704
18705
18706
18707
18708
18710 {
18715 }
18716
18719
18726 .description = "STATISTICS",
18728 .createStmt = q->
data,
18729 .dropStmt =
delq->data));
18730
18731
18738
18744}
18745
18746
18747
18748
18749
18750static void
18752{
18756 int nstats;
18757
18758
18760 return;
18761
18763 {
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18781 "PREPARE getExtStatsStats(pg_catalog.name, pg_catalog.name) AS\n"
18782 "SELECT ");
18783
18784
18785
18786
18787
18788
18789
18792 else
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18823 else
18825 "( "
18826 "SELECT json_agg( "
18827 " json_build_object( "
18829 " string_to_array(kv.key, ', ')::integer[], "
18831 " kv.value::bigint )) "
18832 "FROM json_each_text(e.n_distinct::text::json) AS kv"
18833 ") AS n_distinct, "
18834 "( "
18835 "SELECT json_agg( "
18836 " json_build_object( "
18838 " string_to_array( "
18839 " split_part(kv.key, ' => ', 1), "
18840 " ', ')::integer[], "
18842 " split_part(kv.key, ' => ', 2)::integer, "
18844 " kv.value::double precision )) "
18845 "FROM json_each_text(e.dependencies::text::json) AS kv "
18846 ") AS dependencies, ");
18847
18848
18851 "e.most_common_vals, e.most_common_freqs, "
18852 "e.most_common_base_freqs, ");
18853 else
18855 "NULL AS most_common_vals, NULL AS most_common_freqs, "
18856 "NULL AS most_common_base_freqs, ");
18857
18858
18860 {
18861
18862
18863
18864
18865
18867 "( "
18868 "SELECT jsonb_pretty(jsonb_agg("
18869 "nullif(j.obj, '{}'::jsonb))) "
18870 "FROM pg_stats_ext_exprs AS ee "
18871 "CROSS JOIN LATERAL jsonb_strip_nulls("
18872 " jsonb_build_object( "
18873 " 'null_frac', ee.null_frac::text, "
18874 " 'avg_width', ee.avg_width::text, "
18875 " 'n_distinct', ee.n_distinct::text, "
18876 " 'most_common_vals', ee.most_common_vals::text, "
18877 " 'most_common_freqs', ee.most_common_freqs::text, "
18878 " 'histogram_bounds', ee.histogram_bounds::text, "
18879 " 'correlation', ee.correlation::text, "
18880 " 'most_common_elems', ee.most_common_elems::text, "
18881 " 'most_common_elem_freqs', ee.most_common_elem_freqs::text, "
18882 " 'elem_count_histogram', ee.elem_count_histogram::text");
18883
18884
18887 ", "
18888 " 'range_length_histogram', ee.range_length_histogram::text, "
18889 " 'range_empty_frac', ee.range_empty_frac::text, "
18890 " 'range_bounds_histogram', ee.range_bounds_histogram::text");
18891
18893 " )) AS j(obj)"
18894 "WHERE ee.statistics_schemaname = $1 "
18895 "AND ee.statistics_name = $2 ");
18896
18899
18901 }
18902 else
18904
18905
18908 "FROM pg_catalog.pg_stats_ext AS e "
18909 "WHERE e.statistics_schemaname = $1 "
18910 "AND e.statistics_name = $2 ");
18911 else
18913 "FROM ( "
18914 "SELECT s.stxndistinct AS n_distinct, "
18915 " s.stxdependencies AS dependencies "
18916 "FROM pg_catalog.pg_statistic_ext AS s "
18917 "JOIN pg_catalog.pg_namespace AS n "
18918 "ON n.oid = s.stxnamespace "
18919 "WHERE n.nspname = $1 "
18920 "AND s.stxname = $2 "
18921 ") AS e ");
18922
18923
18925
18927
18929
18931 }
18932
18934
18940
18942
18944
18946
18947 if (nstats > 0)
18948 {
18950
18958
18959 for (
int i = 0;
i < nstats;
i++)
18960 {
18962
18964 pg_fatal(
"inherited cannot be NULL");
18965
18967 "SELECT * FROM pg_catalog.pg_restore_extended_stats(\n");
18970
18971
18976
18977
18984
18988
18992
18996
19000
19004
19008
19010 }
19011
19016 .description = "EXTENDED STATISTICS DATA",
19018 .createStmt = out->
data,
19020 .nDeps = 1));
19022 }
19024}
19025
19026
19027
19028
19029
19030static void
19032{
19039
19040
19042 return;
19043
19046
19049
19050 if (
coninfo->contype ==
'p' ||
19053 {
19054
19056 int k;
19057
19059
19061 pg_fatal(
"missing index for constraint \"%s\"",
19063
19067
19072
19074 {
19075
19077 }
19078 else
19079 {
19081 coninfo->contype ==
'p' ?
"PRIMARY KEY" :
"UNIQUE");
19082
19083
19084
19085
19086
19087
19088
19092 for (k = 0; k <
indxinfo->indnkeyattrs; k++)
19093 {
19096
19098 break;
19100
19102 (k == 0) ? "" : ", ",
19104 }
19107
19110
19112 {
19115
19117 break;
19119
19121 (k ==
indxinfo->indnkeyattrs) ?
"" :
", ",
19123 }
19124
19126
19128 {
19132 }
19133
19135 {
19139 }
19140
19142 }
19143
19144
19145
19146
19147
19148
19149
19150
19152 {
19155
19158 }
19159
19160
19162 {
19165
19168 }
19169
19170
19172 "pg_catalog.pg_class", "INDEX",
19174
19179
19181
19185 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19186 .tablespace =
indxinfo->tablespace,
19187 .owner =
tbinfo->rolname,
19188 .description = "CONSTRAINT",
19190 .createStmt = q->
data,
19191 .dropStmt =
delq->data));
19192 }
19193 else if (
coninfo->contype ==
'f')
19194 {
19196
19197
19198
19199
19200
19201
19202
19204
19205
19206
19207
19208
19214
19219
19221
19225 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19226 .owner =
tbinfo->rolname,
19227 .description = "FK CONSTRAINT",
19229 .createStmt = q->
data,
19230 .dropStmt =
delq->data));
19231 }
19233 {
19234
19235
19236
19238 {
19239 const char *keyword;
19240
19242 keyword = "CHECK CONSTRAINT";
19243 else
19244 keyword = "CONSTRAINT";
19245
19246
19252
19257
19259
19263 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19264 .owner =
tbinfo->rolname,
19265 .description = keyword,
19267 .createStmt = q->
data,
19268 .dropStmt =
delq->data));
19269 }
19270 }
19272 {
19273
19275
19277
19278
19280 {
19281 const char *keyword;
19282
19284 keyword = "CHECK CONSTRAINT";
19285 else
19286 keyword = "CONSTRAINT";
19287
19293
19298
19300
19304 .
namespace =
tyinfo->dobj.namespace->dobj.name,
19305 .owner =
tyinfo->rolname,
19306 .description = keyword,
19308 .createStmt = q->
data,
19309 .dropStmt =
delq->data));
19310
19312 {
19315
19318
19320 tyinfo->dobj.namespace->dobj.name,
19325 }
19326 }
19327 }
19328 else
19329 {
19330 pg_fatal(
"unrecognized constraint type: %c",
19332 }
19333
19334
19338
19342}
19343
19344
19345
19346
19347
19348
19349
19350
19351static void
19353{
19357
19359
19362
19365 tbinfo->dobj.namespace->dobj.name,
19369
19372}
19373
19376{
19378 {
19381 }
19382
19385}
19386
19387
19388
19389
19390static int
19392{
19395
19397}
19398
19399
19400
19401
19402
19403
19404
19405static void
19407{
19409 const char *query;
19410
19411
19412
19413
19414
19415
19416
19417
19418
19420 return;
19423 query = "SELECT seqrelid, format_type(seqtypid, NULL), "
19424 "seqstart, seqincrement, "
19425 "seqmax, seqmin, "
19426 "seqcache, seqcycle, "
19427 "NULL, 'f' "
19428 "FROM pg_catalog.pg_sequence "
19429 "ORDER BY seqrelid";
19430 else
19431 query = "SELECT seqrelid, format_type(seqtypid, NULL), "
19432 "seqstart, seqincrement, "
19433 "seqmax, seqmin, "
19434 "seqcache, seqcycle, "
19435 "last_value, is_called "
19436 "FROM pg_catalog.pg_sequence, "
19437 "pg_get_sequence_data(seqrelid) "
19438 "ORDER BY seqrelid;";
19439
19441
19444
19446 {
19458 }
19459
19461}
19462
19463
19464
19465
19466
19467static void
19469{
19479
19481
19482
19483
19484
19485
19486
19488 {
19490
19492
19496 }
19497 else
19498 {
19500
19501
19502
19503
19504
19505
19506
19508 "SELECT 'bigint' AS sequence_type, "
19509 "start_value, increment_by, max_value, min_value, "
19510 "cache_value, is_cycled FROM %s",
19512
19514
19516 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19517 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19520
19529
19531 }
19532
19533
19536 {
19539 }
19541 {
19544 }
19546 {
19549 }
19550 else
19551 {
19552 pg_fatal(
"unrecognized sequence type: %d",
seq->seqtype);
19554 }
19555
19556
19557
19558
19559 if (!
tbinfo->is_identity_sequence)
19560 {
19563 }
19564
19566
19568 {
19570 tbinfo->dobj.catId.oid);
19571
19572
19573
19574
19575
19576 }
19577
19578 if (
tbinfo->is_identity_sequence)
19579 {
19581
19583 "ALTER TABLE %s ",
19586 "ALTER COLUMN %s ADD GENERATED ",
19594
19595
19596
19597
19598
19602 "UNLOGGED" : "LOGGED");
19603 }
19604 else
19605 {
19607 "CREATE %sSEQUENCE %s\n",
19609 "UNLOGGED " : "",
19611
19614 }
19615
19617
19619
19622 else
19624
19627 else
19629
19632 seq->cache, (
seq->cycled ?
"\n CYCLE" :
""));
19633
19634 if (
tbinfo->is_identity_sequence)
19636 else
19638
19639
19640
19644 tbinfo->dobj.namespace->dobj.name);
19645
19649 .namespace =
tbinfo->dobj.namespace->dobj.name,
19650 .owner =
tbinfo->rolname,
19651 .description = "SEQUENCE",
19653 .createStmt = query->
data,
19654 .dropStmt =
delqry->data));
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19669 {
19671
19672 if (owning_tab ==
NULL)
19673 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
19675
19677 {
19685
19689 .namespace =
tbinfo->dobj.namespace->dobj.name,
19690 .owner =
tbinfo->rolname,
19691 .description = "SEQUENCE OWNED BY",
19693 .createStmt = query->
data,
19694 .deps = &(
tbinfo->dobj.dumpId),
19695 .nDeps = 1));
19696 }
19697 }
19698
19699
19704
19709
19715}
19716
19717
19718
19719
19720
19721static void
19723{
19728
19729
19731 return;
19732
19734
19735
19736
19737
19738
19739
19740
19741
19742
19744 {
19746
19748 "SELECT last_value, is_called FROM %s",
19750
19752
19754 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19755 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19758
19761
19763 }
19764 else
19765 {
19768
19771
19775
19777 pg_fatal(
"failed to get data for sequence \"%s\"; user may lack "
19778 "SELECT privilege on the sequence or the sequence may "
19779 "have been concurrently dropped",
19781
19784 }
19785
19790 last, (
called ?
"true" :
"false"));
19791
19795 .namespace =
tbinfo->dobj.namespace->dobj.name,
19796 .owner =
tbinfo->rolname,
19797 .description = "SEQUENCE SET",
19799 .createStmt = query->
data,
19800 .deps = &(
tbinfo->dobj.dumpId),
19801 .nDeps = 1));
19802
19804}
19805
19806
19807
19808
19809
19810static void
19812{
19820 char *tag;
19821
19822
19824 return;
19825
19830
19832
19835
19838
19839
19841 "pg_catalog.pg_trigger", "TRIGGER",
19843
19844 if (
tginfo->tgispartition)
19845 {
19847
19848
19849
19850
19851
19852
19853
19859 switch (
tginfo->tgenabled)
19860 {
19861 case 'f':
19862 case 'D':
19864 break;
19865 case 't':
19866 case 'O':
19868 break;
19869 case 'R':
19871 break;
19872 case 'A':
19874 break;
19875 }
19878 }
19879 else if (
tginfo->tgenabled !=
't' &&
tginfo->tgenabled !=
'O')
19880 {
19884 switch (
tginfo->tgenabled)
19885 {
19886 case 'D':
19887 case 'f':
19889 break;
19890 case 'A':
19892 break;
19893 case 'R':
19895 break;
19896 default:
19898 break;
19899 }
19902 }
19903
19906
19908
19912 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19913 .owner =
tbinfo->rolname,
19914 .description = "TRIGGER",
19916 .createStmt = query->
data,
19917 .dropStmt =
delqry->data));
19918
19923
19930}
19931
19932
19933
19934
19935
19936static void
19938{
19943
19944
19946 return;
19947
19950
19952
19957
19959 {
19963 }
19964
19968
19969 if (
evtinfo->evtenabled !=
'O')
19970 {
19974 {
19975 case 'D':
19977 break;
19978 case 'A':
19980 break;
19981 case 'R':
19983 break;
19984 default:
19986 break;
19987 }
19989 }
19990
19993
19997
20002 .description = "EVENT TRIGGER",
20004 .createStmt = query->
data,
20005 .dropStmt =
delqry->data));
20006
20011
20016
20020}
20021
20022
20023
20024
20025
20026static void
20028{
20038 char *tag;
20039
20040
20042 return;
20043
20044
20045
20046
20047
20049 return;
20050
20051
20052
20053
20054
20056
20061
20063
20065 {
20067
20068
20069
20070
20071
20075 {
20079 }
20087 }
20088 else
20089 {
20090
20092 "SELECT pg_catalog.pg_get_ruledef('%u'::pg_catalog.oid)",
20094
20096
20098 pg_fatal(
"query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
20100
20102
20104 }
20105
20106
20107
20108
20109
20111 {
20114 {
20115 case 'A':
20118 break;
20119 case 'R':
20122 break;
20123 case 'D':
20126 break;
20127 }
20128 }
20129
20131 {
20132
20133
20134
20135
20136
20138
20144 }
20145 else
20146 {
20151 }
20152
20155
20157
20161 .
namespace =
tbinfo->dobj.namespace->dobj.name,
20162 .owner =
tbinfo->rolname,
20163 .description = "RULE",
20165 .createStmt = cmd->
data,
20166 .dropStmt =
delcmd->data));
20167
20168
20171 tbinfo->dobj.namespace->dobj.name,
20174
20181}
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193void
20196{
20199 int ntups,
20205
20206
20208 return;
20209
20211
20212
20214 "classid, objid, refobjid "
20215 "FROM pg_depend "
20216 "WHERE refclassid = 'pg_extension'::regclass "
20217 "AND deptype = 'e' "
20218 "ORDER BY 3");
20219
20221
20223
20227
20228
20229
20230
20231
20232
20234
20235 for (
i = 0;
i < ntups;
i++)
20236 {
20239
20243
20247
20249 {
20250
20252 continue;
20253 }
20254
20256 }
20257
20259
20261}
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286void
20289{
20293 int ntups,
20297
20298
20300 return;
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20314 {
20317 char *extcondition =
curext->extcondition;
20322
20323
20324
20325
20326
20329 curext->dobj.catId.oid))
20330 continue;
20331
20332
20333
20334
20335
20338 curext->dobj.catId.oid))
20339 continue;
20340
20341 if (
strlen(extconfig) != 0 ||
strlen(extcondition) != 0)
20342 {
20344
20346 pg_fatal(
"could not parse %s array",
"extconfig");
20348 pg_fatal(
"could not parse %s array",
"extcondition");
20350 pg_fatal(
"mismatched number of configurations and conditions for extension");
20351
20353 {
20358
20361 continue;
20362
20363
20364
20365
20366
20368 {
20369
20374
20375
20376 if (
configtbl->dobj.namespace->dobj.dump &
20379 }
20380
20381
20386
20387
20389 configtbl->dobj.namespace->dobj.catId.oid))
20391
20393 {
20396 {
20399 }
20400 }
20401 }
20402 }
20407 }
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20419
20421 "SELECT conrelid, confrelid "
20422 "FROM pg_constraint "
20423 "JOIN pg_depend ON (objid = confrelid) "
20424 "WHERE contype = 'f' "
20425 "AND refclassid = 'pg_extension'::regclass "
20426 "AND classid = 'pg_class'::regclass;");
20427
20430
20433
20434
20435 for (
i = 0;
i < ntups;
i++)
20436 {
20438 confrelid;
20440 *contable;
20441
20446
20449 contable ==
NULL ||
20451 continue;
20452
20453
20454
20455
20456
20459 }
20462}
20463
20464
20465
20466
20467static void
20469{
20472 int ntups,
20481
20483
20485
20486
20487
20488
20489
20490
20491
20492
20493
20495 "classid, objid, refclassid, refobjid, deptype "
20496 "FROM pg_depend "
20497 "WHERE deptype != 'p' AND deptype != 'e'\n");
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20510 "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
20511 "FROM pg_depend d, pg_amop o "
20512 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20513 "classid = 'pg_amop'::regclass AND objid = o.oid "
20514 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
20515
20516
20518 "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
20519 "FROM pg_depend d, pg_amproc p "
20520 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20521 "classid = 'pg_amproc'::regclass AND objid = p.oid "
20522 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
20523
20524
20525
20526
20527
20530 "SELECT 'pg_class'::regclass AS classid, pgepgid AS objid, refclassid, refobjid, deptype "
20531 "FROM pg_depend d, pg_propgraph_element pge "
20532 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20533 "classid = 'pg_propgraph_element'::regclass AND objid = pge.oid\n");
20534
20535
20537
20539
20541
20547
20548
20549
20550
20551
20552
20554
20555 for (
i = 0;
i < ntups;
i++)
20556 {
20559 char deptype;
20560
20566
20567 if (dobj ==
NULL ||
20571
20572
20573
20574
20575
20577 {
20578#ifdef NOT_USED
20581#endif
20582 continue;
20583 }
20584
20586
20588 {
20589#ifdef NOT_USED
20592#endif
20593 continue;
20594 }
20595
20596
20597
20598
20599
20600
20601
20602 if (deptype == 'x')
20604
20605
20606
20607
20608
20609
20610
20611
20612 if (deptype == 'i' &&
20616 else
20617
20619 }
20620
20622
20624}
20625
20626
20627
20628
20629
20630
20633{
20635
20637
20642
20647
20649}
20650
20651
20652
20653
20654
20655static void
20658{
20662
20664 {
20666
20667
20668
20669
20670
20672 {
20698
20700 break;
20705
20708 break;
20722
20724 break;
20726
20727 if (((
RuleInfo *) dobj)->separate)
20729 break;
20732
20735 break;
20737
20738 break;
20740
20742 break;
20744
20746 {
20749 }
20750 else
20752 break;
20753 }
20754 }
20755}
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781static void
20783{
20786
20787
20789 {
20792 int nDeps;
20793 int allocDeps;
20794
20795
20797 continue;
20798
20800 continue;
20801
20804 continue;
20805
20806 if (dobj->
nDeps <= 0)
20807 continue;
20808
20809 allocDeps = 64;
20811 nDeps = 0;
20812
20814 &dependencies, &nDeps, &allocDeps);
20815
20816 if (nDeps > 0)
20817 {
20821 }
20822 else
20823 free(dependencies);
20824 }
20825}
20826
20827
20828static void
20830 DumpId **dependencies,
int *nDeps,
int *allocDeps)
20831{
20833
20834
20835
20836
20837
20840 return;
20841
20843 {
20845
20847 {
20848
20849 if (*nDeps >= *allocDeps)
20850 {
20851 *allocDeps *= 2;
20853 }
20854 (*dependencies)[*nDeps] =
depid;
20855 (*nDeps)++;
20856 }
20857 else
20858 {
20859
20860
20861
20862
20863
20865
20868 dependencies, nDeps, allocDeps);
20869 }
20870 }
20871}
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883static const char *
20885{
20890
20891 if (oid == 0)
20892 {
20894 return "*";
20896 return "NONE";
20897 }
20898
20899
20903
20905 appendPQExpBuffer(query,
"SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
20906 oid);
20907
20909
20910
20912
20915
20916
20917
20918
20919
20920
20921
20924
20926}
20927
20928
20929
20930
20931
20932
20933
20934static const char *
20936{
20937 int numatts =
ti->numatts;
20938 char **attnames =
ti->attnames;
20939 bool *attisdropped =
ti->attisdropped;
20940 char *attgenerated =
ti->attgenerated;
20943
20946 for (
i = 0;
i < numatts;
i++)
20947 {
20948 if (attisdropped[
i])
20949 continue;
20950 if (attgenerated[
i])
20951 continue;
20956 }
20957
20959 return "";
20960
20962 return buffer->
data;
20963}
20964
20965
20966
20967
20968static bool
20970{
20971
20972 return (reloptions !=
NULL &&
strlen(reloptions) > 2);
20973}
20974
20975
20976
20977
20978
20979
20980static void
20983{
20984 bool res;
20985
20988 if (!res)
20990}
20991
20992
20993
20994
20995
20996
20997
20998
20999static void
21001{
21003 char *objname;
21006
21008
21010 {
21012 {
21013 switch (objtype)
21014 {
21016 break;
21024 "include",
21027 break;
21028
21031 break;
21034 break;
21038 break;
21042 break;
21045 objname);
21047 break;
21048 }
21049 }
21051 {
21052 switch (objtype)
21053 {
21055 break;
21062 "exclude",
21065 break;
21066
21069 break;
21072 objname);
21073 break;
21076 objname);
21077 break;
21080 break;
21083 break;
21086 objname);
21087 break;
21088 }
21089 }
21090 else
21091 {
21094 }
21095
21096 if (objname)
21098 }
21099
21101}
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)
DumpId createDumpId(void)
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)
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)
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 RestoreArchive(Archive *AHX, bool append_data)
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 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)