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_default_acl_d.h"
51 #include "catalog/pg_largeobject_d.h"
52 #include "catalog/pg_largeobject_metadata_d.h"
53 #include "catalog/pg_proc_d.h"
55 #include "catalog/pg_trigger_d.h"
56 #include "catalog/pg_type_d.h"
180 #define DUMP_DEFAULT_ROWS_PER_INSERT 1
187 #define MAX_BLOBS_PER_ARCHIVE_ENTRY 1000
192 #define fmtQualifiedDumpable(obj) \
193 fmtQualifiedId((obj)->dobj.namespace->dobj.name, \
198 const char *dumpencoding,
const char *dumpsnapshot,
216 bool with_child_tables);
218 const char *pattern);
223 static const char *
getRoleName(
const char *roleoid_str);
227 const char *
name,
const char *
namespace,
230 const char *initdb_comment);
232 const char *
name,
const char *
namespace,
234 int subid,
DumpId dumpId);
238 const char *
namespace,
const char *owner,
287 const char *servername,
const char *
namespace,
293 const char *nspname,
const char *tag,
const char *owner,
299 DumpId **dependencies,
int *nDeps,
int *allocDeps);
314 const FuncInfo *finfo,
bool honor_quotes);
336 bool force_array_type,
337 bool include_multirange_type);
349 const char *objnamespace);
354 const char *prefix,
Archive *fout);
377 bool g_verbose =
false;
378 const char *dumpencoding = NULL;
379 const char *dumpsnapshot = NULL;
380 char *use_role = NULL;
386 char *compression_detail = NULL;
387 char *compression_algorithm_str =
"none";
388 char *error_detail = NULL;
389 bool user_compression_defined =
false;
394 static struct option long_options[] = {
407 {
"jobs", 1, NULL,
'j'},
486 if (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-?") == 0)
491 if (strcmp(argv[1],
"--version") == 0 || strcmp(argv[1],
"-V") == 0)
493 puts(
"pg_dump (PostgreSQL) " PG_VERSION);
500 while ((
c =
getopt_long(argc, argv,
"abBcCd:e:E:f:F:h:j:n:N:Op:RsS:t:T:U:vwWxZ:",
501 long_options, &optindex)) != -1)
618 &compression_detail);
619 user_compression_defined =
true;
725 pg_log_error(
"too many command-line arguments (first is \"%s\")",
744 pg_fatal(
"options -s/--schema-only and -a/--data-only cannot be used together");
747 pg_fatal(
"options -s/--schema-only and --include-foreign-data cannot be used together");
750 pg_fatal(
"option --include-foreign-data is not supported with parallel backup");
753 pg_fatal(
"options -c/--clean and -a/--data-only cannot be used together");
756 pg_fatal(
"option --if-exists requires option -c/--clean");
763 pg_fatal(
"option --on-conflict-do-nothing requires option --inserts, --rows-per-insert, or --column-inserts");
778 !user_compression_defined)
781 compression_algorithm_str =
"gzip";
783 compression_algorithm_str =
"none";
792 pg_fatal(
"unrecognized compression algorithm: \"%s\"",
793 compression_algorithm_str);
798 if (error_detail != NULL)
799 pg_fatal(
"invalid compression specification: %s",
803 if (error_detail != NULL)
812 pg_log_warning(
"compression option \"%s\" is not currently supported by pg_dump",
824 pg_fatal(
"parallel backup only supported by the directory format");
879 pg_fatal(
"no matching schemas were found");
896 pg_fatal(
"no matching tables were found");
924 pg_fatal(
"no matching extensions were found");
963 getTableData(&dopt, tblinfo, numTables, RELKIND_SEQUENCE);
1016 boundaryObjs[0].dumpId, boundaryObjs[1].dumpId);
1035 for (
i = 0;
i < numObjs;
i++)
1112 printf(
_(
"%s dumps a database as a text file or to other formats.\n\n"),
progname);
1116 printf(
_(
"\nGeneral options:\n"));
1117 printf(
_(
" -f, --file=FILENAME output file or directory name\n"));
1118 printf(
_(
" -F, --format=c|d|t|p output file format (custom, directory, tar,\n"
1119 " plain text (default))\n"));
1120 printf(
_(
" -j, --jobs=NUM use this many parallel jobs to dump\n"));
1121 printf(
_(
" -v, --verbose verbose mode\n"));
1122 printf(
_(
" -V, --version output version information, then exit\n"));
1123 printf(
_(
" -Z, --compress=METHOD[:DETAIL]\n"
1124 " compress as specified\n"));
1125 printf(
_(
" --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock\n"));
1126 printf(
_(
" --no-sync do not wait for changes to be written safely to disk\n"));
1127 printf(
_(
" --sync-method=METHOD set method for syncing files to disk\n"));
1128 printf(
_(
" -?, --help show this help, then exit\n"));
1130 printf(
_(
"\nOptions controlling the output content:\n"));
1131 printf(
_(
" -a, --data-only dump only the data, not the schema\n"));
1132 printf(
_(
" -b, --large-objects include large objects in dump\n"));
1133 printf(
_(
" --blobs (same as --large-objects, deprecated)\n"));
1134 printf(
_(
" -B, --no-large-objects exclude large objects in dump\n"));
1135 printf(
_(
" --no-blobs (same as --no-large-objects, deprecated)\n"));
1136 printf(
_(
" -c, --clean clean (drop) database objects before recreating\n"));
1137 printf(
_(
" -C, --create include commands to create database in dump\n"));
1138 printf(
_(
" -e, --extension=PATTERN dump the specified extension(s) only\n"));
1139 printf(
_(
" -E, --encoding=ENCODING dump the data in encoding ENCODING\n"));
1140 printf(
_(
" -n, --schema=PATTERN dump the specified schema(s) only\n"));
1141 printf(
_(
" -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
1142 printf(
_(
" -O, --no-owner skip restoration of object ownership in\n"
1143 " plain-text format\n"));
1144 printf(
_(
" -s, --schema-only dump only the schema, no data\n"));
1145 printf(
_(
" -S, --superuser=NAME superuser user name to use in plain-text format\n"));
1146 printf(
_(
" -t, --table=PATTERN dump only the specified table(s)\n"));
1147 printf(
_(
" -T, --exclude-table=PATTERN do NOT dump the specified table(s)\n"));
1148 printf(
_(
" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
1149 printf(
_(
" --binary-upgrade for use by upgrade utilities only\n"));
1150 printf(
_(
" --column-inserts dump data as INSERT commands with column names\n"));
1151 printf(
_(
" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
1152 printf(
_(
" --disable-triggers disable triggers during data-only restore\n"));
1153 printf(
_(
" --enable-row-security enable row security (dump only content user has\n"
1155 printf(
_(
" --exclude-extension=PATTERN do NOT dump the specified extension(s)\n"));
1156 printf(
_(
" --exclude-table-and-children=PATTERN\n"
1157 " do NOT dump the specified table(s), including\n"
1158 " child and partition tables\n"));
1159 printf(
_(
" --exclude-table-data=PATTERN do NOT dump data for the specified table(s)\n"));
1160 printf(
_(
" --exclude-table-data-and-children=PATTERN\n"
1161 " do NOT dump data for the specified table(s),\n"
1162 " including child and partition tables\n"));
1163 printf(
_(
" --extra-float-digits=NUM override default setting for extra_float_digits\n"));
1164 printf(
_(
" --filter=FILENAME include or exclude objects and data from dump\n"
1165 " based on expressions in FILENAME\n"));
1166 printf(
_(
" --if-exists use IF EXISTS when dropping objects\n"));
1167 printf(
_(
" --include-foreign-data=PATTERN\n"
1168 " include data of foreign tables on foreign\n"
1169 " servers matching PATTERN\n"));
1170 printf(
_(
" --inserts dump data as INSERT commands, rather than COPY\n"));
1171 printf(
_(
" --load-via-partition-root load partitions via the root table\n"));
1172 printf(
_(
" --no-comments do not dump comments\n"));
1173 printf(
_(
" --no-publications do not dump publications\n"));
1174 printf(
_(
" --no-security-labels do not dump security label assignments\n"));
1175 printf(
_(
" --no-subscriptions do not dump subscriptions\n"));
1176 printf(
_(
" --no-table-access-method do not dump table access methods\n"));
1177 printf(
_(
" --no-tablespaces do not dump tablespace assignments\n"));
1178 printf(
_(
" --no-toast-compression do not dump TOAST compression methods\n"));
1179 printf(
_(
" --no-unlogged-table-data do not dump unlogged table data\n"));
1180 printf(
_(
" --on-conflict-do-nothing add ON CONFLICT DO NOTHING to INSERT commands\n"));
1181 printf(
_(
" --quote-all-identifiers quote all identifiers, even if not key words\n"));
1182 printf(
_(
" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
1183 printf(
_(
" --section=SECTION dump named section (pre-data, data, or post-data)\n"));
1184 printf(
_(
" --serializable-deferrable wait until the dump can run without anomalies\n"));
1185 printf(
_(
" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
1186 printf(
_(
" --strict-names require table and/or schema include patterns to\n"
1187 " match at least one entity each\n"));
1188 printf(
_(
" --table-and-children=PATTERN dump only the specified table(s), including\n"
1189 " child and partition tables\n"));
1190 printf(
_(
" --use-set-session-authorization\n"
1191 " use SET SESSION AUTHORIZATION commands instead of\n"
1192 " ALTER OWNER commands to set ownership\n"));
1194 printf(
_(
"\nConnection options:\n"));
1195 printf(
_(
" -d, --dbname=DBNAME database to dump\n"));
1196 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
1197 printf(
_(
" -p, --port=PORT database server port number\n"));
1198 printf(
_(
" -U, --username=NAME connect as specified database user\n"));
1199 printf(
_(
" -w, --no-password never prompt for password\n"));
1200 printf(
_(
" -W, --password force password prompt (should happen automatically)\n"));
1201 printf(
_(
" --role=ROLENAME do SET ROLE before dump\n"));
1203 printf(
_(
"\nIf no database name is supplied, then the PGDATABASE environment\n"
1204 "variable value is used.\n\n"));
1205 printf(
_(
"Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
1206 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
1211 const char *dumpsnapshot,
char *use_role)
1215 const char *std_strings;
1225 pg_fatal(
"invalid client encoding \"%s\" specified",
1236 AH->
std_strings = (std_strings && strcmp(std_strings,
"on") == 0);
1338 "SET TRANSACTION ISOLATION LEVEL "
1339 "SERIALIZABLE, READ ONLY, DEFERRABLE");
1342 "SET TRANSACTION ISOLATION LEVEL "
1343 "REPEATABLE READ, READ ONLY");
1365 pg_fatal(
"parallel dumps from standby servers are not supported by this server version");
1389 char *query =
"SELECT pg_catalog.pg_export_snapshot()";
1431 return archiveFormat;
1449 if (patterns->
head == NULL)
1459 for (cell = patterns->
head; cell; cell = cell->
next)
1465 "SELECT oid FROM pg_catalog.pg_namespace n\n");
1468 false, NULL,
"n.nspname", NULL, NULL, &dbbuf,
1471 pg_fatal(
"improper qualified name (too many dotted names): %s",
1473 else if (dotcnt == 1)
1479 pg_fatal(
"no matching schemas were found for pattern \"%s\"", cell->
val);
1508 if (patterns->
head == NULL)
1517 for (cell = patterns->
head; cell; cell = cell->
next)
1522 "SELECT oid FROM pg_catalog.pg_extension e\n");
1524 false, NULL,
"e.extname", NULL, NULL, NULL,
1527 pg_fatal(
"improper qualified name (too many dotted names): %s",
1532 pg_fatal(
"no matching extensions were found for pattern \"%s\"", cell->
val);
1560 if (patterns->
head == NULL)
1570 for (cell = patterns->
head; cell; cell = cell->
next)
1575 "SELECT oid FROM pg_catalog.pg_foreign_server s\n");
1577 false, NULL,
"s.srvname", NULL, NULL, NULL,
1580 pg_fatal(
"improper qualified name (too many dotted names): %s",
1585 pg_fatal(
"no matching foreign servers were found for pattern \"%s\"", cell->
val);
1612 if (patterns->
head == NULL)
1622 for (cell = patterns->
head; cell; cell = cell->
next)
1635 if (with_child_tables)
1642 "\nFROM pg_catalog.pg_class c"
1643 "\n LEFT JOIN pg_catalog.pg_namespace n"
1644 "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace"
1645 "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY"
1646 "\n (array['%c', '%c', '%c', '%c', '%c', '%c'])\n",
1647 RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW,
1648 RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE,
1649 RELKIND_PARTITIONED_TABLE);
1652 false,
"n.nspname",
"c.relname", NULL,
1653 "pg_catalog.pg_table_is_visible(c.oid)", &dbbuf,
1656 pg_fatal(
"improper relation name (too many dotted names): %s",
1658 else if (dotcnt == 2)
1662 if (with_child_tables)
1665 "\nSELECT i.inhrelid"
1666 "\nFROM partition_tree p"
1667 "\n JOIN pg_catalog.pg_inherits i"
1668 "\n ON p.relid OPERATOR(pg_catalog.=) i.inhparent"
1670 "\nSELECT relid FROM partition_tree");
1678 pg_fatal(
"no matching tables were found for pattern \"%s\"", cell->
val);
1705 pg_fatal(
"You are currently not connected to a database.");
1707 if (strcmp(db,
dbname) != 0)
1708 pg_fatal(
"cross-database references are not implemented: %s",
1796 strcmp(nsinfo->
dobj.
name,
"pg_catalog") == 0)
1805 else if (strncmp(nsinfo->
dobj.
name,
"pg_", 3) == 0 ||
1806 strcmp(nsinfo->
dobj.
name,
"information_schema") == 0)
1811 else if (strcmp(nsinfo->
dobj.
name,
"public") == 0)
1823 if (nsinfo->
nspowner == ROLE_PG_DATABASE_OWNER)
1903 tyinfo->
typrelkind != RELKIND_COMPOSITE_TYPE)
1908 if (tytable != NULL)
1948 if (dinfo->
dobj.namespace)
2136 if (dobj->namespace)
2153 const char *classname = tbinfo->
dobj.
name;
2165 const char *column_list;
2167 pg_log_info(
"dumping contents of table \"%s.%s\"",
2168 tbinfo->
dobj.namespace->dobj.
name, classname);
2187 if (strlen(column_list) > 2)
2273 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetCopyData() failed.", classname);
2283 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetResult() failed.", classname);
2292 pg_log_warning(
"unexpected extra results during COPY of table \"%s\"",
2320 int rows_this_statement = 0;
2365 pg_fatal(
"wrong number of fields retrieved from table \"%s\"",
2375 if (insertStmt == NULL)
2407 for (
int field = 0; field < nfields; field++)
2427 if (rows_this_statement == 0)
2443 if (rows_per_statement == 1)
2445 else if (rows_this_statement > 0)
2450 for (
int field = 0; field < nfields; field++)
2454 if (attgenerated[field])
2489 if (strspn(s,
"0123456789 +-eE.") == strlen(s))
2524 if (++rows_this_statement >= rows_per_statement)
2527 archputs(
" ON CONFLICT DO NOTHING;\n", fout);
2531 rows_this_statement = 0;
2544 if (rows_this_statement > 0)
2547 archputs(
" ON CONFLICT DO NOTHING;\n", fout);
2557 if (insertStmt != NULL)
2576 parentTbinfo = tbinfo->
parents[0];
2580 parentTbinfo = parentTbinfo->
parents[0];
2583 return parentTbinfo;
2601 parentTbinfo = tbinfo->
parents[0];
2607 parentTbinfo = parentTbinfo->
parents[0];
2629 char *tdDefn = NULL;
2631 const char *copyFrom;
2666 copyStmt = copyBuf->
data;
2686 .namespace = tbinfo->
dobj.namespace->dobj.
name,
2688 .description =
"TABLE DATA",
2690 .createStmt = tdDefn,
2691 .copyStmt = copyStmt,
2695 .dumpArg = tdinfo));
2753 .namespace = tbinfo->
dobj.namespace->dobj.
name,
2755 .description =
"MATERIALIZED VIEW DATA",
2757 .createStmt = q->
data,
2773 for (
i = 0;
i < numTables;
i++)
2776 (!relkind || tblinfo[
i].
relkind == relkind))
2800 if (tbinfo->
relkind == RELKIND_VIEW)
2803 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
2809 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
2825 if (tbinfo->
relkind == RELKIND_MATVIEW)
2827 else if (tbinfo->
relkind == RELKIND_SEQUENCE)
2840 tdinfo->
dobj.namespace = tbinfo->
dobj.namespace;
2880 "SELECT d1.objid, d2.refobjid, c2.relkind AS refrelkind "
2881 "FROM pg_depend d1 "
2882 "JOIN pg_class c1 ON c1.oid = d1.objid "
2884 " JOIN pg_rewrite r1 ON r1.ev_class = d1.objid "
2885 "JOIN pg_depend d2 ON d2.classid = 'pg_rewrite'::regclass "
2886 "AND d2.objid = r1.oid "
2887 "AND d2.refobjid <> d1.objid "
2888 "JOIN pg_class c2 ON c2.oid = d2.refobjid "
2889 "AND c2.relkind IN (" CppAsString2(RELKIND_MATVIEW)
","
2891 "WHERE d1.classid = 'pg_class'::regclass "
2893 "SELECT w.objid, d3.refobjid, c3.relkind "
2895 "JOIN pg_rewrite r3 ON r3.ev_class = w.refobjid "
2896 "JOIN pg_depend d3 ON d3.classid = 'pg_rewrite'::regclass "
2897 "AND d3.objid = r3.oid "
2898 "AND d3.refobjid <> w.refobjid "
2899 "JOIN pg_class c3 ON c3.oid = d3.refobjid "
2900 "AND c3.relkind IN (" CppAsString2(RELKIND_MATVIEW)
","
2903 "SELECT 'pg_class'::regclass::oid AS classid, objid, refobjid "
2915 for (
i = 0;
i < ntups;
i++)
2942 if (refdobj == NULL)
2949 if (refdobj == NULL)
2985 for (
i = 0;
i < numObjs;
i++)
2997 if (ftable == NULL ||
3070 "pg_encoding_to_char(encoding) AS encoding, "
3071 "datcollate, datctype, datfrozenxid, "
3072 "datacl, acldefault('d', datdba) AS acldefault, "
3073 "datistemplate, datconnlimit, ");
3083 appendPQExpBufferStr(dbQry,
"'c' AS datlocprovider, NULL AS datlocale, NULL AS datcollversion, ");
3089 "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
3090 "shobj_description(oid, 'pg_database') AS description "
3092 "WHERE datname = current_database()");
3155 "CREATE DATABASE %s WITH TEMPLATE = template0 "
3156 "OID = %u STRATEGY = FILE_COPY",
3157 qdatname, dbCatId.
oid);
3178 pg_fatal(
"unrecognized locale provider: %s",
3181 if (strlen(collate) > 0 && strcmp(collate, ctype) == 0)
3188 if (strlen(collate) > 0)
3193 if (strlen(ctype) > 0)
3256 .createStmt = creaQry->
data,
3257 .dropStmt = delQry->
data));
3286 .description =
"COMMENT",
3288 .createStmt = dbQry->
data,
3306 if (seclabelQry->
len > 0)
3310 .description =
"SECURITY LABEL",
3312 .createStmt = seclabelQry->
data,
3327 qdatname, NULL, NULL,
3328 NULL, dba, &dbdacl);
3358 "SET datistemplate = false WHERE datname = ");
3379 "SET datfrozenxid = '%u', datminmxid = '%u'\n"
3381 frozenxid, minmxid);
3386 if (creaQry->
len > 0)
3392 .createStmt = creaQry->
data,
3393 .dropStmt = delQry->
data,
3394 .deps = &dbDumpId));
3406 int ii_relfrozenxid,
3415 appendPQExpBuffer(loFrozenQry,
"SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
3416 "FROM pg_catalog.pg_class\n"
3417 "WHERE oid IN (%u, %u);\n",
3418 LargeObjectRelationId, LargeObjectLOidPNIndexId);
3420 appendPQExpBuffer(loFrozenQry,
"SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
3421 "FROM pg_catalog.pg_class\n"
3422 "WHERE oid IN (%u, %u);\n",
3423 LargeObjectRelationId, LargeObjectLOidPNIndexId);
3427 ii_relfrozenxid =
PQfnumber(lo_res,
"relfrozenxid");
3428 ii_relminmxid =
PQfnumber(lo_res,
"relminmxid");
3429 ii_relfilenode =
PQfnumber(lo_res,
"relfilenode");
3432 appendPQExpBufferStr(loHorizonQry,
"\n-- For binary upgrade, set pg_largeobject relfrozenxid and relminmxid\n");
3433 appendPQExpBufferStr(loOutQry,
"\n-- For binary upgrade, preserve pg_largeobject and index relfilenodes\n");
3440 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
3441 "WHERE oid = %u;\n",
3449 if (oid == LargeObjectRelationId)
3451 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
3453 else if (oid == LargeObjectLOidPNIndexId)
3455 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
3460 "TRUNCATE pg_catalog.pg_largeobject;\n");
3467 .createStmt = loOutQry->
data));
3499 "WHERE setrole = 0 AND setdatabase = '%u'::oid",
3506 "DATABASE",
dbname, NULL, NULL,
3513 "FROM pg_db_role_setting s, pg_roles r "
3514 "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
3549 .createStmt = qry->
data));
3561 const char *stdstrings = AH->
std_strings ?
"on" :
"off";
3564 pg_log_info(
"saving \"standard_conforming_strings = %s\"",
3574 .createStmt = qry->
data));
3588 char **schemanames = NULL;
3589 int nschemanames = 0;
3600 "SELECT pg_catalog.current_schemas(false)");
3603 pg_fatal(
"could not parse result of current_schemas()");
3611 for (
i = 0;
i < nschemanames;
i++)
3628 .createStmt = qry->
data));
3665 "SELECT oid, lomowner, lomacl, "
3666 "acldefault('L', lomowner) AS acldefault "
3667 "FROM pg_largeobject_metadata "
3668 "ORDER BY lomowner, lomacl::pg_catalog.text, oid");
3687 for (
i = 0;
i < ntups;
i += n)
3700 if (strcmp(thisowner,
PQgetvalue(
res,
i + n, i_lomowner)) != 0 ||
3715 snprintf(namebuf,
sizeof(namebuf),
"%u..%u", thisoid,
3718 snprintf(namebuf,
sizeof(namebuf),
"%u", thisoid);
3726 loinfo->
looids[0] = thisoid;
3728 for (
int k = 1; k < n; k++)
3735 extraID.
tableoid = LargeObjectRelationId;
3791 for (
int i = 0;
i < loinfo->
numlos;
i++)
3798 .description =
"BLOB METADATA",
3800 .createStmt = cquery->
data,
3801 .dropStmt =
"-- dummy"));
3810 for (
int i = 0;
i < loinfo->
numlos;
i++)
3850 snprintf(tagbuf,
sizeof(tagbuf),
"LARGE OBJECTS %u..%u",
3854 "LARGE OBJECT", namebuf, NULL, NULL,
3860 "LARGE OBJECT", namebuf, NULL, NULL,
3881 for (
int i = 0;
i < loinfo->
numlos;
i++)
3890 pg_fatal(
"could not open large object %u: %s",
3900 pg_fatal(
"error reading large object %u: %s",
3930 int i_polpermissive;
3949 for (
i = 0;
i < numTables;
i++)
3958 if (tbinfo->
relkind != RELKIND_RELATION &&
3959 tbinfo->
relkind != RELKIND_PARTITIONED_TABLE)
3963 if (tbloids->
len > 1)
3984 polinfo->
dobj.namespace = tbinfo->
dobj.namespace;
4003 pg_log_info(
"reading row-level security policies");
4006 "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
4012 "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
4013 " 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, "
4014 "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
4015 "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
4016 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
4017 "JOIN pg_catalog.pg_policy pol ON (src.tbloid = pol.polrelid)",
4037 for (
j = 0;
j < ntups;
j++)
4049 polinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
4058 polinfo[
j].polroles = NULL;
4121 .namespace = polinfo->
dobj.namespace->dobj.
name,
4123 .description =
"ROW SECURITY",
4125 .createStmt = query->
data,
4133 if (polinfo->
polcmd ==
'*')
4135 else if (polinfo->
polcmd ==
'r')
4136 cmd =
" FOR SELECT";
4137 else if (polinfo->
polcmd ==
'a')
4138 cmd =
" FOR INSERT";
4139 else if (polinfo->
polcmd ==
'w')
4140 cmd =
" FOR UPDATE";
4141 else if (polinfo->
polcmd ==
'd')
4142 cmd =
" FOR DELETE";
4144 pg_fatal(
"unexpected policy command type: %c",
4180 .
namespace = polinfo->
dobj.namespace->dobj.
name,
4182 .description =
"POLICY",
4184 .createStmt = query->
data,
4185 .dropStmt = delqry->
data));
4233 "SELECT p.tableoid, p.oid, p.pubname, "
4235 "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, p.pubviaroot "
4236 "FROM pg_publication p");
4239 "SELECT p.tableoid, p.oid, p.pubname, "
4241 "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, p.pubtruncate, false AS pubviaroot "
4242 "FROM pg_publication p");
4245 "SELECT p.tableoid, p.oid, p.pubname, "
4247 "p.puballtables, p.pubinsert, p.pubupdate, p.pubdelete, false AS pubtruncate, false AS pubviaroot "
4248 "FROM pg_publication p");
4267 for (
i = 0;
i < ntups;
i++)
4373 .description =
"PUBLICATION",
4375 .createStmt = query->
data,
4376 .dropStmt = delq->
data));
4419 "SELECT tableoid, oid, pnpubid, pnnspid "
4420 "FROM pg_catalog.pg_publication_namespace");
4434 for (
i = 0;
i < ntups;
i++)
4446 if (pubinfo == NULL)
4449 if (nspinfo == NULL)
4465 pubsinfo[
j].
dobj.namespace = nspinfo->
dobj.namespace;
4509 "SELECT tableoid, oid, prpubid, prrelid, "
4510 "pg_catalog.pg_get_expr(prqual, prrelid) AS prrelqual, "
4512 " WHEN pr.prattrs IS NOT NULL THEN\n"
4513 " (SELECT array_agg(attname)\n"
4515 " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
4516 " pg_catalog.pg_attribute\n"
4517 " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
4518 " ELSE NULL END) prattrs "
4519 "FROM pg_catalog.pg_publication_rel pr");
4522 "SELECT tableoid, oid, prpubid, prrelid, "
4523 "NULL AS prrelqual, NULL AS prattrs "
4524 "FROM pg_catalog.pg_publication_rel");
4540 for (
i = 0;
i < ntups;
i++)
4552 if (pubinfo == NULL)
4567 pubrinfo[
j].dobj.catId.tableoid =
4571 pubrinfo[
j].dobj.namespace = tbinfo->
dobj.namespace;
4572 pubrinfo[
j].dobj.name = tbinfo->
dobj.
name;
4573 pubrinfo[
j].publication = pubinfo;
4574 pubrinfo[
j].pubtable = tbinfo;
4576 pubrinfo[
j].pubrelqual = NULL;
4587 &attnames, &nattnames))
4588 pg_fatal(
"could not parse %s array",
"prattrs");
4590 for (
int k = 0; k < nattnames; k++)
4597 pubrinfo[
j].pubrattrs = attribs->
data;
4600 pubrinfo[
j].pubrattrs = NULL;
4643 .
namespace = schemainfo->
dobj.
name,
4645 .description =
"PUBLICATION TABLES IN SCHEMA",
4647 .createStmt = query->
data));
4681 if (pubrinfo->pubrattrs)
4684 if (pubrinfo->pubrelqual)
4703 ArchiveEntry(fout, pubrinfo->dobj.catId, pubrinfo->dobj.dumpId,
4705 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
4707 .description =
"PUBLICATION TABLE",
4709 .createStmt = query->
data));
4728 if (
val && strcmp(
val,
"on") == 0)
4751 int i_subtwophasestate;
4752 int i_subdisableonerr;
4753 int i_subpasswordrequired;
4754 int i_subrunasowner;
4757 int i_subsynccommit;
4758 int i_subpublications;
4760 int i_suboriginremotelsn;
4774 "SELECT count(*) FROM pg_subscription "
4775 "WHERE subdbid = (SELECT oid FROM pg_database"
4776 " WHERE datname = current_database())",
4780 pg_log_warning(
"subscriptions not dumped because current user is not a superuser");
4789 "SELECT s.tableoid, s.oid, s.subname,\n"
4791 " s.subconninfo, s.subslotname, s.subsynccommit,\n"
4792 " s.subpublications,\n");
4806 " s.subtwophasestate,\n"
4807 " s.subdisableonerr,\n");
4810 " '%c' AS subtwophasestate,\n"
4811 " false AS subdisableonerr,\n",
4816 " s.subpasswordrequired,\n"
4817 " s.subrunasowner,\n"
4821 " 't' AS subpasswordrequired,\n"
4822 " 't' AS subrunasowner,\n"
4823 " '%s' AS suborigin,\n",
4828 " s.subenabled,\n");
4831 " false AS subenabled,\n");
4835 " s.subfailover\n");
4838 " false AS subfailover\n");
4841 "FROM pg_subscription s\n");
4845 "LEFT JOIN pg_catalog.pg_replication_origin_status o \n"
4846 " ON o.external_id = 'pg_' || s.oid::text \n");
4849 "WHERE s.subdbid = (SELECT oid FROM pg_database\n"
4850 " WHERE datname = current_database())");
4866 i_subtwophasestate =
PQfnumber(
res,
"subtwophasestate");
4868 i_subpasswordrequired =
PQfnumber(
res,
"subpasswordrequired");
4875 i_suboriginremotelsn =
PQfnumber(
res,
"suboriginremotelsn");
4881 for (
i = 0;
i < ntups;
i++)
4957 "SELECT srsubid, srrelid, srsubstate, srsublsn "
4958 "FROM pg_catalog.pg_subscription_rel "
4972 for (
int i = 0;
i < ntups;
i++)
4982 if (cur_srsubid != last_srsubid)
4985 if (subinfo == NULL)
4986 pg_fatal(
"subscription with OID %u does not exist", cur_srsubid);
4988 last_srsubid = cur_srsubid;
4992 if (tblinfo == NULL)
4993 pg_fatal(
"failed sanity check, table with OID %u not found",
5050 "\n-- For binary upgrade, must preserve the subscriber table.\n");
5052 "SELECT pg_catalog.binary_upgrade_add_sub_rel_state(");
5079 .description =
"SUBSCRIPTION TABLE",
5081 .createStmt = query->
data));
5101 char **pubnames = NULL;
5124 pg_fatal(
"could not parse %s array",
"subpublications");
5127 for (
i = 0;
i < npubnames;
i++)
5135 appendPQExpBuffer(query,
" PUBLICATION %s WITH (connect = false, slot_name = ", publications->
data);
5141 if (strcmp(subinfo->
subbinary,
"t") == 0)
5144 if (strcmp(subinfo->
substream,
"t") == 0)
5146 else if (strcmp(subinfo->
substream,
"p") == 0)
5190 "\n-- For binary upgrade, must preserve the remote_lsn for the subscriber's replication origin.\n");
5192 "SELECT pg_catalog.binary_upgrade_replorigin_advance(");
5204 "\n-- For binary upgrade, must preserve the subscriber's running state.\n");
5213 .description =
"SUBSCRIPTION",
5215 .createStmt = query->
data,
5216 .dropStmt = delq->
data));
5244 const char *catalog,
5245 const char *keyword,
5246 const char *objname)
5263 "FROM pg_catalog.pg_depend d, pg_catalog.pg_extension e "
5264 "WHERE d.refobjid = e.oid AND classid = '%s'::pg_catalog.regclass "
5265 "AND objid = '%u'::pg_catalog.oid AND deptype = 'x' "
5266 "AND refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass",
5272 for (
i = 0;
i < ntups;
i++)
5302 ++next_possible_free_oid;
5304 "SELECT EXISTS(SELECT 1 "
5305 "FROM pg_catalog.pg_type "
5306 "WHERE oid = '%u'::pg_catalog.oid);",
5307 next_possible_free_oid);
5313 return next_possible_free_oid;
5320 bool force_array_type,
5321 bool include_multirange_type)
5325 Oid pg_type_array_oid;
5326 Oid pg_type_multirange_oid;
5327 Oid pg_type_multirange_array_oid;
5331 "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5336 "FROM pg_catalog.pg_type "
5337 "WHERE oid = '%u'::pg_catalog.oid;",
5346 if (!
OidIsValid(pg_type_array_oid) && force_array_type)
5352 "\n-- For binary upgrade, must preserve pg_type array oid\n");
5354 "SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5361 if (include_multirange_type)
5366 "SELECT t.oid, t.typarray "
5367 "FROM pg_catalog.pg_type t "
5368 "JOIN pg_catalog.pg_range r "
5369 "ON t.oid = r.rngmultitypid "
5370 "WHERE r.rngtypid = '%u'::pg_catalog.oid;",
5387 "\n-- For binary upgrade, must preserve multirange pg_type oid\n");
5389 "SELECT pg_catalog.binary_upgrade_set_next_multirange_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5390 pg_type_multirange_oid);
5392 "\n-- For binary upgrade, must preserve multirange pg_type array oid\n");
5394 "SELECT pg_catalog.binary_upgrade_set_next_multirange_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5395 pg_type_multirange_array_oid);
5410 pg_type_oid,
false,
false);
5438 query =
"SELECT c.oid, c.relkind, c.relfilenode, c.reltoastrelid, "
5439 "ct.relfilenode, i.indexrelid, cti.relfilenode "
5440 "FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_index i "
5441 "ON (c.reltoastrelid = i.indrelid AND i.indisvalid) "
5442 "LEFT JOIN pg_catalog.pg_class ct ON (c.reltoastrelid = ct.oid) "
5443 "LEFT JOIN pg_catalog.pg_class AS cti ON (i.indexrelid = cti.oid) "
5486 key.oid = pg_class_oid;
5492 "\n-- For binary upgrade, must preserve pg_class oids and relfilenodes\n");
5494 if (entry->
relkind != RELKIND_INDEX &&
5495 entry->
relkind != RELKIND_PARTITIONED_INDEX)
5498 "SELECT pg_catalog.binary_upgrade_set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
5507 entry->
relkind != RELKIND_PARTITIONED_TABLE)
5509 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
5517 entry->
relkind != RELKIND_PARTITIONED_TABLE)
5520 "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
5523 "SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
5528 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5531 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5539 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5542 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5559 const char *objtype,
5560 const char *objname,
5561 const char *objnamespace)
5583 pg_fatal(
"could not find parent extension for %s %s",
5587 "\n-- For binary upgrade, handle extension membership the hard way\n");
5591 if (objnamespace && *objnamespace)
5624 "acldefault('n', n.nspowner) AS acldefault "
5625 "FROM pg_namespace n");
5640 for (
i = 0;
i < ntups;
i++)
5642 const char *nspowner;
5680 if (strcmp(nsinfo[
i].dobj.name,
"public") == 0)
5721 pg_fatal(
"schema with OID %u does not exist", nsoid);
5745 int i_extrelocatable;
5753 "x.extname, n.nspname, x.extrelocatable, x.extversion, x.extconfig, x.extcondition "
5754 "FROM pg_extension x "
5755 "JOIN pg_namespace n ON n.oid = x.extnamespace");
5772 for (
i = 0;
i < ntups;
i++)
5792 *numExtensions = ntups;
5843 "typnamespace, typacl, "
5844 "acldefault('T', typowner) AS acldefault, "
5846 "typelem, typrelid, "
5847 "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
5848 "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
5849 "typtype, typisdefined, "
5850 "typname[0] = '_' AND typelem != 0 AND "
5851 "(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray "
5874 for (
i = 0;
i < ntups;
i++)
5881 tyinfo[
i].
dobj.namespace =
5905 if (tyinfo[
i].typtype == TYPTYPE_MULTIRANGE)
5923 tyinfo[
i].
typtype == TYPTYPE_DOMAIN)
5937 (tyinfo[
i].
typtype == TYPTYPE_BASE ||
5938 tyinfo[
i].
typtype == TYPTYPE_RANGE))
5945 stinfo->
dobj.namespace = tyinfo[
i].
dobj.namespace;
5992 "oprcode::oid AS oprcode "
5993 "FROM pg_operator");
6009 for (
i = 0;
i < ntups;
i++)
6016 oprinfo[
i].
dobj.namespace =
6046 int i_collnamespace;
6059 "FROM pg_collation");
6073 for (
i = 0;
i < ntups;
i++)
6080 collinfo[
i].
dobj.namespace =
6121 "FROM pg_conversion");
6135 for (
i = 0;
i < ntups;
i++)
6142 convinfo[
i].
dobj.namespace =
6181 "amhandler::pg_catalog.regproc AS amhandler "
6196 for (
i = 0;
i < ntups;
i++)
6203 aminfo[
i].
dobj.namespace = NULL;
6257 for (
i = 0;
i < ntups;
i++)
6264 opcinfo[
i].
dobj.namespace =
6305 "FROM pg_opfamily");
6319 for (
i = 0;
i < ntups;
i++)
6326 opfinfo[
i].
dobj.namespace =
6368 const char *agg_check;
6370 agg_check = (fout->
remoteVersion >= 110000 ?
"p.prokind = 'a'"
6374 "p.proname AS aggname, "
6375 "p.pronamespace AS aggnamespace, "
6376 "p.pronargs, p.proargtypes, "
6378 "p.proacl AS aggacl, "
6379 "acldefault('f', p.proowner) AS acldefault "
6381 "LEFT JOIN pg_init_privs pip ON "
6382 "(p.oid = pip.objoid "
6383 "AND pip.classoid = 'pg_proc'::regclass "
6384 "AND pip.objsubid = 0) "
6386 "p.pronamespace != "
6387 "(SELECT oid FROM pg_namespace "
6388 "WHERE nspname = 'pg_catalog') OR "
6389 "p.proacl IS DISTINCT FROM pip.initprivs",
6393 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6394 "classid = 'pg_proc'::regclass AND "
6395 "objid = p.oid AND "
6396 "refclassid = 'pg_extension'::regclass AND "
6403 "pronamespace AS aggnamespace, "
6404 "pronargs, proargtypes, "
6406 "proacl AS aggacl, "
6407 "acldefault('f', proowner) AS acldefault "
6409 "WHERE proisagg AND ("
6411 "(SELECT oid FROM pg_namespace "
6412 "WHERE nspname = 'pg_catalog')");
6415 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6416 "classid = 'pg_proc'::regclass AND "
6417 "objid = p.oid AND "
6418 "refclassid = 'pg_extension'::regclass AND "
6439 for (
i = 0;
i < ntups;
i++)
6441 agginfo[
i].aggfn.dobj.objType =
DO_AGG;
6446 agginfo[
i].aggfn.dobj.namespace =
6450 agginfo[
i].aggfn.dacl.privtype = 0;
6451 agginfo[
i].aggfn.dacl.initprivs = NULL;
6456 if (agginfo[
i].aggfn.nargs == 0)
6457 agginfo[
i].aggfn.argtypes = NULL;
6460 agginfo[
i].aggfn.argtypes = (
Oid *)
pg_malloc(agginfo[
i].aggfn.nargs *
sizeof(
Oid));
6462 agginfo[
i].aggfn.argtypes,
6463 agginfo[
i].aggfn.nargs);
6465 agginfo[
i].aggfn.postponed_def =
false;
6528 const char *not_agg_check;
6530 not_agg_check = (fout->
remoteVersion >= 110000 ?
"p.prokind <> 'a'"
6531 :
"NOT p.proisagg");
6534 "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
6535 "p.pronargs, p.proargtypes, p.prorettype, "
6537 "acldefault('f', p.proowner) AS acldefault, "
6541 "LEFT JOIN pg_init_privs pip ON "
6542 "(p.oid = pip.objoid "
6543 "AND pip.classoid = 'pg_proc'::regclass "
6544 "AND pip.objsubid = 0) "
6546 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6547 "WHERE classid = 'pg_proc'::regclass AND "
6548 "objid = p.oid AND deptype = 'i')"
6550 "\n pronamespace != "
6551 "(SELECT oid FROM pg_namespace "
6552 "WHERE nspname = 'pg_catalog')"
6553 "\n OR EXISTS (SELECT 1 FROM pg_cast"
6554 "\n WHERE pg_cast.oid > %u "
6555 "\n AND p.oid = pg_cast.castfunc)"
6556 "\n OR EXISTS (SELECT 1 FROM pg_transform"
6557 "\n WHERE pg_transform.oid > %u AND "
6558 "\n (p.oid = pg_transform.trffromsql"
6559 "\n OR p.oid = pg_transform.trftosql))",
6565 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6566 "classid = 'pg_proc'::regclass AND "
6567 "objid = p.oid AND "
6568 "refclassid = 'pg_extension'::regclass AND "
6571 "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
6577 "SELECT tableoid, oid, proname, prolang, "
6578 "pronargs, proargtypes, prorettype, proacl, "
6579 "acldefault('f', proowner) AS acldefault, "
6583 "WHERE NOT proisagg"
6584 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6585 "WHERE classid = 'pg_proc'::regclass AND "
6586 "objid = p.oid AND deptype = 'i')"
6588 "\n pronamespace != "
6589 "(SELECT oid FROM pg_namespace "
6590 "WHERE nspname = 'pg_catalog')"
6591 "\n OR EXISTS (SELECT 1 FROM pg_cast"
6592 "\n WHERE pg_cast.oid > '%u'::oid"
6593 "\n AND p.oid = pg_cast.castfunc)",
6598 "\n OR EXISTS (SELECT 1 FROM pg_transform"
6599 "\n WHERE pg_transform.oid > '%u'::oid"
6600 "\n AND (p.oid = pg_transform.trffromsql"
6601 "\n OR p.oid = pg_transform.trftosql))",
6606 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6607 "classid = 'pg_proc'::regclass AND "
6608 "objid = p.oid AND "
6609 "refclassid = 'pg_extension'::regclass AND "
6632 for (
i = 0;
i < ntups;
i++)
6639 finfo[
i].
dobj.namespace =
6649 if (finfo[
i].nargs == 0)
6655 finfo[
i].argtypes, finfo[
i].nargs);
6702 int i_reltablespace;
6704 int i_relhastriggers;
6705 int i_relpersistence;
6706 int i_relispopulated;
6709 int i_relforcerowsec;
6711 int i_toastfrozenxid;
6717 int i_toastreloptions;
6719 int i_foreignserver;
6721 int i_is_identity_sequence;
6744 "SELECT c.tableoid, c.oid, c.relname, "
6745 "c.relnamespace, c.relkind, c.reltype, "
6748 "c.relhasindex, c.relhasrules, c.relpages, "
6749 "c.relhastriggers, "
6750 "c.relpersistence, "
6753 "acldefault(CASE WHEN c.relkind = " CppAsString2(RELKIND_SEQUENCE)
6754 " THEN 's'::\"char\" ELSE 'r'::\"char\" END, c.relowner) AS acldefault, "
6755 "CASE WHEN c.relkind = " CppAsString2(RELKIND_FOREIGN_TABLE)
" THEN "
6756 "(SELECT ftserver FROM pg_catalog.pg_foreign_table WHERE ftrelid = c.oid) "
6757 "ELSE 0 END AS foreignserver, "
6758 "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, "
6760 "tc.relpages AS toastpages, "
6761 "tc.reloptions AS toast_reloptions, "
6762 "d.refobjid AS owning_tab, "
6763 "d.refobjsubid AS owning_col, "
6764 "tsp.spcname AS reltablespace, ");
6768 "false AS relhasoids, ");
6775 "c.relispopulated, ");
6778 "'t' as relispopulated, ");
6782 "c.relreplident, ");
6785 "'d' AS relreplident, ");
6789 "c.relrowsecurity, c.relforcerowsecurity, ");
6792 "false AS relrowsecurity, "
6793 "false AS relforcerowsecurity, ");
6797 "c.relminmxid, tc.relminmxid AS tminmxid, ");
6800 "0 AS relminmxid, 0 AS tminmxid, ");
6804 "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
6805 "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
6806 "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
6809 "c.reloptions, NULL AS checkoption, ");
6816 "NULL AS amname, ");
6820 "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
6823 "false AS is_identity_sequence, ");
6827 "c.relispartition AS ispartition ");
6830 "false AS ispartition ");
6839 "\nFROM pg_class c\n"
6840 "LEFT JOIN pg_depend d ON "
6842 "d.classid = 'pg_class'::regclass AND d.objid = c.oid AND "
6843 "d.objsubid = 0 AND "
6844 "d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
6845 "LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
6852 "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
6860 "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid"
6862 " AND c.relkind <> " CppAsString2(RELKIND_PARTITIONED_TABLE)
")\n");
6875 "WHERE c.relkind IN ("
6923 i_relforcerowsec =
PQfnumber(
res,
"relforcerowsecurity");
6931 i_toastreloptions =
PQfnumber(
res,
"toast_reloptions");
6935 i_is_identity_sequence =
PQfnumber(
res,
"is_identity_sequence");
6957 for (
i = 0;
i < ntups;
i++)
6964 tblinfo[
i].
dobj.namespace =
7024 if (tblinfo[
i].relkind == RELKIND_COMPOSITE_TYPE)
7071 (tblinfo[
i].
relkind == RELKIND_RELATION ||
7072 tblinfo[
i].
relkind == RELKIND_PARTITIONED_TABLE))
7079 if (query->
len == 0)
7088 if (query->
len >= 100000)
7099 if (query->
len != 0)
7134 for (
i = 0;
i < numTables;
i++)
7143 if (owning_tab == NULL)
7144 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
7207 *numInherits = ntups;
7214 for (
i = 0;
i < ntups;
i++)
7269 "SELECT partrelid FROM pg_partitioned_table WHERE\n"
7270 "(SELECT c.oid FROM pg_opclass c JOIN pg_am a "
7271 "ON c.opcmethod = a.oid\n"
7272 "WHERE opcname = 'enum_ops' "
7273 "AND opcnamespace = 'pg_catalog'::regnamespace "
7274 "AND amname = 'hash') = ANY(partclass)");
7280 for (
int i = 0;
i < ntups;
i++)
7287 pg_fatal(
"failed sanity check, table OID %u appearing in pg_partitioned_table not found",
7324 i_indnullsnotdistinct,
7346 for (
int i = 0;
i < numTables;
i++)
7360 if (tbloids->
len > 1)
7367 "SELECT t.tableoid, t.oid, i.indrelid, "
7368 "t.relname AS indexname, "
7369 "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
7370 "i.indkey, i.indisclustered, "
7371 "c.contype, c.conname, "
7372 "c.condeferrable, c.condeferred, "
7373 "c.tableoid AS contableoid, "
7375 "pg_catalog.pg_get_constraintdef(c.oid, false) AS condef, "
7376 "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
7377 "t.reloptions AS indreloptions, ");
7382 "i.indisreplident, ");
7385 "false AS indisreplident, ");
7389 "inh.inhparent AS parentidx, "
7390 "i.indnkeyatts AS indnkeyatts, "
7391 "i.indnatts AS indnatts, "
7392 "(SELECT pg_catalog.array_agg(attnum ORDER BY attnum) "
7393 " FROM pg_catalog.pg_attribute "
7394 " WHERE attrelid = i.indexrelid AND "
7395 " attstattarget >= 0) AS indstatcols, "
7396 "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attnum) "
7397 " FROM pg_catalog.pg_attribute "
7398 " WHERE attrelid = i.indexrelid AND "
7399 " attstattarget >= 0) AS indstatvals, ");
7403 "i.indnatts AS indnkeyatts, "
7404 "i.indnatts AS indnatts, "
7405 "'' AS indstatcols, "
7406 "'' AS indstatvals, ");
7410 "i.indnullsnotdistinct ");
7413 "false AS indnullsnotdistinct ");
7427 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7428 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7429 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7430 "JOIN pg_catalog.pg_class t2 ON (t2.oid = i.indrelid) "
7431 "LEFT JOIN pg_catalog.pg_constraint c "
7432 "ON (i.indrelid = c.conrelid AND "
7433 "i.indexrelid = c.conindid AND "
7434 "c.contype IN ('p','u','x')) "
7435 "LEFT JOIN pg_catalog.pg_inherits inh "
7436 "ON (inh.inhrelid = indexrelid) "
7437 "WHERE (i.indisvalid OR t2.relkind = 'p') "
7439 "ORDER BY i.indrelid, indexname",
7449 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7450 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7451 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7452 "LEFT JOIN pg_catalog.pg_constraint c "
7453 "ON (i.indrelid = c.conrelid AND "
7454 "i.indexrelid = c.conindid AND "
7455 "c.contype IN ('p','u','x')) "
7456 "WHERE i.indisvalid AND i.indisready "
7457 "ORDER BY i.indrelid, indexname",
7476 i_indnullsnotdistinct =
PQfnumber(
res,
"indnullsnotdistinct");
7496 for (
int j = 0;
j < ntups;)
7503 for (numinds = 1; numinds < ntups -
j; numinds++)
7511 while (++curtblindx < numTables)
7513 tbinfo = &tblinfo[curtblindx];
7517 if (curtblindx >= numTables)
7518 pg_fatal(
"unrecognized table OID %u", indrelid);
7522 pg_fatal(
"unexpected index data for table \"%s\"",
7529 for (
int c = 0;
c < numinds;
c++,
j++)
7539 indxinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
7550 indxinfo[
j].indkeys, indxinfo[
j].indnattrs);
7561 if (contype ==
'p' || contype ==
'u' || contype ==
'x')
7576 constrinfo->
dobj.namespace = tbinfo->
dobj.namespace;
7579 constrinfo->
contype = contype;
7583 constrinfo->
condef = NULL;
7638 "stxnamespace, stxowner, stxrelid, NULL AS stxstattarget "
7639 "FROM pg_catalog.pg_statistic_ext");
7642 "stxnamespace, stxowner, stxrelid, stxstattarget "
7643 "FROM pg_catalog.pg_statistic_ext");
7659 for (
i = 0;
i < ntups;
i++)
7666 statsextinfo[
i].
dobj.namespace =
7720 for (
int i = 0;
i < numTables;
i++)
7728 if ((!
tinfo->hastriggers &&
7729 tinfo->relkind != RELKIND_PARTITIONED_TABLE) ||
7734 if (tbloids->
len > 1)
7741 "SELECT c.tableoid, c.oid, "
7742 "conrelid, conname, confrelid, ");
7748 "pg_catalog.pg_get_constraintdef(c.oid) AS condef\n"
7749 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7750 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
7751 "WHERE contype = 'f' ",
7755 "AND conparentid = 0 ");
7757 "ORDER BY conrelid, conname");
7774 for (
int j = 0;
j < ntups;
j++)
7783 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != conrelid)
7785 while (++curtblindx < numTables)
7787 tbinfo = &tblinfo[curtblindx];
7791 if (curtblindx >= numTables)
7792 pg_fatal(
"unrecognized table OID %u", conrelid);
7800 constrinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
7819 if (reftable && reftable->
relkind == RELKIND_PARTITIONED_TABLE)
7825 for (
int k = 0; k < reftable->
numIndexes; k++)
7833 refidx = &reftable->
indexes[k];
7898 "PREPARE getDomainConstraints(pg_catalog.oid) AS\n"
7899 "SELECT tableoid, oid, conname, "
7900 "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
7902 "FROM pg_catalog.pg_constraint "
7903 "WHERE contypid = $1 AND contype = 'c' "
7904 "ORDER BY conname");
7912 "EXECUTE getDomainConstraints('%u')",
7929 for (
i = 0;
i < ntups;
i++)
7938 constrinfo[
i].
dobj.namespace = tyinfo->
dobj.namespace;
7988 "tableoid, oid, rulename, "
7989 "ev_class AS ruletable, ev_type, is_instead, "
8008 for (
i = 0;
i < ntups;
i++)
8019 if (ruleinfo[
i].ruletable == NULL)
8020 pg_fatal(
"failed sanity check, parent table with OID %u of pg_rewrite entry with OID %u not found",
8021 ruletableoid, ruleinfo[
i].dobj.catId.oid);
8027 if (ruleinfo[
i].ruletable)
8036 if ((ruleinfo[
i].ruletable->relkind == RELKIND_VIEW ||
8094 for (
int i = 0;
i < numTables;
i++)
8103 if (tbloids->
len > 1)
8120 "SELECT t.tgrelid, t.tgname, "
8121 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8122 "t.tgenabled, t.tableoid, t.oid, "
8123 "t.tgparentid <> 0 AS tgispartition\n"
8124 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8125 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8126 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8127 "WHERE ((NOT t.tgisinternal AND t.tgparentid = 0) "
8128 "OR t.tgenabled != u.tgenabled) "
8129 "ORDER BY t.tgrelid, t.tgname",
8143 "SELECT t.tgrelid, t.tgname, "
8144 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8145 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition\n"
8146 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8147 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8148 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8149 "WHERE (NOT t.tgisinternal OR t.tgenabled != u.tgenabled) "
8150 "ORDER BY t.tgrelid, t.tgname",
8163 "SELECT t.tgrelid, t.tgname, "
8164 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8165 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition "
8166 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8167 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8168 "LEFT JOIN pg_catalog.pg_depend AS d ON "
8169 " d.classid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8170 " d.refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8172 "LEFT JOIN pg_catalog.pg_trigger AS pt ON pt.oid = refobjid "
8173 "WHERE (NOT t.tgisinternal OR t.tgenabled != pt.tgenabled) "
8174 "ORDER BY t.tgrelid, t.tgname",
8181 "SELECT t.tgrelid, t.tgname, "
8182 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8183 "t.tgenabled, false as tgispartition, "
8184 "t.tableoid, t.oid "
8185 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8186 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8187 "WHERE NOT tgisinternal "
8188 "ORDER BY t.tgrelid, t.tgname",
8211 for (
int j = 0;
j < ntups;)
8218 for (numtrigs = 1; numtrigs < ntups -
j; numtrigs++)
8226 while (++curtblindx < numTables)
8228 tbinfo = &tblinfo[curtblindx];
8232 if (curtblindx >= numTables)
8233 pg_fatal(
"unrecognized table OID %u", tgrelid);
8239 for (
int c = 0;
c < numtrigs;
c++,
j++)
8246 tginfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8288 "SELECT e.tableoid, e.oid, evtname, evtenabled, "
8289 "evtevent, evtowner, "
8290 "array_to_string(array("
8291 "select quote_literal(x) "
8292 " from unnest(evttags) as t(x)), ', ') as evttags, "
8293 "e.evtfoid::regproc as evtfname "
8294 "FROM pg_event_trigger e "
8312 for (
i = 0;
i < ntups;
i++)
8354 int i_lanplcallfoid;
8362 "lanname, lanpltrusted, lanplcallfoid, "
8363 "laninline, lanvalidator, "
8365 "acldefault('l', lanowner) AS acldefault, "
8388 for (
i = 0;
i < ntups;
i++)
8445 "castsource, casttarget, castfunc, castcontext, "
8448 "WHERE NOT EXISTS ( "
8449 "SELECT 1 FROM pg_range r "
8450 "WHERE c.castsource = r.rngtypid "
8451 "AND c.casttarget = r.rngmultitypid "
8458 "castsource, casttarget, castfunc, castcontext, "
8460 "FROM pg_cast ORDER BY 3,4");
8477 for (
i = 0;
i < ntups;
i++)
8501 if (sTypeInfo && tTypeInfo)
8523 appendPQExpBuffer(query,
"SELECT lanname FROM pg_language WHERE oid = %u", langid);
8558 "trftype, trflang, trffromsql::oid, trftosql::oid "
8559 "FROM pg_transform "
8575 for (
i = 0;
i < ntups;
i++)
8598 if (typeInfo && lanname)
8634 int i_attstattarget;
8646 int i_attcompression;
8647 int i_attfdwoptions;
8648 int i_attmissingval;
8663 for (
int i = 0;
i < numTables;
i++)
8668 if (tbinfo->
relkind == RELKIND_SEQUENCE)
8676 if (tbloids->
len > 1)
8683 if (checkoids->
len > 1)
8703 "a.attstattarget,\n"
8712 "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n"
8713 "array_to_string(a.attoptions, ', ') AS attoptions,\n"
8714 "CASE WHEN a.attcollation <> t.typcollation "
8715 "THEN a.attcollation ELSE 0 END AS attcollation,\n"
8716 "pg_catalog.array_to_string(ARRAY("
8717 "SELECT pg_catalog.quote_ident(option_name) || "
8718 "' ' || pg_catalog.quote_literal(option_value) "
8719 "FROM pg_catalog.pg_options_to_table(attfdwoptions) "
8720 "ORDER BY option_name"
8721 "), E',\n ') AS attfdwoptions,\n");
8725 "a.attcompression AS attcompression,\n");
8728 "'' AS attcompression,\n");
8732 "a.attidentity,\n");
8735 "'' AS attidentity,\n");
8739 "CASE WHEN a.atthasmissing AND NOT a.attisdropped "
8740 "THEN a.attmissingval ELSE null END AS attmissingval,\n");
8743 "NULL AS attmissingval,\n");
8747 "a.attgenerated\n");
8750 "'' AS attgenerated\n");
8754 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8755 "JOIN pg_catalog.pg_attribute a ON (src.tbloid = a.attrelid) "
8756 "LEFT JOIN pg_catalog.pg_type t "
8757 "ON (a.atttypid = t.oid)\n"
8758 "WHERE a.attnum > 0::pg_catalog.int2\n"
8759 "ORDER BY a.attrelid, a.attnum",
8796 for (
int r = 0; r < ntups;)
8804 for (numatts = 1; numatts < ntups - r; numatts++)
8812 while (++curtblindx < numTables)
8814 tbinfo = &tblinfo[curtblindx];
8818 if (curtblindx >= numTables)
8819 pg_fatal(
"unrecognized table OID %u", attrelid);
8821 if (tbinfo->
relkind == RELKIND_SEQUENCE ||
8823 pg_fatal(
"unexpected column data for table \"%s\"",
8847 hasdefaults =
false;
8849 for (
int j = 0;
j < numatts;
j++, r++)
8852 pg_fatal(
"invalid column numbering in table \"%s\"",
8885 if (tbloids->
len > 1)
8908 "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc\n"
8909 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8910 "JOIN pg_catalog.pg_attrdef a ON (src.tbloid = a.adrelid)\n"
8911 "ORDER BY a.adrelid, a.adnum",
8920 for (
int j = 0;
j < numDefaults;
j++)
8932 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != adrelid)
8934 while (++curtblindx < numTables)
8936 tbinfo = &tblinfo[curtblindx];
8940 if (curtblindx >= numTables)
8941 pg_fatal(
"unrecognized table OID %u", adrelid);
8944 if (adnum <= 0 || adnum > tbinfo->
numatts)
8945 pg_fatal(
"invalid adnum value %d for table \"%s\"",
8960 attrdefs[
j].
adnum = adnum;
8964 attrdefs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8987 else if (tbinfo->
relkind == RELKIND_VIEW)
9005 if (!attrdefs[
j].separate)
9017 tbinfo->
attrdefs[adnum - 1] = &attrdefs[
j];
9043 "SELECT c.tableoid, c.oid, conrelid, conname, "
9044 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9045 "conislocal, convalidated "
9046 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9047 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
9048 "WHERE contype = 'c' "
9049 "ORDER BY c.conrelid, c.conname",
9067 for (
int j = 0;
j < numConstrs;)
9074 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9082 while (++curtblindx < numTables)
9084 tbinfo = &tblinfo[curtblindx];
9088 if (curtblindx >= numTables)
9089 pg_fatal(
"unrecognized table OID %u", conrelid);
9091 if (numcons != tbinfo->
ncheck)
9094 "expected %d check constraints on table \"%s\" but found %d",
9103 for (
int c = 0;
c < numcons;
c++,
j++)
9112 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9141 if (!constrs[
j].separate)
9218 "prsstart::oid, prstoken::oid, "
9219 "prsend::oid, prsheadline::oid, prslextype::oid "
9220 "FROM pg_ts_parser");
9238 for (
i = 0;
i < ntups;
i++)
9245 prsinfo[
i].
dobj.namespace =
9277 int i_dictnamespace;
9280 int i_dictinitoption;
9285 "dictnamespace, dictowner, "
9286 "dicttemplate, dictinitoption "
9303 for (
i = 0;
i < ntups;
i++)
9310 dictinfo[
i].
dobj.namespace =
9343 int i_tmplnamespace;
9350 "tmplnamespace, tmplinit::oid, tmpllexize::oid "
9351 "FROM pg_ts_template");
9366 for (
i = 0;
i < ntups;
i++)
9373 tmplinfo[
i].
dobj.namespace =
9409 "cfgnamespace, cfgowner, cfgparser "
9410 "FROM pg_ts_config");
9425 for (
i = 0;
i < ntups;
i++)
9432 cfginfo[
i].
dobj.namespace =
9472 "fdwhandler::pg_catalog.regproc, "
9473 "fdwvalidator::pg_catalog.regproc, "
9475 "acldefault('F', fdwowner) AS acldefault, "
9476 "array_to_string(ARRAY("
9477 "SELECT quote_ident(option_name) || ' ' || "
9478 "quote_literal(option_value) "
9479 "FROM pg_options_to_table(fdwoptions) "
9480 "ORDER BY option_name"
9481 "), E',\n ') AS fdwoptions "
9482 "FROM pg_foreign_data_wrapper");
9500 for (
i = 0;
i < ntups;
i++)
9507 fdwinfo[
i].
dobj.namespace = NULL;
9557 "srvfdw, srvtype, srvversion, srvacl, "
9558 "acldefault('S', srvowner) AS acldefault, "
9559 "array_to_string(ARRAY("
9560 "SELECT quote_ident(option_name) || ' ' || "
9561 "quote_literal(option_value) "
9562 "FROM pg_options_to_table(srvoptions) "
9563 "ORDER BY option_name"
9564 "), E',\n ') AS srvoptions "
9565 "FROM pg_foreign_server");
9584 for (
i = 0;
i < ntups;
i++)
9591 srvinfo[
i].
dobj.namespace = NULL;
9632 int i_defaclnamespace;
9633 int i_defaclobjtype;
9654 "SELECT oid, tableoid, "
9659 "CASE WHEN defaclnamespace = 0 THEN "
9660 "acldefault(CASE WHEN defaclobjtype = 'S' "
9661 "THEN 's'::\"char\" ELSE defaclobjtype END, "
9662 "defaclrole) ELSE '{}' END AS acldefault "
9663 "FROM pg_default_acl");
9679 for (
i = 0;
i < ntups;
i++)
9693 daclinfo[
i].
dobj.namespace = NULL;
9736 if (roleoid < middle->roleoid)
9738 else if (roleoid > middle->
roleoid)
9745 pg_fatal(
"role with OID %u does not exist", roleoid);
9762 query =
"SELECT oid, rolname FROM pg_catalog.pg_roles ORDER BY 1";
9800 "SELECT DISTINCT attrelid FROM pg_attribute "
9801 "WHERE attacl IS NOT NULL");
9806 for (
i = 0;
i < ntups;
i++)
9825 "SELECT objoid, classoid, objsubid, privtype, initprivs "
9826 "FROM pg_init_privs");
9831 for (
i = 0;
i < ntups;
i++)
9854 ((
TableInfo *) dobj)->hascolumnACLs =
true;
9858 classoid, objoid, objsubid);
9867 strcmp(dobj->
name,
"public") == 0)
9887 classoid, objoid, objsubid);
9921 const char *
name,
const char *
namespace,
9923 int subid,
DumpId dumpId,
9924 const char *initdb_comment)
9935 if (strcmp(
type,
"LARGE OBJECT") != 0)
9960 if (initdb_comment != NULL)
9986 if (
namespace && *
namespace)
10001 .namespace =
namespace,
10003 .description =
"COMMENT",
10005 .createStmt = query->
data,
10021 const char *
name,
const char *
namespace,
10022 const char *owner,
CatalogId catalogId,
10023 int subid,
DumpId dumpId)
10026 catalogId, subid, dumpId, NULL);
10037 const char *reltypename)
10084 .namespace = tbinfo->
dobj.namespace->dobj.
name,
10086 .description =
"COMMENT",
10088 .createStmt = query->
data,
10092 else if (objsubid > 0 && objsubid <= tbinfo->numatts)
10109 .namespace = tbinfo->
dobj.namespace->dobj.
name,
10111 .description =
"COMMENT",
10113 .createStmt = query->
data,
10146 while (low <= high)
10148 middle = low + (high - low) / 2;
10150 if (classoid < middle->classoid)
10152 else if (classoid > middle->
classoid)
10154 else if (objoid < middle->objoid)
10156 else if (objoid > middle->
objoid)
10174 while (middle > low)
10176 if (classoid != middle[-1].classoid ||
10177 objoid != middle[-1].objoid)
10186 while (middle <= high)
10188 if (classoid != middle->
classoid ||
10189 objoid != middle->
objoid)
10226 "FROM pg_catalog.pg_description "
10227 "ORDER BY classoid, objoid, objsubid");
10244 for (
i = 0;
i < ntups;
i++)
10254 if (dobj == NULL ||
10267 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
10306 if (dobj->
dump == 0)
10432 if (loinfo == NULL)
10433 pg_fatal(
"missing metadata for large objects \"%s\"",
10439 .description =
"BLOBS",
10441 .deps = dobj->dependencies,
10442 .nDeps = dobj->nDeps,
10444 .dumpArg = loinfo));
10514 "-- *not* dropping schema, since initdb creates it\n");
10516 "-- *not* creating schema, since initdb creates it\n");
10521 "SCHEMA", qnspname, NULL);
10527 .description =
"SCHEMA",
10529 .createStmt = q->
data,
10530 .dropStmt = delq->
data));
10535 const char *initdb_comment = NULL;
10537 if (!nspinfo->
create && strcmp(qnspname,
"public") == 0)
10538 initdb_comment =
"standard public schema";
10552 qnspname, NULL, NULL,
10597 qextname,
fmtId(extinfo->namespace));
10612 appendPQExpBufferStr(q,
"-- For binary upgrade, create an empty extension and insert objects into it\n");
10622 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
10667 .description =
"EXTENSION",
10669 .createStmt = q->
data,
10670 .dropStmt = delq->
data));
10703 if (tyinfo->
typtype == TYPTYPE_BASE)
10705 else if (tyinfo->
typtype == TYPTYPE_DOMAIN)
10707 else if (tyinfo->
typtype == TYPTYPE_COMPOSITE)
10709 else if (tyinfo->
typtype == TYPTYPE_ENUM)
10711 else if (tyinfo->
typtype == TYPTYPE_RANGE)
10716 pg_log_warning(
"typtype of data type \"%s\" appears to be invalid",
10745 "PREPARE dumpEnumType(pg_catalog.oid) AS\n"
10746 "SELECT oid, enumlabel "
10747 "FROM pg_catalog.pg_enum "
10748 "WHERE enumtypid = $1 "
10749 "ORDER BY enumsortorder");
10757 "EXECUTE dumpEnumType('%u')",
10786 for (
i = 0;
i < num;
i++)
10804 for (
i = 0;
i < num;
i++)
10812 "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
10823 tyinfo->
dobj.namespace->dobj.
name);
10828 .namespace = tyinfo->
dobj.namespace->dobj.
name,
10830 .description =
"TYPE",
10832 .createStmt = q->
data,
10833 .dropStmt = delq->
data));
10849 tyinfo->
dobj.namespace->dobj.
name,
10881 "PREPARE dumpRangeType(pg_catalog.oid) AS\n");
10888 "pg_catalog.format_type(rngmultitypid, NULL) AS rngmultitype, ");
10891 "NULL AS rngmultitype, ");
10894 "pg_catalog.format_type(rngsubtype, NULL) AS rngsubtype, "
10895 "opc.opcname AS opcname, "
10896 "(SELECT nspname FROM pg_catalog.pg_namespace nsp "
10897 " WHERE nsp.oid = opc.opcnamespace) AS opcnsp, "
10899 "CASE WHEN rngcollation = st.typcollation THEN 0 "
10900 " ELSE rngcollation END AS collation, "
10901 "rngcanonical, rngsubdiff "
10902 "FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
10903 " pg_catalog.pg_opclass opc "
10904 "WHERE st.oid = rngsubtype AND opc.oid = rngsubopc AND "
10913 "EXECUTE dumpRangeType('%u')",
10964 if (strcmp(procname,
"-") != 0)
10968 if (strcmp(procname,
"-") != 0)
10976 tyinfo->
dobj.namespace->dobj.
name);
10981 .namespace = tyinfo->
dobj.namespace->dobj.
name,
10983 .description =
"TYPE",
10985 .createStmt = q->
data,
10986 .dropStmt = delq->
data));
11002 tyinfo->
dobj.namespace->dobj.
name,
11047 tyinfo->
dobj.namespace->dobj.
name);
11052 .namespace = tyinfo->
dobj.namespace->dobj.
name,
11054 .description =
"TYPE",
11056 .createStmt = q->
data,
11057 .dropStmt = delq->
data));
11073 tyinfo->
dobj.namespace->dobj.
name,
11104 char *typsubscript;
11110 Oid typsubscriptoid;
11112 char *typispreferred;
11117 char *typcollatable;
11119 bool typdefault_is_literal =
false;
11125 "PREPARE dumpBaseType(pg_catalog.oid) AS\n"
11127 "typinput, typoutput, typreceive, typsend, "
11128 "typreceive::pg_catalog.oid AS typreceiveoid, "
11129 "typsend::pg_catalog.oid AS typsendoid, "
11131 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
11132 "typdelim, typbyval, typalign, typstorage, "
11133 "typmodin, typmodout, "
11134 "typmodin::pg_catalog.oid AS typmodinoid, "
11135 "typmodout::pg_catalog.oid AS typmodoutoid, "
11136 "typcategory, typispreferred, "
11137 "(typcollation <> 0) AS typcollatable, "
11138 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault, ");
11143 "typsubscript::pg_catalog.oid AS typsubscriptoid ");
11146 "'-' AS typsubscript, 0 AS typsubscriptoid ");
11157 "EXECUTE dumpBaseType('%u')",
11189 typdefault_is_literal =
true;
11214 "CREATE TYPE %s (\n"
11215 " INTERNALLENGTH = %s",
11217 (strcmp(typlen,
"-1") == 0) ?
"variable" : typlen);
11233 if (strcmp(typcollatable,
"t") == 0)
11236 if (typdefault != NULL)
11239 if (typdefault_is_literal)
11253 if (strcmp(typcategory,
"U") != 0)
11259 if (strcmp(typispreferred,
"t") == 0)
11262 if (typdelim && strcmp(typdelim,
",") != 0)
11270 else if (*
typalign == TYPALIGN_SHORT)
11272 else if (*
typalign == TYPALIGN_INT)
11274 else if (*
typalign == TYPALIGN_DOUBLE)
11277 if (*typstorage == TYPSTORAGE_PLAIN)
11279 else if (*typstorage == TYPSTORAGE_EXTERNAL)
11281 else if (*typstorage == TYPSTORAGE_EXTENDED)
11283 else if (*typstorage == TYPSTORAGE_MAIN)
11286 if (strcmp(typbyval,
"t") == 0)
11294 tyinfo->
dobj.namespace->dobj.
name);
11299 .namespace = tyinfo->
dobj.namespace->dobj.
name,
11301 .description =
"TYPE",
11303 .createStmt = q->
data,
11304 .dropStmt = delq->
data));
11320 tyinfo->
dobj.namespace->dobj.
name,
11350 bool typdefault_is_literal =
false;
11356 "PREPARE dumpDomain(pg_catalog.oid) AS\n");
11359 "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
11360 "pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
11362 "CASE WHEN t.typcollation <> u.typcollation "
11363 "THEN t.typcollation ELSE 0 END AS typcollation "
11364 "FROM pg_catalog.pg_type t "
11365 "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
11366 "WHERE t.oid = $1");
11374 "EXECUTE dumpDomain('%u')",
11386 typdefault_is_literal =
true;
11402 "CREATE DOMAIN %s AS %s",
11416 if (typnotnull[0] ==
't')
11419 if (typdefault != NULL)
11422 if (typdefault_is_literal)
11448 "DOMAIN", qtypname,
11449 tyinfo->
dobj.namespace->dobj.
name);
11454 .namespace = tyinfo->
dobj.namespace->dobj.
name,
11456 .description =
"DOMAIN",
11458 .createStmt = q->
data,
11459 .dropStmt = delq->
data));
11475 tyinfo->
dobj.namespace->dobj.
name,
11489 tyinfo->
dobj.namespace->dobj.
name,
11524 int i_attisdropped;
11525 int i_attcollation;
11540 "PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
11541 "SELECT a.attname, a.attnum, "
11542 "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
11543 "a.attlen, a.attalign, a.attisdropped, "
11544 "CASE WHEN a.attcollation <> at.typcollation "
11545 "THEN a.attcollation ELSE 0 END AS attcollation "
11546 "FROM pg_catalog.pg_type ct "
11547 "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
11548 "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
11549 "WHERE ct.oid = $1 "
11550 "ORDER BY a.attnum");
11558 "EXECUTE dumpCompositeType('%u')",
11587 for (
i = 0;
i < ntups;
i++)
11607 if (actual_atts++ > 0)
11638 "\n-- For binary upgrade, recreate dropped column.\n");
11640 "SET attlen = %s, "
11641 "attalign = '%s', attbyval = false\n"
11662 tyinfo->
dobj.namespace->dobj.
name);
11667 .namespace = tyinfo->
dobj.namespace->dobj.
name,
11669 .description =
"TYPE",
11671 .createStmt = q->
data,
11672 .dropStmt = delq->
data));
11689 tyinfo->
dobj.namespace->dobj.
name,
11726 int i_attisdropped;
11753 for (
i = 0;
i < ntups;
i++)
11780 .namespace = tyinfo->
dobj.namespace->dobj.
name,
11782 .description =
"COMMENT",
11784 .createStmt = query->
data,
11835 .namespace = stinfo->
dobj.namespace->dobj.
name,
11837 .description =
"SHELL TYPE",
11839 .createStmt = q->
data));
11874 if (funcInfo != NULL && !funcInfo->
dobj.
dump)
11880 if (inlineInfo != NULL && !inlineInfo->
dobj.
dump)
11887 if (validatorInfo != NULL && !validatorInfo->
dobj.
dump)
11888 validatorInfo = NULL;
11896 useParams = (funcInfo != NULL &&
11940 "LANGUAGE", qlanname, NULL);
11946 .description =
"PROCEDURAL LANGUAGE",
11948 .createStmt = defqry->
data,
11949 .dropStmt = delqry->
data,
11965 qlanname, NULL, NULL,
11988 if (is_agg && finfo->
nargs == 0)
12015 for (
j = 0;
j < finfo->
nargs;
j++)
12043 char *funcfullsig = NULL;
12045 char *qual_funcsig;
12058 char *proleakproof;
12065 char **configitems = NULL;
12066 int nconfigitems = 0;
12067 const char *keyword;
12082 "PREPARE dumpFunc(pg_catalog.oid) AS\n");
12096 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
12097 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
12098 "pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
12099 "proleakproof,\n");
12103 "array_to_string(protrftypes, ' ') AS protrftypes,\n");
12106 "NULL AS protrftypes,\n");
12113 "'u' AS proparallel,\n");
12120 "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n");
12127 "'-' AS prosupport,\n");
12131 "pg_get_function_sqlbody(p.oid) AS prosqlbody\n");
12134 "NULL AS prosqlbody\n");
12137 "FROM pg_catalog.pg_proc p, pg_catalog.pg_language l\n"
12138 "WHERE p.oid = $1 "
12139 "AND l.oid = p.prolang");
12147 "EXECUTE dumpFunc('%u')",
12189 else if (probin[0] !=
'\0')
12193 if (prosrc[0] !=
'\0')
12202 (strchr(prosrc,
'\'') == NULL && strchr(prosrc,
'\\') == NULL))
12220 if (!
parsePGArray(proconfig, &configitems, &nconfigitems))
12221 pg_fatal(
"could not parse %s array",
"proconfig");
12225 configitems = NULL;
12238 if (prokind[0] == PROKIND_PROCEDURE)
12239 keyword =
"PROCEDURE";
12241 keyword =
"FUNCTION";
12244 keyword, qual_funcsig);
12249 funcfullsig ? funcfullsig :
12252 if (prokind[0] == PROKIND_PROCEDURE)
12254 else if (funcresult)
12258 (proretset[0] ==
't') ?
"SETOF " :
"",
12271 for (
i = 0; typeids[
i];
i++)
12280 if (prokind[0] == PROKIND_WINDOW)
12283 if (provolatile[0] != PROVOLATILE_VOLATILE)
12285 if (provolatile[0] == PROVOLATILE_IMMUTABLE)
12287 else if (provolatile[0] == PROVOLATILE_STABLE)
12289 else if (provolatile[0] != PROVOLATILE_VOLATILE)
12290 pg_fatal(
"unrecognized provolatile value for function \"%s\"",
12294 if (proisstrict[0] ==
't')
12297 if (prosecdef[0] ==
't')
12300 if (proleakproof[0] ==
't')
12308 if (strcmp(procost,
"0") != 0)
12310 if (strcmp(lanname,
"internal") == 0 || strcmp(lanname,
"c") == 0)
12313 if (strcmp(procost,
"1") != 0)
12319 if (strcmp(procost,
"100") != 0)
12323 if (proretset[0] ==
't' &&
12324 strcmp(prorows,
"0") != 0 && strcmp(prorows,
"1000") != 0)
12327 if (strcmp(prosupport,
"-") != 0)
12333 if (proparallel[0] != PROPARALLEL_UNSAFE)
12335 if (proparallel[0] == PROPARALLEL_SAFE)
12337 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
12339 else if (proparallel[0] != PROPARALLEL_UNSAFE)
12340 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
12344 for (
int i = 0;
i < nconfigitems;
i++)
12347 char *configitem = configitems[
i];
12350 pos = strchr(configitem,
'=');
12380 for (nameptr = namelist; *nameptr; nameptr++)
12382 if (nameptr != namelist)
12396 "pg_catalog.pg_proc", keyword,
12402 finfo->
dobj.namespace->dobj.
name);
12407 .
namespace = finfo->
dobj.namespace->dobj.
name,
12409 .description = keyword,
12412 .createStmt = q->
data,
12413 .dropStmt = delqry->
data));
12441 free(qual_funcsig);
12458 const char *sourceType;
12459 const char *targetType;
12469 if (funcInfo == NULL)
12470 pg_fatal(
"could not find function definition for function with OID %u",
12482 sourceType, targetType);
12485 sourceType, targetType);
12489 case COERCION_METHOD_BINARY:
12492 case COERCION_METHOD_INOUT:
12495 case COERCION_METHOD_FUNCTION:
12509 pg_log_warning(
"bogus value in pg_cast.castfunc or pg_cast.castmethod field");
12522 sourceType, targetType);
12525 sourceType, targetType);
12529 "CAST", castargs->
data, NULL);
12534 .description =
"CAST",
12536 .createStmt = defqry->
data,
12537 .dropStmt = delqry->
data));
12565 const char *transformType;
12575 if (fromsqlFuncInfo == NULL)
12576 pg_fatal(
"could not find function definition for function with OID %u",
12582 if (tosqlFuncInfo == NULL)
12583 pg_fatal(
"could not find function definition for function with OID %u",
12596 transformType, lanname);
12599 transformType, lanname);
12602 pg_log_warning(
"bogus transform definition, at least one of trffromsql and trftosql should be nonzero");
12606 if (fromsqlFuncInfo)
12646 transformType, lanname);
12649 transformType, lanname);
12653 "TRANSFORM", transformargs->
data, NULL);
12658 .description =
"TRANSFORM",
12660 .createStmt = defqry->
data,
12661 .dropStmt = delqry->
data,
12737 "PREPARE dumpOpr(pg_catalog.oid) AS\n"
12739 "oprcode::pg_catalog.regprocedure, "
12740 "oprleft::pg_catalog.regtype, "
12741 "oprright::pg_catalog.regtype, "
12744 "oprrest::pg_catalog.regprocedure, "
12745 "oprjoin::pg_catalog.regprocedure, "
12746 "oprcanmerge, oprcanhash "
12747 "FROM pg_catalog.pg_operator "
12756 "EXECUTE dumpOpr('%u')",
12784 if (strcmp(oprkind,
"r") == 0)
12785 pg_log_warning(
"postfix operators are not supported anymore (operator \"%s\")",
12803 if (strcmp(oprkind,
"r") == 0 ||
12804 strcmp(oprkind,
"b") == 0)
12812 if (strcmp(oprkind,
"l") == 0 ||
12813 strcmp(oprkind,
"b") == 0)
12835 if (strcmp(oprcanmerge,
"t") == 0)
12838 if (strcmp(oprcanhash,
"t") == 0)
12865 "OPERATOR",
oprid->data,
12866 oprinfo->
dobj.namespace->dobj.
name);
12871 .namespace = oprinfo->
dobj.namespace->dobj.
name,
12873 .description =
"OPERATOR",
12875 .createStmt = q->
data,
12876 .dropStmt = delq->
data));
12910 if (strcmp(proc,
"-") == 0)
12916 for (paren =
name; *paren; paren++)
12918 if (*paren ==
'(' && !inquote)
12924 inquote = !inquote;
12949 if (strcmp(oproid,
"0") == 0)
12953 if (oprInfo == NULL)
12960 return psprintf(
"OPERATOR(%s.%s)",
12981 "SELECT '%u'::pg_catalog.regproc", funcOid);
13024 aminfo->
amtype, qamname);
13038 "ACCESS METHOD", qamname, NULL);
13043 .description =
"ACCESS METHOD",
13045 .createStmt = q->
data,
13046 .dropStmt = delq->
data));
13077 int i_opcfamilyname;
13078 int i_opcfamilynsp;
13080 int i_amopstrategy;
13083 int i_sortfamilynsp;
13086 int i_amproclefttype;
13087 int i_amprocrighttype;
13092 char *opcfamilyname;
13093 char *opcfamilynsp;
13095 char *amopstrategy;
13098 char *sortfamilynsp;
13101 char *amproclefttype;
13102 char *amprocrighttype;
13117 "opckeytype::pg_catalog.regtype, "
13118 "opcdefault, opcfamily, "
13119 "opfname AS opcfamilyname, "
13120 "nspname AS opcfamilynsp, "
13121 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS amname "
13122 "FROM pg_catalog.pg_opclass c "
13123 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily "
13124 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
13125 "WHERE c.oid = '%u'::pg_catalog.oid",
13157 if (strcmp(opcdefault,
"t") == 0)
13162 if (strlen(opcfamilyname) > 0)
13172 if (strcmp(opckeytype,
"-") != 0)
13189 "amopopr::pg_catalog.regoperator, "
13190 "opfname AS sortfamily, "
13191 "nspname AS sortfamilynsp "
13192 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
13193 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
13194 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
13195 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
13196 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
13197 "AND refobjid = '%u'::pg_catalog.oid "
13198 "AND amopfamily = '%s'::pg_catalog.oid "
13199 "ORDER BY amopstrategy",
13212 for (
i = 0;
i < ntups;
i++)
13223 amopstrategy, amopopr);
13225 if (strlen(sortfamily) > 0)
13250 "amproc::pg_catalog.regprocedure, "
13251 "amproclefttype::pg_catalog.regtype, "
13252 "amprocrighttype::pg_catalog.regtype "
13253 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
13254 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
13255 "AND refobjid = '%u'::pg_catalog.oid "
13256 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
13257 "AND objid = ap.oid "
13258 "ORDER BY amprocnum",
13268 i_amprocrighttype =
PQfnumber(
res,
"amprocrighttype");
13270 for (
i = 0;
i < ntups;
i++)
13282 if (*amproclefttype && *amprocrighttype)
13309 "OPERATOR CLASS", nameusing->
data,
13310 opcinfo->
dobj.namespace->dobj.
name);
13315 .namespace = opcinfo->
dobj.namespace->dobj.
name,
13317 .description =
"OPERATOR CLASS",
13319 .createStmt = q->
data,
13320 .dropStmt = delq->
data));
13357 int i_amopstrategy;
13360 int i_sortfamilynsp;
13363 int i_amproclefttype;
13364 int i_amprocrighttype;
13366 char *amopstrategy;
13369 char *sortfamilynsp;
13372 char *amproclefttype;
13373 char *amprocrighttype;
13391 "amopopr::pg_catalog.regoperator, "
13392 "opfname AS sortfamily, "
13393 "nspname AS sortfamilynsp "
13394 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
13395 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
13396 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
13397 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
13398 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
13399 "AND refobjid = '%u'::pg_catalog.oid "
13400 "AND amopfamily = '%u'::pg_catalog.oid "
13401 "ORDER BY amopstrategy",
13410 "amproc::pg_catalog.regprocedure, "
13411 "amproclefttype::pg_catalog.regtype, "
13412 "amprocrighttype::pg_catalog.regtype "
13413 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
13414 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
13415 "AND refobjid = '%u'::pg_catalog.oid "
13416 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
13417 "AND objid = ap.oid "
13418 "ORDER BY amprocnum",
13427 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opfmethod) AS amname "
13428 "FROM pg_catalog.pg_opfamily "
13429 "WHERE oid = '%u'::pg_catalog.oid",
13467 i_amopstrategy =
PQfnumber(res_ops,
"amopstrategy");
13468 i_amopopr =
PQfnumber(res_ops,
"amopopr");
13469 i_sortfamily =
PQfnumber(res_ops,
"sortfamily");
13470 i_sortfamilynsp =
PQfnumber(res_ops,
"sortfamilynsp");
13472 for (
i = 0;
i < ntups;
i++)
13474 amopstrategy =
PQgetvalue(res_ops,
i, i_amopstrategy);
13476 sortfamily =
PQgetvalue(res_ops,
i, i_sortfamily);
13477 sortfamilynsp =
PQgetvalue(res_ops,
i, i_sortfamilynsp);
13483 amopstrategy, amopopr);
13485 if (strlen(sortfamily) > 0)
13500 i_amprocnum =
PQfnumber(res_procs,
"amprocnum");
13501 i_amproc =
PQfnumber(res_procs,
"amproc");
13502 i_amproclefttype =
PQfnumber(res_procs,
"amproclefttype");
13503 i_amprocrighttype =
PQfnumber(res_procs,
"amprocrighttype");
13505 for (
i = 0;
i < ntups;
i++)
13507 amprocnum =
PQgetvalue(res_procs,
i, i_amprocnum);
13509 amproclefttype =
PQgetvalue(res_procs,
i, i_amproclefttype);
13510 amprocrighttype =
PQgetvalue(res_procs,
i, i_amprocrighttype);
13516 amprocnum, amproclefttype, amprocrighttype,
13531 "OPERATOR FAMILY", nameusing->
data,
13532 opfinfo->
dobj.namespace->dobj.
name);
13537 .namespace = opfinfo->
dobj.namespace->dobj.
name,
13539 .description =
"OPERATOR FAMILY",
13541 .createStmt = q->
data,
13542 .dropStmt = delq->
data));
13572 int i_collprovider;
13573 int i_collisdeterministic;
13577 int i_collicurules;
13578 const char *collprovider;
13579 const char *collcollate;
13580 const char *collctype;
13581 const char *colllocale;
13582 const char *collicurules;
13603 "'c' AS collprovider, "
13604 "NULL AS collversion, ");
13608 "collisdeterministic, ");
13611 "true AS collisdeterministic, ");
13618 "colliculocale AS colllocale, ");
13621 "NULL AS colllocale, ");
13628 "NULL AS collicurules, ");
13633 "FROM pg_catalog.pg_collation c "
13634 "WHERE c.oid = '%u'::pg_catalog.oid",
13640 i_collisdeterministic =
PQfnumber(
res,
"collisdeterministic");
13651 collcollate = NULL;
13664 if (collcollate[0] ==
'\0')
13665 collcollate = NULL;
13666 if (collctype[0] ==
'\0')
13678 collicurules = NULL;
13687 if (collprovider[0] ==
'b')
13689 else if (collprovider[0] ==
'c')
13691 else if (collprovider[0] ==
'i')
13693 else if (collprovider[0] ==
'd')
13697 pg_fatal(
"unrecognized collation provider: %s",
13700 if (strcmp(
PQgetvalue(
res, 0, i_collisdeterministic),
"f") == 0)
13703 if (collprovider[0] ==
'd')
13705 if (collcollate || collctype || colllocale || collicurules)
13710 else if (collprovider[0] ==
'b')
13712 if (collcollate || collctype || !colllocale || collicurules)
13719 else if (collprovider[0] ==
'i')
13723 if (collcollate || collctype || !colllocale)
13732 if (!collcollate || !collctype || colllocale ||
13733 strcmp(collcollate, collctype) != 0)
13746 else if (collprovider[0] ==
'c')
13748 if (colllocale || collicurules || !collcollate || !collctype)
13751 if (collcollate && collctype && strcmp(collcollate, collctype) == 0)
13765 pg_fatal(
"unrecognized collation provider: %s", collprovider);
13789 "COLLATION", qcollname,
13790 collinfo->
dobj.namespace->dobj.
name);
13795 .namespace = collinfo->
dobj.namespace->dobj.
name,
13797 .description =
"COLLATION",
13799 .createStmt = q->
data,
13800 .dropStmt = delq->
data));
13829 int i_conforencoding;
13830 int i_contoencoding;
13833 const char *conforencoding;
13834 const char *contoencoding;
13835 const char *conproc;
13850 "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
13851 "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
13852 "conproc, condefault "
13853 "FROM pg_catalog.pg_conversion c "
13854 "WHERE c.oid = '%u'::pg_catalog.oid",
13873 (condefault) ?
"DEFAULT " :
"",
13883 "CONVERSION", qconvname,
13884 convinfo->
dobj.namespace->dobj.
name);
13889 .namespace = convinfo->
dobj.namespace->dobj.
name,
13891 .description =
"CONVERSION",
13893 .createStmt = q->
data,
13894 .dropStmt = delq->
data));
13928 if (agginfo->aggfn.nargs == 0)
13933 for (
j = 0;
j < agginfo->aggfn.nargs;
j++)
13935 (
j > 0) ?
", " :
"",
13937 agginfo->aggfn.argtypes[
j],
13957 char *aggfullsig = NULL;
13962 const char *aggtransfn;
13963 const char *aggfinalfn;
13964 const char *aggcombinefn;
13965 const char *aggserialfn;
13966 const char *aggdeserialfn;
13967 const char *aggmtransfn;
13968 const char *aggminvtransfn;
13969 const char *aggmfinalfn;
13970 bool aggfinalextra;
13971 bool aggmfinalextra;
13972 char aggfinalmodify;
13973 char aggmfinalmodify;
13974 const char *aggsortop;
13975 char *aggsortconvop;
13977 const char *aggtranstype;
13978 const char *aggtransspace;
13979 const char *aggmtranstype;
13980 const char *aggmtransspace;
13981 const char *agginitval;
13982 const char *aggminitval;
13983 const char *proparallel;
13984 char defaultfinalmodify;
13999 "PREPARE dumpAgg(pg_catalog.oid) AS\n");
14005 "aggtranstype::pg_catalog.regtype,\n"
14008 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
14009 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
14015 "aggminvtransfn,\n"
14017 "aggmtranstype::pg_catalog.regtype,\n"
14019 "aggmfinalextra,\n"
14021 "aggmtransspace,\n"
14025 "'n' AS aggkind,\n"
14026 "'-' AS aggmtransfn,\n"
14027 "'-' AS aggminvtransfn,\n"
14028 "'-' AS aggmfinalfn,\n"
14029 "0 AS aggmtranstype,\n"
14030 "false AS aggfinalextra,\n"
14031 "false AS aggmfinalextra,\n"
14032 "0 AS aggtransspace,\n"
14033 "0 AS aggmtransspace,\n"
14034 "NULL AS aggminitval,\n");
14044 "'-' AS aggcombinefn,\n"
14045 "'-' AS aggserialfn,\n"
14046 "'-' AS aggdeserialfn,\n"
14047 "'u' AS proparallel,\n");
14051 "aggfinalmodify,\n"
14052 "aggmfinalmodify\n");
14055 "'0' AS aggfinalmodify,\n"
14056 "'0' AS aggmfinalmodify\n");
14059 "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
14060 "WHERE a.aggfnoid = p.oid "
14069 "EXECUTE dumpAgg('%u')",
14070 agginfo->aggfn.dobj.catId.oid);
14112 defaultfinalmodify = (aggkind == AGGKIND_NORMAL) ? AGGMODIFY_READ_ONLY : AGGMODIFY_READ_WRITE;
14114 if (aggfinalmodify ==
'0')
14115 aggfinalmodify = defaultfinalmodify;
14116 if (aggmfinalmodify ==
'0')
14117 aggmfinalmodify = defaultfinalmodify;
14121 aggtransfn, aggtranstype);
14123 if (strcmp(aggtransspace,
"0") != 0)
14135 if (strcmp(aggfinalfn,
"-") != 0)
14141 if (aggfinalmodify != defaultfinalmodify)
14143 switch (aggfinalmodify)
14145 case AGGMODIFY_READ_ONLY:
14148 case AGGMODIFY_SHAREABLE:
14151 case AGGMODIFY_READ_WRITE:
14155 pg_fatal(
"unrecognized aggfinalmodify value for aggregate \"%s\"",
14156 agginfo->aggfn.dobj.name);
14162 if (strcmp(aggcombinefn,
"-") != 0)
14165 if (strcmp(aggserialfn,
"-") != 0)
14168 if (strcmp(aggdeserialfn,
"-") != 0)
14171 if (strcmp(aggmtransfn,
"-") != 0)
14179 if (strcmp(aggmtransspace,
"0") != 0)
14191 if (strcmp(aggmfinalfn,
"-") != 0)
14195 if (aggmfinalextra)
14197 if (aggmfinalmodify != defaultfinalmodify)
14199 switch (aggmfinalmodify)
14201 case AGGMODIFY_READ_ONLY:
14204 case AGGMODIFY_SHAREABLE:
14207 case AGGMODIFY_READ_WRITE:
14211 pg_fatal(
"unrecognized aggmfinalmodify value for aggregate \"%s\"",
14212 agginfo->aggfn.dobj.name);
14223 free(aggsortconvop);
14226 if (aggkind == AGGKIND_HYPOTHETICAL)
14229 if (proparallel[0] != PROPARALLEL_UNSAFE)
14231 if (proparallel[0] == PROPARALLEL_SAFE)
14233 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
14235 else if (proparallel[0] != PROPARALLEL_UNSAFE)
14236 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
14237 agginfo->aggfn.dobj.name);
14241 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
14245 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
14246 aggfullsig ? aggfullsig : aggsig, details->
data);
14250 "AGGREGATE", aggsig,
14251 agginfo->aggfn.dobj.namespace->dobj.name);
14255 agginfo->aggfn.dobj.dumpId,
14257 .
namespace = agginfo->aggfn.dobj.namespace->dobj.name,
14258 .owner = agginfo->aggfn.rolname,
14259 .description =
"AGGREGATE",
14261 .createStmt = q->
data,
14262 .dropStmt = delq->
data));
14267 agginfo->aggfn.dobj.namespace->dobj.name,
14268 agginfo->aggfn.rolname,
14269 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
14273 agginfo->aggfn.dobj.namespace->dobj.name,
14274 agginfo->aggfn.rolname,
14275 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
14288 "FUNCTION", aggsig, NULL,
14289 agginfo->aggfn.dobj.namespace->dobj.name,
14290 NULL, agginfo->aggfn.rolname, &agginfo->aggfn.dacl);
14345 "TEXT SEARCH PARSER", qprsname,
14346 prsinfo->
dobj.namespace->dobj.
name);
14351 .namespace = prsinfo->
dobj.namespace->dobj.
name,
14352 .description =
"TEXT SEARCH PARSER",
14354 .createStmt = q->
data,
14355 .dropStmt = delq->
data));
14359 dumpComment(fout,
"TEXT SEARCH PARSER", qprsname,
14360 prsinfo->
dobj.namespace->dobj.
name,
"",
14396 "FROM pg_ts_template p, pg_namespace n "
14397 "WHERE p.oid = '%u' AND n.oid = tmplnamespace",
14423 "TEXT SEARCH DICTIONARY", qdictname,
14424 dictinfo->
dobj.namespace->dobj.
name);
14429 .namespace = dictinfo->
dobj.namespace->dobj.
name,
14431 .description =
"TEXT SEARCH DICTIONARY",
14433 .createStmt = q->
data,
14434 .dropStmt = delq->
data));
14438 dumpComment(fout,
"TEXT SEARCH DICTIONARY", qdictname,
14483 "TEXT SEARCH TEMPLATE", qtmplname,
14484 tmplinfo->
dobj.namespace->dobj.
name);
14489 .namespace = tmplinfo->
dobj.namespace->dobj.
name,
14490 .description =
"TEXT SEARCH TEMPLATE",
14492 .createStmt = q->
data,
14493 .dropStmt = delq->
data));
14497 dumpComment(fout,
"TEXT SEARCH TEMPLATE", qtmplname,
14498 tmplinfo->
dobj.namespace->dobj.
name,
"",
14538 "FROM pg_ts_parser p, pg_namespace n "
14539 "WHERE p.oid = '%u' AND n.oid = prsnamespace",
14556 " ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
14557 " WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
14558 " m.mapdict::pg_catalog.regdictionary AS dictname\n"
14559 "FROM pg_catalog.pg_ts_config_map AS m\n"
14560 "WHERE m.mapcfg = '%u'\n"
14561 "ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
14570 for (
i = 0;
i < ntups;
i++)
14585 fmtId(tokenname), dictname);
14601 "TEXT SEARCH CONFIGURATION", qcfgname,
14602 cfginfo->
dobj.namespace->dobj.
name);
14607 .namespace = cfginfo->
dobj.namespace->dobj.
name,
14609 .description =
"TEXT SEARCH CONFIGURATION",
14611 .createStmt = q->
data,
14612 .dropStmt = delq->
data));
14616 dumpComment(fout,
"TEXT SEARCH CONFIGURATION", qcfgname,
14666 "FOREIGN DATA WRAPPER", qfdwname,
14673 .description =
"FOREIGN DATA WRAPPER",
14675 .createStmt = q->
data,
14676 .dropStmt = delq->
data));
14680 dumpComment(fout,
"FOREIGN DATA WRAPPER", qfdwname,
14687 "FOREIGN DATA WRAPPER", qfdwname, NULL, NULL,
14723 "FROM pg_foreign_data_wrapper w "
14724 "WHERE w.oid = '%u'",
14754 "SERVER", qsrvname, NULL);
14760 .description =
"SERVER",
14762 .createStmt = q->
data,
14763 .dropStmt = delq->
data));
14774 "FOREIGN SERVER", qsrvname, NULL, NULL,
14802 const char *servername,
const char *
namespace,
14831 "array_to_string(ARRAY("
14832 "SELECT quote_ident(option_name) || ' ' || "
14833 "quote_literal(option_value) "
14834 "FROM pg_options_to_table(umoptions) "
14835 "ORDER BY option_name"
14836 "), E',\n ') AS umoptions "
14837 "FROM pg_user_mappings "
14838 "WHERE srvid = '%u' "
14839 "ORDER BY usename",
14848 for (
i = 0;
i < ntups;
i++)
14860 if (umoptions && strlen(umoptions) > 0)
14871 usename, servername);
14875 .namespace =
namespace,
14877 .description =
"USER MAPPING",
14879 .createStmt = q->
data,
14880 .dropStmt = delq->
data));
14911 case DEFACLOBJ_RELATION:
14914 case DEFACLOBJ_SEQUENCE:
14915 type =
"SEQUENCES";
14917 case DEFACLOBJ_FUNCTION:
14918 type =
"FUNCTIONS";
14920 case DEFACLOBJ_TYPE:
14923 case DEFACLOBJ_NAMESPACE:
14928 pg_fatal(
"unrecognized object type in default privileges: %d",
14937 daclinfo->
dobj.namespace != NULL ?
14938 daclinfo->
dobj.namespace->dobj.
name : NULL,
14944 pg_fatal(
"could not parse default ACL list (%s)",
14950 .namespace = daclinfo->
dobj.namespace ?
14951 daclinfo->
dobj.namespace->dobj.
name : NULL,
14953 .description =
"DEFAULT ACL",
14955 .createStmt = q->
data));
14986 const char *nspname,
const char *tag,
const char *owner,
14991 const char *acls = dacl->
acl;
14994 const char *initprivs = dacl->
initprivs;
14995 const char *baseacls;
15003 if (dopt->
dataOnly && strcmp(
type,
"LARGE OBJECT") != 0)
15022 initprivs && *initprivs !=
'\0')
15028 pg_fatal(
"could not parse initial ACL list (%s) or default (%s) for object \"%s\" (%s)",
15030 appendPQExpBufferStr(sql,
"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
15041 if (initprivs && *initprivs !=
'\0')
15043 baseacls = initprivs;
15044 if (acls == NULL || *acls ==
'\0')
15051 acls, baseacls, owner,
15053 pg_fatal(
"could not parse ACL list (%s) or default (%s) for object \"%s\" (%s)",
15069 aclDeps[nDeps++] = objDumpId;
15071 aclDeps[nDeps++] = altDumpId;
15077 .namespace = nspname,
15079 .description =
"ACL",
15081 .createStmt = sql->
data,
15113 const char *
namespace,
const char *owner,
15130 if (strcmp(
type,
"LARGE OBJECT") != 0)
15147 for (
i = 0;
i < nlabels;
i++)
15152 if (labels[
i].objsubid != subid)
15156 "SECURITY LABEL FOR %s ON %s ",
15158 if (
namespace && *
namespace)
15165 if (query->
len > 0)
15172 .namespace =
namespace,
15174 .description =
"SECURITY LABEL",
15176 .createStmt = query->
data,
15221 for (
i = 0;
i < nlabels;
i++)
15223 const char *colname;
15247 if (query->
len > 0)
15254 .namespace = tbinfo->
dobj.namespace->dobj.
name,
15256 .description =
"SECURITY LABEL",
15258 .createStmt = query->
data,
15292 while (low <= high)
15294 middle = low + (high - low) / 2;
15296 if (classoid < middle->classoid)
15298 else if (classoid > middle->
classoid)
15300 else if (objoid < middle->objoid)
15302 else if (objoid > middle->
objoid)
15320 while (middle > low)
15322 if (classoid != middle[-1].classoid ||
15323 objoid != middle[-1].objoid)
15332 while (middle <= high)
15334 if (classoid != middle->
classoid ||
15335 objoid != middle->
objoid)
15369 "SELECT label, provider, classoid, objoid, objsubid "
15370 "FROM pg_catalog.pg_seclabel "
15371 "ORDER BY classoid, objoid, objsubid");
15388 for (
i = 0;
i < ntups;
i++)
15398 if (dobj == NULL ||
15411 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
15451 if (tbinfo->
relkind == RELKIND_SEQUENCE)
15461 const char *objtype =
15462 (tbinfo->
relkind == RELKIND_SEQUENCE) ?
"SEQUENCE" :
"TABLE";
15466 objtype, namecopy, NULL,
15467 tbinfo->
dobj.namespace->dobj.
name,
15487 "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
15502 "SELECT at.attname, "
15504 "'{}' AS acldefault, "
15505 "pip.privtype, pip.initprivs "
15506 "FROM pg_catalog.pg_attribute at "
15507 "LEFT JOIN pg_catalog.pg_init_privs pip ON "
15508 "(at.attrelid = pip.objoid "
15509 "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
15510 "AND at.attnum = pip.objsubid) "
15511 "WHERE at.attrelid = $1 AND "
15512 "NOT at.attisdropped "
15513 "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
15514 "ORDER BY at.attnum");
15519 "SELECT attname, attacl, '{}' AS acldefault, "
15520 "NULL AS privtype, NULL AS initprivs "
15521 "FROM pg_catalog.pg_attribute "
15522 "WHERE attrelid = $1 AND NOT attisdropped "
15523 "AND attacl IS NOT NULL "
15524 "ORDER BY attnum");
15533 "EXECUTE getColumnACLs('%u')",
15548 coldacl.
acl = attacl;
15560 "TABLE", namecopy, attnamecopy,
15561 tbinfo->
dobj.namespace->dobj.
name,
15562 NULL, tbinfo->
rolname, &coldacl);
15588 "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
15596 pg_fatal(
"query to obtain definition of view \"%s\" returned no data",
15599 pg_fatal(
"query to obtain definition of view \"%s\" returned more than one definition",
15606 pg_fatal(
"definition of view \"%s\" appears to be empty (length zero)",
15678 const char *reltypename;
15690 pg_log_warning(
"WITH OIDS is not supported anymore (table \"%s\")",
15697 if (tbinfo->
relkind == RELKIND_VIEW)
15705 reltypename =
"VIEW";
15736 char *partkeydef = NULL;
15737 char *ftoptions = NULL;
15738 char *srvname = NULL;
15739 char *foreign =
"";
15747 case RELKIND_PARTITIONED_TABLE:
15752 reltypename =
"TABLE";
15756 "SELECT pg_get_partkeydef('%u')",
15764 case RELKIND_FOREIGN_TABLE:
15771 reltypename =
"FOREIGN TABLE";
15775 "SELECT fs.srvname, "
15776 "pg_catalog.array_to_string(ARRAY("
15777 "SELECT pg_catalog.quote_ident(option_name) || "
15778 "' ' || pg_catalog.quote_literal(option_value) "
15779 "FROM pg_catalog.pg_options_to_table(ftoptions) "
15780 "ORDER BY option_name"
15781 "), E',\n ') AS ftoptions "
15782 "FROM pg_catalog.pg_foreign_table ft "
15783 "JOIN pg_catalog.pg_foreign_server fs "
15784 "ON (fs.oid = ft.ftserver) "
15785 "WHERE ft.ftrelid = '%u'",
15795 foreign =
"FOREIGN ";
15798 case RELKIND_MATVIEW:
15799 reltypename =
"MATERIALIZED VIEW";
15802 reltypename =
"TABLE";
15830 if (tbinfo->
relkind != RELKIND_MATVIEW)
15844 bool print_default;
15845 bool print_notnull;
15851 print_default = (tbinfo->
attrdefs[
j] != NULL &&
15860 print_notnull = (tbinfo->
notnull[
j] &&
15869 !print_default && !print_notnull &&
15874 if (actual_atts == 0)
15951 if (actual_atts == 0)
15982 for (k = 0; k < numParents; k++)
15993 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
15996 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
16003 bool addcomma =
false;
16022 if (ftoptions && ftoptions[0])
16029 if (tbinfo->
relkind == RELKIND_MATVIEW)
16042 if (tbinfo->
relkind == RELKIND_MATVIEW)
16044 "pg_catalog.pg_class",
16045 "MATERIALIZED VIEW",
16060 "SELECT pg_catalog.binary_upgrade_set_missing_value(");
16093 (tbinfo->
relkind == RELKIND_RELATION ||
16094 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ||
16095 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE))
16103 "SET attlen = %d, "
16104 "attalign = '%c', attbyval = false\n"
16105 "WHERE attname = ",
16113 if (tbinfo->
relkind == RELKIND_RELATION ||
16114 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
16127 "SET attislocal = false\n"
16128 "WHERE attname = ");
16142 for (k = 0; k < tbinfo->
ncheck; k++)
16151 foreign, qualrelname,
16155 "SET conislocal = false\n"
16156 "WHERE contype = 'c' AND conname = ");
16166 for (k = 0; k < numParents; k++)
16194 (tbinfo->
relkind == RELKIND_RELATION ||
16195 tbinfo->
relkind == RELKIND_MATVIEW))
16199 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
16211 appendPQExpBufferStr(q,
"\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
16213 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
16214 "WHERE oid = '%u';\n",
16232 "SET relispopulated = 't'\n"
16256 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET NOT NULL;\n",
16257 foreign, qualrelname,
16266 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STATISTICS %d;\n",
16267 foreign, qualrelname,
16279 case TYPSTORAGE_PLAIN:
16282 case TYPSTORAGE_EXTERNAL:
16285 case TYPSTORAGE_EXTENDED:
16288 case TYPSTORAGE_MAIN:
16299 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STORAGE %s;\n",
16300 foreign, qualrelname,
16310 const char *cmname;
16325 if (cmname != NULL)
16326 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET COMPRESSION %s;\n",
16327 foreign, qualrelname,
16337 foreign, qualrelname,
16344 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
16347 "ALTER FOREIGN TABLE %s ALTER COLUMN %s OPTIONS (\n"
16363 if ((tbinfo->
relkind == RELKIND_RELATION ||
16364 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ||
16365 tbinfo->
relkind == RELKIND_MATVIEW) &&
16372 else if (tbinfo->
relreplident == REPLICA_IDENTITY_NOTHING)
16377 else if (tbinfo->
relreplident == REPLICA_IDENTITY_FULL)
16390 reltypename, qrelname,
16391 tbinfo->
dobj.namespace->dobj.
name);
16396 char *tableam = NULL;
16405 if (RELKIND_HAS_TABLESPACE(tbinfo->
relkind))
16408 if (RELKIND_HAS_TABLE_AM(tbinfo->
relkind) ||
16409 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
16410 tableam = tbinfo->
amname;
16414 .namespace = tbinfo->
dobj.namespace->dobj.
name,
16416 .tableam = tableam,
16419 .description = reltypename,
16422 .createStmt = q->
data,
16423 .dropStmt = delq->
data));
16485 "PREPARE dumpTableAttach(pg_catalog.oid) AS\n");
16488 "SELECT pg_get_expr(c.relpartbound, c.oid) "
16490 "WHERE c.oid = $1");
16498 "EXECUTE dumpTableAttach('%u')",
16506 "ALTER TABLE ONLY %s ",
16509 "ATTACH PARTITION %s %s;\n",
16522 .namespace = attachinfo->
dobj.namespace->dobj.
name,
16524 .description =
"TABLE ATTACH",
16526 .createStmt = q->
data));
16540 int adnum = adinfo->
adnum;
16560 foreign = tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
16563 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET DEFAULT %s;\n",
16568 foreign, qualrelname,
16576 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
16578 .description =
"DEFAULT",
16580 .createStmt = q->
data,
16581 .dropStmt = delq->
data));
16596 static const char *
16599 if (attrnum > 0 && attrnum <= tblInfo->numatts)
16600 return tblInfo->
attnames[attrnum - 1];
16616 pg_fatal(
"invalid column number %d for table \"%s\"",
16653 if (!is_constraint)
16657 char **indstatcolsarray = NULL;
16658 char **indstatvalsarray = NULL;
16689 if (strlen(indstatcols) != 0 || strlen(indstatvals) != 0)
16693 if (!
parsePGArray(indstatcols, &indstatcolsarray, &nstatcols))
16694 pg_fatal(
"could not parse index statistic columns");
16695 if (!
parsePGArray(indstatvals, &indstatvalsarray, &nstatvals))
16696 pg_fatal(
"could not parse index statistic values");
16697 if (nstatcols != nstatvals)
16698 pg_fatal(
"mismatched number of columns and values for index statistics");
16700 for (
j = 0;
j < nstatcols;
j++)
16709 indstatcolsarray[
j]);
16711 indstatvalsarray[
j]);
16717 "pg_catalog.pg_class",
16718 "INDEX", qqindxname);
16735 .namespace = tbinfo->
dobj.namespace->dobj.
name,
16738 .description =
"INDEX",
16740 .createStmt = q->
data,
16741 .dropStmt = delq->
data));
16743 free(indstatcolsarray);
16744 free(indstatvalsarray);
16750 tbinfo->
dobj.namespace->dobj.
name,
16791 .namespace = attachinfo->
dobj.namespace->dobj.
name,
16793 .description =
"INDEX ATTACH",
16795 .createStmt = q->
data));
16812 char *qstatsextname;
16827 "pg_catalog.pg_get_statisticsobjdef('%u'::pg_catalog.oid)",
16856 .namespace = statsextinfo->
dobj.namespace->dobj.
name,
16857 .owner = statsextinfo->
rolname,
16858 .description =
"STATISTICS",
16860 .createStmt = q->
data,
16861 .dropStmt = delq->
data));
16866 statsextinfo->
dobj.namespace->dobj.
name,
16875 free(qstatsextname);
16899 foreign = tbinfo &&
16900 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
16902 if (coninfo->
contype ==
'p' ||
16912 if (indxinfo == NULL)
16913 pg_fatal(
"missing index for constraint \"%s\"",
16933 coninfo->
contype ==
'p' ?
"PRIMARY KEY" :
"UNIQUE");
16946 int indkey = (int) indxinfo->
indkeys[k];
16954 (k == 0) ?
"" :
", ",
16961 for (k = indxinfo->
indnkeyattrs; k < indxinfo->indnattrs; k++)
16963 int indkey = (int) indxinfo->
indkeys[k];
17022 "pg_catalog.pg_class",
"INDEX",
17035 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
17038 .description =
"CONSTRAINT",
17040 .createStmt = q->
data,
17041 .dropStmt = delq->
data));
17043 else if (coninfo->
contype ==
'f')
17053 only = tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ?
"" :
"ONLY ";
17075 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
17077 .description =
"FK CONSTRAINT",
17079 .createStmt = q->
data,
17080 .dropStmt = delq->
data));
17082 else if (coninfo->
contype ==
'c' && tbinfo)
17106 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
17108 .description =
"CHECK CONSTRAINT",
17110 .createStmt = q->
data,
17111 .dropStmt = delq->
data));
17114 else if (coninfo->
contype ==
'c' && tbinfo == NULL)
17138 .
namespace = tyinfo->
dobj.namespace->dobj.
name,
17140 .description =
"CHECK CONSTRAINT",
17142 .createStmt = q->
data,
17143 .dropStmt = delq->
data));
17148 pg_fatal(
"unrecognized constraint type: %c",
17153 if (tbinfo && coninfo->
separate &&
17183 tbinfo->
dobj.namespace->dobj.
name,
17209 int64 default_minv,
17223 "SELECT format_type(seqtypid, NULL), "
17224 "seqstart, seqincrement, "
17226 "seqcache, seqcycle "
17227 "FROM pg_catalog.pg_sequence "
17228 "WHERE seqrelid = '%u'::oid",
17240 "SELECT 'bigint' AS sequence_type, "
17241 "start_value, increment_by, max_value, min_value, "
17242 "cache_value, is_cycled FROM %s",
17249 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
17250 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
17263 is_ascending = (incby[0] !=
'-');
17264 if (strcmp(seqtype,
"smallint") == 0)
17269 else if (strcmp(seqtype,
"integer") == 0)
17274 else if (strcmp(seqtype,
"bigint") == 0)
17281 pg_fatal(
"unrecognized sequence type: %s", seqtype);
17282 default_minv = default_maxv = 0;
17293 if (strcmp(minv, bufm) == 0)
17295 if (strcmp(maxv, bufx) == 0)
17328 "ALTER COLUMN %s ADD GENERATED ",
17340 "CREATE %sSEQUENCE %s\n",
17345 if (strcmp(seqtype,
"bigint") != 0)
17365 cache, (cycled ?
"\n CYCLE" :
""));
17372 "ALTER SEQUENCE %s SET %s;\n",
17375 "UNLOGGED" :
"LOGGED");
17384 "SEQUENCE", qseqname,
17385 tbinfo->
dobj.namespace->dobj.
name);
17390 .namespace = tbinfo->
dobj.namespace->dobj.
name,
17392 .description =
"SEQUENCE",
17394 .createStmt = query->
data,
17395 .dropStmt = delqry->
data));
17413 if (owning_tab == NULL)
17414 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
17430 .namespace = tbinfo->
dobj.namespace->dobj.
name,
17432 .description =
"SEQUENCE OWNED BY",
17434 .createStmt = query->
data,
17472 "SELECT last_value, is_called FROM %s",
17478 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
17479 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
17490 last, (called ?
"true" :
"false"));
17495 .namespace = tbinfo->
dobj.namespace->dobj.
name,
17497 .description =
"SEQUENCE SET",
17499 .createStmt = query->
data,
17543 "pg_catalog.pg_trigger",
"TRIGGER",
17544 trigidentity->
data);
17559 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
17584 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
17614 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
17616 .description =
"TRIGGER",
17618 .createStmt = query->
data,
17619 .dropStmt = delqry->
data));
17660 if (strcmp(
"", evtinfo->
evttags) != 0)
17698 "EVENT TRIGGER", qevtname, NULL);
17704 .description =
"EVENT TRIGGER",
17706 .createStmt = query->
data,
17707 .dropStmt = delqry->
data));
17789 "SELECT pg_catalog.pg_get_ruledef('%u'::pg_catalog.oid)",
17795 pg_fatal(
"query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
17858 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
17860 .description =
"RULE",
17862 .createStmt = cmd->
data,
17863 .dropStmt = delcmd->
data));
17868 tbinfo->
dobj.namespace->dobj.
name,
17904 if (numExtensions == 0)
17911 "classid, objid, refobjid "
17913 "WHERE refclassid = 'pg_extension'::regclass "
17914 "AND deptype = 'e' "
17932 for (
i = 0;
i < ntups;
i++)
17948 pg_log_warning(
"could not find referenced extension %u", extId);
17996 if (numExtensions == 0)
18010 for (
i = 0;
i < numExtensions;
i++)
18015 char **extconfigarray = NULL;
18016 char **extconditionarray = NULL;
18017 int nconfigitems = 0;
18018 int nconditionitems = 0;
18038 if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
18042 if (!
parsePGArray(extconfig, &extconfigarray, &nconfigitems))
18043 pg_fatal(
"could not parse %s array",
"extconfig");
18044 if (!
parsePGArray(extcondition, &extconditionarray, &nconditionitems))
18045 pg_fatal(
"could not parse %s array",
"extcondition");
18046 if (nconfigitems != nconditionitems)
18047 pg_fatal(
"mismatched number of configurations and conditions for extension");
18049 for (
j = 0;
j < nconfigitems;
j++)
18052 Oid configtbloid =
atooid(extconfigarray[
j]);
18057 if (configtbl == NULL)
18073 if (configtbl->
dobj.namespace->dobj.
dump &
18092 if (configtbl->
dataObj != NULL)
18094 if (strlen(extconditionarray[
j]) > 0)
18100 if (extconfigarray)
18101 free(extconfigarray);
18102 if (extconditionarray)
18103 free(extconditionarray);
18118 "SELECT conrelid, confrelid "
18119 "FROM pg_constraint "
18120 "JOIN pg_depend ON (objid = confrelid) "
18121 "WHERE contype = 'f' "
18122 "AND refclassid = 'pg_extension'::regclass "
18123 "AND classid = 'pg_class'::regclass;");
18132 for (
i = 0;
i < ntups;
i++)
18144 if (reftable == NULL ||
18146 contable == NULL ||
18192 "classid, objid, refclassid, refobjid, deptype "
18194 "WHERE deptype != 'p' AND deptype != 'e'\n");
18207 "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
18208 "FROM pg_depend d, pg_amop o "
18209 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
18210 "classid = 'pg_amop'::regclass AND objid = o.oid "
18211 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
18215 "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
18216 "FROM pg_depend d, pg_amproc p "
18217 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
18218 "classid = 'pg_amproc'::regclass AND objid = p.oid "
18219 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
18241 for (
i = 0;
i < ntups;
i++)
18253 if (dobj == NULL ||
18273 if (refdobj == NULL)
18288 if (deptype ==
'x')
18298 if (deptype ==
'i' &&
18349 for (
i = 0;
i < numObjs;
i++)
18413 if (((
RuleInfo *) dobj)->separate)
18482 if (dobj->
nDeps <= 0)
18490 &dependencies, &nDeps, &allocDeps);
18495 nDeps *
sizeof(
DumpId));
18500 free(dependencies);
18507 DumpId **dependencies,
int *nDeps,
int *allocDeps)
18526 if (*nDeps >= *allocDeps)
18530 *allocDeps *
sizeof(
DumpId));
18532 (*dependencies)[*nDeps] = depid;
18546 dependencies, nDeps, allocDeps);
18561 static const char *
18579 if (typeInfo && typeInfo->
ftypname)
18583 appendPQExpBuffer(query,
"SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
18612 static const char *
18624 for (
i = 0;
i < numatts;
i++)
18626 if (attisdropped[
i])
18628 if (attgenerated[
i])
18640 return buffer->
data;
18650 return (reloptions != NULL && strlen(reloptions) > 2);
18660 const char *prefix,
Archive *fout)
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)
NamespaceInfo * findNamespaceByOid(Oid oid)
SubscriptionInfo * findSubscriptionByOid(Oid oid)
ExtensionInfo * findOwningExtension(CatalogId catalogId)
TableInfo * getSchemaData(Archive *fout, int *numTablesPtr)
DumpableObject * findObjectByCatalogId(CatalogId catalogId)
void addObjectDependency(DumpableObject *dobj, DumpId refId)
DumpableObject * findObjectByDumpId(DumpId dumpId)
void parseOidArray(const char *str, Oid *array, int arraysize)
TableInfo * findTableByOid(Oid oid)
DumpId createDumpId(void)
ExtensionInfo * findExtensionByOid(Oid oid)
void AssignDumpId(DumpableObject *dobj)
void getDumpableObjects(DumpableObject ***objs, int *numObjs)
CollInfo * findCollationByOid(Oid oid)
TypeInfo * findTypeByOid(Oid oid)
OprInfo * findOprByOid(Oid oid)
PublicationInfo * findPublicationByOid(Oid oid)
void on_exit_close_archive(Archive *AHX)
void init_parallel_dump_utils(void)
static void cleanup(void)
static const gbtree_vinfo tinfo
#define ngettext(s, p, n)
#define Assert(condition)
#define PG_TEXTDOMAIN(domain)
#define OidIsValid(objectId)
void set_pglocale_pgservice(const char *argv0, const char *app)
char * supports_compression(const pg_compress_specification compression_spec)
bool parse_compress_algorithm(char *name, pg_compress_algorithm *algorithm)
void parse_compress_specification(pg_compress_algorithm algorithm, char *specification, pg_compress_specification *result)
char * validate_compress_specification(pg_compress_specification *spec)
#define PG_COMPRESSION_OPTION_WORKERS
void parse_compress_options(const char *option, char **algorithm, char **detail)
#define ALWAYS_SECURE_SEARCH_PATH_SQL
PGconn * GetConnection(UserMapping *user, bool will_prep_stmt, PgFdwConnState **state)
static void PGresult const char * p2
static void PGresult * res
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)
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)
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)
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
char * PQdb(const PGconn *conn)
char * PQerrorMessage(const PGconn *conn)
int PQclientEncoding(const PGconn *conn)
int PQsetClientEncoding(PGconn *conn, const char *encoding)
int PQgetlength(const PGresult *res, int tup_num, int field_num)
void PQfreemem(void *ptr)
Oid PQftype(const PGresult *res, int field_num)
ExecStatusType PQresultStatus(const PGresult *res)
int PQntuples(const PGresult *res)
char * PQfname(const PGresult *res, int field_num)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
int PQfnumber(const PGresult *res, const char *field_name)
int PQgetisnull(const PGresult *res, int tup_num, int field_num)
int PQnfields(const PGresult *res)
PGresult * PQgetResult(PGconn *conn)
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_realloc(void *ptr, size_t size)
void * pg_malloc0(size_t size)
char * pg_strdup(const char *in)
void * pg_malloc(size_t size)
@ DATA_DIR_SYNC_METHOD_FSYNC
void filter_init(FilterStateData *fstate, const char *filename, exit_function f_exit)
void filter_free(FilterStateData *fstate)
bool filter_read_item(FilterStateData *fstate, char **objname, FilterCommandType *comtype, FilterObjectType *objtype)
void pg_log_filter_error(FilterStateData *fstate, const char *fmt,...)
const char * filter_object_type_name(FilterObjectType fot)
@ 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)
if(TABLE==NULL||TABLE_index==NULL)
static JitProviderCallbacks provider
void pg_logging_increase_verbosity(void)
void pg_logging_init(const char *argv0)
void pg_logging_set_level(enum pg_log_level new_level)
#define pg_log_error(...)
#define pg_log_error_hint(...)
#define pg_log_error_detail(...)
char * pstrdup(const char *in)
bool option_parse_int(const char *optarg, const char *optname, int min_range, int max_range, int *result)
bool parse_sync_method(const char *optarg, DataDirSyncMethod *sync_method)
static AmcheckOptions opts
void ConnectDatabase(Archive *AHX, const ConnParams *cparams, bool isReconnect)
int EndLO(Archive *AHX, Oid oid)
void ProcessArchiveRestoreOptions(Archive *AHX)
#define appendStringLiteralAH(buf, str, AH)
RestoreOptions * NewRestoreOptions(void)
int StartLO(Archive *AHX, Oid oid)
Archive * CreateArchive(const char *FileSpec, const ArchiveFormat fmt, const pg_compress_specification compression_spec, bool dosync, ArchiveMode mode, SetupWorkerPtrType setupDumpWorker, DataDirSyncMethod sync_method)
enum _archiveFormat ArchiveFormat
void CloseArchive(Archive *AHX)
@ PREPQUERY_DUMPTABLEATTACH
@ PREPQUERY_DUMPRANGETYPE
@ PREPQUERY_DUMPCOMPOSITETYPE
@ PREPQUERY_GETCOLUMNACLS
@ PREPQUERY_GETDOMAINCONSTRAINTS
int archprintf(Archive *AH, const char *fmt,...) pg_attribute_printf(2
void SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)
void RestoreArchive(Archive *AHX)
void archputs(const char *s, Archive *AH)
void InitDumpOptions(DumpOptions *opts)
void WriteData(Archive *AHX, const void *data, size_t dLen)
int(* DataDumperPtr)(Archive *AH, const void *userArg)
int TocIDRequired(ArchiveHandle *AH, DumpId id)
TocEntry * ArchiveEntry(Archive *AHX, CatalogId catalogId, DumpId dumpId, ArchiveOpts *opts)
#define ARCHIVE_OPTS(...)
void ExecuteSqlStatement(Archive *AHX, const char *query)
PGresult * ExecuteSqlQuery(Archive *AHX, const char *query, ExecStatusType status)
PGresult * ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)
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)
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 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 void dumpTableComment(Archive *fout, const TableInfo *tbinfo, const char *reltypename)
static SimpleStringList extension_include_patterns
static void selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
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)
static void help(const char *progname)
void getTypes(Archive *fout)
static void dumpAccessMethod(Archive *fout, const AccessMethodInfo *aminfo)
int main(int argc, char **argv)
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)
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 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 const char * getRoleName(const char *roleoid_str)
static void dumpShellType(Archive *fout, const ShellTypeInfo *stinfo)
static void refreshMatViewData(Archive *fout, const TableDataInfo *tdinfo)
static int findComments(Oid classoid, Oid objoid, CommentItem **items)
static SimpleStringList foreign_servers_include_patterns
static char * format_aggregate_signature(const AggInfo *agginfo, Archive *fout, bool honor_quotes)
static void selectDumpableCast(CastInfo *cast, Archive *fout)
void getCasts(Archive *fout)
static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo)
static char * get_language_name(Archive *fout, Oid langid)
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 bool is_superuser(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)
InhInfo * getInherits(Archive *fout, int *numInherits)
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)
void getSubscriptionTables(Archive *fout)
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 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)
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
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)
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 Oid g_last_builtin_oid
ExtensionInfo * getExtensions(Archive *fout, int *numExtensions)
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 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
TableInfo * getTables(Archive *fout, int *numTables)
static void binary_upgrade_set_pg_class_oids(Archive *fout, PQExpBuffer upgrade_buffer, Oid pg_class_oid)
void getTSTemplates(Archive *fout)
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 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 exit_nicely(code)
PGDLLIMPORT char * optarg
#define LOGICALREP_ORIGIN_ANY
#define LOGICALREP_TWOPHASE_STATE_DISABLED
#define pg_encoding_to_char
#define pg_log_warning(...)
int pg_strcasecmp(const char *s1, const char *s2)
const char * get_progname(const char *argv0)
void printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
PQExpBuffer createPQExpBuffer(void)
void initPQExpBuffer(PQExpBuffer str)
void resetPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen)
void destroyPQExpBuffer(PQExpBuffer str)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
void termPQExpBuffer(PQExpBuffer str)
char * psprintf(const char *fmt,...)
#define RelFileNumberIsValid(relnumber)
bool quote_all_identifiers
void simple_string_list_append(SimpleStringList *list, const char *val)
bool simple_oid_list_member(SimpleOidList *list, Oid val)
void simple_oid_list_append(SimpleOidList *list, Oid val)
struct SimplePtrList SimplePtrList
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)
const char * fmtId(const char *rawid)
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
NamespaceInfo * pubschema
PublicationInfo * publication
SubscriptionInfo * subinfo
char * suboriginremotelsn
char * subpasswordrequired
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
SimplePtrList partattaches
Oid looids[FLEXIBLE_ARRAY_MEMBER]
pg_compress_specification compression_spec
int disable_dollar_quoting
const char * lockWaitTimeout
struct _indxInfo * indexes
bool is_identity_sequence
struct _tableInfo ** parents
struct _triggerInfo * triggers
struct _constraintInfo * checkexprs
struct _attrDefInfo ** attrdefs
struct _tableDataInfo * dataObj
struct _constraintInfo * domChecks
struct _shellTypeInfo * shellType
#define MinTransactionIdAttributeNumber
#define MaxCommandIdAttributeNumber
#define MaxTransactionIdAttributeNumber
#define TableOidAttributeNumber
#define SelfItemPointerAttributeNumber
#define MinCommandIdAttributeNumber
static StringInfo copybuf
static void * fn(void *arg)
#define FirstNormalObjectId
bool SplitGUCList(char *rawstring, char separator, List **namelist)