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\"",
9261 hasdefaults =
false;
9263 for (
int j = 0;
j < numatts;
j++, r++)
9266 pg_fatal(
"invalid column numbering in table \"%s\"",
9288 i_notnull_invalidoid,
9289 i_notnull_noinherit,
9291 &invalidnotnulloids);
9299 if (
PQgetvalue(res, r, i_atthasdef)[0] ==
't')
9306 if (tbloids->
len > 1)
9313 if (invalidnotnulloids != NULL)
9333 "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc\n"
9334 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9335 "JOIN pg_catalog.pg_attrdef a ON (src.tbloid = a.adrelid)\n"
9336 "ORDER BY a.adrelid, a.adnum",
9345 for (
int j = 0;
j < numDefaults;
j++)
9357 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != adrelid)
9359 while (++curtblindx < numTables)
9361 tbinfo = &tblinfo[curtblindx];
9365 if (curtblindx >= numTables)
9366 pg_fatal(
"unrecognized table OID %u", adrelid);
9369 if (adnum <= 0 || adnum > tbinfo->
numatts)
9370 pg_fatal(
"invalid adnum value %d for table \"%s\"",
9385 attrdefs[
j].
adnum = adnum;
9389 attrdefs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9412 else if (tbinfo->
relkind == RELKIND_VIEW)
9430 if (!attrdefs[
j].separate)
9442 tbinfo->
attrdefs[adnum - 1] = &attrdefs[
j];
9463 pg_log_info(
"finding invalid not null constraints");
9467 "SELECT c.tableoid, c.oid, conrelid, conname, "
9468 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9469 "conislocal, convalidated "
9470 "FROM unnest('%s'::pg_catalog.oid[]) AS src(conoid)\n"
9471 "JOIN pg_catalog.pg_constraint c ON (src.conoid = c.oid)\n"
9472 "ORDER BY c.conrelid, c.conname",
9473 invalidnotnulloids->
data);
9480 i_tableoid =
PQfnumber(res,
"tableoid");
9482 i_conrelid =
PQfnumber(res,
"conrelid");
9485 i_conislocal =
PQfnumber(res,
"conislocal");
9489 for (
int j = 0;
j < numConstrs;)
9496 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9504 while (++curtblindx < numTables)
9506 tbinfo = &tblinfo[curtblindx];
9510 if (curtblindx >= numTables)
9511 pg_fatal(
"unrecognized table OID %u", conrelid);
9513 for (
int c = 0;
c < numcons;
c++,
j++)
9520 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9565 "SELECT c.tableoid, c.oid, conrelid, conname, "
9566 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9567 "conislocal, convalidated "
9568 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9569 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
9570 "WHERE contype = 'c' "
9571 "ORDER BY c.conrelid, c.conname",
9579 i_tableoid =
PQfnumber(res,
"tableoid");
9581 i_conrelid =
PQfnumber(res,
"conrelid");
9584 i_conislocal =
PQfnumber(res,
"conislocal");
9585 i_convalidated =
PQfnumber(res,
"convalidated");
9589 for (
int j = 0;
j < numConstrs;)
9596 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9604 while (++curtblindx < numTables)
9606 tbinfo = &tblinfo[curtblindx];
9610 if (curtblindx >= numTables)
9611 pg_fatal(
"unrecognized table OID %u", conrelid);
9613 if (numcons != tbinfo->
ncheck)
9616 "expected %d check constraints on table \"%s\" but found %d",
9625 for (
int c = 0;
c < numcons;
c++,
j++)
9627 bool validated =
PQgetvalue(res,
j, i_convalidated)[0] ==
't';
9634 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9663 if (!constrs[
j].separate)
9730 int i_notnull_invalidoid,
9731 int i_notnull_noinherit,
9732 int i_notnull_islocal,
9748 char *constroid =
PQgetvalue(res, r, i_notnull_invalidoid);
9750 if (*invalidnotnulloids == NULL)
9812 if (strcmp(default_name,
9884 "prsstart::oid, prstoken::oid, "
9885 "prsend::oid, prsheadline::oid, prslextype::oid "
9886 "FROM pg_ts_parser");
9894 i_tableoid =
PQfnumber(res,
"tableoid");
9897 i_prsnamespace =
PQfnumber(res,
"prsnamespace");
9898 i_prsstart =
PQfnumber(res,
"prsstart");
9899 i_prstoken =
PQfnumber(res,
"prstoken");
9901 i_prsheadline =
PQfnumber(res,
"prsheadline");
9902 i_prslextype =
PQfnumber(res,
"prslextype");
9904 for (
i = 0;
i < ntups;
i++)
9911 prsinfo[
i].
dobj.namespace =
9943 int i_dictnamespace;
9946 int i_dictinitoption;
9951 "dictnamespace, dictowner, "
9952 "dicttemplate, dictinitoption "
9961 i_tableoid =
PQfnumber(res,
"tableoid");
9963 i_dictname =
PQfnumber(res,
"dictname");
9964 i_dictnamespace =
PQfnumber(res,
"dictnamespace");
9965 i_dictowner =
PQfnumber(res,
"dictowner");
9966 i_dictinitoption =
PQfnumber(res,
"dictinitoption");
9967 i_dicttemplate =
PQfnumber(res,
"dicttemplate");
9969 for (
i = 0;
i < ntups;
i++)
9976 dictinfo[
i].
dobj.namespace =
10009 int i_tmplnamespace;
10016 "tmplnamespace, tmplinit::oid, tmpllexize::oid "
10017 "FROM pg_ts_template");
10025 i_tableoid =
PQfnumber(res,
"tableoid");
10027 i_tmplname =
PQfnumber(res,
"tmplname");
10028 i_tmplnamespace =
PQfnumber(res,
"tmplnamespace");
10029 i_tmplinit =
PQfnumber(res,
"tmplinit");
10030 i_tmpllexize =
PQfnumber(res,
"tmpllexize");
10032 for (
i = 0;
i < ntups;
i++)
10039 tmplinfo[
i].
dobj.namespace =
10068 int i_cfgnamespace;
10075 "cfgnamespace, cfgowner, cfgparser "
10076 "FROM pg_ts_config");
10084 i_tableoid =
PQfnumber(res,
"tableoid");
10087 i_cfgnamespace =
PQfnumber(res,
"cfgnamespace");
10088 i_cfgowner =
PQfnumber(res,
"cfgowner");
10089 i_cfgparser =
PQfnumber(res,
"cfgparser");
10091 for (
i = 0;
i < ntups;
i++)
10098 cfginfo[
i].
dobj.namespace =
10129 int i_fdwvalidator;
10138 "fdwhandler::pg_catalog.regproc, "
10139 "fdwvalidator::pg_catalog.regproc, "
10141 "acldefault('F', fdwowner) AS acldefault, "
10142 "array_to_string(ARRAY("
10143 "SELECT quote_ident(option_name) || ' ' || "
10144 "quote_literal(option_value) "
10145 "FROM pg_options_to_table(fdwoptions) "
10146 "ORDER BY option_name"
10147 "), E',\n ') AS fdwoptions "
10148 "FROM pg_foreign_data_wrapper");
10156 i_tableoid =
PQfnumber(res,
"tableoid");
10159 i_fdwowner =
PQfnumber(res,
"fdwowner");
10160 i_fdwhandler =
PQfnumber(res,
"fdwhandler");
10161 i_fdwvalidator =
PQfnumber(res,
"fdwvalidator");
10163 i_acldefault =
PQfnumber(res,
"acldefault");
10164 i_fdwoptions =
PQfnumber(res,
"fdwoptions");
10166 for (
i = 0;
i < ntups;
i++)
10173 fdwinfo[
i].
dobj.namespace = NULL;
10223 "srvfdw, srvtype, srvversion, srvacl, "
10224 "acldefault('S', srvowner) AS acldefault, "
10225 "array_to_string(ARRAY("
10226 "SELECT quote_ident(option_name) || ' ' || "
10227 "quote_literal(option_value) "
10228 "FROM pg_options_to_table(srvoptions) "
10229 "ORDER BY option_name"
10230 "), E',\n ') AS srvoptions "
10231 "FROM pg_foreign_server");
10239 i_tableoid =
PQfnumber(res,
"tableoid");
10242 i_srvowner =
PQfnumber(res,
"srvowner");
10245 i_srvversion =
PQfnumber(res,
"srvversion");
10247 i_acldefault =
PQfnumber(res,
"acldefault");
10248 i_srvoptions =
PQfnumber(res,
"srvoptions");
10250 for (
i = 0;
i < ntups;
i++)
10257 srvinfo[
i].
dobj.namespace = NULL;
10298 int i_defaclnamespace;
10299 int i_defaclobjtype;
10320 "SELECT oid, tableoid, "
10322 "defaclnamespace, "
10325 "CASE WHEN defaclnamespace = 0 THEN "
10326 "acldefault(CASE WHEN defaclobjtype = 'S' "
10327 "THEN 's'::\"char\" ELSE defaclobjtype END, "
10328 "defaclrole) ELSE '{}' END AS acldefault "
10329 "FROM pg_default_acl");
10338 i_tableoid =
PQfnumber(res,
"tableoid");
10339 i_defaclrole =
PQfnumber(res,
"defaclrole");
10340 i_defaclnamespace =
PQfnumber(res,
"defaclnamespace");
10341 i_defaclobjtype =
PQfnumber(res,
"defaclobjtype");
10342 i_defaclacl =
PQfnumber(res,
"defaclacl");
10343 i_acldefault =
PQfnumber(res,
"acldefault");
10345 for (
i = 0;
i < ntups;
i++)
10359 daclinfo[
i].
dobj.namespace = NULL;
10398 while (low <= high)
10402 if (roleoid < middle->roleoid)
10404 else if (roleoid > middle->
roleoid)
10411 pg_fatal(
"role with OID %u does not exist", roleoid);
10428 query =
"SELECT oid, rolname FROM pg_catalog.pg_roles ORDER BY 1";
10466 "SELECT DISTINCT attrelid FROM pg_attribute "
10467 "WHERE attacl IS NOT NULL");
10472 for (
i = 0;
i < ntups;
i++)
10491 "SELECT objoid, classoid, objsubid, privtype, initprivs "
10492 "FROM pg_init_privs");
10497 for (
i = 0;
i < ntups;
i++)
10508 objId.
oid = objoid;
10520 ((
TableInfo *) dobj)->hascolumnACLs =
true;
10524 classoid, objoid, objsubid);
10533 strcmp(dobj->
name,
"public") == 0)
10553 classoid, objoid, objsubid);
10587 const char *
name,
const char *
namespace,
10588 const char *owner,
CatalogId catalogId,
10589 int subid,
DumpId dumpId,
10590 const char *initdb_comment)
10601 if (strcmp(
type,
"LARGE OBJECT") != 0)
10626 if (initdb_comment != NULL)
10652 if (
namespace && *
namespace)
10667 .namespace =
namespace,
10669 .description =
"COMMENT",
10671 .createStmt = query->
data,
10687 const char *
name,
const char *
namespace,
10688 const char *owner,
CatalogId catalogId,
10689 int subid,
DumpId dumpId)
10692 catalogId, subid, dumpId, NULL);
10703 const char *argtype,
const char *argval)
10728 static bool restarted;
10764 for (; te != AH->
toc && count < max_rels; te = te->
next)
10767 strcmp(te->
desc,
"STATISTICS DATA") == 0)
10770 fmtId(te->namespace));
10783 "'{%s}'::pg_catalog.name[],"
10784 "'{%s}'::pg_catalog.name[])",
10818 int i_most_common_vals;
10819 int i_most_common_freqs;
10820 int i_histogram_bounds;
10822 int i_most_common_elems;
10823 int i_most_common_elem_freqs;
10824 int i_elem_count_histogram;
10825 int i_range_length_histogram;
10826 int i_range_empty_frac;
10827 int i_range_bounds_histogram;
10837 expected_te = expected_te->
next;
10839 strcmp(expected_te->
desc,
"STATISTICS DATA") != 0)
10840 expected_te = expected_te->
next;
10842 if (te != expected_te)
10843 pg_fatal(
"stats dumped out of order (current: %d %s %s) (expected: %d %s %s)",
10851 "PREPARE getAttributeStats(pg_catalog.name[], pg_catalog.name[]) AS\n"
10852 "SELECT s.schemaname, s.tablename, s.attname, s.inherited, "
10853 "s.null_frac, s.avg_width, s.n_distinct, "
10854 "s.most_common_vals, s.most_common_freqs, "
10855 "s.histogram_bounds, s.correlation, "
10856 "s.most_common_elems, s.most_common_elem_freqs, "
10857 "s.elem_count_histogram, ");
10861 "s.range_length_histogram, "
10862 "s.range_empty_frac, "
10863 "s.range_bounds_histogram ");
10866 "NULL AS range_length_histogram,"
10867 "NULL AS range_empty_frac,"
10868 "NULL AS range_bounds_histogram ");
10885 "FROM pg_catalog.pg_stats s "
10886 "JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
10887 "ON s.schemaname = u.schemaname "
10888 "AND s.tablename = u.tablename "
10889 "WHERE s.tablename = ANY($2) "
10890 "ORDER BY u.ord, s.attname, s.inherited");
10893 "FROM pg_catalog.pg_stats s "
10894 "WHERE s.schemaname = $1[1] "
10895 "AND s.tablename = $2[1] "
10896 "ORDER BY s.attname, s.inherited");
10934 i_schemaname =
PQfnumber(res,
"schemaname");
10935 i_tablename =
PQfnumber(res,
"tablename");
10937 i_inherited =
PQfnumber(res,
"inherited");
10938 i_null_frac =
PQfnumber(res,
"null_frac");
10939 i_avg_width =
PQfnumber(res,
"avg_width");
10940 i_n_distinct =
PQfnumber(res,
"n_distinct");
10941 i_most_common_vals =
PQfnumber(res,
"most_common_vals");
10942 i_most_common_freqs =
PQfnumber(res,
"most_common_freqs");
10943 i_histogram_bounds =
PQfnumber(res,
"histogram_bounds");
10944 i_correlation =
PQfnumber(res,
"correlation");
10945 i_most_common_elems =
PQfnumber(res,
"most_common_elems");
10946 i_most_common_elem_freqs =
PQfnumber(res,
"most_common_elem_freqs");
10947 i_elem_count_histogram =
PQfnumber(res,
"elem_count_histogram");
10948 i_range_length_histogram =
PQfnumber(res,
"range_length_histogram");
10949 i_range_empty_frac =
PQfnumber(res,
"range_empty_frac");
10950 i_range_bounds_histogram =
PQfnumber(res,
"range_bounds_histogram");
10953 for (; rownum <
PQntuples(res); rownum++)
10958 if (strcmp(te->
tag,
PQgetvalue(res, rownum, i_tablename)) != 0 ||
10959 strcmp(te->namespace,
PQgetvalue(res, rownum, i_schemaname)) != 0)
10971 pg_fatal(
"attname cannot be NULL");
10986 bool found =
false;
11015 if (!
PQgetisnull(res, rownum, i_most_common_vals))
11017 PQgetvalue(res, rownum, i_most_common_vals));
11018 if (!
PQgetisnull(res, rownum, i_most_common_freqs))
11020 PQgetvalue(res, rownum, i_most_common_freqs));
11021 if (!
PQgetisnull(res, rownum, i_histogram_bounds))
11023 PQgetvalue(res, rownum, i_histogram_bounds));
11027 if (!
PQgetisnull(res, rownum, i_most_common_elems))
11029 PQgetvalue(res, rownum, i_most_common_elems));
11030 if (!
PQgetisnull(res, rownum, i_most_common_elem_freqs))
11032 PQgetvalue(res, rownum, i_most_common_elem_freqs));
11033 if (!
PQgetisnull(res, rownum, i_elem_count_histogram))
11035 PQgetvalue(res, rownum, i_elem_count_histogram));
11038 if (!
PQgetisnull(res, rownum, i_range_length_histogram))
11040 PQgetvalue(res, rownum, i_range_length_histogram));
11041 if (!
PQgetisnull(res, rownum, i_range_empty_frac))
11043 PQgetvalue(res, rownum, i_range_empty_frac));
11044 if (!
PQgetisnull(res, rownum, i_range_bounds_histogram))
11046 PQgetvalue(res, rownum, i_range_bounds_histogram));
11073 .namespace = dobj->namespace->dobj.
name,
11074 .description =
"STATISTICS DATA",
11079 .nDeps = dobj->
nDeps));
11090 const char *reltypename)
11137 .namespace = tbinfo->
dobj.namespace->dobj.
name,
11139 .description =
"COMMENT",
11141 .createStmt = query->
data,
11145 else if (objsubid > 0 && objsubid <= tbinfo->numatts)
11162 .namespace = tbinfo->
dobj.namespace->dobj.
name,
11164 .description =
"COMMENT",
11166 .createStmt = query->
data,
11199 while (low <= high)
11201 middle = low + (high - low) / 2;
11203 if (classoid < middle->classoid)
11205 else if (classoid > middle->
classoid)
11207 else if (objoid < middle->objoid)
11209 else if (objoid > middle->
objoid)
11227 while (middle > low)
11229 if (classoid != middle[-1].classoid ||
11230 objoid != middle[-1].objoid)
11239 while (middle <= high)
11241 if (classoid != middle->
classoid ||
11242 objoid != middle->
objoid)
11279 "FROM pg_catalog.pg_description "
11280 "ORDER BY classoid, objoid, objsubid");
11286 i_description =
PQfnumber(res,
"description");
11287 i_classoid =
PQfnumber(res,
"classoid");
11289 i_objsubid =
PQfnumber(res,
"objsubid");
11297 for (
i = 0;
i < ntups;
i++)
11307 if (dobj == NULL ||
11320 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
11359 if (dobj->
dump == 0)
11485 if (loinfo == NULL)
11486 pg_fatal(
"missing metadata for large objects \"%s\"",
11492 .description =
"BLOBS",
11494 .deps = dobj->dependencies,
11495 .nDeps = dobj->nDeps,
11497 .dumpArg = loinfo));
11570 "-- *not* dropping schema, since initdb creates it\n");
11572 "-- *not* creating schema, since initdb creates it\n");
11577 "SCHEMA", qnspname, NULL);
11583 .description =
"SCHEMA",
11585 .createStmt = q->
data,
11586 .dropStmt = delq->
data));
11591 const char *initdb_comment = NULL;
11593 if (!nspinfo->
create && strcmp(qnspname,
"public") == 0)
11594 initdb_comment =
"standard public schema";
11608 qnspname, NULL, NULL,
11653 qextname,
fmtId(extinfo->namespace));
11668 appendPQExpBufferStr(q,
"-- For binary upgrade, create an empty extension and insert objects into it\n");
11678 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
11723 .description =
"EXTENSION",
11725 .createStmt = q->
data,
11726 .dropStmt = delq->
data));
11759 if (tyinfo->
typtype == TYPTYPE_BASE)
11761 else if (tyinfo->
typtype == TYPTYPE_DOMAIN)
11763 else if (tyinfo->
typtype == TYPTYPE_COMPOSITE)
11765 else if (tyinfo->
typtype == TYPTYPE_ENUM)
11767 else if (tyinfo->
typtype == TYPTYPE_RANGE)
11772 pg_log_warning(
"typtype of data type \"%s\" appears to be invalid",
11801 "PREPARE dumpEnumType(pg_catalog.oid) AS\n"
11802 "SELECT oid, enumlabel "
11803 "FROM pg_catalog.pg_enum "
11804 "WHERE enumtypid = $1 "
11805 "ORDER BY enumsortorder");
11813 "EXECUTE dumpEnumType('%u')",
11839 i_enumlabel =
PQfnumber(res,
"enumlabel");
11842 for (
i = 0;
i < num;
i++)
11857 i_enumlabel =
PQfnumber(res,
"enumlabel");
11860 for (
i = 0;
i < num;
i++)
11868 "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
11879 tyinfo->
dobj.namespace->dobj.
name);
11884 .namespace = tyinfo->
dobj.namespace->dobj.
name,
11886 .description =
"TYPE",
11888 .createStmt = q->
data,
11889 .dropStmt = delq->
data));
11905 tyinfo->
dobj.namespace->dobj.
name,
11937 "PREPARE dumpRangeType(pg_catalog.oid) AS\n");
11944 "pg_catalog.format_type(rngmultitypid, NULL) AS rngmultitype, ");
11947 "NULL AS rngmultitype, ");
11950 "pg_catalog.format_type(rngsubtype, NULL) AS rngsubtype, "
11951 "opc.opcname AS opcname, "
11952 "(SELECT nspname FROM pg_catalog.pg_namespace nsp "
11953 " WHERE nsp.oid = opc.opcnamespace) AS opcnsp, "
11955 "CASE WHEN rngcollation = st.typcollation THEN 0 "
11956 " ELSE rngcollation END AS collation, "
11957 "rngcanonical, rngsubdiff "
11958 "FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
11959 " pg_catalog.pg_opclass opc "
11960 "WHERE st.oid = rngsubtype AND opc.oid = rngsubopc AND "
11969 "EXECUTE dumpRangeType('%u')",
12020 if (strcmp(procname,
"-") != 0)
12024 if (strcmp(procname,
"-") != 0)
12032 tyinfo->
dobj.namespace->dobj.
name);
12037 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12039 .description =
"TYPE",
12041 .createStmt = q->
data,
12042 .dropStmt = delq->
data));
12058 tyinfo->
dobj.namespace->dobj.
name,
12103 tyinfo->
dobj.namespace->dobj.
name);
12108 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12110 .description =
"TYPE",
12112 .createStmt = q->
data,
12113 .dropStmt = delq->
data));
12129 tyinfo->
dobj.namespace->dobj.
name,
12160 char *typsubscript;
12166 Oid typsubscriptoid;
12168 char *typispreferred;
12173 char *typcollatable;
12175 bool typdefault_is_literal =
false;
12181 "PREPARE dumpBaseType(pg_catalog.oid) AS\n"
12183 "typinput, typoutput, typreceive, typsend, "
12184 "typreceive::pg_catalog.oid AS typreceiveoid, "
12185 "typsend::pg_catalog.oid AS typsendoid, "
12187 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
12188 "typdelim, typbyval, typalign, typstorage, "
12189 "typmodin, typmodout, "
12190 "typmodin::pg_catalog.oid AS typmodinoid, "
12191 "typmodout::pg_catalog.oid AS typmodoutoid, "
12192 "typcategory, typispreferred, "
12193 "(typcollation <> 0) AS typcollatable, "
12194 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault, ");
12199 "typsubscript::pg_catalog.oid AS typsubscriptoid ");
12202 "'-' AS typsubscript, 0 AS typsubscriptoid ");
12213 "EXECUTE dumpBaseType('%u')",
12245 typdefault_is_literal =
true;
12270 "CREATE TYPE %s (\n"
12271 " INTERNALLENGTH = %s",
12273 (strcmp(typlen,
"-1") == 0) ?
"variable" : typlen);
12289 if (strcmp(typcollatable,
"t") == 0)
12292 if (typdefault != NULL)
12295 if (typdefault_is_literal)
12309 if (strcmp(typcategory,
"U") != 0)
12315 if (strcmp(typispreferred,
"t") == 0)
12318 if (typdelim && strcmp(typdelim,
",") != 0)
12326 else if (*
typalign == TYPALIGN_SHORT)
12328 else if (*
typalign == TYPALIGN_INT)
12330 else if (*
typalign == TYPALIGN_DOUBLE)
12333 if (*typstorage == TYPSTORAGE_PLAIN)
12335 else if (*typstorage == TYPSTORAGE_EXTERNAL)
12337 else if (*typstorage == TYPSTORAGE_EXTENDED)
12339 else if (*typstorage == TYPSTORAGE_MAIN)
12342 if (strcmp(typbyval,
"t") == 0)
12350 tyinfo->
dobj.namespace->dobj.
name);
12355 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12357 .description =
"TYPE",
12359 .createStmt = q->
data,
12360 .dropStmt = delq->
data));
12376 tyinfo->
dobj.namespace->dobj.
name,
12406 bool typdefault_is_literal =
false;
12412 "PREPARE dumpDomain(pg_catalog.oid) AS\n");
12415 "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
12416 "pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
12418 "CASE WHEN t.typcollation <> u.typcollation "
12419 "THEN t.typcollation ELSE 0 END AS typcollation "
12420 "FROM pg_catalog.pg_type t "
12421 "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
12422 "WHERE t.oid = $1");
12430 "EXECUTE dumpDomain('%u')",
12442 typdefault_is_literal =
true;
12458 "CREATE DOMAIN %s AS %s",
12472 if (typnotnull[0] ==
't')
12475 if (typdefault != NULL)
12478 if (typdefault_is_literal)
12504 "DOMAIN", qtypname,
12505 tyinfo->
dobj.namespace->dobj.
name);
12510 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12512 .description =
"DOMAIN",
12514 .createStmt = q->
data,
12515 .dropStmt = delq->
data));
12531 tyinfo->
dobj.namespace->dobj.
name,
12545 tyinfo->
dobj.namespace->dobj.
name,
12580 int i_attisdropped;
12581 int i_attcollation;
12596 "PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
12597 "SELECT a.attname, a.attnum, "
12598 "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
12599 "a.attlen, a.attalign, a.attisdropped, "
12600 "CASE WHEN a.attcollation <> at.typcollation "
12601 "THEN a.attcollation ELSE 0 END AS attcollation "
12602 "FROM pg_catalog.pg_type ct "
12603 "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
12604 "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
12605 "WHERE ct.oid = $1 "
12606 "ORDER BY a.attnum");
12614 "EXECUTE dumpCompositeType('%u')",
12622 i_atttypdefn =
PQfnumber(res,
"atttypdefn");
12624 i_attalign =
PQfnumber(res,
"attalign");
12625 i_attisdropped =
PQfnumber(res,
"attisdropped");
12626 i_attcollation =
PQfnumber(res,
"attcollation");
12643 for (
i = 0;
i < ntups;
i++)
12656 attisdropped = (
PQgetvalue(res,
i, i_attisdropped)[0] ==
't');
12663 if (actual_atts++ > 0)
12694 "\n-- For binary upgrade, recreate dropped column.\n");
12696 "SET attlen = %s, "
12697 "attalign = '%s', attbyval = false\n"
12718 tyinfo->
dobj.namespace->dobj.
name);
12723 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12725 .description =
"TYPE",
12727 .createStmt = q->
data,
12728 .dropStmt = delq->
data));
12745 tyinfo->
dobj.namespace->dobj.
name,
12782 int i_attisdropped;
12803 i_attisdropped =
PQfnumber(res,
"attisdropped");
12809 for (
i = 0;
i < ntups;
i++)
12836 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12838 .description =
"COMMENT",
12840 .createStmt = query->
data,
12891 .namespace = stinfo->
dobj.namespace->dobj.
name,
12893 .description =
"SHELL TYPE",
12895 .createStmt = q->
data));
12930 if (funcInfo != NULL && !funcInfo->
dobj.
dump)
12936 if (inlineInfo != NULL && !inlineInfo->
dobj.
dump)
12943 if (validatorInfo != NULL && !validatorInfo->
dobj.
dump)
12944 validatorInfo = NULL;
12952 useParams = (funcInfo != NULL &&
12996 "LANGUAGE", qlanname, NULL);
13002 .description =
"PROCEDURAL LANGUAGE",
13004 .createStmt = defqry->
data,
13005 .dropStmt = delqry->
data,
13021 qlanname, NULL, NULL,
13044 if (is_agg && finfo->
nargs == 0)
13071 for (
j = 0;
j < finfo->
nargs;
j++)
13099 char *funcfullsig = NULL;
13101 char *qual_funcsig;
13114 char *proleakproof;
13121 char **configitems = NULL;
13122 int nconfigitems = 0;
13123 const char *keyword;
13138 "PREPARE dumpFunc(pg_catalog.oid) AS\n");
13152 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
13153 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
13154 "pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
13155 "proleakproof,\n");
13159 "array_to_string(protrftypes, ' ') AS protrftypes,\n");
13162 "NULL AS protrftypes,\n");
13169 "'u' AS proparallel,\n");
13176 "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n");
13183 "'-' AS prosupport,\n");
13187 "pg_get_function_sqlbody(p.oid) AS prosqlbody\n");
13190 "NULL AS prosqlbody\n");
13193 "FROM pg_catalog.pg_proc p, pg_catalog.pg_language l\n"
13194 "WHERE p.oid = $1 "
13195 "AND l.oid = p.prolang");
13203 "EXECUTE dumpFunc('%u')",
13245 else if (probin[0] !=
'\0')
13249 if (prosrc[0] !=
'\0')
13258 (strchr(prosrc,
'\'') == NULL && strchr(prosrc,
'\\') == NULL))
13276 if (!
parsePGArray(proconfig, &configitems, &nconfigitems))
13277 pg_fatal(
"could not parse %s array",
"proconfig");
13281 configitems = NULL;
13294 if (prokind[0] == PROKIND_PROCEDURE)
13295 keyword =
"PROCEDURE";
13297 keyword =
"FUNCTION";
13300 keyword, qual_funcsig);
13305 funcfullsig ? funcfullsig :
13308 if (prokind[0] == PROKIND_PROCEDURE)
13310 else if (funcresult)
13314 (proretset[0] ==
't') ?
"SETOF " :
"",
13327 for (
i = 0; typeids[
i];
i++)
13338 if (prokind[0] == PROKIND_WINDOW)
13341 if (provolatile[0] != PROVOLATILE_VOLATILE)
13343 if (provolatile[0] == PROVOLATILE_IMMUTABLE)
13345 else if (provolatile[0] == PROVOLATILE_STABLE)
13347 else if (provolatile[0] != PROVOLATILE_VOLATILE)
13348 pg_fatal(
"unrecognized provolatile value for function \"%s\"",
13352 if (proisstrict[0] ==
't')
13355 if (prosecdef[0] ==
't')
13358 if (proleakproof[0] ==
't')
13366 if (strcmp(procost,
"0") != 0)
13368 if (strcmp(lanname,
"internal") == 0 || strcmp(lanname,
"c") == 0)
13371 if (strcmp(procost,
"1") != 0)
13377 if (strcmp(procost,
"100") != 0)
13381 if (proretset[0] ==
't' &&
13382 strcmp(prorows,
"0") != 0 && strcmp(prorows,
"1000") != 0)
13385 if (strcmp(prosupport,
"-") != 0)
13391 if (proparallel[0] != PROPARALLEL_UNSAFE)
13393 if (proparallel[0] == PROPARALLEL_SAFE)
13395 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
13397 else if (proparallel[0] != PROPARALLEL_UNSAFE)
13398 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
13402 for (
int i = 0;
i < nconfigitems;
i++)
13405 char *configitem = configitems[
i];
13408 pos = strchr(configitem,
'=');
13438 for (nameptr = namelist; *nameptr; nameptr++)
13440 if (nameptr != namelist)
13454 "pg_catalog.pg_proc", keyword,
13460 finfo->
dobj.namespace->dobj.
name);
13465 .
namespace = finfo->
dobj.namespace->dobj.
name,
13467 .description = keyword,
13470 .createStmt = q->
data,
13471 .dropStmt = delqry->
data));
13499 free(qual_funcsig);
13516 const char *sourceType;
13517 const char *targetType;
13527 if (funcInfo == NULL)
13528 pg_fatal(
"could not find function definition for function with OID %u",
13540 sourceType, targetType);
13543 sourceType, targetType);
13547 case COERCION_METHOD_BINARY:
13550 case COERCION_METHOD_INOUT:
13553 case COERCION_METHOD_FUNCTION:
13567 pg_log_warning(
"bogus value in pg_cast.castfunc or pg_cast.castmethod field");
13580 sourceType, targetType);
13583 sourceType, targetType);
13587 "CAST", castargs->
data, NULL);
13592 .description =
"CAST",
13594 .createStmt = defqry->
data,
13595 .dropStmt = delqry->
data));
13623 const char *transformType;
13633 if (fromsqlFuncInfo == NULL)
13634 pg_fatal(
"could not find function definition for function with OID %u",
13640 if (tosqlFuncInfo == NULL)
13641 pg_fatal(
"could not find function definition for function with OID %u",
13654 transformType, lanname);
13657 transformType, lanname);
13660 pg_log_warning(
"bogus transform definition, at least one of trffromsql and trftosql should be nonzero");
13664 if (fromsqlFuncInfo)
13704 transformType, lanname);
13707 transformType, lanname);
13711 "TRANSFORM", transformargs->
data, NULL);
13716 .description =
"TRANSFORM",
13718 .createStmt = defqry->
data,
13719 .dropStmt = delqry->
data,
13795 "PREPARE dumpOpr(pg_catalog.oid) AS\n"
13797 "oprcode::pg_catalog.regprocedure, "
13798 "oprleft::pg_catalog.regtype, "
13799 "oprright::pg_catalog.regtype, "
13802 "oprrest::pg_catalog.regprocedure, "
13803 "oprjoin::pg_catalog.regprocedure, "
13804 "oprcanmerge, oprcanhash "
13805 "FROM pg_catalog.pg_operator "
13814 "EXECUTE dumpOpr('%u')",
13822 i_oprright =
PQfnumber(res,
"oprright");
13824 i_oprnegate =
PQfnumber(res,
"oprnegate");
13827 i_oprcanmerge =
PQfnumber(res,
"oprcanmerge");
13828 i_oprcanhash =
PQfnumber(res,
"oprcanhash");
13835 oprnegate =
PQgetvalue(res, 0, i_oprnegate);
13838 oprcanmerge =
PQgetvalue(res, 0, i_oprcanmerge);
13839 oprcanhash =
PQgetvalue(res, 0, i_oprcanhash);
13842 if (strcmp(oprkind,
"r") == 0)
13843 pg_log_warning(
"postfix operators are not supported anymore (operator \"%s\")",
13861 if (strcmp(oprkind,
"r") == 0 ||
13862 strcmp(oprkind,
"b") == 0)
13870 if (strcmp(oprkind,
"l") == 0 ||
13871 strcmp(oprkind,
"b") == 0)
13893 if (strcmp(oprcanmerge,
"t") == 0)
13896 if (strcmp(oprcanhash,
"t") == 0)
13923 "OPERATOR",
oprid->data,
13924 oprinfo->
dobj.namespace->dobj.
name);
13929 .namespace = oprinfo->
dobj.namespace->dobj.
name,
13931 .description =
"OPERATOR",
13933 .createStmt = q->
data,
13934 .dropStmt = delq->
data));
13968 if (strcmp(proc,
"-") == 0)
13974 for (paren =
name; *paren; paren++)
13976 if (*paren ==
'(' && !inquote)
13982 inquote = !inquote;
14007 if (strcmp(oproid,
"0") == 0)
14011 if (oprInfo == NULL)
14018 return psprintf(
"OPERATOR(%s.%s)",
14039 "SELECT '%u'::pg_catalog.regproc", funcOid);
14082 aminfo->
amtype, qamname);
14096 "ACCESS METHOD", qamname, NULL);
14101 .description =
"ACCESS METHOD",
14103 .createStmt = q->
data,
14104 .dropStmt = delq->
data));
14135 int i_opcfamilyname;
14136 int i_opcfamilynsp;
14138 int i_amopstrategy;
14141 int i_sortfamilynsp;
14144 int i_amproclefttype;
14145 int i_amprocrighttype;
14150 char *opcfamilyname;
14151 char *opcfamilynsp;
14153 char *amopstrategy;
14156 char *sortfamilynsp;
14159 char *amproclefttype;
14160 char *amprocrighttype;
14175 "opckeytype::pg_catalog.regtype, "
14176 "opcdefault, opcfamily, "
14177 "opfname AS opcfamilyname, "
14178 "nspname AS opcfamilynsp, "
14179 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS amname "
14180 "FROM pg_catalog.pg_opclass c "
14181 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily "
14182 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14183 "WHERE c.oid = '%u'::pg_catalog.oid",
14188 i_opcintype =
PQfnumber(res,
"opcintype");
14189 i_opckeytype =
PQfnumber(res,
"opckeytype");
14190 i_opcdefault =
PQfnumber(res,
"opcdefault");
14191 i_opcfamily =
PQfnumber(res,
"opcfamily");
14192 i_opcfamilyname =
PQfnumber(res,
"opcfamilyname");
14193 i_opcfamilynsp =
PQfnumber(res,
"opcfamilynsp");
14198 opckeytype =
PQgetvalue(res, 0, i_opckeytype);
14199 opcdefault =
PQgetvalue(res, 0, i_opcdefault);
14202 opcfamilyname =
PQgetvalue(res, 0, i_opcfamilyname);
14203 opcfamilynsp =
PQgetvalue(res, 0, i_opcfamilynsp);
14215 if (strcmp(opcdefault,
"t") == 0)
14220 if (strlen(opcfamilyname) > 0)
14230 if (strcmp(opckeytype,
"-") != 0)
14247 "amopopr::pg_catalog.regoperator, "
14248 "opfname AS sortfamily, "
14249 "nspname AS sortfamilynsp "
14250 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14251 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14252 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14253 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14254 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14255 "AND refobjid = '%u'::pg_catalog.oid "
14256 "AND amopfamily = '%s'::pg_catalog.oid "
14257 "ORDER BY amopstrategy",
14265 i_amopstrategy =
PQfnumber(res,
"amopstrategy");
14267 i_sortfamily =
PQfnumber(res,
"sortfamily");
14268 i_sortfamilynsp =
PQfnumber(res,
"sortfamilynsp");
14270 for (
i = 0;
i < ntups;
i++)
14272 amopstrategy =
PQgetvalue(res,
i, i_amopstrategy);
14275 sortfamilynsp =
PQgetvalue(res,
i, i_sortfamilynsp);
14281 amopstrategy, amopopr);
14283 if (strlen(sortfamily) > 0)
14308 "amproc::pg_catalog.regprocedure, "
14309 "amproclefttype::pg_catalog.regtype, "
14310 "amprocrighttype::pg_catalog.regtype "
14311 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14312 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14313 "AND refobjid = '%u'::pg_catalog.oid "
14314 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14315 "AND objid = ap.oid "
14316 "ORDER BY amprocnum",
14323 i_amprocnum =
PQfnumber(res,
"amprocnum");
14325 i_amproclefttype =
PQfnumber(res,
"amproclefttype");
14326 i_amprocrighttype =
PQfnumber(res,
"amprocrighttype");
14328 for (
i = 0;
i < ntups;
i++)
14332 amproclefttype =
PQgetvalue(res,
i, i_amproclefttype);
14333 amprocrighttype =
PQgetvalue(res,
i, i_amprocrighttype);
14340 if (*amproclefttype && *amprocrighttype)
14367 "OPERATOR CLASS", nameusing->
data,
14368 opcinfo->
dobj.namespace->dobj.
name);
14373 .namespace = opcinfo->
dobj.namespace->dobj.
name,
14375 .description =
"OPERATOR CLASS",
14377 .createStmt = q->
data,
14378 .dropStmt = delq->
data));
14415 int i_amopstrategy;
14418 int i_sortfamilynsp;
14421 int i_amproclefttype;
14422 int i_amprocrighttype;
14424 char *amopstrategy;
14427 char *sortfamilynsp;
14430 char *amproclefttype;
14431 char *amprocrighttype;
14449 "amopopr::pg_catalog.regoperator, "
14450 "opfname AS sortfamily, "
14451 "nspname AS sortfamilynsp "
14452 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14453 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14454 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14455 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14456 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14457 "AND refobjid = '%u'::pg_catalog.oid "
14458 "AND amopfamily = '%u'::pg_catalog.oid "
14459 "ORDER BY amopstrategy",
14468 "amproc::pg_catalog.regprocedure, "
14469 "amproclefttype::pg_catalog.regtype, "
14470 "amprocrighttype::pg_catalog.regtype "
14471 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14472 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14473 "AND refobjid = '%u'::pg_catalog.oid "
14474 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14475 "AND objid = ap.oid "
14476 "ORDER BY amprocnum",
14485 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opfmethod) AS amname "
14486 "FROM pg_catalog.pg_opfamily "
14487 "WHERE oid = '%u'::pg_catalog.oid",
14525 i_amopstrategy =
PQfnumber(res_ops,
"amopstrategy");
14526 i_amopopr =
PQfnumber(res_ops,
"amopopr");
14527 i_sortfamily =
PQfnumber(res_ops,
"sortfamily");
14528 i_sortfamilynsp =
PQfnumber(res_ops,
"sortfamilynsp");
14530 for (
i = 0;
i < ntups;
i++)
14532 amopstrategy =
PQgetvalue(res_ops,
i, i_amopstrategy);
14534 sortfamily =
PQgetvalue(res_ops,
i, i_sortfamily);
14535 sortfamilynsp =
PQgetvalue(res_ops,
i, i_sortfamilynsp);
14541 amopstrategy, amopopr);
14543 if (strlen(sortfamily) > 0)
14558 i_amprocnum =
PQfnumber(res_procs,
"amprocnum");
14559 i_amproc =
PQfnumber(res_procs,
"amproc");
14560 i_amproclefttype =
PQfnumber(res_procs,
"amproclefttype");
14561 i_amprocrighttype =
PQfnumber(res_procs,
"amprocrighttype");
14563 for (
i = 0;
i < ntups;
i++)
14565 amprocnum =
PQgetvalue(res_procs,
i, i_amprocnum);
14567 amproclefttype =
PQgetvalue(res_procs,
i, i_amproclefttype);
14568 amprocrighttype =
PQgetvalue(res_procs,
i, i_amprocrighttype);
14574 amprocnum, amproclefttype, amprocrighttype,
14589 "OPERATOR FAMILY", nameusing->
data,
14590 opfinfo->
dobj.namespace->dobj.
name);
14595 .namespace = opfinfo->
dobj.namespace->dobj.
name,
14597 .description =
"OPERATOR FAMILY",
14599 .createStmt = q->
data,
14600 .dropStmt = delq->
data));
14630 int i_collprovider;
14631 int i_collisdeterministic;
14635 int i_collicurules;
14636 const char *collprovider;
14637 const char *collcollate;
14638 const char *collctype;
14639 const char *colllocale;
14640 const char *collicurules;
14661 "'c' AS collprovider, "
14662 "NULL AS collversion, ");
14666 "collisdeterministic, ");
14669 "true AS collisdeterministic, ");
14676 "colliculocale AS colllocale, ");
14679 "NULL AS colllocale, ");
14686 "NULL AS collicurules, ");
14691 "FROM pg_catalog.pg_collation c "
14692 "WHERE c.oid = '%u'::pg_catalog.oid",
14697 i_collprovider =
PQfnumber(res,
"collprovider");
14698 i_collisdeterministic =
PQfnumber(res,
"collisdeterministic");
14699 i_collcollate =
PQfnumber(res,
"collcollate");
14700 i_collctype =
PQfnumber(res,
"collctype");
14701 i_colllocale =
PQfnumber(res,
"colllocale");
14702 i_collicurules =
PQfnumber(res,
"collicurules");
14704 collprovider =
PQgetvalue(res, 0, i_collprovider);
14707 collcollate =
PQgetvalue(res, 0, i_collcollate);
14709 collcollate = NULL;
14712 collctype =
PQgetvalue(res, 0, i_collctype);
14722 if (collcollate[0] ==
'\0')
14723 collcollate = NULL;
14724 if (collctype[0] ==
'\0')
14729 colllocale =
PQgetvalue(res, 0, i_colllocale);
14734 collicurules =
PQgetvalue(res, 0, i_collicurules);
14736 collicurules = NULL;
14745 if (collprovider[0] ==
'b')
14747 else if (collprovider[0] ==
'c')
14749 else if (collprovider[0] ==
'i')
14751 else if (collprovider[0] ==
'd')
14755 pg_fatal(
"unrecognized collation provider: %s",
14758 if (strcmp(
PQgetvalue(res, 0, i_collisdeterministic),
"f") == 0)
14761 if (collprovider[0] ==
'd')
14763 if (collcollate || collctype || colllocale || collicurules)
14768 else if (collprovider[0] ==
'b')
14770 if (collcollate || collctype || !colllocale || collicurules)
14777 else if (collprovider[0] ==
'i')
14781 if (collcollate || collctype || !colllocale)
14790 if (!collcollate || !collctype || colllocale ||
14791 strcmp(collcollate, collctype) != 0)
14804 else if (collprovider[0] ==
'c')
14806 if (colllocale || collicurules || !collcollate || !collctype)
14809 if (collcollate && collctype && strcmp(collcollate, collctype) == 0)
14823 pg_fatal(
"unrecognized collation provider: %s", collprovider);
14833 i_collversion =
PQfnumber(res,
"collversion");
14847 "COLLATION", qcollname,
14848 collinfo->
dobj.namespace->dobj.
name);
14853 .namespace = collinfo->
dobj.namespace->dobj.
name,
14855 .description =
"COLLATION",
14857 .createStmt = q->
data,
14858 .dropStmt = delq->
data));
14887 int i_conforencoding;
14888 int i_contoencoding;
14891 const char *conforencoding;
14892 const char *contoencoding;
14893 const char *conproc;
14908 "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
14909 "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
14910 "conproc, condefault "
14911 "FROM pg_catalog.pg_conversion c "
14912 "WHERE c.oid = '%u'::pg_catalog.oid",
14917 i_conforencoding =
PQfnumber(res,
"conforencoding");
14918 i_contoencoding =
PQfnumber(res,
"contoencoding");
14920 i_condefault =
PQfnumber(res,
"condefault");
14922 conforencoding =
PQgetvalue(res, 0, i_conforencoding);
14923 contoencoding =
PQgetvalue(res, 0, i_contoencoding);
14925 condefault = (
PQgetvalue(res, 0, i_condefault)[0] ==
't');
14931 (condefault) ?
"DEFAULT " :
"",
14941 "CONVERSION", qconvname,
14942 convinfo->
dobj.namespace->dobj.
name);
14947 .namespace = convinfo->
dobj.namespace->dobj.
name,
14949 .description =
"CONVERSION",
14951 .createStmt = q->
data,
14952 .dropStmt = delq->
data));
14986 if (agginfo->aggfn.nargs == 0)
14991 for (
j = 0;
j < agginfo->aggfn.nargs;
j++)
14993 (
j > 0) ?
", " :
"",
14995 agginfo->aggfn.argtypes[
j],
15015 char *aggfullsig = NULL;
15020 const char *aggtransfn;
15021 const char *aggfinalfn;
15022 const char *aggcombinefn;
15023 const char *aggserialfn;
15024 const char *aggdeserialfn;
15025 const char *aggmtransfn;
15026 const char *aggminvtransfn;
15027 const char *aggmfinalfn;
15028 bool aggfinalextra;
15029 bool aggmfinalextra;
15030 char aggfinalmodify;
15031 char aggmfinalmodify;
15032 const char *aggsortop;
15033 char *aggsortconvop;
15035 const char *aggtranstype;
15036 const char *aggtransspace;
15037 const char *aggmtranstype;
15038 const char *aggmtransspace;
15039 const char *agginitval;
15040 const char *aggminitval;
15041 const char *proparallel;
15042 char defaultfinalmodify;
15057 "PREPARE dumpAgg(pg_catalog.oid) AS\n");
15063 "aggtranstype::pg_catalog.regtype,\n"
15066 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
15067 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
15073 "aggminvtransfn,\n"
15075 "aggmtranstype::pg_catalog.regtype,\n"
15077 "aggmfinalextra,\n"
15079 "aggmtransspace,\n"
15083 "'n' AS aggkind,\n"
15084 "'-' AS aggmtransfn,\n"
15085 "'-' AS aggminvtransfn,\n"
15086 "'-' AS aggmfinalfn,\n"
15087 "0 AS aggmtranstype,\n"
15088 "false AS aggfinalextra,\n"
15089 "false AS aggmfinalextra,\n"
15090 "0 AS aggtransspace,\n"
15091 "0 AS aggmtransspace,\n"
15092 "NULL AS aggminitval,\n");
15102 "'-' AS aggcombinefn,\n"
15103 "'-' AS aggserialfn,\n"
15104 "'-' AS aggdeserialfn,\n"
15105 "'u' AS proparallel,\n");
15109 "aggfinalmodify,\n"
15110 "aggmfinalmodify\n");
15113 "'0' AS aggfinalmodify,\n"
15114 "'0' AS aggmfinalmodify\n");
15117 "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
15118 "WHERE a.aggfnoid = p.oid "
15127 "EXECUTE dumpAgg('%u')",
15128 agginfo->aggfn.dobj.catId.oid);
15132 i_agginitval =
PQfnumber(res,
"agginitval");
15133 i_aggminitval =
PQfnumber(res,
"aggminitval");
15153 agginitval =
PQgetvalue(res, 0, i_agginitval);
15154 aggminitval =
PQgetvalue(res, 0, i_aggminitval);
15170 defaultfinalmodify = (aggkind == AGGKIND_NORMAL) ? AGGMODIFY_READ_ONLY : AGGMODIFY_READ_WRITE;
15172 if (aggfinalmodify ==
'0')
15173 aggfinalmodify = defaultfinalmodify;
15174 if (aggmfinalmodify ==
'0')
15175 aggmfinalmodify = defaultfinalmodify;
15179 aggtransfn, aggtranstype);
15181 if (strcmp(aggtransspace,
"0") != 0)
15193 if (strcmp(aggfinalfn,
"-") != 0)
15199 if (aggfinalmodify != defaultfinalmodify)
15201 switch (aggfinalmodify)
15203 case AGGMODIFY_READ_ONLY:
15206 case AGGMODIFY_SHAREABLE:
15209 case AGGMODIFY_READ_WRITE:
15213 pg_fatal(
"unrecognized aggfinalmodify value for aggregate \"%s\"",
15214 agginfo->aggfn.dobj.name);
15220 if (strcmp(aggcombinefn,
"-") != 0)
15223 if (strcmp(aggserialfn,
"-") != 0)
15226 if (strcmp(aggdeserialfn,
"-") != 0)
15229 if (strcmp(aggmtransfn,
"-") != 0)
15237 if (strcmp(aggmtransspace,
"0") != 0)
15249 if (strcmp(aggmfinalfn,
"-") != 0)
15253 if (aggmfinalextra)
15255 if (aggmfinalmodify != defaultfinalmodify)
15257 switch (aggmfinalmodify)
15259 case AGGMODIFY_READ_ONLY:
15262 case AGGMODIFY_SHAREABLE:
15265 case AGGMODIFY_READ_WRITE:
15269 pg_fatal(
"unrecognized aggmfinalmodify value for aggregate \"%s\"",
15270 agginfo->aggfn.dobj.name);
15281 free(aggsortconvop);
15284 if (aggkind == AGGKIND_HYPOTHETICAL)
15287 if (proparallel[0] != PROPARALLEL_UNSAFE)
15289 if (proparallel[0] == PROPARALLEL_SAFE)
15291 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
15293 else if (proparallel[0] != PROPARALLEL_UNSAFE)
15294 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
15295 agginfo->aggfn.dobj.name);
15299 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
15303 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
15304 aggfullsig ? aggfullsig : aggsig, details->
data);
15308 "AGGREGATE", aggsig,
15309 agginfo->aggfn.dobj.namespace->dobj.name);
15313 agginfo->aggfn.dobj.dumpId,
15315 .
namespace = agginfo->aggfn.dobj.namespace->dobj.name,
15316 .owner = agginfo->aggfn.rolname,
15317 .description =
"AGGREGATE",
15319 .createStmt = q->
data,
15320 .dropStmt = delq->
data));
15325 agginfo->aggfn.dobj.namespace->dobj.name,
15326 agginfo->aggfn.rolname,
15327 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
15331 agginfo->aggfn.dobj.namespace->dobj.name,
15332 agginfo->aggfn.rolname,
15333 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
15346 "FUNCTION", aggsig, NULL,
15347 agginfo->aggfn.dobj.namespace->dobj.name,
15348 NULL, agginfo->aggfn.rolname, &agginfo->aggfn.dacl);
15403 "TEXT SEARCH PARSER", qprsname,
15404 prsinfo->
dobj.namespace->dobj.
name);
15409 .namespace = prsinfo->
dobj.namespace->dobj.
name,
15410 .description =
"TEXT SEARCH PARSER",
15412 .createStmt = q->
data,
15413 .dropStmt = delq->
data));
15417 dumpComment(fout,
"TEXT SEARCH PARSER", qprsname,
15418 prsinfo->
dobj.namespace->dobj.
name,
"",
15454 "FROM pg_ts_template p, pg_namespace n "
15455 "WHERE p.oid = '%u' AND n.oid = tmplnamespace",
15481 "TEXT SEARCH DICTIONARY", qdictname,
15482 dictinfo->
dobj.namespace->dobj.
name);
15487 .namespace = dictinfo->
dobj.namespace->dobj.
name,
15489 .description =
"TEXT SEARCH DICTIONARY",
15491 .createStmt = q->
data,
15492 .dropStmt = delq->
data));
15496 dumpComment(fout,
"TEXT SEARCH DICTIONARY", qdictname,
15541 "TEXT SEARCH TEMPLATE", qtmplname,
15542 tmplinfo->
dobj.namespace->dobj.
name);
15547 .namespace = tmplinfo->
dobj.namespace->dobj.
name,
15548 .description =
"TEXT SEARCH TEMPLATE",
15550 .createStmt = q->
data,
15551 .dropStmt = delq->
data));
15555 dumpComment(fout,
"TEXT SEARCH TEMPLATE", qtmplname,
15556 tmplinfo->
dobj.namespace->dobj.
name,
"",
15596 "FROM pg_ts_parser p, pg_namespace n "
15597 "WHERE p.oid = '%u' AND n.oid = prsnamespace",
15614 " ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
15615 " WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
15616 " m.mapdict::pg_catalog.regdictionary AS dictname\n"
15617 "FROM pg_catalog.pg_ts_config_map AS m\n"
15618 "WHERE m.mapcfg = '%u'\n"
15619 "ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
15625 i_tokenname =
PQfnumber(res,
"tokenname");
15626 i_dictname =
PQfnumber(res,
"dictname");
15628 for (
i = 0;
i < ntups;
i++)
15630 char *tokenname =
PQgetvalue(res,
i, i_tokenname);
15634 strcmp(tokenname,
PQgetvalue(res,
i - 1, i_tokenname)) != 0)
15643 fmtId(tokenname), dictname);
15659 "TEXT SEARCH CONFIGURATION", qcfgname,
15660 cfginfo->
dobj.namespace->dobj.
name);
15665 .namespace = cfginfo->
dobj.namespace->dobj.
name,
15667 .description =
"TEXT SEARCH CONFIGURATION",
15669 .createStmt = q->
data,
15670 .dropStmt = delq->
data));
15674 dumpComment(fout,
"TEXT SEARCH CONFIGURATION", qcfgname,
15724 "FOREIGN DATA WRAPPER", qfdwname,
15731 .description =
"FOREIGN DATA WRAPPER",
15733 .createStmt = q->
data,
15734 .dropStmt = delq->
data));
15738 dumpComment(fout,
"FOREIGN DATA WRAPPER", qfdwname,
15745 "FOREIGN DATA WRAPPER", qfdwname, NULL, NULL,
15781 "FROM pg_foreign_data_wrapper w "
15782 "WHERE w.oid = '%u'",
15812 "SERVER", qsrvname, NULL);
15818 .description =
"SERVER",
15820 .createStmt = q->
data,
15821 .dropStmt = delq->
data));
15832 "FOREIGN SERVER", qsrvname, NULL, NULL,
15860 const char *servername,
const char *
namespace,
15889 "array_to_string(ARRAY("
15890 "SELECT quote_ident(option_name) || ' ' || "
15891 "quote_literal(option_value) "
15892 "FROM pg_options_to_table(umoptions) "
15893 "ORDER BY option_name"
15894 "), E',\n ') AS umoptions "
15895 "FROM pg_user_mappings "
15896 "WHERE srvid = '%u' "
15897 "ORDER BY usename",
15904 i_umoptions =
PQfnumber(res,
"umoptions");
15906 for (
i = 0;
i < ntups;
i++)
15918 if (umoptions && strlen(umoptions) > 0)
15929 usename, servername);
15933 .namespace =
namespace,
15935 .description =
"USER MAPPING",
15937 .createStmt = q->
data,
15938 .dropStmt = delq->
data));
15969 case DEFACLOBJ_RELATION:
15972 case DEFACLOBJ_SEQUENCE:
15973 type =
"SEQUENCES";
15975 case DEFACLOBJ_FUNCTION:
15976 type =
"FUNCTIONS";
15978 case DEFACLOBJ_TYPE:
15981 case DEFACLOBJ_NAMESPACE:
15984 case DEFACLOBJ_LARGEOBJECT:
15985 type =
"LARGE OBJECTS";
15989 pg_fatal(
"unrecognized object type in default privileges: %d",
15998 daclinfo->
dobj.namespace != NULL ?
15999 daclinfo->
dobj.namespace->dobj.
name : NULL,
16005 pg_fatal(
"could not parse default ACL list (%s)",
16011 .namespace = daclinfo->
dobj.namespace ?
16012 daclinfo->
dobj.namespace->dobj.
name : NULL,
16014 .description =
"DEFAULT ACL",
16016 .createStmt = q->
data));
16047 const char *nspname,
const char *tag,
const char *owner,
16052 const char *acls = dacl->
acl;
16055 const char *initprivs = dacl->
initprivs;
16056 const char *baseacls;
16083 initprivs && *initprivs !=
'\0')
16089 pg_fatal(
"could not parse initial ACL list (%s) or default (%s) for object \"%s\" (%s)",
16091 appendPQExpBufferStr(sql,
"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
16102 if (initprivs && *initprivs !=
'\0')
16104 baseacls = initprivs;
16105 if (acls == NULL || *acls ==
'\0')
16112 acls, baseacls, owner,
16114 pg_fatal(
"could not parse ACL list (%s) or default (%s) for object \"%s\" (%s)",
16130 aclDeps[nDeps++] = objDumpId;
16132 aclDeps[nDeps++] = altDumpId;
16138 .namespace = nspname,
16140 .description =
"ACL",
16142 .createStmt = sql->
data,
16174 const char *
namespace,
const char *owner,
16191 if (strcmp(
type,
"LARGE OBJECT") != 0)
16208 for (
i = 0;
i < nlabels;
i++)
16213 if (labels[
i].objsubid != subid)
16217 "SECURITY LABEL FOR %s ON %s ",
16219 if (
namespace && *
namespace)
16226 if (query->
len > 0)
16233 .namespace =
namespace,
16235 .description =
"SECURITY LABEL",
16237 .createStmt = query->
data,
16282 for (
i = 0;
i < nlabels;
i++)
16284 const char *colname;
16308 if (query->
len > 0)
16315 .namespace = tbinfo->
dobj.namespace->dobj.
name,
16317 .description =
"SECURITY LABEL",
16319 .createStmt = query->
data,
16353 while (low <= high)
16355 middle = low + (high - low) / 2;
16357 if (classoid < middle->classoid)
16359 else if (classoid > middle->
classoid)
16361 else if (objoid < middle->objoid)
16363 else if (objoid > middle->
objoid)
16381 while (middle > low)
16383 if (classoid != middle[-1].classoid ||
16384 objoid != middle[-1].objoid)
16393 while (middle <= high)
16395 if (classoid != middle->
classoid ||
16396 objoid != middle->
objoid)
16430 "SELECT label, provider, classoid, objoid, objsubid "
16431 "FROM pg_catalog.pg_seclabel "
16432 "ORDER BY classoid, objoid, objsubid");
16438 i_provider =
PQfnumber(res,
"provider");
16439 i_classoid =
PQfnumber(res,
"classoid");
16441 i_objsubid =
PQfnumber(res,
"objsubid");
16449 for (
i = 0;
i < ntups;
i++)
16459 if (dobj == NULL ||
16472 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
16512 if (tbinfo->
relkind == RELKIND_SEQUENCE)
16522 const char *objtype =
16523 (tbinfo->
relkind == RELKIND_SEQUENCE) ?
"SEQUENCE" :
"TABLE";
16527 objtype, namecopy, NULL,
16528 tbinfo->
dobj.namespace->dobj.
name,
16548 "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
16563 "SELECT at.attname, "
16565 "'{}' AS acldefault, "
16566 "pip.privtype, pip.initprivs "
16567 "FROM pg_catalog.pg_attribute at "
16568 "LEFT JOIN pg_catalog.pg_init_privs pip ON "
16569 "(at.attrelid = pip.objoid "
16570 "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
16571 "AND at.attnum = pip.objsubid) "
16572 "WHERE at.attrelid = $1 AND "
16573 "NOT at.attisdropped "
16574 "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
16575 "ORDER BY at.attnum");
16580 "SELECT attname, attacl, '{}' AS acldefault, "
16581 "NULL AS privtype, NULL AS initprivs "
16582 "FROM pg_catalog.pg_attribute "
16583 "WHERE attrelid = $1 AND NOT attisdropped "
16584 "AND attacl IS NOT NULL "
16585 "ORDER BY attnum");
16594 "EXECUTE getColumnACLs('%u')",
16609 coldacl.
acl = attacl;
16621 "TABLE", namecopy, attnamecopy,
16622 tbinfo->
dobj.namespace->dobj.
name,
16623 NULL, tbinfo->
rolname, &coldacl);
16649 "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
16657 pg_fatal(
"query to obtain definition of view \"%s\" returned no data",
16660 pg_fatal(
"query to obtain definition of view \"%s\" returned more than one definition",
16667 pg_fatal(
"definition of view \"%s\" appears to be empty (length zero)",
16740 const char *reltypename;
16752 pg_log_warning(
"WITH OIDS is not supported anymore (table \"%s\")",
16759 if (tbinfo->
relkind == RELKIND_VIEW)
16767 reltypename =
"VIEW";
16798 char *partkeydef = NULL;
16799 char *ftoptions = NULL;
16800 char *srvname = NULL;
16801 const char *foreign =
"";
16809 case RELKIND_PARTITIONED_TABLE:
16814 reltypename =
"TABLE";
16818 "SELECT pg_get_partkeydef('%u')",
16826 case RELKIND_FOREIGN_TABLE:
16833 reltypename =
"FOREIGN TABLE";
16837 "SELECT fs.srvname, "
16838 "pg_catalog.array_to_string(ARRAY("
16839 "SELECT pg_catalog.quote_ident(option_name) || "
16840 "' ' || pg_catalog.quote_literal(option_value) "
16841 "FROM pg_catalog.pg_options_to_table(ftoptions) "
16842 "ORDER BY option_name"
16843 "), E',\n ') AS ftoptions "
16844 "FROM pg_catalog.pg_foreign_table ft "
16845 "JOIN pg_catalog.pg_foreign_server fs "
16846 "ON (fs.oid = ft.ftserver) "
16847 "WHERE ft.ftrelid = '%u'",
16851 i_ftoptions =
PQfnumber(res,
"ftoptions");
16857 foreign =
"FOREIGN ";
16860 case RELKIND_MATVIEW:
16861 reltypename =
"MATERIALIZED VIEW";
16864 reltypename =
"TABLE";
16883 tbinfo->
relkind != RELKIND_PARTITIONED_TABLE) ?
16897 if (tbinfo->
relkind != RELKIND_MATVIEW)
16911 bool print_default;
16912 bool print_notnull;
16918 print_default = (tbinfo->
attrdefs[
j] != NULL &&
16937 !print_default && !print_notnull &&
16942 if (actual_atts == 0)
16981 else if (tbinfo->
attgenerated[
j] == ATTRIBUTE_GENERATED_VIRTUAL)
17029 if (actual_atts == 0)
17062 if (actual_atts == 0)
17093 for (k = 0; k < numParents; k++)
17104 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
17107 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
17114 bool addcomma =
false;
17133 if (ftoptions && ftoptions[0])
17140 if (tbinfo->
relkind == RELKIND_MATVIEW)
17153 if (tbinfo->
relkind == RELKIND_MATVIEW)
17155 "pg_catalog.pg_class",
17156 "MATERIALIZED VIEW",
17171 "SELECT pg_catalog.binary_upgrade_set_missing_value(");
17204 (tbinfo->
relkind == RELKIND_RELATION ||
17205 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ||
17206 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE))
17209 bool firstitem_extra;
17226 "UPDATE pg_catalog.pg_attribute\n"
17227 "SET attlen = v.dlen, "
17228 "attalign = v.dalign, "
17229 "attbyval = false\n"
17242 foreign, qualrelname);
17250 "WHERE attrelid = ");
17253 " AND attname = v.dname;\n");
17272 "SET attislocal = false\n"
17273 "WHERE attrelid = ");
17276 " AND attname IN (");
17294 firstitem_extra =
true;
17315 "SET conislocal = false\n"
17316 "WHERE contype = 'n' AND conrelid = ");
17328 if (firstitem_extra)
17331 "SET conislocal = false\n"
17332 "WHERE contype = 'n' AND conrelid = ");
17336 firstitem_extra =
false;
17346 if (!firstitem_extra)
17349 if (extra->
len > 0)
17366 for (k = 0; k < tbinfo->
ncheck; k++)
17376 foreign, qualrelname,
17383 "SET conislocal = false\n"
17384 "WHERE contype = 'c' AND conrelid = ");
17403 for (k = 0; k < numParents; k++)
17431 (tbinfo->
relkind == RELKIND_RELATION ||
17432 tbinfo->
relkind == RELKIND_MATVIEW))
17436 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17448 appendPQExpBufferStr(q,
"\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
17450 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17451 "WHERE oid = '%u';\n",
17469 "SET relispopulated = 't'\n"
17491 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STATISTICS %d;\n",
17492 foreign, qualrelname,
17504 case TYPSTORAGE_PLAIN:
17507 case TYPSTORAGE_EXTERNAL:
17510 case TYPSTORAGE_EXTENDED:
17513 case TYPSTORAGE_MAIN:
17524 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STORAGE %s;\n",
17525 foreign, qualrelname,
17535 const char *cmname;
17550 if (cmname != NULL)
17551 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET COMPRESSION %s;\n",
17552 foreign, qualrelname,
17562 foreign, qualrelname,
17569 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
17572 "ALTER FOREIGN TABLE ONLY %s ALTER COLUMN %s OPTIONS (\n"
17588 if ((tbinfo->
relkind == RELKIND_RELATION ||
17589 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ||
17590 tbinfo->
relkind == RELKIND_MATVIEW) &&
17597 else if (tbinfo->
relreplident == REPLICA_IDENTITY_NOTHING)
17602 else if (tbinfo->
relreplident == REPLICA_IDENTITY_FULL)
17615 reltypename, qrelname,
17616 tbinfo->
dobj.namespace->dobj.
name);
17621 char *tableam = NULL;
17630 if (RELKIND_HAS_TABLESPACE(tbinfo->
relkind))
17633 if (RELKIND_HAS_TABLE_AM(tbinfo->
relkind) ||
17634 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
17635 tableam = tbinfo->
amname;
17639 .namespace = tbinfo->
dobj.namespace->dobj.
name,
17641 .tableam = tableam,
17644 .description = reltypename,
17647 .createStmt = q->
data,
17648 .dropStmt = delq->
data));
17711 "PREPARE dumpTableAttach(pg_catalog.oid) AS\n");
17714 "SELECT pg_get_expr(c.relpartbound, c.oid) "
17716 "WHERE c.oid = $1");
17724 "EXECUTE dumpTableAttach('%u')",
17732 "ALTER TABLE ONLY %s ",
17735 "ATTACH PARTITION %s %s;\n",
17748 .namespace = attachinfo->
dobj.namespace->dobj.
name,
17750 .description =
"TABLE ATTACH",
17752 .createStmt = q->
data));
17766 int adnum = adinfo->
adnum;
17786 foreign = tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
17789 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET DEFAULT %s;\n",
17794 foreign, qualrelname,
17802 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
17804 .description =
"DEFAULT",
17806 .createStmt = q->
data,
17807 .dropStmt = delq->
data));
17825 if (attrnum > 0 && attrnum <= tblInfo->numatts)
17826 return tblInfo->
attnames[attrnum - 1];
17842 pg_fatal(
"invalid column number %d for table \"%s\"",
17879 if (!is_constraint)
17883 char **indstatcolsarray = NULL;
17884 char **indstatvalsarray = NULL;
17915 if (strlen(indstatcols) != 0 || strlen(indstatvals) != 0)
17919 if (!
parsePGArray(indstatcols, &indstatcolsarray, &nstatcols))
17920 pg_fatal(
"could not parse index statistic columns");
17921 if (!
parsePGArray(indstatvals, &indstatvalsarray, &nstatvals))
17922 pg_fatal(
"could not parse index statistic values");
17923 if (nstatcols != nstatvals)
17924 pg_fatal(
"mismatched number of columns and values for index statistics");
17926 for (
j = 0;
j < nstatcols;
j++)
17935 indstatcolsarray[
j]);
17937 indstatvalsarray[
j]);
17943 "pg_catalog.pg_class",
17944 "INDEX", qqindxname);
17961 .namespace = tbinfo->
dobj.namespace->dobj.
name,
17964 .description =
"INDEX",
17966 .createStmt = q->
data,
17967 .dropStmt = delq->
data));
17969 free(indstatcolsarray);
17970 free(indstatvalsarray);
17976 tbinfo->
dobj.namespace->dobj.
name,
18017 .namespace = attachinfo->
dobj.namespace->dobj.
name,
18019 .description =
"INDEX ATTACH",
18021 .createStmt = q->
data));
18038 char *qstatsextname;
18053 "pg_catalog.pg_get_statisticsobjdef('%u'::pg_catalog.oid)",
18082 .namespace = statsextinfo->
dobj.namespace->dobj.
name,
18083 .owner = statsextinfo->
rolname,
18084 .description =
"STATISTICS",
18086 .createStmt = q->
data,
18087 .dropStmt = delq->
data));
18092 statsextinfo->
dobj.namespace->dobj.
name,
18101 free(qstatsextname);
18125 foreign = tbinfo &&
18126 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
18128 if (coninfo->
contype ==
'p' ||
18138 if (indxinfo == NULL)
18139 pg_fatal(
"missing index for constraint \"%s\"",
18159 coninfo->
contype ==
'p' ?
"PRIMARY KEY" :
"UNIQUE");
18172 int indkey = (int) indxinfo->
indkeys[k];
18180 (k == 0) ?
"" :
", ",
18189 for (k = indxinfo->
indnkeyattrs; k < indxinfo->indnattrs; k++)
18191 int indkey = (int) indxinfo->
indkeys[k];
18250 "pg_catalog.pg_class",
"INDEX",
18263 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18266 .description =
"CONSTRAINT",
18268 .createStmt = q->
data,
18269 .dropStmt = delq->
data));
18271 else if (coninfo->
contype ==
'f')
18281 only = tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ?
"" :
"ONLY ";
18303 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18305 .description =
"FK CONSTRAINT",
18307 .createStmt = q->
data,
18308 .dropStmt = delq->
data));
18310 else if ((coninfo->
contype ==
'c' || coninfo->
contype ==
'n') && tbinfo)
18317 const char *keyword;
18320 keyword =
"CHECK CONSTRAINT";
18322 keyword =
"CONSTRAINT";
18341 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18343 .description = keyword,
18345 .createStmt = q->
data,
18346 .dropStmt = delq->
data));
18349 else if (coninfo->
contype ==
'c' && tbinfo == NULL)
18373 .
namespace = tyinfo->
dobj.namespace->dobj.
name,
18375 .description =
"CHECK CONSTRAINT",
18377 .createStmt = q->
data,
18378 .dropStmt = delq->
data));
18383 pg_fatal(
"unrecognized constraint type: %c",
18388 if (tbinfo && coninfo->
separate &&
18418 tbinfo->
dobj.namespace->dobj.
name,
18476 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
18477 "seqstart, seqincrement, "
18479 "seqcache, seqcycle, "
18481 "FROM pg_catalog.pg_sequence "
18482 "ORDER BY seqrelid";
18484 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
18485 "seqstart, seqincrement, "
18487 "seqcache, seqcycle, "
18488 "last_value, is_called "
18489 "FROM pg_catalog.pg_sequence, "
18490 "pg_get_sequence_data(seqrelid) "
18491 "ORDER BY seqrelid;";
18525 int64 default_minv,
18560 "SELECT 'bigint' AS sequence_type, "
18561 "start_value, increment_by, max_value, min_value, "
18562 "cache_value, is_cycled FROM %s",
18568 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
18569 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
18586 is_ascending = (seq->
incby >= 0);
18605 default_minv = default_maxv = 0;
18638 "ALTER COLUMN %s ADD GENERATED ",
18654 "UNLOGGED" :
"LOGGED");
18659 "CREATE %sSEQUENCE %s\n",
18672 if (seq->
minv != default_minv)
18677 if (seq->
maxv != default_maxv)
18695 "SEQUENCE", qseqname,
18696 tbinfo->
dobj.namespace->dobj.
name);
18701 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18703 .description =
"SEQUENCE",
18705 .createStmt = query->
data,
18706 .dropStmt = delqry->
data));
18724 if (owning_tab == NULL)
18725 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
18741 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18743 .description =
"SEQUENCE OWNED BY",
18745 .createStmt = query->
data,
18794 "SELECT last_value, is_called FROM %s",
18800 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
18801 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
18805 last = strtoi64(
PQgetvalue(res, 0, 0), NULL, 10);
18806 called = (strcmp(
PQgetvalue(res, 0, 1),
"t") == 0);
18830 last, (called ?
"true" :
"false"));
18835 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18837 .description =
"SEQUENCE SET",
18839 .createStmt = query->
data,
18881 "pg_catalog.pg_trigger",
"TRIGGER",
18882 trigidentity->
data);
18897 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
18922 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
18952 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18954 .description =
"TRIGGER",
18956 .createStmt = query->
data,
18957 .dropStmt = delqry->
data));
18998 if (strcmp(
"", evtinfo->
evttags) != 0)
19036 "EVENT TRIGGER", qevtname, NULL);
19042 .description =
"EVENT TRIGGER",
19044 .createStmt = query->
data,
19045 .dropStmt = delqry->
data));
19127 "SELECT pg_catalog.pg_get_ruledef('%u'::pg_catalog.oid)",
19133 pg_fatal(
"query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
19196 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
19198 .description =
"RULE",
19200 .createStmt = cmd->
data,
19201 .dropStmt = delcmd->
data));
19206 tbinfo->
dobj.namespace->dobj.
name,
19242 if (numExtensions == 0)
19249 "classid, objid, refobjid "
19251 "WHERE refclassid = 'pg_extension'::regclass "
19252 "AND deptype = 'e' "
19261 i_refobjid =
PQfnumber(res,
"refobjid");
19270 for (
i = 0;
i < ntups;
i++)
19286 pg_log_warning(
"could not find referenced extension %u", extId);
19334 if (numExtensions == 0)
19348 for (
i = 0;
i < numExtensions;
i++)
19353 char **extconfigarray = NULL;
19354 char **extconditionarray = NULL;
19355 int nconfigitems = 0;
19356 int nconditionitems = 0;
19376 if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
19380 if (!
parsePGArray(extconfig, &extconfigarray, &nconfigitems))
19381 pg_fatal(
"could not parse %s array",
"extconfig");
19382 if (!
parsePGArray(extcondition, &extconditionarray, &nconditionitems))
19383 pg_fatal(
"could not parse %s array",
"extcondition");
19384 if (nconfigitems != nconditionitems)
19385 pg_fatal(
"mismatched number of configurations and conditions for extension");
19387 for (
j = 0;
j < nconfigitems;
j++)
19390 Oid configtbloid =
atooid(extconfigarray[
j]);
19395 if (configtbl == NULL)
19411 if (configtbl->
dobj.namespace->dobj.
dump &
19430 if (configtbl->
dataObj != NULL)
19432 if (strlen(extconditionarray[
j]) > 0)
19438 if (extconfigarray)
19439 free(extconfigarray);
19440 if (extconditionarray)
19441 free(extconditionarray);
19456 "SELECT conrelid, confrelid "
19457 "FROM pg_constraint "
19458 "JOIN pg_depend ON (objid = confrelid) "
19459 "WHERE contype = 'f' "
19460 "AND refclassid = 'pg_extension'::regclass "
19461 "AND classid = 'pg_class'::regclass;");
19466 i_conrelid =
PQfnumber(res,
"conrelid");
19467 i_confrelid =
PQfnumber(res,
"confrelid");
19470 for (
i = 0;
i < ntups;
i++)
19482 if (reftable == NULL ||
19484 contable == NULL ||
19530 "classid, objid, refclassid, refobjid, deptype "
19532 "WHERE deptype != 'p' AND deptype != 'e'\n");
19545 "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
19546 "FROM pg_depend d, pg_amop o "
19547 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
19548 "classid = 'pg_amop'::regclass AND objid = o.oid "
19549 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
19553 "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
19554 "FROM pg_depend d, pg_amproc p "
19555 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
19556 "classid = 'pg_amproc'::regclass AND objid = p.oid "
19557 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
19568 i_refclassid =
PQfnumber(res,
"refclassid");
19569 i_refobjid =
PQfnumber(res,
"refobjid");
19579 for (
i = 0;
i < ntups;
i++)
19591 if (dobj == NULL ||
19611 if (refdobj == NULL)
19626 if (deptype ==
'x')
19636 if (deptype ==
'i' &&
19687 for (
i = 0;
i < numObjs;
i++)
19751 if (((
RuleInfo *) dobj)->separate)
19830 if (dobj->
nDeps <= 0)
19838 &dependencies, &nDeps, &allocDeps);
19843 nDeps *
sizeof(
DumpId));
19848 free(dependencies);
19855 DumpId **dependencies,
int *nDeps,
int *allocDeps)
19874 if (*nDeps >= *allocDeps)
19878 *allocDeps *
sizeof(
DumpId));
19880 (*dependencies)[*nDeps] = depid;
19894 dependencies, nDeps, allocDeps);
19927 if (typeInfo && typeInfo->
ftypname)
19931 appendPQExpBuffer(query,
"SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
19972 for (
i = 0;
i < numatts;
i++)
19974 if (attisdropped[
i])
19976 if (attgenerated[
i])
19988 return buffer->
data;
19998 return (reloptions != NULL && strlen(reloptions) > 2);
20008 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)