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\")",
856 pg_fatal(
"option %s is not supported with parallel backup",
857 "--include-foreign-data");
864 pg_fatal(
"option %s requires option %s",
865 "--if-exists",
"-c/--clean");
885 pg_fatal(
"option %s requires option %s, %s, or %s",
886 "--on-conflict-do-nothing",
887 "--inserts",
"--rows-per-insert",
"--column-inserts");
903 pg_fatal(
"could not generate restrict key");
908 pg_fatal(
"option %s can only be used with %s",
909 "--restrict-key",
"--format=plain");
931 pg_fatal(
"unrecognized compression algorithm: \"%s\"",
938 pg_fatal(
"invalid compression specification: %s",
951 pg_log_warning(
"compression option \"%s\" is not currently supported by pg_dump",
963 pg_fatal(
"parallel backup only supported by the directory format");
1018 pg_fatal(
"no matching schemas were found");
1035 pg_fatal(
"no matching tables were found");
1063 pg_fatal(
"no matching extensions were found");
1120 shdepend->dataObj->filtercond =
"WHERE classid = 'pg_largeobject'::regclass "
1121 "AND dbid = (SELECT oid FROM pg_database "
1122 " WHERE datname = current_database())";
1293 printf(
_(
"%s exports a PostgreSQL database as an SQL script or to other formats.\n\n"),
progname);
1297 printf(
_(
"\nGeneral options:\n"));
1298 printf(
_(
" -f, --file=FILENAME output file or directory name\n"));
1299 printf(
_(
" -F, --format=c|d|t|p output file format (custom, directory, tar,\n"
1300 " plain text (default))\n"));
1301 printf(
_(
" -j, --jobs=NUM use this many parallel jobs to dump\n"));
1302 printf(
_(
" -v, --verbose verbose mode\n"));
1303 printf(
_(
" -V, --version output version information, then exit\n"));
1304 printf(
_(
" -Z, --compress=METHOD[:DETAIL]\n"
1305 " compress as specified\n"));
1306 printf(
_(
" --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock\n"));
1307 printf(
_(
" --no-sync do not wait for changes to be written safely to disk\n"));
1308 printf(
_(
" --sync-method=METHOD set method for syncing files to disk\n"));
1309 printf(
_(
" -?, --help show this help, then exit\n"));
1311 printf(
_(
"\nOptions controlling the output content:\n"));
1312 printf(
_(
" -a, --data-only dump only the data, not the schema or statistics\n"));
1313 printf(
_(
" -b, --large-objects include large objects in dump\n"));
1314 printf(
_(
" --blobs (same as --large-objects, deprecated)\n"));
1315 printf(
_(
" -B, --no-large-objects exclude large objects in dump\n"));
1316 printf(
_(
" --no-blobs (same as --no-large-objects, deprecated)\n"));
1317 printf(
_(
" -c, --clean clean (drop) database objects before recreating\n"));
1318 printf(
_(
" -C, --create include commands to create database in dump\n"));
1319 printf(
_(
" -e, --extension=PATTERN dump the specified extension(s) only\n"));
1320 printf(
_(
" -E, --encoding=ENCODING dump the data in encoding ENCODING\n"));
1321 printf(
_(
" -n, --schema=PATTERN dump the specified schema(s) only\n"));
1322 printf(
_(
" -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
1323 printf(
_(
" -O, --no-owner skip restoration of object ownership in\n"
1324 " plain-text format\n"));
1325 printf(
_(
" -s, --schema-only dump only the schema, no data or statistics\n"));
1326 printf(
_(
" -S, --superuser=NAME superuser user name to use in plain-text format\n"));
1327 printf(
_(
" -t, --table=PATTERN dump only the specified table(s)\n"));
1328 printf(
_(
" -T, --exclude-table=PATTERN do NOT dump the specified table(s)\n"));
1329 printf(
_(
" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
1330 printf(
_(
" --binary-upgrade for use by upgrade utilities only\n"));
1331 printf(
_(
" --column-inserts dump data as INSERT commands with column names\n"));
1332 printf(
_(
" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
1333 printf(
_(
" --disable-triggers disable triggers during data-only restore\n"));
1334 printf(
_(
" --enable-row-security enable row security (dump only content user has\n"
1336 printf(
_(
" --exclude-extension=PATTERN do NOT dump the specified extension(s)\n"));
1337 printf(
_(
" --exclude-table-and-children=PATTERN\n"
1338 " do NOT dump the specified table(s), including\n"
1339 " child and partition tables\n"));
1340 printf(
_(
" --exclude-table-data=PATTERN do NOT dump data for the specified table(s)\n"));
1341 printf(
_(
" --exclude-table-data-and-children=PATTERN\n"
1342 " do NOT dump data for the specified table(s),\n"
1343 " including child and partition tables\n"));
1344 printf(
_(
" --extra-float-digits=NUM override default setting for extra_float_digits\n"));
1345 printf(
_(
" --filter=FILENAME include or exclude objects and data from dump\n"
1346 " based on expressions in FILENAME\n"));
1347 printf(
_(
" --if-exists use IF EXISTS when dropping objects\n"));
1348 printf(
_(
" --include-foreign-data=PATTERN\n"
1349 " include data of foreign tables on foreign\n"
1350 " servers matching PATTERN\n"));
1351 printf(
_(
" --inserts dump data as INSERT commands, rather than COPY\n"));
1352 printf(
_(
" --load-via-partition-root load partitions via the root table\n"));
1353 printf(
_(
" --no-comments do not dump comment commands\n"));
1354 printf(
_(
" --no-data do not dump data\n"));
1355 printf(
_(
" --no-policies do not dump row security policies\n"));
1356 printf(
_(
" --no-publications do not dump publications\n"));
1357 printf(
_(
" --no-schema do not dump schema\n"));
1358 printf(
_(
" --no-security-labels do not dump security label assignments\n"));
1359 printf(
_(
" --no-statistics do not dump statistics\n"));
1360 printf(
_(
" --no-subscriptions do not dump subscriptions\n"));
1361 printf(
_(
" --no-table-access-method do not dump table access methods\n"));
1362 printf(
_(
" --no-tablespaces do not dump tablespace assignments\n"));
1363 printf(
_(
" --no-toast-compression do not dump TOAST compression methods\n"));
1364 printf(
_(
" --no-unlogged-table-data do not dump unlogged table data\n"));
1365 printf(
_(
" --on-conflict-do-nothing add ON CONFLICT DO NOTHING to INSERT commands\n"));
1366 printf(
_(
" --quote-all-identifiers quote all identifiers, even if not key words\n"));
1367 printf(
_(
" --restrict-key=RESTRICT_KEY use provided string as psql \\restrict key\n"));
1368 printf(
_(
" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
1369 printf(
_(
" --section=SECTION dump named section (pre-data, data, or post-data)\n"));
1370 printf(
_(
" --sequence-data include sequence data in dump\n"));
1371 printf(
_(
" --serializable-deferrable wait until the dump can run without anomalies\n"));
1372 printf(
_(
" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
1373 printf(
_(
" --statistics dump the statistics\n"));
1374 printf(
_(
" --statistics-only dump only the statistics, not schema or data\n"));
1375 printf(
_(
" --strict-names require table and/or schema include patterns to\n"
1376 " match at least one entity each\n"));
1377 printf(
_(
" --table-and-children=PATTERN dump only the specified table(s), including\n"
1378 " child and partition tables\n"));
1379 printf(
_(
" --use-set-session-authorization\n"
1380 " use SET SESSION AUTHORIZATION commands instead of\n"
1381 " ALTER OWNER commands to set ownership\n"));
1383 printf(
_(
"\nConnection options:\n"));
1384 printf(
_(
" -d, --dbname=DBNAME database to dump\n"));
1385 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
1386 printf(
_(
" -p, --port=PORT database server port number\n"));
1387 printf(
_(
" -U, --username=NAME connect as specified database user\n"));
1388 printf(
_(
" -w, --no-password never prompt for password\n"));
1389 printf(
_(
" -W, --password force password prompt (should happen automatically)\n"));
1390 printf(
_(
" --role=ROLENAME do SET ROLE before dump\n"));
1392 printf(
_(
"\nIf no database name is supplied, then the PGDATABASE environment\n"
1393 "variable value is used.\n\n"));
1413 pg_fatal(
"invalid client encoding \"%s\" specified",
1546 "SET TRANSACTION ISOLATION LEVEL "
1547 "SERIALIZABLE, READ ONLY, DEFERRABLE");
1550 "SET TRANSACTION ISOLATION LEVEL "
1551 "REPEATABLE READ, READ ONLY");
1573 pg_fatal(
"parallel dumps from standby servers are not supported by this server version");
1597 char *query =
"SELECT pg_catalog.pg_export_snapshot()";
1673 "SELECT oid FROM pg_catalog.pg_namespace n\n");
1679 pg_fatal(
"improper qualified name (too many dotted names): %s",
1687 pg_fatal(
"no matching schemas were found for pattern \"%s\"", cell->
val);
1730 "SELECT oid FROM pg_catalog.pg_extension e\n");
1735 pg_fatal(
"improper qualified name (too many dotted names): %s",
1740 pg_fatal(
"no matching extensions were found for pattern \"%s\"", cell->
val);
1783 "SELECT oid FROM pg_catalog.pg_foreign_server s\n");
1788 pg_fatal(
"improper qualified name (too many dotted names): %s",
1793 pg_fatal(
"no matching foreign servers were found for pattern \"%s\"", cell->
val);
1850 "\nFROM pg_catalog.pg_class c"
1851 "\n LEFT JOIN pg_catalog.pg_namespace n"
1852 "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace"
1853 "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY"
1854 "\n (array['%c', '%c', '%c', '%c', '%c', '%c', '%c'])\n",
1860 false,
"n.nspname",
"c.relname",
NULL,
1861 "pg_catalog.pg_table_is_visible(c.oid)", &
dbbuf,
1864 pg_fatal(
"improper relation name (too many dotted names): %s",
1873 "\nSELECT i.inhrelid"
1874 "\nFROM partition_tree p"
1875 "\n JOIN pg_catalog.pg_inherits i"
1876 "\n ON p.relid OPERATOR(pg_catalog.=) i.inhparent"
1878 "\nSELECT relid FROM partition_tree");
1886 pg_fatal(
"no matching tables were found for pattern \"%s\"", cell->
val);
1913 pg_fatal(
"You are currently not connected to a database.");
1916 pg_fatal(
"cross-database references are not implemented: %s",
2001 nsinfo->dobj.catId.oid) ?
2048 if (
nsinfo->dobj.dump_contains &&
2079 tbinfo->dobj.catId.oid) ?
2082 tbinfo->dobj.dump =
tbinfo->dobj.namespace->dobj.dump_contains;
2140 tyinfo->dobj.dump =
tyinfo->dobj.namespace->dobj.dump_contains;
2156 if (
dinfo->dobj.namespace)
2158 dinfo->dobj.dump =
dinfo->dobj.namespace->dobj.dump_contains;
2329 sobj->dobj.dump =
sobj->dobj.namespace->dobj.dump_contains;
2351 if (dobj->namespace)
2382 pg_log_info(
"dumping contents of table \"%s.%s\"",
2383 tbinfo->dobj.namespace->dobj.name, classname);
2495 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetCopyData() failed.", classname);
2505 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetResult() failed.", classname);
2514 pg_log_warning(
"unexpected extra results during COPY of table \"%s\"",
2575 attgenerated[nfields] =
tbinfo->attgenerated[
i];
2596 pg_fatal(
"wrong number of fields retrieved from table \"%s\"",
2617 if (
tbinfo->ispartition &&
2638 for (
int field = 0; field < nfields; field++)
2648 if (
tbinfo->needs_override)
2655 for (
int tuple = 0; tuple <
PQntuples(res); tuple++)
2681 for (
int field = 0; field < nfields; field++)
2685 if (attgenerated[field])
2718 const char *s =
PQgetvalue(res, tuple, field);
2877 if (
tbinfo->ispartition &&
2924 .namespace =
tbinfo->dobj.namespace->dobj.name,
2925 .owner =
tbinfo->rolname,
2926 .description =
"TABLE DATA",
2929 .copyStmt = copyStmt,
2930 .deps = &(
tbinfo->dobj.dumpId),
2978 if (!
tbinfo->relispopulated)
2991 .namespace =
tbinfo->dobj.namespace->dobj.name,
2992 .owner =
tbinfo->rolname,
2993 .description =
"MATERIALIZED VIEW DATA",
2995 .createStmt = q->
data,
2996 .deps =
tdinfo->dobj.dependencies,
2997 .nDeps =
tdinfo->dobj.nDeps));
3014 (!relkind || tblinfo[
i].
relkind == relkind))
3047 tbinfo->foreign_server)))
3077 tdinfo->dobj.catId.tableoid = 0;
3105 tbinfo->interesting =
true;
3134 "SELECT d1.objid, d2.refobjid, c2.relkind AS refrelkind "
3135 "FROM pg_depend d1 "
3136 "JOIN pg_class c1 ON c1.oid = d1.objid "
3138 " JOIN pg_rewrite r1 ON r1.ev_class = d1.objid "
3139 "JOIN pg_depend d2 ON d2.classid = 'pg_rewrite'::regclass "
3140 "AND d2.objid = r1.oid "
3141 "AND d2.refobjid <> d1.objid "
3142 "JOIN pg_class c2 ON c2.oid = d2.refobjid "
3145 "WHERE d1.classid = 'pg_class'::regclass "
3147 "SELECT w.objid, d3.refobjid, c3.relkind "
3149 "JOIN pg_rewrite r3 ON r3.ev_class = w.refobjid "
3150 "JOIN pg_depend d3 ON d3.classid = 'pg_rewrite'::regclass "
3151 "AND d3.objid = r3.oid "
3152 "AND d3.refobjid <> w.refobjid "
3153 "JOIN pg_class c3 ON c3.oid = d3.refobjid "
3157 "SELECT 'pg_class'::regclass::oid AS classid, objid, refobjid "
3169 for (
i = 0;
i < ntups;
i++)
3210 tbinfo->relispopulated =
false;
3260 ftable->dataObj->dobj.dumpId);
3324 "pg_encoding_to_char(encoding) AS encoding, "
3325 "datcollate, datctype, datfrozenxid, "
3326 "datacl, acldefault('d', datdba) AS acldefault, "
3327 "datistemplate, datconnlimit, ");
3343 "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
3344 "shobj_description(oid, 'pg_database') AS description "
3346 "WHERE datname = current_database()");
3409 "CREATE DATABASE %s WITH TEMPLATE = template0 "
3410 "OID = %u STRATEGY = FILE_COPY",
3432 pg_fatal(
"unrecognized locale provider: %s",
3435 if (
strlen(collate) > 0 &&
strcmp(collate, ctype) == 0)
3511 .dropStmt =
delQry->data));
3540 .description =
"COMMENT",
3542 .createStmt =
dbQry->data,
3564 .description =
"SECURITY LABEL",
3612 "SET datistemplate = false WHERE datname = ");
3633 "SET datfrozenxid = '%u', datminmxid = '%u'\n"
3635 frozenxid, minmxid);
3647 .dropStmt =
delQry->data,
3675 "FROM pg_catalog.pg_class\n"
3676 "WHERE oid IN (%u, %u, %u, %u);\n",
3681 "FROM pg_catalog.pg_class\n"
3682 "WHERE oid IN (%u, %u);\n",
3719 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
3720 "WHERE oid = %u;\n",
3728 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
3733 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
3738 "TRUNCATE pg_catalog.pg_largeobject;\n");
3740 "TRUNCATE pg_catalog.pg_largeobject_metadata;\n");
3790 "WHERE setrole = 0 AND setdatabase = '%u'::oid",
3804 "FROM pg_db_role_setting s, pg_roles r "
3805 "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
3840 .createStmt = qry->
data));
3855 pg_log_info(
"saving \"standard_conforming_strings = %s\"",
3865 .createStmt = qry->
data));
3891 "SELECT pg_catalog.current_schemas(false)");
3894 pg_fatal(
"could not parse result of current_schemas()");
3919 .createStmt = qry->
data));
3956 "SELECT oid, lomowner, lomacl, "
3957 "acldefault('L', lomowner) AS acldefault "
3958 "FROM pg_largeobject_metadata ");
3970 "(SELECT objoid FROM pg_description "
3972 "UNION SELECT objoid FROM pg_seclabel "
3976 "ORDER BY lomowner, lomacl::pg_catalog.text, oid");
3995 for (
i = 0;
i < ntups;
i += n)
4030 loinfo->dacl.privtype = 0;
4036 for (
int k = 1; k < n; k++)
4098 for (
int i = 0;
i <
loinfo->numlos;
i++)
4104 .owner =
loinfo->rolname,
4105 .description =
"BLOB METADATA",
4107 .createStmt =
cquery->data,
4108 .dropStmt =
"-- dummy"));
4117 for (
int i = 0;
i <
loinfo->numlos;
i++)
4130 catId, 0,
loinfo->dobj.dumpId);
4135 catId, 0,
loinfo->dobj.dumpId);
4188 for (
int i = 0;
i <
loinfo->numlos;
i++)
4197 pg_fatal(
"could not open large object %u: %s",
4207 pg_fatal(
"error reading large object %u: %s",
4293 polinfo->dobj.catId.tableoid = 0;
4315 pg_log_info(
"reading row-level security policies");
4318 "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
4324 "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
4325 " 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, "
4326 "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
4327 "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
4328 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
4329 "JOIN pg_catalog.pg_policy pol ON (src.tbloid = pol.polrelid)",
4349 for (
j = 0;
j < ntups;
j++)
4433 .namespace =
polinfo->dobj.namespace->dobj.name,
4434 .owner =
tbinfo->rolname,
4435 .description =
"ROW SECURITY",
4437 .createStmt = query->
data,
4438 .deps = &(
tbinfo->dobj.dumpId),
4447 else if (
polinfo->polcmd ==
'r')
4448 cmd =
" FOR SELECT";
4449 else if (
polinfo->polcmd ==
'a')
4450 cmd =
" FOR INSERT";
4451 else if (
polinfo->polcmd ==
'w')
4452 cmd =
" FOR UPDATE";
4453 else if (
polinfo->polcmd ==
'd')
4454 cmd =
" FOR DELETE";
4456 pg_fatal(
"unexpected policy command type: %c",
4468 !
polinfo->polpermissive ?
" AS RESTRICTIVE" :
"", cmd);
4492 .
namespace =
polinfo->dobj.namespace->dobj.name,
4493 .owner =
tbinfo->rolname,
4494 .description =
"POLICY",
4496 .createStmt = query->
data,
4497 .dropStmt =
delqry->data));
4544 "p.pubowner, p.puballtables, p.pubinsert, "
4545 "p.pubupdate, p.pubdelete, ");
4591 for (
i = 0;
i < ntups;
i++)
4646 "FROM pg_catalog.pg_publication_rel\n"
4647 "WHERE prpubid = %u AND prexcept",
4728 else if (
pubinfo->puballsequences)
4779 .description =
"PUBLICATION",
4781 .createStmt = query->
data,
4782 .dropStmt =
delq->data));
4825 "SELECT tableoid, oid, pnpubid, pnnspid "
4826 "FROM pg_catalog.pg_publication_namespace");
4840 for (
i = 0;
i < ntups;
i++)
4909 "SELECT tableoid, oid, prpubid, prrelid, "
4910 "pg_catalog.pg_get_expr(prqual, prrelid) AS prrelqual, "
4912 " WHEN pr.prattrs IS NOT NULL THEN\n"
4913 " (SELECT array_agg(attname)\n"
4915 " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
4916 " pg_catalog.pg_attribute\n"
4917 " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
4918 " ELSE NULL END) prattrs "
4919 "FROM pg_catalog.pg_publication_rel pr");
4925 "SELECT tableoid, oid, prpubid, prrelid, "
4926 "NULL AS prrelqual, NULL AS prattrs "
4927 "FROM pg_catalog.pg_publication_rel");
4943 for (
i = 0;
i < ntups;
i++)
4984 pg_fatal(
"could not parse %s array",
"prattrs");
5043 .description =
"PUBLICATION TABLES IN SCHEMA",
5045 .createStmt = query->
data));
5103 .
namespace =
tbinfo->dobj.namespace->dobj.name,
5105 .description =
"PUBLICATION TABLE",
5107 .createStmt = query->
data));
5144 "SELECT set_config(name, '%s', false) "
5146 "WHERE name = 'restrict_nonsystem_relation_kind'",
5198 "SELECT count(*) FROM pg_subscription "
5199 "WHERE subdbid = (SELECT oid FROM pg_database"
5200 " WHERE datname = current_database())",
5204 pg_log_warning(
"subscriptions not dumped because current user is not a superuser");
5213 "SELECT s.tableoid, s.oid, s.subname,\n"
5215 " s.subconninfo, s.subslotname, s.subsynccommit,\n"
5216 " s.subpublications,\n");
5230 " s.subtwophasestate,\n"
5231 " s.subdisableonerr,\n");
5234 " '%c' AS subtwophasestate,\n"
5235 " false AS subdisableonerr,\n",
5240 " s.subpasswordrequired,\n"
5241 " s.subrunasowner,\n"
5245 " 't' AS subpasswordrequired,\n"
5246 " 't' AS subrunasowner,\n"
5247 " '%s' AS suborigin,\n",
5252 " s.subenabled,\n");
5255 " false AS subenabled,\n");
5259 " s.subfailover,\n");
5262 " false AS subfailover,\n");
5266 " s.subretaindeadtuples,\n");
5269 " false AS subretaindeadtuples,\n");
5273 " s.submaxretention,\n");
5279 " s.subwalrcvtimeout,\n");
5282 " '-1' AS subwalrcvtimeout,\n");
5290 "FROM pg_subscription s\n");
5294 "LEFT JOIN pg_catalog.pg_foreign_server fs \n"
5295 " ON fs.oid = s.subserver \n");
5299 "LEFT JOIN pg_catalog.pg_replication_origin_status o \n"
5300 " ON o.external_id = 'pg_' || s.oid::text \n");
5303 "WHERE s.subdbid = (SELECT oid FROM pg_database\n"
5304 " WHERE datname = current_database())");
5339 for (
i = 0;
i < ntups;
i++)
5352 subinfo[
i].subservername =
NULL;
5426 "SELECT srsubid, srrelid, srsubstate, srsublsn "
5427 "FROM pg_catalog.pg_subscription_rel "
5441 for (
int i = 0;
i < ntups;
i++)
5454 if (subinfo ==
NULL)
5461 if (tblinfo ==
NULL)
5462 pg_fatal(
"failed sanity check, relation with OID %u not found",
5467 subrinfo[
i].dobj.catId.tableoid = relid;
5519 "\n-- For binary upgrade, must preserve the subscriber table.\n");
5521 "SELECT pg_catalog.binary_upgrade_add_sub_rel_state(");
5546 .
namespace =
subrinfo->tblinfo->dobj.namespace->dobj.name,
5548 .description =
"SUBSCRIPTION TABLE",
5550 .createStmt = query->
data));
5600 pg_fatal(
"could not parse %s array",
"subpublications");
5611 appendPQExpBuffer(query,
" PUBLICATION %s WITH (connect = false, slot_name = ", publications->
data);
5677 "\n-- For binary upgrade, must preserve the remote_lsn for the subscriber's replication origin.\n");
5679 "SELECT pg_catalog.binary_upgrade_replorigin_advance(");
5691 "\n-- For binary upgrade, must preserve the subscriber's running state.\n");
5700 .description =
"SUBSCRIPTION",
5702 .createStmt = query->
data,
5703 .dropStmt =
delq->data));
5732 const char *keyword,
5733 const char *objname)
5750 "FROM pg_catalog.pg_depend d, pg_catalog.pg_extension e "
5751 "WHERE d.refobjid = e.oid AND classid = '%s'::pg_catalog.regclass "
5752 "AND objid = '%u'::pg_catalog.oid AND deptype = 'x' "
5753 "AND refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass",
5759 for (
i = 0;
i < ntups;
i++)
5791 "SELECT EXISTS(SELECT 1 "
5792 "FROM pg_catalog.pg_type "
5793 "WHERE oid = '%u'::pg_catalog.oid);",
5819 "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5834 "\n-- For binary upgrade, must preserve pg_type array oid\n");
5836 "SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5848 "SELECT t.oid, t.typarray "
5849 "FROM pg_catalog.pg_type t "
5850 "JOIN pg_catalog.pg_range r "
5851 "ON t.oid = r.rngmultitypid "
5852 "WHERE r.rngtypid = '%u'::pg_catalog.oid;",
5869 "\n-- For binary upgrade, must preserve multirange pg_type oid\n");
5871 "SELECT pg_catalog.binary_upgrade_set_next_multirange_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5874 "\n-- For binary upgrade, must preserve multirange pg_type array oid\n");
5876 "SELECT pg_catalog.binary_upgrade_set_next_multirange_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5920 query =
"SELECT c.oid, c.relkind, c.relfilenode, c.reltoastrelid, "
5921 "ct.relfilenode, i.indexrelid, cti.relfilenode "
5922 "FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_index i "
5923 "ON (c.reltoastrelid = i.indrelid AND i.indisvalid) "
5924 "LEFT JOIN pg_catalog.pg_class ct ON (c.reltoastrelid = ct.oid) "
5925 "LEFT JOIN pg_catalog.pg_class AS cti ON (i.indexrelid = cti.oid) "
5974 "\n-- For binary upgrade, must preserve pg_class oids and relfilenodes\n");
5980 "SELECT pg_catalog.binary_upgrade_set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
5991 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
6002 "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
6005 "SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
6010 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
6013 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
6021 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
6024 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
6041 const char *objtype,
6042 const char *objname,
6065 pg_fatal(
"could not find parent extension for %s %s",
6069 "\n-- For binary upgrade, handle extension membership the hard way\n");
6106 "acldefault('n', n.nspowner) AS acldefault "
6107 "FROM pg_namespace n");
6122 for (
i = 0;
i < ntups;
i++)
6124 const char *nspowner;
6179 nsinfo[
i].dacl.privtype =
'i';
6235 "x.extname, n.nspname, x.extrelocatable, x.extversion, x.extconfig, x.extcondition "
6236 "FROM pg_extension x "
6237 "JOIN pg_namespace n ON n.oid = x.extnamespace");
6256 for (
i = 0;
i < ntups;
i++)
6329 "typnamespace, typacl, "
6330 "acldefault('T', typowner) AS acldefault, "
6332 "typelem, typrelid, typarray, "
6333 "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
6334 "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
6335 "typtype, typisdefined, "
6336 "typname[0] = '_' AND typelem != 0 AND "
6337 "(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray "
6361 for (
i = 0;
i < ntups;
i++)
6395 tyinfo[
i].isMultirange =
true;
6397 tyinfo[
i].isMultirange =
false;
6486 "oprcode::oid AS oprcode "
6487 "FROM pg_operator");
6505 for (
i = 0;
i < ntups;
i++)
6559 "FROM pg_collation");
6574 for (
i = 0;
i < ntups;
i++)
6623 "FROM pg_conversion");
6637 for (
i = 0;
i < ntups;
i++)
6691 "amhandler::pg_catalog.regproc AS amhandler ");
6694 "'i'::pg_catalog.\"char\" AS amtype, "
6695 "'-'::pg_catalog.regproc AS amhandler ");
6710 for (
i = 0;
i < ntups;
i++)
6773 for (
i = 0;
i < ntups;
i++)
6823 "FROM pg_opfamily");
6838 for (
i = 0;
i < ntups;
i++)
6894 "p.proname AS aggname, "
6895 "p.pronamespace AS aggnamespace, "
6896 "p.pronargs, p.proargtypes, "
6898 "p.proacl AS aggacl, "
6899 "acldefault('f', p.proowner) AS acldefault "
6901 "LEFT JOIN pg_init_privs pip ON "
6902 "(p.oid = pip.objoid "
6903 "AND pip.classoid = 'pg_proc'::regclass "
6904 "AND pip.objsubid = 0) "
6906 "p.pronamespace != "
6907 "(SELECT oid FROM pg_namespace "
6908 "WHERE nspname = 'pg_catalog') OR "
6909 "p.proacl IS DISTINCT FROM pip.initprivs",
6913 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6914 "classid = 'pg_proc'::regclass AND "
6915 "objid = p.oid AND "
6916 "refclassid = 'pg_extension'::regclass AND "
6923 "pronamespace AS aggnamespace, "
6924 "pronargs, proargtypes, "
6926 "proacl AS aggacl, "
6927 "acldefault('f', proowner) AS acldefault "
6929 "WHERE proisagg AND ("
6931 "(SELECT oid FROM pg_namespace "
6932 "WHERE nspname = 'pg_catalog')");
6935 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6936 "classid = 'pg_proc'::regclass AND "
6937 "objid = p.oid AND "
6938 "refclassid = 'pg_extension'::regclass AND "
6959 for (
i = 0;
i < ntups;
i++)
6970 agginfo[
i].aggfn.dacl.privtype = 0;
6985 agginfo[
i].aggfn.postponed_def =
false;
7051 :
"NOT p.proisagg");
7054 "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
7055 "p.pronargs, p.proargtypes, p.prorettype, "
7057 "acldefault('f', p.proowner) AS acldefault, "
7061 "LEFT JOIN pg_init_privs pip ON "
7062 "(p.oid = pip.objoid "
7063 "AND pip.classoid = 'pg_proc'::regclass "
7064 "AND pip.objsubid = 0) "
7066 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
7067 "WHERE classid = 'pg_proc'::regclass AND "
7068 "objid = p.oid AND deptype = 'i')"
7070 "\n pronamespace != "
7071 "(SELECT oid FROM pg_namespace "
7072 "WHERE nspname = 'pg_catalog')"
7073 "\n OR EXISTS (SELECT 1 FROM pg_cast"
7074 "\n WHERE pg_cast.oid > %u "
7075 "\n AND p.oid = pg_cast.castfunc)"
7076 "\n OR EXISTS (SELECT 1 FROM pg_transform"
7077 "\n WHERE pg_transform.oid > %u AND "
7078 "\n (p.oid = pg_transform.trffromsql"
7079 "\n OR p.oid = pg_transform.trftosql))",
7085 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
7086 "classid = 'pg_proc'::regclass AND "
7087 "objid = p.oid AND "
7088 "refclassid = 'pg_extension'::regclass AND "
7091 "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
7097 "SELECT tableoid, oid, proname, prolang, "
7098 "pronargs, proargtypes, prorettype, proacl, "
7099 "acldefault('f', proowner) AS acldefault, "
7103 "WHERE NOT proisagg"
7104 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
7105 "WHERE classid = 'pg_proc'::regclass AND "
7106 "objid = p.oid AND deptype = 'i')"
7108 "\n pronamespace != "
7109 "(SELECT oid FROM pg_namespace "
7110 "WHERE nspname = 'pg_catalog')"
7111 "\n OR EXISTS (SELECT 1 FROM pg_cast"
7112 "\n WHERE pg_cast.oid > '%u'::oid"
7113 "\n AND p.oid = pg_cast.castfunc)",
7118 "\n OR EXISTS (SELECT 1 FROM pg_transform"
7119 "\n WHERE pg_transform.oid > '%u'::oid"
7120 "\n AND (p.oid = pg_transform.trffromsql"
7121 "\n OR p.oid = pg_transform.trftosql))",
7126 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
7127 "classid = 'pg_proc'::regclass AND "
7128 "objid = p.oid AND "
7129 "refclassid = 'pg_extension'::regclass AND "
7152 for (
i = 0;
i < ntups;
i++)
7159 finfo[
i].
dobj.namespace =
7169 if (finfo[
i].nargs == 0)
7175 finfo[
i].argtypes, finfo[
i].nargs);
7201 char *reltuples,
int32 relallvisible,
7202 int32 relallfrozen,
char relkind,
7203 char **indAttNames,
int nindAttNames)
7228 dobj->namespace = rel->namespace;
7261 pg_fatal(
"cannot dump statistics for relation kind \"%c\"",
7345 "SELECT c.tableoid, c.oid, c.relname, "
7346 "c.relnamespace, c.relkind, c.reltype, "
7349 "c.relhasindex, c.relhasrules, c.relpages, "
7350 "c.reltuples, c.relallvisible, ");
7358 "c.relhastriggers, c.relpersistence, "
7362 " THEN 's'::\"char\" ELSE 'r'::\"char\" END, c.relowner) AS acldefault, "
7364 "(SELECT ftserver FROM pg_catalog.pg_foreign_table WHERE ftrelid = c.oid) "
7365 "ELSE 0 END AS foreignserver, "
7366 "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, "
7368 "tc.relpages AS toastpages, "
7369 "tc.reloptions AS toast_reloptions, "
7370 "d.refobjid AS owning_tab, "
7371 "d.refobjsubid AS owning_col, "
7372 "tsp.spcname AS reltablespace, ");
7376 "false AS relhasoids, ");
7383 "c.relispopulated, ");
7386 "'t' as relispopulated, ");
7390 "c.relreplident, ");
7393 "'d' AS relreplident, ");
7397 "c.relrowsecurity, c.relforcerowsecurity, ");
7400 "false AS relrowsecurity, "
7401 "false AS relforcerowsecurity, ");
7405 "c.relminmxid, tc.relminmxid AS tminmxid, ");
7408 "0 AS relminmxid, 0 AS tminmxid, ");
7412 "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
7413 "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
7414 "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
7417 "c.reloptions, NULL AS checkoption, ");
7424 "NULL AS amname, ");
7428 "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
7431 "false AS is_identity_sequence, ");
7435 "c.relispartition AS ispartition ");
7438 "false AS ispartition ");
7447 "\nFROM pg_class c\n"
7448 "LEFT JOIN pg_depend d ON "
7450 "d.classid = 'pg_class'::regclass AND d.objid = c.oid AND "
7451 "d.objsubid = 0 AND "
7452 "d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
7453 "LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
7460 "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
7468 "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid"
7483 "WHERE c.relkind IN ("
7569 for (
i = 0;
i < ntups;
i++)
7579 tblinfo[
i].
dobj.namespace =
7672 if (tblinfo[
i].interesting)
7677 tblinfo[
i].relpages,
7679 relallvisible, relallfrozen,
7680 tblinfo[
i].relkind,
NULL, 0);
7682 tblinfo[
i].
stats = stats;
7709 if (query->
len == 0)
7718 if (query->
len >= 100000)
7729 if (query->
len != 0)
7773 if (owning_tab ==
NULL)
7774 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
7799 if (
seqinfo->is_identity_sequence)
7846 for (
i = 0;
i < ntups;
i++)
7901 "SELECT partrelid FROM pg_partitioned_table WHERE\n"
7902 "(SELECT c.oid FROM pg_opclass c JOIN pg_am a "
7903 "ON c.opcmethod = a.oid\n"
7904 "WHERE opcname = 'enum_ops' "
7905 "AND opcnamespace = 'pg_catalog'::regnamespace "
7906 "AND amname = 'hash') = ANY(partclass)");
7912 for (
int i = 0;
i < ntups;
i++)
7919 pg_fatal(
"failed sanity check, table OID %u appearing in pg_partitioned_table not found",
7921 tbinfo->unsafe_partitions =
true;
7994 if (!
tbinfo->interesting)
8005 "SELECT t.tableoid, t.oid, i.indrelid, "
8006 "t.relname AS indexname, "
8007 "t.relpages, t.reltuples, t.relallvisible, ");
8015 "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
8016 "i.indkey, i.indisclustered, "
8017 "c.contype, c.conname, "
8018 "c.condeferrable, c.condeferred, "
8019 "c.tableoid AS contableoid, "
8021 "pg_catalog.pg_get_constraintdef(c.oid, false) AS condef, "
8022 "CASE WHEN i.indexprs IS NOT NULL THEN "
8023 "(SELECT pg_catalog.array_agg(attname ORDER BY attnum)"
8024 " FROM pg_catalog.pg_attribute "
8025 " WHERE attrelid = i.indexrelid) "
8026 "ELSE NULL END AS indattnames, "
8027 "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
8028 "t.reloptions AS indreloptions, ");
8033 "i.indisreplident, ");
8036 "false AS indisreplident, ");
8040 "inh.inhparent AS parentidx, "
8041 "i.indnkeyatts AS indnkeyatts, "
8042 "i.indnatts AS indnatts, "
8043 "(SELECT pg_catalog.array_agg(attnum ORDER BY attnum) "
8044 " FROM pg_catalog.pg_attribute "
8045 " WHERE attrelid = i.indexrelid AND "
8046 " attstattarget >= 0) AS indstatcols, "
8047 "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attnum) "
8048 " FROM pg_catalog.pg_attribute "
8049 " WHERE attrelid = i.indexrelid AND "
8050 " attstattarget >= 0) AS indstatvals, ");
8054 "i.indnatts AS indnkeyatts, "
8055 "i.indnatts AS indnatts, "
8056 "'' AS indstatcols, "
8057 "'' AS indstatvals, ");
8061 "i.indnullsnotdistinct, ");
8064 "false AS indnullsnotdistinct, ");
8071 "NULL AS conperiod ");
8085 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8086 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
8087 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
8088 "JOIN pg_catalog.pg_class t2 ON (t2.oid = i.indrelid) "
8089 "LEFT JOIN pg_catalog.pg_constraint c "
8090 "ON (i.indrelid = c.conrelid AND "
8091 "i.indexrelid = c.conindid AND "
8092 "c.contype IN ('p','u','x')) "
8093 "LEFT JOIN pg_catalog.pg_inherits inh "
8094 "ON (inh.inhrelid = indexrelid) "
8095 "WHERE (i.indisvalid OR t2.relkind = 'p') "
8097 "ORDER BY i.indrelid, indexname",
8107 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8108 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
8109 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
8110 "LEFT JOIN pg_catalog.pg_constraint c "
8111 "ON (i.indrelid = c.conrelid AND "
8112 "i.indexrelid = c.conindid AND "
8113 "c.contype IN ('p','u','x')) "
8114 "WHERE i.indisvalid AND i.indisready "
8115 "ORDER BY i.indrelid, indexname",
8160 for (
int j = 0;
j < ntups;)
8186 pg_fatal(
"unexpected index data for table \"%s\"",
8197 char **indAttNames =
NULL;
8198 int nindAttNames = 0;
8239 &indAttNames, &nindAttNames))
8240 pg_fatal(
"could not parse %s array",
"indattnames");
8246 indAttNames, nindAttNames);
8249 if (contype ==
'p' || contype ==
'u' || contype ==
'x')
8329 "stxnamespace, stxowner, stxrelid, NULL AS stxstattarget "
8330 "FROM pg_catalog.pg_statistic_ext");
8333 "stxnamespace, stxowner, stxrelid, stxstattarget "
8334 "FROM pg_catalog.pg_statistic_ext");
8350 for (
i = 0;
i < ntups;
i++)
8429 "SELECT c.tableoid, c.oid, "
8430 "conrelid, conname, confrelid, ");
8436 "pg_catalog.pg_get_constraintdef(c.oid) AS condef\n"
8437 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8438 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
8439 "WHERE contype = 'f' ",
8443 "AND conparentid = 0 ");
8445 "ORDER BY conrelid, conname");
8462 for (
int j = 0;
j < ntups;
j++)
8476 if (
tbinfo->dobj.catId.oid == conrelid)
8480 pg_fatal(
"unrecognized table OID %u", conrelid);
8513 for (
int k = 0; k <
reftable->numIndexes; k++)
8518 if (
reftable->indexes[k].dobj.catId.oid != indexOid)
8553 for (cell =
refidx->partattaches.head; cell; cell = cell->
next)
8559 if (
attach->partitionIdx->partattaches.head !=
NULL)
8591 "PREPARE getDomainConstraints(pg_catalog.oid) AS\n"
8592 "SELECT tableoid, oid, conname, "
8593 "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
8594 "convalidated, contype "
8595 "FROM pg_catalog.pg_constraint "
8596 "WHERE contypid = $1 AND contype IN (%s) "
8606 "EXECUTE getDomainConstraints('%u')",
8624 for (
int i = 0,
j = 0;
i < ntups;
i++)
8641 constraint =
tyinfo->notnull;
8649 constraint->
dobj.namespace =
tyinfo->dobj.namespace;
8652 constraint->
contype = contype;
8698 "tableoid, oid, rulename, "
8699 "ev_class AS ruletable, ev_type, is_instead, "
8718 for (
i = 0;
i < ntups;
i++)
8730 pg_fatal(
"failed sanity check, parent table with OID %u of pg_rewrite entry with OID %u not found",
8808 if (!
tbinfo->hastriggers ||
8830 "SELECT t.tgrelid, t.tgname, "
8831 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8832 "t.tgenabled, t.tableoid, t.oid, "
8833 "t.tgparentid <> 0 AS tgispartition\n"
8834 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8835 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8836 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8837 "WHERE ((NOT t.tgisinternal AND t.tgparentid = 0) "
8838 "OR t.tgenabled != u.tgenabled) "
8839 "ORDER BY t.tgrelid, t.tgname",
8853 "SELECT t.tgrelid, t.tgname, "
8854 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8855 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition\n"
8856 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8857 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8858 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8859 "WHERE (NOT t.tgisinternal OR t.tgenabled != u.tgenabled) "
8860 "ORDER BY t.tgrelid, t.tgname",
8873 "SELECT t.tgrelid, t.tgname, "
8874 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8875 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition "
8876 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8877 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8878 "LEFT JOIN pg_catalog.pg_depend AS d ON "
8879 " d.classid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8880 " d.refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8882 "LEFT JOIN pg_catalog.pg_trigger AS pt ON pt.oid = refobjid "
8883 "WHERE (NOT t.tgisinternal OR t.tgenabled != pt.tgenabled) "
8884 "ORDER BY t.tgrelid, t.tgname",
8891 "SELECT t.tgrelid, t.tgname, "
8892 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8893 "t.tgenabled, false as tgispartition, "
8894 "t.tableoid, t.oid "
8895 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8896 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8897 "WHERE NOT tgisinternal "
8898 "ORDER BY t.tgrelid, t.tgname",
8921 for (
int j = 0;
j < ntups;)
8998 "SELECT e.tableoid, e.oid, evtname, evtenabled, "
8999 "evtevent, evtowner, "
9000 "array_to_string(array("
9001 "select quote_literal(x) "
9002 " from unnest(evttags) as t(x)), ', ') as evttags, "
9003 "e.evtfoid::regproc as evtfname "
9004 "FROM pg_event_trigger e "
9022 for (
i = 0;
i < ntups;
i++)
9072 "lanname, lanpltrusted, lanplcallfoid, "
9073 "laninline, lanvalidator, "
9075 "acldefault('l', lanowner) AS acldefault, "
9098 for (
i = 0;
i < ntups;
i++)
9155 "castsource, casttarget, castfunc, castcontext, "
9158 "WHERE NOT EXISTS ( "
9159 "SELECT 1 FROM pg_range r "
9160 "WHERE c.castsource = r.rngtypid "
9161 "AND c.casttarget = r.rngmultitypid "
9168 "castsource, casttarget, castfunc, castcontext, "
9170 "FROM pg_cast ORDER BY 3,4");
9187 for (
i = 0;
i < ntups;
i++)
9233 appendPQExpBuffer(query,
"SELECT lanname FROM pg_language WHERE oid = %u", langid);
9268 "trftype, trflang, trffromsql::oid, trftosql::oid "
9269 "FROM pg_transform "
9285 for (
i = 0;
i < ntups;
i++)
9394 if (!
tbinfo->interesting &&
9428 "a.attstattarget,\n"
9436 "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n"
9437 "array_to_string(a.attoptions, ', ') AS attoptions,\n"
9438 "CASE WHEN a.attcollation <> t.typcollation "
9439 "THEN a.attcollation ELSE 0 END AS attcollation,\n"
9440 "pg_catalog.array_to_string(ARRAY("
9441 "SELECT pg_catalog.quote_ident(option_name) || "
9442 "' ' || pg_catalog.quote_literal(option_value) "
9443 "FROM pg_catalog.pg_options_to_table(attfdwoptions) "
9444 "ORDER BY option_name"
9445 "), E',\n ') AS attfdwoptions,\n");
9467 "co.conname AS notnull_name,\n"
9468 "CASE WHEN co.convalidated THEN pt.description"
9469 " ELSE NULL END AS notnull_comment,\n"
9470 "CASE WHEN NOT co.convalidated THEN co.oid "
9471 "ELSE NULL END AS notnull_invalidoid,\n"
9472 "co.connoinherit AS notnull_noinherit,\n"
9473 "co.conislocal AS notnull_islocal,\n");
9476 "CASE WHEN a.attnotnull THEN '' ELSE NULL END AS notnull_name,\n"
9477 "NULL AS notnull_comment,\n"
9478 "NULL AS notnull_invalidoid,\n"
9479 "false AS notnull_noinherit,\n"
9480 "CASE WHEN a.attislocal THEN true\n"
9481 " WHEN a.attnotnull AND NOT a.attislocal THEN true\n"
9483 "END AS notnull_islocal,\n");
9487 "a.attcompression AS attcompression,\n");
9490 "'' AS attcompression,\n");
9494 "a.attidentity,\n");
9497 "'' AS attidentity,\n");
9501 "CASE WHEN a.atthasmissing AND NOT a.attisdropped "
9502 "THEN a.attmissingval ELSE null END AS attmissingval,\n");
9505 "NULL AS attmissingval,\n");
9509 "a.attgenerated\n");
9512 "'' AS attgenerated\n");
9516 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9517 "JOIN pg_catalog.pg_attribute a ON (src.tbloid = a.attrelid) "
9518 "LEFT JOIN pg_catalog.pg_type t "
9519 "ON (a.atttypid = t.oid)\n",
9528 " LEFT JOIN pg_catalog.pg_constraint co ON "
9529 "(a.attrelid = co.conrelid\n"
9530 " AND co.contype = 'n' AND "
9531 "co.conkey = array[a.attnum])\n"
9532 " LEFT JOIN pg_catalog.pg_description pt ON "
9533 "(pt.classoid = co.tableoid AND pt.objoid = co.oid)\n");
9536 "WHERE a.attnum > 0::pg_catalog.int2\n");
9544 "OR (a.attnum = -2::pg_catalog.int2 AND src.tbloid = "
9548 "ORDER BY a.attrelid, a.attnum");
9588 for (
int r = 0; r < ntups;)
9596 for (numatts = 1; numatts < ntups - r; numatts++)
9607 if (
tbinfo->dobj.catId.oid == attrelid)
9611 pg_fatal(
"unrecognized table OID %u", attrelid);
9618 pg_fatal(
"unexpected column data for table \"%s\"",
9622 tbinfo->numatts = numatts;
9647 for (
int j = 0;
j < numatts;
j++, r++)
9652 pg_fatal(
"invalid column numbering in table \"%s\"",
9657 tbinfo->attstattarget[
j] = -1;
9722 "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc\n"
9723 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9724 "JOIN pg_catalog.pg_attrdef a ON (src.tbloid = a.adrelid)\n"
9725 "ORDER BY a.adrelid, a.adnum",
9759 pg_fatal(
"invalid adnum value %d for table \"%s\"",
9760 adnum,
tbinfo->dobj.name);
9766 if (
tbinfo->attisdropped[adnum - 1])
9774 attrdefs[
j].
adnum = adnum;
9778 attrdefs[
j].
dobj.namespace =
tbinfo->dobj.namespace;
9789 if (
tbinfo->attgenerated[adnum - 1])
9819 if (!attrdefs[
j].separate)
9831 tbinfo->attrdefs[adnum - 1] = &attrdefs[
j];
9852 pg_log_info(
"finding invalid not-null constraints");
9856 "SELECT c.tableoid, c.oid, conrelid, conname, "
9857 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9858 "conislocal, convalidated "
9859 "FROM unnest('%s'::pg_catalog.oid[]) AS src(conoid)\n"
9860 "JOIN pg_catalog.pg_constraint c ON (src.conoid = c.oid)\n"
9861 "ORDER BY c.conrelid, c.conname",
9896 if (
tbinfo->dobj.catId.oid == conrelid)
9900 pg_fatal(
"unrecognized table OID %u", conrelid);
9954 "SELECT c.tableoid, c.oid, conrelid, conname, "
9955 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9956 "conislocal, convalidated "
9957 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9958 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
9959 "WHERE contype = 'c' "
9960 "ORDER BY c.conrelid, c.conname",
9996 if (
tbinfo->dobj.catId.oid == conrelid)
10000 pg_fatal(
"unrecognized table OID %u", conrelid);
10005 "expected %d check constraints on table \"%s\" but found %d",
10156 tbinfo->notnull_invalid[
j] =
true;
10169 tbinfo->notnull_invalid[
j] =
false;
10186 tbinfo->notnull_constrs[
j] =
"";
10201 !
tbinfo->notnull_islocal[
j]) ||
10216 tbinfo->notnull_constrs[
j] =
"";
10250 if (
tbinfo->attisdropped[colno])
10252 return (
tbinfo->attislocal[colno] ||
tbinfo->ispartition);
10286 "prsstart::oid, prstoken::oid, "
10287 "prsend::oid, prsheadline::oid, prslextype::oid "
10288 "FROM pg_ts_parser");
10306 for (
i = 0;
i < ntups;
i++)
10353 "dictnamespace, dictowner, "
10354 "dicttemplate, dictinitoption "
10355 "FROM pg_ts_dict");
10371 for (
i = 0;
i < ntups;
i++)
10418 "tmplnamespace, tmplinit::oid, tmpllexize::oid "
10419 "FROM pg_ts_template");
10434 for (
i = 0;
i < ntups;
i++)
10477 "cfgnamespace, cfgowner, cfgparser "
10478 "FROM pg_ts_config");
10493 for (
i = 0;
i < ntups;
i++)
10541 "fdwhandler::pg_catalog.regproc, "
10542 "fdwvalidator::pg_catalog.regproc, ");
10551 "acldefault('F', fdwowner) AS acldefault, "
10552 "array_to_string(ARRAY("
10553 "SELECT quote_ident(option_name) || ' ' || "
10554 "quote_literal(option_value) "
10555 "FROM pg_options_to_table(fdwoptions) "
10556 "ORDER BY option_name"
10557 "), E',\n ') AS fdwoptions "
10558 "FROM pg_foreign_data_wrapper");
10577 for (
i = 0;
i < ntups;
i++)
10635 "srvfdw, srvtype, srvversion, srvacl, "
10636 "acldefault('S', srvowner) AS acldefault, "
10637 "array_to_string(ARRAY("
10638 "SELECT quote_ident(option_name) || ' ' || "
10639 "quote_literal(option_value) "
10640 "FROM pg_options_to_table(srvoptions) "
10641 "ORDER BY option_name"
10642 "), E',\n ') AS srvoptions "
10643 "FROM pg_foreign_server");
10662 for (
i = 0;
i < ntups;
i++)
10732 "SELECT oid, tableoid, "
10734 "defaclnamespace, "
10737 "CASE WHEN defaclnamespace = 0 THEN "
10738 "acldefault(CASE WHEN defaclobjtype = 'S' "
10739 "THEN 's'::\"char\" ELSE defaclobjtype END, "
10740 "defaclrole) ELSE '{}' END AS acldefault "
10741 "FROM pg_default_acl");
10757 for (
i = 0;
i < ntups;
i++)
10810 while (low <= high)
10816 else if (roleoid >
middle->roleoid)
10823 pg_fatal(
"role with OID %u does not exist", roleoid);
10840 query =
"SELECT oid, rolname FROM pg_catalog.pg_roles ORDER BY 1";
10878 "SELECT DISTINCT attrelid FROM pg_attribute "
10879 "WHERE attacl IS NOT NULL");
10884 for (
i = 0;
i < ntups;
i++)
10903 "SELECT objoid, classoid, objsubid, privtype, initprivs "
10904 "FROM pg_init_privs");
10909 for (
i = 0;
i < ntups;
i++)
10920 objId.
oid = objoid;
10932 ((
TableInfo *) dobj)->hascolumnACLs =
true;
10936 classoid, objoid, objsubid);
10960 daobj->dacl.privtype = privtype;
10965 classoid, objoid, objsubid);
10999 const char *
name,
const char *
namespace,
11000 const char *owner,
CatalogId catalogId,
11001 int subid,
DumpId dumpId,
11064 if (
namespace && *
namespace)
11079 .namespace =
namespace,
11081 .description =
"COMMENT",
11083 .createStmt = query->
data,
11099 const char *
name,
const char *
namespace,
11100 const char *owner,
CatalogId catalogId,
11101 int subid,
DumpId dumpId)
11104 catalogId, subid, dumpId,
NULL);
11115 const char *argtype,
const char *
argval)
11286 pg_fatal(
"statistics dumped out of order (current: %d %s %s, expected: %d %s %s)",
11295 "PREPARE getAttributeStats(pg_catalog.oid[]) AS\n");
11298 "PREPARE getAttributeStats(pg_catalog.name[], pg_catalog.name[]) AS\n");
11301 "SELECT s.schemaname, s.tablename, s.attname, s.inherited, "
11302 "s.null_frac, s.avg_width, s.n_distinct, "
11303 "s.most_common_vals, s.most_common_freqs, "
11304 "s.histogram_bounds, s.correlation, "
11305 "s.most_common_elems, s.most_common_elem_freqs, "
11306 "s.elem_count_histogram, ");
11310 "s.range_length_histogram, "
11311 "s.range_empty_frac, "
11312 "s.range_bounds_histogram ");
11315 "NULL AS range_length_histogram,"
11316 "NULL AS range_empty_frac,"
11317 "NULL AS range_bounds_histogram ");
11336 "FROM pg_catalog.pg_stats s "
11337 "JOIN unnest($1) WITH ORDINALITY AS u (tableid, ord) "
11338 "ON s.tableid = u.tableid "
11339 "ORDER BY u.ord, s.attname, s.inherited");
11342 "FROM pg_catalog.pg_stats s "
11343 "JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
11344 "ON s.schemaname = u.schemaname "
11345 "AND s.tablename = u.tablename "
11346 "WHERE s.tablename = ANY($2) "
11347 "ORDER BY u.ord, s.attname, s.inherited");
11350 "FROM pg_catalog.pg_stats s "
11351 "WHERE s.schemaname = $1[1] "
11352 "AND s.tablename = $2[1] "
11353 "ORDER BY s.attname, s.inherited");
11423 for (; rownum <
PQntuples(res); rownum++)
11441 pg_fatal(
"unexpected null attname");
11449 if (
rsinfo->nindAttNames == 0)
11456 bool found =
false;
11458 for (
int i = 0;
i <
rsinfo->nindAttNames;
i++)
11543 .namespace = dobj->namespace->dobj.
name,
11544 .description =
"STATISTICS DATA",
11545 .section =
rsinfo->section,
11549 .nDeps = dobj->
nDeps));
11607 .namespace =
tbinfo->dobj.namespace->dobj.name,
11608 .owner =
tbinfo->rolname,
11609 .description =
"COMMENT",
11611 .createStmt = query->
data,
11612 .deps = &(
tbinfo->dobj.dumpId),
11632 .namespace =
tbinfo->dobj.namespace->dobj.name,
11633 .owner =
tbinfo->rolname,
11634 .description =
"COMMENT",
11636 .createStmt = query->
data,
11637 .deps = &(
tbinfo->dobj.dumpId),
11669 while (low <= high)
11671 middle = low + (high - low) / 2;
11675 else if (classoid >
middle->classoid)
11679 else if (objoid >
middle->objoid)
11699 if (classoid !=
middle[-1].classoid ||
11700 objoid !=
middle[-1].objoid)
11711 if (classoid !=
middle->classoid ||
11712 objoid !=
middle->objoid)
11749 "FROM pg_catalog.pg_description "
11750 "ORDER BY classoid, objoid, objsubid");
11767 for (
i = 0;
i < ntups;
i++)
11777 if (dobj ==
NULL ||
11829 if (dobj->
dump == 0)
11957 pg_fatal(
"missing metadata for large objects \"%s\"",
11963 .description =
"BLOBS",
11965 .deps = dobj->dependencies,
11966 .nDeps = dobj->nDeps,
12041 "-- *not* dropping schema, since initdb creates it\n");
12043 "-- *not* creating schema, since initdb creates it\n");
12054 .description =
"SCHEMA",
12056 .createStmt = q->
data,
12057 .dropStmt =
delq->data));
12139 appendPQExpBufferStr(q,
"-- For binary upgrade, create an empty extension and insert objects into it\n");
12149 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
12194 .description =
"EXTENSION",
12196 .createStmt = q->
data,
12197 .dropStmt =
delq->data));
12238 pg_log_warning(
"typtype of data type \"%s\" appears to be invalid",
12267 "PREPARE dumpEnumType(pg_catalog.oid) AS\n"
12268 "SELECT oid, enumlabel "
12269 "FROM pg_catalog.pg_enum "
12270 "WHERE enumtypid = $1 "
12271 "ORDER BY enumsortorder");
12279 "EXECUTE dumpEnumType('%u')",
12280 tyinfo->dobj.catId.oid);
12308 for (
i = 0;
i < num;
i++)
12326 for (
i = 0;
i < num;
i++)
12334 "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
12345 tyinfo->dobj.namespace->dobj.name);
12350 .namespace =
tyinfo->dobj.namespace->dobj.name,
12351 .owner =
tyinfo->rolname,
12352 .description =
"TYPE",
12354 .createStmt = q->
data,
12355 .dropStmt =
delq->data));
12371 tyinfo->dobj.namespace->dobj.name,
12403 "PREPARE dumpRangeType(pg_catalog.oid) AS\n");
12410 "pg_catalog.format_type(rngmultitypid, NULL) AS rngmultitype, ");
12413 "NULL AS rngmultitype, ");
12416 "pg_catalog.format_type(rngsubtype, NULL) AS rngsubtype, "
12417 "opc.opcname AS opcname, "
12418 "(SELECT nspname FROM pg_catalog.pg_namespace nsp "
12419 " WHERE nsp.oid = opc.opcnamespace) AS opcnsp, "
12421 "CASE WHEN rngcollation = st.typcollation THEN 0 "
12422 " ELSE rngcollation END AS collation, "
12423 "rngcanonical, rngsubdiff "
12424 "FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
12425 " pg_catalog.pg_opclass opc "
12426 "WHERE st.oid = rngsubtype AND opc.oid = rngsubopc AND "
12435 "EXECUTE dumpRangeType('%u')",
12436 tyinfo->dobj.catId.oid);
12486 if (
strcmp(procname,
"-") != 0)
12490 if (
strcmp(procname,
"-") != 0)
12498 tyinfo->dobj.namespace->dobj.name);
12503 .namespace =
tyinfo->dobj.namespace->dobj.name,
12504 .owner =
tyinfo->rolname,
12505 .description =
"TYPE",
12507 .createStmt = q->
data,
12508 .dropStmt =
delq->data));
12524 tyinfo->dobj.namespace->dobj.name,
12569 tyinfo->dobj.namespace->dobj.name);
12574 .namespace =
tyinfo->dobj.namespace->dobj.name,
12575 .owner =
tyinfo->rolname,
12576 .description =
"TYPE",
12578 .createStmt = q->
data,
12579 .dropStmt =
delq->data));
12595 tyinfo->dobj.namespace->dobj.name,
12626 char *typsubscript;
12647 "PREPARE dumpBaseType(pg_catalog.oid) AS\n"
12649 "typinput, typoutput, typreceive, typsend, "
12650 "typreceive::pg_catalog.oid AS typreceiveoid, "
12651 "typsend::pg_catalog.oid AS typsendoid, "
12653 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
12654 "typdelim, typbyval, typalign, typstorage, "
12655 "typmodin, typmodout, "
12656 "typmodin::pg_catalog.oid AS typmodinoid, "
12657 "typmodout::pg_catalog.oid AS typmodoutoid, "
12658 "typcategory, typispreferred, "
12659 "(typcollation <> 0) AS typcollatable, "
12660 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault, ");
12665 "typsubscript::pg_catalog.oid AS typsubscriptoid ");
12668 "'-' AS typsubscript, 0 AS typsubscriptoid ");
12679 "EXECUTE dumpBaseType('%u')",
12680 tyinfo->dobj.catId.oid);
12736 "CREATE TYPE %s (\n"
12737 " INTERNALLENGTH = %s",
12739 (
strcmp(typlen,
"-1") == 0) ?
"variable" : typlen);
12784 if (typdelim &&
strcmp(typdelim,
",") != 0)
12808 if (
strcmp(typbyval,
"t") == 0)
12816 tyinfo->dobj.namespace->dobj.name);
12821 .namespace =
tyinfo->dobj.namespace->dobj.name,
12822 .owner =
tyinfo->rolname,
12823 .description =
"TYPE",
12825 .createStmt = q->
data,
12826 .dropStmt =
delq->data));
12842 tyinfo->dobj.namespace->dobj.name,
12878 "PREPARE dumpDomain(pg_catalog.oid) AS\n");
12881 "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
12882 "pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
12884 "CASE WHEN t.typcollation <> u.typcollation "
12885 "THEN t.typcollation ELSE 0 END AS typcollation "
12886 "FROM pg_catalog.pg_type t "
12887 "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
12888 "WHERE t.oid = $1");
12896 "EXECUTE dumpDomain('%u')",
12897 tyinfo->dobj.catId.oid);
12924 "CREATE DOMAIN %s AS %s",
12983 for (
i = 0;
i <
tyinfo->nDomChecks;
i++)
12999 tyinfo->dobj.namespace->dobj.name);
13004 .namespace =
tyinfo->dobj.namespace->dobj.name,
13005 .owner =
tyinfo->rolname,
13006 .description =
"DOMAIN",
13008 .createStmt = q->
data,
13009 .dropStmt =
delq->data));
13025 tyinfo->dobj.namespace->dobj.name,
13029 for (
i = 0;
i <
tyinfo->nDomChecks;
i++)
13044 tyinfo->dobj.namespace->dobj.name,
13064 tyinfo->dobj.namespace->dobj.name,
13114 "PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
13115 "SELECT a.attname, a.attnum, "
13116 "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
13117 "a.attlen, a.attalign, a.attisdropped, "
13118 "CASE WHEN a.attcollation <> at.typcollation "
13119 "THEN a.attcollation ELSE 0 END AS attcollation "
13120 "FROM pg_catalog.pg_type ct "
13121 "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
13122 "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
13123 "WHERE ct.oid = $1 "
13124 "ORDER BY a.attnum");
13132 "EXECUTE dumpCompositeType('%u')",
13133 tyinfo->dobj.catId.oid);
13161 for (
i = 0;
i < ntups;
i++)
13212 "\n-- For binary upgrade, recreate dropped column.\n");
13214 "SET attlen = %s, "
13215 "attalign = '%s', attbyval = false\n"
13236 tyinfo->dobj.namespace->dobj.name);
13241 .namespace =
tyinfo->dobj.namespace->dobj.name,
13242 .owner =
tyinfo->rolname,
13243 .description =
"TYPE",
13245 .createStmt = q->
data,
13246 .dropStmt =
delq->data));
13263 tyinfo->dobj.namespace->dobj.name,
13327 for (
i = 0;
i < ntups;
i++)
13354 .namespace =
tyinfo->dobj.namespace->dobj.name,
13355 .owner =
tyinfo->rolname,
13356 .description =
"COMMENT",
13358 .createStmt = query->
data,
13359 .deps = &(
tyinfo->dobj.dumpId),
13400 stinfo->baseType->dobj.catId.oid,
13409 .namespace =
stinfo->dobj.namespace->dobj.name,
13410 .owner =
stinfo->baseType->rolname,
13411 .description =
"SHELL TYPE",
13413 .createStmt = q->
data));
13485 plang->lanpltrusted ?
"TRUSTED " :
"",
13519 .owner =
plang->lanowner,
13520 .description =
"PROCEDURAL LANGUAGE",
13522 .createStmt =
defqry->data,
13523 .dropStmt =
delqry->data,
13589 for (
j = 0;
j < finfo->
nargs;
j++)
13641 const char *keyword;
13656 "PREPARE dumpFunc(pg_catalog.oid) AS\n");
13670 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
13671 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
13672 "pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
13673 "proleakproof,\n");
13677 "array_to_string(protrftypes, ' ') AS protrftypes,\n");
13680 "NULL AS protrftypes,\n");
13687 "'u' AS proparallel,\n");
13694 "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n");
13701 "'-' AS prosupport,\n");
13705 "pg_get_function_sqlbody(p.oid) AS prosqlbody\n");
13708 "NULL AS prosqlbody\n");
13711 "FROM pg_catalog.pg_proc p, pg_catalog.pg_language l\n"
13712 "WHERE p.oid = $1 "
13713 "AND l.oid = p.prolang");
13721 "EXECUTE dumpFunc('%u')",
13763 else if (
probin[0] !=
'\0')
13767 if (prosrc[0] !=
'\0')
13795 pg_fatal(
"could not parse %s array",
"proconfig");
13813 keyword =
"PROCEDURE";
13815 keyword =
"FUNCTION";
13866 pg_fatal(
"unrecognized provolatile value for function \"%s\"",
13916 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
13976 "pg_catalog.pg_proc", keyword,
13982 finfo->
dobj.namespace->dobj.
name);
13987 .
namespace = finfo->
dobj.namespace->dobj.
name,
13989 .description = keyword,
13992 .createStmt = q->
data,
13993 .dropStmt =
delqry->data));
14050 pg_fatal(
"could not find function definition for function with OID %u",
14067 switch (
cast->castmethod)
14089 pg_log_warning(
"bogus value in pg_cast.castfunc or pg_cast.castmethod field");
14095 if (
cast->castcontext ==
'a')
14097 else if (
cast->castcontext ==
'i')
14114 .description =
"CAST",
14116 .createStmt =
defqry->data,
14117 .dropStmt =
delqry->data));
14123 cast->dobj.catId, 0,
cast->dobj.dumpId);
14156 pg_fatal(
"could not find function definition for function with OID %u",
14163 pg_fatal(
"could not find function definition for function with OID %u",
14182 pg_log_warning(
"bogus transform definition, at least one of trffromsql and trftosql should be nonzero");
14238 .description =
"TRANSFORM",
14240 .createStmt =
defqry->data,
14241 .dropStmt =
delqry->data,
14317 "PREPARE dumpOpr(pg_catalog.oid) AS\n"
14319 "oprcode::pg_catalog.regprocedure, "
14320 "oprleft::pg_catalog.regtype, "
14321 "oprright::pg_catalog.regtype, "
14324 "oprrest::pg_catalog.regprocedure, "
14325 "oprjoin::pg_catalog.regprocedure, "
14326 "oprcanmerge, oprcanhash "
14327 "FROM pg_catalog.pg_operator "
14336 "EXECUTE dumpOpr('%u')",
14364 if (
strcmp(oprkind,
"r") == 0)
14365 pg_log_warning(
"postfix operators are not supported anymore (operator \"%s\")",
14383 if (
strcmp(oprkind,
"r") == 0 ||
14384 strcmp(oprkind,
"b") == 0)
14392 if (
strcmp(oprkind,
"l") == 0 ||
14393 strcmp(oprkind,
"b") == 0)
14446 oprinfo->dobj.namespace->dobj.name);
14451 .namespace =
oprinfo->dobj.namespace->dobj.name,
14453 .description =
"OPERATOR",
14455 .createStmt = q->
data,
14456 .dropStmt =
delq->data));
14490 if (
strcmp(proc,
"-") == 0)
14540 return psprintf(
"OPERATOR(%s.%s)",
14561 "SELECT '%u'::pg_catalog.regproc", funcOid);
14623 .description =
"ACCESS METHOD",
14625 .createStmt = q->
data,
14626 .dropStmt =
delq->data));
14697 "opckeytype::pg_catalog.regtype, "
14698 "opcdefault, opcfamily, "
14699 "opfname AS opcfamilyname, "
14700 "nspname AS opcfamilynsp, "
14701 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS amname "
14702 "FROM pg_catalog.pg_opclass c "
14703 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily "
14704 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14705 "WHERE c.oid = '%u'::pg_catalog.oid",
14769 "amopopr::pg_catalog.regoperator, "
14770 "opfname AS sortfamily, "
14771 "nspname AS sortfamilynsp "
14772 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14773 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14774 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14775 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14776 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14777 "AND refobjid = '%u'::pg_catalog.oid "
14778 "AND amopfamily = '%s'::pg_catalog.oid "
14779 "ORDER BY amopstrategy",
14792 for (
i = 0;
i < ntups;
i++)
14805 if (
strlen(sortfamily) > 0)
14830 "amproc::pg_catalog.regprocedure, "
14831 "amproclefttype::pg_catalog.regtype, "
14832 "amprocrighttype::pg_catalog.regtype "
14833 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14834 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14835 "AND refobjid = '%u'::pg_catalog.oid "
14836 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14837 "AND objid = ap.oid "
14838 "ORDER BY amprocnum",
14850 for (
i = 0;
i < ntups;
i++)
14890 opcinfo->dobj.namespace->dobj.name);
14895 .namespace =
opcinfo->dobj.namespace->dobj.name,
14897 .description =
"OPERATOR CLASS",
14899 .createStmt = q->
data,
14900 .dropStmt =
delq->data));
14971 "amopopr::pg_catalog.regoperator, "
14972 "opfname AS sortfamily, "
14973 "nspname AS sortfamilynsp "
14974 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14975 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14976 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14977 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14978 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14979 "AND refobjid = '%u'::pg_catalog.oid "
14980 "AND amopfamily = '%u'::pg_catalog.oid "
14981 "ORDER BY amopstrategy",
14990 "amproc::pg_catalog.regprocedure, "
14991 "amproclefttype::pg_catalog.regtype, "
14992 "amprocrighttype::pg_catalog.regtype "
14993 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14994 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14995 "AND refobjid = '%u'::pg_catalog.oid "
14996 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14997 "AND objid = ap.oid "
14998 "ORDER BY amprocnum",
15007 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opfmethod) AS amname "
15008 "FROM pg_catalog.pg_opfamily "
15009 "WHERE oid = '%u'::pg_catalog.oid",
15052 for (
i = 0;
i < ntups;
i++)
15065 if (
strlen(sortfamily) > 0)
15085 for (
i = 0;
i < ntups;
i++)
15112 opfinfo->dobj.namespace->dobj.name);
15117 .namespace =
opfinfo->dobj.namespace->dobj.name,
15119 .description =
"OPERATOR FAMILY",
15121 .createStmt = q->
data,
15122 .dropStmt =
delq->data));
15183 "'c' AS collprovider, "
15184 "NULL AS collversion, ");
15188 "collisdeterministic, ");
15191 "true AS collisdeterministic, ");
15198 "colliculocale AS colllocale, ");
15201 "NULL AS colllocale, ");
15208 "NULL AS collicurules, ");
15213 "FROM pg_catalog.pg_collation c "
15214 "WHERE c.oid = '%u'::pg_catalog.oid",
15277 pg_fatal(
"unrecognized collation provider: %s",
15370 collinfo->dobj.namespace->dobj.name);
15375 .namespace =
collinfo->dobj.namespace->dobj.name,
15377 .description =
"COLLATION",
15379 .createStmt = q->
data,
15380 .dropStmt =
delq->data));
15430 "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
15431 "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
15432 "conproc, condefault "
15433 "FROM pg_catalog.pg_conversion c "
15434 "WHERE c.oid = '%u'::pg_catalog.oid",
15464 convinfo->dobj.namespace->dobj.name);
15469 .namespace =
convinfo->dobj.namespace->dobj.name,
15471 .description =
"CONVERSION",
15473 .createStmt = q->
data,
15474 .dropStmt =
delq->data));
15508 if (
agginfo->aggfn.nargs == 0)
15515 (
j > 0) ?
", " :
"",
15554 const char *aggsortop;
15557 const char *aggtranstype;
15558 const char *aggtransspace;
15579 "PREPARE dumpAgg(pg_catalog.oid) AS\n");
15585 "aggtranstype::pg_catalog.regtype,\n"
15588 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
15589 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
15595 "aggminvtransfn,\n"
15597 "aggmtranstype::pg_catalog.regtype,\n"
15599 "aggmfinalextra,\n"
15601 "aggmtransspace,\n"
15605 "'n' AS aggkind,\n"
15606 "'-' AS aggmtransfn,\n"
15607 "'-' AS aggminvtransfn,\n"
15608 "'-' AS aggmfinalfn,\n"
15609 "0 AS aggmtranstype,\n"
15610 "false AS aggfinalextra,\n"
15611 "false AS aggmfinalextra,\n"
15612 "0 AS aggtransspace,\n"
15613 "0 AS aggmtransspace,\n"
15614 "NULL AS aggminitval,\n");
15624 "'-' AS aggcombinefn,\n"
15625 "'-' AS aggserialfn,\n"
15626 "'-' AS aggdeserialfn,\n"
15627 "'u' AS proparallel,\n");
15631 "aggfinalmodify,\n"
15632 "aggmfinalmodify\n");
15635 "'0' AS aggfinalmodify,\n"
15636 "'0' AS aggmfinalmodify\n");
15639 "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
15640 "WHERE a.aggfnoid = p.oid "
15649 "EXECUTE dumpAgg('%u')",
15650 agginfo->aggfn.dobj.catId.oid);
15703 if (
strcmp(aggtransspace,
"0") != 0)
15735 pg_fatal(
"unrecognized aggfinalmodify value for aggregate \"%s\"",
15791 pg_fatal(
"unrecognized aggmfinalmodify value for aggregate \"%s\"",
15816 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
15831 agginfo->aggfn.dobj.namespace->dobj.name);
15837 .
namespace =
agginfo->aggfn.dobj.namespace->dobj.name,
15838 .owner =
agginfo->aggfn.rolname,
15839 .description =
"AGGREGATE",
15841 .createStmt = q->
data,
15842 .dropStmt =
delq->data));
15847 agginfo->aggfn.dobj.namespace->dobj.name,
15853 agginfo->aggfn.dobj.namespace->dobj.name,
15869 agginfo->aggfn.dobj.namespace->dobj.name,
15926 prsinfo->dobj.namespace->dobj.name);
15931 .namespace =
prsinfo->dobj.namespace->dobj.name,
15932 .description =
"TEXT SEARCH PARSER",
15934 .createStmt = q->
data,
15935 .dropStmt =
delq->data));
15940 prsinfo->dobj.namespace->dobj.name,
"",
15976 "FROM pg_ts_template p, pg_namespace n "
15977 "WHERE p.oid = '%u' AND n.oid = tmplnamespace",
16004 dictinfo->dobj.namespace->dobj.name);
16009 .namespace =
dictinfo->dobj.namespace->dobj.name,
16011 .description =
"TEXT SEARCH DICTIONARY",
16013 .createStmt = q->
data,
16014 .dropStmt =
delq->data));
16064 tmplinfo->dobj.namespace->dobj.name);
16069 .namespace =
tmplinfo->dobj.namespace->dobj.name,
16070 .description =
"TEXT SEARCH TEMPLATE",
16072 .createStmt = q->
data,
16073 .dropStmt =
delq->data));
16078 tmplinfo->dobj.namespace->dobj.name,
"",
16118 "FROM pg_ts_parser p, pg_namespace n "
16119 "WHERE p.oid = '%u' AND n.oid = prsnamespace",
16136 " ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
16137 " WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
16138 " m.mapdict::pg_catalog.regdictionary AS dictname\n"
16139 "FROM pg_catalog.pg_ts_config_map AS m\n"
16140 "WHERE m.mapcfg = '%u'\n"
16141 "ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
16150 for (
i = 0;
i < ntups;
i++)
16181 "TEXT SEARCH CONFIGURATION",
qcfgname,
16182 cfginfo->dobj.namespace->dobj.name);
16187 .namespace =
cfginfo->dobj.namespace->dobj.name,
16189 .description =
"TEXT SEARCH CONFIGURATION",
16191 .createStmt = q->
data,
16192 .dropStmt =
delq->data));
16256 .description =
"FOREIGN DATA WRAPPER",
16258 .createStmt = q->
data,
16259 .dropStmt =
delq->data));
16306 "FROM pg_foreign_data_wrapper w "
16307 "WHERE w.oid = '%u'",
16343 .description =
"SERVER",
16345 .createStmt = q->
data,
16346 .dropStmt =
delq->data));
16385 const char *servername,
const char *
namespace,
16414 "array_to_string(ARRAY("
16415 "SELECT quote_ident(option_name) || ' ' || "
16416 "quote_literal(option_value) "
16417 "FROM pg_options_to_table(umoptions) "
16418 "ORDER BY option_name"
16419 "), E',\n ') AS umoptions "
16420 "FROM pg_user_mappings "
16421 "WHERE srvid = '%u' "
16422 "ORDER BY usename",
16431 for (
i = 0;
i < ntups;
i++)
16458 .namespace =
namespace,
16460 .description =
"USER MAPPING",
16462 .createStmt = q->
data,
16463 .dropStmt =
delq->data));
16498 type =
"SEQUENCES";
16501 type =
"FUNCTIONS";
16510 type =
"LARGE OBJECTS";
16514 pg_fatal(
"unrecognized object type in default privileges: %d",
16530 pg_fatal(
"could not parse default ACL list (%s)",
16536 .namespace =
daclinfo->dobj.namespace ?
16539 .description =
"DEFAULT ACL",
16541 .createStmt = q->
data));
16572 const char *nspname,
const char *tag,
const char *owner,
16577 const char *
acls = dacl->
acl;
16580 const char *initprivs = dacl->
initprivs;
16608 initprivs && *initprivs !=
'\0')
16614 pg_fatal(
"could not parse initial ACL list (%s) or default (%s) for object \"%s\" (%s)",
16616 appendPQExpBufferStr(sql,
"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
16627 if (initprivs && *initprivs !=
'\0')
16639 pg_fatal(
"could not parse ACL list (%s) or default (%s) for object \"%s\" (%s)",
16663 .namespace = nspname,
16665 .description =
"ACL",
16667 .createStmt = sql->
data,
16699 const char *
namespace,
const char *owner,
16738 if (labels[
i].objsubid != subid)
16742 "SECURITY LABEL FOR %s ON %s ",
16744 if (
namespace && *
namespace)
16751 if (query->
len > 0)
16758 .namespace =
namespace,
16760 .description =
"SECURITY LABEL",
16762 .createStmt = query->
data,
16809 const char *colname;
16833 if (query->
len > 0)
16840 .namespace =
tbinfo->dobj.namespace->dobj.name,
16841 .owner =
tbinfo->rolname,
16842 .description =
"SECURITY LABEL",
16844 .createStmt = query->
data,
16845 .deps = &(
tbinfo->dobj.dumpId),
16878 while (low <= high)
16880 middle = low + (high - low) / 2;
16884 else if (classoid >
middle->classoid)
16888 else if (objoid >
middle->objoid)
16908 if (classoid !=
middle[-1].classoid ||
16909 objoid !=
middle[-1].objoid)
16920 if (classoid !=
middle->classoid ||
16921 objoid !=
middle->objoid)
16955 "SELECT label, provider, classoid, objoid, objsubid "
16956 "FROM pg_catalog.pg_seclabels "
16957 "ORDER BY classoid, objoid, objsubid");
16974 for (
i = 0;
i < ntups;
i++)
16984 if (dobj ==
NULL ||
17047 const char *objtype;
17049 switch (
tbinfo->relkind)
17052 objtype =
"SEQUENCE";
17055 objtype =
"PROPERTY GRAPH";
17065 tbinfo->dobj.namespace->dobj.name,
17085 "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
17100 "SELECT at.attname, "
17102 "'{}' AS acldefault, "
17103 "pip.privtype, pip.initprivs "
17104 "FROM pg_catalog.pg_attribute at "
17105 "LEFT JOIN pg_catalog.pg_init_privs pip ON "
17106 "(at.attrelid = pip.objoid "
17107 "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
17108 "AND at.attnum = pip.objsubid) "
17109 "WHERE at.attrelid = $1 AND "
17110 "NOT at.attisdropped "
17111 "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
17112 "ORDER BY at.attnum");
17117 "SELECT attname, attacl, '{}' AS acldefault, "
17118 "NULL AS privtype, NULL AS initprivs "
17119 "FROM pg_catalog.pg_attribute "
17120 "WHERE attrelid = $1 AND NOT attisdropped "
17121 "AND attacl IS NOT NULL "
17122 "ORDER BY attnum");
17131 "EXECUTE getColumnACLs('%u')",
17132 tbinfo->dobj.catId.oid);
17149 coldacl.initprivs = initprivs;
17159 tbinfo->dobj.namespace->dobj.name,
17186 "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
17187 tbinfo->dobj.catId.oid);
17194 pg_fatal(
"query to obtain definition of view \"%s\" returned no data",
17197 pg_fatal(
"query to obtain definition of view \"%s\" returned more than one definition",
17204 pg_fatal(
"definition of view \"%s\" appears to be empty (length zero)",
17289 pg_log_warning(
"WITH OIDS is not supported anymore (table \"%s\")",
17308 tbinfo->dobj.catId.oid);
17341 tbinfo->dobj.catId.oid);
17344 "SELECT pg_catalog.pg_get_propgraphdef('%u'::pg_catalog.oid) AS pgdef",
17345 tbinfo->dobj.catId.oid);
17352 pg_fatal(
"query to obtain definition of property graph \"%s\" returned no data",
17355 pg_fatal(
"query to obtain definition of property graph \"%s\" returned more than one definition",
17362 pg_fatal(
"definition of property graph \"%s\" appears to be empty (length zero)",
17383 switch (
tbinfo->relkind)
17394 "SELECT pg_get_partkeydef('%u')",
17395 tbinfo->dobj.catId.oid);
17413 "SELECT fs.srvname, "
17414 "pg_catalog.array_to_string(ARRAY("
17415 "SELECT pg_catalog.quote_ident(option_name) || "
17416 "' ' || pg_catalog.quote_literal(option_value) "
17417 "FROM pg_catalog.pg_options_to_table(ftoptions) "
17418 "ORDER BY option_name"
17419 "), E',\n ') AS ftoptions "
17420 "FROM pg_catalog.pg_foreign_table ft "
17421 "JOIN pg_catalog.pg_foreign_server fs "
17422 "ON (fs.oid = ft.ftserver) "
17423 "WHERE ft.ftrelid = '%u'",
17424 tbinfo->dobj.catId.oid);
17444 numParents =
tbinfo->numParents;
17449 tbinfo->dobj.catId.oid);
17493 tbinfo->attrdefs[
j]->dobj.dump &&
17494 !
tbinfo->attrdefs[
j]->separate);
17502 (
tbinfo->notnull_islocal[
j] ||
17554 tbinfo->attrdefs[
j]->adef_expr);
17557 tbinfo->attrdefs[
j]->adef_expr);
17560 tbinfo->attrdefs[
j]->adef_expr);
17565 if (
tbinfo->notnull_constrs[
j][0] ==
'\0')
17571 if (
tbinfo->notnull_noinh[
j])
17610 if (
tbinfo->notnull_constrs[
j][0] ==
'\0')
17618 if (
tbinfo->notnull_noinh[
j])
17666 if (numParents > 0 && !
tbinfo->ispartition &&
17670 for (k = 0; k < numParents; k++)
17732 "pg_catalog.pg_class",
17733 "MATERIALIZED VIEW",
17744 if (
tbinfo->attmissingval[
j][0] !=
'\0')
17748 "SELECT pg_catalog.binary_upgrade_set_missing_value(");
17803 "UPDATE pg_catalog.pg_attribute\n"
17804 "SET attlen = v.dlen, "
17805 "attalign = v.dalign, "
17806 "attbyval = false\n"
17827 "WHERE attrelid = ");
17830 " AND attname = v.dname;\n");
17842 if (!
tbinfo->attisdropped[
j] &&
17849 "SET attislocal = false\n"
17850 "WHERE attrelid = ");
17853 " AND attname IN (");
17887 if (
tbinfo->notnull_constrs[
j][0] !=
'\0')
17892 "SET conislocal = false\n"
17893 "WHERE contype = 'n' AND conrelid = ");
17908 "SET conislocal = false\n"
17909 "WHERE contype = 'n' AND conrelid = ");
17926 if (extra->
len > 0)
17943 for (k = 0; k <
tbinfo->ncheck; k++)
17960 "SET conislocal = false\n"
17961 "WHERE contype = 'c' AND conrelid = ");
17977 if (numParents > 0 && !
tbinfo->ispartition)
17980 for (k = 0; k < numParents; k++)
18013 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
18025 appendPQExpBufferStr(q,
"\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
18027 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
18028 "WHERE oid = '%u';\n",
18029 tbinfo->toast_frozenxid,
18046 "SET relispopulated = 't'\n"
18067 if (
tbinfo->attstattarget[
j] >= 0)
18068 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STATISTICS %d;\n",
18079 switch (
tbinfo->attstorage[
j])
18101 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STORAGE %s;\n",
18114 switch (
tbinfo->attcompression[
j])
18128 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET COMPRESSION %s;\n",
18137 if (
tbinfo->attoptions[
j][0] !=
'\0')
18147 tbinfo->attfdwoptions[
j][0] !=
'\0')
18149 "ALTER FOREIGN TABLE ONLY %s ALTER COLUMN %s OPTIONS (\n"
18186 if (
tbinfo->forcerowsec)
18195 tbinfo->dobj.namespace->dobj.name);
18200 char *tableam =
NULL;
18214 tableam =
tbinfo->amname;
18218 .namespace =
tbinfo->dobj.namespace->dobj.name,
18220 .tableam = tableam,
18221 .relkind =
tbinfo->relkind,
18222 .owner =
tbinfo->rolname,
18224 .section =
tbinfo->postponed_def ?
18226 .createStmt = q->
data,
18227 .dropStmt =
delq->data));
18274 .namespace =
tbinfo->dobj.namespace->dobj.name,
18275 .owner =
tbinfo->rolname,
18276 .description =
"COMMENT",
18279 .deps = &(
tbinfo->dobj.dumpId),
18340 "PREPARE dumpTableAttach(pg_catalog.oid) AS\n");
18343 "SELECT pg_get_expr(c.relpartbound, c.oid) "
18345 "WHERE c.oid = $1");
18353 "EXECUTE dumpTableAttach('%u')",
18361 "ALTER TABLE ONLY %s ",
18364 "ATTACH PARTITION %s %s;\n",
18377 .namespace =
attachinfo->dobj.namespace->dobj.name,
18379 .description =
"TABLE ATTACH",
18381 .createStmt = q->
data));
18395 int adnum =
adinfo->adnum;
18418 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET DEFAULT %s;\n",
18431 .
namespace =
tbinfo->dobj.namespace->dobj.name,
18432 .owner =
tbinfo->rolname,
18433 .description =
"DEFAULT",
18435 .createStmt = q->
data,
18436 .dropStmt =
delq->data));
18455 return tblInfo->attnames[attrnum - 1];
18471 pg_fatal(
"invalid column number %d for table \"%s\"",
18472 attrnum,
tblInfo->dobj.name);
18510 char *indstatcols =
indxinfo->indstatcols;
18511 char *indstatvals =
indxinfo->indstatvals;
18544 if (
strlen(indstatcols) != 0 ||
strlen(indstatvals) != 0)
18549 pg_fatal(
"could not parse index statistic columns");
18551 pg_fatal(
"could not parse index statistic values");
18553 pg_fatal(
"mismatched number of columns and values for index statistics");
18572 "pg_catalog.pg_class",
18600 .namespace =
tbinfo->dobj.namespace->dobj.name,
18601 .tablespace =
indxinfo->tablespace,
18602 .owner =
tbinfo->rolname,
18603 .description =
"INDEX",
18605 .createStmt = q->
data,
18606 .dropStmt =
delq->data));
18615 tbinfo->dobj.namespace->dobj.name,
18660 .namespace =
attachinfo->dobj.namespace->dobj.name,
18661 .owner =
attachinfo->parentIdx->indextable->rolname,
18662 .description =
"INDEX ATTACH",
18664 .createStmt = q->
data));
18696 "pg_catalog.pg_get_statisticsobjdef('%u'::pg_catalog.oid)",
18727 .description =
"STATISTICS",
18729 .createStmt = q->
data,
18730 .dropStmt =
delq->data));
18782 "PREPARE getExtStatsStats(pg_catalog.name, pg_catalog.name) AS\n"
18827 "SELECT json_agg( "
18828 " json_build_object( "
18830 " string_to_array(kv.key, ', ')::integer[], "
18832 " kv.value::bigint )) "
18833 "FROM json_each_text(e.n_distinct::text::json) AS kv"
18834 ") AS n_distinct, "
18836 "SELECT json_agg( "
18837 " json_build_object( "
18839 " string_to_array( "
18840 " split_part(kv.key, ' => ', 1), "
18841 " ', ')::integer[], "
18843 " split_part(kv.key, ' => ', 2)::integer, "
18845 " kv.value::double precision )) "
18846 "FROM json_each_text(e.dependencies::text::json) AS kv "
18847 ") AS dependencies, ");
18852 "e.most_common_vals, e.most_common_freqs, "
18853 "e.most_common_base_freqs, ");
18856 "NULL AS most_common_vals, NULL AS most_common_freqs, "
18857 "NULL AS most_common_base_freqs, ");
18869 "SELECT jsonb_pretty(jsonb_agg("
18870 "nullif(j.obj, '{}'::jsonb))) "
18871 "FROM pg_stats_ext_exprs AS ee "
18872 "CROSS JOIN LATERAL jsonb_strip_nulls("
18873 " jsonb_build_object( "
18874 " 'null_frac', ee.null_frac::text, "
18875 " 'avg_width', ee.avg_width::text, "
18876 " 'n_distinct', ee.n_distinct::text, "
18877 " 'most_common_vals', ee.most_common_vals::text, "
18878 " 'most_common_freqs', ee.most_common_freqs::text, "
18879 " 'histogram_bounds', ee.histogram_bounds::text, "
18880 " 'correlation', ee.correlation::text, "
18881 " 'most_common_elems', ee.most_common_elems::text, "
18882 " 'most_common_elem_freqs', ee.most_common_elem_freqs::text, "
18883 " 'elem_count_histogram', ee.elem_count_histogram::text");
18889 " 'range_length_histogram', ee.range_length_histogram::text, "
18890 " 'range_empty_frac', ee.range_empty_frac::text, "
18891 " 'range_bounds_histogram', ee.range_bounds_histogram::text");
18895 "WHERE ee.statistics_schemaname = $1 "
18896 "AND ee.statistics_name = $2 ");
18909 "FROM pg_catalog.pg_stats_ext AS e "
18910 "WHERE e.statistics_schemaname = $1 "
18911 "AND e.statistics_name = $2 ");
18915 "SELECT s.stxndistinct AS n_distinct, "
18916 " s.stxdependencies AS dependencies "
18917 "FROM pg_catalog.pg_statistic_ext AS s "
18918 "JOIN pg_catalog.pg_namespace AS n "
18919 "ON n.oid = s.stxnamespace "
18920 "WHERE n.nspname = $1 "
18921 "AND s.stxname = $2 "
18960 for (
int i = 0;
i < nstats;
i++)
18965 pg_fatal(
"inherited cannot be NULL");
18968 "SELECT * FROM pg_catalog.pg_restore_extended_stats(\n");
19017 .description =
"EXTENDED STATISTICS DATA",
19019 .createStmt = out->
data,
19051 if (
coninfo->contype ==
'p' ||
19062 pg_fatal(
"missing index for constraint \"%s\"",
19082 coninfo->contype ==
'p' ?
"PRIMARY KEY" :
"UNIQUE");
19093 for (k = 0; k <
indxinfo->indnkeyattrs; k++)
19103 (k == 0) ?
"" :
", ",
19122 (k ==
indxinfo->indnkeyattrs) ?
"" :
", ",
19173 "pg_catalog.pg_class",
"INDEX",
19186 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19187 .tablespace =
indxinfo->tablespace,
19188 .owner =
tbinfo->rolname,
19189 .description =
"CONSTRAINT",
19191 .createStmt = q->
data,
19192 .dropStmt =
delq->data));
19194 else if (
coninfo->contype ==
'f')
19226 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19227 .owner =
tbinfo->rolname,
19228 .description =
"FK CONSTRAINT",
19230 .createStmt = q->
data,
19231 .dropStmt =
delq->data));
19240 const char *keyword;
19243 keyword =
"CHECK CONSTRAINT";
19245 keyword =
"CONSTRAINT";
19264 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19265 .owner =
tbinfo->rolname,
19266 .description = keyword,
19268 .createStmt = q->
data,
19269 .dropStmt =
delq->data));
19282 const char *keyword;
19285 keyword =
"CHECK CONSTRAINT";
19287 keyword =
"CONSTRAINT";
19305 .
namespace =
tyinfo->dobj.namespace->dobj.name,
19306 .owner =
tyinfo->rolname,
19307 .description = keyword,
19309 .createStmt = q->
data,
19310 .dropStmt =
delq->data));
19321 tyinfo->dobj.namespace->dobj.name,
19331 pg_fatal(
"unrecognized constraint type: %c",
19366 tbinfo->dobj.namespace->dobj.name,
19424 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
19425 "seqstart, seqincrement, "
19427 "seqcache, seqcycle, "
19429 "FROM pg_catalog.pg_sequence "
19430 "ORDER BY seqrelid";
19432 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
19433 "seqstart, seqincrement, "
19435 "seqcache, seqcycle, "
19436 "last_value, is_called "
19437 "FROM pg_catalog.pg_sequence, "
19438 "pg_get_sequence_data(seqrelid) "
19439 "ORDER BY seqrelid;";
19494 key.oid =
tbinfo->dobj.catId.oid;
19509 "SELECT 'bigint' AS sequence_type, "
19510 "start_value, increment_by, max_value, min_value, "
19511 "cache_value, is_cycled FROM %s",
19517 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19518 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19553 pg_fatal(
"unrecognized sequence type: %d",
seq->seqtype);
19560 if (!
tbinfo->is_identity_sequence)
19571 tbinfo->dobj.catId.oid);
19579 if (
tbinfo->is_identity_sequence)
19587 "ALTER COLUMN %s ADD GENERATED ",
19603 "UNLOGGED" :
"LOGGED");
19608 "CREATE %sSEQUENCE %s\n",
19633 seq->cache, (
seq->cycled ?
"\n CYCLE" :
""));
19635 if (
tbinfo->is_identity_sequence)
19645 tbinfo->dobj.namespace->dobj.name);
19650 .namespace =
tbinfo->dobj.namespace->dobj.name,
19651 .owner =
tbinfo->rolname,
19652 .description =
"SEQUENCE",
19654 .createStmt = query->
data,
19655 .dropStmt =
delqry->data));
19673 if (owning_tab ==
NULL)
19674 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
19690 .namespace =
tbinfo->dobj.namespace->dobj.name,
19691 .owner =
tbinfo->rolname,
19692 .description =
"SEQUENCE OWNED BY",
19694 .createStmt = query->
data,
19695 .deps = &(
tbinfo->dobj.dumpId),
19749 "SELECT last_value, is_called FROM %s",
19755 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19756 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19773 key.oid =
tbinfo->dobj.catId.oid;
19778 pg_fatal(
"failed to get data for sequence \"%s\"; user may lack "
19779 "SELECT privilege on the sequence or the sequence may "
19780 "have been concurrently dropped",
19791 last, (
called ?
"true" :
"false"));
19796 .namespace =
tbinfo->dobj.namespace->dobj.name,
19797 .owner =
tbinfo->rolname,
19798 .description =
"SEQUENCE SET",
19800 .createStmt = query->
data,
19801 .deps = &(
tbinfo->dobj.dumpId),
19842 "pg_catalog.pg_trigger",
"TRIGGER",
19845 if (
tginfo->tgispartition)
19860 switch (
tginfo->tgenabled)
19880 else if (
tginfo->tgenabled !=
't' &&
tginfo->tgenabled !=
'O')
19885 switch (
tginfo->tgenabled)
19913 .
namespace =
tbinfo->dobj.namespace->dobj.name,
19914 .owner =
tbinfo->rolname,
19915 .description =
"TRIGGER",
19917 .createStmt = query->
data,
19918 .dropStmt =
delqry->data));
19970 if (
evtinfo->evtenabled !=
'O')
20003 .description =
"EVENT TRIGGER",
20005 .createStmt = query->
data,
20006 .dropStmt =
delqry->data));
20093 "SELECT pg_catalog.pg_get_ruledef('%u'::pg_catalog.oid)",
20099 pg_fatal(
"query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
20162 .
namespace =
tbinfo->dobj.namespace->dobj.name,
20163 .owner =
tbinfo->rolname,
20164 .description =
"RULE",
20166 .createStmt = cmd->
data,
20167 .dropStmt =
delcmd->data));
20172 tbinfo->dobj.namespace->dobj.name,
20215 "classid, objid, refobjid "
20217 "WHERE refclassid = 'pg_extension'::regclass "
20218 "AND deptype = 'e' "
20236 for (
i = 0;
i < ntups;
i++)
20318 char *extcondition =
curext->extcondition;
20330 curext->dobj.catId.oid))
20339 curext->dobj.catId.oid))
20342 if (
strlen(extconfig) != 0 ||
strlen(extcondition) != 0)
20347 pg_fatal(
"could not parse %s array",
"extconfig");
20349 pg_fatal(
"could not parse %s array",
"extcondition");
20351 pg_fatal(
"mismatched number of configurations and conditions for extension");
20377 if (
configtbl->dobj.namespace->dobj.dump &
20390 configtbl->dobj.namespace->dobj.catId.oid))
20422 "SELECT conrelid, confrelid "
20423 "FROM pg_constraint "
20424 "JOIN pg_depend ON (objid = confrelid) "
20425 "WHERE contype = 'f' "
20426 "AND refclassid = 'pg_extension'::regclass "
20427 "AND classid = 'pg_class'::regclass;");
20436 for (
i = 0;
i < ntups;
i++)
20450 contable ==
NULL ||
20496 "classid, objid, refclassid, refobjid, deptype "
20498 "WHERE deptype != 'p' AND deptype != 'e'\n");
20511 "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
20512 "FROM pg_depend d, pg_amop o "
20513 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20514 "classid = 'pg_amop'::regclass AND objid = o.oid "
20515 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
20519 "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
20520 "FROM pg_depend d, pg_amproc p "
20521 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20522 "classid = 'pg_amproc'::regclass AND objid = p.oid "
20523 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
20531 "SELECT 'pg_class'::regclass AS classid, pgepgid AS objid, refclassid, refobjid, deptype "
20532 "FROM pg_depend d, pg_propgraph_element pge "
20533 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20534 "classid = 'pg_propgraph_element'::regclass AND objid = pge.oid\n");
20556 for (
i = 0;
i < ntups;
i++)
20568 if (dobj ==
NULL ||
20603 if (deptype ==
'x')
20613 if (deptype ==
'i' &&
20728 if (((
RuleInfo *) dobj)->separate)
20807 if (dobj->
nDeps <= 0)
20815 &dependencies, &nDeps, &allocDeps);
20824 free(dependencies);
20831 DumpId **dependencies,
int *nDeps,
int *allocDeps)
20850 if (*nDeps >= *allocDeps)
20855 (*dependencies)[*nDeps] =
depid;
20869 dependencies, nDeps, allocDeps);
20906 appendPQExpBuffer(query,
"SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
20938 int numatts =
ti->numatts;
20939 char **attnames =
ti->attnames;
20940 bool *attisdropped =
ti->attisdropped;
20941 char *attgenerated =
ti->attgenerated;
20947 for (
i = 0;
i < numatts;
i++)
20949 if (attisdropped[
i])
20951 if (attgenerated[
i])
20963 return buffer->
data;
20973 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)
#define check_mut_excl_opts(set, opt,...)
static AmcheckOptions opts
int EndLO(Archive *AHX, Oid oid)
void ProcessArchiveRestoreOptions(Archive *AHX)
RestoreOptions * NewRestoreOptions(void)
#define appendStringLiteralAH(buf, str, AH)
int StartLO(Archive *AHX, Oid oid)
enum _archiveFormat ArchiveFormat
void RestoreArchive(Archive *AHX, bool append_data)
void ConnectDatabaseAhx(Archive *AHX, const ConnParams *cparams, bool isReconnect)
void CloseArchive(Archive *AHX)
Archive * CreateArchive(const char *FileSpec, const ArchiveFormat fmt, const pg_compress_specification compression_spec, bool dosync, ArchiveMode mode, SetupWorkerPtrType setupDumpWorker, DataDirSyncMethod sync_method)
@ PREPQUERY_DUMPTABLEATTACH
@ PREPQUERY_DUMPRANGETYPE
@ PREPQUERY_DUMPEXTSTATSOBJSTATS
@ PREPQUERY_GETATTRIBUTESTATS
@ PREPQUERY_DUMPCOMPOSITETYPE
@ PREPQUERY_GETCOLUMNACLS
@ PREPQUERY_GETDOMAINCONSTRAINTS
int archprintf(Archive *AH, const char *fmt,...) pg_attribute_printf(2
void SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)
void archputs(const char *s, Archive *AH)
void InitDumpOptions(DumpOptions *opts)
void WriteData(Archive *AHX, const void *data, size_t dLen)
int TocIDRequired(ArchiveHandle *AH, DumpId id)
TocEntry * ArchiveEntry(Archive *AHX, CatalogId catalogId, DumpId dumpId, ArchiveOpts *opts)
#define ARCHIVE_OPTS(...)
int(* DataDumperPtr)(Archive *AH, const void *userArg)
void ExecuteSqlStatement(Archive *AHX, const char *query)
PGresult * ExecuteSqlQuery(Archive *AHX, const char *query, ExecStatusType status)
PGresult * ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)
void exit_nicely(int code)
void set_dump_section(const char *arg, int *dumpSections)
static PgChecksumMode mode
static void expand_schema_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names)
static const CatalogId nilCatalogId
static void dumpEncoding(Archive *AH)
void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
static DumpId dumpACL(Archive *fout, DumpId objDumpId, DumpId altDumpId, const char *type, const char *name, const char *subname, const char *nspname, const char *tag, const char *owner, const DumpableAcl *dacl)
static SimpleStringList schema_include_patterns
static void dumpAttrDef(Archive *fout, const AttrDefInfo *adinfo)
ExtensionInfo * getExtensions(Archive *fout, int *numExtensions)
static void selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void collectBinaryUpgradeClassOids(Archive *fout)
static PQExpBuffer createDummyViewAsClause(Archive *fout, const TableInfo *tbinfo)
static void dumpUserMappings(Archive *fout, const char *servername, const char *namespace, const char *owner, CatalogId catalogId, DumpId dumpId)
static void dumpPublicationNamespace(Archive *fout, const PublicationSchemaInfo *pubsinfo)
static void addBoundaryDependencies(DumpableObject **dobjs, int numObjs, DumpableObject *boundaryObjs)
void getPublicationNamespaces(Archive *fout)
static void dumpSearchPath(Archive *AH)
static void selectDumpableTable(TableInfo *tbinfo, Archive *fout)
static DumpableObject * createBoundaryObjects(void)
static char * convertTSFunction(Archive *fout, Oid funcOid)
static void dumpDatabase(Archive *fout)
static SimpleStringList table_include_patterns
static void append_depends_on_extension(Archive *fout, PQExpBuffer create, const DumpableObject *dobj, const char *catalog, const char *keyword, const char *objname)
static Oid get_next_possible_free_pg_type_oid(Archive *fout, PQExpBuffer upgrade_query)
static void dumpNamespace(Archive *fout, const NamespaceInfo *nspinfo)
static bool forcePartitionRootLoad(const TableInfo *tbinfo)
static void dumpCast(Archive *fout, const CastInfo *cast)
static SimpleOidList schema_exclude_oids
static bool have_extra_float_digits
static void dumpIndex(Archive *fout, const IndxInfo *indxinfo)
void getPartitioningInfo(Archive *fout)
static int nbinaryUpgradeClassOids
static void dumpBaseType(Archive *fout, const TypeInfo *tyinfo)
static char * dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
static SimpleOidList extension_include_oids
static void dumpTSDictionary(Archive *fout, const TSDictInfo *dictinfo)
static void dumpAgg(Archive *fout, const AggInfo *agginfo)
static int extra_float_digits
static int SequenceItemCmp(const void *p1, const void *p2)
static void dumpRelationStats(Archive *fout, const RelStatsInfo *rsinfo)
static void dumpTableComment(Archive *fout, const TableInfo *tbinfo, const char *reltypename)
static SimpleStringList extension_include_patterns
static void selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
InhInfo * getInherits(Archive *fout, int *numInherits)
void getForeignDataWrappers(Archive *fout)
static void dumpTrigger(Archive *fout, const TriggerInfo *tginfo)
static void binary_upgrade_set_type_oids_by_rel(Archive *fout, PQExpBuffer upgrade_buffer, const TableInfo *tbinfo)
static void dumpTable(Archive *fout, const TableInfo *tbinfo)
static SimpleOidList extension_exclude_oids
static SimpleStringList table_exclude_patterns
static PQExpBuffer createViewAsClause(Archive *fout, const TableInfo *tbinfo)
static void dumpStatisticsExt(Archive *fout, const StatsExtInfo *statsextinfo)
void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
static void dumpRangeType(Archive *fout, const TypeInfo *tyinfo)
void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
static void dumpComment(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId)
static char * getFormattedOperatorName(const char *oproid)
static char * format_function_signature(Archive *fout, const FuncInfo *finfo, bool honor_quotes)
static pg_compress_algorithm compression_algorithm
static void dumpStdStrings(Archive *AH)
static void dumpConstraint(Archive *fout, const ConstraintInfo *coninfo)
static void dumpType(Archive *fout, const TypeInfo *tyinfo)
static void dumpTableAttach(Archive *fout, const TableAttachInfo *attachinfo)
void getTypes(Archive *fout)
static void dumpAccessMethod(Archive *fout, const AccessMethodInfo *aminfo)
static void dumpOpr(Archive *fout, const OprInfo *oprinfo)
static void selectDumpableStatisticsObject(StatsExtInfo *sobj, Archive *fout)
static void selectDumpablePublicationObject(DumpableObject *dobj, Archive *fout)
static void dumpSequenceData(Archive *fout, const TableDataInfo *tdinfo)
static void dumpFunc(Archive *fout, const FuncInfo *finfo)
static void selectDumpableDefaultACL(DefaultACLInfo *dinfo, DumpOptions *dopt)
static void BuildArchiveDependencies(Archive *fout)
static RelStatsInfo * getRelationStatistics(Archive *fout, DumpableObject *rel, int32 relpages, char *reltuples, int32 relallvisible, int32 relallfrozen, char relkind, char **indAttNames, int nindAttNames)
static const char *const SeqTypeNames[]
void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo)
static const char * getAttrName(int attrnum, const TableInfo *tblInfo)
static void dumpForeignServer(Archive *fout, const ForeignServerInfo *srvinfo)
static RoleNameItem * rolenames
static void collectRoleNames(Archive *fout)
static PGresult * fetchAttributeStats(Archive *fout)
static void appendReloptionsArrayAH(PQExpBuffer buffer, const char *reloptions, const char *prefix, Archive *fout)
void getOpclasses(Archive *fout)
void getForeignServers(Archive *fout)
void getFuncs(Archive *fout)
static void dumpTableData(Archive *fout, const TableDataInfo *tdinfo)
static void prohibit_crossdb_refs(PGconn *conn, const char *dbname, const char *pattern)
static int dumpTableData_copy(Archive *fout, const void *dcontext)
#define MAX_BLOBS_PER_ARCHIVE_ENTRY
static const char * getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts)
static void getDependencies(Archive *fout)
static void buildMatViewRefreshDependencies(Archive *fout)
void getTSDictionaries(Archive *fout)
static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, PQExpBuffer upgrade_buffer, Oid pg_type_oid, bool force_array_type, bool include_multirange_type)
#define DUMP_DEFAULT_ROWS_PER_INSERT
void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
static SeqType parse_sequence_type(const char *name)
static const char * getRoleName(const char *roleoid_str)
static void dumpShellType(Archive *fout, const ShellTypeInfo *stinfo)
static SequenceItem * sequences
static void refreshMatViewData(Archive *fout, const TableDataInfo *tdinfo)
static int findComments(Oid classoid, Oid objoid, CommentItem **items)
static SimpleStringList foreign_servers_include_patterns
static void selectDumpableCast(CastInfo *cast, Archive *fout)
void getCasts(Archive *fout)
static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo)
static void dumpPolicy(Archive *fout, const PolicyInfo *polinfo)
void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
static void setupDumpWorker(Archive *AH)
static void addConstrChildIdxDeps(DumpableObject *dobj, const IndxInfo *refidx)
void getTSConfigurations(Archive *fout)
static int findSecLabels(Oid classoid, Oid objoid, SecLabelItem **items)
static SimpleStringList table_include_patterns_and_children
static char * convertRegProcReference(const char *proc)
static void getAdditionalACLs(Archive *fout)
static void getTableDataFKConstraints(void)
static void getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, char relkind)
static SimpleOidList table_exclude_oids
void getAccessMethods(Archive *fout)
void getConversions(Archive *fout)
void getRules(Archive *fout)
static void dumpDomain(Archive *fout, const TypeInfo *tyinfo)
void getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
static void collectComments(Archive *fout)
static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo)
static void dumpOpfamily(Archive *fout, const OpfamilyInfo *opfinfo)
static void dumpDefaultACL(Archive *fout, const DefaultACLInfo *daclinfo)
static void selectDumpableObject(DumpableObject *dobj, Archive *fout)
static void dumpTSTemplate(Archive *fout, const TSTemplateInfo *tmplinfo)
static void dumpIndexAttach(Archive *fout, const IndexAttachInfo *attachinfo)
static void dumpSubscriptionTable(Archive *fout, const SubRelInfo *subrinfo)
void getCollations(Archive *fout)
static char * format_function_arguments(const FuncInfo *finfo, const char *funcargs, bool is_agg)
static void dumpTransform(Archive *fout, const TransformInfo *transform)
void getAggregates(Archive *fout)
static void dumpLO(Archive *fout, const LoInfo *loinfo)
void getNamespaces(Archive *fout)
static void dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo)
void getPublications(Archive *fout)
static void binary_upgrade_extension_member(PQExpBuffer upgrade_buffer, const DumpableObject *dobj, const char *objtype, const char *objname, const char *objnamespace)
static void dumpDumpableObject(Archive *fout, DumpableObject *dobj)
static void getLOs(Archive *fout)
static void dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, const char *dbname, Oid dboid)
void getTSParsers(Archive *fout)
static void setup_connection(Archive *AH, const char *dumpencoding, const char *dumpsnapshot, char *use_role)
static void dumpTableConstraintComment(Archive *fout, const ConstraintInfo *coninfo)
static void dumpUndefinedType(Archive *fout, const TypeInfo *tyinfo)
static void selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
static const char * fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer)
static void expand_table_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names, bool with_child_tables)
static void findDumpableDependencies(ArchiveHandle *AH, const DumpableObject *dobj, DumpId **dependencies, int *nDeps, int *allocDeps)
static void determineNotNullFlags(Archive *fout, PGresult *res, int r, TableInfo *tbinfo, int j, int i_notnull_name, int i_notnull_comment, int i_notnull_invalidoid, int i_notnull_noinherit, int i_notnull_islocal, PQExpBuffer *invalidnotnulloids)
static void dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
static void dumpTSParser(Archive *fout, const TSParserInfo *prsinfo)
static void expand_foreign_server_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids)
TableInfo * getTables(Archive *fout, int *numTables)
static void dumpRule(Archive *fout, const RuleInfo *rinfo)
static void dumpCompositeType(Archive *fout, const TypeInfo *tyinfo)
static void dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
static void dumpExtension(Archive *fout, const ExtensionInfo *extinfo)
#define fmtQualifiedDumpable(obj)
static bool nonemptyReloptions(const char *reloptions)
static SimpleStringList extension_exclude_patterns
static BinaryUpgradeClassOidItem * binaryUpgradeClassOids
static SimpleOidList table_include_oids
static void dumpStatisticsExtStats(Archive *fout, const StatsExtInfo *statsextinfo)
void getExtendedStatistics(Archive *fout)
static NamespaceInfo * findNamespace(Oid nsoid)
static char * get_synchronized_snapshot(Archive *fout)
static int dumpLOs(Archive *fout, const void *arg)
static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
static void appendNamedArgument(PQExpBuffer out, Archive *fout, const char *argname, const char *argtype, const char *argval)
void processExtensionTables(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
static void dumpEventTrigger(Archive *fout, const EventTriggerInfo *evtinfo)
static int BinaryUpgradeClassOidItemCmp(const void *p1, const void *p2)
static void dumpCommentExtended(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId, const char *initdb_comment)
void getDefaultACLs(Archive *fout)
static SimpleStringList tabledata_exclude_patterns
static void dumpConversion(Archive *fout, const ConvInfo *convinfo)
static void dumpForeignDataWrapper(Archive *fout, const FdwInfo *fdwinfo)
static void dumpProcLang(Archive *fout, const ProcLangInfo *plang)
static void dumpSecLabel(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId)
void getSubscriptions(Archive *fout)
static void collectSecLabels(Archive *fout)
static void selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
static void collectSequences(Archive *fout)
static Oid g_last_builtin_oid
#define MAX_ATTR_STATS_RELS
void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
void getTransforms(Archive *fout)
void getEventTriggers(Archive *fout)
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode)
static void read_dump_filters(const char *filename, DumpOptions *dopt)
static void dumpTSConfig(Archive *fout, const TSConfigInfo *cfginfo)
static SecLabelItem * seclabels
static SimpleStringList tabledata_exclude_patterns_and_children
static char * get_language_name(Archive *fout, Oid langid)
static bool checkExtensionMembership(DumpableObject *dobj, Archive *fout)
static CommentItem * comments
static int dumpTableData_insert(Archive *fout, const void *dcontext)
static SimpleOidList tabledata_exclude_oids
static SimpleStringList table_exclude_patterns_and_children
static void binary_upgrade_set_pg_class_oids(Archive *fout, PQExpBuffer upgrade_buffer, Oid pg_class_oid)
void getTSTemplates(Archive *fout)
static void set_restrict_relation_kind(Archive *AH, const char *value)
static char * format_aggregate_signature(const AggInfo *agginfo, Archive *fout, bool honor_quotes)
void getProcLangs(Archive *fout)
static void dumpSequence(Archive *fout, const TableInfo *tbinfo)
bool shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
static TableInfo * getRootTableInfo(const TableInfo *tbinfo)
void getSubscriptionRelations(Archive *fout)
void getOperators(Archive *fout)
static SimpleOidList foreign_servers_include_oids
static void dumpCollation(Archive *fout, const CollInfo *collinfo)
static void dumpTableSecLabel(Archive *fout, const TableInfo *tbinfo, const char *reltypename)
static void dumpCompositeTypeColComments(Archive *fout, const TypeInfo *tyinfo, PGresult *res)
static void expand_extension_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names)
void getOpfamilies(Archive *fout)
static void selectDumpableType(TypeInfo *tyinfo, Archive *fout)
static SimpleOidList schema_include_oids
static void dumpOpclass(Archive *fout, const OpclassInfo *opcinfo)
static SimpleStringList schema_exclude_patterns
#define DUMP_COMPONENT_COMMENT
#define DUMP_COMPONENT_DATA
#define DUMP_COMPONENT_USERMAP
#define DUMP_COMPONENT_POLICY
#define DUMP_COMPONENT_SECLABEL
#define DUMP_COMPONENT_ALL
#define DUMP_COMPONENT_ACL
#define DUMP_COMPONENT_NONE
#define DUMP_COMPONENTS_REQUIRING_LOCK
void sortDumpableObjects(DumpableObject **objs, int numObjs, DumpId preBoundaryId, DumpId postBoundaryId)
#define DUMP_COMPONENT_DEFINITION
@ DO_PUBLICATION_TABLE_IN_SCHEMA
void sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs)
#define DUMP_COMPONENT_STATISTICS
static int statistics_only
static int with_statistics
PGDLLIMPORT char * optarg
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define pg_encoding_to_char
#define pg_log_warning(...)
int pg_strcasecmp(const char *s1, const char *s2)
const char * get_progname(const char *argv0)
void printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
PQExpBuffer createPQExpBuffer(void)
void initPQExpBuffer(PQExpBuffer str)
void resetPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen)
void destroyPQExpBuffer(PQExpBuffer str)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
void termPQExpBuffer(PQExpBuffer str)
char * psprintf(const char *fmt,...)
#define RelFileNumberIsValid(relnumber)
bool quote_all_identifiers
void simple_string_list_append(SimpleStringList *list, const char *val)
void simple_ptr_list_append(SimplePtrList *list, void *ptr)
bool simple_oid_list_member(SimpleOidList *list, Oid val)
void simple_oid_list_append(SimpleOidList *list, Oid val)
PGconn * GetConnection(void)
const char * fmtId(const char *rawid)
void setFmtEncoding(int encoding)
void appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
void appendPGArray(PQExpBuffer buffer, const char *value)
bool processSQLNamePattern(PGconn *conn, PQExpBuffer buf, const char *pattern, bool have_where, bool force_escape, const char *schemavar, const char *namevar, const char *altnamevar, const char *visibilityrule, PQExpBuffer dbnamebuf, int *dotcnt)
bool parsePGArray(const char *atext, char ***itemarray, int *nitems)
bool appendReloptionsArray(PQExpBuffer buffer, const char *reloptions, const char *prefix, int encoding, bool std_strings)
void appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
RelFileNumber toast_index_relfilenumber
RelFileNumber toast_relfilenumber
RelFileNumber relfilenumber
struct SimplePtrListCell * next
char val[FLEXIBLE_ARRAY_MEMBER]
struct SimpleStringListCell * next
SimpleStringListCell * head
char * suboriginremotelsn
int disable_dollar_quoting
int serializable_deferrable
int no_unlogged_table_data
const char * lockWaitTimeout
int load_via_partition_root
DumpComponents components
DumpableObjectType objType
DumpComponents dump_contains
pg_compress_specification compression_spec
int disable_dollar_quoting
const char * lockWaitTimeout
struct _relStatsInfo * stats
bool is_identity_sequence
struct _tableInfo ** parents
struct _tableDataInfo * dataObj
const void * defnDumperArg
#define MinTransactionIdAttributeNumber
#define MaxCommandIdAttributeNumber
#define MaxTransactionIdAttributeNumber
#define TableOidAttributeNumber
#define SelfItemPointerAttributeNumber
#define MinCommandIdAttributeNumber
static StringInfo copybuf
static void * fn(void *arg)
#define FirstNormalObjectId
static char * error_detail
bool SplitGUCList(char *rawstring, char separator, List **namelist)