44#include "catalog/pg_aggregate_d.h"
45#include "catalog/pg_am_d.h"
46#include "catalog/pg_attribute_d.h"
47#include "catalog/pg_authid_d.h"
48#include "catalog/pg_cast_d.h"
49#include "catalog/pg_class_d.h"
50#include "catalog/pg_constraint_d.h"
51#include "catalog/pg_default_acl_d.h"
52#include "catalog/pg_largeobject_d.h"
53#include "catalog/pg_largeobject_metadata_d.h"
54#include "catalog/pg_proc_d.h"
55#include "catalog/pg_publication_d.h"
56#include "catalog/pg_shdepend_d.h"
57#include "catalog/pg_subscription_d.h"
58#include "catalog/pg_type_d.h"
127 "array length mismatch");
218#define MAX_ATTR_STATS_RELS 64
224#define DUMP_DEFAULT_ROWS_PER_INSERT 1
231#define MAX_BLOBS_PER_ARCHIVE_ENTRY 1000
236#define fmtQualifiedDumpable(obj) \
237 fmtQualifiedId((obj)->dobj.namespace->dobj.name, \
262 const char *pattern);
271 const char *
name,
const char *
namespace,
276 const char *
name,
const char *
namespace,
278 int subid,
DumpId dumpId);
282 const char *
namespace,
const char *owner,
333 const char *servername,
const char *
namespace,
339 const char *nspname,
const char *tag,
const char *owner,
345 DumpId **dependencies,
int *nDeps,
int *allocDeps);
435 char *use_role =
NULL;
469 {
"jobs", 1,
NULL,
'j'},
556 if (
strcmp(argv[1],
"--help") == 0 ||
strcmp(argv[1],
"-?") == 0)
561 if (
strcmp(argv[1],
"--version") == 0 ||
strcmp(argv[1],
"-V") == 0)
570 while ((
c =
getopt_long(argc, argv,
"abBcCd:e:E:f:F:h:j:n:N:Op:RsS:t:T:U:vwWxXZ:",
819 pg_log_error(
"too many command-line arguments (first is \"%s\")",
831 pg_fatal(
"options %s and %s cannot be used together",
832 "-s/--schema-only",
"-a/--data-only");
834 pg_fatal(
"options %s and %s cannot be used together",
835 "-s/--schema-only",
"--statistics-only");
837 pg_fatal(
"options %s and %s cannot be used together",
838 "-a/--data-only",
"--statistics-only");
842 pg_fatal(
"options %s and %s cannot be used together",
843 "-a/--data-only",
"--no-data");
845 pg_fatal(
"options %s and %s cannot be used together",
846 "-s/--schema-only",
"--no-schema");
848 pg_fatal(
"options %s and %s cannot be used together",
849 "--statistics-only",
"--no-statistics");
853 pg_fatal(
"options %s and %s cannot be used together",
854 "--statistics",
"--no-statistics");
858 pg_fatal(
"options %s and %s cannot be used together",
859 "-a/--data-only",
"--statistics");
861 pg_fatal(
"options %s and %s cannot be used together",
862 "-s/--schema-only",
"--statistics");
865 pg_fatal(
"options %s and %s cannot be used together",
866 "-s/--schema-only",
"--include-foreign-data");
869 pg_fatal(
"option %s is not supported with parallel backup",
870 "--include-foreign-data");
873 pg_fatal(
"options %s and %s cannot be used together",
874 "-c/--clean",
"-a/--data-only");
877 pg_fatal(
"option %s requires option %s",
878 "--if-exists",
"-c/--clean");
898 pg_fatal(
"option %s requires option %s, %s, or %s",
899 "--on-conflict-do-nothing",
900 "--inserts",
"--rows-per-insert",
"--column-inserts");
916 pg_fatal(
"could not generate restrict key");
921 pg_fatal(
"option %s can only be used with %s",
922 "--restrict-key",
"--format=plain");
944 pg_fatal(
"unrecognized compression algorithm: \"%s\"",
951 pg_fatal(
"invalid compression specification: %s",
964 pg_log_warning(
"compression option \"%s\" is not currently supported by pg_dump",
976 pg_fatal(
"parallel backup only supported by the directory format");
1031 pg_fatal(
"no matching schemas were found");
1048 pg_fatal(
"no matching tables were found");
1076 pg_fatal(
"no matching extensions were found");
1133 shdepend->dataObj->filtercond =
"WHERE classid = 'pg_largeobject'::regclass "
1134 "AND dbid = (SELECT oid FROM pg_database "
1135 " WHERE datname = current_database())";
1306 printf(
_(
"%s exports a PostgreSQL database as an SQL script or to other formats.\n\n"),
progname);
1310 printf(
_(
"\nGeneral options:\n"));
1311 printf(
_(
" -f, --file=FILENAME output file or directory name\n"));
1312 printf(
_(
" -F, --format=c|d|t|p output file format (custom, directory, tar,\n"
1313 " plain text (default))\n"));
1314 printf(
_(
" -j, --jobs=NUM use this many parallel jobs to dump\n"));
1315 printf(
_(
" -v, --verbose verbose mode\n"));
1316 printf(
_(
" -V, --version output version information, then exit\n"));
1317 printf(
_(
" -Z, --compress=METHOD[:DETAIL]\n"
1318 " compress as specified\n"));
1319 printf(
_(
" --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock\n"));
1320 printf(
_(
" --no-sync do not wait for changes to be written safely to disk\n"));
1321 printf(
_(
" --sync-method=METHOD set method for syncing files to disk\n"));
1322 printf(
_(
" -?, --help show this help, then exit\n"));
1324 printf(
_(
"\nOptions controlling the output content:\n"));
1325 printf(
_(
" -a, --data-only dump only the data, not the schema or statistics\n"));
1326 printf(
_(
" -b, --large-objects include large objects in dump\n"));
1327 printf(
_(
" --blobs (same as --large-objects, deprecated)\n"));
1328 printf(
_(
" -B, --no-large-objects exclude large objects in dump\n"));
1329 printf(
_(
" --no-blobs (same as --no-large-objects, deprecated)\n"));
1330 printf(
_(
" -c, --clean clean (drop) database objects before recreating\n"));
1331 printf(
_(
" -C, --create include commands to create database in dump\n"));
1332 printf(
_(
" -e, --extension=PATTERN dump the specified extension(s) only\n"));
1333 printf(
_(
" -E, --encoding=ENCODING dump the data in encoding ENCODING\n"));
1334 printf(
_(
" -n, --schema=PATTERN dump the specified schema(s) only\n"));
1335 printf(
_(
" -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
1336 printf(
_(
" -O, --no-owner skip restoration of object ownership in\n"
1337 " plain-text format\n"));
1338 printf(
_(
" -s, --schema-only dump only the schema, no data or statistics\n"));
1339 printf(
_(
" -S, --superuser=NAME superuser user name to use in plain-text format\n"));
1340 printf(
_(
" -t, --table=PATTERN dump only the specified table(s)\n"));
1341 printf(
_(
" -T, --exclude-table=PATTERN do NOT dump the specified table(s)\n"));
1342 printf(
_(
" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
1343 printf(
_(
" --binary-upgrade for use by upgrade utilities only\n"));
1344 printf(
_(
" --column-inserts dump data as INSERT commands with column names\n"));
1345 printf(
_(
" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
1346 printf(
_(
" --disable-triggers disable triggers during data-only restore\n"));
1347 printf(
_(
" --enable-row-security enable row security (dump only content user has\n"
1349 printf(
_(
" --exclude-extension=PATTERN do NOT dump the specified extension(s)\n"));
1350 printf(
_(
" --exclude-table-and-children=PATTERN\n"
1351 " do NOT dump the specified table(s), including\n"
1352 " child and partition tables\n"));
1353 printf(
_(
" --exclude-table-data=PATTERN do NOT dump data for the specified table(s)\n"));
1354 printf(
_(
" --exclude-table-data-and-children=PATTERN\n"
1355 " do NOT dump data for the specified table(s),\n"
1356 " including child and partition tables\n"));
1357 printf(
_(
" --extra-float-digits=NUM override default setting for extra_float_digits\n"));
1358 printf(
_(
" --filter=FILENAME include or exclude objects and data from dump\n"
1359 " based on expressions in FILENAME\n"));
1360 printf(
_(
" --if-exists use IF EXISTS when dropping objects\n"));
1361 printf(
_(
" --include-foreign-data=PATTERN\n"
1362 " include data of foreign tables on foreign\n"
1363 " servers matching PATTERN\n"));
1364 printf(
_(
" --inserts dump data as INSERT commands, rather than COPY\n"));
1365 printf(
_(
" --load-via-partition-root load partitions via the root table\n"));
1366 printf(
_(
" --no-comments do not dump comment commands\n"));
1367 printf(
_(
" --no-data do not dump data\n"));
1368 printf(
_(
" --no-policies do not dump row security policies\n"));
1369 printf(
_(
" --no-publications do not dump publications\n"));
1370 printf(
_(
" --no-schema do not dump schema\n"));
1371 printf(
_(
" --no-security-labels do not dump security label assignments\n"));
1372 printf(
_(
" --no-statistics do not dump statistics\n"));
1373 printf(
_(
" --no-subscriptions do not dump subscriptions\n"));
1374 printf(
_(
" --no-table-access-method do not dump table access methods\n"));
1375 printf(
_(
" --no-tablespaces do not dump tablespace assignments\n"));
1376 printf(
_(
" --no-toast-compression do not dump TOAST compression methods\n"));
1377 printf(
_(
" --no-unlogged-table-data do not dump unlogged table data\n"));
1378 printf(
_(
" --on-conflict-do-nothing add ON CONFLICT DO NOTHING to INSERT commands\n"));
1379 printf(
_(
" --quote-all-identifiers quote all identifiers, even if not key words\n"));
1380 printf(
_(
" --restrict-key=RESTRICT_KEY use provided string as psql \\restrict key\n"));
1381 printf(
_(
" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
1382 printf(
_(
" --section=SECTION dump named section (pre-data, data, or post-data)\n"));
1383 printf(
_(
" --sequence-data include sequence data in dump\n"));
1384 printf(
_(
" --serializable-deferrable wait until the dump can run without anomalies\n"));
1385 printf(
_(
" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
1386 printf(
_(
" --statistics dump the statistics\n"));
1387 printf(
_(
" --statistics-only dump only the statistics, not schema or data\n"));
1388 printf(
_(
" --strict-names require table and/or schema include patterns to\n"
1389 " match at least one entity each\n"));
1390 printf(
_(
" --table-and-children=PATTERN dump only the specified table(s), including\n"
1391 " child and partition tables\n"));
1392 printf(
_(
" --use-set-session-authorization\n"
1393 " use SET SESSION AUTHORIZATION commands instead of\n"
1394 " ALTER OWNER commands to set ownership\n"));
1396 printf(
_(
"\nConnection options:\n"));
1397 printf(
_(
" -d, --dbname=DBNAME database to dump\n"));
1398 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
1399 printf(
_(
" -p, --port=PORT database server port number\n"));
1400 printf(
_(
" -U, --username=NAME connect as specified database user\n"));
1401 printf(
_(
" -w, --no-password never prompt for password\n"));
1402 printf(
_(
" -W, --password force password prompt (should happen automatically)\n"));
1403 printf(
_(
" --role=ROLENAME do SET ROLE before dump\n"));
1405 printf(
_(
"\nIf no database name is supplied, then the PGDATABASE environment\n"
1406 "variable value is used.\n\n"));
1426 pg_fatal(
"invalid client encoding \"%s\" specified",
1559 "SET TRANSACTION ISOLATION LEVEL "
1560 "SERIALIZABLE, READ ONLY, DEFERRABLE");
1563 "SET TRANSACTION ISOLATION LEVEL "
1564 "REPEATABLE READ, READ ONLY");
1586 pg_fatal(
"parallel dumps from standby servers are not supported by this server version");
1610 char *query =
"SELECT pg_catalog.pg_export_snapshot()";
1686 "SELECT oid FROM pg_catalog.pg_namespace n\n");
1692 pg_fatal(
"improper qualified name (too many dotted names): %s",
1700 pg_fatal(
"no matching schemas were found for pattern \"%s\"", cell->
val);
1743 "SELECT oid FROM pg_catalog.pg_extension e\n");
1748 pg_fatal(
"improper qualified name (too many dotted names): %s",
1753 pg_fatal(
"no matching extensions were found for pattern \"%s\"", cell->
val);
1796 "SELECT oid FROM pg_catalog.pg_foreign_server s\n");
1801 pg_fatal(
"improper qualified name (too many dotted names): %s",
1806 pg_fatal(
"no matching foreign servers were found for pattern \"%s\"", cell->
val);
1863 "\nFROM pg_catalog.pg_class c"
1864 "\n LEFT JOIN pg_catalog.pg_namespace n"
1865 "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace"
1866 "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY"
1867 "\n (array['%c', '%c', '%c', '%c', '%c', '%c'])\n",
1873 false,
"n.nspname",
"c.relname",
NULL,
1874 "pg_catalog.pg_table_is_visible(c.oid)", &
dbbuf,
1877 pg_fatal(
"improper relation name (too many dotted names): %s",
1886 "\nSELECT i.inhrelid"
1887 "\nFROM partition_tree p"
1888 "\n JOIN pg_catalog.pg_inherits i"
1889 "\n ON p.relid OPERATOR(pg_catalog.=) i.inhparent"
1891 "\nSELECT relid FROM partition_tree");
1899 pg_fatal(
"no matching tables were found for pattern \"%s\"", cell->
val);
1926 pg_fatal(
"You are currently not connected to a database.");
1929 pg_fatal(
"cross-database references are not implemented: %s",
2014 nsinfo->dobj.catId.oid) ?
2061 if (
nsinfo->dobj.dump_contains &&
2092 tbinfo->dobj.catId.oid) ?
2095 tbinfo->dobj.dump =
tbinfo->dobj.namespace->dobj.dump_contains;
2153 tyinfo->dobj.dump =
tyinfo->dobj.namespace->dobj.dump_contains;
2169 if (
dinfo->dobj.namespace)
2171 dinfo->dobj.dump =
dinfo->dobj.namespace->dobj.dump_contains;
2342 sobj->dobj.dump =
sobj->dobj.namespace->dobj.dump_contains;
2364 if (dobj->namespace)
2395 pg_log_info(
"dumping contents of table \"%s.%s\"",
2396 tbinfo->dobj.namespace->dobj.name, classname);
2508 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetCopyData() failed.", classname);
2518 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetResult() failed.", classname);
2527 pg_log_warning(
"unexpected extra results during COPY of table \"%s\"",
2588 attgenerated[nfields] =
tbinfo->attgenerated[
i];
2609 pg_fatal(
"wrong number of fields retrieved from table \"%s\"",
2630 if (
tbinfo->ispartition &&
2651 for (
int field = 0; field < nfields; field++)
2661 if (
tbinfo->needs_override)
2668 for (
int tuple = 0; tuple <
PQntuples(res); tuple++)
2694 for (
int field = 0; field < nfields; field++)
2698 if (attgenerated[field])
2731 const char *s =
PQgetvalue(res, tuple, field);
2890 if (
tbinfo->ispartition &&
2937 .namespace =
tbinfo->dobj.namespace->dobj.name,
2938 .owner =
tbinfo->rolname,
2939 .description =
"TABLE DATA",
2942 .copyStmt = copyStmt,
2943 .deps = &(
tbinfo->dobj.dumpId),
2991 if (!
tbinfo->relispopulated)
3004 .namespace =
tbinfo->dobj.namespace->dobj.name,
3005 .owner =
tbinfo->rolname,
3006 .description =
"MATERIALIZED VIEW DATA",
3008 .createStmt = q->
data,
3009 .deps =
tdinfo->dobj.dependencies,
3010 .nDeps =
tdinfo->dobj.nDeps));
3027 (!relkind || tblinfo[
i].
relkind == relkind))
3057 tbinfo->foreign_server)))
3087 tdinfo->dobj.catId.tableoid = 0;
3115 tbinfo->interesting =
true;
3144 "SELECT d1.objid, d2.refobjid, c2.relkind AS refrelkind "
3145 "FROM pg_depend d1 "
3146 "JOIN pg_class c1 ON c1.oid = d1.objid "
3148 " JOIN pg_rewrite r1 ON r1.ev_class = d1.objid "
3149 "JOIN pg_depend d2 ON d2.classid = 'pg_rewrite'::regclass "
3150 "AND d2.objid = r1.oid "
3151 "AND d2.refobjid <> d1.objid "
3152 "JOIN pg_class c2 ON c2.oid = d2.refobjid "
3155 "WHERE d1.classid = 'pg_class'::regclass "
3157 "SELECT w.objid, d3.refobjid, c3.relkind "
3159 "JOIN pg_rewrite r3 ON r3.ev_class = w.refobjid "
3160 "JOIN pg_depend d3 ON d3.classid = 'pg_rewrite'::regclass "
3161 "AND d3.objid = r3.oid "
3162 "AND d3.refobjid <> w.refobjid "
3163 "JOIN pg_class c3 ON c3.oid = d3.refobjid "
3167 "SELECT 'pg_class'::regclass::oid AS classid, objid, refobjid "
3179 for (
i = 0;
i < ntups;
i++)
3220 tbinfo->relispopulated =
false;
3270 ftable->dataObj->dobj.dumpId);
3334 "pg_encoding_to_char(encoding) AS encoding, "
3335 "datcollate, datctype, datfrozenxid, "
3336 "datacl, acldefault('d', datdba) AS acldefault, "
3337 "datistemplate, datconnlimit, ");
3353 "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
3354 "shobj_description(oid, 'pg_database') AS description "
3356 "WHERE datname = current_database()");
3419 "CREATE DATABASE %s WITH TEMPLATE = template0 "
3420 "OID = %u STRATEGY = FILE_COPY",
3442 pg_fatal(
"unrecognized locale provider: %s",
3445 if (
strlen(collate) > 0 &&
strcmp(collate, ctype) == 0)
3521 .dropStmt =
delQry->data));
3550 .description =
"COMMENT",
3552 .createStmt =
dbQry->data,
3574 .description =
"SECURITY LABEL",
3622 "SET datistemplate = false WHERE datname = ");
3643 "SET datfrozenxid = '%u', datminmxid = '%u'\n"
3645 frozenxid, minmxid);
3657 .dropStmt =
delQry->data,
3685 "FROM pg_catalog.pg_class\n"
3686 "WHERE oid IN (%u, %u, %u, %u);\n",
3691 "FROM pg_catalog.pg_class\n"
3692 "WHERE oid IN (%u, %u);\n",
3729 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
3730 "WHERE oid = %u;\n",
3738 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
3743 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
3748 "TRUNCATE pg_catalog.pg_largeobject;\n");
3750 "TRUNCATE pg_catalog.pg_largeobject_metadata;\n");
3800 "WHERE setrole = 0 AND setdatabase = '%u'::oid",
3814 "FROM pg_db_role_setting s, pg_roles r "
3815 "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
3850 .createStmt = qry->
data));
3865 pg_log_info(
"saving \"standard_conforming_strings = %s\"",
3875 .createStmt = qry->
data));
3901 "SELECT pg_catalog.current_schemas(false)");
3904 pg_fatal(
"could not parse result of current_schemas()");
3929 .createStmt = qry->
data));
3966 "SELECT oid, lomowner, lomacl, "
3967 "acldefault('L', lomowner) AS acldefault "
3968 "FROM pg_largeobject_metadata ");
3980 "(SELECT objoid FROM pg_description "
3982 "UNION SELECT objoid FROM pg_seclabel "
3986 "ORDER BY lomowner, lomacl::pg_catalog.text, oid");
4005 for (
i = 0;
i < ntups;
i += n)
4040 loinfo->dacl.privtype = 0;
4046 for (
int k = 1; k < n; k++)
4108 for (
int i = 0;
i <
loinfo->numlos;
i++)
4114 .owner =
loinfo->rolname,
4115 .description =
"BLOB METADATA",
4117 .createStmt =
cquery->data,
4118 .dropStmt =
"-- dummy"));
4127 for (
int i = 0;
i <
loinfo->numlos;
i++)
4140 catId, 0,
loinfo->dobj.dumpId);
4145 catId, 0,
loinfo->dobj.dumpId);
4198 for (
int i = 0;
i <
loinfo->numlos;
i++)
4207 pg_fatal(
"could not open large object %u: %s",
4217 pg_fatal(
"error reading large object %u: %s",
4303 polinfo->dobj.catId.tableoid = 0;
4325 pg_log_info(
"reading row-level security policies");
4328 "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
4334 "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
4335 " 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, "
4336 "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
4337 "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
4338 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
4339 "JOIN pg_catalog.pg_policy pol ON (src.tbloid = pol.polrelid)",
4359 for (
j = 0;
j < ntups;
j++)
4443 .namespace =
polinfo->dobj.namespace->dobj.name,
4444 .owner =
tbinfo->rolname,
4445 .description =
"ROW SECURITY",
4447 .createStmt = query->
data,
4448 .deps = &(
tbinfo->dobj.dumpId),
4457 else if (
polinfo->polcmd ==
'r')
4458 cmd =
" FOR SELECT";
4459 else if (
polinfo->polcmd ==
'a')
4460 cmd =
" FOR INSERT";
4461 else if (
polinfo->polcmd ==
'w')
4462 cmd =
" FOR UPDATE";
4463 else if (
polinfo->polcmd ==
'd')
4464 cmd =
" FOR DELETE";
4466 pg_fatal(
"unexpected policy command type: %c",
4478 !
polinfo->polpermissive ?
" AS RESTRICTIVE" :
"", cmd);
4502 .
namespace =
polinfo->dobj.namespace->dobj.name,
4503 .owner =
tbinfo->rolname,
4504 .description =
"POLICY",
4506 .createStmt = query->
data,
4507 .dropStmt =
delqry->data));
4554 "p.pubowner, p.puballtables, p.pubinsert, "
4555 "p.pubupdate, p.pubdelete, ");
4601 for (
i = 0;
i < ntups;
i++)
4667 else if (
pubinfo->puballtables)
4669 else if (
pubinfo->puballsequences)
4720 .description =
"PUBLICATION",
4722 .createStmt = query->
data,
4723 .dropStmt =
delq->data));
4766 "SELECT tableoid, oid, pnpubid, pnnspid "
4767 "FROM pg_catalog.pg_publication_namespace");
4781 for (
i = 0;
i < ntups;
i++)
4849 "SELECT tableoid, oid, prpubid, prrelid, "
4850 "pg_catalog.pg_get_expr(prqual, prrelid) AS prrelqual, "
4852 " WHEN pr.prattrs IS NOT NULL THEN\n"
4853 " (SELECT array_agg(attname)\n"
4855 " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
4856 " pg_catalog.pg_attribute\n"
4857 " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
4858 " ELSE NULL END) prattrs "
4859 "FROM pg_catalog.pg_publication_rel pr");
4862 "SELECT tableoid, oid, prpubid, prrelid, "
4863 "NULL AS prrelqual, NULL AS prattrs "
4864 "FROM pg_catalog.pg_publication_rel");
4880 for (
i = 0;
i < ntups;
i++)
4921 pg_fatal(
"could not parse %s array",
"prattrs");
4980 .description =
"PUBLICATION TABLES IN SCHEMA",
4982 .createStmt = query->
data));
5040 .
namespace =
tbinfo->dobj.namespace->dobj.name,
5042 .description =
"PUBLICATION TABLE",
5044 .createStmt = query->
data));
5081 "SELECT set_config(name, '%s', false) "
5083 "WHERE name = 'restrict_nonsystem_relation_kind'",
5134 "SELECT count(*) FROM pg_subscription "
5135 "WHERE subdbid = (SELECT oid FROM pg_database"
5136 " WHERE datname = current_database())",
5140 pg_log_warning(
"subscriptions not dumped because current user is not a superuser");
5149 "SELECT s.tableoid, s.oid, s.subname,\n"
5151 " s.subconninfo, s.subslotname, s.subsynccommit,\n"
5152 " s.subpublications,\n");
5166 " s.subtwophasestate,\n"
5167 " s.subdisableonerr,\n");
5170 " '%c' AS subtwophasestate,\n"
5171 " false AS subdisableonerr,\n",
5176 " s.subpasswordrequired,\n"
5177 " s.subrunasowner,\n"
5181 " 't' AS subpasswordrequired,\n"
5182 " 't' AS subrunasowner,\n"
5183 " '%s' AS suborigin,\n",
5188 " s.subenabled,\n");
5191 " false AS subenabled,\n");
5195 " s.subfailover,\n");
5198 " false AS subfailover,\n");
5202 " s.subretaindeadtuples,\n");
5205 " false AS subretaindeadtuples,\n");
5209 " s.submaxretention,\n");
5212 " 0 AS submaxretention,\n");
5216 " s.subwalrcvtimeout\n");
5219 " '-1' AS subwalrcvtimeout\n");
5222 "FROM pg_subscription s\n");
5226 "LEFT JOIN pg_catalog.pg_replication_origin_status o \n"
5227 " ON o.external_id = 'pg_' || s.oid::text \n");
5230 "WHERE s.subdbid = (SELECT oid FROM pg_database\n"
5231 " WHERE datname = current_database())");
5265 for (
i = 0;
i < ntups;
i++)
5345 "SELECT srsubid, srrelid, srsubstate, srsublsn "
5346 "FROM pg_catalog.pg_subscription_rel "
5360 for (
int i = 0;
i < ntups;
i++)
5373 if (subinfo ==
NULL)
5380 if (tblinfo ==
NULL)
5381 pg_fatal(
"failed sanity check, relation with OID %u not found",
5386 subrinfo[
i].dobj.catId.tableoid = relid;
5438 "\n-- For binary upgrade, must preserve the subscriber table.\n");
5440 "SELECT pg_catalog.binary_upgrade_add_sub_rel_state(");
5465 .
namespace =
subrinfo->tblinfo->dobj.namespace->dobj.name,
5467 .description =
"SUBSCRIPTION TABLE",
5469 .createStmt = query->
data));
5511 pg_fatal(
"could not parse %s array",
"subpublications");
5522 appendPQExpBuffer(query,
" PUBLICATION %s WITH (connect = false, slot_name = ", publications->
data);
5588 "\n-- For binary upgrade, must preserve the remote_lsn for the subscriber's replication origin.\n");
5590 "SELECT pg_catalog.binary_upgrade_replorigin_advance(");
5602 "\n-- For binary upgrade, must preserve the subscriber's running state.\n");
5611 .description =
"SUBSCRIPTION",
5613 .createStmt = query->
data,
5614 .dropStmt =
delq->data));
5643 const char *keyword,
5644 const char *objname)
5661 "FROM pg_catalog.pg_depend d, pg_catalog.pg_extension e "
5662 "WHERE d.refobjid = e.oid AND classid = '%s'::pg_catalog.regclass "
5663 "AND objid = '%u'::pg_catalog.oid AND deptype = 'x' "
5664 "AND refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass",
5670 for (
i = 0;
i < ntups;
i++)
5702 "SELECT EXISTS(SELECT 1 "
5703 "FROM pg_catalog.pg_type "
5704 "WHERE oid = '%u'::pg_catalog.oid);",
5730 "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5745 "\n-- For binary upgrade, must preserve pg_type array oid\n");
5747 "SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5759 "SELECT t.oid, t.typarray "
5760 "FROM pg_catalog.pg_type t "
5761 "JOIN pg_catalog.pg_range r "
5762 "ON t.oid = r.rngmultitypid "
5763 "WHERE r.rngtypid = '%u'::pg_catalog.oid;",
5780 "\n-- For binary upgrade, must preserve multirange pg_type oid\n");
5782 "SELECT pg_catalog.binary_upgrade_set_next_multirange_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5785 "\n-- For binary upgrade, must preserve multirange pg_type array oid\n");
5787 "SELECT pg_catalog.binary_upgrade_set_next_multirange_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5831 query =
"SELECT c.oid, c.relkind, c.relfilenode, c.reltoastrelid, "
5832 "ct.relfilenode, i.indexrelid, cti.relfilenode "
5833 "FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_index i "
5834 "ON (c.reltoastrelid = i.indrelid AND i.indisvalid) "
5835 "LEFT JOIN pg_catalog.pg_class ct ON (c.reltoastrelid = ct.oid) "
5836 "LEFT JOIN pg_catalog.pg_class AS cti ON (i.indexrelid = cti.oid) "
5885 "\n-- For binary upgrade, must preserve pg_class oids and relfilenodes\n");
5891 "SELECT pg_catalog.binary_upgrade_set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
5902 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
5913 "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
5916 "SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
5921 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5924 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5932 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5935 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5952 const char *objtype,
5953 const char *objname,
5976 pg_fatal(
"could not find parent extension for %s %s",
5980 "\n-- For binary upgrade, handle extension membership the hard way\n");
6017 "acldefault('n', n.nspowner) AS acldefault "
6018 "FROM pg_namespace n");
6033 for (
i = 0;
i < ntups;
i++)
6035 const char *nspowner;
6090 nsinfo[
i].dacl.privtype =
'i';
6146 "x.extname, n.nspname, x.extrelocatable, x.extversion, x.extconfig, x.extcondition "
6147 "FROM pg_extension x "
6148 "JOIN pg_namespace n ON n.oid = x.extnamespace");
6167 for (
i = 0;
i < ntups;
i++)
6240 "typnamespace, typacl, "
6241 "acldefault('T', typowner) AS acldefault, "
6243 "typelem, typrelid, typarray, "
6244 "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
6245 "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
6246 "typtype, typisdefined, "
6247 "typname[0] = '_' AND typelem != 0 AND "
6248 "(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray "
6272 for (
i = 0;
i < ntups;
i++)
6306 tyinfo[
i].isMultirange =
true;
6308 tyinfo[
i].isMultirange =
false;
6397 "oprcode::oid AS oprcode "
6398 "FROM pg_operator");
6416 for (
i = 0;
i < ntups;
i++)
6470 "FROM pg_collation");
6485 for (
i = 0;
i < ntups;
i++)
6534 "FROM pg_conversion");
6548 for (
i = 0;
i < ntups;
i++)
6602 "amhandler::pg_catalog.regproc AS amhandler ");
6605 "'i'::pg_catalog.\"char\" AS amtype, "
6606 "'-'::pg_catalog.regproc AS amhandler ");
6621 for (
i = 0;
i < ntups;
i++)
6684 for (
i = 0;
i < ntups;
i++)
6734 "FROM pg_opfamily");
6749 for (
i = 0;
i < ntups;
i++)
6805 "p.proname AS aggname, "
6806 "p.pronamespace AS aggnamespace, "
6807 "p.pronargs, p.proargtypes, "
6809 "p.proacl AS aggacl, "
6810 "acldefault('f', p.proowner) AS acldefault "
6812 "LEFT JOIN pg_init_privs pip ON "
6813 "(p.oid = pip.objoid "
6814 "AND pip.classoid = 'pg_proc'::regclass "
6815 "AND pip.objsubid = 0) "
6817 "p.pronamespace != "
6818 "(SELECT oid FROM pg_namespace "
6819 "WHERE nspname = 'pg_catalog') OR "
6820 "p.proacl IS DISTINCT FROM pip.initprivs",
6824 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6825 "classid = 'pg_proc'::regclass AND "
6826 "objid = p.oid AND "
6827 "refclassid = 'pg_extension'::regclass AND "
6834 "pronamespace AS aggnamespace, "
6835 "pronargs, proargtypes, "
6837 "proacl AS aggacl, "
6838 "acldefault('f', proowner) AS acldefault "
6840 "WHERE proisagg AND ("
6842 "(SELECT oid FROM pg_namespace "
6843 "WHERE nspname = 'pg_catalog')");
6846 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6847 "classid = 'pg_proc'::regclass AND "
6848 "objid = p.oid AND "
6849 "refclassid = 'pg_extension'::regclass AND "
6870 for (
i = 0;
i < ntups;
i++)
6881 agginfo[
i].aggfn.dacl.privtype = 0;
6896 agginfo[
i].aggfn.postponed_def =
false;
6962 :
"NOT p.proisagg");
6965 "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
6966 "p.pronargs, p.proargtypes, p.prorettype, "
6968 "acldefault('f', p.proowner) AS acldefault, "
6972 "LEFT JOIN pg_init_privs pip ON "
6973 "(p.oid = pip.objoid "
6974 "AND pip.classoid = 'pg_proc'::regclass "
6975 "AND pip.objsubid = 0) "
6977 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6978 "WHERE classid = 'pg_proc'::regclass AND "
6979 "objid = p.oid AND deptype = 'i')"
6981 "\n pronamespace != "
6982 "(SELECT oid FROM pg_namespace "
6983 "WHERE nspname = 'pg_catalog')"
6984 "\n OR EXISTS (SELECT 1 FROM pg_cast"
6985 "\n WHERE pg_cast.oid > %u "
6986 "\n AND p.oid = pg_cast.castfunc)"
6987 "\n OR EXISTS (SELECT 1 FROM pg_transform"
6988 "\n WHERE pg_transform.oid > %u AND "
6989 "\n (p.oid = pg_transform.trffromsql"
6990 "\n OR p.oid = pg_transform.trftosql))",
6996 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6997 "classid = 'pg_proc'::regclass AND "
6998 "objid = p.oid AND "
6999 "refclassid = 'pg_extension'::regclass AND "
7002 "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
7008 "SELECT tableoid, oid, proname, prolang, "
7009 "pronargs, proargtypes, prorettype, proacl, "
7010 "acldefault('f', proowner) AS acldefault, "
7014 "WHERE NOT proisagg"
7015 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
7016 "WHERE classid = 'pg_proc'::regclass AND "
7017 "objid = p.oid AND deptype = 'i')"
7019 "\n pronamespace != "
7020 "(SELECT oid FROM pg_namespace "
7021 "WHERE nspname = 'pg_catalog')"
7022 "\n OR EXISTS (SELECT 1 FROM pg_cast"
7023 "\n WHERE pg_cast.oid > '%u'::oid"
7024 "\n AND p.oid = pg_cast.castfunc)",
7029 "\n OR EXISTS (SELECT 1 FROM pg_transform"
7030 "\n WHERE pg_transform.oid > '%u'::oid"
7031 "\n AND (p.oid = pg_transform.trffromsql"
7032 "\n OR p.oid = pg_transform.trftosql))",
7037 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
7038 "classid = 'pg_proc'::regclass AND "
7039 "objid = p.oid AND "
7040 "refclassid = 'pg_extension'::regclass AND "
7063 for (
i = 0;
i < ntups;
i++)
7070 finfo[
i].
dobj.namespace =
7080 if (finfo[
i].nargs == 0)
7086 finfo[
i].argtypes, finfo[
i].nargs);
7112 char *reltuples,
int32 relallvisible,
7113 int32 relallfrozen,
char relkind,
7114 char **indAttNames,
int nindAttNames)
7139 dobj->namespace = rel->namespace;
7171 pg_fatal(
"cannot dump statistics for relation kind \"%c\"",
7255 "SELECT c.tableoid, c.oid, c.relname, "
7256 "c.relnamespace, c.relkind, c.reltype, "
7259 "c.relhasindex, c.relhasrules, c.relpages, "
7260 "c.reltuples, c.relallvisible, ");
7268 "c.relhastriggers, c.relpersistence, "
7272 " THEN 's'::\"char\" ELSE 'r'::\"char\" END, c.relowner) AS acldefault, "
7274 "(SELECT ftserver FROM pg_catalog.pg_foreign_table WHERE ftrelid = c.oid) "
7275 "ELSE 0 END AS foreignserver, "
7276 "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, "
7278 "tc.relpages AS toastpages, "
7279 "tc.reloptions AS toast_reloptions, "
7280 "d.refobjid AS owning_tab, "
7281 "d.refobjsubid AS owning_col, "
7282 "tsp.spcname AS reltablespace, ");
7286 "false AS relhasoids, ");
7293 "c.relispopulated, ");
7296 "'t' as relispopulated, ");
7300 "c.relreplident, ");
7303 "'d' AS relreplident, ");
7307 "c.relrowsecurity, c.relforcerowsecurity, ");
7310 "false AS relrowsecurity, "
7311 "false AS relforcerowsecurity, ");
7315 "c.relminmxid, tc.relminmxid AS tminmxid, ");
7318 "0 AS relminmxid, 0 AS tminmxid, ");
7322 "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
7323 "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
7324 "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
7327 "c.reloptions, NULL AS checkoption, ");
7334 "NULL AS amname, ");
7338 "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
7341 "false AS is_identity_sequence, ");
7345 "c.relispartition AS ispartition ");
7348 "false AS ispartition ");
7357 "\nFROM pg_class c\n"
7358 "LEFT JOIN pg_depend d ON "
7360 "d.classid = 'pg_class'::regclass AND d.objid = c.oid AND "
7361 "d.objsubid = 0 AND "
7362 "d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
7363 "LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
7370 "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
7378 "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid"
7393 "WHERE c.relkind IN ("
7478 for (
i = 0;
i < ntups;
i++)
7488 tblinfo[
i].
dobj.namespace =
7581 if (tblinfo[
i].interesting)
7586 tblinfo[
i].relpages,
7588 relallvisible, relallfrozen,
7589 tblinfo[
i].relkind,
NULL, 0);
7591 tblinfo[
i].
stats = stats;
7618 if (query->
len == 0)
7627 if (query->
len >= 100000)
7638 if (query->
len != 0)
7682 if (owning_tab ==
NULL)
7683 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
7708 if (
seqinfo->is_identity_sequence)
7755 for (
i = 0;
i < ntups;
i++)
7810 "SELECT partrelid FROM pg_partitioned_table WHERE\n"
7811 "(SELECT c.oid FROM pg_opclass c JOIN pg_am a "
7812 "ON c.opcmethod = a.oid\n"
7813 "WHERE opcname = 'enum_ops' "
7814 "AND opcnamespace = 'pg_catalog'::regnamespace "
7815 "AND amname = 'hash') = ANY(partclass)");
7821 for (
int i = 0;
i < ntups;
i++)
7828 pg_fatal(
"failed sanity check, table OID %u appearing in pg_partitioned_table not found",
7830 tbinfo->unsafe_partitions =
true;
7903 if (!
tbinfo->interesting)
7914 "SELECT t.tableoid, t.oid, i.indrelid, "
7915 "t.relname AS indexname, "
7916 "t.relpages, t.reltuples, t.relallvisible, ");
7924 "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
7925 "i.indkey, i.indisclustered, "
7926 "c.contype, c.conname, "
7927 "c.condeferrable, c.condeferred, "
7928 "c.tableoid AS contableoid, "
7930 "pg_catalog.pg_get_constraintdef(c.oid, false) AS condef, "
7931 "CASE WHEN i.indexprs IS NOT NULL THEN "
7932 "(SELECT pg_catalog.array_agg(attname ORDER BY attnum)"
7933 " FROM pg_catalog.pg_attribute "
7934 " WHERE attrelid = i.indexrelid) "
7935 "ELSE NULL END AS indattnames, "
7936 "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
7937 "t.reloptions AS indreloptions, ");
7942 "i.indisreplident, ");
7945 "false AS indisreplident, ");
7949 "inh.inhparent AS parentidx, "
7950 "i.indnkeyatts AS indnkeyatts, "
7951 "i.indnatts AS indnatts, "
7952 "(SELECT pg_catalog.array_agg(attnum ORDER BY attnum) "
7953 " FROM pg_catalog.pg_attribute "
7954 " WHERE attrelid = i.indexrelid AND "
7955 " attstattarget >= 0) AS indstatcols, "
7956 "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attnum) "
7957 " FROM pg_catalog.pg_attribute "
7958 " WHERE attrelid = i.indexrelid AND "
7959 " attstattarget >= 0) AS indstatvals, ");
7963 "i.indnatts AS indnkeyatts, "
7964 "i.indnatts AS indnatts, "
7965 "'' AS indstatcols, "
7966 "'' AS indstatvals, ");
7970 "i.indnullsnotdistinct, ");
7973 "false AS indnullsnotdistinct, ");
7980 "NULL AS conperiod ");
7994 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7995 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7996 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7997 "JOIN pg_catalog.pg_class t2 ON (t2.oid = i.indrelid) "
7998 "LEFT JOIN pg_catalog.pg_constraint c "
7999 "ON (i.indrelid = c.conrelid AND "
8000 "i.indexrelid = c.conindid AND "
8001 "c.contype IN ('p','u','x')) "
8002 "LEFT JOIN pg_catalog.pg_inherits inh "
8003 "ON (inh.inhrelid = indexrelid) "
8004 "WHERE (i.indisvalid OR t2.relkind = 'p') "
8006 "ORDER BY i.indrelid, indexname",
8016 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8017 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
8018 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
8019 "LEFT JOIN pg_catalog.pg_constraint c "
8020 "ON (i.indrelid = c.conrelid AND "
8021 "i.indexrelid = c.conindid AND "
8022 "c.contype IN ('p','u','x')) "
8023 "WHERE i.indisvalid AND i.indisready "
8024 "ORDER BY i.indrelid, indexname",
8069 for (
int j = 0;
j < ntups;)
8073 char **indAttNames =
NULL;
8074 int nindAttNames = 0;
8097 pg_fatal(
"unexpected index data for table \"%s\"",
8148 &indAttNames, &nindAttNames))
8149 pg_fatal(
"could not parse %s array",
"indattnames");
8155 indAttNames, nindAttNames);
8158 if (contype ==
'p' || contype ==
'u' || contype ==
'x')
8238 "stxnamespace, stxowner, stxrelid, NULL AS stxstattarget "
8239 "FROM pg_catalog.pg_statistic_ext");
8242 "stxnamespace, stxowner, stxrelid, stxstattarget "
8243 "FROM pg_catalog.pg_statistic_ext");
8259 for (
i = 0;
i < ntups;
i++)
8338 "SELECT c.tableoid, c.oid, "
8339 "conrelid, conname, confrelid, ");
8345 "pg_catalog.pg_get_constraintdef(c.oid) AS condef\n"
8346 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8347 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
8348 "WHERE contype = 'f' ",
8352 "AND conparentid = 0 ");
8354 "ORDER BY conrelid, conname");
8371 for (
int j = 0;
j < ntups;
j++)
8385 if (
tbinfo->dobj.catId.oid == conrelid)
8389 pg_fatal(
"unrecognized table OID %u", conrelid);
8422 for (
int k = 0; k <
reftable->numIndexes; k++)
8427 if (
reftable->indexes[k].dobj.catId.oid != indexOid)
8462 for (cell =
refidx->partattaches.head; cell; cell = cell->
next)
8468 if (
attach->partitionIdx->partattaches.head !=
NULL)
8500 "PREPARE getDomainConstraints(pg_catalog.oid) AS\n"
8501 "SELECT tableoid, oid, conname, "
8502 "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
8503 "convalidated, contype "
8504 "FROM pg_catalog.pg_constraint "
8505 "WHERE contypid = $1 AND contype IN (%s) "
8515 "EXECUTE getDomainConstraints('%u')",
8533 for (
int i = 0,
j = 0;
i < ntups;
i++)
8550 constraint =
tyinfo->notnull;
8558 constraint->
dobj.namespace =
tyinfo->dobj.namespace;
8561 constraint->
contype = contype;
8607 "tableoid, oid, rulename, "
8608 "ev_class AS ruletable, ev_type, is_instead, "
8627 for (
i = 0;
i < ntups;
i++)
8639 pg_fatal(
"failed sanity check, parent table with OID %u of pg_rewrite entry with OID %u not found",
8717 if (!
tbinfo->hastriggers ||
8739 "SELECT t.tgrelid, t.tgname, "
8740 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8741 "t.tgenabled, t.tableoid, t.oid, "
8742 "t.tgparentid <> 0 AS tgispartition\n"
8743 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8744 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8745 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8746 "WHERE ((NOT t.tgisinternal AND t.tgparentid = 0) "
8747 "OR t.tgenabled != u.tgenabled) "
8748 "ORDER BY t.tgrelid, t.tgname",
8762 "SELECT t.tgrelid, t.tgname, "
8763 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8764 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition\n"
8765 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8766 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8767 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8768 "WHERE (NOT t.tgisinternal OR t.tgenabled != u.tgenabled) "
8769 "ORDER BY t.tgrelid, t.tgname",
8782 "SELECT t.tgrelid, t.tgname, "
8783 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8784 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition "
8785 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8786 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8787 "LEFT JOIN pg_catalog.pg_depend AS d ON "
8788 " d.classid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8789 " d.refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8791 "LEFT JOIN pg_catalog.pg_trigger AS pt ON pt.oid = refobjid "
8792 "WHERE (NOT t.tgisinternal OR t.tgenabled != pt.tgenabled) "
8793 "ORDER BY t.tgrelid, t.tgname",
8800 "SELECT t.tgrelid, t.tgname, "
8801 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8802 "t.tgenabled, false as tgispartition, "
8803 "t.tableoid, t.oid "
8804 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8805 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8806 "WHERE NOT tgisinternal "
8807 "ORDER BY t.tgrelid, t.tgname",
8830 for (
int j = 0;
j < ntups;)
8907 "SELECT e.tableoid, e.oid, evtname, evtenabled, "
8908 "evtevent, evtowner, "
8909 "array_to_string(array("
8910 "select quote_literal(x) "
8911 " from unnest(evttags) as t(x)), ', ') as evttags, "
8912 "e.evtfoid::regproc as evtfname "
8913 "FROM pg_event_trigger e "
8931 for (
i = 0;
i < ntups;
i++)
8981 "lanname, lanpltrusted, lanplcallfoid, "
8982 "laninline, lanvalidator, "
8984 "acldefault('l', lanowner) AS acldefault, "
9007 for (
i = 0;
i < ntups;
i++)
9064 "castsource, casttarget, castfunc, castcontext, "
9067 "WHERE NOT EXISTS ( "
9068 "SELECT 1 FROM pg_range r "
9069 "WHERE c.castsource = r.rngtypid "
9070 "AND c.casttarget = r.rngmultitypid "
9077 "castsource, casttarget, castfunc, castcontext, "
9079 "FROM pg_cast ORDER BY 3,4");
9096 for (
i = 0;
i < ntups;
i++)
9142 appendPQExpBuffer(query,
"SELECT lanname FROM pg_language WHERE oid = %u", langid);
9177 "trftype, trflang, trffromsql::oid, trftosql::oid "
9178 "FROM pg_transform "
9194 for (
i = 0;
i < ntups;
i++)
9303 if (!
tbinfo->interesting &&
9337 "a.attstattarget,\n"
9345 "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n"
9346 "array_to_string(a.attoptions, ', ') AS attoptions,\n"
9347 "CASE WHEN a.attcollation <> t.typcollation "
9348 "THEN a.attcollation ELSE 0 END AS attcollation,\n"
9349 "pg_catalog.array_to_string(ARRAY("
9350 "SELECT pg_catalog.quote_ident(option_name) || "
9351 "' ' || pg_catalog.quote_literal(option_value) "
9352 "FROM pg_catalog.pg_options_to_table(attfdwoptions) "
9353 "ORDER BY option_name"
9354 "), E',\n ') AS attfdwoptions,\n");
9376 "co.conname AS notnull_name,\n"
9377 "CASE WHEN co.convalidated THEN pt.description"
9378 " ELSE NULL END AS notnull_comment,\n"
9379 "CASE WHEN NOT co.convalidated THEN co.oid "
9380 "ELSE NULL END AS notnull_invalidoid,\n"
9381 "co.connoinherit AS notnull_noinherit,\n"
9382 "co.conislocal AS notnull_islocal,\n");
9385 "CASE WHEN a.attnotnull THEN '' ELSE NULL END AS notnull_name,\n"
9386 "NULL AS notnull_comment,\n"
9387 "NULL AS notnull_invalidoid,\n"
9388 "false AS notnull_noinherit,\n"
9389 "CASE WHEN a.attislocal THEN true\n"
9390 " WHEN a.attnotnull AND NOT a.attislocal THEN true\n"
9392 "END AS notnull_islocal,\n");
9396 "a.attcompression AS attcompression,\n");
9399 "'' AS attcompression,\n");
9403 "a.attidentity,\n");
9406 "'' AS attidentity,\n");
9410 "CASE WHEN a.atthasmissing AND NOT a.attisdropped "
9411 "THEN a.attmissingval ELSE null END AS attmissingval,\n");
9414 "NULL AS attmissingval,\n");
9418 "a.attgenerated\n");
9421 "'' AS attgenerated\n");
9425 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9426 "JOIN pg_catalog.pg_attribute a ON (src.tbloid = a.attrelid) "
9427 "LEFT JOIN pg_catalog.pg_type t "
9428 "ON (a.atttypid = t.oid)\n",
9437 " LEFT JOIN pg_catalog.pg_constraint co ON "
9438 "(a.attrelid = co.conrelid\n"
9439 " AND co.contype = 'n' AND "
9440 "co.conkey = array[a.attnum])\n"
9441 " LEFT JOIN pg_catalog.pg_description pt ON "
9442 "(pt.classoid = co.tableoid AND pt.objoid = co.oid)\n");
9445 "WHERE a.attnum > 0::pg_catalog.int2\n");
9453 "OR (a.attnum = -2::pg_catalog.int2 AND src.tbloid = "
9457 "ORDER BY a.attrelid, a.attnum");
9497 for (
int r = 0; r < ntups;)
9505 for (numatts = 1; numatts < ntups - r; numatts++)
9516 if (
tbinfo->dobj.catId.oid == attrelid)
9520 pg_fatal(
"unrecognized table OID %u", attrelid);
9527 pg_fatal(
"unexpected column data for table \"%s\"",
9531 tbinfo->numatts = numatts;
9556 for (
int j = 0;
j < numatts;
j++, r++)
9561 pg_fatal(
"invalid column numbering in table \"%s\"",
9566 tbinfo->attstattarget[
j] = -1;
9631 "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc\n"
9632 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9633 "JOIN pg_catalog.pg_attrdef a ON (src.tbloid = a.adrelid)\n"
9634 "ORDER BY a.adrelid, a.adnum",
9668 pg_fatal(
"invalid adnum value %d for table \"%s\"",
9669 adnum,
tbinfo->dobj.name);
9675 if (
tbinfo->attisdropped[adnum - 1])
9683 attrdefs[
j].
adnum = adnum;
9687 attrdefs[
j].
dobj.namespace =
tbinfo->dobj.namespace;
9698 if (
tbinfo->attgenerated[adnum - 1])
9728 if (!attrdefs[
j].separate)
9740 tbinfo->attrdefs[adnum - 1] = &attrdefs[
j];
9761 pg_log_info(
"finding invalid not-null constraints");
9765 "SELECT c.tableoid, c.oid, conrelid, conname, "
9766 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9767 "conislocal, convalidated "
9768 "FROM unnest('%s'::pg_catalog.oid[]) AS src(conoid)\n"
9769 "JOIN pg_catalog.pg_constraint c ON (src.conoid = c.oid)\n"
9770 "ORDER BY c.conrelid, c.conname",
9805 if (
tbinfo->dobj.catId.oid == conrelid)
9809 pg_fatal(
"unrecognized table OID %u", conrelid);
9863 "SELECT c.tableoid, c.oid, conrelid, conname, "
9864 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9865 "conislocal, convalidated "
9866 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9867 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
9868 "WHERE contype = 'c' "
9869 "ORDER BY c.conrelid, c.conname",
9905 if (
tbinfo->dobj.catId.oid == conrelid)
9909 pg_fatal(
"unrecognized table OID %u", conrelid);
9914 "expected %d check constraints on table \"%s\" but found %d",
10065 tbinfo->notnull_invalid[
j] =
true;
10078 tbinfo->notnull_invalid[
j] =
false;
10095 tbinfo->notnull_constrs[
j] =
"";
10110 !
tbinfo->notnull_islocal) ||
10125 tbinfo->notnull_constrs[
j] =
"";
10159 if (
tbinfo->attisdropped[colno])
10161 return (
tbinfo->attislocal[colno] ||
tbinfo->ispartition);
10195 "prsstart::oid, prstoken::oid, "
10196 "prsend::oid, prsheadline::oid, prslextype::oid "
10197 "FROM pg_ts_parser");
10215 for (
i = 0;
i < ntups;
i++)
10262 "dictnamespace, dictowner, "
10263 "dicttemplate, dictinitoption "
10264 "FROM pg_ts_dict");
10280 for (
i = 0;
i < ntups;
i++)
10327 "tmplnamespace, tmplinit::oid, tmpllexize::oid "
10328 "FROM pg_ts_template");
10343 for (
i = 0;
i < ntups;
i++)
10386 "cfgnamespace, cfgowner, cfgparser "
10387 "FROM pg_ts_config");
10402 for (
i = 0;
i < ntups;
i++)
10449 "fdwhandler::pg_catalog.regproc, "
10450 "fdwvalidator::pg_catalog.regproc, "
10452 "acldefault('F', fdwowner) AS acldefault, "
10453 "array_to_string(ARRAY("
10454 "SELECT quote_ident(option_name) || ' ' || "
10455 "quote_literal(option_value) "
10456 "FROM pg_options_to_table(fdwoptions) "
10457 "ORDER BY option_name"
10458 "), E',\n ') AS fdwoptions "
10459 "FROM pg_foreign_data_wrapper");
10477 for (
i = 0;
i < ntups;
i++)
10534 "srvfdw, srvtype, srvversion, srvacl, "
10535 "acldefault('S', srvowner) AS acldefault, "
10536 "array_to_string(ARRAY("
10537 "SELECT quote_ident(option_name) || ' ' || "
10538 "quote_literal(option_value) "
10539 "FROM pg_options_to_table(srvoptions) "
10540 "ORDER BY option_name"
10541 "), E',\n ') AS srvoptions "
10542 "FROM pg_foreign_server");
10561 for (
i = 0;
i < ntups;
i++)
10631 "SELECT oid, tableoid, "
10633 "defaclnamespace, "
10636 "CASE WHEN defaclnamespace = 0 THEN "
10637 "acldefault(CASE WHEN defaclobjtype = 'S' "
10638 "THEN 's'::\"char\" ELSE defaclobjtype END, "
10639 "defaclrole) ELSE '{}' END AS acldefault "
10640 "FROM pg_default_acl");
10656 for (
i = 0;
i < ntups;
i++)
10709 while (low <= high)
10715 else if (roleoid >
middle->roleoid)
10722 pg_fatal(
"role with OID %u does not exist", roleoid);
10739 query =
"SELECT oid, rolname FROM pg_catalog.pg_roles ORDER BY 1";
10777 "SELECT DISTINCT attrelid FROM pg_attribute "
10778 "WHERE attacl IS NOT NULL");
10783 for (
i = 0;
i < ntups;
i++)
10802 "SELECT objoid, classoid, objsubid, privtype, initprivs "
10803 "FROM pg_init_privs");
10808 for (
i = 0;
i < ntups;
i++)
10819 objId.
oid = objoid;
10831 ((
TableInfo *) dobj)->hascolumnACLs =
true;
10835 classoid, objoid, objsubid);
10859 daobj->dacl.privtype = privtype;
10864 classoid, objoid, objsubid);
10898 const char *
name,
const char *
namespace,
10899 const char *owner,
CatalogId catalogId,
10900 int subid,
DumpId dumpId,
10963 if (
namespace && *
namespace)
10978 .namespace =
namespace,
10980 .description =
"COMMENT",
10982 .createStmt = query->
data,
10998 const char *
name,
const char *
namespace,
10999 const char *owner,
CatalogId catalogId,
11000 int subid,
DumpId dumpId)
11003 catalogId, subid, dumpId,
NULL);
11014 const char *argtype,
const char *
argval)
11159 pg_fatal(
"statistics dumped out of order (current: %d %s %s, expected: %d %s %s)",
11167 "PREPARE getAttributeStats(pg_catalog.name[], pg_catalog.name[]) AS\n"
11168 "SELECT s.schemaname, s.tablename, s.attname, s.inherited, "
11169 "s.null_frac, s.avg_width, s.n_distinct, "
11170 "s.most_common_vals, s.most_common_freqs, "
11171 "s.histogram_bounds, s.correlation, "
11172 "s.most_common_elems, s.most_common_elem_freqs, "
11173 "s.elem_count_histogram, ");
11177 "s.range_length_histogram, "
11178 "s.range_empty_frac, "
11179 "s.range_bounds_histogram ");
11182 "NULL AS range_length_histogram,"
11183 "NULL AS range_empty_frac,"
11184 "NULL AS range_bounds_histogram ");
11201 "FROM pg_catalog.pg_stats s "
11202 "JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
11203 "ON s.schemaname = u.schemaname "
11204 "AND s.tablename = u.tablename "
11205 "WHERE s.tablename = ANY($2) "
11206 "ORDER BY u.ord, s.attname, s.inherited");
11209 "FROM pg_catalog.pg_stats s "
11210 "WHERE s.schemaname = $1[1] "
11211 "AND s.tablename = $2[1] "
11212 "ORDER BY s.attname, s.inherited");
11282 for (; rownum <
PQntuples(res); rownum++)
11300 pg_fatal(
"unexpected null attname");
11308 if (
rsinfo->nindAttNames == 0)
11315 bool found =
false;
11317 for (
int i = 0;
i <
rsinfo->nindAttNames;
i++)
11402 .namespace = dobj->namespace->dobj.
name,
11403 .description =
"STATISTICS DATA",
11404 .section =
rsinfo->section,
11408 .nDeps = dobj->
nDeps));
11466 .namespace =
tbinfo->dobj.namespace->dobj.name,
11467 .owner =
tbinfo->rolname,
11468 .description =
"COMMENT",
11470 .createStmt = query->
data,
11471 .deps = &(
tbinfo->dobj.dumpId),
11491 .namespace =
tbinfo->dobj.namespace->dobj.name,
11492 .owner =
tbinfo->rolname,
11493 .description =
"COMMENT",
11495 .createStmt = query->
data,
11496 .deps = &(
tbinfo->dobj.dumpId),
11528 while (low <= high)
11530 middle = low + (high - low) / 2;
11534 else if (classoid >
middle->classoid)
11538 else if (objoid >
middle->objoid)
11558 if (classoid !=
middle[-1].classoid ||
11559 objoid !=
middle[-1].objoid)
11570 if (classoid !=
middle->classoid ||
11571 objoid !=
middle->objoid)
11608 "FROM pg_catalog.pg_description "
11609 "ORDER BY classoid, objoid, objsubid");
11626 for (
i = 0;
i < ntups;
i++)
11636 if (dobj ==
NULL ||
11688 if (dobj->
dump == 0)
11816 pg_fatal(
"missing metadata for large objects \"%s\"",
11822 .description =
"BLOBS",
11824 .deps = dobj->dependencies,
11825 .nDeps = dobj->nDeps,
11900 "-- *not* dropping schema, since initdb creates it\n");
11902 "-- *not* creating schema, since initdb creates it\n");
11913 .description =
"SCHEMA",
11915 .createStmt = q->
data,
11916 .dropStmt =
delq->data));
11998 appendPQExpBufferStr(q,
"-- For binary upgrade, create an empty extension and insert objects into it\n");
12008 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
12053 .description =
"EXTENSION",
12055 .createStmt = q->
data,
12056 .dropStmt =
delq->data));
12097 pg_log_warning(
"typtype of data type \"%s\" appears to be invalid",
12126 "PREPARE dumpEnumType(pg_catalog.oid) AS\n"
12127 "SELECT oid, enumlabel "
12128 "FROM pg_catalog.pg_enum "
12129 "WHERE enumtypid = $1 "
12130 "ORDER BY enumsortorder");
12138 "EXECUTE dumpEnumType('%u')",
12139 tyinfo->dobj.catId.oid);
12167 for (
i = 0;
i < num;
i++)
12185 for (
i = 0;
i < num;
i++)
12193 "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
12204 tyinfo->dobj.namespace->dobj.name);
12209 .namespace =
tyinfo->dobj.namespace->dobj.name,
12210 .owner =
tyinfo->rolname,
12211 .description =
"TYPE",
12213 .createStmt = q->
data,
12214 .dropStmt =
delq->data));
12230 tyinfo->dobj.namespace->dobj.name,
12262 "PREPARE dumpRangeType(pg_catalog.oid) AS\n");
12269 "pg_catalog.format_type(rngmultitypid, NULL) AS rngmultitype, ");
12272 "NULL AS rngmultitype, ");
12275 "pg_catalog.format_type(rngsubtype, NULL) AS rngsubtype, "
12276 "opc.opcname AS opcname, "
12277 "(SELECT nspname FROM pg_catalog.pg_namespace nsp "
12278 " WHERE nsp.oid = opc.opcnamespace) AS opcnsp, "
12280 "CASE WHEN rngcollation = st.typcollation THEN 0 "
12281 " ELSE rngcollation END AS collation, "
12282 "rngcanonical, rngsubdiff "
12283 "FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
12284 " pg_catalog.pg_opclass opc "
12285 "WHERE st.oid = rngsubtype AND opc.oid = rngsubopc AND "
12294 "EXECUTE dumpRangeType('%u')",
12295 tyinfo->dobj.catId.oid);
12345 if (
strcmp(procname,
"-") != 0)
12349 if (
strcmp(procname,
"-") != 0)
12357 tyinfo->dobj.namespace->dobj.name);
12362 .namespace =
tyinfo->dobj.namespace->dobj.name,
12363 .owner =
tyinfo->rolname,
12364 .description =
"TYPE",
12366 .createStmt = q->
data,
12367 .dropStmt =
delq->data));
12383 tyinfo->dobj.namespace->dobj.name,
12428 tyinfo->dobj.namespace->dobj.name);
12433 .namespace =
tyinfo->dobj.namespace->dobj.name,
12434 .owner =
tyinfo->rolname,
12435 .description =
"TYPE",
12437 .createStmt = q->
data,
12438 .dropStmt =
delq->data));
12454 tyinfo->dobj.namespace->dobj.name,
12485 char *typsubscript;
12506 "PREPARE dumpBaseType(pg_catalog.oid) AS\n"
12508 "typinput, typoutput, typreceive, typsend, "
12509 "typreceive::pg_catalog.oid AS typreceiveoid, "
12510 "typsend::pg_catalog.oid AS typsendoid, "
12512 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
12513 "typdelim, typbyval, typalign, typstorage, "
12514 "typmodin, typmodout, "
12515 "typmodin::pg_catalog.oid AS typmodinoid, "
12516 "typmodout::pg_catalog.oid AS typmodoutoid, "
12517 "typcategory, typispreferred, "
12518 "(typcollation <> 0) AS typcollatable, "
12519 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault, ");
12524 "typsubscript::pg_catalog.oid AS typsubscriptoid ");
12527 "'-' AS typsubscript, 0 AS typsubscriptoid ");
12538 "EXECUTE dumpBaseType('%u')",
12539 tyinfo->dobj.catId.oid);
12595 "CREATE TYPE %s (\n"
12596 " INTERNALLENGTH = %s",
12598 (
strcmp(typlen,
"-1") == 0) ?
"variable" : typlen);
12643 if (typdelim &&
strcmp(typdelim,
",") != 0)
12667 if (
strcmp(typbyval,
"t") == 0)
12675 tyinfo->dobj.namespace->dobj.name);
12680 .namespace =
tyinfo->dobj.namespace->dobj.name,
12681 .owner =
tyinfo->rolname,
12682 .description =
"TYPE",
12684 .createStmt = q->
data,
12685 .dropStmt =
delq->data));
12701 tyinfo->dobj.namespace->dobj.name,
12737 "PREPARE dumpDomain(pg_catalog.oid) AS\n");
12740 "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
12741 "pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
12743 "CASE WHEN t.typcollation <> u.typcollation "
12744 "THEN t.typcollation ELSE 0 END AS typcollation "
12745 "FROM pg_catalog.pg_type t "
12746 "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
12747 "WHERE t.oid = $1");
12755 "EXECUTE dumpDomain('%u')",
12756 tyinfo->dobj.catId.oid);
12783 "CREATE DOMAIN %s AS %s",
12842 for (
i = 0;
i <
tyinfo->nDomChecks;
i++)
12858 tyinfo->dobj.namespace->dobj.name);
12863 .namespace =
tyinfo->dobj.namespace->dobj.name,
12864 .owner =
tyinfo->rolname,
12865 .description =
"DOMAIN",
12867 .createStmt = q->
data,
12868 .dropStmt =
delq->data));
12884 tyinfo->dobj.namespace->dobj.name,
12888 for (
i = 0;
i <
tyinfo->nDomChecks;
i++)
12903 tyinfo->dobj.namespace->dobj.name,
12923 tyinfo->dobj.namespace->dobj.name,
12973 "PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
12974 "SELECT a.attname, a.attnum, "
12975 "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
12976 "a.attlen, a.attalign, a.attisdropped, "
12977 "CASE WHEN a.attcollation <> at.typcollation "
12978 "THEN a.attcollation ELSE 0 END AS attcollation "
12979 "FROM pg_catalog.pg_type ct "
12980 "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
12981 "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
12982 "WHERE ct.oid = $1 "
12983 "ORDER BY a.attnum");
12991 "EXECUTE dumpCompositeType('%u')",
12992 tyinfo->dobj.catId.oid);
13020 for (
i = 0;
i < ntups;
i++)
13071 "\n-- For binary upgrade, recreate dropped column.\n");
13073 "SET attlen = %s, "
13074 "attalign = '%s', attbyval = false\n"
13095 tyinfo->dobj.namespace->dobj.name);
13100 .namespace =
tyinfo->dobj.namespace->dobj.name,
13101 .owner =
tyinfo->rolname,
13102 .description =
"TYPE",
13104 .createStmt = q->
data,
13105 .dropStmt =
delq->data));
13122 tyinfo->dobj.namespace->dobj.name,
13186 for (
i = 0;
i < ntups;
i++)
13213 .namespace =
tyinfo->dobj.namespace->dobj.name,
13214 .owner =
tyinfo->rolname,
13215 .description =
"COMMENT",
13217 .createStmt = query->
data,
13218 .deps = &(
tyinfo->dobj.dumpId),
13259 stinfo->baseType->dobj.catId.oid,
13268 .namespace =
stinfo->dobj.namespace->dobj.name,
13269 .owner =
stinfo->baseType->rolname,
13270 .description =
"SHELL TYPE",
13272 .createStmt = q->
data));
13344 plang->lanpltrusted ?
"TRUSTED " :
"",
13378 .owner =
plang->lanowner,
13379 .description =
"PROCEDURAL LANGUAGE",
13381 .createStmt =
defqry->data,
13382 .dropStmt =
delqry->data,
13448 for (
j = 0;
j < finfo->
nargs;
j++)
13500 const char *keyword;
13515 "PREPARE dumpFunc(pg_catalog.oid) AS\n");
13529 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
13530 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
13531 "pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
13532 "proleakproof,\n");
13536 "array_to_string(protrftypes, ' ') AS protrftypes,\n");
13539 "NULL AS protrftypes,\n");
13546 "'u' AS proparallel,\n");
13553 "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n");
13560 "'-' AS prosupport,\n");
13564 "pg_get_function_sqlbody(p.oid) AS prosqlbody\n");
13567 "NULL AS prosqlbody\n");
13570 "FROM pg_catalog.pg_proc p, pg_catalog.pg_language l\n"
13571 "WHERE p.oid = $1 "
13572 "AND l.oid = p.prolang");
13580 "EXECUTE dumpFunc('%u')",
13622 else if (
probin[0] !=
'\0')
13626 if (prosrc[0] !=
'\0')
13654 pg_fatal(
"could not parse %s array",
"proconfig");
13672 keyword =
"PROCEDURE";
13674 keyword =
"FUNCTION";
13725 pg_fatal(
"unrecognized provolatile value for function \"%s\"",
13775 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
13835 "pg_catalog.pg_proc", keyword,
13841 finfo->
dobj.namespace->dobj.
name);
13846 .
namespace = finfo->
dobj.namespace->dobj.
name,
13848 .description = keyword,
13851 .createStmt = q->
data,
13852 .dropStmt =
delqry->data));
13909 pg_fatal(
"could not find function definition for function with OID %u",
13926 switch (
cast->castmethod)
13948 pg_log_warning(
"bogus value in pg_cast.castfunc or pg_cast.castmethod field");
13954 if (
cast->castcontext ==
'a')
13956 else if (
cast->castcontext ==
'i')
13973 .description =
"CAST",
13975 .createStmt =
defqry->data,
13976 .dropStmt =
delqry->data));
13982 cast->dobj.catId, 0,
cast->dobj.dumpId);
14015 pg_fatal(
"could not find function definition for function with OID %u",
14022 pg_fatal(
"could not find function definition for function with OID %u",
14041 pg_log_warning(
"bogus transform definition, at least one of trffromsql and trftosql should be nonzero");
14097 .description =
"TRANSFORM",
14099 .createStmt =
defqry->data,
14100 .dropStmt =
delqry->data,
14176 "PREPARE dumpOpr(pg_catalog.oid) AS\n"
14178 "oprcode::pg_catalog.regprocedure, "
14179 "oprleft::pg_catalog.regtype, "
14180 "oprright::pg_catalog.regtype, "
14183 "oprrest::pg_catalog.regprocedure, "
14184 "oprjoin::pg_catalog.regprocedure, "
14185 "oprcanmerge, oprcanhash "
14186 "FROM pg_catalog.pg_operator "
14195 "EXECUTE dumpOpr('%u')",
14223 if (
strcmp(oprkind,
"r") == 0)
14224 pg_log_warning(
"postfix operators are not supported anymore (operator \"%s\")",
14242 if (
strcmp(oprkind,
"r") == 0 ||
14243 strcmp(oprkind,
"b") == 0)
14251 if (
strcmp(oprkind,
"l") == 0 ||
14252 strcmp(oprkind,
"b") == 0)
14305 oprinfo->dobj.namespace->dobj.name);
14310 .namespace =
oprinfo->dobj.namespace->dobj.name,
14312 .description =
"OPERATOR",
14314 .createStmt = q->
data,
14315 .dropStmt =
delq->data));
14349 if (
strcmp(proc,
"-") == 0)
14399 return psprintf(
"OPERATOR(%s.%s)",
14420 "SELECT '%u'::pg_catalog.regproc", funcOid);
14482 .description =
"ACCESS METHOD",
14484 .createStmt = q->
data,
14485 .dropStmt =
delq->data));
14556 "opckeytype::pg_catalog.regtype, "
14557 "opcdefault, opcfamily, "
14558 "opfname AS opcfamilyname, "
14559 "nspname AS opcfamilynsp, "
14560 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS amname "
14561 "FROM pg_catalog.pg_opclass c "
14562 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily "
14563 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14564 "WHERE c.oid = '%u'::pg_catalog.oid",
14628 "amopopr::pg_catalog.regoperator, "
14629 "opfname AS sortfamily, "
14630 "nspname AS sortfamilynsp "
14631 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14632 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14633 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14634 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14635 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14636 "AND refobjid = '%u'::pg_catalog.oid "
14637 "AND amopfamily = '%s'::pg_catalog.oid "
14638 "ORDER BY amopstrategy",
14651 for (
i = 0;
i < ntups;
i++)
14664 if (
strlen(sortfamily) > 0)
14689 "amproc::pg_catalog.regprocedure, "
14690 "amproclefttype::pg_catalog.regtype, "
14691 "amprocrighttype::pg_catalog.regtype "
14692 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14693 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14694 "AND refobjid = '%u'::pg_catalog.oid "
14695 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14696 "AND objid = ap.oid "
14697 "ORDER BY amprocnum",
14709 for (
i = 0;
i < ntups;
i++)
14749 opcinfo->dobj.namespace->dobj.name);
14754 .namespace =
opcinfo->dobj.namespace->dobj.name,
14756 .description =
"OPERATOR CLASS",
14758 .createStmt = q->
data,
14759 .dropStmt =
delq->data));
14830 "amopopr::pg_catalog.regoperator, "
14831 "opfname AS sortfamily, "
14832 "nspname AS sortfamilynsp "
14833 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14834 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14835 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14836 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14837 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14838 "AND refobjid = '%u'::pg_catalog.oid "
14839 "AND amopfamily = '%u'::pg_catalog.oid "
14840 "ORDER BY amopstrategy",
14849 "amproc::pg_catalog.regprocedure, "
14850 "amproclefttype::pg_catalog.regtype, "
14851 "amprocrighttype::pg_catalog.regtype "
14852 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14853 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14854 "AND refobjid = '%u'::pg_catalog.oid "
14855 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14856 "AND objid = ap.oid "
14857 "ORDER BY amprocnum",
14866 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opfmethod) AS amname "
14867 "FROM pg_catalog.pg_opfamily "
14868 "WHERE oid = '%u'::pg_catalog.oid",
14911 for (
i = 0;
i < ntups;
i++)
14924 if (
strlen(sortfamily) > 0)
14944 for (
i = 0;
i < ntups;
i++)
14971 opfinfo->dobj.namespace->dobj.name);
14976 .namespace =
opfinfo->dobj.namespace->dobj.name,
14978 .description =
"OPERATOR FAMILY",
14980 .createStmt = q->
data,
14981 .dropStmt =
delq->data));
15042 "'c' AS collprovider, "
15043 "NULL AS collversion, ");
15047 "collisdeterministic, ");
15050 "true AS collisdeterministic, ");
15057 "colliculocale AS colllocale, ");
15060 "NULL AS colllocale, ");
15067 "NULL AS collicurules, ");
15072 "FROM pg_catalog.pg_collation c "
15073 "WHERE c.oid = '%u'::pg_catalog.oid",
15136 pg_fatal(
"unrecognized collation provider: %s",
15229 collinfo->dobj.namespace->dobj.name);
15234 .namespace =
collinfo->dobj.namespace->dobj.name,
15236 .description =
"COLLATION",
15238 .createStmt = q->
data,
15239 .dropStmt =
delq->data));
15289 "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
15290 "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
15291 "conproc, condefault "
15292 "FROM pg_catalog.pg_conversion c "
15293 "WHERE c.oid = '%u'::pg_catalog.oid",
15323 convinfo->dobj.namespace->dobj.name);
15328 .namespace =
convinfo->dobj.namespace->dobj.name,
15330 .description =
"CONVERSION",
15332 .createStmt = q->
data,
15333 .dropStmt =
delq->data));
15367 if (
agginfo->aggfn.nargs == 0)
15374 (
j > 0) ?
", " :
"",
15413 const char *aggsortop;
15416 const char *aggtranstype;
15417 const char *aggtransspace;
15438 "PREPARE dumpAgg(pg_catalog.oid) AS\n");
15444 "aggtranstype::pg_catalog.regtype,\n"
15447 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
15448 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
15454 "aggminvtransfn,\n"
15456 "aggmtranstype::pg_catalog.regtype,\n"
15458 "aggmfinalextra,\n"
15460 "aggmtransspace,\n"
15464 "'n' AS aggkind,\n"
15465 "'-' AS aggmtransfn,\n"
15466 "'-' AS aggminvtransfn,\n"
15467 "'-' AS aggmfinalfn,\n"
15468 "0 AS aggmtranstype,\n"
15469 "false AS aggfinalextra,\n"
15470 "false AS aggmfinalextra,\n"
15471 "0 AS aggtransspace,\n"
15472 "0 AS aggmtransspace,\n"
15473 "NULL AS aggminitval,\n");
15483 "'-' AS aggcombinefn,\n"
15484 "'-' AS aggserialfn,\n"
15485 "'-' AS aggdeserialfn,\n"
15486 "'u' AS proparallel,\n");
15490 "aggfinalmodify,\n"
15491 "aggmfinalmodify\n");
15494 "'0' AS aggfinalmodify,\n"
15495 "'0' AS aggmfinalmodify\n");
15498 "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
15499 "WHERE a.aggfnoid = p.oid "
15508 "EXECUTE dumpAgg('%u')",
15509 agginfo->aggfn.dobj.catId.oid);
15562 if (
strcmp(aggtransspace,
"0") != 0)
15594 pg_fatal(
"unrecognized aggfinalmodify value for aggregate \"%s\"",
15650 pg_fatal(
"unrecognized aggmfinalmodify value for aggregate \"%s\"",
15675 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
15690 agginfo->aggfn.dobj.namespace->dobj.name);
15696 .
namespace =
agginfo->aggfn.dobj.namespace->dobj.name,
15697 .owner =
agginfo->aggfn.rolname,
15698 .description =
"AGGREGATE",
15700 .createStmt = q->
data,
15701 .dropStmt =
delq->data));
15706 agginfo->aggfn.dobj.namespace->dobj.name,
15712 agginfo->aggfn.dobj.namespace->dobj.name,
15728 agginfo->aggfn.dobj.namespace->dobj.name,
15785 prsinfo->dobj.namespace->dobj.name);
15790 .namespace =
prsinfo->dobj.namespace->dobj.name,
15791 .description =
"TEXT SEARCH PARSER",
15793 .createStmt = q->
data,
15794 .dropStmt =
delq->data));
15799 prsinfo->dobj.namespace->dobj.name,
"",
15835 "FROM pg_ts_template p, pg_namespace n "
15836 "WHERE p.oid = '%u' AND n.oid = tmplnamespace",
15863 dictinfo->dobj.namespace->dobj.name);
15868 .namespace =
dictinfo->dobj.namespace->dobj.name,
15870 .description =
"TEXT SEARCH DICTIONARY",
15872 .createStmt = q->
data,
15873 .dropStmt =
delq->data));
15923 tmplinfo->dobj.namespace->dobj.name);
15928 .namespace =
tmplinfo->dobj.namespace->dobj.name,
15929 .description =
"TEXT SEARCH TEMPLATE",
15931 .createStmt = q->
data,
15932 .dropStmt =
delq->data));
15937 tmplinfo->dobj.namespace->dobj.name,
"",
15977 "FROM pg_ts_parser p, pg_namespace n "
15978 "WHERE p.oid = '%u' AND n.oid = prsnamespace",
15995 " ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
15996 " WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
15997 " m.mapdict::pg_catalog.regdictionary AS dictname\n"
15998 "FROM pg_catalog.pg_ts_config_map AS m\n"
15999 "WHERE m.mapcfg = '%u'\n"
16000 "ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
16009 for (
i = 0;
i < ntups;
i++)
16040 "TEXT SEARCH CONFIGURATION",
qcfgname,
16041 cfginfo->dobj.namespace->dobj.name);
16046 .namespace =
cfginfo->dobj.namespace->dobj.name,
16048 .description =
"TEXT SEARCH CONFIGURATION",
16050 .createStmt = q->
data,
16051 .dropStmt =
delq->data));
16112 .description =
"FOREIGN DATA WRAPPER",
16114 .createStmt = q->
data,
16115 .dropStmt =
delq->data));
16162 "FROM pg_foreign_data_wrapper w "
16163 "WHERE w.oid = '%u'",
16199 .description =
"SERVER",
16201 .createStmt = q->
data,
16202 .dropStmt =
delq->data));
16241 const char *servername,
const char *
namespace,
16270 "array_to_string(ARRAY("
16271 "SELECT quote_ident(option_name) || ' ' || "
16272 "quote_literal(option_value) "
16273 "FROM pg_options_to_table(umoptions) "
16274 "ORDER BY option_name"
16275 "), E',\n ') AS umoptions "
16276 "FROM pg_user_mappings "
16277 "WHERE srvid = '%u' "
16278 "ORDER BY usename",
16287 for (
i = 0;
i < ntups;
i++)
16314 .namespace =
namespace,
16316 .description =
"USER MAPPING",
16318 .createStmt = q->
data,
16319 .dropStmt =
delq->data));
16354 type =
"SEQUENCES";
16357 type =
"FUNCTIONS";
16366 type =
"LARGE OBJECTS";
16370 pg_fatal(
"unrecognized object type in default privileges: %d",
16386 pg_fatal(
"could not parse default ACL list (%s)",
16392 .namespace =
daclinfo->dobj.namespace ?
16395 .description =
"DEFAULT ACL",
16397 .createStmt = q->
data));
16428 const char *nspname,
const char *tag,
const char *owner,
16433 const char *
acls = dacl->
acl;
16436 const char *initprivs = dacl->
initprivs;
16464 initprivs && *initprivs !=
'\0')
16470 pg_fatal(
"could not parse initial ACL list (%s) or default (%s) for object \"%s\" (%s)",
16472 appendPQExpBufferStr(sql,
"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
16483 if (initprivs && *initprivs !=
'\0')
16495 pg_fatal(
"could not parse ACL list (%s) or default (%s) for object \"%s\" (%s)",
16519 .namespace = nspname,
16521 .description =
"ACL",
16523 .createStmt = sql->
data,
16555 const char *
namespace,
const char *owner,
16594 if (
labels[
i].objsubid != subid)
16598 "SECURITY LABEL FOR %s ON %s ",
16600 if (
namespace && *
namespace)
16607 if (query->
len > 0)
16614 .namespace =
namespace,
16616 .description =
"SECURITY LABEL",
16618 .createStmt = query->
data,
16665 const char *colname;
16668 int objsubid =
labels[
i].objsubid;
16689 if (query->
len > 0)
16696 .namespace =
tbinfo->dobj.namespace->dobj.name,
16697 .owner =
tbinfo->rolname,
16698 .description =
"SECURITY LABEL",
16700 .createStmt = query->
data,
16701 .deps = &(
tbinfo->dobj.dumpId),
16734 while (low <= high)
16736 middle = low + (high - low) / 2;
16740 else if (classoid >
middle->classoid)
16744 else if (objoid >
middle->objoid)
16764 if (classoid !=
middle[-1].classoid ||
16765 objoid !=
middle[-1].objoid)
16776 if (classoid !=
middle->classoid ||
16777 objoid !=
middle->objoid)
16811 "SELECT label, provider, classoid, objoid, objsubid "
16812 "FROM pg_catalog.pg_seclabels "
16813 "ORDER BY classoid, objoid, objsubid");
16830 for (
i = 0;
i < ntups;
i++)
16840 if (dobj ==
NULL ||
16903 const char *objtype =
16909 tbinfo->dobj.namespace->dobj.name,
16929 "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
16944 "SELECT at.attname, "
16946 "'{}' AS acldefault, "
16947 "pip.privtype, pip.initprivs "
16948 "FROM pg_catalog.pg_attribute at "
16949 "LEFT JOIN pg_catalog.pg_init_privs pip ON "
16950 "(at.attrelid = pip.objoid "
16951 "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
16952 "AND at.attnum = pip.objsubid) "
16953 "WHERE at.attrelid = $1 AND "
16954 "NOT at.attisdropped "
16955 "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
16956 "ORDER BY at.attnum");
16961 "SELECT attname, attacl, '{}' AS acldefault, "
16962 "NULL AS privtype, NULL AS initprivs "
16963 "FROM pg_catalog.pg_attribute "
16964 "WHERE attrelid = $1 AND NOT attisdropped "
16965 "AND attacl IS NOT NULL "
16966 "ORDER BY attnum");
16975 "EXECUTE getColumnACLs('%u')",
16976 tbinfo->dobj.catId.oid);
16993 coldacl.initprivs = initprivs;
17003 tbinfo->dobj.namespace->dobj.name,
17030 "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
17031 tbinfo->dobj.catId.oid);
17038 pg_fatal(
"query to obtain definition of view \"%s\" returned no data",
17041 pg_fatal(
"query to obtain definition of view \"%s\" returned more than one definition",
17048 pg_fatal(
"definition of view \"%s\" appears to be empty (length zero)",
17133 pg_log_warning(
"WITH OIDS is not supported anymore (table \"%s\")",
17154 tbinfo->dobj.catId.oid);
17188 switch (
tbinfo->relkind)
17199 "SELECT pg_get_partkeydef('%u')",
17200 tbinfo->dobj.catId.oid);
17218 "SELECT fs.srvname, "
17219 "pg_catalog.array_to_string(ARRAY("
17220 "SELECT pg_catalog.quote_ident(option_name) || "
17221 "' ' || pg_catalog.quote_literal(option_value) "
17222 "FROM pg_catalog.pg_options_to_table(ftoptions) "
17223 "ORDER BY option_name"
17224 "), E',\n ') AS ftoptions "
17225 "FROM pg_catalog.pg_foreign_table ft "
17226 "JOIN pg_catalog.pg_foreign_server fs "
17227 "ON (fs.oid = ft.ftserver) "
17228 "WHERE ft.ftrelid = '%u'",
17229 tbinfo->dobj.catId.oid);
17249 numParents =
tbinfo->numParents;
17256 tbinfo->dobj.catId.oid);
17300 tbinfo->attrdefs[
j]->dobj.dump &&
17301 !
tbinfo->attrdefs[
j]->separate);
17309 (
tbinfo->notnull_islocal[
j] ||
17361 tbinfo->attrdefs[
j]->adef_expr);
17364 tbinfo->attrdefs[
j]->adef_expr);
17367 tbinfo->attrdefs[
j]->adef_expr);
17372 if (
tbinfo->notnull_constrs[
j][0] ==
'\0')
17378 if (
tbinfo->notnull_noinh[
j])
17417 if (
tbinfo->notnull_constrs[
j][0] ==
'\0')
17425 if (
tbinfo->notnull_noinh[
j])
17473 if (numParents > 0 && !
tbinfo->ispartition &&
17477 for (k = 0; k < numParents; k++)
17539 "pg_catalog.pg_class",
17540 "MATERIALIZED VIEW",
17551 if (
tbinfo->attmissingval[
j][0] !=
'\0')
17555 "SELECT pg_catalog.binary_upgrade_set_missing_value(");
17610 "UPDATE pg_catalog.pg_attribute\n"
17611 "SET attlen = v.dlen, "
17612 "attalign = v.dalign, "
17613 "attbyval = false\n"
17634 "WHERE attrelid = ");
17637 " AND attname = v.dname;\n");
17649 if (!
tbinfo->attisdropped[
j] &&
17656 "SET attislocal = false\n"
17657 "WHERE attrelid = ");
17660 " AND attname IN (");
17694 if (
tbinfo->notnull_constrs[
j][0] !=
'\0')
17699 "SET conislocal = false\n"
17700 "WHERE contype = 'n' AND conrelid = ");
17715 "SET conislocal = false\n"
17716 "WHERE contype = 'n' AND conrelid = ");
17733 if (extra->
len > 0)
17750 for (k = 0; k <
tbinfo->ncheck; k++)
17767 "SET conislocal = false\n"
17768 "WHERE contype = 'c' AND conrelid = ");
17784 if (numParents > 0 && !
tbinfo->ispartition)
17787 for (k = 0; k < numParents; k++)
17820 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17832 appendPQExpBufferStr(q,
"\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
17834 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17835 "WHERE oid = '%u';\n",
17836 tbinfo->toast_frozenxid,
17853 "SET relispopulated = 't'\n"
17874 if (
tbinfo->attstattarget[
j] >= 0)
17875 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STATISTICS %d;\n",
17886 switch (
tbinfo->attstorage[
j])
17908 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STORAGE %s;\n",
17921 switch (
tbinfo->attcompression[
j])
17935 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET COMPRESSION %s;\n",
17944 if (
tbinfo->attoptions[
j][0] !=
'\0')
17954 tbinfo->attfdwoptions[
j][0] !=
'\0')
17956 "ALTER FOREIGN TABLE ONLY %s ALTER COLUMN %s OPTIONS (\n"
17993 if (
tbinfo->forcerowsec)
18000 tbinfo->dobj.namespace->dobj.name);
18005 char *tableam =
NULL;
18019 tableam =
tbinfo->amname;
18023 .namespace =
tbinfo->dobj.namespace->dobj.name,
18025 .tableam = tableam,
18026 .relkind =
tbinfo->relkind,
18027 .owner =
tbinfo->rolname,
18029 .section =
tbinfo->postponed_def ?
18031 .createStmt = q->
data,
18032 .dropStmt =
delq->data));
18079 .namespace =
tbinfo->dobj.namespace->dobj.name,
18080 .owner =
tbinfo->rolname,
18081 .description =
"COMMENT",
18084 .deps = &(
tbinfo->dobj.dumpId),
18145 "PREPARE dumpTableAttach(pg_catalog.oid) AS\n");
18148 "SELECT pg_get_expr(c.relpartbound, c.oid) "
18150 "WHERE c.oid = $1");
18158 "EXECUTE dumpTableAttach('%u')",
18166 "ALTER TABLE ONLY %s ",
18169 "ATTACH PARTITION %s %s;\n",
18182 .namespace =
attachinfo->dobj.namespace->dobj.name,
18184 .description =
"TABLE ATTACH",
18186 .createStmt = q->
data));
18200 int adnum =
adinfo->adnum;
18223 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET DEFAULT %s;\n",
18236 .
namespace =
tbinfo->dobj.namespace->dobj.name,
18237 .owner =
tbinfo->rolname,
18238 .description =
"DEFAULT",
18240 .createStmt = q->
data,
18241 .dropStmt =
delq->data));
18260 return tblInfo->attnames[attrnum - 1];
18276 pg_fatal(
"invalid column number %d for table \"%s\"",
18277 attrnum,
tblInfo->dobj.name);
18315 char *indstatcols =
indxinfo->indstatcols;
18316 char *indstatvals =
indxinfo->indstatvals;
18349 if (
strlen(indstatcols) != 0 ||
strlen(indstatvals) != 0)
18354 pg_fatal(
"could not parse index statistic columns");
18356 pg_fatal(
"could not parse index statistic values");
18358 pg_fatal(
"mismatched number of columns and values for index statistics");
18377 "pg_catalog.pg_class",
18405 .namespace =
tbinfo->dobj.namespace->dobj.name,
18406 .tablespace =
indxinfo->tablespace,
18407 .owner =
tbinfo->rolname,
18408 .description =
"INDEX",
18410 .createStmt = q->
data,
18411 .dropStmt =
delq->data));
18420 tbinfo->dobj.namespace->dobj.name,
18465 .namespace =
attachinfo->dobj.namespace->dobj.name,
18466 .owner =
attachinfo->parentIdx->indextable->rolname,
18467 .description =
"INDEX ATTACH",
18469 .createStmt = q->
data));
18501 "pg_catalog.pg_get_statisticsobjdef('%u'::pg_catalog.oid)",
18532 .description =
"STATISTICS",
18534 .createStmt = q->
data,
18535 .dropStmt =
delq->data));
18587 "PREPARE getExtStatsStats(pg_catalog.name, pg_catalog.name) AS\n"
18632 "SELECT json_agg( "
18633 " json_build_object( "
18635 " string_to_array(kv.key, ', ')::integer[], "
18637 " kv.value::bigint )) "
18638 "FROM json_each_text(e.n_distinct::text::json) AS kv"
18639 ") AS n_distinct, "
18641 "SELECT json_agg( "
18642 " json_build_object( "
18644 " string_to_array( "
18645 " split_part(kv.key, ' => ', 1), "
18646 " ', ')::integer[], "
18648 " split_part(kv.key, ' => ', 2)::integer, "
18650 " kv.value::double precision )) "
18651 "FROM json_each_text(e.dependencies::text::json) AS kv "
18652 ") AS dependencies, ");
18657 "e.most_common_vals, e.most_common_freqs, "
18658 "e.most_common_base_freqs ");
18661 "NULL AS most_common_vals, NULL AS most_common_freqs, "
18662 "NULL AS most_common_base_freqs ");
18667 "FROM pg_catalog.pg_stats_ext AS e "
18668 "WHERE e.statistics_schemaname = $1 "
18669 "AND e.statistics_name = $2 ");
18673 "SELECT s.stxndistinct AS n_distinct, "
18674 " s.stxdependencies AS dependencies "
18675 "FROM pg_catalog.pg_statistic_ext AS s "
18676 "JOIN pg_catalog.pg_namespace AS n "
18677 "ON n.oid = s.stxnamespace "
18678 "WHERE n.nspname = $1 "
18679 "AND s.stxname = $2 "
18717 for (
int i = 0;
i < nstats;
i++)
18722 pg_fatal(
"inherited cannot be NULL");
18725 "SELECT * FROM pg_catalog.pg_restore_extended_stats(\n");
18770 .description =
"EXTENDED STATISTICS DATA",
18772 .createStmt = out->
data,
18804 if (
coninfo->contype ==
'p' ||
18815 pg_fatal(
"missing index for constraint \"%s\"",
18835 coninfo->contype ==
'p' ?
"PRIMARY KEY" :
"UNIQUE");
18846 for (k = 0; k <
indxinfo->indnkeyattrs; k++)
18856 (k == 0) ?
"" :
", ",
18875 (k ==
indxinfo->indnkeyattrs) ?
"" :
", ",
18926 "pg_catalog.pg_class",
"INDEX",
18939 .
namespace =
tbinfo->dobj.namespace->dobj.name,
18940 .tablespace =
indxinfo->tablespace,
18941 .owner =
tbinfo->rolname,
18942 .description =
"CONSTRAINT",
18944 .createStmt = q->
data,
18945 .dropStmt =
delq->data));
18947 else if (
coninfo->contype ==
'f')
18979 .
namespace =
tbinfo->dobj.namespace->dobj.name,
18980 .owner =
tbinfo->rolname,
18981 .description =
"FK CONSTRAINT",
18983 .createStmt = q->
data,
18984 .dropStmt =
delq->data));
18993 const char *keyword;
18996 keyword =
"CHECK CONSTRAINT";
18998 keyword =
"CONSTRAINT";
19017 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19018 .owner =
tbinfo->rolname,
19019 .description = keyword,
19021 .createStmt = q->
data,
19022 .dropStmt =
delq->data));
19035 const char *keyword;
19038 keyword =
"CHECK CONSTRAINT";
19040 keyword =
"CONSTRAINT";
19058 .
namespace =
tyinfo->dobj.namespace->dobj.name,
19059 .owner =
tyinfo->rolname,
19060 .description = keyword,
19062 .createStmt = q->
data,
19063 .dropStmt =
delq->data));
19074 tyinfo->dobj.namespace->dobj.name,
19084 pg_fatal(
"unrecognized constraint type: %c",
19119 tbinfo->dobj.namespace->dobj.name,
19177 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
19178 "seqstart, seqincrement, "
19180 "seqcache, seqcycle, "
19182 "FROM pg_catalog.pg_sequence "
19183 "ORDER BY seqrelid";
19185 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
19186 "seqstart, seqincrement, "
19188 "seqcache, seqcycle, "
19189 "last_value, is_called "
19190 "FROM pg_catalog.pg_sequence, "
19191 "pg_get_sequence_data(seqrelid) "
19192 "ORDER BY seqrelid;";
19247 key.oid =
tbinfo->dobj.catId.oid;
19262 "SELECT 'bigint' AS sequence_type, "
19263 "start_value, increment_by, max_value, min_value, "
19264 "cache_value, is_cycled FROM %s",
19270 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19271 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19306 pg_fatal(
"unrecognized sequence type: %d",
seq->seqtype);
19313 if (!
tbinfo->is_identity_sequence)
19324 tbinfo->dobj.catId.oid);
19332 if (
tbinfo->is_identity_sequence)
19340 "ALTER COLUMN %s ADD GENERATED ",
19356 "UNLOGGED" :
"LOGGED");
19361 "CREATE %sSEQUENCE %s\n",
19386 seq->cache, (
seq->cycled ?
"\n CYCLE" :
""));
19388 if (
tbinfo->is_identity_sequence)
19398 tbinfo->dobj.namespace->dobj.name);
19403 .namespace =
tbinfo->dobj.namespace->dobj.name,
19404 .owner =
tbinfo->rolname,
19405 .description =
"SEQUENCE",
19407 .createStmt = query->
data,
19408 .dropStmt =
delqry->data));
19426 if (owning_tab ==
NULL)
19427 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
19443 .namespace =
tbinfo->dobj.namespace->dobj.name,
19444 .owner =
tbinfo->rolname,
19445 .description =
"SEQUENCE OWNED BY",
19447 .createStmt = query->
data,
19448 .deps = &(
tbinfo->dobj.dumpId),
19502 "SELECT last_value, is_called FROM %s",
19508 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19509 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19526 key.oid =
tbinfo->dobj.catId.oid;
19531 pg_fatal(
"failed to get data for sequence \"%s\"; user may lack "
19532 "SELECT privilege on the sequence or the sequence may "
19533 "have been concurrently dropped",
19544 last, (
called ?
"true" :
"false"));
19549 .namespace =
tbinfo->dobj.namespace->dobj.name,
19550 .owner =
tbinfo->rolname,
19551 .description =
"SEQUENCE SET",
19553 .createStmt = query->
data,
19554 .deps = &(
tbinfo->dobj.dumpId),
19595 "pg_catalog.pg_trigger",
"TRIGGER",
19598 if (
tginfo->tgispartition)
19613 switch (
tginfo->tgenabled)
19633 else if (
tginfo->tgenabled !=
't' &&
tginfo->tgenabled !=
'O')
19638 switch (
tginfo->tgenabled)
19666 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19667 .owner =
tbinfo->rolname,
19668 .description =
"TRIGGER",
19670 .createStmt = query->
data,
19671 .dropStmt =
delqry->data));
19723 if (
evtinfo->evtenabled !=
'O')
19756 .description =
"EVENT TRIGGER",
19758 .createStmt = query->
data,
19759 .dropStmt =
delqry->data));
19846 "SELECT pg_catalog.pg_get_ruledef('%u'::pg_catalog.oid)",
19852 pg_fatal(
"query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
19915 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19916 .owner =
tbinfo->rolname,
19917 .description =
"RULE",
19919 .createStmt = cmd->
data,
19920 .dropStmt =
delcmd->data));
19925 tbinfo->dobj.namespace->dobj.name,
19968 "classid, objid, refobjid "
19970 "WHERE refclassid = 'pg_extension'::regclass "
19971 "AND deptype = 'e' "
19989 for (
i = 0;
i < ntups;
i++)
20071 char *extcondition =
curext->extcondition;
20083 curext->dobj.catId.oid))
20092 curext->dobj.catId.oid))
20095 if (
strlen(extconfig) != 0 ||
strlen(extcondition) != 0)
20100 pg_fatal(
"could not parse %s array",
"extconfig");
20102 pg_fatal(
"could not parse %s array",
"extcondition");
20104 pg_fatal(
"mismatched number of configurations and conditions for extension");
20130 if (
configtbl->dobj.namespace->dobj.dump &
20143 configtbl->dobj.namespace->dobj.catId.oid))
20175 "SELECT conrelid, confrelid "
20176 "FROM pg_constraint "
20177 "JOIN pg_depend ON (objid = confrelid) "
20178 "WHERE contype = 'f' "
20179 "AND refclassid = 'pg_extension'::regclass "
20180 "AND classid = 'pg_class'::regclass;");
20189 for (
i = 0;
i < ntups;
i++)
20203 contable ==
NULL ||
20249 "classid, objid, refclassid, refobjid, deptype "
20251 "WHERE deptype != 'p' AND deptype != 'e'\n");
20264 "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
20265 "FROM pg_depend d, pg_amop o "
20266 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20267 "classid = 'pg_amop'::regclass AND objid = o.oid "
20268 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
20272 "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
20273 "FROM pg_depend d, pg_amproc p "
20274 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20275 "classid = 'pg_amproc'::regclass AND objid = p.oid "
20276 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
20298 for (
i = 0;
i < ntups;
i++)
20310 if (dobj ==
NULL ||
20345 if (deptype ==
'x')
20355 if (deptype ==
'i' &&
20470 if (((
RuleInfo *) dobj)->separate)
20549 if (dobj->
nDeps <= 0)
20557 &dependencies, &nDeps, &allocDeps);
20566 free(dependencies);
20573 DumpId **dependencies,
int *nDeps,
int *allocDeps)
20592 if (*nDeps >= *allocDeps)
20597 (*dependencies)[*nDeps] =
depid;
20611 dependencies, nDeps, allocDeps);
20648 appendPQExpBuffer(query,
"SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
20680 int numatts =
ti->numatts;
20681 char **attnames =
ti->attnames;
20682 bool *attisdropped =
ti->attisdropped;
20683 char *attgenerated =
ti->attgenerated;
20689 for (
i = 0;
i < numatts;
i++)
20691 if (attisdropped[
i])
20693 if (attgenerated[
i])
20705 return buffer->
data;
20715 return (reloptions !=
NULL &&
strlen(reloptions) > 2);
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 StaticAssertDecl(condition, errmessage)
#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)
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)
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
#define MinTransactionIdAttributeNumber
#define MaxCommandIdAttributeNumber
#define MaxTransactionIdAttributeNumber
#define TableOidAttributeNumber
#define SelfItemPointerAttributeNumber
#define MinCommandIdAttributeNumber
static StringInfo copybuf
static void * fn(void *arg)
#define FirstNormalObjectId
bool SplitGUCList(char *rawstring, char separator, List **namelist)