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_proc_d.h"
53#include "catalog/pg_publication_d.h"
54#include "catalog/pg_subscription_d.h"
55#include "catalog/pg_type_d.h"
123 "array length mismatch");
213#define MAX_ATTR_STATS_RELS 64
219#define DUMP_DEFAULT_ROWS_PER_INSERT 1
226#define MAX_BLOBS_PER_ARCHIVE_ENTRY 1000
231#define fmtQualifiedDumpable(obj) \
232 fmtQualifiedId((obj)->dobj.namespace->dobj.name, \
237 const char *dumpencoding,
const char *dumpsnapshot,
255 bool with_child_tables);
257 const char *pattern);
262static const char *
getRoleName(
const char *roleoid_str);
266 const char *
name,
const char *
namespace,
269 const char *initdb_comment);
271 const char *
name,
const char *
namespace,
273 int subid,
DumpId dumpId);
277 const char *
namespace,
const char *owner,
327 const char *servername,
const char *
namespace,
333 const char *nspname,
const char *tag,
const char *owner,
339 DumpId **dependencies,
int *nDeps,
int *allocDeps);
353 int i_notnull_name,
int i_notnull_invalidoid,
354 int i_notnull_noinherit,
355 int i_notnull_islocal,
360 const FuncInfo *finfo,
bool honor_quotes);
382 bool force_array_type,
383 bool include_multirange_type);
395 const char *objnamespace);
400 const char *prefix,
Archive *fout);
424 bool g_verbose =
false;
425 const char *dumpencoding = NULL;
426 const char *dumpsnapshot = NULL;
427 char *use_role = NULL;
433 char *compression_detail = NULL;
434 char *compression_algorithm_str =
"none";
435 char *error_detail = NULL;
436 bool user_compression_defined =
false;
438 bool data_only =
false;
439 bool schema_only =
false;
450 static struct option long_options[] = {
463 {
"jobs", 1, NULL,
'j'},
551 if (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-?") == 0)
556 if (strcmp(argv[1],
"--version") == 0 || strcmp(argv[1],
"-V") == 0)
558 puts(
"pg_dump (PostgreSQL) " PG_VERSION);
565 while ((
c =
getopt_long(argc, argv,
"abBcCd:e:E:f:F:h:j:n:N:Op:RsS:t:T:U:vwWxXZ:",
566 long_options, &optindex)) != -1)
683 &compression_detail);
684 user_compression_defined =
true;
818 pg_log_error(
"too many command-line arguments (first is \"%s\")",
829 if (data_only && schema_only)
830 pg_fatal(
"options -s/--schema-only and -a/--data-only cannot be used together");
832 pg_fatal(
"options -s/--schema-only and --statistics-only cannot be used together");
834 pg_fatal(
"options -a/--data-only and --statistics-only cannot be used together");
838 pg_fatal(
"options -a/--data-only and --no-data cannot be used together");
840 pg_fatal(
"options -s/--schema-only and --no-schema cannot be used together");
842 pg_fatal(
"options --statistics-only and --no-statistics cannot be used together");
846 pg_fatal(
"options --with-data and --no-data cannot be used together");
848 pg_fatal(
"options --with-schema and --no-schema cannot be used together");
850 pg_fatal(
"options --with-statistics and --no-statistics cannot be used together");
853 pg_fatal(
"options -s/--schema-only and --include-foreign-data cannot be used together");
856 pg_fatal(
"option --include-foreign-data is not supported with parallel backup");
859 pg_fatal(
"options -c/--clean and -a/--data-only cannot be used together");
862 pg_fatal(
"option --if-exists requires option -c/--clean");
884 pg_fatal(
"option --on-conflict-do-nothing requires option --inserts, --rows-per-insert, or --column-inserts");
899 !user_compression_defined)
902 compression_algorithm_str =
"gzip";
904 compression_algorithm_str =
"none";
913 pg_fatal(
"unrecognized compression algorithm: \"%s\"",
914 compression_algorithm_str);
919 if (error_detail != NULL)
920 pg_fatal(
"invalid compression specification: %s",
924 if (error_detail != NULL)
933 pg_log_warning(
"compression option \"%s\" is not currently supported by pg_dump",
945 pg_fatal(
"parallel backup only supported by the directory format");
1000 pg_fatal(
"no matching schemas were found");
1017 pg_fatal(
"no matching tables were found");
1045 pg_fatal(
"no matching extensions were found");
1084 getTableData(&dopt, tblinfo, numTables, RELKIND_SEQUENCE);
1140 boundaryObjs[0].dumpId, boundaryObjs[1].dumpId);
1159 for (
i = 0;
i < numObjs;
i++)
1238 printf(
_(
"%s dumps a database as a text file or to other formats.\n\n"),
progname);
1242 printf(
_(
"\nGeneral options:\n"));
1243 printf(
_(
" -f, --file=FILENAME output file or directory name\n"));
1244 printf(
_(
" -F, --format=c|d|t|p output file format (custom, directory, tar,\n"
1245 " plain text (default))\n"));
1246 printf(
_(
" -j, --jobs=NUM use this many parallel jobs to dump\n"));
1247 printf(
_(
" -v, --verbose verbose mode\n"));
1248 printf(
_(
" -V, --version output version information, then exit\n"));
1249 printf(
_(
" -Z, --compress=METHOD[:DETAIL]\n"
1250 " compress as specified\n"));
1251 printf(
_(
" --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock\n"));
1252 printf(
_(
" --no-sync do not wait for changes to be written safely to disk\n"));
1253 printf(
_(
" --sync-method=METHOD set method for syncing files to disk\n"));
1254 printf(
_(
" -?, --help show this help, then exit\n"));
1256 printf(
_(
"\nOptions controlling the output content:\n"));
1257 printf(
_(
" -a, --data-only dump only the data, not the schema or statistics\n"));
1258 printf(
_(
" -b, --large-objects include large objects in dump\n"));
1259 printf(
_(
" --blobs (same as --large-objects, deprecated)\n"));
1260 printf(
_(
" -B, --no-large-objects exclude large objects in dump\n"));
1261 printf(
_(
" --no-blobs (same as --no-large-objects, deprecated)\n"));
1262 printf(
_(
" -c, --clean clean (drop) database objects before recreating\n"));
1263 printf(
_(
" -C, --create include commands to create database in dump\n"));
1264 printf(
_(
" -e, --extension=PATTERN dump the specified extension(s) only\n"));
1265 printf(
_(
" -E, --encoding=ENCODING dump the data in encoding ENCODING\n"));
1266 printf(
_(
" -n, --schema=PATTERN dump the specified schema(s) only\n"));
1267 printf(
_(
" -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
1268 printf(
_(
" -O, --no-owner skip restoration of object ownership in\n"
1269 " plain-text format\n"));
1270 printf(
_(
" -s, --schema-only dump only the schema, no data or statistics\n"));
1271 printf(
_(
" -S, --superuser=NAME superuser user name to use in plain-text format\n"));
1272 printf(
_(
" -t, --table=PATTERN dump only the specified table(s)\n"));
1273 printf(
_(
" -T, --exclude-table=PATTERN do NOT dump the specified table(s)\n"));
1274 printf(
_(
" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
1275 printf(
_(
" --binary-upgrade for use by upgrade utilities only\n"));
1276 printf(
_(
" --column-inserts dump data as INSERT commands with column names\n"));
1277 printf(
_(
" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
1278 printf(
_(
" --disable-triggers disable triggers during data-only restore\n"));
1279 printf(
_(
" --enable-row-security enable row security (dump only content user has\n"
1281 printf(
_(
" --exclude-extension=PATTERN do NOT dump the specified extension(s)\n"));
1282 printf(
_(
" --exclude-table-and-children=PATTERN\n"
1283 " do NOT dump the specified table(s), including\n"
1284 " child and partition tables\n"));
1285 printf(
_(
" --exclude-table-data=PATTERN do NOT dump data for the specified table(s)\n"));
1286 printf(
_(
" --exclude-table-data-and-children=PATTERN\n"
1287 " do NOT dump data for the specified table(s),\n"
1288 " including child and partition tables\n"));
1289 printf(
_(
" --extra-float-digits=NUM override default setting for extra_float_digits\n"));
1290 printf(
_(
" --filter=FILENAME include or exclude objects and data from dump\n"
1291 " based on expressions in FILENAME\n"));
1292 printf(
_(
" --if-exists use IF EXISTS when dropping objects\n"));
1293 printf(
_(
" --include-foreign-data=PATTERN\n"
1294 " include data of foreign tables on foreign\n"
1295 " servers matching PATTERN\n"));
1296 printf(
_(
" --inserts dump data as INSERT commands, rather than COPY\n"));
1297 printf(
_(
" --load-via-partition-root load partitions via the root table\n"));
1298 printf(
_(
" --no-comments do not dump comment commands\n"));
1299 printf(
_(
" --no-data do not dump data\n"));
1300 printf(
_(
" --no-policies do not dump row security policies\n"));
1301 printf(
_(
" --no-publications do not dump publications\n"));
1302 printf(
_(
" --no-schema do not dump schema\n"));
1303 printf(
_(
" --no-security-labels do not dump security label assignments\n"));
1304 printf(
_(
" --no-statistics do not dump statistics\n"));
1305 printf(
_(
" --no-subscriptions do not dump subscriptions\n"));
1306 printf(
_(
" --no-table-access-method do not dump table access methods\n"));
1307 printf(
_(
" --no-tablespaces do not dump tablespace assignments\n"));
1308 printf(
_(
" --no-toast-compression do not dump TOAST compression methods\n"));
1309 printf(
_(
" --no-unlogged-table-data do not dump unlogged table data\n"));
1310 printf(
_(
" --on-conflict-do-nothing add ON CONFLICT DO NOTHING to INSERT commands\n"));
1311 printf(
_(
" --quote-all-identifiers quote all identifiers, even if not key words\n"));
1312 printf(
_(
" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
1313 printf(
_(
" --section=SECTION dump named section (pre-data, data, or post-data)\n"));
1314 printf(
_(
" --sequence-data include sequence data in dump\n"));
1315 printf(
_(
" --serializable-deferrable wait until the dump can run without anomalies\n"));
1316 printf(
_(
" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
1317 printf(
_(
" --statistics-only dump only the statistics, not schema or data\n"));
1318 printf(
_(
" --strict-names require table and/or schema include patterns to\n"
1319 " match at least one entity each\n"));
1320 printf(
_(
" --table-and-children=PATTERN dump only the specified table(s), including\n"
1321 " child and partition tables\n"));
1322 printf(
_(
" --use-set-session-authorization\n"
1323 " use SET SESSION AUTHORIZATION commands instead of\n"
1324 " ALTER OWNER commands to set ownership\n"));
1325 printf(
_(
" --with-data dump the data\n"));
1326 printf(
_(
" --with-schema dump the schema\n"));
1327 printf(
_(
" --with-statistics dump the statistics\n"));
1329 printf(
_(
"\nConnection options:\n"));
1330 printf(
_(
" -d, --dbname=DBNAME database to dump\n"));
1331 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
1332 printf(
_(
" -p, --port=PORT database server port number\n"));
1333 printf(
_(
" -U, --username=NAME connect as specified database user\n"));
1334 printf(
_(
" -w, --no-password never prompt for password\n"));
1335 printf(
_(
" -W, --password force password prompt (should happen automatically)\n"));
1336 printf(
_(
" --role=ROLENAME do SET ROLE before dump\n"));
1338 printf(
_(
"\nIf no database name is supplied, then the PGDATABASE environment\n"
1339 "variable value is used.\n\n"));
1340 printf(
_(
"Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
1341 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
1346 const char *dumpsnapshot,
char *use_role)
1350 const char *std_strings;
1360 pg_fatal(
"invalid client encoding \"%s\" specified",
1372 AH->
std_strings = (std_strings && strcmp(std_strings,
"on") == 0);
1481 "SET TRANSACTION ISOLATION LEVEL "
1482 "SERIALIZABLE, READ ONLY, DEFERRABLE");
1485 "SET TRANSACTION ISOLATION LEVEL "
1486 "REPEATABLE READ, READ ONLY");
1508 pg_fatal(
"parallel dumps from standby servers are not supported by this server version");
1532 char *query =
"SELECT pg_catalog.pg_export_snapshot()";
1574 return archiveFormat;
1592 if (patterns->
head == NULL)
1602 for (cell = patterns->
head; cell; cell = cell->
next)
1608 "SELECT oid FROM pg_catalog.pg_namespace n\n");
1611 false, NULL,
"n.nspname", NULL, NULL, &dbbuf,
1614 pg_fatal(
"improper qualified name (too many dotted names): %s",
1616 else if (dotcnt == 1)
1622 pg_fatal(
"no matching schemas were found for pattern \"%s\"", cell->
val);
1651 if (patterns->
head == NULL)
1660 for (cell = patterns->
head; cell; cell = cell->
next)
1665 "SELECT oid FROM pg_catalog.pg_extension e\n");
1667 false, NULL,
"e.extname", NULL, NULL, NULL,
1670 pg_fatal(
"improper qualified name (too many dotted names): %s",
1675 pg_fatal(
"no matching extensions were found for pattern \"%s\"", cell->
val);
1703 if (patterns->
head == NULL)
1713 for (cell = patterns->
head; cell; cell = cell->
next)
1718 "SELECT oid FROM pg_catalog.pg_foreign_server s\n");
1720 false, NULL,
"s.srvname", NULL, NULL, NULL,
1723 pg_fatal(
"improper qualified name (too many dotted names): %s",
1728 pg_fatal(
"no matching foreign servers were found for pattern \"%s\"", cell->
val);
1755 if (patterns->
head == NULL)
1765 for (cell = patterns->
head; cell; cell = cell->
next)
1778 if (with_child_tables)
1785 "\nFROM pg_catalog.pg_class c"
1786 "\n LEFT JOIN pg_catalog.pg_namespace n"
1787 "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace"
1788 "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY"
1789 "\n (array['%c', '%c', '%c', '%c', '%c', '%c'])\n",
1790 RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW,
1791 RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE,
1792 RELKIND_PARTITIONED_TABLE);
1795 false,
"n.nspname",
"c.relname", NULL,
1796 "pg_catalog.pg_table_is_visible(c.oid)", &dbbuf,
1799 pg_fatal(
"improper relation name (too many dotted names): %s",
1801 else if (dotcnt == 2)
1805 if (with_child_tables)
1808 "\nSELECT i.inhrelid"
1809 "\nFROM partition_tree p"
1810 "\n JOIN pg_catalog.pg_inherits i"
1811 "\n ON p.relid OPERATOR(pg_catalog.=) i.inhparent"
1813 "\nSELECT relid FROM partition_tree");
1821 pg_fatal(
"no matching tables were found for pattern \"%s\"", cell->
val);
1848 pg_fatal(
"You are currently not connected to a database.");
1850 if (strcmp(db,
dbname) != 0)
1851 pg_fatal(
"cross-database references are not implemented: %s",
1939 strcmp(nsinfo->
dobj.
name,
"pg_catalog") == 0)
1948 else if (strncmp(nsinfo->
dobj.
name,
"pg_", 3) == 0 ||
1949 strcmp(nsinfo->
dobj.
name,
"information_schema") == 0)
1954 else if (strcmp(nsinfo->
dobj.
name,
"public") == 0)
1966 if (nsinfo->
nspowner == ROLE_PG_DATABASE_OWNER)
1967 nsinfo->
dobj.
dump &= ~DUMP_COMPONENT_DEFINITION;
2046 tyinfo->
typrelkind != RELKIND_COMPOSITE_TYPE)
2051 if (tytable != NULL)
2091 if (dinfo->
dobj.namespace)
2279 if (dobj->namespace)
2296 const char *classname = tbinfo->
dobj.
name;
2308 const char *column_list;
2310 pg_log_info(
"dumping contents of table \"%s.%s\"",
2311 tbinfo->
dobj.namespace->dobj.
name, classname);
2329 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2334 if (strlen(column_list) > 2)
2420 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetCopyData() failed.", classname);
2430 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetResult() failed.", classname);
2439 pg_log_warning(
"unexpected extra results during COPY of table \"%s\"",
2445 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2472 int rows_this_statement = 0;
2475 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2521 pg_fatal(
"wrong number of fields retrieved from table \"%s\"",
2531 if (insertStmt == NULL)
2563 for (
int field = 0; field < nfields; field++)
2580 for (
int tuple = 0; tuple <
PQntuples(res); tuple++)
2583 if (rows_this_statement == 0)
2599 if (rows_per_statement == 1)
2601 else if (rows_this_statement > 0)
2606 for (
int field = 0; field < nfields; field++)
2610 if (attgenerated[field])
2643 const char *s =
PQgetvalue(res, tuple, field);
2645 if (strspn(s,
"0123456789 +-eE.") == strlen(s))
2659 if (strcmp(
PQgetvalue(res, tuple, field),
"t") == 0)
2680 if (++rows_this_statement >= rows_per_statement)
2683 archputs(
" ON CONFLICT DO NOTHING;\n", fout);
2687 rows_this_statement = 0;
2700 if (rows_this_statement > 0)
2703 archputs(
" ON CONFLICT DO NOTHING;\n", fout);
2713 if (insertStmt != NULL)
2718 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2736 parentTbinfo = tbinfo->
parents[0];
2740 parentTbinfo = parentTbinfo->
parents[0];
2743 return parentTbinfo;
2761 parentTbinfo = tbinfo->
parents[0];
2767 parentTbinfo = parentTbinfo->
parents[0];
2789 char *tdDefn = NULL;
2791 const char *copyFrom;
2826 copyStmt = copyBuf->
data;
2846 .namespace = tbinfo->
dobj.namespace->dobj.
name,
2848 .description =
"TABLE DATA",
2850 .createStmt = tdDefn,
2851 .copyStmt = copyStmt,
2855 .dumpArg = tdinfo));
2913 .namespace = tbinfo->
dobj.namespace->dobj.
name,
2915 .description =
"MATERIALIZED VIEW DATA",
2917 .createStmt = q->
data,
2933 for (
i = 0;
i < numTables;
i++)
2936 (!relkind || tblinfo[
i].
relkind == relkind))
2960 if (tbinfo->
relkind == RELKIND_VIEW)
2963 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
2969 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
2985 if (tbinfo->
relkind == RELKIND_MATVIEW)
2987 else if (tbinfo->
relkind == RELKIND_SEQUENCE)
3000 tdinfo->
dobj.namespace = tbinfo->
dobj.namespace;
3017 if (tbinfo->
relkind == RELKIND_MATVIEW && tbinfo->
stats != NULL)
3053 "SELECT d1.objid, d2.refobjid, c2.relkind AS refrelkind "
3054 "FROM pg_depend d1 "
3055 "JOIN pg_class c1 ON c1.oid = d1.objid "
3057 " JOIN pg_rewrite r1 ON r1.ev_class = d1.objid "
3058 "JOIN pg_depend d2 ON d2.classid = 'pg_rewrite'::regclass "
3059 "AND d2.objid = r1.oid "
3060 "AND d2.refobjid <> d1.objid "
3061 "JOIN pg_class c2 ON c2.oid = d2.refobjid "
3062 "AND c2.relkind IN (" CppAsString2(RELKIND_MATVIEW)
","
3064 "WHERE d1.classid = 'pg_class'::regclass "
3066 "SELECT w.objid, d3.refobjid, c3.relkind "
3068 "JOIN pg_rewrite r3 ON r3.ev_class = w.refobjid "
3069 "JOIN pg_depend d3 ON d3.classid = 'pg_rewrite'::regclass "
3070 "AND d3.objid = r3.oid "
3071 "AND d3.refobjid <> w.refobjid "
3072 "JOIN pg_class c3 ON c3.oid = d3.refobjid "
3073 "AND c3.relkind IN (" CppAsString2(RELKIND_MATVIEW)
","
3076 "SELECT 'pg_class'::regclass::oid AS classid, objid, refobjid "
3086 i_refobjid =
PQfnumber(res,
"refobjid");
3088 for (
i = 0;
i < ntups;
i++)
3115 if (refdobj == NULL)
3122 if (refdobj == NULL)
3158 for (
i = 0;
i < numObjs;
i++)
3170 if (ftable == NULL ||
3243 "pg_encoding_to_char(encoding) AS encoding, "
3244 "datcollate, datctype, datfrozenxid, "
3245 "datacl, acldefault('d', datdba) AS acldefault, "
3246 "datistemplate, datconnlimit, ");
3256 appendPQExpBufferStr(dbQry,
"'c' AS datlocprovider, NULL AS datlocale, NULL AS datcollversion, ");
3262 "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
3263 "shobj_description(oid, 'pg_database') AS description "
3265 "WHERE datname = current_database()");
3269 i_tableoid =
PQfnumber(res,
"tableoid");
3273 i_encoding =
PQfnumber(res,
"encoding");
3274 i_datlocprovider =
PQfnumber(res,
"datlocprovider");
3275 i_collate =
PQfnumber(res,
"datcollate");
3277 i_datlocale =
PQfnumber(res,
"datlocale");
3278 i_daticurules =
PQfnumber(res,
"daticurules");
3279 i_frozenxid =
PQfnumber(res,
"datfrozenxid");
3280 i_minmxid =
PQfnumber(res,
"datminmxid");
3282 i_acldefault =
PQfnumber(res,
"acldefault");
3283 i_datistemplate =
PQfnumber(res,
"datistemplate");
3284 i_datconnlimit =
PQfnumber(res,
"datconnlimit");
3285 i_datcollversion =
PQfnumber(res,
"datcollversion");
3286 i_tablespace =
PQfnumber(res,
"tablespace");
3301 icurules =
PQgetvalue(res, 0, i_daticurules);
3328 "CREATE DATABASE %s WITH TEMPLATE = template0 "
3329 "OID = %u STRATEGY = FILE_COPY",
3330 qdatname, dbCatId.
oid);
3351 pg_fatal(
"unrecognized locale provider: %s",
3354 if (strlen(collate) > 0 && strcmp(collate, ctype) == 0)
3361 if (strlen(collate) > 0)
3366 if (strlen(ctype) > 0)
3429 .createStmt = creaQry->
data,
3430 .dropStmt = delQry->
data));
3459 .description =
"COMMENT",
3461 .createStmt = dbQry->
data,
3479 if (seclabelQry->
len > 0)
3483 .description =
"SECURITY LABEL",
3485 .createStmt = seclabelQry->
data,
3500 qdatname, NULL, NULL,
3501 NULL, dba, &dbdacl);
3531 "SET datistemplate = false WHERE datname = ");
3552 "SET datfrozenxid = '%u', datminmxid = '%u'\n"
3554 frozenxid, minmxid);
3559 if (creaQry->
len > 0)
3565 .createStmt = creaQry->
data,
3566 .dropStmt = delQry->
data,
3567 .deps = &dbDumpId));
3579 int ii_relfrozenxid,
3588 appendPQExpBuffer(loFrozenQry,
"SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
3589 "FROM pg_catalog.pg_class\n"
3590 "WHERE oid IN (%u, %u);\n",
3591 LargeObjectRelationId, LargeObjectLOidPNIndexId);
3593 appendPQExpBuffer(loFrozenQry,
"SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
3594 "FROM pg_catalog.pg_class\n"
3595 "WHERE oid IN (%u, %u);\n",
3596 LargeObjectRelationId, LargeObjectLOidPNIndexId);
3600 ii_relfrozenxid =
PQfnumber(lo_res,
"relfrozenxid");
3601 ii_relminmxid =
PQfnumber(lo_res,
"relminmxid");
3602 ii_relfilenode =
PQfnumber(lo_res,
"relfilenode");
3605 appendPQExpBufferStr(loHorizonQry,
"\n-- For binary upgrade, set pg_largeobject relfrozenxid and relminmxid\n");
3606 appendPQExpBufferStr(loOutQry,
"\n-- For binary upgrade, preserve pg_largeobject and index relfilenodes\n");
3613 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
3614 "WHERE oid = %u;\n",
3622 if (oid == LargeObjectRelationId)
3624 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
3626 else if (oid == LargeObjectLOidPNIndexId)
3628 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
3633 "TRUNCATE pg_catalog.pg_largeobject;\n");
3640 .createStmt = loOutQry->
data));
3672 "WHERE setrole = 0 AND setdatabase = '%u'::oid",
3679 "DATABASE",
dbname, NULL, NULL,
3686 "FROM pg_db_role_setting s, pg_roles r "
3687 "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
3722 .createStmt = qry->
data));
3734 const char *stdstrings = AH->
std_strings ?
"on" :
"off";
3737 pg_log_info(
"saving \"standard_conforming_strings = %s\"",
3747 .createStmt = qry->
data));
3761 char **schemanames = NULL;
3762 int nschemanames = 0;
3773 "SELECT pg_catalog.current_schemas(false)");
3776 pg_fatal(
"could not parse result of current_schemas()");
3784 for (
i = 0;
i < nschemanames;
i++)
3801 .createStmt = qry->
data));
3838 "SELECT oid, lomowner, lomacl, "
3839 "acldefault('L', lomowner) AS acldefault "
3840 "FROM pg_largeobject_metadata "
3841 "ORDER BY lomowner, lomacl::pg_catalog.text, oid");
3846 i_lomowner =
PQfnumber(res,
"lomowner");
3848 i_acldefault =
PQfnumber(res,
"acldefault");
3860 for (
i = 0;
i < ntups;
i += n)
3873 if (strcmp(thisowner,
PQgetvalue(res,
i + n, i_lomowner)) != 0 ||
3874 strcmp(thisacl,
PQgetvalue(res,
i + n, i_lomacl)) != 0)
3888 snprintf(namebuf,
sizeof(namebuf),
"%u..%u", thisoid,
3891 snprintf(namebuf,
sizeof(namebuf),
"%u", thisoid);
3899 loinfo->
looids[0] = thisoid;
3901 for (
int k = 1; k < n; k++)
3908 extraID.
tableoid = LargeObjectRelationId;
3928 loinfo->
dobj.
dump &= ~DUMP_COMPONENT_DATA;
3964 for (
int i = 0;
i < loinfo->
numlos;
i++)
3971 .description =
"BLOB METADATA",
3973 .createStmt = cquery->
data,
3974 .dropStmt =
"-- dummy"));
3983 for (
int i = 0;
i < loinfo->
numlos;
i++)
4023 snprintf(tagbuf,
sizeof(tagbuf),
"LARGE OBJECTS %u..%u",
4027 "LARGE OBJECT", namebuf, NULL, NULL,
4033 "LARGE OBJECT", namebuf, NULL, NULL,
4054 for (
int i = 0;
i < loinfo->
numlos;
i++)
4063 pg_fatal(
"could not open large object %u: %s",
4073 pg_fatal(
"error reading large object %u: %s",
4104 int i_polpermissive;
4127 for (
i = 0;
i < numTables;
i++)
4136 if (tbinfo->
relkind != RELKIND_RELATION &&
4137 tbinfo->
relkind != RELKIND_PARTITIONED_TABLE)
4141 if (tbloids->
len > 1)
4162 polinfo->
dobj.namespace = tbinfo->
dobj.namespace;
4181 pg_log_info(
"reading row-level security policies");
4184 "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
4190 "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
4191 " 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, "
4192 "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
4193 "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
4194 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
4195 "JOIN pg_catalog.pg_policy pol ON (src.tbloid = pol.polrelid)",
4204 i_tableoid =
PQfnumber(res,
"tableoid");
4205 i_polrelid =
PQfnumber(res,
"polrelid");
4208 i_polpermissive =
PQfnumber(res,
"polpermissive");
4209 i_polroles =
PQfnumber(res,
"polroles");
4211 i_polwithcheck =
PQfnumber(res,
"polwithcheck");
4215 for (
j = 0;
j < ntups;
j++)
4227 polinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
4236 polinfo[
j].polroles = NULL;
4299 .namespace = polinfo->
dobj.namespace->dobj.
name,
4301 .description =
"ROW SECURITY",
4303 .createStmt = query->
data,
4311 if (polinfo->
polcmd ==
'*')
4313 else if (polinfo->
polcmd ==
'r')
4314 cmd =
" FOR SELECT";
4315 else if (polinfo->
polcmd ==
'a')
4316 cmd =
" FOR INSERT";
4317 else if (polinfo->
polcmd ==
'w')
4318 cmd =
" FOR UPDATE";
4319 else if (polinfo->
polcmd ==
'd')
4320 cmd =
" FOR DELETE";
4322 pg_fatal(
"unexpected policy command type: %c",
4358 .
namespace = polinfo->
dobj.namespace->dobj.
name,
4360 .description =
"POLICY",
4362 .createStmt = query->
data,
4363 .dropStmt = delqry->
data));
4409 "p.pubowner, p.puballtables, p.pubinsert, "
4410 "p.pubupdate, p.pubdelete, ");
4436 i_tableoid =
PQfnumber(res,
"tableoid");
4439 i_pubowner =
PQfnumber(res,
"pubowner");
4440 i_puballtables =
PQfnumber(res,
"puballtables");
4441 i_pubinsert =
PQfnumber(res,
"pubinsert");
4442 i_pubupdate =
PQfnumber(res,
"pubupdate");
4443 i_pubdelete =
PQfnumber(res,
"pubdelete");
4444 i_pubtruncate =
PQfnumber(res,
"pubtruncate");
4445 i_pubviaroot =
PQfnumber(res,
"pubviaroot");
4446 i_pubgencols =
PQfnumber(res,
"pubgencols");
4450 for (
i = 0;
i < ntups;
i++)
4460 (strcmp(
PQgetvalue(res,
i, i_puballtables),
"t") == 0);
4462 (strcmp(
PQgetvalue(res,
i, i_pubinsert),
"t") == 0);
4464 (strcmp(
PQgetvalue(res,
i, i_pubupdate),
"t") == 0);
4466 (strcmp(
PQgetvalue(res,
i, i_pubdelete),
"t") == 0);
4468 (strcmp(
PQgetvalue(res,
i, i_pubtruncate),
"t") == 0);
4470 (strcmp(
PQgetvalue(res,
i, i_pubviaroot),
"t") == 0);
4563 .description =
"PUBLICATION",
4565 .createStmt = query->
data,
4566 .dropStmt = delq->
data));
4609 "SELECT tableoid, oid, pnpubid, pnnspid "
4610 "FROM pg_catalog.pg_publication_namespace");
4615 i_tableoid =
PQfnumber(res,
"tableoid");
4624 for (
i = 0;
i < ntups;
i++)
4636 if (pubinfo == NULL)
4639 if (nspinfo == NULL)
4648 pubsinfo[
j].
dobj.namespace = nspinfo->
dobj.namespace;
4692 "SELECT tableoid, oid, prpubid, prrelid, "
4693 "pg_catalog.pg_get_expr(prqual, prrelid) AS prrelqual, "
4695 " WHEN pr.prattrs IS NOT NULL THEN\n"
4696 " (SELECT array_agg(attname)\n"
4698 " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
4699 " pg_catalog.pg_attribute\n"
4700 " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
4701 " ELSE NULL END) prattrs "
4702 "FROM pg_catalog.pg_publication_rel pr");
4705 "SELECT tableoid, oid, prpubid, prrelid, "
4706 "NULL AS prrelqual, NULL AS prattrs "
4707 "FROM pg_catalog.pg_publication_rel");
4712 i_tableoid =
PQfnumber(res,
"tableoid");
4716 i_prrelqual =
PQfnumber(res,
"prrelqual");
4723 for (
i = 0;
i < ntups;
i++)
4735 if (pubinfo == NULL)
4743 pubrinfo[
j].dobj.catId.tableoid =
4747 pubrinfo[
j].dobj.namespace = tbinfo->
dobj.namespace;
4748 pubrinfo[
j].dobj.name = tbinfo->
dobj.
name;
4749 pubrinfo[
j].publication = pubinfo;
4750 pubrinfo[
j].pubtable = tbinfo;
4752 pubrinfo[
j].pubrelqual = NULL;
4763 &attnames, &nattnames))
4764 pg_fatal(
"could not parse %s array",
"prattrs");
4766 for (
int k = 0; k < nattnames; k++)
4773 pubrinfo[
j].pubrattrs = attribs->
data;
4778 pubrinfo[
j].pubrattrs = NULL;
4821 .
namespace = schemainfo->
dobj.
name,
4823 .description =
"PUBLICATION TABLES IN SCHEMA",
4825 .createStmt = query->
data));
4859 if (pubrinfo->pubrattrs)
4862 if (pubrinfo->pubrelqual)
4881 ArchiveEntry(fout, pubrinfo->dobj.catId, pubrinfo->dobj.dumpId,
4883 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
4885 .description =
"PUBLICATION TABLE",
4887 .createStmt = query->
data));
4906 if (
val && strcmp(
val,
"on") == 0)
4924 "SELECT set_config(name, '%s', false) "
4926 "WHERE name = 'restrict_nonsystem_relation_kind'",
4951 int i_subtwophasestate;
4952 int i_subdisableonerr;
4953 int i_subpasswordrequired;
4954 int i_subrunasowner;
4957 int i_subsynccommit;
4958 int i_subpublications;
4960 int i_suboriginremotelsn;
4974 "SELECT count(*) FROM pg_subscription "
4975 "WHERE subdbid = (SELECT oid FROM pg_database"
4976 " WHERE datname = current_database())",
4980 pg_log_warning(
"subscriptions not dumped because current user is not a superuser");
4989 "SELECT s.tableoid, s.oid, s.subname,\n"
4991 " s.subconninfo, s.subslotname, s.subsynccommit,\n"
4992 " s.subpublications,\n");
5006 " s.subtwophasestate,\n"
5007 " s.subdisableonerr,\n");
5010 " '%c' AS subtwophasestate,\n"
5011 " false AS subdisableonerr,\n",
5012 LOGICALREP_TWOPHASE_STATE_DISABLED);
5016 " s.subpasswordrequired,\n"
5017 " s.subrunasowner,\n"
5021 " 't' AS subpasswordrequired,\n"
5022 " 't' AS subrunasowner,\n"
5023 " '%s' AS suborigin,\n",
5024 LOGICALREP_ORIGIN_ANY);
5028 " s.subenabled,\n");
5031 " false AS subenabled,\n");
5035 " s.subfailover\n");
5038 " false AS subfailover\n");
5041 "FROM pg_subscription s\n");
5045 "LEFT JOIN pg_catalog.pg_replication_origin_status o \n"
5046 " ON o.external_id = 'pg_' || s.oid::text \n");
5049 "WHERE s.subdbid = (SELECT oid FROM pg_database\n"
5050 " WHERE datname = current_database())");
5060 i_tableoid =
PQfnumber(res,
"tableoid");
5063 i_subowner =
PQfnumber(res,
"subowner");
5064 i_subenabled =
PQfnumber(res,
"subenabled");
5065 i_subbinary =
PQfnumber(res,
"subbinary");
5066 i_substream =
PQfnumber(res,
"substream");
5067 i_subtwophasestate =
PQfnumber(res,
"subtwophasestate");
5068 i_subdisableonerr =
PQfnumber(res,
"subdisableonerr");
5069 i_subpasswordrequired =
PQfnumber(res,
"subpasswordrequired");
5070 i_subrunasowner =
PQfnumber(res,
"subrunasowner");
5071 i_subfailover =
PQfnumber(res,
"subfailover");
5072 i_subconninfo =
PQfnumber(res,
"subconninfo");
5073 i_subslotname =
PQfnumber(res,
"subslotname");
5074 i_subsynccommit =
PQfnumber(res,
"subsynccommit");
5075 i_subpublications =
PQfnumber(res,
"subpublications");
5076 i_suborigin =
PQfnumber(res,
"suborigin");
5077 i_suboriginremotelsn =
PQfnumber(res,
"suboriginremotelsn");
5081 for (
i = 0;
i < ntups;
i++)
5092 (strcmp(
PQgetvalue(res,
i, i_subenabled),
"t") == 0);
5094 (strcmp(
PQgetvalue(res,
i, i_subbinary),
"t") == 0);
5098 (strcmp(
PQgetvalue(res,
i, i_subdisableonerr),
"t") == 0);
5100 (strcmp(
PQgetvalue(res,
i, i_subpasswordrequired),
"t") == 0);
5102 (strcmp(
PQgetvalue(res,
i, i_subrunasowner),
"t") == 0);
5104 (strcmp(
PQgetvalue(res,
i, i_subfailover),
"t") == 0);
5155 "SELECT srsubid, srrelid, srsubstate, srsublsn "
5156 "FROM pg_catalog.pg_subscription_rel "
5166 i_srsubstate =
PQfnumber(res,
"srsubstate");
5167 i_srsublsn =
PQfnumber(res,
"srsublsn");
5170 for (
int i = 0;
i < ntups;
i++)
5180 if (cur_srsubid != last_srsubid)
5183 if (subinfo == NULL)
5184 pg_fatal(
"subscription with OID %u does not exist", cur_srsubid);
5186 last_srsubid = cur_srsubid;
5190 if (tblinfo == NULL)
5191 pg_fatal(
"failed sanity check, table with OID %u not found",
5248 "\n-- For binary upgrade, must preserve the subscriber table.\n");
5250 "SELECT pg_catalog.binary_upgrade_add_sub_rel_state(");
5277 .description =
"SUBSCRIPTION TABLE",
5279 .createStmt = query->
data));
5299 char **pubnames = NULL;
5321 pg_fatal(
"could not parse %s array",
"subpublications");
5324 for (
i = 0;
i < npubnames;
i++)
5332 appendPQExpBuffer(query,
" PUBLICATION %s WITH (connect = false, slot_name = ", publications->
data);
5341 if (subinfo->
substream == LOGICALREP_STREAM_ON)
5343 else if (subinfo->
substream == LOGICALREP_STREAM_PARALLEL)
5389 "\n-- For binary upgrade, must preserve the remote_lsn for the subscriber's replication origin.\n");
5391 "SELECT pg_catalog.binary_upgrade_replorigin_advance(");
5403 "\n-- For binary upgrade, must preserve the subscriber's running state.\n");
5412 .description =
"SUBSCRIPTION",
5414 .createStmt = query->
data,
5415 .dropStmt = delq->
data));
5443 const char *catalog,
5444 const char *keyword,
5445 const char *objname)
5462 "FROM pg_catalog.pg_depend d, pg_catalog.pg_extension e "
5463 "WHERE d.refobjid = e.oid AND classid = '%s'::pg_catalog.regclass "
5464 "AND objid = '%u'::pg_catalog.oid AND deptype = 'x' "
5465 "AND refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass",
5471 for (
i = 0;
i < ntups;
i++)
5501 ++next_possible_free_oid;
5503 "SELECT EXISTS(SELECT 1 "
5504 "FROM pg_catalog.pg_type "
5505 "WHERE oid = '%u'::pg_catalog.oid);",
5506 next_possible_free_oid);
5512 return next_possible_free_oid;
5519 bool force_array_type,
5520 bool include_multirange_type)
5524 Oid pg_type_array_oid;
5525 Oid pg_type_multirange_oid;
5526 Oid pg_type_multirange_array_oid;
5531 "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5536 pg_type_array_oid =
tinfo->typarray;
5540 if (!
OidIsValid(pg_type_array_oid) && force_array_type)
5546 "\n-- For binary upgrade, must preserve pg_type array oid\n");
5548 "SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5555 if (include_multirange_type)
5560 "SELECT t.oid, t.typarray "
5561 "FROM pg_catalog.pg_type t "
5562 "JOIN pg_catalog.pg_range r "
5563 "ON t.oid = r.rngmultitypid "
5564 "WHERE r.rngtypid = '%u'::pg_catalog.oid;",
5581 "\n-- For binary upgrade, must preserve multirange pg_type oid\n");
5583 "SELECT pg_catalog.binary_upgrade_set_next_multirange_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5584 pg_type_multirange_oid);
5586 "\n-- For binary upgrade, must preserve multirange pg_type array oid\n");
5588 "SELECT pg_catalog.binary_upgrade_set_next_multirange_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5589 pg_type_multirange_array_oid);
5604 pg_type_oid,
false,
false);
5632 query =
"SELECT c.oid, c.relkind, c.relfilenode, c.reltoastrelid, "
5633 "ct.relfilenode, i.indexrelid, cti.relfilenode "
5634 "FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_index i "
5635 "ON (c.reltoastrelid = i.indrelid AND i.indisvalid) "
5636 "LEFT JOIN pg_catalog.pg_class ct ON (c.reltoastrelid = ct.oid) "
5637 "LEFT JOIN pg_catalog.pg_class AS cti ON (i.indexrelid = cti.oid) "
5680 key.oid = pg_class_oid;
5686 "\n-- For binary upgrade, must preserve pg_class oids and relfilenodes\n");
5688 if (entry->
relkind != RELKIND_INDEX &&
5689 entry->
relkind != RELKIND_PARTITIONED_INDEX)
5692 "SELECT pg_catalog.binary_upgrade_set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
5701 entry->
relkind != RELKIND_PARTITIONED_TABLE)
5703 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
5711 entry->
relkind != RELKIND_PARTITIONED_TABLE)
5714 "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
5717 "SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
5722 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5725 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5733 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5736 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5753 const char *objtype,
5754 const char *objname,
5755 const char *objnamespace)
5777 pg_fatal(
"could not find parent extension for %s %s",
5781 "\n-- For binary upgrade, handle extension membership the hard way\n");
5785 if (objnamespace && *objnamespace)
5818 "acldefault('n', n.nspowner) AS acldefault "
5819 "FROM pg_namespace n");
5827 i_tableoid =
PQfnumber(res,
"tableoid");
5830 i_nspowner =
PQfnumber(res,
"nspowner");
5832 i_acldefault =
PQfnumber(res,
"acldefault");
5834 for (
i = 0;
i < ntups;
i++)
5836 const char *nspowner;
5874 if (strcmp(nsinfo[
i].dobj.name,
"public") == 0)
5915 pg_fatal(
"schema with OID %u does not exist", nsoid);
5939 int i_extrelocatable;
5947 "x.extname, n.nspname, x.extrelocatable, x.extversion, x.extconfig, x.extcondition "
5948 "FROM pg_extension x "
5949 "JOIN pg_namespace n ON n.oid = x.extnamespace");
5959 i_tableoid =
PQfnumber(res,
"tableoid");
5963 i_extrelocatable =
PQfnumber(res,
"extrelocatable");
5964 i_extversion =
PQfnumber(res,
"extversion");
5965 i_extconfig =
PQfnumber(res,
"extconfig");
5966 i_extcondition =
PQfnumber(res,
"extcondition");
5968 for (
i = 0;
i < ntups;
i++)
5989 *numExtensions = ntups;
6041 "typnamespace, typacl, "
6042 "acldefault('T', typowner) AS acldefault, "
6044 "typelem, typrelid, typarray, "
6045 "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
6046 "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
6047 "typtype, typisdefined, "
6048 "typname[0] = '_' AND typelem != 0 AND "
6049 "(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray "
6058 i_tableoid =
PQfnumber(res,
"tableoid");
6061 i_typnamespace =
PQfnumber(res,
"typnamespace");
6063 i_acldefault =
PQfnumber(res,
"acldefault");
6064 i_typowner =
PQfnumber(res,
"typowner");
6066 i_typrelid =
PQfnumber(res,
"typrelid");
6067 i_typrelkind =
PQfnumber(res,
"typrelkind");
6069 i_typisdefined =
PQfnumber(res,
"typisdefined");
6071 i_typarray =
PQfnumber(res,
"typarray");
6073 for (
i = 0;
i < ntups;
i++)
6080 tyinfo[
i].
dobj.namespace =
6094 if (strcmp(
PQgetvalue(res,
i, i_typisdefined),
"t") == 0)
6099 if (strcmp(
PQgetvalue(res,
i, i_isarray),
"t") == 0)
6106 if (tyinfo[
i].typtype == TYPTYPE_MULTIRANGE)
6124 tyinfo[
i].
typtype == TYPTYPE_DOMAIN)
6138 (tyinfo[
i].
typtype == TYPTYPE_BASE ||
6139 tyinfo[
i].
typtype == TYPTYPE_RANGE))
6146 stinfo->
dobj.namespace = tyinfo[
i].
dobj.namespace;
6193 "oprcode::oid AS oprcode "
6194 "FROM pg_operator");
6202 i_tableoid =
PQfnumber(res,
"tableoid");
6205 i_oprnamespace =
PQfnumber(res,
"oprnamespace");
6206 i_oprowner =
PQfnumber(res,
"oprowner");
6210 for (
i = 0;
i < ntups;
i++)
6217 oprinfo[
i].
dobj.namespace =
6247 int i_collnamespace;
6260 "FROM pg_collation");
6268 i_tableoid =
PQfnumber(res,
"tableoid");
6270 i_collname =
PQfnumber(res,
"collname");
6271 i_collnamespace =
PQfnumber(res,
"collnamespace");
6272 i_collowner =
PQfnumber(res,
"collowner");
6274 for (
i = 0;
i < ntups;
i++)
6281 collinfo[
i].
dobj.namespace =
6322 "FROM pg_conversion");
6330 i_tableoid =
PQfnumber(res,
"tableoid");
6333 i_connamespace =
PQfnumber(res,
"connamespace");
6334 i_conowner =
PQfnumber(res,
"conowner");
6336 for (
i = 0;
i < ntups;
i++)
6343 convinfo[
i].
dobj.namespace =
6382 "amhandler::pg_catalog.regproc AS amhandler "
6391 i_tableoid =
PQfnumber(res,
"tableoid");
6394 i_amhandler =
PQfnumber(res,
"amhandler");
6397 for (
i = 0;
i < ntups;
i++)
6404 aminfo[
i].
dobj.namespace = NULL;
6452 i_tableoid =
PQfnumber(res,
"tableoid");
6455 i_opcnamespace =
PQfnumber(res,
"opcnamespace");
6456 i_opcowner =
PQfnumber(res,
"opcowner");
6458 for (
i = 0;
i < ntups;
i++)
6465 opcinfo[
i].
dobj.namespace =
6506 "FROM pg_opfamily");
6514 i_tableoid =
PQfnumber(res,
"tableoid");
6517 i_opfnamespace =
PQfnumber(res,
"opfnamespace");
6518 i_opfowner =
PQfnumber(res,
"opfowner");
6520 for (
i = 0;
i < ntups;
i++)
6527 opfinfo[
i].
dobj.namespace =
6569 const char *agg_check;
6571 agg_check = (fout->
remoteVersion >= 110000 ?
"p.prokind = 'a'"
6575 "p.proname AS aggname, "
6576 "p.pronamespace AS aggnamespace, "
6577 "p.pronargs, p.proargtypes, "
6579 "p.proacl AS aggacl, "
6580 "acldefault('f', p.proowner) AS acldefault "
6582 "LEFT JOIN pg_init_privs pip ON "
6583 "(p.oid = pip.objoid "
6584 "AND pip.classoid = 'pg_proc'::regclass "
6585 "AND pip.objsubid = 0) "
6587 "p.pronamespace != "
6588 "(SELECT oid FROM pg_namespace "
6589 "WHERE nspname = 'pg_catalog') OR "
6590 "p.proacl IS DISTINCT FROM pip.initprivs",
6594 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6595 "classid = 'pg_proc'::regclass AND "
6596 "objid = p.oid AND "
6597 "refclassid = 'pg_extension'::regclass AND "
6604 "pronamespace AS aggnamespace, "
6605 "pronargs, proargtypes, "
6607 "proacl AS aggacl, "
6608 "acldefault('f', proowner) AS acldefault "
6610 "WHERE proisagg AND ("
6612 "(SELECT oid FROM pg_namespace "
6613 "WHERE nspname = 'pg_catalog')");
6616 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6617 "classid = 'pg_proc'::regclass AND "
6618 "objid = p.oid AND "
6619 "refclassid = 'pg_extension'::regclass AND "
6630 i_tableoid =
PQfnumber(res,
"tableoid");
6633 i_aggnamespace =
PQfnumber(res,
"aggnamespace");
6634 i_pronargs =
PQfnumber(res,
"pronargs");
6635 i_proargtypes =
PQfnumber(res,
"proargtypes");
6636 i_proowner =
PQfnumber(res,
"proowner");
6638 i_acldefault =
PQfnumber(res,
"acldefault");
6640 for (
i = 0;
i < ntups;
i++)
6642 agginfo[
i].aggfn.dobj.objType =
DO_AGG;
6647 agginfo[
i].aggfn.dobj.namespace =
6651 agginfo[
i].aggfn.dacl.privtype = 0;
6652 agginfo[
i].aggfn.dacl.initprivs = NULL;
6656 agginfo[
i].aggfn.nargs = atoi(
PQgetvalue(res,
i, i_pronargs));
6657 if (agginfo[
i].aggfn.nargs == 0)
6658 agginfo[
i].aggfn.argtypes = NULL;
6661 agginfo[
i].aggfn.argtypes = (
Oid *)
pg_malloc(agginfo[
i].aggfn.nargs *
sizeof(
Oid));
6663 agginfo[
i].aggfn.argtypes,
6664 agginfo[
i].aggfn.nargs);
6666 agginfo[
i].aggfn.postponed_def =
false;
6729 const char *not_agg_check;
6731 not_agg_check = (fout->
remoteVersion >= 110000 ?
"p.prokind <> 'a'"
6732 :
"NOT p.proisagg");
6735 "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
6736 "p.pronargs, p.proargtypes, p.prorettype, "
6738 "acldefault('f', p.proowner) AS acldefault, "
6742 "LEFT JOIN pg_init_privs pip ON "
6743 "(p.oid = pip.objoid "
6744 "AND pip.classoid = 'pg_proc'::regclass "
6745 "AND pip.objsubid = 0) "
6747 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6748 "WHERE classid = 'pg_proc'::regclass AND "
6749 "objid = p.oid AND deptype = 'i')"
6751 "\n pronamespace != "
6752 "(SELECT oid FROM pg_namespace "
6753 "WHERE nspname = 'pg_catalog')"
6754 "\n OR EXISTS (SELECT 1 FROM pg_cast"
6755 "\n WHERE pg_cast.oid > %u "
6756 "\n AND p.oid = pg_cast.castfunc)"
6757 "\n OR EXISTS (SELECT 1 FROM pg_transform"
6758 "\n WHERE pg_transform.oid > %u AND "
6759 "\n (p.oid = pg_transform.trffromsql"
6760 "\n OR p.oid = pg_transform.trftosql))",
6766 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6767 "classid = 'pg_proc'::regclass AND "
6768 "objid = p.oid AND "
6769 "refclassid = 'pg_extension'::regclass AND "
6772 "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
6778 "SELECT tableoid, oid, proname, prolang, "
6779 "pronargs, proargtypes, prorettype, proacl, "
6780 "acldefault('f', proowner) AS acldefault, "
6784 "WHERE NOT proisagg"
6785 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6786 "WHERE classid = 'pg_proc'::regclass AND "
6787 "objid = p.oid AND deptype = 'i')"
6789 "\n pronamespace != "
6790 "(SELECT oid FROM pg_namespace "
6791 "WHERE nspname = 'pg_catalog')"
6792 "\n OR EXISTS (SELECT 1 FROM pg_cast"
6793 "\n WHERE pg_cast.oid > '%u'::oid"
6794 "\n AND p.oid = pg_cast.castfunc)",
6799 "\n OR EXISTS (SELECT 1 FROM pg_transform"
6800 "\n WHERE pg_transform.oid > '%u'::oid"
6801 "\n AND (p.oid = pg_transform.trffromsql"
6802 "\n OR p.oid = pg_transform.trftosql))",
6807 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6808 "classid = 'pg_proc'::regclass AND "
6809 "objid = p.oid AND "
6810 "refclassid = 'pg_extension'::regclass AND "
6821 i_tableoid =
PQfnumber(res,
"tableoid");
6824 i_pronamespace =
PQfnumber(res,
"pronamespace");
6825 i_proowner =
PQfnumber(res,
"proowner");
6827 i_pronargs =
PQfnumber(res,
"pronargs");
6828 i_proargtypes =
PQfnumber(res,
"proargtypes");
6829 i_prorettype =
PQfnumber(res,
"prorettype");
6831 i_acldefault =
PQfnumber(res,
"acldefault");
6833 for (
i = 0;
i < ntups;
i++)
6840 finfo[
i].
dobj.namespace =
6850 if (finfo[
i].nargs == 0)
6856 finfo[
i].argtypes, finfo[
i].nargs);
6882 char *reltuples,
int32 relallvisible,
6883 int32 relallfrozen,
char relkind,
6884 char **indAttNames,
int nindAttNames)
6889 if ((relkind == RELKIND_RELATION) ||
6890 (relkind == RELKIND_PARTITIONED_TABLE) ||
6891 (relkind == RELKIND_INDEX) ||
6892 (relkind == RELKIND_PARTITIONED_INDEX) ||
6893 (relkind == RELKIND_MATVIEW))
6908 dobj->namespace = rel->namespace;
6929 case RELKIND_RELATION:
6930 case RELKIND_PARTITIONED_TABLE:
6931 case RELKIND_MATVIEW:
6935 case RELKIND_PARTITIONED_INDEX:
6939 pg_fatal(
"cannot dump statistics for relation kind '%c'",
6976 int i_relallvisible;
6981 int i_reltablespace;
6983 int i_relhastriggers;
6984 int i_relpersistence;
6985 int i_relispopulated;
6988 int i_relforcerowsec;
6990 int i_toastfrozenxid;
6996 int i_toastreloptions;
6998 int i_foreignserver;
7000 int i_is_identity_sequence;
7023 "SELECT c.tableoid, c.oid, c.relname, "
7024 "c.relnamespace, c.relkind, c.reltype, "
7027 "c.relhasindex, c.relhasrules, c.relpages, "
7028 "c.reltuples, c.relallvisible, ");
7036 "c.relhastriggers, c.relpersistence, "
7039 "acldefault(CASE WHEN c.relkind = " CppAsString2(RELKIND_SEQUENCE)
7040 " THEN 's'::\"char\" ELSE 'r'::\"char\" END, c.relowner) AS acldefault, "
7041 "CASE WHEN c.relkind = " CppAsString2(RELKIND_FOREIGN_TABLE)
" THEN "
7042 "(SELECT ftserver FROM pg_catalog.pg_foreign_table WHERE ftrelid = c.oid) "
7043 "ELSE 0 END AS foreignserver, "
7044 "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, "
7046 "tc.relpages AS toastpages, "
7047 "tc.reloptions AS toast_reloptions, "
7048 "d.refobjid AS owning_tab, "
7049 "d.refobjsubid AS owning_col, "
7050 "tsp.spcname AS reltablespace, ");
7054 "false AS relhasoids, ");
7061 "c.relispopulated, ");
7064 "'t' as relispopulated, ");
7068 "c.relreplident, ");
7071 "'d' AS relreplident, ");
7075 "c.relrowsecurity, c.relforcerowsecurity, ");
7078 "false AS relrowsecurity, "
7079 "false AS relforcerowsecurity, ");
7083 "c.relminmxid, tc.relminmxid AS tminmxid, ");
7086 "0 AS relminmxid, 0 AS tminmxid, ");
7090 "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
7091 "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
7092 "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
7095 "c.reloptions, NULL AS checkoption, ");
7102 "NULL AS amname, ");
7106 "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
7109 "false AS is_identity_sequence, ");
7113 "c.relispartition AS ispartition ");
7116 "false AS ispartition ");
7125 "\nFROM pg_class c\n"
7126 "LEFT JOIN pg_depend d ON "
7128 "d.classid = 'pg_class'::regclass AND d.objid = c.oid AND "
7129 "d.objsubid = 0 AND "
7130 "d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
7131 "LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
7138 "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
7146 "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid"
7148 " AND c.relkind <> " CppAsString2(RELKIND_PARTITIONED_TABLE)
")\n");
7161 "WHERE c.relkind IN ("
7188 i_reltableoid =
PQfnumber(res,
"tableoid");
7191 i_relnamespace =
PQfnumber(res,
"relnamespace");
7194 i_relowner =
PQfnumber(res,
"relowner");
7195 i_relchecks =
PQfnumber(res,
"relchecks");
7196 i_relhasindex =
PQfnumber(res,
"relhasindex");
7197 i_relhasrules =
PQfnumber(res,
"relhasrules");
7198 i_relpages =
PQfnumber(res,
"relpages");
7199 i_reltuples =
PQfnumber(res,
"reltuples");
7200 i_relallvisible =
PQfnumber(res,
"relallvisible");
7201 i_relallfrozen =
PQfnumber(res,
"relallfrozen");
7202 i_toastpages =
PQfnumber(res,
"toastpages");
7203 i_owning_tab =
PQfnumber(res,
"owning_tab");
7204 i_owning_col =
PQfnumber(res,
"owning_col");
7205 i_reltablespace =
PQfnumber(res,
"reltablespace");
7206 i_relhasoids =
PQfnumber(res,
"relhasoids");
7207 i_relhastriggers =
PQfnumber(res,
"relhastriggers");
7208 i_relpersistence =
PQfnumber(res,
"relpersistence");
7209 i_relispopulated =
PQfnumber(res,
"relispopulated");
7210 i_relreplident =
PQfnumber(res,
"relreplident");
7211 i_relrowsec =
PQfnumber(res,
"relrowsecurity");
7212 i_relforcerowsec =
PQfnumber(res,
"relforcerowsecurity");
7213 i_relfrozenxid =
PQfnumber(res,
"relfrozenxid");
7214 i_toastfrozenxid =
PQfnumber(res,
"tfrozenxid");
7216 i_relminmxid =
PQfnumber(res,
"relminmxid");
7217 i_toastminmxid =
PQfnumber(res,
"tminmxid");
7218 i_reloptions =
PQfnumber(res,
"reloptions");
7219 i_checkoption =
PQfnumber(res,
"checkoption");
7220 i_toastreloptions =
PQfnumber(res,
"toast_reloptions");
7221 i_reloftype =
PQfnumber(res,
"reloftype");
7222 i_foreignserver =
PQfnumber(res,
"foreignserver");
7224 i_is_identity_sequence =
PQfnumber(res,
"is_identity_sequence");
7226 i_acldefault =
PQfnumber(res,
"acldefault");
7227 i_ispartition =
PQfnumber(res,
"ispartition");
7246 for (
i = 0;
i < ntups;
i++)
7256 tblinfo[
i].
dobj.namespace =
7316 if (tblinfo[
i].relkind == RELKIND_COMPOSITE_TYPE)
7349 if (tblinfo[
i].interesting)
7354 tblinfo[
i].relpages,
7356 relallvisible, relallfrozen,
7357 tblinfo[
i].relkind, NULL, 0);
7358 if (tblinfo[
i].relkind == RELKIND_MATVIEW)
7359 tblinfo[
i].
stats = stats;
7378 (tblinfo[
i].
relkind == RELKIND_RELATION ||
7379 tblinfo[
i].
relkind == RELKIND_PARTITIONED_TABLE))
7386 if (query->
len == 0)
7395 if (query->
len >= 100000)
7406 if (query->
len != 0)
7441 for (
i = 0;
i < numTables;
i++)
7450 if (owning_tab == NULL)
7451 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
7516 *numInherits = ntups;
7520 i_inhrelid =
PQfnumber(res,
"inhrelid");
7521 i_inhparent =
PQfnumber(res,
"inhparent");
7523 for (
i = 0;
i < ntups;
i++)
7578 "SELECT partrelid FROM pg_partitioned_table WHERE\n"
7579 "(SELECT c.oid FROM pg_opclass c JOIN pg_am a "
7580 "ON c.opcmethod = a.oid\n"
7581 "WHERE opcname = 'enum_ops' "
7582 "AND opcnamespace = 'pg_catalog'::regnamespace "
7583 "AND amname = 'hash') = ANY(partclass)");
7589 for (
int i = 0;
i < ntups;
i++)
7596 pg_fatal(
"failed sanity check, table OID %u appearing in pg_partitioned_table not found",
7637 i_indnullsnotdistinct,
7661 for (
int i = 0;
i < numTables;
i++)
7675 if (tbloids->
len > 1)
7682 "SELECT t.tableoid, t.oid, i.indrelid, "
7683 "t.relname AS indexname, "
7684 "t.relpages, t.reltuples, t.relallvisible, ");
7692 "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
7693 "i.indkey, i.indisclustered, "
7694 "c.contype, c.conname, "
7695 "c.condeferrable, c.condeferred, "
7696 "c.tableoid AS contableoid, "
7698 "pg_catalog.pg_get_constraintdef(c.oid, false) AS condef, "
7699 "CASE WHEN i.indexprs IS NOT NULL THEN "
7700 "(SELECT pg_catalog.array_agg(attname ORDER BY attnum)"
7701 " FROM pg_catalog.pg_attribute "
7702 " WHERE attrelid = i.indexrelid) "
7703 "ELSE NULL END AS indattnames, "
7704 "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
7705 "t.reloptions AS indreloptions, ");
7710 "i.indisreplident, ");
7713 "false AS indisreplident, ");
7717 "inh.inhparent AS parentidx, "
7718 "i.indnkeyatts AS indnkeyatts, "
7719 "i.indnatts AS indnatts, "
7720 "(SELECT pg_catalog.array_agg(attnum ORDER BY attnum) "
7721 " FROM pg_catalog.pg_attribute "
7722 " WHERE attrelid = i.indexrelid AND "
7723 " attstattarget >= 0) AS indstatcols, "
7724 "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attnum) "
7725 " FROM pg_catalog.pg_attribute "
7726 " WHERE attrelid = i.indexrelid AND "
7727 " attstattarget >= 0) AS indstatvals, ");
7731 "i.indnatts AS indnkeyatts, "
7732 "i.indnatts AS indnatts, "
7733 "'' AS indstatcols, "
7734 "'' AS indstatvals, ");
7738 "i.indnullsnotdistinct, ");
7741 "false AS indnullsnotdistinct, ");
7748 "NULL AS conperiod ");
7762 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7763 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7764 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7765 "JOIN pg_catalog.pg_class t2 ON (t2.oid = i.indrelid) "
7766 "LEFT JOIN pg_catalog.pg_constraint c "
7767 "ON (i.indrelid = c.conrelid AND "
7768 "i.indexrelid = c.conindid AND "
7769 "c.contype IN ('p','u','x')) "
7770 "LEFT JOIN pg_catalog.pg_inherits inh "
7771 "ON (inh.inhrelid = indexrelid) "
7772 "WHERE (i.indisvalid OR t2.relkind = 'p') "
7774 "ORDER BY i.indrelid, indexname",
7784 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7785 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7786 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7787 "LEFT JOIN pg_catalog.pg_constraint c "
7788 "ON (i.indrelid = c.conrelid AND "
7789 "i.indexrelid = c.conindid AND "
7790 "c.contype IN ('p','u','x')) "
7791 "WHERE i.indisvalid AND i.indisready "
7792 "ORDER BY i.indrelid, indexname",
7800 i_tableoid =
PQfnumber(res,
"tableoid");
7802 i_indrelid =
PQfnumber(res,
"indrelid");
7803 i_indexname =
PQfnumber(res,
"indexname");
7804 i_relpages =
PQfnumber(res,
"relpages");
7805 i_reltuples =
PQfnumber(res,
"reltuples");
7806 i_relallvisible =
PQfnumber(res,
"relallvisible");
7807 i_relallfrozen =
PQfnumber(res,
"relallfrozen");
7808 i_parentidx =
PQfnumber(res,
"parentidx");
7809 i_indexdef =
PQfnumber(res,
"indexdef");
7810 i_indnkeyatts =
PQfnumber(res,
"indnkeyatts");
7811 i_indnatts =
PQfnumber(res,
"indnatts");
7813 i_indisclustered =
PQfnumber(res,
"indisclustered");
7814 i_indisreplident =
PQfnumber(res,
"indisreplident");
7815 i_indnullsnotdistinct =
PQfnumber(res,
"indnullsnotdistinct");
7818 i_condeferrable =
PQfnumber(res,
"condeferrable");
7819 i_condeferred =
PQfnumber(res,
"condeferred");
7820 i_conperiod =
PQfnumber(res,
"conperiod");
7821 i_contableoid =
PQfnumber(res,
"contableoid");
7824 i_indattnames =
PQfnumber(res,
"indattnames");
7825 i_tablespace =
PQfnumber(res,
"tablespace");
7826 i_indreloptions =
PQfnumber(res,
"indreloptions");
7827 i_indstatcols =
PQfnumber(res,
"indstatcols");
7828 i_indstatvals =
PQfnumber(res,
"indstatvals");
7837 for (
int j = 0;
j < ntups;)
7841 char **indAttNames = NULL;
7842 int nindAttNames = 0;
7846 for (numinds = 1; numinds < ntups -
j; numinds++)
7854 while (++curtblindx < numTables)
7856 tbinfo = &tblinfo[curtblindx];
7860 if (curtblindx >= numTables)
7861 pg_fatal(
"unrecognized table OID %u", indrelid);
7865 pg_fatal(
"unexpected index data for table \"%s\"",
7872 for (
int c = 0;
c < numinds;
c++,
j++)
7887 indxinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
7898 indxinfo[
j].indkeys, indxinfo[
j].indnattrs);
7908 if (indxinfo[
j].parentidx == 0)
7909 indexkind = RELKIND_INDEX;
7911 indexkind = RELKIND_PARTITIONED_INDEX;
7916 &indAttNames, &nindAttNames))
7917 pg_fatal(
"could not parse %s array",
"indattnames");
7922 relallvisible, relallfrozen, indexkind,
7923 indAttNames, nindAttNames);
7926 if (contype ==
'p' || contype ==
'u' || contype ==
'x')
7941 constrinfo->
dobj.namespace = tbinfo->
dobj.namespace;
7944 constrinfo->
contype = contype;
7948 constrinfo->
condef = NULL;
7958 if (relstats != NULL)
8006 "stxnamespace, stxowner, stxrelid, NULL AS stxstattarget "
8007 "FROM pg_catalog.pg_statistic_ext");
8010 "stxnamespace, stxowner, stxrelid, stxstattarget "
8011 "FROM pg_catalog.pg_statistic_ext");
8017 i_tableoid =
PQfnumber(res,
"tableoid");
8020 i_stxnamespace =
PQfnumber(res,
"stxnamespace");
8021 i_stxowner =
PQfnumber(res,
"stxowner");
8022 i_stxrelid =
PQfnumber(res,
"stxrelid");
8023 i_stattarget =
PQfnumber(res,
"stxstattarget");
8027 for (
i = 0;
i < ntups;
i++)
8034 statsextinfo[
i].
dobj.namespace =
8088 for (
int i = 0;
i < numTables;
i++)
8096 if (tbloids->
len > 1)
8103 "SELECT c.tableoid, c.oid, "
8104 "conrelid, conname, confrelid, ");
8110 "pg_catalog.pg_get_constraintdef(c.oid) AS condef\n"
8111 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8112 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
8113 "WHERE contype = 'f' ",
8117 "AND conparentid = 0 ");
8119 "ORDER BY conrelid, conname");
8125 i_contableoid =
PQfnumber(res,
"tableoid");
8127 i_conrelid =
PQfnumber(res,
"conrelid");
8129 i_confrelid =
PQfnumber(res,
"confrelid");
8130 i_conindid =
PQfnumber(res,
"conindid");
8136 for (
int j = 0;
j < ntups;
j++)
8145 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != conrelid)
8147 while (++curtblindx < numTables)
8149 tbinfo = &tblinfo[curtblindx];
8153 if (curtblindx >= numTables)
8154 pg_fatal(
"unrecognized table OID %u", conrelid);
8162 constrinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8181 if (reftable && reftable->
relkind == RELKIND_PARTITIONED_TABLE)
8187 for (
int k = 0; k < reftable->
numIndexes; k++)
8195 refidx = &reftable->
indexes[k];
8260 "PREPARE getDomainConstraints(pg_catalog.oid) AS\n"
8261 "SELECT tableoid, oid, conname, "
8262 "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
8264 "FROM pg_catalog.pg_constraint "
8265 "WHERE contypid = $1 AND contype = 'c' "
8266 "ORDER BY conname");
8274 "EXECUTE getDomainConstraints('%u')",
8281 i_tableoid =
PQfnumber(res,
"tableoid");
8291 for (
i = 0;
i < ntups;
i++)
8300 constrinfo[
i].
dobj.namespace = tyinfo->
dobj.namespace;
8350 "tableoid, oid, rulename, "
8351 "ev_class AS ruletable, ev_type, is_instead, "
8362 i_tableoid =
PQfnumber(res,
"tableoid");
8364 i_rulename =
PQfnumber(res,
"rulename");
8365 i_ruletable =
PQfnumber(res,
"ruletable");
8367 i_is_instead =
PQfnumber(res,
"is_instead");
8368 i_ev_enabled =
PQfnumber(res,
"ev_enabled");
8370 for (
i = 0;
i < ntups;
i++)
8381 if (ruleinfo[
i].ruletable == NULL)
8382 pg_fatal(
"failed sanity check, parent table with OID %u of pg_rewrite entry with OID %u not found",
8383 ruletableoid, ruleinfo[
i].dobj.catId.oid);
8389 if (ruleinfo[
i].ruletable)
8398 if ((ruleinfo[
i].ruletable->relkind == RELKIND_VIEW ||
8456 for (
int i = 0;
i < numTables;
i++)
8465 if (tbloids->
len > 1)
8482 "SELECT t.tgrelid, t.tgname, "
8483 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8484 "t.tgenabled, t.tableoid, t.oid, "
8485 "t.tgparentid <> 0 AS tgispartition\n"
8486 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8487 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8488 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8489 "WHERE ((NOT t.tgisinternal AND t.tgparentid = 0) "
8490 "OR t.tgenabled != u.tgenabled) "
8491 "ORDER BY t.tgrelid, t.tgname",
8505 "SELECT t.tgrelid, t.tgname, "
8506 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8507 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition\n"
8508 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8509 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8510 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8511 "WHERE (NOT t.tgisinternal OR t.tgenabled != u.tgenabled) "
8512 "ORDER BY t.tgrelid, t.tgname",
8525 "SELECT t.tgrelid, t.tgname, "
8526 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8527 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition "
8528 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8529 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8530 "LEFT JOIN pg_catalog.pg_depend AS d ON "
8531 " d.classid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8532 " d.refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8534 "LEFT JOIN pg_catalog.pg_trigger AS pt ON pt.oid = refobjid "
8535 "WHERE (NOT t.tgisinternal OR t.tgenabled != pt.tgenabled) "
8536 "ORDER BY t.tgrelid, t.tgname",
8543 "SELECT t.tgrelid, t.tgname, "
8544 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8545 "t.tgenabled, false as tgispartition, "
8546 "t.tableoid, t.oid "
8547 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8548 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8549 "WHERE NOT tgisinternal "
8550 "ORDER BY t.tgrelid, t.tgname",
8558 i_tableoid =
PQfnumber(res,
"tableoid");
8562 i_tgenabled =
PQfnumber(res,
"tgenabled");
8563 i_tgispartition =
PQfnumber(res,
"tgispartition");
8573 for (
int j = 0;
j < ntups;)
8580 for (numtrigs = 1; numtrigs < ntups -
j; numtrigs++)
8588 while (++curtblindx < numTables)
8590 tbinfo = &tblinfo[curtblindx];
8594 if (curtblindx >= numTables)
8595 pg_fatal(
"unrecognized table OID %u", tgrelid);
8601 for (
int c = 0;
c < numtrigs;
c++,
j++)
8608 tginfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8650 "SELECT e.tableoid, e.oid, evtname, evtenabled, "
8651 "evtevent, evtowner, "
8652 "array_to_string(array("
8653 "select quote_literal(x) "
8654 " from unnest(evttags) as t(x)), ', ') as evttags, "
8655 "e.evtfoid::regproc as evtfname "
8656 "FROM pg_event_trigger e "
8665 i_tableoid =
PQfnumber(res,
"tableoid");
8668 i_evtevent =
PQfnumber(res,
"evtevent");
8669 i_evtowner =
PQfnumber(res,
"evtowner");
8671 i_evtfname =
PQfnumber(res,
"evtfname");
8672 i_evtenabled =
PQfnumber(res,
"evtenabled");
8674 for (
i = 0;
i < ntups;
i++)
8716 int i_lanplcallfoid;
8724 "lanname, lanpltrusted, lanplcallfoid, "
8725 "laninline, lanvalidator, "
8727 "acldefault('l', lanowner) AS acldefault, "
8739 i_tableoid =
PQfnumber(res,
"tableoid");
8742 i_lanpltrusted =
PQfnumber(res,
"lanpltrusted");
8743 i_lanplcallfoid =
PQfnumber(res,
"lanplcallfoid");
8744 i_laninline =
PQfnumber(res,
"laninline");
8745 i_lanvalidator =
PQfnumber(res,
"lanvalidator");
8747 i_acldefault =
PQfnumber(res,
"acldefault");
8748 i_lanowner =
PQfnumber(res,
"lanowner");
8750 for (
i = 0;
i < ntups;
i++)
8807 "castsource, casttarget, castfunc, castcontext, "
8810 "WHERE NOT EXISTS ( "
8811 "SELECT 1 FROM pg_range r "
8812 "WHERE c.castsource = r.rngtypid "
8813 "AND c.casttarget = r.rngmultitypid "
8820 "castsource, casttarget, castfunc, castcontext, "
8822 "FROM pg_cast ORDER BY 3,4");
8831 i_tableoid =
PQfnumber(res,
"tableoid");
8833 i_castsource =
PQfnumber(res,
"castsource");
8834 i_casttarget =
PQfnumber(res,
"casttarget");
8835 i_castfunc =
PQfnumber(res,
"castfunc");
8836 i_castcontext =
PQfnumber(res,
"castcontext");
8837 i_castmethod =
PQfnumber(res,
"castmethod");
8839 for (
i = 0;
i < ntups;
i++)
8863 if (sTypeInfo && tTypeInfo)
8885 appendPQExpBuffer(query,
"SELECT lanname FROM pg_language WHERE oid = %u", langid);
8920 "trftype, trflang, trffromsql::oid, trftosql::oid "
8921 "FROM pg_transform "
8930 i_tableoid =
PQfnumber(res,
"tableoid");
8934 i_trffromsql =
PQfnumber(res,
"trffromsql");
8935 i_trftosql =
PQfnumber(res,
"trftosql");
8937 for (
i = 0;
i < ntups;
i++)
8960 if (typeInfo && lanname)
8997 int i_attstattarget;
9007 int i_notnull_noinherit;
9008 int i_notnull_islocal;
9009 int i_notnull_invalidoid;
9012 int i_attcompression;
9013 int i_attfdwoptions;
9014 int i_attmissingval;
9029 for (
int i = 0;
i < numTables;
i++)
9034 if (tbinfo->
relkind == RELKIND_SEQUENCE)
9042 if (tbloids->
len > 1)
9049 if (checkoids->
len > 1)
9069 "a.attstattarget,\n"
9077 "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n"
9078 "array_to_string(a.attoptions, ', ') AS attoptions,\n"
9079 "CASE WHEN a.attcollation <> t.typcollation "
9080 "THEN a.attcollation ELSE 0 END AS attcollation,\n"
9081 "pg_catalog.array_to_string(ARRAY("
9082 "SELECT pg_catalog.quote_ident(option_name) || "
9083 "' ' || pg_catalog.quote_literal(option_value) "
9084 "FROM pg_catalog.pg_options_to_table(attfdwoptions) "
9085 "ORDER BY option_name"
9086 "), E',\n ') AS attfdwoptions,\n");
9107 "co.conname AS notnull_name,\n"
9108 "CASE WHEN NOT co.convalidated THEN co.oid "
9109 "ELSE NULL END AS notnull_invalidoid,\n"
9110 "co.connoinherit AS notnull_noinherit,\n"
9111 "co.conislocal AS notnull_islocal,\n");
9114 "CASE WHEN a.attnotnull THEN '' ELSE NULL END AS notnull_name,\n"
9115 "NULL AS notnull_invalidoid,\n"
9116 "false AS notnull_noinherit,\n"
9117 "a.attislocal AS notnull_islocal,\n");
9121 "a.attcompression AS attcompression,\n");
9124 "'' AS attcompression,\n");
9128 "a.attidentity,\n");
9131 "'' AS attidentity,\n");
9135 "CASE WHEN a.atthasmissing AND NOT a.attisdropped "
9136 "THEN a.attmissingval ELSE null END AS attmissingval,\n");
9139 "NULL AS attmissingval,\n");
9143 "a.attgenerated\n");
9146 "'' AS attgenerated\n");
9150 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9151 "JOIN pg_catalog.pg_attribute a ON (src.tbloid = a.attrelid) "
9152 "LEFT JOIN pg_catalog.pg_type t "
9153 "ON (a.atttypid = t.oid)\n",
9163 " LEFT JOIN pg_catalog.pg_constraint co ON "
9164 "(a.attrelid = co.conrelid\n"
9165 " AND co.contype = 'n' AND "
9166 "co.conkey = array[a.attnum])\n");
9169 "WHERE a.attnum > 0::pg_catalog.int2\n"
9170 "ORDER BY a.attrelid, a.attnum");
9176 i_attrelid =
PQfnumber(res,
"attrelid");
9179 i_atttypname =
PQfnumber(res,
"atttypname");
9180 i_attstattarget =
PQfnumber(res,
"attstattarget");
9181 i_attstorage =
PQfnumber(res,
"attstorage");
9182 i_typstorage =
PQfnumber(res,
"typstorage");
9183 i_attidentity =
PQfnumber(res,
"attidentity");
9184 i_attgenerated =
PQfnumber(res,
"attgenerated");
9185 i_attisdropped =
PQfnumber(res,
"attisdropped");
9187 i_attalign =
PQfnumber(res,
"attalign");
9188 i_attislocal =
PQfnumber(res,
"attislocal");
9189 i_notnull_name =
PQfnumber(res,
"notnull_name");
9190 i_notnull_invalidoid =
PQfnumber(res,
"notnull_invalidoid");
9191 i_notnull_noinherit =
PQfnumber(res,
"notnull_noinherit");
9192 i_notnull_islocal =
PQfnumber(res,
"notnull_islocal");
9193 i_attoptions =
PQfnumber(res,
"attoptions");
9194 i_attcollation =
PQfnumber(res,
"attcollation");
9195 i_attcompression =
PQfnumber(res,
"attcompression");
9196 i_attfdwoptions =
PQfnumber(res,
"attfdwoptions");
9197 i_attmissingval =
PQfnumber(res,
"attmissingval");
9198 i_atthasdef =
PQfnumber(res,
"atthasdef");
9209 for (
int r = 0; r < ntups;)
9217 for (numatts = 1; numatts < ntups - r; numatts++)
9225 while (++curtblindx < numTables)
9227 tbinfo = &tblinfo[curtblindx];
9231 if (curtblindx >= numTables)
9232 pg_fatal(
"unrecognized table OID %u", attrelid);
9234 if (tbinfo->
relkind == RELKIND_SEQUENCE ||
9236 pg_fatal(
"unexpected column data for table \"%s\"",
9262 hasdefaults =
false;
9264 for (
int j = 0;
j < numatts;
j++, r++)
9267 pg_fatal(
"invalid column numbering in table \"%s\"",
9289 i_notnull_invalidoid,
9290 i_notnull_noinherit,
9292 &invalidnotnulloids);
9300 if (
PQgetvalue(res, r, i_atthasdef)[0] ==
't')
9307 if (tbloids->
len > 1)
9314 if (invalidnotnulloids != NULL)
9334 "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc\n"
9335 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9336 "JOIN pg_catalog.pg_attrdef a ON (src.tbloid = a.adrelid)\n"
9337 "ORDER BY a.adrelid, a.adnum",
9346 for (
int j = 0;
j < numDefaults;
j++)
9358 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != adrelid)
9360 while (++curtblindx < numTables)
9362 tbinfo = &tblinfo[curtblindx];
9366 if (curtblindx >= numTables)
9367 pg_fatal(
"unrecognized table OID %u", adrelid);
9370 if (adnum <= 0 || adnum > tbinfo->
numatts)
9371 pg_fatal(
"invalid adnum value %d for table \"%s\"",
9386 attrdefs[
j].
adnum = adnum;
9390 attrdefs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9413 else if (tbinfo->
relkind == RELKIND_VIEW)
9431 if (!attrdefs[
j].separate)
9443 tbinfo->
attrdefs[adnum - 1] = &attrdefs[
j];
9464 pg_log_info(
"finding invalid not null constraints");
9468 "SELECT c.tableoid, c.oid, conrelid, conname, "
9469 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9470 "conislocal, convalidated "
9471 "FROM unnest('%s'::pg_catalog.oid[]) AS src(conoid)\n"
9472 "JOIN pg_catalog.pg_constraint c ON (src.conoid = c.oid)\n"
9473 "ORDER BY c.conrelid, c.conname",
9474 invalidnotnulloids->
data);
9481 i_tableoid =
PQfnumber(res,
"tableoid");
9483 i_conrelid =
PQfnumber(res,
"conrelid");
9486 i_conislocal =
PQfnumber(res,
"conislocal");
9490 for (
int j = 0;
j < numConstrs;)
9497 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9505 while (++curtblindx < numTables)
9507 tbinfo = &tblinfo[curtblindx];
9511 if (curtblindx >= numTables)
9512 pg_fatal(
"unrecognized table OID %u", conrelid);
9514 for (
int c = 0;
c < numcons;
c++,
j++)
9521 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9566 "SELECT c.tableoid, c.oid, conrelid, conname, "
9567 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9568 "conislocal, convalidated "
9569 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9570 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
9571 "WHERE contype = 'c' "
9572 "ORDER BY c.conrelid, c.conname",
9580 i_tableoid =
PQfnumber(res,
"tableoid");
9582 i_conrelid =
PQfnumber(res,
"conrelid");
9585 i_conislocal =
PQfnumber(res,
"conislocal");
9586 i_convalidated =
PQfnumber(res,
"convalidated");
9590 for (
int j = 0;
j < numConstrs;)
9597 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9605 while (++curtblindx < numTables)
9607 tbinfo = &tblinfo[curtblindx];
9611 if (curtblindx >= numTables)
9612 pg_fatal(
"unrecognized table OID %u", conrelid);
9614 if (numcons != tbinfo->
ncheck)
9617 "expected %d check constraints on table \"%s\" but found %d",
9626 for (
int c = 0;
c < numcons;
c++,
j++)
9628 bool validated =
PQgetvalue(res,
j, i_convalidated)[0] ==
't';
9635 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9664 if (!constrs[
j].separate)
9733 int i_notnull_invalidoid,
9734 int i_notnull_noinherit,
9735 int i_notnull_islocal,
9751 char *constroid =
PQgetvalue(res, r, i_notnull_invalidoid);
9753 if (*invalidnotnulloids == NULL)
9822 if (strcmp(default_name,
9894 "prsstart::oid, prstoken::oid, "
9895 "prsend::oid, prsheadline::oid, prslextype::oid "
9896 "FROM pg_ts_parser");
9904 i_tableoid =
PQfnumber(res,
"tableoid");
9907 i_prsnamespace =
PQfnumber(res,
"prsnamespace");
9908 i_prsstart =
PQfnumber(res,
"prsstart");
9909 i_prstoken =
PQfnumber(res,
"prstoken");
9911 i_prsheadline =
PQfnumber(res,
"prsheadline");
9912 i_prslextype =
PQfnumber(res,
"prslextype");
9914 for (
i = 0;
i < ntups;
i++)
9921 prsinfo[
i].
dobj.namespace =
9953 int i_dictnamespace;
9956 int i_dictinitoption;
9961 "dictnamespace, dictowner, "
9962 "dicttemplate, dictinitoption "
9971 i_tableoid =
PQfnumber(res,
"tableoid");
9973 i_dictname =
PQfnumber(res,
"dictname");
9974 i_dictnamespace =
PQfnumber(res,
"dictnamespace");
9975 i_dictowner =
PQfnumber(res,
"dictowner");
9976 i_dictinitoption =
PQfnumber(res,
"dictinitoption");
9977 i_dicttemplate =
PQfnumber(res,
"dicttemplate");
9979 for (
i = 0;
i < ntups;
i++)
9986 dictinfo[
i].
dobj.namespace =
10019 int i_tmplnamespace;
10026 "tmplnamespace, tmplinit::oid, tmpllexize::oid "
10027 "FROM pg_ts_template");
10035 i_tableoid =
PQfnumber(res,
"tableoid");
10037 i_tmplname =
PQfnumber(res,
"tmplname");
10038 i_tmplnamespace =
PQfnumber(res,
"tmplnamespace");
10039 i_tmplinit =
PQfnumber(res,
"tmplinit");
10040 i_tmpllexize =
PQfnumber(res,
"tmpllexize");
10042 for (
i = 0;
i < ntups;
i++)
10049 tmplinfo[
i].
dobj.namespace =
10078 int i_cfgnamespace;
10085 "cfgnamespace, cfgowner, cfgparser "
10086 "FROM pg_ts_config");
10094 i_tableoid =
PQfnumber(res,
"tableoid");
10097 i_cfgnamespace =
PQfnumber(res,
"cfgnamespace");
10098 i_cfgowner =
PQfnumber(res,
"cfgowner");
10099 i_cfgparser =
PQfnumber(res,
"cfgparser");
10101 for (
i = 0;
i < ntups;
i++)
10108 cfginfo[
i].
dobj.namespace =
10139 int i_fdwvalidator;
10148 "fdwhandler::pg_catalog.regproc, "
10149 "fdwvalidator::pg_catalog.regproc, "
10151 "acldefault('F', fdwowner) AS acldefault, "
10152 "array_to_string(ARRAY("
10153 "SELECT quote_ident(option_name) || ' ' || "
10154 "quote_literal(option_value) "
10155 "FROM pg_options_to_table(fdwoptions) "
10156 "ORDER BY option_name"
10157 "), E',\n ') AS fdwoptions "
10158 "FROM pg_foreign_data_wrapper");
10166 i_tableoid =
PQfnumber(res,
"tableoid");
10169 i_fdwowner =
PQfnumber(res,
"fdwowner");
10170 i_fdwhandler =
PQfnumber(res,
"fdwhandler");
10171 i_fdwvalidator =
PQfnumber(res,
"fdwvalidator");
10173 i_acldefault =
PQfnumber(res,
"acldefault");
10174 i_fdwoptions =
PQfnumber(res,
"fdwoptions");
10176 for (
i = 0;
i < ntups;
i++)
10183 fdwinfo[
i].
dobj.namespace = NULL;
10233 "srvfdw, srvtype, srvversion, srvacl, "
10234 "acldefault('S', srvowner) AS acldefault, "
10235 "array_to_string(ARRAY("
10236 "SELECT quote_ident(option_name) || ' ' || "
10237 "quote_literal(option_value) "
10238 "FROM pg_options_to_table(srvoptions) "
10239 "ORDER BY option_name"
10240 "), E',\n ') AS srvoptions "
10241 "FROM pg_foreign_server");
10249 i_tableoid =
PQfnumber(res,
"tableoid");
10252 i_srvowner =
PQfnumber(res,
"srvowner");
10255 i_srvversion =
PQfnumber(res,
"srvversion");
10257 i_acldefault =
PQfnumber(res,
"acldefault");
10258 i_srvoptions =
PQfnumber(res,
"srvoptions");
10260 for (
i = 0;
i < ntups;
i++)
10267 srvinfo[
i].
dobj.namespace = NULL;
10308 int i_defaclnamespace;
10309 int i_defaclobjtype;
10330 "SELECT oid, tableoid, "
10332 "defaclnamespace, "
10335 "CASE WHEN defaclnamespace = 0 THEN "
10336 "acldefault(CASE WHEN defaclobjtype = 'S' "
10337 "THEN 's'::\"char\" ELSE defaclobjtype END, "
10338 "defaclrole) ELSE '{}' END AS acldefault "
10339 "FROM pg_default_acl");
10348 i_tableoid =
PQfnumber(res,
"tableoid");
10349 i_defaclrole =
PQfnumber(res,
"defaclrole");
10350 i_defaclnamespace =
PQfnumber(res,
"defaclnamespace");
10351 i_defaclobjtype =
PQfnumber(res,
"defaclobjtype");
10352 i_defaclacl =
PQfnumber(res,
"defaclacl");
10353 i_acldefault =
PQfnumber(res,
"acldefault");
10355 for (
i = 0;
i < ntups;
i++)
10369 daclinfo[
i].
dobj.namespace = NULL;
10408 while (low <= high)
10412 if (roleoid < middle->roleoid)
10414 else if (roleoid > middle->
roleoid)
10421 pg_fatal(
"role with OID %u does not exist", roleoid);
10438 query =
"SELECT oid, rolname FROM pg_catalog.pg_roles ORDER BY 1";
10476 "SELECT DISTINCT attrelid FROM pg_attribute "
10477 "WHERE attacl IS NOT NULL");
10482 for (
i = 0;
i < ntups;
i++)
10501 "SELECT objoid, classoid, objsubid, privtype, initprivs "
10502 "FROM pg_init_privs");
10507 for (
i = 0;
i < ntups;
i++)
10518 objId.
oid = objoid;
10530 ((
TableInfo *) dobj)->hascolumnACLs =
true;
10534 classoid, objoid, objsubid);
10543 strcmp(dobj->
name,
"public") == 0)
10563 classoid, objoid, objsubid);
10597 const char *
name,
const char *
namespace,
10598 const char *owner,
CatalogId catalogId,
10599 int subid,
DumpId dumpId,
10600 const char *initdb_comment)
10611 if (strcmp(
type,
"LARGE OBJECT") != 0)
10636 if (initdb_comment != NULL)
10662 if (
namespace && *
namespace)
10677 .namespace =
namespace,
10679 .description =
"COMMENT",
10681 .createStmt = query->
data,
10697 const char *
name,
const char *
namespace,
10698 const char *owner,
CatalogId catalogId,
10699 int subid,
DumpId dumpId)
10702 catalogId, subid, dumpId, NULL);
10713 const char *argtype,
const char *argval)
10738 static bool restarted;
10774 for (; te != AH->
toc && count < max_rels; te = te->
next)
10777 strcmp(te->
desc,
"STATISTICS DATA") == 0)
10780 fmtId(te->namespace));
10793 "'{%s}'::pg_catalog.name[],"
10794 "'{%s}'::pg_catalog.name[])",
10828 int i_most_common_vals;
10829 int i_most_common_freqs;
10830 int i_histogram_bounds;
10832 int i_most_common_elems;
10833 int i_most_common_elem_freqs;
10834 int i_elem_count_histogram;
10835 int i_range_length_histogram;
10836 int i_range_empty_frac;
10837 int i_range_bounds_histogram;
10847 expected_te = expected_te->
next;
10849 strcmp(expected_te->
desc,
"STATISTICS DATA") != 0)
10850 expected_te = expected_te->
next;
10852 if (te != expected_te)
10853 pg_fatal(
"stats dumped out of order (current: %d %s %s) (expected: %d %s %s)",
10861 "PREPARE getAttributeStats(pg_catalog.name[], pg_catalog.name[]) AS\n"
10862 "SELECT s.schemaname, s.tablename, s.attname, s.inherited, "
10863 "s.null_frac, s.avg_width, s.n_distinct, "
10864 "s.most_common_vals, s.most_common_freqs, "
10865 "s.histogram_bounds, s.correlation, "
10866 "s.most_common_elems, s.most_common_elem_freqs, "
10867 "s.elem_count_histogram, ");
10871 "s.range_length_histogram, "
10872 "s.range_empty_frac, "
10873 "s.range_bounds_histogram ");
10876 "NULL AS range_length_histogram,"
10877 "NULL AS range_empty_frac,"
10878 "NULL AS range_bounds_histogram ");
10895 "FROM pg_catalog.pg_stats s "
10896 "JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
10897 "ON s.schemaname = u.schemaname "
10898 "AND s.tablename = u.tablename "
10899 "WHERE s.tablename = ANY($2) "
10900 "ORDER BY u.ord, s.attname, s.inherited");
10903 "FROM pg_catalog.pg_stats s "
10904 "WHERE s.schemaname = $1[1] "
10905 "AND s.tablename = $2[1] "
10906 "ORDER BY s.attname, s.inherited");
10944 i_schemaname =
PQfnumber(res,
"schemaname");
10945 i_tablename =
PQfnumber(res,
"tablename");
10947 i_inherited =
PQfnumber(res,
"inherited");
10948 i_null_frac =
PQfnumber(res,
"null_frac");
10949 i_avg_width =
PQfnumber(res,
"avg_width");
10950 i_n_distinct =
PQfnumber(res,
"n_distinct");
10951 i_most_common_vals =
PQfnumber(res,
"most_common_vals");
10952 i_most_common_freqs =
PQfnumber(res,
"most_common_freqs");
10953 i_histogram_bounds =
PQfnumber(res,
"histogram_bounds");
10954 i_correlation =
PQfnumber(res,
"correlation");
10955 i_most_common_elems =
PQfnumber(res,
"most_common_elems");
10956 i_most_common_elem_freqs =
PQfnumber(res,
"most_common_elem_freqs");
10957 i_elem_count_histogram =
PQfnumber(res,
"elem_count_histogram");
10958 i_range_length_histogram =
PQfnumber(res,
"range_length_histogram");
10959 i_range_empty_frac =
PQfnumber(res,
"range_empty_frac");
10960 i_range_bounds_histogram =
PQfnumber(res,
"range_bounds_histogram");
10963 for (; rownum <
PQntuples(res); rownum++)
10968 if (strcmp(te->
tag,
PQgetvalue(res, rownum, i_tablename)) != 0 ||
10969 strcmp(te->namespace,
PQgetvalue(res, rownum, i_schemaname)) != 0)
10981 pg_fatal(
"attname cannot be NULL");
10996 bool found =
false;
11025 if (!
PQgetisnull(res, rownum, i_most_common_vals))
11027 PQgetvalue(res, rownum, i_most_common_vals));
11028 if (!
PQgetisnull(res, rownum, i_most_common_freqs))
11030 PQgetvalue(res, rownum, i_most_common_freqs));
11031 if (!
PQgetisnull(res, rownum, i_histogram_bounds))
11033 PQgetvalue(res, rownum, i_histogram_bounds));
11037 if (!
PQgetisnull(res, rownum, i_most_common_elems))
11039 PQgetvalue(res, rownum, i_most_common_elems));
11040 if (!
PQgetisnull(res, rownum, i_most_common_elem_freqs))
11042 PQgetvalue(res, rownum, i_most_common_elem_freqs));
11043 if (!
PQgetisnull(res, rownum, i_elem_count_histogram))
11045 PQgetvalue(res, rownum, i_elem_count_histogram));
11048 if (!
PQgetisnull(res, rownum, i_range_length_histogram))
11050 PQgetvalue(res, rownum, i_range_length_histogram));
11051 if (!
PQgetisnull(res, rownum, i_range_empty_frac))
11053 PQgetvalue(res, rownum, i_range_empty_frac));
11054 if (!
PQgetisnull(res, rownum, i_range_bounds_histogram))
11056 PQgetvalue(res, rownum, i_range_bounds_histogram));
11083 .namespace = dobj->namespace->dobj.
name,
11084 .description =
"STATISTICS DATA",
11089 .nDeps = dobj->
nDeps));
11100 const char *reltypename)
11147 .namespace = tbinfo->
dobj.namespace->dobj.
name,
11149 .description =
"COMMENT",
11151 .createStmt = query->
data,
11155 else if (objsubid > 0 && objsubid <= tbinfo->numatts)
11172 .namespace = tbinfo->
dobj.namespace->dobj.
name,
11174 .description =
"COMMENT",
11176 .createStmt = query->
data,
11209 while (low <= high)
11211 middle = low + (high - low) / 2;
11213 if (classoid < middle->classoid)
11215 else if (classoid > middle->
classoid)
11217 else if (objoid < middle->objoid)
11219 else if (objoid > middle->
objoid)
11237 while (middle > low)
11239 if (classoid != middle[-1].classoid ||
11240 objoid != middle[-1].objoid)
11249 while (middle <= high)
11251 if (classoid != middle->
classoid ||
11252 objoid != middle->
objoid)
11289 "FROM pg_catalog.pg_description "
11290 "ORDER BY classoid, objoid, objsubid");
11296 i_description =
PQfnumber(res,
"description");
11297 i_classoid =
PQfnumber(res,
"classoid");
11299 i_objsubid =
PQfnumber(res,
"objsubid");
11307 for (
i = 0;
i < ntups;
i++)
11317 if (dobj == NULL ||
11330 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
11369 if (dobj->
dump == 0)
11495 if (loinfo == NULL)
11496 pg_fatal(
"missing metadata for large objects \"%s\"",
11502 .description =
"BLOBS",
11504 .deps = dobj->dependencies,
11505 .nDeps = dobj->nDeps,
11507 .dumpArg = loinfo));
11580 "-- *not* dropping schema, since initdb creates it\n");
11582 "-- *not* creating schema, since initdb creates it\n");
11587 "SCHEMA", qnspname, NULL);
11593 .description =
"SCHEMA",
11595 .createStmt = q->
data,
11596 .dropStmt = delq->
data));
11601 const char *initdb_comment = NULL;
11603 if (!nspinfo->
create && strcmp(qnspname,
"public") == 0)
11604 initdb_comment =
"standard public schema";
11618 qnspname, NULL, NULL,
11663 qextname,
fmtId(extinfo->namespace));
11678 appendPQExpBufferStr(q,
"-- For binary upgrade, create an empty extension and insert objects into it\n");
11688 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
11733 .description =
"EXTENSION",
11735 .createStmt = q->
data,
11736 .dropStmt = delq->
data));
11769 if (tyinfo->
typtype == TYPTYPE_BASE)
11771 else if (tyinfo->
typtype == TYPTYPE_DOMAIN)
11773 else if (tyinfo->
typtype == TYPTYPE_COMPOSITE)
11775 else if (tyinfo->
typtype == TYPTYPE_ENUM)
11777 else if (tyinfo->
typtype == TYPTYPE_RANGE)
11782 pg_log_warning(
"typtype of data type \"%s\" appears to be invalid",
11811 "PREPARE dumpEnumType(pg_catalog.oid) AS\n"
11812 "SELECT oid, enumlabel "
11813 "FROM pg_catalog.pg_enum "
11814 "WHERE enumtypid = $1 "
11815 "ORDER BY enumsortorder");
11823 "EXECUTE dumpEnumType('%u')",
11849 i_enumlabel =
PQfnumber(res,
"enumlabel");
11852 for (
i = 0;
i < num;
i++)
11867 i_enumlabel =
PQfnumber(res,
"enumlabel");
11870 for (
i = 0;
i < num;
i++)
11878 "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
11889 tyinfo->
dobj.namespace->dobj.
name);
11894 .namespace = tyinfo->
dobj.namespace->dobj.
name,
11896 .description =
"TYPE",
11898 .createStmt = q->
data,
11899 .dropStmt = delq->
data));
11915 tyinfo->
dobj.namespace->dobj.
name,
11947 "PREPARE dumpRangeType(pg_catalog.oid) AS\n");
11954 "pg_catalog.format_type(rngmultitypid, NULL) AS rngmultitype, ");
11957 "NULL AS rngmultitype, ");
11960 "pg_catalog.format_type(rngsubtype, NULL) AS rngsubtype, "
11961 "opc.opcname AS opcname, "
11962 "(SELECT nspname FROM pg_catalog.pg_namespace nsp "
11963 " WHERE nsp.oid = opc.opcnamespace) AS opcnsp, "
11965 "CASE WHEN rngcollation = st.typcollation THEN 0 "
11966 " ELSE rngcollation END AS collation, "
11967 "rngcanonical, rngsubdiff "
11968 "FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
11969 " pg_catalog.pg_opclass opc "
11970 "WHERE st.oid = rngsubtype AND opc.oid = rngsubopc AND "
11979 "EXECUTE dumpRangeType('%u')",
12030 if (strcmp(procname,
"-") != 0)
12034 if (strcmp(procname,
"-") != 0)
12042 tyinfo->
dobj.namespace->dobj.
name);
12047 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12049 .description =
"TYPE",
12051 .createStmt = q->
data,
12052 .dropStmt = delq->
data));
12068 tyinfo->
dobj.namespace->dobj.
name,
12113 tyinfo->
dobj.namespace->dobj.
name);
12118 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12120 .description =
"TYPE",
12122 .createStmt = q->
data,
12123 .dropStmt = delq->
data));
12139 tyinfo->
dobj.namespace->dobj.
name,
12170 char *typsubscript;
12176 Oid typsubscriptoid;
12178 char *typispreferred;
12183 char *typcollatable;
12185 bool typdefault_is_literal =
false;
12191 "PREPARE dumpBaseType(pg_catalog.oid) AS\n"
12193 "typinput, typoutput, typreceive, typsend, "
12194 "typreceive::pg_catalog.oid AS typreceiveoid, "
12195 "typsend::pg_catalog.oid AS typsendoid, "
12197 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
12198 "typdelim, typbyval, typalign, typstorage, "
12199 "typmodin, typmodout, "
12200 "typmodin::pg_catalog.oid AS typmodinoid, "
12201 "typmodout::pg_catalog.oid AS typmodoutoid, "
12202 "typcategory, typispreferred, "
12203 "(typcollation <> 0) AS typcollatable, "
12204 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault, ");
12209 "typsubscript::pg_catalog.oid AS typsubscriptoid ");
12212 "'-' AS typsubscript, 0 AS typsubscriptoid ");
12223 "EXECUTE dumpBaseType('%u')",
12255 typdefault_is_literal =
true;
12280 "CREATE TYPE %s (\n"
12281 " INTERNALLENGTH = %s",
12283 (strcmp(typlen,
"-1") == 0) ?
"variable" : typlen);
12299 if (strcmp(typcollatable,
"t") == 0)
12302 if (typdefault != NULL)
12305 if (typdefault_is_literal)
12319 if (strcmp(typcategory,
"U") != 0)
12325 if (strcmp(typispreferred,
"t") == 0)
12328 if (typdelim && strcmp(typdelim,
",") != 0)
12336 else if (*
typalign == TYPALIGN_SHORT)
12338 else if (*
typalign == TYPALIGN_INT)
12340 else if (*
typalign == TYPALIGN_DOUBLE)
12343 if (*typstorage == TYPSTORAGE_PLAIN)
12345 else if (*typstorage == TYPSTORAGE_EXTERNAL)
12347 else if (*typstorage == TYPSTORAGE_EXTENDED)
12349 else if (*typstorage == TYPSTORAGE_MAIN)
12352 if (strcmp(typbyval,
"t") == 0)
12360 tyinfo->
dobj.namespace->dobj.
name);
12365 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12367 .description =
"TYPE",
12369 .createStmt = q->
data,
12370 .dropStmt = delq->
data));
12386 tyinfo->
dobj.namespace->dobj.
name,
12416 bool typdefault_is_literal =
false;
12422 "PREPARE dumpDomain(pg_catalog.oid) AS\n");
12425 "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
12426 "pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
12428 "CASE WHEN t.typcollation <> u.typcollation "
12429 "THEN t.typcollation ELSE 0 END AS typcollation "
12430 "FROM pg_catalog.pg_type t "
12431 "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
12432 "WHERE t.oid = $1");
12440 "EXECUTE dumpDomain('%u')",
12452 typdefault_is_literal =
true;
12468 "CREATE DOMAIN %s AS %s",
12482 if (typnotnull[0] ==
't')
12485 if (typdefault != NULL)
12488 if (typdefault_is_literal)
12514 "DOMAIN", qtypname,
12515 tyinfo->
dobj.namespace->dobj.
name);
12520 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12522 .description =
"DOMAIN",
12524 .createStmt = q->
data,
12525 .dropStmt = delq->
data));
12541 tyinfo->
dobj.namespace->dobj.
name,
12555 tyinfo->
dobj.namespace->dobj.
name,
12590 int i_attisdropped;
12591 int i_attcollation;
12606 "PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
12607 "SELECT a.attname, a.attnum, "
12608 "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
12609 "a.attlen, a.attalign, a.attisdropped, "
12610 "CASE WHEN a.attcollation <> at.typcollation "
12611 "THEN a.attcollation ELSE 0 END AS attcollation "
12612 "FROM pg_catalog.pg_type ct "
12613 "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
12614 "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
12615 "WHERE ct.oid = $1 "
12616 "ORDER BY a.attnum");
12624 "EXECUTE dumpCompositeType('%u')",
12632 i_atttypdefn =
PQfnumber(res,
"atttypdefn");
12634 i_attalign =
PQfnumber(res,
"attalign");
12635 i_attisdropped =
PQfnumber(res,
"attisdropped");
12636 i_attcollation =
PQfnumber(res,
"attcollation");
12653 for (
i = 0;
i < ntups;
i++)
12666 attisdropped = (
PQgetvalue(res,
i, i_attisdropped)[0] ==
't');
12673 if (actual_atts++ > 0)
12704 "\n-- For binary upgrade, recreate dropped column.\n");
12706 "SET attlen = %s, "
12707 "attalign = '%s', attbyval = false\n"
12728 tyinfo->
dobj.namespace->dobj.
name);
12733 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12735 .description =
"TYPE",
12737 .createStmt = q->
data,
12738 .dropStmt = delq->
data));
12755 tyinfo->
dobj.namespace->dobj.
name,
12792 int i_attisdropped;
12813 i_attisdropped =
PQfnumber(res,
"attisdropped");
12819 for (
i = 0;
i < ntups;
i++)
12846 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12848 .description =
"COMMENT",
12850 .createStmt = query->
data,
12901 .namespace = stinfo->
dobj.namespace->dobj.
name,
12903 .description =
"SHELL TYPE",
12905 .createStmt = q->
data));
12940 if (funcInfo != NULL && !funcInfo->
dobj.
dump)
12946 if (inlineInfo != NULL && !inlineInfo->
dobj.
dump)
12953 if (validatorInfo != NULL && !validatorInfo->
dobj.
dump)
12954 validatorInfo = NULL;
12962 useParams = (funcInfo != NULL &&
13006 "LANGUAGE", qlanname, NULL);
13012 .description =
"PROCEDURAL LANGUAGE",
13014 .createStmt = defqry->
data,
13015 .dropStmt = delqry->
data,
13031 qlanname, NULL, NULL,
13054 if (is_agg && finfo->
nargs == 0)
13081 for (
j = 0;
j < finfo->
nargs;
j++)
13109 char *funcfullsig = NULL;
13111 char *qual_funcsig;
13124 char *proleakproof;
13131 char **configitems = NULL;
13132 int nconfigitems = 0;
13133 const char *keyword;
13148 "PREPARE dumpFunc(pg_catalog.oid) AS\n");
13162 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
13163 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
13164 "pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
13165 "proleakproof,\n");
13169 "array_to_string(protrftypes, ' ') AS protrftypes,\n");
13172 "NULL AS protrftypes,\n");
13179 "'u' AS proparallel,\n");
13186 "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n");
13193 "'-' AS prosupport,\n");
13197 "pg_get_function_sqlbody(p.oid) AS prosqlbody\n");
13200 "NULL AS prosqlbody\n");
13203 "FROM pg_catalog.pg_proc p, pg_catalog.pg_language l\n"
13204 "WHERE p.oid = $1 "
13205 "AND l.oid = p.prolang");
13213 "EXECUTE dumpFunc('%u')",
13255 else if (probin[0] !=
'\0')
13259 if (prosrc[0] !=
'\0')
13268 (strchr(prosrc,
'\'') == NULL && strchr(prosrc,
'\\') == NULL))
13286 if (!
parsePGArray(proconfig, &configitems, &nconfigitems))
13287 pg_fatal(
"could not parse %s array",
"proconfig");
13291 configitems = NULL;
13304 if (prokind[0] == PROKIND_PROCEDURE)
13305 keyword =
"PROCEDURE";
13307 keyword =
"FUNCTION";
13310 keyword, qual_funcsig);
13315 funcfullsig ? funcfullsig :
13318 if (prokind[0] == PROKIND_PROCEDURE)
13320 else if (funcresult)
13324 (proretset[0] ==
't') ?
"SETOF " :
"",
13337 for (
i = 0; typeids[
i];
i++)
13348 if (prokind[0] == PROKIND_WINDOW)
13351 if (provolatile[0] != PROVOLATILE_VOLATILE)
13353 if (provolatile[0] == PROVOLATILE_IMMUTABLE)
13355 else if (provolatile[0] == PROVOLATILE_STABLE)
13357 else if (provolatile[0] != PROVOLATILE_VOLATILE)
13358 pg_fatal(
"unrecognized provolatile value for function \"%s\"",
13362 if (proisstrict[0] ==
't')
13365 if (prosecdef[0] ==
't')
13368 if (proleakproof[0] ==
't')
13376 if (strcmp(procost,
"0") != 0)
13378 if (strcmp(lanname,
"internal") == 0 || strcmp(lanname,
"c") == 0)
13381 if (strcmp(procost,
"1") != 0)
13387 if (strcmp(procost,
"100") != 0)
13391 if (proretset[0] ==
't' &&
13392 strcmp(prorows,
"0") != 0 && strcmp(prorows,
"1000") != 0)
13395 if (strcmp(prosupport,
"-") != 0)
13401 if (proparallel[0] != PROPARALLEL_UNSAFE)
13403 if (proparallel[0] == PROPARALLEL_SAFE)
13405 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
13407 else if (proparallel[0] != PROPARALLEL_UNSAFE)
13408 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
13412 for (
int i = 0;
i < nconfigitems;
i++)
13415 char *configitem = configitems[
i];
13418 pos = strchr(configitem,
'=');
13448 for (nameptr = namelist; *nameptr; nameptr++)
13450 if (nameptr != namelist)
13464 "pg_catalog.pg_proc", keyword,
13470 finfo->
dobj.namespace->dobj.
name);
13475 .
namespace = finfo->
dobj.namespace->dobj.
name,
13477 .description = keyword,
13480 .createStmt = q->
data,
13481 .dropStmt = delqry->
data));
13509 free(qual_funcsig);
13526 const char *sourceType;
13527 const char *targetType;
13537 if (funcInfo == NULL)
13538 pg_fatal(
"could not find function definition for function with OID %u",
13550 sourceType, targetType);
13553 sourceType, targetType);
13557 case COERCION_METHOD_BINARY:
13560 case COERCION_METHOD_INOUT:
13563 case COERCION_METHOD_FUNCTION:
13577 pg_log_warning(
"bogus value in pg_cast.castfunc or pg_cast.castmethod field");
13590 sourceType, targetType);
13593 sourceType, targetType);
13597 "CAST", castargs->
data, NULL);
13602 .description =
"CAST",
13604 .createStmt = defqry->
data,
13605 .dropStmt = delqry->
data));
13633 const char *transformType;
13643 if (fromsqlFuncInfo == NULL)
13644 pg_fatal(
"could not find function definition for function with OID %u",
13650 if (tosqlFuncInfo == NULL)
13651 pg_fatal(
"could not find function definition for function with OID %u",
13664 transformType, lanname);
13667 transformType, lanname);
13670 pg_log_warning(
"bogus transform definition, at least one of trffromsql and trftosql should be nonzero");
13674 if (fromsqlFuncInfo)
13714 transformType, lanname);
13717 transformType, lanname);
13721 "TRANSFORM", transformargs->
data, NULL);
13726 .description =
"TRANSFORM",
13728 .createStmt = defqry->
data,
13729 .dropStmt = delqry->
data,
13805 "PREPARE dumpOpr(pg_catalog.oid) AS\n"
13807 "oprcode::pg_catalog.regprocedure, "
13808 "oprleft::pg_catalog.regtype, "
13809 "oprright::pg_catalog.regtype, "
13812 "oprrest::pg_catalog.regprocedure, "
13813 "oprjoin::pg_catalog.regprocedure, "
13814 "oprcanmerge, oprcanhash "
13815 "FROM pg_catalog.pg_operator "
13824 "EXECUTE dumpOpr('%u')",
13832 i_oprright =
PQfnumber(res,
"oprright");
13834 i_oprnegate =
PQfnumber(res,
"oprnegate");
13837 i_oprcanmerge =
PQfnumber(res,
"oprcanmerge");
13838 i_oprcanhash =
PQfnumber(res,
"oprcanhash");
13845 oprnegate =
PQgetvalue(res, 0, i_oprnegate);
13848 oprcanmerge =
PQgetvalue(res, 0, i_oprcanmerge);
13849 oprcanhash =
PQgetvalue(res, 0, i_oprcanhash);
13852 if (strcmp(oprkind,
"r") == 0)
13853 pg_log_warning(
"postfix operators are not supported anymore (operator \"%s\")",
13871 if (strcmp(oprkind,
"r") == 0 ||
13872 strcmp(oprkind,
"b") == 0)
13880 if (strcmp(oprkind,
"l") == 0 ||
13881 strcmp(oprkind,
"b") == 0)
13903 if (strcmp(oprcanmerge,
"t") == 0)
13906 if (strcmp(oprcanhash,
"t") == 0)
13933 "OPERATOR",
oprid->data,
13934 oprinfo->
dobj.namespace->dobj.
name);
13939 .namespace = oprinfo->
dobj.namespace->dobj.
name,
13941 .description =
"OPERATOR",
13943 .createStmt = q->
data,
13944 .dropStmt = delq->
data));
13978 if (strcmp(proc,
"-") == 0)
13984 for (paren =
name; *paren; paren++)
13986 if (*paren ==
'(' && !inquote)
13992 inquote = !inquote;
14017 if (strcmp(oproid,
"0") == 0)
14021 if (oprInfo == NULL)
14028 return psprintf(
"OPERATOR(%s.%s)",
14049 "SELECT '%u'::pg_catalog.regproc", funcOid);
14092 aminfo->
amtype, qamname);
14106 "ACCESS METHOD", qamname, NULL);
14111 .description =
"ACCESS METHOD",
14113 .createStmt = q->
data,
14114 .dropStmt = delq->
data));
14145 int i_opcfamilyname;
14146 int i_opcfamilynsp;
14148 int i_amopstrategy;
14151 int i_sortfamilynsp;
14154 int i_amproclefttype;
14155 int i_amprocrighttype;
14160 char *opcfamilyname;
14161 char *opcfamilynsp;
14163 char *amopstrategy;
14166 char *sortfamilynsp;
14169 char *amproclefttype;
14170 char *amprocrighttype;
14185 "opckeytype::pg_catalog.regtype, "
14186 "opcdefault, opcfamily, "
14187 "opfname AS opcfamilyname, "
14188 "nspname AS opcfamilynsp, "
14189 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS amname "
14190 "FROM pg_catalog.pg_opclass c "
14191 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily "
14192 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14193 "WHERE c.oid = '%u'::pg_catalog.oid",
14198 i_opcintype =
PQfnumber(res,
"opcintype");
14199 i_opckeytype =
PQfnumber(res,
"opckeytype");
14200 i_opcdefault =
PQfnumber(res,
"opcdefault");
14201 i_opcfamily =
PQfnumber(res,
"opcfamily");
14202 i_opcfamilyname =
PQfnumber(res,
"opcfamilyname");
14203 i_opcfamilynsp =
PQfnumber(res,
"opcfamilynsp");
14208 opckeytype =
PQgetvalue(res, 0, i_opckeytype);
14209 opcdefault =
PQgetvalue(res, 0, i_opcdefault);
14212 opcfamilyname =
PQgetvalue(res, 0, i_opcfamilyname);
14213 opcfamilynsp =
PQgetvalue(res, 0, i_opcfamilynsp);
14225 if (strcmp(opcdefault,
"t") == 0)
14230 if (strlen(opcfamilyname) > 0)
14240 if (strcmp(opckeytype,
"-") != 0)
14257 "amopopr::pg_catalog.regoperator, "
14258 "opfname AS sortfamily, "
14259 "nspname AS sortfamilynsp "
14260 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14261 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14262 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14263 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14264 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14265 "AND refobjid = '%u'::pg_catalog.oid "
14266 "AND amopfamily = '%s'::pg_catalog.oid "
14267 "ORDER BY amopstrategy",
14275 i_amopstrategy =
PQfnumber(res,
"amopstrategy");
14277 i_sortfamily =
PQfnumber(res,
"sortfamily");
14278 i_sortfamilynsp =
PQfnumber(res,
"sortfamilynsp");
14280 for (
i = 0;
i < ntups;
i++)
14282 amopstrategy =
PQgetvalue(res,
i, i_amopstrategy);
14285 sortfamilynsp =
PQgetvalue(res,
i, i_sortfamilynsp);
14291 amopstrategy, amopopr);
14293 if (strlen(sortfamily) > 0)
14318 "amproc::pg_catalog.regprocedure, "
14319 "amproclefttype::pg_catalog.regtype, "
14320 "amprocrighttype::pg_catalog.regtype "
14321 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14322 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14323 "AND refobjid = '%u'::pg_catalog.oid "
14324 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14325 "AND objid = ap.oid "
14326 "ORDER BY amprocnum",
14333 i_amprocnum =
PQfnumber(res,
"amprocnum");
14335 i_amproclefttype =
PQfnumber(res,
"amproclefttype");
14336 i_amprocrighttype =
PQfnumber(res,
"amprocrighttype");
14338 for (
i = 0;
i < ntups;
i++)
14342 amproclefttype =
PQgetvalue(res,
i, i_amproclefttype);
14343 amprocrighttype =
PQgetvalue(res,
i, i_amprocrighttype);
14350 if (*amproclefttype && *amprocrighttype)
14377 "OPERATOR CLASS", nameusing->
data,
14378 opcinfo->
dobj.namespace->dobj.
name);
14383 .namespace = opcinfo->
dobj.namespace->dobj.
name,
14385 .description =
"OPERATOR CLASS",
14387 .createStmt = q->
data,
14388 .dropStmt = delq->
data));
14425 int i_amopstrategy;
14428 int i_sortfamilynsp;
14431 int i_amproclefttype;
14432 int i_amprocrighttype;
14434 char *amopstrategy;
14437 char *sortfamilynsp;
14440 char *amproclefttype;
14441 char *amprocrighttype;
14459 "amopopr::pg_catalog.regoperator, "
14460 "opfname AS sortfamily, "
14461 "nspname AS sortfamilynsp "
14462 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14463 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14464 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14465 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14466 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14467 "AND refobjid = '%u'::pg_catalog.oid "
14468 "AND amopfamily = '%u'::pg_catalog.oid "
14469 "ORDER BY amopstrategy",
14478 "amproc::pg_catalog.regprocedure, "
14479 "amproclefttype::pg_catalog.regtype, "
14480 "amprocrighttype::pg_catalog.regtype "
14481 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14482 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14483 "AND refobjid = '%u'::pg_catalog.oid "
14484 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14485 "AND objid = ap.oid "
14486 "ORDER BY amprocnum",
14495 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opfmethod) AS amname "
14496 "FROM pg_catalog.pg_opfamily "
14497 "WHERE oid = '%u'::pg_catalog.oid",
14535 i_amopstrategy =
PQfnumber(res_ops,
"amopstrategy");
14536 i_amopopr =
PQfnumber(res_ops,
"amopopr");
14537 i_sortfamily =
PQfnumber(res_ops,
"sortfamily");
14538 i_sortfamilynsp =
PQfnumber(res_ops,
"sortfamilynsp");
14540 for (
i = 0;
i < ntups;
i++)
14542 amopstrategy =
PQgetvalue(res_ops,
i, i_amopstrategy);
14544 sortfamily =
PQgetvalue(res_ops,
i, i_sortfamily);
14545 sortfamilynsp =
PQgetvalue(res_ops,
i, i_sortfamilynsp);
14551 amopstrategy, amopopr);
14553 if (strlen(sortfamily) > 0)
14568 i_amprocnum =
PQfnumber(res_procs,
"amprocnum");
14569 i_amproc =
PQfnumber(res_procs,
"amproc");
14570 i_amproclefttype =
PQfnumber(res_procs,
"amproclefttype");
14571 i_amprocrighttype =
PQfnumber(res_procs,
"amprocrighttype");
14573 for (
i = 0;
i < ntups;
i++)
14575 amprocnum =
PQgetvalue(res_procs,
i, i_amprocnum);
14577 amproclefttype =
PQgetvalue(res_procs,
i, i_amproclefttype);
14578 amprocrighttype =
PQgetvalue(res_procs,
i, i_amprocrighttype);
14584 amprocnum, amproclefttype, amprocrighttype,
14599 "OPERATOR FAMILY", nameusing->
data,
14600 opfinfo->
dobj.namespace->dobj.
name);
14605 .namespace = opfinfo->
dobj.namespace->dobj.
name,
14607 .description =
"OPERATOR FAMILY",
14609 .createStmt = q->
data,
14610 .dropStmt = delq->
data));
14640 int i_collprovider;
14641 int i_collisdeterministic;
14645 int i_collicurules;
14646 const char *collprovider;
14647 const char *collcollate;
14648 const char *collctype;
14649 const char *colllocale;
14650 const char *collicurules;
14671 "'c' AS collprovider, "
14672 "NULL AS collversion, ");
14676 "collisdeterministic, ");
14679 "true AS collisdeterministic, ");
14686 "colliculocale AS colllocale, ");
14689 "NULL AS colllocale, ");
14696 "NULL AS collicurules, ");
14701 "FROM pg_catalog.pg_collation c "
14702 "WHERE c.oid = '%u'::pg_catalog.oid",
14707 i_collprovider =
PQfnumber(res,
"collprovider");
14708 i_collisdeterministic =
PQfnumber(res,
"collisdeterministic");
14709 i_collcollate =
PQfnumber(res,
"collcollate");
14710 i_collctype =
PQfnumber(res,
"collctype");
14711 i_colllocale =
PQfnumber(res,
"colllocale");
14712 i_collicurules =
PQfnumber(res,
"collicurules");
14714 collprovider =
PQgetvalue(res, 0, i_collprovider);
14717 collcollate =
PQgetvalue(res, 0, i_collcollate);
14719 collcollate = NULL;
14722 collctype =
PQgetvalue(res, 0, i_collctype);
14732 if (collcollate[0] ==
'\0')
14733 collcollate = NULL;
14734 if (collctype[0] ==
'\0')
14739 colllocale =
PQgetvalue(res, 0, i_colllocale);
14744 collicurules =
PQgetvalue(res, 0, i_collicurules);
14746 collicurules = NULL;
14755 if (collprovider[0] ==
'b')
14757 else if (collprovider[0] ==
'c')
14759 else if (collprovider[0] ==
'i')
14761 else if (collprovider[0] ==
'd')
14765 pg_fatal(
"unrecognized collation provider: %s",
14768 if (strcmp(
PQgetvalue(res, 0, i_collisdeterministic),
"f") == 0)
14771 if (collprovider[0] ==
'd')
14773 if (collcollate || collctype || colllocale || collicurules)
14778 else if (collprovider[0] ==
'b')
14780 if (collcollate || collctype || !colllocale || collicurules)
14787 else if (collprovider[0] ==
'i')
14791 if (collcollate || collctype || !colllocale)
14800 if (!collcollate || !collctype || colllocale ||
14801 strcmp(collcollate, collctype) != 0)
14814 else if (collprovider[0] ==
'c')
14816 if (colllocale || collicurules || !collcollate || !collctype)
14819 if (collcollate && collctype && strcmp(collcollate, collctype) == 0)
14833 pg_fatal(
"unrecognized collation provider: %s", collprovider);
14843 i_collversion =
PQfnumber(res,
"collversion");
14857 "COLLATION", qcollname,
14858 collinfo->
dobj.namespace->dobj.
name);
14863 .namespace = collinfo->
dobj.namespace->dobj.
name,
14865 .description =
"COLLATION",
14867 .createStmt = q->
data,
14868 .dropStmt = delq->
data));
14897 int i_conforencoding;
14898 int i_contoencoding;
14901 const char *conforencoding;
14902 const char *contoencoding;
14903 const char *conproc;
14918 "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
14919 "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
14920 "conproc, condefault "
14921 "FROM pg_catalog.pg_conversion c "
14922 "WHERE c.oid = '%u'::pg_catalog.oid",
14927 i_conforencoding =
PQfnumber(res,
"conforencoding");
14928 i_contoencoding =
PQfnumber(res,
"contoencoding");
14930 i_condefault =
PQfnumber(res,
"condefault");
14932 conforencoding =
PQgetvalue(res, 0, i_conforencoding);
14933 contoencoding =
PQgetvalue(res, 0, i_contoencoding);
14935 condefault = (
PQgetvalue(res, 0, i_condefault)[0] ==
't');
14941 (condefault) ?
"DEFAULT " :
"",
14951 "CONVERSION", qconvname,
14952 convinfo->
dobj.namespace->dobj.
name);
14957 .namespace = convinfo->
dobj.namespace->dobj.
name,
14959 .description =
"CONVERSION",
14961 .createStmt = q->
data,
14962 .dropStmt = delq->
data));
14996 if (agginfo->aggfn.nargs == 0)
15001 for (
j = 0;
j < agginfo->aggfn.nargs;
j++)
15003 (
j > 0) ?
", " :
"",
15005 agginfo->aggfn.argtypes[
j],
15025 char *aggfullsig = NULL;
15030 const char *aggtransfn;
15031 const char *aggfinalfn;
15032 const char *aggcombinefn;
15033 const char *aggserialfn;
15034 const char *aggdeserialfn;
15035 const char *aggmtransfn;
15036 const char *aggminvtransfn;
15037 const char *aggmfinalfn;
15038 bool aggfinalextra;
15039 bool aggmfinalextra;
15040 char aggfinalmodify;
15041 char aggmfinalmodify;
15042 const char *aggsortop;
15043 char *aggsortconvop;
15045 const char *aggtranstype;
15046 const char *aggtransspace;
15047 const char *aggmtranstype;
15048 const char *aggmtransspace;
15049 const char *agginitval;
15050 const char *aggminitval;
15051 const char *proparallel;
15052 char defaultfinalmodify;
15067 "PREPARE dumpAgg(pg_catalog.oid) AS\n");
15073 "aggtranstype::pg_catalog.regtype,\n"
15076 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
15077 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
15083 "aggminvtransfn,\n"
15085 "aggmtranstype::pg_catalog.regtype,\n"
15087 "aggmfinalextra,\n"
15089 "aggmtransspace,\n"
15093 "'n' AS aggkind,\n"
15094 "'-' AS aggmtransfn,\n"
15095 "'-' AS aggminvtransfn,\n"
15096 "'-' AS aggmfinalfn,\n"
15097 "0 AS aggmtranstype,\n"
15098 "false AS aggfinalextra,\n"
15099 "false AS aggmfinalextra,\n"
15100 "0 AS aggtransspace,\n"
15101 "0 AS aggmtransspace,\n"
15102 "NULL AS aggminitval,\n");
15112 "'-' AS aggcombinefn,\n"
15113 "'-' AS aggserialfn,\n"
15114 "'-' AS aggdeserialfn,\n"
15115 "'u' AS proparallel,\n");
15119 "aggfinalmodify,\n"
15120 "aggmfinalmodify\n");
15123 "'0' AS aggfinalmodify,\n"
15124 "'0' AS aggmfinalmodify\n");
15127 "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
15128 "WHERE a.aggfnoid = p.oid "
15137 "EXECUTE dumpAgg('%u')",
15138 agginfo->aggfn.dobj.catId.oid);
15142 i_agginitval =
PQfnumber(res,
"agginitval");
15143 i_aggminitval =
PQfnumber(res,
"aggminitval");
15163 agginitval =
PQgetvalue(res, 0, i_agginitval);
15164 aggminitval =
PQgetvalue(res, 0, i_aggminitval);
15180 defaultfinalmodify = (aggkind == AGGKIND_NORMAL) ? AGGMODIFY_READ_ONLY : AGGMODIFY_READ_WRITE;
15182 if (aggfinalmodify ==
'0')
15183 aggfinalmodify = defaultfinalmodify;
15184 if (aggmfinalmodify ==
'0')
15185 aggmfinalmodify = defaultfinalmodify;
15189 aggtransfn, aggtranstype);
15191 if (strcmp(aggtransspace,
"0") != 0)
15203 if (strcmp(aggfinalfn,
"-") != 0)
15209 if (aggfinalmodify != defaultfinalmodify)
15211 switch (aggfinalmodify)
15213 case AGGMODIFY_READ_ONLY:
15216 case AGGMODIFY_SHAREABLE:
15219 case AGGMODIFY_READ_WRITE:
15223 pg_fatal(
"unrecognized aggfinalmodify value for aggregate \"%s\"",
15224 agginfo->aggfn.dobj.name);
15230 if (strcmp(aggcombinefn,
"-") != 0)
15233 if (strcmp(aggserialfn,
"-") != 0)
15236 if (strcmp(aggdeserialfn,
"-") != 0)
15239 if (strcmp(aggmtransfn,
"-") != 0)
15247 if (strcmp(aggmtransspace,
"0") != 0)
15259 if (strcmp(aggmfinalfn,
"-") != 0)
15263 if (aggmfinalextra)
15265 if (aggmfinalmodify != defaultfinalmodify)
15267 switch (aggmfinalmodify)
15269 case AGGMODIFY_READ_ONLY:
15272 case AGGMODIFY_SHAREABLE:
15275 case AGGMODIFY_READ_WRITE:
15279 pg_fatal(
"unrecognized aggmfinalmodify value for aggregate \"%s\"",
15280 agginfo->aggfn.dobj.name);
15291 free(aggsortconvop);
15294 if (aggkind == AGGKIND_HYPOTHETICAL)
15297 if (proparallel[0] != PROPARALLEL_UNSAFE)
15299 if (proparallel[0] == PROPARALLEL_SAFE)
15301 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
15303 else if (proparallel[0] != PROPARALLEL_UNSAFE)
15304 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
15305 agginfo->aggfn.dobj.name);
15309 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
15313 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
15314 aggfullsig ? aggfullsig : aggsig, details->
data);
15318 "AGGREGATE", aggsig,
15319 agginfo->aggfn.dobj.namespace->dobj.name);
15323 agginfo->aggfn.dobj.dumpId,
15325 .
namespace = agginfo->aggfn.dobj.namespace->dobj.name,
15326 .owner = agginfo->aggfn.rolname,
15327 .description =
"AGGREGATE",
15329 .createStmt = q->
data,
15330 .dropStmt = delq->
data));
15335 agginfo->aggfn.dobj.namespace->dobj.name,
15336 agginfo->aggfn.rolname,
15337 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
15341 agginfo->aggfn.dobj.namespace->dobj.name,
15342 agginfo->aggfn.rolname,
15343 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
15356 "FUNCTION", aggsig, NULL,
15357 agginfo->aggfn.dobj.namespace->dobj.name,
15358 NULL, agginfo->aggfn.rolname, &agginfo->aggfn.dacl);
15413 "TEXT SEARCH PARSER", qprsname,
15414 prsinfo->
dobj.namespace->dobj.
name);
15419 .namespace = prsinfo->
dobj.namespace->dobj.
name,
15420 .description =
"TEXT SEARCH PARSER",
15422 .createStmt = q->
data,
15423 .dropStmt = delq->
data));
15427 dumpComment(fout,
"TEXT SEARCH PARSER", qprsname,
15428 prsinfo->
dobj.namespace->dobj.
name,
"",
15464 "FROM pg_ts_template p, pg_namespace n "
15465 "WHERE p.oid = '%u' AND n.oid = tmplnamespace",
15491 "TEXT SEARCH DICTIONARY", qdictname,
15492 dictinfo->
dobj.namespace->dobj.
name);
15497 .namespace = dictinfo->
dobj.namespace->dobj.
name,
15499 .description =
"TEXT SEARCH DICTIONARY",
15501 .createStmt = q->
data,
15502 .dropStmt = delq->
data));
15506 dumpComment(fout,
"TEXT SEARCH DICTIONARY", qdictname,
15551 "TEXT SEARCH TEMPLATE", qtmplname,
15552 tmplinfo->
dobj.namespace->dobj.
name);
15557 .namespace = tmplinfo->
dobj.namespace->dobj.
name,
15558 .description =
"TEXT SEARCH TEMPLATE",
15560 .createStmt = q->
data,
15561 .dropStmt = delq->
data));
15565 dumpComment(fout,
"TEXT SEARCH TEMPLATE", qtmplname,
15566 tmplinfo->
dobj.namespace->dobj.
name,
"",
15606 "FROM pg_ts_parser p, pg_namespace n "
15607 "WHERE p.oid = '%u' AND n.oid = prsnamespace",
15624 " ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
15625 " WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
15626 " m.mapdict::pg_catalog.regdictionary AS dictname\n"
15627 "FROM pg_catalog.pg_ts_config_map AS m\n"
15628 "WHERE m.mapcfg = '%u'\n"
15629 "ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
15635 i_tokenname =
PQfnumber(res,
"tokenname");
15636 i_dictname =
PQfnumber(res,
"dictname");
15638 for (
i = 0;
i < ntups;
i++)
15640 char *tokenname =
PQgetvalue(res,
i, i_tokenname);
15644 strcmp(tokenname,
PQgetvalue(res,
i - 1, i_tokenname)) != 0)
15653 fmtId(tokenname), dictname);
15669 "TEXT SEARCH CONFIGURATION", qcfgname,
15670 cfginfo->
dobj.namespace->dobj.
name);
15675 .namespace = cfginfo->
dobj.namespace->dobj.
name,
15677 .description =
"TEXT SEARCH CONFIGURATION",
15679 .createStmt = q->
data,
15680 .dropStmt = delq->
data));
15684 dumpComment(fout,
"TEXT SEARCH CONFIGURATION", qcfgname,
15734 "FOREIGN DATA WRAPPER", qfdwname,
15741 .description =
"FOREIGN DATA WRAPPER",
15743 .createStmt = q->
data,
15744 .dropStmt = delq->
data));
15748 dumpComment(fout,
"FOREIGN DATA WRAPPER", qfdwname,
15755 "FOREIGN DATA WRAPPER", qfdwname, NULL, NULL,
15791 "FROM pg_foreign_data_wrapper w "
15792 "WHERE w.oid = '%u'",
15822 "SERVER", qsrvname, NULL);
15828 .description =
"SERVER",
15830 .createStmt = q->
data,
15831 .dropStmt = delq->
data));
15842 "FOREIGN SERVER", qsrvname, NULL, NULL,
15870 const char *servername,
const char *
namespace,
15899 "array_to_string(ARRAY("
15900 "SELECT quote_ident(option_name) || ' ' || "
15901 "quote_literal(option_value) "
15902 "FROM pg_options_to_table(umoptions) "
15903 "ORDER BY option_name"
15904 "), E',\n ') AS umoptions "
15905 "FROM pg_user_mappings "
15906 "WHERE srvid = '%u' "
15907 "ORDER BY usename",
15914 i_umoptions =
PQfnumber(res,
"umoptions");
15916 for (
i = 0;
i < ntups;
i++)
15928 if (umoptions && strlen(umoptions) > 0)
15939 usename, servername);
15943 .namespace =
namespace,
15945 .description =
"USER MAPPING",
15947 .createStmt = q->
data,
15948 .dropStmt = delq->
data));
15979 case DEFACLOBJ_RELATION:
15982 case DEFACLOBJ_SEQUENCE:
15983 type =
"SEQUENCES";
15985 case DEFACLOBJ_FUNCTION:
15986 type =
"FUNCTIONS";
15988 case DEFACLOBJ_TYPE:
15991 case DEFACLOBJ_NAMESPACE:
15994 case DEFACLOBJ_LARGEOBJECT:
15995 type =
"LARGE OBJECTS";
15999 pg_fatal(
"unrecognized object type in default privileges: %d",
16008 daclinfo->
dobj.namespace != NULL ?
16009 daclinfo->
dobj.namespace->dobj.
name : NULL,
16015 pg_fatal(
"could not parse default ACL list (%s)",
16021 .namespace = daclinfo->
dobj.namespace ?
16022 daclinfo->
dobj.namespace->dobj.
name : NULL,
16024 .description =
"DEFAULT ACL",
16026 .createStmt = q->
data));
16057 const char *nspname,
const char *tag,
const char *owner,
16062 const char *acls = dacl->
acl;
16065 const char *initprivs = dacl->
initprivs;
16066 const char *baseacls;
16093 initprivs && *initprivs !=
'\0')
16099 pg_fatal(
"could not parse initial ACL list (%s) or default (%s) for object \"%s\" (%s)",
16101 appendPQExpBufferStr(sql,
"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
16112 if (initprivs && *initprivs !=
'\0')
16114 baseacls = initprivs;
16115 if (acls == NULL || *acls ==
'\0')
16122 acls, baseacls, owner,
16124 pg_fatal(
"could not parse ACL list (%s) or default (%s) for object \"%s\" (%s)",
16140 aclDeps[nDeps++] = objDumpId;
16142 aclDeps[nDeps++] = altDumpId;
16148 .namespace = nspname,
16150 .description =
"ACL",
16152 .createStmt = sql->
data,
16184 const char *
namespace,
const char *owner,
16201 if (strcmp(
type,
"LARGE OBJECT") != 0)
16218 for (
i = 0;
i < nlabels;
i++)
16223 if (labels[
i].objsubid != subid)
16227 "SECURITY LABEL FOR %s ON %s ",
16229 if (
namespace && *
namespace)
16236 if (query->
len > 0)
16243 .namespace =
namespace,
16245 .description =
"SECURITY LABEL",
16247 .createStmt = query->
data,
16292 for (
i = 0;
i < nlabels;
i++)
16294 const char *colname;
16318 if (query->
len > 0)
16325 .namespace = tbinfo->
dobj.namespace->dobj.
name,
16327 .description =
"SECURITY LABEL",
16329 .createStmt = query->
data,
16363 while (low <= high)
16365 middle = low + (high - low) / 2;
16367 if (classoid < middle->classoid)
16369 else if (classoid > middle->
classoid)
16371 else if (objoid < middle->objoid)
16373 else if (objoid > middle->
objoid)
16391 while (middle > low)
16393 if (classoid != middle[-1].classoid ||
16394 objoid != middle[-1].objoid)
16403 while (middle <= high)
16405 if (classoid != middle->
classoid ||
16406 objoid != middle->
objoid)
16440 "SELECT label, provider, classoid, objoid, objsubid "
16441 "FROM pg_catalog.pg_seclabel "
16442 "ORDER BY classoid, objoid, objsubid");
16448 i_provider =
PQfnumber(res,
"provider");
16449 i_classoid =
PQfnumber(res,
"classoid");
16451 i_objsubid =
PQfnumber(res,
"objsubid");
16459 for (
i = 0;
i < ntups;
i++)
16469 if (dobj == NULL ||
16482 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
16522 if (tbinfo->
relkind == RELKIND_SEQUENCE)
16532 const char *objtype =
16533 (tbinfo->
relkind == RELKIND_SEQUENCE) ?
"SEQUENCE" :
"TABLE";
16537 objtype, namecopy, NULL,
16538 tbinfo->
dobj.namespace->dobj.
name,
16558 "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
16573 "SELECT at.attname, "
16575 "'{}' AS acldefault, "
16576 "pip.privtype, pip.initprivs "
16577 "FROM pg_catalog.pg_attribute at "
16578 "LEFT JOIN pg_catalog.pg_init_privs pip ON "
16579 "(at.attrelid = pip.objoid "
16580 "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
16581 "AND at.attnum = pip.objsubid) "
16582 "WHERE at.attrelid = $1 AND "
16583 "NOT at.attisdropped "
16584 "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
16585 "ORDER BY at.attnum");
16590 "SELECT attname, attacl, '{}' AS acldefault, "
16591 "NULL AS privtype, NULL AS initprivs "
16592 "FROM pg_catalog.pg_attribute "
16593 "WHERE attrelid = $1 AND NOT attisdropped "
16594 "AND attacl IS NOT NULL "
16595 "ORDER BY attnum");
16604 "EXECUTE getColumnACLs('%u')",
16619 coldacl.
acl = attacl;
16631 "TABLE", namecopy, attnamecopy,
16632 tbinfo->
dobj.namespace->dobj.
name,
16633 NULL, tbinfo->
rolname, &coldacl);
16659 "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
16667 pg_fatal(
"query to obtain definition of view \"%s\" returned no data",
16670 pg_fatal(
"query to obtain definition of view \"%s\" returned more than one definition",
16677 pg_fatal(
"definition of view \"%s\" appears to be empty (length zero)",
16750 const char *reltypename;
16762 pg_log_warning(
"WITH OIDS is not supported anymore (table \"%s\")",
16769 if (tbinfo->
relkind == RELKIND_VIEW)
16777 reltypename =
"VIEW";
16808 char *partkeydef = NULL;
16809 char *ftoptions = NULL;
16810 char *srvname = NULL;
16811 const char *foreign =
"";
16819 case RELKIND_PARTITIONED_TABLE:
16824 reltypename =
"TABLE";
16828 "SELECT pg_get_partkeydef('%u')",
16836 case RELKIND_FOREIGN_TABLE:
16843 reltypename =
"FOREIGN TABLE";
16847 "SELECT fs.srvname, "
16848 "pg_catalog.array_to_string(ARRAY("
16849 "SELECT pg_catalog.quote_ident(option_name) || "
16850 "' ' || pg_catalog.quote_literal(option_value) "
16851 "FROM pg_catalog.pg_options_to_table(ftoptions) "
16852 "ORDER BY option_name"
16853 "), E',\n ') AS ftoptions "
16854 "FROM pg_catalog.pg_foreign_table ft "
16855 "JOIN pg_catalog.pg_foreign_server fs "
16856 "ON (fs.oid = ft.ftserver) "
16857 "WHERE ft.ftrelid = '%u'",
16861 i_ftoptions =
PQfnumber(res,
"ftoptions");
16867 foreign =
"FOREIGN ";
16870 case RELKIND_MATVIEW:
16871 reltypename =
"MATERIALIZED VIEW";
16874 reltypename =
"TABLE";
16893 tbinfo->
relkind != RELKIND_PARTITIONED_TABLE) ?
16907 if (tbinfo->
relkind != RELKIND_MATVIEW)
16921 bool print_default;
16922 bool print_notnull;
16928 print_default = (tbinfo->
attrdefs[
j] != NULL &&
16947 !print_default && !print_notnull &&
16952 if (actual_atts == 0)
16991 else if (tbinfo->
attgenerated[
j] == ATTRIBUTE_GENERATED_VIRTUAL)
17039 if (actual_atts == 0)
17072 if (actual_atts == 0)
17103 for (k = 0; k < numParents; k++)
17114 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
17117 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
17124 bool addcomma =
false;
17143 if (ftoptions && ftoptions[0])
17150 if (tbinfo->
relkind == RELKIND_MATVIEW)
17163 if (tbinfo->
relkind == RELKIND_MATVIEW)
17165 "pg_catalog.pg_class",
17166 "MATERIALIZED VIEW",
17181 "SELECT pg_catalog.binary_upgrade_set_missing_value(");
17214 (tbinfo->
relkind == RELKIND_RELATION ||
17215 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ||
17216 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE))
17219 bool firstitem_extra;
17236 "UPDATE pg_catalog.pg_attribute\n"
17237 "SET attlen = v.dlen, "
17238 "attalign = v.dalign, "
17239 "attbyval = false\n"
17252 foreign, qualrelname);
17260 "WHERE attrelid = ");
17263 " AND attname = v.dname;\n");
17282 "SET attislocal = false\n"
17283 "WHERE attrelid = ");
17286 " AND attname IN (");
17304 firstitem_extra =
true;
17325 "SET conislocal = false\n"
17326 "WHERE contype = 'n' AND conrelid = ");
17338 if (firstitem_extra)
17341 "SET conislocal = false\n"
17342 "WHERE contype = 'n' AND conrelid = ");
17346 firstitem_extra =
false;
17356 if (!firstitem_extra)
17359 if (extra->
len > 0)
17376 for (k = 0; k < tbinfo->
ncheck; k++)
17386 foreign, qualrelname,
17393 "SET conislocal = false\n"
17394 "WHERE contype = 'c' AND conrelid = ");
17413 for (k = 0; k < numParents; k++)
17441 (tbinfo->
relkind == RELKIND_RELATION ||
17442 tbinfo->
relkind == RELKIND_MATVIEW))
17446 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17458 appendPQExpBufferStr(q,
"\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
17460 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17461 "WHERE oid = '%u';\n",
17479 "SET relispopulated = 't'\n"
17501 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STATISTICS %d;\n",
17502 foreign, qualrelname,
17514 case TYPSTORAGE_PLAIN:
17517 case TYPSTORAGE_EXTERNAL:
17520 case TYPSTORAGE_EXTENDED:
17523 case TYPSTORAGE_MAIN:
17534 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STORAGE %s;\n",
17535 foreign, qualrelname,
17545 const char *cmname;
17560 if (cmname != NULL)
17561 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET COMPRESSION %s;\n",
17562 foreign, qualrelname,
17572 foreign, qualrelname,
17579 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
17582 "ALTER FOREIGN TABLE ONLY %s ALTER COLUMN %s OPTIONS (\n"
17598 if ((tbinfo->
relkind == RELKIND_RELATION ||
17599 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ||
17600 tbinfo->
relkind == RELKIND_MATVIEW) &&
17607 else if (tbinfo->
relreplident == REPLICA_IDENTITY_NOTHING)
17612 else if (tbinfo->
relreplident == REPLICA_IDENTITY_FULL)
17625 reltypename, qrelname,
17626 tbinfo->
dobj.namespace->dobj.
name);
17631 char *tableam = NULL;
17640 if (RELKIND_HAS_TABLESPACE(tbinfo->
relkind))
17643 if (RELKIND_HAS_TABLE_AM(tbinfo->
relkind) ||
17644 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
17645 tableam = tbinfo->
amname;
17649 .namespace = tbinfo->
dobj.namespace->dobj.
name,
17651 .tableam = tableam,
17654 .description = reltypename,
17657 .createStmt = q->
data,
17658 .dropStmt = delq->
data));
17721 "PREPARE dumpTableAttach(pg_catalog.oid) AS\n");
17724 "SELECT pg_get_expr(c.relpartbound, c.oid) "
17726 "WHERE c.oid = $1");
17734 "EXECUTE dumpTableAttach('%u')",
17742 "ALTER TABLE ONLY %s ",
17745 "ATTACH PARTITION %s %s;\n",
17758 .namespace = attachinfo->
dobj.namespace->dobj.
name,
17760 .description =
"TABLE ATTACH",
17762 .createStmt = q->
data));
17776 int adnum = adinfo->
adnum;
17796 foreign = tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
17799 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET DEFAULT %s;\n",
17804 foreign, qualrelname,
17812 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
17814 .description =
"DEFAULT",
17816 .createStmt = q->
data,
17817 .dropStmt = delq->
data));
17835 if (attrnum > 0 && attrnum <= tblInfo->numatts)
17836 return tblInfo->
attnames[attrnum - 1];
17852 pg_fatal(
"invalid column number %d for table \"%s\"",
17889 if (!is_constraint)
17893 char **indstatcolsarray = NULL;
17894 char **indstatvalsarray = NULL;
17925 if (strlen(indstatcols) != 0 || strlen(indstatvals) != 0)
17929 if (!
parsePGArray(indstatcols, &indstatcolsarray, &nstatcols))
17930 pg_fatal(
"could not parse index statistic columns");
17931 if (!
parsePGArray(indstatvals, &indstatvalsarray, &nstatvals))
17932 pg_fatal(
"could not parse index statistic values");
17933 if (nstatcols != nstatvals)
17934 pg_fatal(
"mismatched number of columns and values for index statistics");
17936 for (
j = 0;
j < nstatcols;
j++)
17945 indstatcolsarray[
j]);
17947 indstatvalsarray[
j]);
17953 "pg_catalog.pg_class",
17954 "INDEX", qqindxname);
17981 .namespace = tbinfo->
dobj.namespace->dobj.
name,
17984 .description =
"INDEX",
17986 .createStmt = q->
data,
17987 .dropStmt = delq->
data));
17989 free(indstatcolsarray);
17990 free(indstatvalsarray);
17996 tbinfo->
dobj.namespace->dobj.
name,
18041 .namespace = attachinfo->
dobj.namespace->dobj.
name,
18043 .description =
"INDEX ATTACH",
18045 .createStmt = q->
data));
18062 char *qstatsextname;
18077 "pg_catalog.pg_get_statisticsobjdef('%u'::pg_catalog.oid)",
18106 .namespace = statsextinfo->
dobj.namespace->dobj.
name,
18107 .owner = statsextinfo->
rolname,
18108 .description =
"STATISTICS",
18110 .createStmt = q->
data,
18111 .dropStmt = delq->
data));
18116 statsextinfo->
dobj.namespace->dobj.
name,
18125 free(qstatsextname);
18149 foreign = tbinfo &&
18150 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
18152 if (coninfo->
contype ==
'p' ||
18162 if (indxinfo == NULL)
18163 pg_fatal(
"missing index for constraint \"%s\"",
18183 coninfo->
contype ==
'p' ?
"PRIMARY KEY" :
"UNIQUE");
18196 int indkey = (int) indxinfo->
indkeys[k];
18204 (k == 0) ?
"" :
", ",
18213 for (k = indxinfo->
indnkeyattrs; k < indxinfo->indnattrs; k++)
18215 int indkey = (int) indxinfo->
indkeys[k];
18274 "pg_catalog.pg_class",
"INDEX",
18287 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18290 .description =
"CONSTRAINT",
18292 .createStmt = q->
data,
18293 .dropStmt = delq->
data));
18295 else if (coninfo->
contype ==
'f')
18305 only = tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ?
"" :
"ONLY ";
18327 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18329 .description =
"FK CONSTRAINT",
18331 .createStmt = q->
data,
18332 .dropStmt = delq->
data));
18334 else if ((coninfo->
contype ==
'c' || coninfo->
contype ==
'n') && tbinfo)
18341 const char *keyword;
18344 keyword =
"CHECK CONSTRAINT";
18346 keyword =
"CONSTRAINT";
18365 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18367 .description = keyword,
18369 .createStmt = q->
data,
18370 .dropStmt = delq->
data));
18373 else if (coninfo->
contype ==
'c' && tbinfo == NULL)
18397 .
namespace = tyinfo->
dobj.namespace->dobj.
name,
18399 .description =
"CHECK CONSTRAINT",
18401 .createStmt = q->
data,
18402 .dropStmt = delq->
data));
18407 pg_fatal(
"unrecognized constraint type: %c",
18412 if (tbinfo && coninfo->
separate &&
18442 tbinfo->
dobj.namespace->dobj.
name,
18500 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
18501 "seqstart, seqincrement, "
18503 "seqcache, seqcycle, "
18505 "FROM pg_catalog.pg_sequence "
18506 "ORDER BY seqrelid";
18508 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
18509 "seqstart, seqincrement, "
18511 "seqcache, seqcycle, "
18512 "last_value, is_called "
18513 "FROM pg_catalog.pg_sequence, "
18514 "pg_get_sequence_data(seqrelid) "
18515 "ORDER BY seqrelid;";
18549 int64 default_minv,
18584 "SELECT 'bigint' AS sequence_type, "
18585 "start_value, increment_by, max_value, min_value, "
18586 "cache_value, is_cycled FROM %s",
18592 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
18593 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
18610 is_ascending = (seq->
incby >= 0);
18629 default_minv = default_maxv = 0;
18662 "ALTER COLUMN %s ADD GENERATED ",
18678 "UNLOGGED" :
"LOGGED");
18683 "CREATE %sSEQUENCE %s\n",
18696 if (seq->
minv != default_minv)
18701 if (seq->
maxv != default_maxv)
18719 "SEQUENCE", qseqname,
18720 tbinfo->
dobj.namespace->dobj.
name);
18725 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18727 .description =
"SEQUENCE",
18729 .createStmt = query->
data,
18730 .dropStmt = delqry->
data));
18748 if (owning_tab == NULL)
18749 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
18765 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18767 .description =
"SEQUENCE OWNED BY",
18769 .createStmt = query->
data,
18818 "SELECT last_value, is_called FROM %s",
18824 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
18825 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
18829 last = strtoi64(
PQgetvalue(res, 0, 0), NULL, 10);
18830 called = (strcmp(
PQgetvalue(res, 0, 1),
"t") == 0);
18854 last, (called ?
"true" :
"false"));
18859 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18861 .description =
"SEQUENCE SET",
18863 .createStmt = query->
data,
18905 "pg_catalog.pg_trigger",
"TRIGGER",
18906 trigidentity->
data);
18921 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
18946 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
18976 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18978 .description =
"TRIGGER",
18980 .createStmt = query->
data,
18981 .dropStmt = delqry->
data));
19022 if (strcmp(
"", evtinfo->
evttags) != 0)
19060 "EVENT TRIGGER", qevtname, NULL);
19066 .description =
"EVENT TRIGGER",
19068 .createStmt = query->
data,
19069 .dropStmt = delqry->
data));
19151 "SELECT pg_catalog.pg_get_ruledef('%u'::pg_catalog.oid)",
19157 pg_fatal(
"query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
19220 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
19222 .description =
"RULE",
19224 .createStmt = cmd->
data,
19225 .dropStmt = delcmd->
data));
19230 tbinfo->
dobj.namespace->dobj.
name,
19266 if (numExtensions == 0)
19273 "classid, objid, refobjid "
19275 "WHERE refclassid = 'pg_extension'::regclass "
19276 "AND deptype = 'e' "
19285 i_refobjid =
PQfnumber(res,
"refobjid");
19294 for (
i = 0;
i < ntups;
i++)
19310 pg_log_warning(
"could not find referenced extension %u", extId);
19358 if (numExtensions == 0)
19372 for (
i = 0;
i < numExtensions;
i++)
19377 char **extconfigarray = NULL;
19378 char **extconditionarray = NULL;
19379 int nconfigitems = 0;
19380 int nconditionitems = 0;
19400 if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
19404 if (!
parsePGArray(extconfig, &extconfigarray, &nconfigitems))
19405 pg_fatal(
"could not parse %s array",
"extconfig");
19406 if (!
parsePGArray(extcondition, &extconditionarray, &nconditionitems))
19407 pg_fatal(
"could not parse %s array",
"extcondition");
19408 if (nconfigitems != nconditionitems)
19409 pg_fatal(
"mismatched number of configurations and conditions for extension");
19411 for (
j = 0;
j < nconfigitems;
j++)
19414 Oid configtbloid =
atooid(extconfigarray[
j]);
19419 if (configtbl == NULL)
19435 if (configtbl->
dobj.namespace->dobj.
dump &
19454 if (configtbl->
dataObj != NULL)
19456 if (strlen(extconditionarray[
j]) > 0)
19462 if (extconfigarray)
19463 free(extconfigarray);
19464 if (extconditionarray)
19465 free(extconditionarray);
19480 "SELECT conrelid, confrelid "
19481 "FROM pg_constraint "
19482 "JOIN pg_depend ON (objid = confrelid) "
19483 "WHERE contype = 'f' "
19484 "AND refclassid = 'pg_extension'::regclass "
19485 "AND classid = 'pg_class'::regclass;");
19490 i_conrelid =
PQfnumber(res,
"conrelid");
19491 i_confrelid =
PQfnumber(res,
"confrelid");
19494 for (
i = 0;
i < ntups;
i++)
19506 if (reftable == NULL ||
19508 contable == NULL ||
19554 "classid, objid, refclassid, refobjid, deptype "
19556 "WHERE deptype != 'p' AND deptype != 'e'\n");
19569 "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
19570 "FROM pg_depend d, pg_amop o "
19571 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
19572 "classid = 'pg_amop'::regclass AND objid = o.oid "
19573 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
19577 "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
19578 "FROM pg_depend d, pg_amproc p "
19579 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
19580 "classid = 'pg_amproc'::regclass AND objid = p.oid "
19581 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
19592 i_refclassid =
PQfnumber(res,
"refclassid");
19593 i_refobjid =
PQfnumber(res,
"refobjid");
19603 for (
i = 0;
i < ntups;
i++)
19615 if (dobj == NULL ||
19635 if (refdobj == NULL)
19650 if (deptype ==
'x')
19660 if (deptype ==
'i' &&
19711 for (
i = 0;
i < numObjs;
i++)
19775 if (((
RuleInfo *) dobj)->separate)
19854 if (dobj->
nDeps <= 0)
19862 &dependencies, &nDeps, &allocDeps);
19867 nDeps *
sizeof(
DumpId));
19872 free(dependencies);
19879 DumpId **dependencies,
int *nDeps,
int *allocDeps)
19898 if (*nDeps >= *allocDeps)
19902 *allocDeps *
sizeof(
DumpId));
19904 (*dependencies)[*nDeps] = depid;
19918 dependencies, nDeps, allocDeps);
19951 if (typeInfo && typeInfo->
ftypname)
19955 appendPQExpBuffer(query,
"SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
19996 for (
i = 0;
i < numatts;
i++)
19998 if (attisdropped[
i])
20000 if (attgenerated[
i])
20012 return buffer->
data;
20022 return (reloptions != NULL && strlen(reloptions) > 2);
20032 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)
TableInfo * findTableByOid(Oid oid)
ExtensionInfo * findExtensionByOid(Oid oid)
CollInfo * findCollationByOid(Oid oid)
SubscriptionInfo * findSubscriptionByOid(Oid oid)
OprInfo * findOprByOid(Oid oid)
NamespaceInfo * findNamespaceByOid(Oid oid)
void addObjectDependency(DumpableObject *dobj, DumpId refId)
DumpableObject * findObjectByDumpId(DumpId dumpId)
void parseOidArray(const char *str, Oid *array, int arraysize)
ExtensionInfo * findOwningExtension(CatalogId catalogId)
TableInfo * getSchemaData(Archive *fout, int *numTablesPtr)
TypeInfo * findTypeByOid(Oid oid)
DumpId createDumpId(void)
DumpableObject * findObjectByCatalogId(CatalogId catalogId)
void AssignDumpId(DumpableObject *dobj)
void getDumpableObjects(DumpableObject ***objs, int *numObjs)
PublicationInfo * findPublicationByOid(Oid oid)
void on_exit_close_archive(Archive *AHX)
void init_parallel_dump_utils(void)
static void cleanup(void)
static const gbtree_vinfo tinfo
#define ngettext(s, p, n)
#define PG_TEXTDOMAIN(domain)
#define OidIsValid(objectId)
void set_pglocale_pgservice(const char *argv0, const char *app)
char * supports_compression(const pg_compress_specification compression_spec)
char * validate_compress_specification(pg_compress_specification *spec)
bool parse_compress_algorithm(char *name, pg_compress_algorithm *algorithm)
void parse_compress_specification(pg_compress_algorithm algorithm, char *specification, pg_compress_specification *result)
#define PG_COMPRESSION_OPTION_WORKERS
void parse_compress_options(const char *option, char **algorithm, char **detail)
#define ALWAYS_SECURE_SEARCH_PATH_SQL
PGconn * GetConnection(UserMapping *user, bool will_prep_stmt, PgFdwConnState **state)
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)
char * PQdb(const PGconn *conn)
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
int PQclientEncoding(const PGconn *conn)
char * PQerrorMessage(const PGconn *conn)
int PQsetClientEncoding(PGconn *conn, const char *encoding)
int PQgetlength(const PGresult *res, int tup_num, int field_num)
void PQfreemem(void *ptr)
Oid PQftype(const PGresult *res, int field_num)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
PGresult * PQgetResult(PGconn *conn)
ExecStatusType PQresultStatus(const PGresult *res)
void PQclear(PGresult *res)
int PQntuples(const PGresult *res)
char * PQfname(const PGresult *res, 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)
int PQgetCopyData(PGconn *conn, char **buffer, int async)
int lo_close(PGconn *conn, int fd)
int lo_open(PGconn *conn, Oid lobjId, int mode)
void * pg_malloc(size_t size)
char * pg_strdup(const char *in)
void * pg_malloc0(size_t size)
void * pg_realloc(void *ptr, 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)
const char * filter_object_type_name(FilterObjectType fot)
bool filter_read_item(FilterStateData *fstate, char **objname, FilterCommandType *comtype, FilterObjectType *objtype)
void pg_log_filter_error(FilterStateData *fstate, const char *fmt,...)
@ FILTER_OBJECT_TYPE_TABLE_DATA_AND_CHILDREN
@ FILTER_OBJECT_TYPE_SCHEMA
@ FILTER_OBJECT_TYPE_INDEX
@ FILTER_OBJECT_TYPE_TRIGGER
@ FILTER_OBJECT_TYPE_FOREIGN_DATA
@ FILTER_OBJECT_TYPE_DATABASE
@ FILTER_OBJECT_TYPE_FUNCTION
@ FILTER_OBJECT_TYPE_TABLE_DATA
@ FILTER_OBJECT_TYPE_NONE
@ FILTER_OBJECT_TYPE_TABLE_AND_CHILDREN
@ FILTER_OBJECT_TYPE_EXTENSION
@ FILTER_OBJECT_TYPE_TABLE
@ FILTER_COMMAND_TYPE_NONE
@ FILTER_COMMAND_TYPE_EXCLUDE
@ FILTER_COMMAND_TYPE_INCLUDE
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
Assert(PointerIsAligned(start, uint64))
static DataDirSyncMethod sync_method
static int pg_cmp_u32(uint32 a, uint32 b)
if(TABLE==NULL||TABLE_index==NULL)
void pg_logging_increase_verbosity(void)
void pg_logging_init(const char *argv0)
void pg_logging_set_level(enum pg_log_level new_level)
#define pg_log_error(...)
#define pg_log_error_hint(...)
#define pg_log_error_detail(...)
char * pstrdup(const char *in)
bool option_parse_int(const char *optarg, const char *optname, int min_range, int max_range, int *result)
bool parse_sync_method(const char *optarg, DataDirSyncMethod *sync_method)
static AmcheckOptions opts
int EndLO(Archive *AHX, Oid oid)
void ProcessArchiveRestoreOptions(Archive *AHX)
RestoreOptions * NewRestoreOptions(void)
#define appendStringLiteralAH(buf, str, AH)
int StartLO(Archive *AHX, Oid oid)
enum _archiveFormat ArchiveFormat
void RestoreArchive(Archive *AHX, bool append_data)
void ConnectDatabaseAhx(Archive *AHX, const ConnParams *cparams, bool isReconnect)
void CloseArchive(Archive *AHX)
Archive * CreateArchive(const char *FileSpec, const ArchiveFormat fmt, const pg_compress_specification compression_spec, bool dosync, ArchiveMode mode, SetupWorkerPtrType setupDumpWorker, DataDirSyncMethod sync_method)
@ PREPQUERY_DUMPTABLEATTACH
@ PREPQUERY_DUMPRANGETYPE
@ PREPQUERY_GETATTRIBUTESTATS
@ PREPQUERY_DUMPCOMPOSITETYPE
@ PREPQUERY_GETCOLUMNACLS
@ PREPQUERY_GETDOMAINCONSTRAINTS
int archprintf(Archive *AH, const char *fmt,...) pg_attribute_printf(2
void SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)
void archputs(const char *s, Archive *AH)
void InitDumpOptions(DumpOptions *opts)
void WriteData(Archive *AHX, const void *data, size_t dLen)
int TocIDRequired(ArchiveHandle *AH, DumpId id)
TocEntry * ArchiveEntry(Archive *AHX, CatalogId catalogId, DumpId dumpId, ArchiveOpts *opts)
#define ARCHIVE_OPTS(...)
int(* DataDumperPtr)(Archive *AH, const void *userArg)
void ExecuteSqlStatement(Archive *AHX, const char *query)
PGresult * ExecuteSqlQuery(Archive *AHX, const char *query, ExecStatusType status)
PGresult * ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)
void exit_nicely(int code)
void set_dump_section(const char *arg, int *dumpSections)
static PgChecksumMode mode
static void expand_schema_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names)
static const CatalogId nilCatalogId
static void dumpEncoding(Archive *AH)
void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
static DumpId dumpACL(Archive *fout, DumpId objDumpId, DumpId altDumpId, const char *type, const char *name, const char *subname, const char *nspname, const char *tag, const char *owner, const DumpableAcl *dacl)
static SimpleStringList schema_include_patterns
static void dumpAttrDef(Archive *fout, const AttrDefInfo *adinfo)
ExtensionInfo * getExtensions(Archive *fout, int *numExtensions)
static void selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void collectBinaryUpgradeClassOids(Archive *fout)
static PQExpBuffer createDummyViewAsClause(Archive *fout, const TableInfo *tbinfo)
static void dumpUserMappings(Archive *fout, const char *servername, const char *namespace, const char *owner, CatalogId catalogId, DumpId dumpId)
static void dumpPublicationNamespace(Archive *fout, const PublicationSchemaInfo *pubsinfo)
static void addBoundaryDependencies(DumpableObject **dobjs, int numObjs, DumpableObject *boundaryObjs)
void getPublicationNamespaces(Archive *fout)
static void dumpSearchPath(Archive *AH)
static void selectDumpableTable(TableInfo *tbinfo, Archive *fout)
static DumpableObject * createBoundaryObjects(void)
static char * convertTSFunction(Archive *fout, Oid funcOid)
static void dumpDatabase(Archive *fout)
static SimpleStringList table_include_patterns
static void append_depends_on_extension(Archive *fout, PQExpBuffer create, const DumpableObject *dobj, const char *catalog, const char *keyword, const char *objname)
static Oid get_next_possible_free_pg_type_oid(Archive *fout, PQExpBuffer upgrade_query)
static void dumpNamespace(Archive *fout, const NamespaceInfo *nspinfo)
static bool forcePartitionRootLoad(const TableInfo *tbinfo)
static void dumpCast(Archive *fout, const CastInfo *cast)
static SimpleOidList schema_exclude_oids
static bool have_extra_float_digits
static void dumpIndex(Archive *fout, const IndxInfo *indxinfo)
void getPartitioningInfo(Archive *fout)
static int nbinaryUpgradeClassOids
static void dumpBaseType(Archive *fout, const TypeInfo *tyinfo)
static char * dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
static SimpleOidList extension_include_oids
static void dumpTSDictionary(Archive *fout, const TSDictInfo *dictinfo)
static void dumpAgg(Archive *fout, const AggInfo *agginfo)
static int extra_float_digits
static int SequenceItemCmp(const void *p1, const void *p2)
static void dumpRelationStats(Archive *fout, const RelStatsInfo *rsinfo)
static void dumpTableComment(Archive *fout, const TableInfo *tbinfo, const char *reltypename)
static SimpleStringList extension_include_patterns
static void selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
InhInfo * getInherits(Archive *fout, int *numInherits)
void getForeignDataWrappers(Archive *fout)
static void dumpTrigger(Archive *fout, const TriggerInfo *tginfo)
static void binary_upgrade_set_type_oids_by_rel(Archive *fout, PQExpBuffer upgrade_buffer, const TableInfo *tbinfo)
static void dumpTable(Archive *fout, const TableInfo *tbinfo)
static SimpleOidList extension_exclude_oids
static SimpleStringList table_exclude_patterns
static PQExpBuffer createViewAsClause(Archive *fout, const TableInfo *tbinfo)
static void dumpStatisticsExt(Archive *fout, const StatsExtInfo *statsextinfo)
void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
static void dumpRangeType(Archive *fout, const TypeInfo *tyinfo)
void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
static void dumpComment(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId)
static char * getFormattedOperatorName(const char *oproid)
static char * format_function_signature(Archive *fout, const FuncInfo *finfo, bool honor_quotes)
static pg_compress_algorithm compression_algorithm
static void dumpStdStrings(Archive *AH)
static void dumpConstraint(Archive *fout, const ConstraintInfo *coninfo)
static void dumpType(Archive *fout, const TypeInfo *tyinfo)
static void dumpTableAttach(Archive *fout, const TableAttachInfo *attachinfo)
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)
static RelStatsInfo * getRelationStatistics(Archive *fout, DumpableObject *rel, int32 relpages, char *reltuples, int32 relallvisible, int32 relallfrozen, char relkind, char **indAttNames, int nindAttNames)
static const char *const SeqTypeNames[]
void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo)
static const char * getAttrName(int attrnum, const TableInfo *tblInfo)
static void dumpForeignServer(Archive *fout, const ForeignServerInfo *srvinfo)
static RoleNameItem * rolenames
static void collectRoleNames(Archive *fout)
static PGresult * fetchAttributeStats(Archive *fout)
static void appendReloptionsArrayAH(PQExpBuffer buffer, const char *reloptions, const char *prefix, Archive *fout)
void getOpclasses(Archive *fout)
void getForeignServers(Archive *fout)
void getFuncs(Archive *fout)
static void dumpTableData(Archive *fout, const TableDataInfo *tdinfo)
static void prohibit_crossdb_refs(PGconn *conn, const char *dbname, const char *pattern)
static int dumpTableData_copy(Archive *fout, const void *dcontext)
#define MAX_BLOBS_PER_ARCHIVE_ENTRY
static const char * getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts)
static void getDependencies(Archive *fout)
static void buildMatViewRefreshDependencies(Archive *fout)
void getTSDictionaries(Archive *fout)
static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, PQExpBuffer upgrade_buffer, Oid pg_type_oid, bool force_array_type, bool include_multirange_type)
#define DUMP_DEFAULT_ROWS_PER_INSERT
void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
static SeqType parse_sequence_type(const char *name)
static const char * getRoleName(const char *roleoid_str)
static void dumpShellType(Archive *fout, const ShellTypeInfo *stinfo)
static SequenceItem * sequences
static void refreshMatViewData(Archive *fout, const TableDataInfo *tdinfo)
static int findComments(Oid classoid, Oid objoid, CommentItem **items)
static SimpleStringList foreign_servers_include_patterns
static void selectDumpableCast(CastInfo *cast, Archive *fout)
void getCasts(Archive *fout)
static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo)
static void dumpPolicy(Archive *fout, const PolicyInfo *polinfo)
void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
static void setupDumpWorker(Archive *AH)
static void addConstrChildIdxDeps(DumpableObject *dobj, const IndxInfo *refidx)
void getTSConfigurations(Archive *fout)
static int findSecLabels(Oid classoid, Oid objoid, SecLabelItem **items)
static SimpleStringList table_include_patterns_and_children
static char * convertRegProcReference(const char *proc)
static void getAdditionalACLs(Archive *fout)
StaticAssertDecl(lengthof(SeqTypeNames)==(SEQTYPE_BIGINT+1), "array length mismatch")
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)
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)
TableInfo * getTables(Archive *fout, int *numTables)
static void dumpRule(Archive *fout, const RuleInfo *rinfo)
static void dumpCompositeType(Archive *fout, const TypeInfo *tyinfo)
static void dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
static void dumpExtension(Archive *fout, const ExtensionInfo *extinfo)
#define fmtQualifiedDumpable(obj)
static bool nonemptyReloptions(const char *reloptions)
static SimpleStringList extension_exclude_patterns
static BinaryUpgradeClassOidItem * binaryUpgradeClassOids
static SimpleOidList table_include_oids
void getExtendedStatistics(Archive *fout)
static NamespaceInfo * findNamespace(Oid nsoid)
static char * get_synchronized_snapshot(Archive *fout)
static int dumpLOs(Archive *fout, const void *arg)
static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
static void appendNamedArgument(PQExpBuffer out, Archive *fout, const char *argname, const char *argtype, const char *argval)
void processExtensionTables(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
static void dumpEventTrigger(Archive *fout, const EventTriggerInfo *evtinfo)
static int BinaryUpgradeClassOidItemCmp(const void *p1, const void *p2)
static void dumpCommentExtended(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId, const char *initdb_comment)
void getDefaultACLs(Archive *fout)
static SimpleStringList tabledata_exclude_patterns
static void dumpConversion(Archive *fout, const ConvInfo *convinfo)
static void dumpForeignDataWrapper(Archive *fout, const FdwInfo *fdwinfo)
static void dumpProcLang(Archive *fout, const ProcLangInfo *plang)
static void dumpSecLabel(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId)
void getSubscriptions(Archive *fout)
static void collectSecLabels(Archive *fout)
static void selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
static void collectSequences(Archive *fout)
static Oid g_last_builtin_oid
#define MAX_ATTR_STATS_RELS
void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
void getTransforms(Archive *fout)
void getEventTriggers(Archive *fout)
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode)
static void read_dump_filters(const char *filename, DumpOptions *dopt)
static void dumpTSConfig(Archive *fout, const TSConfigInfo *cfginfo)
static SecLabelItem * seclabels
static SimpleStringList tabledata_exclude_patterns_and_children
static char * get_language_name(Archive *fout, Oid langid)
static bool checkExtensionMembership(DumpableObject *dobj, Archive *fout)
static CommentItem * comments
static int dumpTableData_insert(Archive *fout, const void *dcontext)
static SimpleOidList tabledata_exclude_oids
static SimpleStringList table_exclude_patterns_and_children
static void binary_upgrade_set_pg_class_oids(Archive *fout, PQExpBuffer upgrade_buffer, Oid pg_class_oid)
void getTSTemplates(Archive *fout)
static void set_restrict_relation_kind(Archive *AH, const char *value)
static char * format_aggregate_signature(const AggInfo *agginfo, Archive *fout, bool honor_quotes)
void getProcLangs(Archive *fout)
static void dumpSequence(Archive *fout, const TableInfo *tbinfo)
bool shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
static TableInfo * getRootTableInfo(const TableInfo *tbinfo)
void 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)
static void determineNotNullFlags(Archive *fout, PGresult *res, int r, TableInfo *tbinfo, int j, int i_notnull_name, int i_notnull_invalidoid, int i_notnull_noinherit, int i_notnull_islocal, PQExpBuffer *invalidnotnulloids)
void getOpfamilies(Archive *fout)
static void selectDumpableType(TypeInfo *tyinfo, Archive *fout)
static SimpleOidList schema_include_oids
static void dumpOpclass(Archive *fout, const OpclassInfo *opcinfo)
static SimpleStringList schema_exclude_patterns
#define DUMP_COMPONENT_COMMENT
#define DUMP_COMPONENT_DATA
#define DUMP_COMPONENT_USERMAP
#define DUMP_COMPONENT_POLICY
#define DUMP_COMPONENT_SECLABEL
#define DUMP_COMPONENT_ALL
#define DUMP_COMPONENT_ACL
#define DUMP_COMPONENT_NONE
#define DUMP_COMPONENTS_REQUIRING_LOCK
void sortDumpableObjects(DumpableObject **objs, int numObjs, DumpId preBoundaryId, DumpId postBoundaryId)
#define DUMP_COMPONENT_DEFINITION
@ DO_PUBLICATION_TABLE_IN_SCHEMA
void sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs)
#define DUMP_COMPONENT_STATISTICS
static int statistics_only
static int with_statistics
PGDLLIMPORT char * optarg
#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
const char * fmtId(const char *rawid)
void setFmtEncoding(int encoding)
void appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
void appendPGArray(PQExpBuffer buffer, const char *value)
bool processSQLNamePattern(PGconn *conn, PQExpBuffer buf, const char *pattern, bool have_where, bool force_escape, const char *schemavar, const char *namevar, const char *altnamevar, const char *visibilityrule, PQExpBuffer dbnamebuf, int *dotcnt)
bool parsePGArray(const char *atext, char ***itemarray, int *nitems)
bool appendReloptionsArray(PQExpBuffer buffer, const char *reloptions, const char *prefix, int encoding, bool std_strings)
void appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
RelFileNumber toast_index_relfilenumber
RelFileNumber toast_relfilenumber
RelFileNumber relfilenumber
struct SimplePtrListCell * next
char val[FLEXIBLE_ARRAY_MEMBER]
struct SimpleStringListCell * next
SimpleStringListCell * head
PublishGencolsType pubgencols_type
NamespaceInfo * pubschema
PublicationInfo * publication
SubscriptionInfo * subinfo
char * suboriginremotelsn
int disable_dollar_quoting
int serializable_deferrable
int no_unlogged_table_data
const char * lockWaitTimeout
int load_via_partition_root
DumpComponents components
DumpableObjectType objType
DumpComponents dump_contains
SimplePtrList partattaches
Oid looids[FLEXIBLE_ARRAY_MEMBER]
pg_compress_specification compression_spec
int disable_dollar_quoting
const char * lockWaitTimeout
struct _relStatsInfo * stats
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)