44#include "catalog/pg_aggregate_d.h"
45#include "catalog/pg_am_d.h"
46#include "catalog/pg_attribute_d.h"
47#include "catalog/pg_authid_d.h"
48#include "catalog/pg_cast_d.h"
49#include "catalog/pg_class_d.h"
50#include "catalog/pg_constraint_d.h"
51#include "catalog/pg_default_acl_d.h"
52#include "catalog/pg_largeobject_d.h"
53#include "catalog/pg_largeobject_metadata_d.h"
54#include "catalog/pg_proc_d.h"
55#include "catalog/pg_publication_d.h"
56#include "catalog/pg_shdepend_d.h"
57#include "catalog/pg_subscription_d.h"
58#include "catalog/pg_type_d.h"
126 "array length mismatch");
222#define MAX_ATTR_STATS_RELS 64
228#define DUMP_DEFAULT_ROWS_PER_INSERT 1
235#define MAX_BLOBS_PER_ARCHIVE_ENTRY 1000
240#define fmtQualifiedDumpable(obj) \
241 fmtQualifiedId((obj)->dobj.namespace->dobj.name, \
246 const char *dumpencoding,
const char *dumpsnapshot,
264 bool with_child_tables);
266 const char *pattern);
271static const char *
getRoleName(
const char *roleoid_str);
275 const char *
name,
const char *
namespace,
278 const char *initdb_comment);
280 const char *
name,
const char *
namespace,
282 int subid,
DumpId dumpId);
286 const char *
namespace,
const char *owner,
336 const char *servername,
const char *
namespace,
342 const char *nspname,
const char *tag,
const char *owner,
348 DumpId **dependencies,
int *nDeps,
int *allocDeps);
363 int i_notnull_comment,
364 int i_notnull_invalidoid,
365 int i_notnull_noinherit,
366 int i_notnull_islocal,
371 const FuncInfo *finfo,
bool honor_quotes);
393 bool force_array_type,
394 bool include_multirange_type);
406 const char *objnamespace);
411 const char *prefix,
Archive *fout);
435 bool g_verbose =
false;
436 const char *dumpencoding = NULL;
437 const char *dumpsnapshot = NULL;
438 char *use_role = NULL;
444 char *compression_detail = NULL;
445 char *compression_algorithm_str =
"none";
446 char *error_detail = NULL;
447 bool user_compression_defined =
false;
449 bool data_only =
false;
450 bool schema_only =
false;
459 static struct option long_options[] = {
472 {
"jobs", 1, NULL,
'j'},
559 if (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-?") == 0)
564 if (strcmp(argv[1],
"--version") == 0 || strcmp(argv[1],
"-V") == 0)
566 puts(
"pg_dump (PostgreSQL) " PG_VERSION);
573 while ((
c =
getopt_long(argc, argv,
"abBcCd:e:E:f:F:h:j:n:N:Op:RsS:t:T:U:vwWxXZ:",
574 long_options, &optindex)) != -1)
691 &compression_detail);
692 user_compression_defined =
true;
822 pg_log_error(
"too many command-line arguments (first is \"%s\")",
833 if (data_only && schema_only)
834 pg_fatal(
"options -s/--schema-only and -a/--data-only cannot be used together");
836 pg_fatal(
"options -s/--schema-only and --statistics-only cannot be used together");
838 pg_fatal(
"options -a/--data-only and --statistics-only cannot be used together");
842 pg_fatal(
"options -a/--data-only and --no-data cannot be used together");
844 pg_fatal(
"options -s/--schema-only and --no-schema cannot be used together");
846 pg_fatal(
"options --statistics-only and --no-statistics cannot be used together");
850 pg_fatal(
"options --statistics and --no-statistics cannot be used together");
854 pg_fatal(
"options %s and %s cannot be used together",
855 "-a/--data-only",
"--statistics");
857 pg_fatal(
"options %s and %s cannot be used together",
858 "-s/--schema-only",
"--statistics");
861 pg_fatal(
"options -s/--schema-only and --include-foreign-data cannot be used together");
864 pg_fatal(
"option --include-foreign-data is not supported with parallel backup");
867 pg_fatal(
"options -c/--clean and -a/--data-only cannot be used together");
870 pg_fatal(
"option --if-exists requires option -c/--clean");
890 pg_fatal(
"option --on-conflict-do-nothing requires option --inserts, --rows-per-insert, or --column-inserts");
906 pg_fatal(
"could not generate restrict key");
911 pg_fatal(
"option --restrict-key can only be used with --format=plain");
919 !user_compression_defined)
922 compression_algorithm_str =
"gzip";
924 compression_algorithm_str =
"none";
933 pg_fatal(
"unrecognized compression algorithm: \"%s\"",
934 compression_algorithm_str);
939 if (error_detail != NULL)
940 pg_fatal(
"invalid compression specification: %s",
944 if (error_detail != NULL)
953 pg_log_warning(
"compression option \"%s\" is not currently supported by pg_dump",
965 pg_fatal(
"parallel backup only supported by the directory format");
1020 pg_fatal(
"no matching schemas were found");
1037 pg_fatal(
"no matching tables were found");
1065 pg_fatal(
"no matching extensions were found");
1104 getTableData(&dopt, tblinfo, numTables, RELKIND_SEQUENCE);
1132 "AND dbid = (SELECT oid FROM pg_database "
1133 " WHERE datname = current_database())";
1147 "(SELECT objoid FROM pg_description "
1148 "WHERE classoid = " CppAsString2(LargeObjectRelationId)
" "
1149 "UNION SELECT objoid FROM pg_seclabel "
1150 "WHERE classoid = " CppAsString2(LargeObjectRelationId)
")";
1207 boundaryObjs[0].dumpId, boundaryObjs[1].dumpId);
1226 for (
i = 0;
i < numObjs;
i++)
1306 printf(
_(
"%s exports a PostgreSQL database as an SQL script or to other formats.\n\n"),
progname);
1310 printf(
_(
"\nGeneral options:\n"));
1311 printf(
_(
" -f, --file=FILENAME output file or directory name\n"));
1312 printf(
_(
" -F, --format=c|d|t|p output file format (custom, directory, tar,\n"
1313 " plain text (default))\n"));
1314 printf(
_(
" -j, --jobs=NUM use this many parallel jobs to dump\n"));
1315 printf(
_(
" -v, --verbose verbose mode\n"));
1316 printf(
_(
" -V, --version output version information, then exit\n"));
1317 printf(
_(
" -Z, --compress=METHOD[:DETAIL]\n"
1318 " compress as specified\n"));
1319 printf(
_(
" --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock\n"));
1320 printf(
_(
" --no-sync do not wait for changes to be written safely to disk\n"));
1321 printf(
_(
" --sync-method=METHOD set method for syncing files to disk\n"));
1322 printf(
_(
" -?, --help show this help, then exit\n"));
1324 printf(
_(
"\nOptions controlling the output content:\n"));
1325 printf(
_(
" -a, --data-only dump only the data, not the schema or statistics\n"));
1326 printf(
_(
" -b, --large-objects include large objects in dump\n"));
1327 printf(
_(
" --blobs (same as --large-objects, deprecated)\n"));
1328 printf(
_(
" -B, --no-large-objects exclude large objects in dump\n"));
1329 printf(
_(
" --no-blobs (same as --no-large-objects, deprecated)\n"));
1330 printf(
_(
" -c, --clean clean (drop) database objects before recreating\n"));
1331 printf(
_(
" -C, --create include commands to create database in dump\n"));
1332 printf(
_(
" -e, --extension=PATTERN dump the specified extension(s) only\n"));
1333 printf(
_(
" -E, --encoding=ENCODING dump the data in encoding ENCODING\n"));
1334 printf(
_(
" -n, --schema=PATTERN dump the specified schema(s) only\n"));
1335 printf(
_(
" -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
1336 printf(
_(
" -O, --no-owner skip restoration of object ownership in\n"
1337 " plain-text format\n"));
1338 printf(
_(
" -s, --schema-only dump only the schema, no data or statistics\n"));
1339 printf(
_(
" -S, --superuser=NAME superuser user name to use in plain-text format\n"));
1340 printf(
_(
" -t, --table=PATTERN dump only the specified table(s)\n"));
1341 printf(
_(
" -T, --exclude-table=PATTERN do NOT dump the specified table(s)\n"));
1342 printf(
_(
" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
1343 printf(
_(
" --binary-upgrade for use by upgrade utilities only\n"));
1344 printf(
_(
" --column-inserts dump data as INSERT commands with column names\n"));
1345 printf(
_(
" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
1346 printf(
_(
" --disable-triggers disable triggers during data-only restore\n"));
1347 printf(
_(
" --enable-row-security enable row security (dump only content user has\n"
1349 printf(
_(
" --exclude-extension=PATTERN do NOT dump the specified extension(s)\n"));
1350 printf(
_(
" --exclude-table-and-children=PATTERN\n"
1351 " do NOT dump the specified table(s), including\n"
1352 " child and partition tables\n"));
1353 printf(
_(
" --exclude-table-data=PATTERN do NOT dump data for the specified table(s)\n"));
1354 printf(
_(
" --exclude-table-data-and-children=PATTERN\n"
1355 " do NOT dump data for the specified table(s),\n"
1356 " including child and partition tables\n"));
1357 printf(
_(
" --extra-float-digits=NUM override default setting for extra_float_digits\n"));
1358 printf(
_(
" --filter=FILENAME include or exclude objects and data from dump\n"
1359 " based on expressions in FILENAME\n"));
1360 printf(
_(
" --if-exists use IF EXISTS when dropping objects\n"));
1361 printf(
_(
" --include-foreign-data=PATTERN\n"
1362 " include data of foreign tables on foreign\n"
1363 " servers matching PATTERN\n"));
1364 printf(
_(
" --inserts dump data as INSERT commands, rather than COPY\n"));
1365 printf(
_(
" --load-via-partition-root load partitions via the root table\n"));
1366 printf(
_(
" --no-comments do not dump comment commands\n"));
1367 printf(
_(
" --no-data do not dump data\n"));
1368 printf(
_(
" --no-policies do not dump row security policies\n"));
1369 printf(
_(
" --no-publications do not dump publications\n"));
1370 printf(
_(
" --no-schema do not dump schema\n"));
1371 printf(
_(
" --no-security-labels do not dump security label assignments\n"));
1372 printf(
_(
" --no-statistics do not dump statistics\n"));
1373 printf(
_(
" --no-subscriptions do not dump subscriptions\n"));
1374 printf(
_(
" --no-table-access-method do not dump table access methods\n"));
1375 printf(
_(
" --no-tablespaces do not dump tablespace assignments\n"));
1376 printf(
_(
" --no-toast-compression do not dump TOAST compression methods\n"));
1377 printf(
_(
" --no-unlogged-table-data do not dump unlogged table data\n"));
1378 printf(
_(
" --on-conflict-do-nothing add ON CONFLICT DO NOTHING to INSERT commands\n"));
1379 printf(
_(
" --quote-all-identifiers quote all identifiers, even if not key words\n"));
1380 printf(
_(
" --restrict-key=RESTRICT_KEY use provided string as psql \\restrict key\n"));
1381 printf(
_(
" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
1382 printf(
_(
" --section=SECTION dump named section (pre-data, data, or post-data)\n"));
1383 printf(
_(
" --sequence-data include sequence data in dump\n"));
1384 printf(
_(
" --serializable-deferrable wait until the dump can run without anomalies\n"));
1385 printf(
_(
" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
1386 printf(
_(
" --statistics dump the statistics\n"));
1387 printf(
_(
" --statistics-only dump only the statistics, not schema or data\n"));
1388 printf(
_(
" --strict-names require table and/or schema include patterns to\n"
1389 " match at least one entity each\n"));
1390 printf(
_(
" --table-and-children=PATTERN dump only the specified table(s), including\n"
1391 " child and partition tables\n"));
1392 printf(
_(
" --use-set-session-authorization\n"
1393 " use SET SESSION AUTHORIZATION commands instead of\n"
1394 " ALTER OWNER commands to set ownership\n"));
1396 printf(
_(
"\nConnection options:\n"));
1397 printf(
_(
" -d, --dbname=DBNAME database to dump\n"));
1398 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
1399 printf(
_(
" -p, --port=PORT database server port number\n"));
1400 printf(
_(
" -U, --username=NAME connect as specified database user\n"));
1401 printf(
_(
" -w, --no-password never prompt for password\n"));
1402 printf(
_(
" -W, --password force password prompt (should happen automatically)\n"));
1403 printf(
_(
" --role=ROLENAME do SET ROLE before dump\n"));
1405 printf(
_(
"\nIf no database name is supplied, then the PGDATABASE environment\n"
1406 "variable value is used.\n\n"));
1407 printf(
_(
"Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
1408 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
1413 const char *dumpsnapshot,
char *use_role)
1417 const char *std_strings;
1427 pg_fatal(
"invalid client encoding \"%s\" specified",
1439 AH->
std_strings = (std_strings && strcmp(std_strings,
"on") == 0);
1548 "SET TRANSACTION ISOLATION LEVEL "
1549 "SERIALIZABLE, READ ONLY, DEFERRABLE");
1552 "SET TRANSACTION ISOLATION LEVEL "
1553 "REPEATABLE READ, READ ONLY");
1575 pg_fatal(
"parallel dumps from standby servers are not supported by this server version");
1599 char *query =
"SELECT pg_catalog.pg_export_snapshot()";
1641 return archiveFormat;
1659 if (patterns->
head == NULL)
1669 for (cell = patterns->
head; cell; cell = cell->
next)
1675 "SELECT oid FROM pg_catalog.pg_namespace n\n");
1678 false, NULL,
"n.nspname", NULL, NULL, &dbbuf,
1681 pg_fatal(
"improper qualified name (too many dotted names): %s",
1683 else if (dotcnt == 1)
1689 pg_fatal(
"no matching schemas were found for pattern \"%s\"", cell->
val);
1718 if (patterns->
head == NULL)
1727 for (cell = patterns->
head; cell; cell = cell->
next)
1732 "SELECT oid FROM pg_catalog.pg_extension e\n");
1734 false, NULL,
"e.extname", NULL, NULL, NULL,
1737 pg_fatal(
"improper qualified name (too many dotted names): %s",
1742 pg_fatal(
"no matching extensions were found for pattern \"%s\"", cell->
val);
1770 if (patterns->
head == NULL)
1780 for (cell = patterns->
head; cell; cell = cell->
next)
1785 "SELECT oid FROM pg_catalog.pg_foreign_server s\n");
1787 false, NULL,
"s.srvname", NULL, NULL, NULL,
1790 pg_fatal(
"improper qualified name (too many dotted names): %s",
1795 pg_fatal(
"no matching foreign servers were found for pattern \"%s\"", cell->
val);
1822 if (patterns->
head == NULL)
1832 for (cell = patterns->
head; cell; cell = cell->
next)
1845 if (with_child_tables)
1852 "\nFROM pg_catalog.pg_class c"
1853 "\n LEFT JOIN pg_catalog.pg_namespace n"
1854 "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace"
1855 "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY"
1856 "\n (array['%c', '%c', '%c', '%c', '%c', '%c'])\n",
1857 RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW,
1858 RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE,
1859 RELKIND_PARTITIONED_TABLE);
1862 false,
"n.nspname",
"c.relname", NULL,
1863 "pg_catalog.pg_table_is_visible(c.oid)", &dbbuf,
1866 pg_fatal(
"improper relation name (too many dotted names): %s",
1868 else if (dotcnt == 2)
1872 if (with_child_tables)
1875 "\nSELECT i.inhrelid"
1876 "\nFROM partition_tree p"
1877 "\n JOIN pg_catalog.pg_inherits i"
1878 "\n ON p.relid OPERATOR(pg_catalog.=) i.inhparent"
1880 "\nSELECT relid FROM partition_tree");
1888 pg_fatal(
"no matching tables were found for pattern \"%s\"", cell->
val);
1915 pg_fatal(
"You are currently not connected to a database.");
1917 if (strcmp(db,
dbname) != 0)
1918 pg_fatal(
"cross-database references are not implemented: %s",
2006 strcmp(nsinfo->
dobj.
name,
"pg_catalog") == 0)
2015 else if (strncmp(nsinfo->
dobj.
name,
"pg_", 3) == 0 ||
2016 strcmp(nsinfo->
dobj.
name,
"information_schema") == 0)
2021 else if (strcmp(nsinfo->
dobj.
name,
"public") == 0)
2033 if (nsinfo->
nspowner == ROLE_PG_DATABASE_OWNER)
2034 nsinfo->
dobj.
dump &= ~DUMP_COMPONENT_DEFINITION;
2113 tyinfo->
typrelkind != RELKIND_COMPOSITE_TYPE)
2118 if (tytable != NULL)
2158 if (dinfo->
dobj.namespace)
2353 if (dobj->namespace)
2370 const char *classname = tbinfo->
dobj.
name;
2382 const char *column_list;
2384 pg_log_info(
"dumping contents of table \"%s.%s\"",
2385 tbinfo->
dobj.namespace->dobj.
name, classname);
2403 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2408 if (strlen(column_list) > 2)
2494 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetCopyData() failed.", classname);
2504 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetResult() failed.", classname);
2513 pg_log_warning(
"unexpected extra results during COPY of table \"%s\"",
2519 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2546 int rows_this_statement = 0;
2549 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2595 pg_fatal(
"wrong number of fields retrieved from table \"%s\"",
2605 if (insertStmt == NULL)
2637 for (
int field = 0; field < nfields; field++)
2654 for (
int tuple = 0; tuple <
PQntuples(res); tuple++)
2657 if (rows_this_statement == 0)
2673 if (rows_per_statement == 1)
2675 else if (rows_this_statement > 0)
2680 for (
int field = 0; field < nfields; field++)
2684 if (attgenerated[field])
2717 const char *s =
PQgetvalue(res, tuple, field);
2719 if (strspn(s,
"0123456789 +-eE.") == strlen(s))
2733 if (strcmp(
PQgetvalue(res, tuple, field),
"t") == 0)
2754 if (++rows_this_statement >= rows_per_statement)
2757 archputs(
" ON CONFLICT DO NOTHING;\n", fout);
2761 rows_this_statement = 0;
2774 if (rows_this_statement > 0)
2777 archputs(
" ON CONFLICT DO NOTHING;\n", fout);
2787 if (insertStmt != NULL)
2792 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2810 parentTbinfo = tbinfo->
parents[0];
2814 parentTbinfo = parentTbinfo->
parents[0];
2817 return parentTbinfo;
2835 parentTbinfo = tbinfo->
parents[0];
2841 parentTbinfo = parentTbinfo->
parents[0];
2863 char *tdDefn = NULL;
2865 const char *copyFrom;
2903 copyStmt = copyBuf->
data;
2923 .namespace = tbinfo->
dobj.namespace->dobj.
name,
2925 .description =
"TABLE DATA",
2927 .createStmt = tdDefn,
2928 .copyStmt = copyStmt,
2932 .dumpArg = tdinfo));
2990 .namespace = tbinfo->
dobj.namespace->dobj.
name,
2992 .description =
"MATERIALIZED VIEW DATA",
2994 .createStmt = q->
data,
3010 for (
i = 0;
i < numTables;
i++)
3013 (!relkind || tblinfo[
i].
relkind == relkind))
3037 if (tbinfo->
relkind == RELKIND_VIEW)
3040 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
3046 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
3062 if (tbinfo->
relkind == RELKIND_MATVIEW)
3064 else if (tbinfo->
relkind == RELKIND_SEQUENCE)
3077 tdinfo->
dobj.namespace = tbinfo->
dobj.namespace;
3094 if (tbinfo->
relkind == RELKIND_MATVIEW && tbinfo->
stats != NULL)
3130 "SELECT d1.objid, d2.refobjid, c2.relkind AS refrelkind "
3131 "FROM pg_depend d1 "
3132 "JOIN pg_class c1 ON c1.oid = d1.objid "
3134 " JOIN pg_rewrite r1 ON r1.ev_class = d1.objid "
3135 "JOIN pg_depend d2 ON d2.classid = 'pg_rewrite'::regclass "
3136 "AND d2.objid = r1.oid "
3137 "AND d2.refobjid <> d1.objid "
3138 "JOIN pg_class c2 ON c2.oid = d2.refobjid "
3139 "AND c2.relkind IN (" CppAsString2(RELKIND_MATVIEW)
","
3141 "WHERE d1.classid = 'pg_class'::regclass "
3143 "SELECT w.objid, d3.refobjid, c3.relkind "
3145 "JOIN pg_rewrite r3 ON r3.ev_class = w.refobjid "
3146 "JOIN pg_depend d3 ON d3.classid = 'pg_rewrite'::regclass "
3147 "AND d3.objid = r3.oid "
3148 "AND d3.refobjid <> w.refobjid "
3149 "JOIN pg_class c3 ON c3.oid = d3.refobjid "
3150 "AND c3.relkind IN (" CppAsString2(RELKIND_MATVIEW)
","
3153 "SELECT 'pg_class'::regclass::oid AS classid, objid, refobjid "
3163 i_refobjid =
PQfnumber(res,
"refobjid");
3165 for (
i = 0;
i < ntups;
i++)
3192 if (refdobj == NULL)
3199 if (refdobj == NULL)
3235 for (
i = 0;
i < numObjs;
i++)
3247 if (ftable == NULL ||
3320 "pg_encoding_to_char(encoding) AS encoding, "
3321 "datcollate, datctype, datfrozenxid, "
3322 "datacl, acldefault('d', datdba) AS acldefault, "
3323 "datistemplate, datconnlimit, ");
3333 appendPQExpBufferStr(dbQry,
"'c' AS datlocprovider, NULL AS datlocale, NULL AS datcollversion, ");
3339 "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
3340 "shobj_description(oid, 'pg_database') AS description "
3342 "WHERE datname = current_database()");
3346 i_tableoid =
PQfnumber(res,
"tableoid");
3350 i_encoding =
PQfnumber(res,
"encoding");
3351 i_datlocprovider =
PQfnumber(res,
"datlocprovider");
3352 i_collate =
PQfnumber(res,
"datcollate");
3354 i_datlocale =
PQfnumber(res,
"datlocale");
3355 i_daticurules =
PQfnumber(res,
"daticurules");
3356 i_frozenxid =
PQfnumber(res,
"datfrozenxid");
3357 i_minmxid =
PQfnumber(res,
"datminmxid");
3359 i_acldefault =
PQfnumber(res,
"acldefault");
3360 i_datistemplate =
PQfnumber(res,
"datistemplate");
3361 i_datconnlimit =
PQfnumber(res,
"datconnlimit");
3362 i_datcollversion =
PQfnumber(res,
"datcollversion");
3363 i_tablespace =
PQfnumber(res,
"tablespace");
3378 icurules =
PQgetvalue(res, 0, i_daticurules);
3405 "CREATE DATABASE %s WITH TEMPLATE = template0 "
3406 "OID = %u STRATEGY = FILE_COPY",
3407 qdatname, dbCatId.
oid);
3428 pg_fatal(
"unrecognized locale provider: %s",
3431 if (strlen(collate) > 0 && strcmp(collate, ctype) == 0)
3438 if (strlen(collate) > 0)
3443 if (strlen(ctype) > 0)
3506 .createStmt = creaQry->
data,
3507 .dropStmt = delQry->
data));
3536 .description =
"COMMENT",
3538 .createStmt = dbQry->
data,
3556 if (seclabelQry->
len > 0)
3560 .description =
"SECURITY LABEL",
3562 .createStmt = seclabelQry->
data,
3577 qdatname, NULL, NULL,
3578 NULL, dba, &dbdacl);
3608 "SET datistemplate = false WHERE datname = ");
3629 "SET datfrozenxid = '%u', datminmxid = '%u'\n"
3631 frozenxid, minmxid);
3636 if (creaQry->
len > 0)
3642 .createStmt = creaQry->
data,
3643 .dropStmt = delQry->
data,
3644 .deps = &dbDumpId));
3664 int ii_relfrozenxid,
3670 appendPQExpBuffer(loFrozenQry,
"SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
3671 "FROM pg_catalog.pg_class\n"
3672 "WHERE oid IN (%u, %u, %u, %u);\n",
3673 LargeObjectRelationId, LargeObjectLOidPNIndexId,
3674 LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
3676 appendPQExpBuffer(loFrozenQry,
"SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
3677 "FROM pg_catalog.pg_class\n"
3678 "WHERE oid IN (%u, %u);\n",
3679 LargeObjectRelationId, LargeObjectLOidPNIndexId);
3683 ii_relfrozenxid =
PQfnumber(lo_res,
"relfrozenxid");
3684 ii_relminmxid =
PQfnumber(lo_res,
"relminmxid");
3685 ii_relfilenode =
PQfnumber(lo_res,
"relfilenode");
3688 appendPQExpBufferStr(loHorizonQry,
"\n-- For binary upgrade, set pg_largeobject relfrozenxid and relminmxid\n");
3689 appendPQExpBufferStr(lomHorizonQry,
"\n-- For binary upgrade, set pg_largeobject_metadata relfrozenxid and relminmxid\n");
3690 appendPQExpBufferStr(loOutQry,
"\n-- For binary upgrade, preserve pg_largeobject and index relfilenodes\n");
3691 appendPQExpBufferStr(lomOutQry,
"\n-- For binary upgrade, preserve pg_largeobject_metadata and index relfilenodes\n");
3702 if (oid == LargeObjectRelationId ||
3703 oid == LargeObjectLOidPNIndexId)
3705 horizonQry = loHorizonQry;
3710 horizonQry = lomHorizonQry;
3715 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
3716 "WHERE oid = %u;\n",
3721 if (oid == LargeObjectRelationId ||
3722 oid == LargeObjectMetadataRelationId)
3724 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
3726 else if (oid == LargeObjectLOidPNIndexId ||
3727 oid == LargeObjectMetadataOidIndexId)
3729 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
3734 "TRUNCATE pg_catalog.pg_largeobject;\n");
3736 "TRUNCATE pg_catalog.pg_largeobject_metadata;\n");
3745 .createStmt = loOutQry->
data));
3752 .createStmt = lomOutQry->
data));
3786 "WHERE setrole = 0 AND setdatabase = '%u'::oid",
3793 "DATABASE",
dbname, NULL, NULL,
3800 "FROM pg_db_role_setting s, pg_roles r "
3801 "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
3836 .createStmt = qry->
data));
3848 const char *stdstrings = AH->
std_strings ?
"on" :
"off";
3851 pg_log_info(
"saving \"standard_conforming_strings = %s\"",
3861 .createStmt = qry->
data));
3875 char **schemanames = NULL;
3876 int nschemanames = 0;
3887 "SELECT pg_catalog.current_schemas(false)");
3890 pg_fatal(
"could not parse result of current_schemas()");
3898 for (
i = 0;
i < nschemanames;
i++)
3915 .createStmt = qry->
data));
3952 "SELECT oid, lomowner, lomacl, "
3953 "acldefault('L', lomowner) AS acldefault "
3954 "FROM pg_largeobject_metadata "
3955 "ORDER BY lomowner, lomacl::pg_catalog.text, oid");
3960 i_lomowner =
PQfnumber(res,
"lomowner");
3962 i_acldefault =
PQfnumber(res,
"acldefault");
3974 for (
i = 0;
i < ntups;
i += n)
3987 if (strcmp(thisowner,
PQgetvalue(res,
i + n, i_lomowner)) != 0 ||
3988 strcmp(thisacl,
PQgetvalue(res,
i + n, i_lomacl)) != 0)
4002 snprintf(namebuf,
sizeof(namebuf),
"%u..%u", thisoid,
4005 snprintf(namebuf,
sizeof(namebuf),
"%u", thisoid);
4013 loinfo->
looids[0] = thisoid;
4015 for (
int k = 1; k < n; k++)
4022 extraID.
tableoid = LargeObjectRelationId;
4068 loinfo->
dobj.
dump &= ~DUMP_COMPONENT_DATA;
4105 for (
int i = 0;
i < loinfo->
numlos;
i++)
4112 .description =
"BLOB METADATA",
4114 .createStmt = cquery->
data,
4115 .dropStmt =
"-- dummy"));
4124 for (
int i = 0;
i < loinfo->
numlos;
i++)
4164 snprintf(tagbuf,
sizeof(tagbuf),
"LARGE OBJECTS %u..%u",
4168 "LARGE OBJECT", namebuf, NULL, NULL,
4174 "LARGE OBJECT", namebuf, NULL, NULL,
4195 for (
int i = 0;
i < loinfo->
numlos;
i++)
4204 pg_fatal(
"could not open large object %u: %s",
4214 pg_fatal(
"error reading large object %u: %s",
4245 int i_polpermissive;
4268 for (
i = 0;
i < numTables;
i++)
4277 if (tbinfo->
relkind != RELKIND_RELATION &&
4278 tbinfo->
relkind != RELKIND_PARTITIONED_TABLE)
4282 if (tbloids->
len > 1)
4303 polinfo->
dobj.namespace = tbinfo->
dobj.namespace;
4322 pg_log_info(
"reading row-level security policies");
4325 "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
4331 "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
4332 " 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, "
4333 "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
4334 "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
4335 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
4336 "JOIN pg_catalog.pg_policy pol ON (src.tbloid = pol.polrelid)",
4345 i_tableoid =
PQfnumber(res,
"tableoid");
4346 i_polrelid =
PQfnumber(res,
"polrelid");
4349 i_polpermissive =
PQfnumber(res,
"polpermissive");
4350 i_polroles =
PQfnumber(res,
"polroles");
4352 i_polwithcheck =
PQfnumber(res,
"polwithcheck");
4356 for (
j = 0;
j < ntups;
j++)
4368 polinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
4377 polinfo[
j].polroles = NULL;
4440 .namespace = polinfo->
dobj.namespace->dobj.
name,
4442 .description =
"ROW SECURITY",
4444 .createStmt = query->
data,
4452 if (polinfo->
polcmd ==
'*')
4454 else if (polinfo->
polcmd ==
'r')
4455 cmd =
" FOR SELECT";
4456 else if (polinfo->
polcmd ==
'a')
4457 cmd =
" FOR INSERT";
4458 else if (polinfo->
polcmd ==
'w')
4459 cmd =
" FOR UPDATE";
4460 else if (polinfo->
polcmd ==
'd')
4461 cmd =
" FOR DELETE";
4463 pg_fatal(
"unexpected policy command type: %c",
4499 .
namespace = polinfo->
dobj.namespace->dobj.
name,
4501 .description =
"POLICY",
4503 .createStmt = query->
data,
4504 .dropStmt = delqry->
data));
4534 int i_puballsequences;
4551 "p.pubowner, p.puballtables, p.pubinsert, "
4552 "p.pubupdate, p.pubdelete, ");
4583 i_tableoid =
PQfnumber(res,
"tableoid");
4586 i_pubowner =
PQfnumber(res,
"pubowner");
4587 i_puballtables =
PQfnumber(res,
"puballtables");
4588 i_puballsequences =
PQfnumber(res,
"puballsequences");
4589 i_pubinsert =
PQfnumber(res,
"pubinsert");
4590 i_pubupdate =
PQfnumber(res,
"pubupdate");
4591 i_pubdelete =
PQfnumber(res,
"pubdelete");
4592 i_pubtruncate =
PQfnumber(res,
"pubtruncate");
4593 i_pubviaroot =
PQfnumber(res,
"pubviaroot");
4594 i_pubgencols =
PQfnumber(res,
"pubgencols");
4598 for (
i = 0;
i < ntups;
i++)
4608 (strcmp(
PQgetvalue(res,
i, i_puballtables),
"t") == 0);
4610 (strcmp(
PQgetvalue(res,
i, i_puballsequences),
"t") == 0);
4612 (strcmp(
PQgetvalue(res,
i, i_pubinsert),
"t") == 0);
4614 (strcmp(
PQgetvalue(res,
i, i_pubupdate),
"t") == 0);
4616 (strcmp(
PQgetvalue(res,
i, i_pubdelete),
"t") == 0);
4618 (strcmp(
PQgetvalue(res,
i, i_pubtruncate),
"t") == 0);
4620 (strcmp(
PQgetvalue(res,
i, i_pubviaroot),
"t") == 0);
4717 .description =
"PUBLICATION",
4719 .createStmt = query->
data,
4720 .dropStmt = delq->
data));
4763 "SELECT tableoid, oid, pnpubid, pnnspid "
4764 "FROM pg_catalog.pg_publication_namespace");
4769 i_tableoid =
PQfnumber(res,
"tableoid");
4778 for (
i = 0;
i < ntups;
i++)
4790 if (pubinfo == NULL)
4793 if (nspinfo == NULL)
4802 pubsinfo[
j].
dobj.namespace = nspinfo->
dobj.namespace;
4846 "SELECT tableoid, oid, prpubid, prrelid, "
4847 "pg_catalog.pg_get_expr(prqual, prrelid) AS prrelqual, "
4849 " WHEN pr.prattrs IS NOT NULL THEN\n"
4850 " (SELECT array_agg(attname)\n"
4852 " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
4853 " pg_catalog.pg_attribute\n"
4854 " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
4855 " ELSE NULL END) prattrs "
4856 "FROM pg_catalog.pg_publication_rel pr");
4859 "SELECT tableoid, oid, prpubid, prrelid, "
4860 "NULL AS prrelqual, NULL AS prattrs "
4861 "FROM pg_catalog.pg_publication_rel");
4866 i_tableoid =
PQfnumber(res,
"tableoid");
4870 i_prrelqual =
PQfnumber(res,
"prrelqual");
4877 for (
i = 0;
i < ntups;
i++)
4889 if (pubinfo == NULL)
4897 pubrinfo[
j].dobj.catId.tableoid =
4901 pubrinfo[
j].dobj.namespace = tbinfo->
dobj.namespace;
4902 pubrinfo[
j].dobj.name = tbinfo->
dobj.
name;
4903 pubrinfo[
j].publication = pubinfo;
4904 pubrinfo[
j].pubtable = tbinfo;
4906 pubrinfo[
j].pubrelqual = NULL;
4917 &attnames, &nattnames))
4918 pg_fatal(
"could not parse %s array",
"prattrs");
4920 for (
int k = 0; k < nattnames; k++)
4927 pubrinfo[
j].pubrattrs = attribs->
data;
4932 pubrinfo[
j].pubrattrs = NULL;
4975 .
namespace = schemainfo->
dobj.
name,
4977 .description =
"PUBLICATION TABLES IN SCHEMA",
4979 .createStmt = query->
data));
5013 if (pubrinfo->pubrattrs)
5016 if (pubrinfo->pubrelqual)
5035 ArchiveEntry(fout, pubrinfo->dobj.catId, pubrinfo->dobj.dumpId,
5037 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
5039 .description =
"PUBLICATION TABLE",
5041 .createStmt = query->
data));
5060 if (
val && strcmp(
val,
"on") == 0)
5078 "SELECT set_config(name, '%s', false) "
5080 "WHERE name = 'restrict_nonsystem_relation_kind'",
5105 int i_subtwophasestate;
5106 int i_subdisableonerr;
5107 int i_subpasswordrequired;
5108 int i_subrunasowner;
5111 int i_subsynccommit;
5112 int i_subpublications;
5114 int i_suboriginremotelsn;
5117 int i_subretaindeadtuples;
5118 int i_submaxretention;
5130 "SELECT count(*) FROM pg_subscription "
5131 "WHERE subdbid = (SELECT oid FROM pg_database"
5132 " WHERE datname = current_database())",
5136 pg_log_warning(
"subscriptions not dumped because current user is not a superuser");
5145 "SELECT s.tableoid, s.oid, s.subname,\n"
5147 " s.subconninfo, s.subslotname, s.subsynccommit,\n"
5148 " s.subpublications,\n");
5162 " s.subtwophasestate,\n"
5163 " s.subdisableonerr,\n");
5166 " '%c' AS subtwophasestate,\n"
5167 " false AS subdisableonerr,\n",
5168 LOGICALREP_TWOPHASE_STATE_DISABLED);
5172 " s.subpasswordrequired,\n"
5173 " s.subrunasowner,\n"
5177 " 't' AS subpasswordrequired,\n"
5178 " 't' AS subrunasowner,\n"
5179 " '%s' AS suborigin,\n",
5180 LOGICALREP_ORIGIN_ANY);
5184 " s.subenabled,\n");
5187 " false AS subenabled,\n");
5191 " s.subfailover,\n");
5194 " false AS subfailover,\n");
5198 " s.subretaindeadtuples,\n");
5201 " false AS subretaindeadtuples,\n");
5205 " s.submaxretention\n");
5208 " 0 AS submaxretention\n");
5211 "FROM pg_subscription s\n");
5215 "LEFT JOIN pg_catalog.pg_replication_origin_status o \n"
5216 " ON o.external_id = 'pg_' || s.oid::text \n");
5219 "WHERE s.subdbid = (SELECT oid FROM pg_database\n"
5220 " WHERE datname = current_database())");
5230 i_tableoid =
PQfnumber(res,
"tableoid");
5233 i_subowner =
PQfnumber(res,
"subowner");
5234 i_subenabled =
PQfnumber(res,
"subenabled");
5235 i_subbinary =
PQfnumber(res,
"subbinary");
5236 i_substream =
PQfnumber(res,
"substream");
5237 i_subtwophasestate =
PQfnumber(res,
"subtwophasestate");
5238 i_subdisableonerr =
PQfnumber(res,
"subdisableonerr");
5239 i_subpasswordrequired =
PQfnumber(res,
"subpasswordrequired");
5240 i_subrunasowner =
PQfnumber(res,
"subrunasowner");
5241 i_subfailover =
PQfnumber(res,
"subfailover");
5242 i_subretaindeadtuples =
PQfnumber(res,
"subretaindeadtuples");
5243 i_submaxretention =
PQfnumber(res,
"submaxretention");
5244 i_subconninfo =
PQfnumber(res,
"subconninfo");
5245 i_subslotname =
PQfnumber(res,
"subslotname");
5246 i_subsynccommit =
PQfnumber(res,
"subsynccommit");
5247 i_subpublications =
PQfnumber(res,
"subpublications");
5248 i_suborigin =
PQfnumber(res,
"suborigin");
5249 i_suboriginremotelsn =
PQfnumber(res,
"suboriginremotelsn");
5253 for (
i = 0;
i < ntups;
i++)
5264 (strcmp(
PQgetvalue(res,
i, i_subenabled),
"t") == 0);
5266 (strcmp(
PQgetvalue(res,
i, i_subbinary),
"t") == 0);
5270 (strcmp(
PQgetvalue(res,
i, i_subdisableonerr),
"t") == 0);
5272 (strcmp(
PQgetvalue(res,
i, i_subpasswordrequired),
"t") == 0);
5274 (strcmp(
PQgetvalue(res,
i, i_subrunasowner),
"t") == 0);
5276 (strcmp(
PQgetvalue(res,
i, i_subfailover),
"t") == 0);
5278 (strcmp(
PQgetvalue(res,
i, i_subretaindeadtuples),
"t") == 0);
5331 "SELECT srsubid, srrelid, srsubstate, srsublsn "
5332 "FROM pg_catalog.pg_subscription_rel "
5342 i_srsubstate =
PQfnumber(res,
"srsubstate");
5343 i_srsublsn =
PQfnumber(res,
"srsublsn");
5346 for (
int i = 0;
i < ntups;
i++)
5356 if (cur_srsubid != last_srsubid)
5359 if (subinfo == NULL)
5360 pg_fatal(
"subscription with OID %u does not exist", cur_srsubid);
5362 last_srsubid = cur_srsubid;
5366 if (tblinfo == NULL)
5367 pg_fatal(
"failed sanity check, relation with OID %u not found",
5424 "\n-- For binary upgrade, must preserve the subscriber table.\n");
5426 "SELECT pg_catalog.binary_upgrade_add_sub_rel_state(");
5453 .description =
"SUBSCRIPTION TABLE",
5455 .createStmt = query->
data));
5475 char **pubnames = NULL;
5497 pg_fatal(
"could not parse %s array",
"subpublications");
5500 for (
i = 0;
i < npubnames;
i++)
5508 appendPQExpBuffer(query,
" PUBLICATION %s WITH (connect = false, slot_name = ", publications->
data);
5517 if (subinfo->
substream == LOGICALREP_STREAM_ON)
5519 else if (subinfo->
substream == LOGICALREP_STREAM_PARALLEL)
5571 "\n-- For binary upgrade, must preserve the remote_lsn for the subscriber's replication origin.\n");
5573 "SELECT pg_catalog.binary_upgrade_replorigin_advance(");
5585 "\n-- For binary upgrade, must preserve the subscriber's running state.\n");
5594 .description =
"SUBSCRIPTION",
5596 .createStmt = query->
data,
5597 .dropStmt = delq->
data));
5625 const char *catalog,
5626 const char *keyword,
5627 const char *objname)
5644 "FROM pg_catalog.pg_depend d, pg_catalog.pg_extension e "
5645 "WHERE d.refobjid = e.oid AND classid = '%s'::pg_catalog.regclass "
5646 "AND objid = '%u'::pg_catalog.oid AND deptype = 'x' "
5647 "AND refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass",
5653 for (
i = 0;
i < ntups;
i++)
5683 ++next_possible_free_oid;
5685 "SELECT EXISTS(SELECT 1 "
5686 "FROM pg_catalog.pg_type "
5687 "WHERE oid = '%u'::pg_catalog.oid);",
5688 next_possible_free_oid);
5694 return next_possible_free_oid;
5701 bool force_array_type,
5702 bool include_multirange_type)
5706 Oid pg_type_array_oid;
5707 Oid pg_type_multirange_oid;
5708 Oid pg_type_multirange_array_oid;
5713 "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5718 pg_type_array_oid =
tinfo->typarray;
5722 if (!
OidIsValid(pg_type_array_oid) && force_array_type)
5728 "\n-- For binary upgrade, must preserve pg_type array oid\n");
5730 "SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5737 if (include_multirange_type)
5742 "SELECT t.oid, t.typarray "
5743 "FROM pg_catalog.pg_type t "
5744 "JOIN pg_catalog.pg_range r "
5745 "ON t.oid = r.rngmultitypid "
5746 "WHERE r.rngtypid = '%u'::pg_catalog.oid;",
5763 "\n-- For binary upgrade, must preserve multirange pg_type oid\n");
5765 "SELECT pg_catalog.binary_upgrade_set_next_multirange_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5766 pg_type_multirange_oid);
5768 "\n-- For binary upgrade, must preserve multirange pg_type array oid\n");
5770 "SELECT pg_catalog.binary_upgrade_set_next_multirange_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5771 pg_type_multirange_array_oid);
5786 pg_type_oid,
false,
false);
5814 query =
"SELECT c.oid, c.relkind, c.relfilenode, c.reltoastrelid, "
5815 "ct.relfilenode, i.indexrelid, cti.relfilenode "
5816 "FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_index i "
5817 "ON (c.reltoastrelid = i.indrelid AND i.indisvalid) "
5818 "LEFT JOIN pg_catalog.pg_class ct ON (c.reltoastrelid = ct.oid) "
5819 "LEFT JOIN pg_catalog.pg_class AS cti ON (i.indexrelid = cti.oid) "
5862 key.oid = pg_class_oid;
5868 "\n-- For binary upgrade, must preserve pg_class oids and relfilenodes\n");
5870 if (entry->
relkind != RELKIND_INDEX &&
5871 entry->
relkind != RELKIND_PARTITIONED_INDEX)
5874 "SELECT pg_catalog.binary_upgrade_set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
5883 entry->
relkind != RELKIND_PARTITIONED_TABLE)
5885 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
5893 entry->
relkind != RELKIND_PARTITIONED_TABLE)
5896 "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
5899 "SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
5904 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5907 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5915 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5918 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5935 const char *objtype,
5936 const char *objname,
5937 const char *objnamespace)
5959 pg_fatal(
"could not find parent extension for %s %s",
5963 "\n-- For binary upgrade, handle extension membership the hard way\n");
5967 if (objnamespace && *objnamespace)
6000 "acldefault('n', n.nspowner) AS acldefault "
6001 "FROM pg_namespace n");
6009 i_tableoid =
PQfnumber(res,
"tableoid");
6012 i_nspowner =
PQfnumber(res,
"nspowner");
6014 i_acldefault =
PQfnumber(res,
"acldefault");
6016 for (
i = 0;
i < ntups;
i++)
6018 const char *nspowner;
6056 if (strcmp(nsinfo[
i].dobj.name,
"public") == 0)
6097 pg_fatal(
"schema with OID %u does not exist", nsoid);
6121 int i_extrelocatable;
6129 "x.extname, n.nspname, x.extrelocatable, x.extversion, x.extconfig, x.extcondition "
6130 "FROM pg_extension x "
6131 "JOIN pg_namespace n ON n.oid = x.extnamespace");
6141 i_tableoid =
PQfnumber(res,
"tableoid");
6145 i_extrelocatable =
PQfnumber(res,
"extrelocatable");
6146 i_extversion =
PQfnumber(res,
"extversion");
6147 i_extconfig =
PQfnumber(res,
"extconfig");
6148 i_extcondition =
PQfnumber(res,
"extcondition");
6150 for (
i = 0;
i < ntups;
i++)
6171 *numExtensions = ntups;
6223 "typnamespace, typacl, "
6224 "acldefault('T', typowner) AS acldefault, "
6226 "typelem, typrelid, typarray, "
6227 "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
6228 "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
6229 "typtype, typisdefined, "
6230 "typname[0] = '_' AND typelem != 0 AND "
6231 "(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray "
6240 i_tableoid =
PQfnumber(res,
"tableoid");
6243 i_typnamespace =
PQfnumber(res,
"typnamespace");
6245 i_acldefault =
PQfnumber(res,
"acldefault");
6246 i_typowner =
PQfnumber(res,
"typowner");
6248 i_typrelid =
PQfnumber(res,
"typrelid");
6249 i_typrelkind =
PQfnumber(res,
"typrelkind");
6251 i_typisdefined =
PQfnumber(res,
"typisdefined");
6253 i_typarray =
PQfnumber(res,
"typarray");
6255 for (
i = 0;
i < ntups;
i++)
6262 tyinfo[
i].
dobj.namespace =
6276 if (strcmp(
PQgetvalue(res,
i, i_typisdefined),
"t") == 0)
6281 if (strcmp(
PQgetvalue(res,
i, i_isarray),
"t") == 0)
6288 if (tyinfo[
i].typtype == TYPTYPE_MULTIRANGE)
6307 tyinfo[
i].
typtype == TYPTYPE_DOMAIN)
6321 (tyinfo[
i].
typtype == TYPTYPE_BASE ||
6322 tyinfo[
i].
typtype == TYPTYPE_RANGE))
6329 stinfo->
dobj.namespace = tyinfo[
i].
dobj.namespace;
6380 "oprcode::oid AS oprcode "
6381 "FROM pg_operator");
6389 i_tableoid =
PQfnumber(res,
"tableoid");
6392 i_oprnamespace =
PQfnumber(res,
"oprnamespace");
6393 i_oprowner =
PQfnumber(res,
"oprowner");
6396 i_oprright =
PQfnumber(res,
"oprright");
6399 for (
i = 0;
i < ntups;
i++)
6406 oprinfo[
i].
dobj.namespace =
6438 int i_collnamespace;
6453 "FROM pg_collation");
6461 i_tableoid =
PQfnumber(res,
"tableoid");
6463 i_collname =
PQfnumber(res,
"collname");
6464 i_collnamespace =
PQfnumber(res,
"collnamespace");
6465 i_collowner =
PQfnumber(res,
"collowner");
6466 i_collencoding =
PQfnumber(res,
"collencoding");
6468 for (
i = 0;
i < ntups;
i++)
6475 collinfo[
i].
dobj.namespace =
6517 "FROM pg_conversion");
6525 i_tableoid =
PQfnumber(res,
"tableoid");
6528 i_connamespace =
PQfnumber(res,
"connamespace");
6529 i_conowner =
PQfnumber(res,
"conowner");
6531 for (
i = 0;
i < ntups;
i++)
6538 convinfo[
i].
dobj.namespace =
6585 "amhandler::pg_catalog.regproc AS amhandler ");
6588 "'i'::pg_catalog.\"char\" AS amtype, "
6589 "'-'::pg_catalog.regproc AS amhandler ");
6598 i_tableoid =
PQfnumber(res,
"tableoid");
6601 i_amhandler =
PQfnumber(res,
"amhandler");
6604 for (
i = 0;
i < ntups;
i++)
6611 aminfo[
i].
dobj.namespace = NULL;
6660 i_tableoid =
PQfnumber(res,
"tableoid");
6662 i_opcmethod =
PQfnumber(res,
"opcmethod");
6664 i_opcnamespace =
PQfnumber(res,
"opcnamespace");
6665 i_opcowner =
PQfnumber(res,
"opcowner");
6667 for (
i = 0;
i < ntups;
i++)
6674 opcinfo[
i].
dobj.namespace =
6717 "FROM pg_opfamily");
6725 i_tableoid =
PQfnumber(res,
"tableoid");
6728 i_opfmethod =
PQfnumber(res,
"opfmethod");
6729 i_opfnamespace =
PQfnumber(res,
"opfnamespace");
6730 i_opfowner =
PQfnumber(res,
"opfowner");
6732 for (
i = 0;
i < ntups;
i++)
6739 opfinfo[
i].
dobj.namespace =
6782 const char *agg_check;
6784 agg_check = (fout->
remoteVersion >= 110000 ?
"p.prokind = 'a'"
6788 "p.proname AS aggname, "
6789 "p.pronamespace AS aggnamespace, "
6790 "p.pronargs, p.proargtypes, "
6792 "p.proacl AS aggacl, "
6793 "acldefault('f', p.proowner) AS acldefault "
6795 "LEFT JOIN pg_init_privs pip ON "
6796 "(p.oid = pip.objoid "
6797 "AND pip.classoid = 'pg_proc'::regclass "
6798 "AND pip.objsubid = 0) "
6800 "p.pronamespace != "
6801 "(SELECT oid FROM pg_namespace "
6802 "WHERE nspname = 'pg_catalog') OR "
6803 "p.proacl IS DISTINCT FROM pip.initprivs",
6807 " 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 "
6817 "pronamespace AS aggnamespace, "
6818 "pronargs, proargtypes, "
6820 "proacl AS aggacl, "
6821 "acldefault('f', proowner) AS acldefault "
6823 "WHERE proisagg AND ("
6825 "(SELECT oid FROM pg_namespace "
6826 "WHERE nspname = 'pg_catalog')");
6829 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6830 "classid = 'pg_proc'::regclass AND "
6831 "objid = p.oid AND "
6832 "refclassid = 'pg_extension'::regclass AND "
6843 i_tableoid =
PQfnumber(res,
"tableoid");
6846 i_aggnamespace =
PQfnumber(res,
"aggnamespace");
6847 i_pronargs =
PQfnumber(res,
"pronargs");
6848 i_proargtypes =
PQfnumber(res,
"proargtypes");
6849 i_proowner =
PQfnumber(res,
"proowner");
6851 i_acldefault =
PQfnumber(res,
"acldefault");
6853 for (
i = 0;
i < ntups;
i++)
6855 agginfo[
i].aggfn.dobj.objType =
DO_AGG;
6860 agginfo[
i].aggfn.dobj.namespace =
6864 agginfo[
i].aggfn.dacl.privtype = 0;
6865 agginfo[
i].aggfn.dacl.initprivs = NULL;
6869 agginfo[
i].aggfn.nargs = atoi(
PQgetvalue(res,
i, i_pronargs));
6870 if (agginfo[
i].aggfn.nargs == 0)
6871 agginfo[
i].aggfn.argtypes = NULL;
6874 agginfo[
i].aggfn.argtypes = (
Oid *)
pg_malloc(agginfo[
i].aggfn.nargs *
sizeof(
Oid));
6876 agginfo[
i].aggfn.argtypes,
6877 agginfo[
i].aggfn.nargs);
6879 agginfo[
i].aggfn.postponed_def =
false;
6942 const char *not_agg_check;
6944 not_agg_check = (fout->
remoteVersion >= 110000 ?
"p.prokind <> 'a'"
6945 :
"NOT p.proisagg");
6948 "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
6949 "p.pronargs, p.proargtypes, p.prorettype, "
6951 "acldefault('f', p.proowner) AS acldefault, "
6955 "LEFT JOIN pg_init_privs pip ON "
6956 "(p.oid = pip.objoid "
6957 "AND pip.classoid = 'pg_proc'::regclass "
6958 "AND pip.objsubid = 0) "
6960 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6961 "WHERE classid = 'pg_proc'::regclass AND "
6962 "objid = p.oid AND deptype = 'i')"
6964 "\n pronamespace != "
6965 "(SELECT oid FROM pg_namespace "
6966 "WHERE nspname = 'pg_catalog')"
6967 "\n OR EXISTS (SELECT 1 FROM pg_cast"
6968 "\n WHERE pg_cast.oid > %u "
6969 "\n AND p.oid = pg_cast.castfunc)"
6970 "\n OR EXISTS (SELECT 1 FROM pg_transform"
6971 "\n WHERE pg_transform.oid > %u AND "
6972 "\n (p.oid = pg_transform.trffromsql"
6973 "\n OR p.oid = pg_transform.trftosql))",
6979 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6980 "classid = 'pg_proc'::regclass AND "
6981 "objid = p.oid AND "
6982 "refclassid = 'pg_extension'::regclass AND "
6985 "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
6991 "SELECT tableoid, oid, proname, prolang, "
6992 "pronargs, proargtypes, prorettype, proacl, "
6993 "acldefault('f', proowner) AS acldefault, "
6997 "WHERE NOT proisagg"
6998 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6999 "WHERE classid = 'pg_proc'::regclass AND "
7000 "objid = p.oid AND deptype = 'i')"
7002 "\n pronamespace != "
7003 "(SELECT oid FROM pg_namespace "
7004 "WHERE nspname = 'pg_catalog')"
7005 "\n OR EXISTS (SELECT 1 FROM pg_cast"
7006 "\n WHERE pg_cast.oid > '%u'::oid"
7007 "\n AND p.oid = pg_cast.castfunc)",
7012 "\n OR EXISTS (SELECT 1 FROM pg_transform"
7013 "\n WHERE pg_transform.oid > '%u'::oid"
7014 "\n AND (p.oid = pg_transform.trffromsql"
7015 "\n OR p.oid = pg_transform.trftosql))",
7020 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
7021 "classid = 'pg_proc'::regclass AND "
7022 "objid = p.oid AND "
7023 "refclassid = 'pg_extension'::regclass AND "
7034 i_tableoid =
PQfnumber(res,
"tableoid");
7037 i_pronamespace =
PQfnumber(res,
"pronamespace");
7038 i_proowner =
PQfnumber(res,
"proowner");
7040 i_pronargs =
PQfnumber(res,
"pronargs");
7041 i_proargtypes =
PQfnumber(res,
"proargtypes");
7042 i_prorettype =
PQfnumber(res,
"prorettype");
7044 i_acldefault =
PQfnumber(res,
"acldefault");
7046 for (
i = 0;
i < ntups;
i++)
7053 finfo[
i].
dobj.namespace =
7063 if (finfo[
i].nargs == 0)
7069 finfo[
i].argtypes, finfo[
i].nargs);
7095 char *reltuples,
int32 relallvisible,
7096 int32 relallfrozen,
char relkind,
7097 char **indAttNames,
int nindAttNames)
7102 if ((relkind == RELKIND_RELATION) ||
7103 (relkind == RELKIND_PARTITIONED_TABLE) ||
7104 (relkind == RELKIND_INDEX) ||
7105 (relkind == RELKIND_PARTITIONED_INDEX) ||
7106 (relkind == RELKIND_MATVIEW ||
7107 relkind == RELKIND_FOREIGN_TABLE))
7122 dobj->namespace = rel->namespace;
7143 case RELKIND_RELATION:
7144 case RELKIND_PARTITIONED_TABLE:
7145 case RELKIND_MATVIEW:
7146 case RELKIND_FOREIGN_TABLE:
7150 case RELKIND_PARTITIONED_INDEX:
7154 pg_fatal(
"cannot dump statistics for relation kind \"%c\"",
7191 int i_relallvisible;
7196 int i_reltablespace;
7198 int i_relhastriggers;
7199 int i_relpersistence;
7200 int i_relispopulated;
7203 int i_relforcerowsec;
7205 int i_toastfrozenxid;
7211 int i_toastreloptions;
7213 int i_foreignserver;
7215 int i_is_identity_sequence;
7238 "SELECT c.tableoid, c.oid, c.relname, "
7239 "c.relnamespace, c.relkind, c.reltype, "
7242 "c.relhasindex, c.relhasrules, c.relpages, "
7243 "c.reltuples, c.relallvisible, ");
7251 "c.relhastriggers, c.relpersistence, "
7254 "acldefault(CASE WHEN c.relkind = " CppAsString2(RELKIND_SEQUENCE)
7255 " THEN 's'::\"char\" ELSE 'r'::\"char\" END, c.relowner) AS acldefault, "
7256 "CASE WHEN c.relkind = " CppAsString2(RELKIND_FOREIGN_TABLE)
" THEN "
7257 "(SELECT ftserver FROM pg_catalog.pg_foreign_table WHERE ftrelid = c.oid) "
7258 "ELSE 0 END AS foreignserver, "
7259 "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, "
7261 "tc.relpages AS toastpages, "
7262 "tc.reloptions AS toast_reloptions, "
7263 "d.refobjid AS owning_tab, "
7264 "d.refobjsubid AS owning_col, "
7265 "tsp.spcname AS reltablespace, ");
7269 "false AS relhasoids, ");
7276 "c.relispopulated, ");
7279 "'t' as relispopulated, ");
7283 "c.relreplident, ");
7286 "'d' AS relreplident, ");
7290 "c.relrowsecurity, c.relforcerowsecurity, ");
7293 "false AS relrowsecurity, "
7294 "false AS relforcerowsecurity, ");
7298 "c.relminmxid, tc.relminmxid AS tminmxid, ");
7301 "0 AS relminmxid, 0 AS tminmxid, ");
7305 "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
7306 "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
7307 "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
7310 "c.reloptions, NULL AS checkoption, ");
7317 "NULL AS amname, ");
7321 "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
7324 "false AS is_identity_sequence, ");
7328 "c.relispartition AS ispartition ");
7331 "false AS ispartition ");
7340 "\nFROM pg_class c\n"
7341 "LEFT JOIN pg_depend d ON "
7343 "d.classid = 'pg_class'::regclass AND d.objid = c.oid AND "
7344 "d.objsubid = 0 AND "
7345 "d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
7346 "LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
7353 "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
7361 "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid"
7363 " AND c.relkind <> " CppAsString2(RELKIND_PARTITIONED_TABLE)
")\n");
7376 "WHERE c.relkind IN ("
7403 i_reltableoid =
PQfnumber(res,
"tableoid");
7406 i_relnamespace =
PQfnumber(res,
"relnamespace");
7409 i_relowner =
PQfnumber(res,
"relowner");
7410 i_relchecks =
PQfnumber(res,
"relchecks");
7411 i_relhasindex =
PQfnumber(res,
"relhasindex");
7412 i_relhasrules =
PQfnumber(res,
"relhasrules");
7413 i_relpages =
PQfnumber(res,
"relpages");
7414 i_reltuples =
PQfnumber(res,
"reltuples");
7415 i_relallvisible =
PQfnumber(res,
"relallvisible");
7416 i_relallfrozen =
PQfnumber(res,
"relallfrozen");
7417 i_toastpages =
PQfnumber(res,
"toastpages");
7418 i_owning_tab =
PQfnumber(res,
"owning_tab");
7419 i_owning_col =
PQfnumber(res,
"owning_col");
7420 i_reltablespace =
PQfnumber(res,
"reltablespace");
7421 i_relhasoids =
PQfnumber(res,
"relhasoids");
7422 i_relhastriggers =
PQfnumber(res,
"relhastriggers");
7423 i_relpersistence =
PQfnumber(res,
"relpersistence");
7424 i_relispopulated =
PQfnumber(res,
"relispopulated");
7425 i_relreplident =
PQfnumber(res,
"relreplident");
7426 i_relrowsec =
PQfnumber(res,
"relrowsecurity");
7427 i_relforcerowsec =
PQfnumber(res,
"relforcerowsecurity");
7428 i_relfrozenxid =
PQfnumber(res,
"relfrozenxid");
7429 i_toastfrozenxid =
PQfnumber(res,
"tfrozenxid");
7431 i_relminmxid =
PQfnumber(res,
"relminmxid");
7432 i_toastminmxid =
PQfnumber(res,
"tminmxid");
7433 i_reloptions =
PQfnumber(res,
"reloptions");
7434 i_checkoption =
PQfnumber(res,
"checkoption");
7435 i_toastreloptions =
PQfnumber(res,
"toast_reloptions");
7436 i_reloftype =
PQfnumber(res,
"reloftype");
7437 i_foreignserver =
PQfnumber(res,
"foreignserver");
7439 i_is_identity_sequence =
PQfnumber(res,
"is_identity_sequence");
7441 i_acldefault =
PQfnumber(res,
"acldefault");
7442 i_ispartition =
PQfnumber(res,
"ispartition");
7461 for (
i = 0;
i < ntups;
i++)
7471 tblinfo[
i].
dobj.namespace =
7531 if (tblinfo[
i].relkind == RELKIND_COMPOSITE_TYPE)
7564 if (tblinfo[
i].interesting)
7569 tblinfo[
i].relpages,
7571 relallvisible, relallfrozen,
7572 tblinfo[
i].relkind, NULL, 0);
7573 if (tblinfo[
i].relkind == RELKIND_MATVIEW)
7574 tblinfo[
i].
stats = stats;
7593 (tblinfo[
i].
relkind == RELKIND_RELATION ||
7594 tblinfo[
i].
relkind == RELKIND_PARTITIONED_TABLE))
7601 if (query->
len == 0)
7610 if (query->
len >= 100000)
7621 if (query->
len != 0)
7656 for (
i = 0;
i < numTables;
i++)
7665 if (owning_tab == NULL)
7666 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
7731 *numInherits = ntups;
7735 i_inhrelid =
PQfnumber(res,
"inhrelid");
7736 i_inhparent =
PQfnumber(res,
"inhparent");
7738 for (
i = 0;
i < ntups;
i++)
7793 "SELECT partrelid FROM pg_partitioned_table WHERE\n"
7794 "(SELECT c.oid FROM pg_opclass c JOIN pg_am a "
7795 "ON c.opcmethod = a.oid\n"
7796 "WHERE opcname = 'enum_ops' "
7797 "AND opcnamespace = 'pg_catalog'::regnamespace "
7798 "AND amname = 'hash') = ANY(partclass)");
7804 for (
int i = 0;
i < ntups;
i++)
7811 pg_fatal(
"failed sanity check, table OID %u appearing in pg_partitioned_table not found",
7852 i_indnullsnotdistinct,
7876 for (
int i = 0;
i < numTables;
i++)
7890 if (tbloids->
len > 1)
7897 "SELECT t.tableoid, t.oid, i.indrelid, "
7898 "t.relname AS indexname, "
7899 "t.relpages, t.reltuples, t.relallvisible, ");
7907 "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
7908 "i.indkey, i.indisclustered, "
7909 "c.contype, c.conname, "
7910 "c.condeferrable, c.condeferred, "
7911 "c.tableoid AS contableoid, "
7913 "pg_catalog.pg_get_constraintdef(c.oid, false) AS condef, "
7914 "CASE WHEN i.indexprs IS NOT NULL THEN "
7915 "(SELECT pg_catalog.array_agg(attname ORDER BY attnum)"
7916 " FROM pg_catalog.pg_attribute "
7917 " WHERE attrelid = i.indexrelid) "
7918 "ELSE NULL END AS indattnames, "
7919 "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
7920 "t.reloptions AS indreloptions, ");
7925 "i.indisreplident, ");
7928 "false AS indisreplident, ");
7932 "inh.inhparent AS parentidx, "
7933 "i.indnkeyatts AS indnkeyatts, "
7934 "i.indnatts AS indnatts, "
7935 "(SELECT pg_catalog.array_agg(attnum ORDER BY attnum) "
7936 " FROM pg_catalog.pg_attribute "
7937 " WHERE attrelid = i.indexrelid AND "
7938 " attstattarget >= 0) AS indstatcols, "
7939 "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attnum) "
7940 " FROM pg_catalog.pg_attribute "
7941 " WHERE attrelid = i.indexrelid AND "
7942 " attstattarget >= 0) AS indstatvals, ");
7946 "i.indnatts AS indnkeyatts, "
7947 "i.indnatts AS indnatts, "
7948 "'' AS indstatcols, "
7949 "'' AS indstatvals, ");
7953 "i.indnullsnotdistinct, ");
7956 "false AS indnullsnotdistinct, ");
7963 "NULL AS conperiod ");
7977 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7978 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7979 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7980 "JOIN pg_catalog.pg_class t2 ON (t2.oid = i.indrelid) "
7981 "LEFT JOIN pg_catalog.pg_constraint c "
7982 "ON (i.indrelid = c.conrelid AND "
7983 "i.indexrelid = c.conindid AND "
7984 "c.contype IN ('p','u','x')) "
7985 "LEFT JOIN pg_catalog.pg_inherits inh "
7986 "ON (inh.inhrelid = indexrelid) "
7987 "WHERE (i.indisvalid OR t2.relkind = 'p') "
7989 "ORDER BY i.indrelid, indexname",
7999 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8000 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
8001 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
8002 "LEFT JOIN pg_catalog.pg_constraint c "
8003 "ON (i.indrelid = c.conrelid AND "
8004 "i.indexrelid = c.conindid AND "
8005 "c.contype IN ('p','u','x')) "
8006 "WHERE i.indisvalid AND i.indisready "
8007 "ORDER BY i.indrelid, indexname",
8015 i_tableoid =
PQfnumber(res,
"tableoid");
8017 i_indrelid =
PQfnumber(res,
"indrelid");
8018 i_indexname =
PQfnumber(res,
"indexname");
8019 i_relpages =
PQfnumber(res,
"relpages");
8020 i_reltuples =
PQfnumber(res,
"reltuples");
8021 i_relallvisible =
PQfnumber(res,
"relallvisible");
8022 i_relallfrozen =
PQfnumber(res,
"relallfrozen");
8023 i_parentidx =
PQfnumber(res,
"parentidx");
8024 i_indexdef =
PQfnumber(res,
"indexdef");
8025 i_indnkeyatts =
PQfnumber(res,
"indnkeyatts");
8026 i_indnatts =
PQfnumber(res,
"indnatts");
8028 i_indisclustered =
PQfnumber(res,
"indisclustered");
8029 i_indisreplident =
PQfnumber(res,
"indisreplident");
8030 i_indnullsnotdistinct =
PQfnumber(res,
"indnullsnotdistinct");
8033 i_condeferrable =
PQfnumber(res,
"condeferrable");
8034 i_condeferred =
PQfnumber(res,
"condeferred");
8035 i_conperiod =
PQfnumber(res,
"conperiod");
8036 i_contableoid =
PQfnumber(res,
"contableoid");
8039 i_indattnames =
PQfnumber(res,
"indattnames");
8040 i_tablespace =
PQfnumber(res,
"tablespace");
8041 i_indreloptions =
PQfnumber(res,
"indreloptions");
8042 i_indstatcols =
PQfnumber(res,
"indstatcols");
8043 i_indstatvals =
PQfnumber(res,
"indstatvals");
8052 for (
int j = 0;
j < ntups;)
8056 char **indAttNames = NULL;
8057 int nindAttNames = 0;
8061 for (numinds = 1; numinds < ntups -
j; numinds++)
8069 while (++curtblindx < numTables)
8071 tbinfo = &tblinfo[curtblindx];
8075 if (curtblindx >= numTables)
8076 pg_fatal(
"unrecognized table OID %u", indrelid);
8080 pg_fatal(
"unexpected index data for table \"%s\"",
8087 for (
int c = 0;
c < numinds;
c++,
j++)
8102 indxinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8113 indxinfo[
j].indkeys, indxinfo[
j].indnattrs);
8123 if (indxinfo[
j].parentidx == 0)
8124 indexkind = RELKIND_INDEX;
8126 indexkind = RELKIND_PARTITIONED_INDEX;
8131 &indAttNames, &nindAttNames))
8132 pg_fatal(
"could not parse %s array",
"indattnames");
8137 relallvisible, relallfrozen, indexkind,
8138 indAttNames, nindAttNames);
8141 if (contype ==
'p' || contype ==
'u' || contype ==
'x')
8156 constrinfo->
dobj.namespace = tbinfo->
dobj.namespace;
8159 constrinfo->
contype = contype;
8163 constrinfo->
condef = NULL;
8173 if (relstats != NULL)
8221 "stxnamespace, stxowner, stxrelid, NULL AS stxstattarget "
8222 "FROM pg_catalog.pg_statistic_ext");
8225 "stxnamespace, stxowner, stxrelid, stxstattarget "
8226 "FROM pg_catalog.pg_statistic_ext");
8232 i_tableoid =
PQfnumber(res,
"tableoid");
8235 i_stxnamespace =
PQfnumber(res,
"stxnamespace");
8236 i_stxowner =
PQfnumber(res,
"stxowner");
8237 i_stxrelid =
PQfnumber(res,
"stxrelid");
8238 i_stattarget =
PQfnumber(res,
"stxstattarget");
8242 for (
i = 0;
i < ntups;
i++)
8249 statsextinfo[
i].
dobj.namespace =
8303 for (
int i = 0;
i < numTables;
i++)
8311 if (tbloids->
len > 1)
8318 "SELECT c.tableoid, c.oid, "
8319 "conrelid, conname, confrelid, ");
8325 "pg_catalog.pg_get_constraintdef(c.oid) AS condef\n"
8326 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8327 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
8328 "WHERE contype = 'f' ",
8332 "AND conparentid = 0 ");
8334 "ORDER BY conrelid, conname");
8340 i_contableoid =
PQfnumber(res,
"tableoid");
8342 i_conrelid =
PQfnumber(res,
"conrelid");
8344 i_confrelid =
PQfnumber(res,
"confrelid");
8345 i_conindid =
PQfnumber(res,
"conindid");
8351 for (
int j = 0;
j < ntups;
j++)
8360 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != conrelid)
8362 while (++curtblindx < numTables)
8364 tbinfo = &tblinfo[curtblindx];
8368 if (curtblindx >= numTables)
8369 pg_fatal(
"unrecognized table OID %u", conrelid);
8377 constrinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8396 if (reftable && reftable->
relkind == RELKIND_PARTITIONED_TABLE)
8402 for (
int k = 0; k < reftable->
numIndexes; k++)
8410 refidx = &reftable->
indexes[k];
8480 "PREPARE getDomainConstraints(pg_catalog.oid) AS\n"
8481 "SELECT tableoid, oid, conname, "
8482 "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
8483 "convalidated, contype "
8484 "FROM pg_catalog.pg_constraint "
8485 "WHERE contypid = $1 AND contype IN (%s) "
8495 "EXECUTE getDomainConstraints('%u')",
8502 i_tableoid =
PQfnumber(res,
"tableoid");
8506 i_convalidated =
PQfnumber(res,
"convalidated");
8513 for (
int i = 0,
j = 0;
i < ntups;
i++)
8515 bool validated =
PQgetvalue(res,
i, i_convalidated)[0] ==
't';
8516 char contype = (
PQgetvalue(res,
i, i_contype))[0];
8519 if (contype == CONSTRAINT_CHECK)
8521 constraint = &constrinfo[
j++];
8526 Assert(contype == CONSTRAINT_NOTNULL);
8529 tyinfo->
notnull = &(constrinfo[ntups - 1]);
8538 constraint->
dobj.namespace = tyinfo->
dobj.namespace;
8541 constraint->
contype = contype;
8587 "tableoid, oid, rulename, "
8588 "ev_class AS ruletable, ev_type, is_instead, "
8599 i_tableoid =
PQfnumber(res,
"tableoid");
8601 i_rulename =
PQfnumber(res,
"rulename");
8602 i_ruletable =
PQfnumber(res,
"ruletable");
8604 i_is_instead =
PQfnumber(res,
"is_instead");
8605 i_ev_enabled =
PQfnumber(res,
"ev_enabled");
8607 for (
i = 0;
i < ntups;
i++)
8618 if (ruleinfo[
i].ruletable == NULL)
8619 pg_fatal(
"failed sanity check, parent table with OID %u of pg_rewrite entry with OID %u not found",
8620 ruletableoid, ruleinfo[
i].dobj.catId.oid);
8626 if (ruleinfo[
i].ruletable)
8635 if ((ruleinfo[
i].ruletable->relkind == RELKIND_VIEW ||
8693 for (
int i = 0;
i < numTables;
i++)
8702 if (tbloids->
len > 1)
8719 "SELECT t.tgrelid, t.tgname, "
8720 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8721 "t.tgenabled, t.tableoid, t.oid, "
8722 "t.tgparentid <> 0 AS tgispartition\n"
8723 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8724 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8725 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8726 "WHERE ((NOT t.tgisinternal AND t.tgparentid = 0) "
8727 "OR t.tgenabled != u.tgenabled) "
8728 "ORDER BY t.tgrelid, t.tgname",
8742 "SELECT t.tgrelid, t.tgname, "
8743 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8744 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition\n"
8745 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8746 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8747 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8748 "WHERE (NOT t.tgisinternal OR t.tgenabled != u.tgenabled) "
8749 "ORDER BY t.tgrelid, t.tgname",
8762 "SELECT t.tgrelid, t.tgname, "
8763 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8764 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition "
8765 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8766 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8767 "LEFT JOIN pg_catalog.pg_depend AS d ON "
8768 " d.classid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8769 " d.refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8771 "LEFT JOIN pg_catalog.pg_trigger AS pt ON pt.oid = refobjid "
8772 "WHERE (NOT t.tgisinternal OR t.tgenabled != pt.tgenabled) "
8773 "ORDER BY t.tgrelid, t.tgname",
8780 "SELECT t.tgrelid, t.tgname, "
8781 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8782 "t.tgenabled, false as tgispartition, "
8783 "t.tableoid, t.oid "
8784 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8785 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8786 "WHERE NOT tgisinternal "
8787 "ORDER BY t.tgrelid, t.tgname",
8795 i_tableoid =
PQfnumber(res,
"tableoid");
8799 i_tgenabled =
PQfnumber(res,
"tgenabled");
8800 i_tgispartition =
PQfnumber(res,
"tgispartition");
8810 for (
int j = 0;
j < ntups;)
8817 for (numtrigs = 1; numtrigs < ntups -
j; numtrigs++)
8825 while (++curtblindx < numTables)
8827 tbinfo = &tblinfo[curtblindx];
8831 if (curtblindx >= numTables)
8832 pg_fatal(
"unrecognized table OID %u", tgrelid);
8838 for (
int c = 0;
c < numtrigs;
c++,
j++)
8845 tginfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8887 "SELECT e.tableoid, e.oid, evtname, evtenabled, "
8888 "evtevent, evtowner, "
8889 "array_to_string(array("
8890 "select quote_literal(x) "
8891 " from unnest(evttags) as t(x)), ', ') as evttags, "
8892 "e.evtfoid::regproc as evtfname "
8893 "FROM pg_event_trigger e "
8902 i_tableoid =
PQfnumber(res,
"tableoid");
8905 i_evtevent =
PQfnumber(res,
"evtevent");
8906 i_evtowner =
PQfnumber(res,
"evtowner");
8908 i_evtfname =
PQfnumber(res,
"evtfname");
8909 i_evtenabled =
PQfnumber(res,
"evtenabled");
8911 for (
i = 0;
i < ntups;
i++)
8953 int i_lanplcallfoid;
8961 "lanname, lanpltrusted, lanplcallfoid, "
8962 "laninline, lanvalidator, "
8964 "acldefault('l', lanowner) AS acldefault, "
8976 i_tableoid =
PQfnumber(res,
"tableoid");
8979 i_lanpltrusted =
PQfnumber(res,
"lanpltrusted");
8980 i_lanplcallfoid =
PQfnumber(res,
"lanplcallfoid");
8981 i_laninline =
PQfnumber(res,
"laninline");
8982 i_lanvalidator =
PQfnumber(res,
"lanvalidator");
8984 i_acldefault =
PQfnumber(res,
"acldefault");
8985 i_lanowner =
PQfnumber(res,
"lanowner");
8987 for (
i = 0;
i < ntups;
i++)
9044 "castsource, casttarget, castfunc, castcontext, "
9047 "WHERE NOT EXISTS ( "
9048 "SELECT 1 FROM pg_range r "
9049 "WHERE c.castsource = r.rngtypid "
9050 "AND c.casttarget = r.rngmultitypid "
9057 "castsource, casttarget, castfunc, castcontext, "
9059 "FROM pg_cast ORDER BY 3,4");
9068 i_tableoid =
PQfnumber(res,
"tableoid");
9070 i_castsource =
PQfnumber(res,
"castsource");
9071 i_casttarget =
PQfnumber(res,
"casttarget");
9072 i_castfunc =
PQfnumber(res,
"castfunc");
9073 i_castcontext =
PQfnumber(res,
"castcontext");
9074 i_castmethod =
PQfnumber(res,
"castmethod");
9076 for (
i = 0;
i < ntups;
i++)
9100 if (sTypeInfo && tTypeInfo)
9122 appendPQExpBuffer(query,
"SELECT lanname FROM pg_language WHERE oid = %u", langid);
9157 "trftype, trflang, trffromsql::oid, trftosql::oid "
9158 "FROM pg_transform "
9167 i_tableoid =
PQfnumber(res,
"tableoid");
9171 i_trffromsql =
PQfnumber(res,
"trffromsql");
9172 i_trftosql =
PQfnumber(res,
"trftosql");
9174 for (
i = 0;
i < ntups;
i++)
9197 if (typeInfo && lanname)
9234 int i_attstattarget;
9244 int i_notnull_comment;
9245 int i_notnull_noinherit;
9246 int i_notnull_islocal;
9247 int i_notnull_invalidoid;
9250 int i_attcompression;
9251 int i_attfdwoptions;
9252 int i_attmissingval;
9267 for (
int i = 0;
i < numTables;
i++)
9272 if (tbinfo->
relkind == RELKIND_SEQUENCE)
9287 (tbinfo->
dobj.
catId.
oid == LargeObjectMetadataRelationId ||
9292 if (tbloids->
len > 1)
9299 if (checkoids->
len > 1)
9319 "a.attstattarget,\n"
9327 "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n"
9328 "array_to_string(a.attoptions, ', ') AS attoptions,\n"
9329 "CASE WHEN a.attcollation <> t.typcollation "
9330 "THEN a.attcollation ELSE 0 END AS attcollation,\n"
9331 "pg_catalog.array_to_string(ARRAY("
9332 "SELECT pg_catalog.quote_ident(option_name) || "
9333 "' ' || pg_catalog.quote_literal(option_value) "
9334 "FROM pg_catalog.pg_options_to_table(attfdwoptions) "
9335 "ORDER BY option_name"
9336 "), E',\n ') AS attfdwoptions,\n");
9358 "co.conname AS notnull_name,\n"
9359 "CASE WHEN co.convalidated THEN pt.description"
9360 " ELSE NULL END AS notnull_comment,\n"
9361 "CASE WHEN NOT co.convalidated THEN co.oid "
9362 "ELSE NULL END AS notnull_invalidoid,\n"
9363 "co.connoinherit AS notnull_noinherit,\n"
9364 "co.conislocal AS notnull_islocal,\n");
9367 "CASE WHEN a.attnotnull THEN '' ELSE NULL END AS notnull_name,\n"
9368 "NULL AS notnull_comment,\n"
9369 "NULL AS notnull_invalidoid,\n"
9370 "false AS notnull_noinherit,\n"
9371 "CASE WHEN a.attislocal THEN true\n"
9372 " WHEN a.attnotnull AND NOT a.attislocal THEN true\n"
9374 "END AS notnull_islocal,\n");
9378 "a.attcompression AS attcompression,\n");
9381 "'' AS attcompression,\n");
9385 "a.attidentity,\n");
9388 "'' AS attidentity,\n");
9392 "CASE WHEN a.atthasmissing AND NOT a.attisdropped "
9393 "THEN a.attmissingval ELSE null END AS attmissingval,\n");
9396 "NULL AS attmissingval,\n");
9400 "a.attgenerated\n");
9403 "'' AS attgenerated\n");
9407 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9408 "JOIN pg_catalog.pg_attribute a ON (src.tbloid = a.attrelid) "
9409 "LEFT JOIN pg_catalog.pg_type t "
9410 "ON (a.atttypid = t.oid)\n",
9419 " LEFT JOIN pg_catalog.pg_constraint co ON "
9420 "(a.attrelid = co.conrelid\n"
9421 " AND co.contype = 'n' AND "
9422 "co.conkey = array[a.attnum])\n"
9423 " LEFT JOIN pg_catalog.pg_description pt ON "
9424 "(pt.classoid = co.tableoid AND pt.objoid = co.oid)\n");
9427 "WHERE a.attnum > 0::pg_catalog.int2\n"
9428 "ORDER BY a.attrelid, a.attnum");
9434 i_attrelid =
PQfnumber(res,
"attrelid");
9437 i_atttypname =
PQfnumber(res,
"atttypname");
9438 i_attstattarget =
PQfnumber(res,
"attstattarget");
9439 i_attstorage =
PQfnumber(res,
"attstorage");
9440 i_typstorage =
PQfnumber(res,
"typstorage");
9441 i_attidentity =
PQfnumber(res,
"attidentity");
9442 i_attgenerated =
PQfnumber(res,
"attgenerated");
9443 i_attisdropped =
PQfnumber(res,
"attisdropped");
9445 i_attalign =
PQfnumber(res,
"attalign");
9446 i_attislocal =
PQfnumber(res,
"attislocal");
9447 i_notnull_name =
PQfnumber(res,
"notnull_name");
9448 i_notnull_comment =
PQfnumber(res,
"notnull_comment");
9449 i_notnull_invalidoid =
PQfnumber(res,
"notnull_invalidoid");
9450 i_notnull_noinherit =
PQfnumber(res,
"notnull_noinherit");
9451 i_notnull_islocal =
PQfnumber(res,
"notnull_islocal");
9452 i_attoptions =
PQfnumber(res,
"attoptions");
9453 i_attcollation =
PQfnumber(res,
"attcollation");
9454 i_attcompression =
PQfnumber(res,
"attcompression");
9455 i_attfdwoptions =
PQfnumber(res,
"attfdwoptions");
9456 i_attmissingval =
PQfnumber(res,
"attmissingval");
9457 i_atthasdef =
PQfnumber(res,
"atthasdef");
9468 for (
int r = 0; r < ntups;)
9476 for (numatts = 1; numatts < ntups - r; numatts++)
9484 while (++curtblindx < numTables)
9486 tbinfo = &tblinfo[curtblindx];
9490 if (curtblindx >= numTables)
9491 pg_fatal(
"unrecognized table OID %u", attrelid);
9493 if (tbinfo->
relkind == RELKIND_SEQUENCE ||
9496 (tbinfo->
dobj.
catId.
oid == LargeObjectMetadataRelationId ||
9498 pg_fatal(
"unexpected column data for table \"%s\"",
9525 hasdefaults =
false;
9527 for (
int j = 0;
j < numatts;
j++, r++)
9530 pg_fatal(
"invalid column numbering in table \"%s\"",
9553 i_notnull_invalidoid,
9554 i_notnull_noinherit,
9556 &invalidnotnulloids);
9566 if (
PQgetvalue(res, r, i_atthasdef)[0] ==
't')
9573 if (tbloids->
len > 1)
9580 if (invalidnotnulloids != NULL)
9600 "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc\n"
9601 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9602 "JOIN pg_catalog.pg_attrdef a ON (src.tbloid = a.adrelid)\n"
9603 "ORDER BY a.adrelid, a.adnum",
9612 for (
int j = 0;
j < numDefaults;
j++)
9624 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != adrelid)
9626 while (++curtblindx < numTables)
9628 tbinfo = &tblinfo[curtblindx];
9632 if (curtblindx >= numTables)
9633 pg_fatal(
"unrecognized table OID %u", adrelid);
9636 if (adnum <= 0 || adnum > tbinfo->
numatts)
9637 pg_fatal(
"invalid adnum value %d for table \"%s\"",
9652 attrdefs[
j].
adnum = adnum;
9656 attrdefs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9679 else if (tbinfo->
relkind == RELKIND_VIEW)
9697 if (!attrdefs[
j].separate)
9709 tbinfo->
attrdefs[adnum - 1] = &attrdefs[
j];
9730 pg_log_info(
"finding invalid not-null constraints");
9734 "SELECT c.tableoid, c.oid, conrelid, conname, "
9735 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9736 "conislocal, convalidated "
9737 "FROM unnest('%s'::pg_catalog.oid[]) AS src(conoid)\n"
9738 "JOIN pg_catalog.pg_constraint c ON (src.conoid = c.oid)\n"
9739 "ORDER BY c.conrelid, c.conname",
9740 invalidnotnulloids->
data);
9747 i_tableoid =
PQfnumber(res,
"tableoid");
9749 i_conrelid =
PQfnumber(res,
"conrelid");
9752 i_conislocal =
PQfnumber(res,
"conislocal");
9756 for (
int j = 0;
j < numConstrs;)
9763 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9771 while (++curtblindx < numTables)
9773 tbinfo = &tblinfo[curtblindx];
9777 if (curtblindx >= numTables)
9778 pg_fatal(
"unrecognized table OID %u", conrelid);
9780 for (
int c = 0;
c < numcons;
c++,
j++)
9787 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9832 "SELECT c.tableoid, c.oid, conrelid, conname, "
9833 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9834 "conislocal, convalidated "
9835 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9836 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
9837 "WHERE contype = 'c' "
9838 "ORDER BY c.conrelid, c.conname",
9846 i_tableoid =
PQfnumber(res,
"tableoid");
9848 i_conrelid =
PQfnumber(res,
"conrelid");
9851 i_conislocal =
PQfnumber(res,
"conislocal");
9852 i_convalidated =
PQfnumber(res,
"convalidated");
9856 for (
int j = 0;
j < numConstrs;)
9863 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9871 while (++curtblindx < numTables)
9873 tbinfo = &tblinfo[curtblindx];
9877 if (curtblindx >= numTables)
9878 pg_fatal(
"unrecognized table OID %u", conrelid);
9880 if (numcons != tbinfo->
ncheck)
9883 "expected %d check constraints on table \"%s\" but found %d",
9892 for (
int c = 0;
c < numcons;
c++,
j++)
9894 bool validated =
PQgetvalue(res,
j, i_convalidated)[0] ==
't';
9901 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9930 if (!constrs[
j].separate)
10000 int i_notnull_comment,
10001 int i_notnull_invalidoid,
10002 int i_notnull_noinherit,
10003 int i_notnull_islocal,
10019 char *constroid =
PQgetvalue(res, r, i_notnull_invalidoid);
10021 if (*invalidnotnulloids == NULL)
10087 char *default_name;
10092 if (strcmp(default_name,
10100 free(default_name);
10149 int i_prsnamespace;
10164 "prsstart::oid, prstoken::oid, "
10165 "prsend::oid, prsheadline::oid, prslextype::oid "
10166 "FROM pg_ts_parser");
10174 i_tableoid =
PQfnumber(res,
"tableoid");
10177 i_prsnamespace =
PQfnumber(res,
"prsnamespace");
10178 i_prsstart =
PQfnumber(res,
"prsstart");
10179 i_prstoken =
PQfnumber(res,
"prstoken");
10181 i_prsheadline =
PQfnumber(res,
"prsheadline");
10182 i_prslextype =
PQfnumber(res,
"prslextype");
10184 for (
i = 0;
i < ntups;
i++)
10191 prsinfo[
i].
dobj.namespace =
10223 int i_dictnamespace;
10225 int i_dicttemplate;
10226 int i_dictinitoption;
10231 "dictnamespace, dictowner, "
10232 "dicttemplate, dictinitoption "
10233 "FROM pg_ts_dict");
10241 i_tableoid =
PQfnumber(res,
"tableoid");
10243 i_dictname =
PQfnumber(res,
"dictname");
10244 i_dictnamespace =
PQfnumber(res,
"dictnamespace");
10245 i_dictowner =
PQfnumber(res,
"dictowner");
10246 i_dictinitoption =
PQfnumber(res,
"dictinitoption");
10247 i_dicttemplate =
PQfnumber(res,
"dicttemplate");
10249 for (
i = 0;
i < ntups;
i++)
10256 dictinfo[
i].
dobj.namespace =
10289 int i_tmplnamespace;
10296 "tmplnamespace, tmplinit::oid, tmpllexize::oid "
10297 "FROM pg_ts_template");
10305 i_tableoid =
PQfnumber(res,
"tableoid");
10307 i_tmplname =
PQfnumber(res,
"tmplname");
10308 i_tmplnamespace =
PQfnumber(res,
"tmplnamespace");
10309 i_tmplinit =
PQfnumber(res,
"tmplinit");
10310 i_tmpllexize =
PQfnumber(res,
"tmpllexize");
10312 for (
i = 0;
i < ntups;
i++)
10319 tmplinfo[
i].
dobj.namespace =
10348 int i_cfgnamespace;
10355 "cfgnamespace, cfgowner, cfgparser "
10356 "FROM pg_ts_config");
10364 i_tableoid =
PQfnumber(res,
"tableoid");
10367 i_cfgnamespace =
PQfnumber(res,
"cfgnamespace");
10368 i_cfgowner =
PQfnumber(res,
"cfgowner");
10369 i_cfgparser =
PQfnumber(res,
"cfgparser");
10371 for (
i = 0;
i < ntups;
i++)
10378 cfginfo[
i].
dobj.namespace =
10409 int i_fdwvalidator;
10418 "fdwhandler::pg_catalog.regproc, "
10419 "fdwvalidator::pg_catalog.regproc, "
10421 "acldefault('F', fdwowner) AS acldefault, "
10422 "array_to_string(ARRAY("
10423 "SELECT quote_ident(option_name) || ' ' || "
10424 "quote_literal(option_value) "
10425 "FROM pg_options_to_table(fdwoptions) "
10426 "ORDER BY option_name"
10427 "), E',\n ') AS fdwoptions "
10428 "FROM pg_foreign_data_wrapper");
10436 i_tableoid =
PQfnumber(res,
"tableoid");
10439 i_fdwowner =
PQfnumber(res,
"fdwowner");
10440 i_fdwhandler =
PQfnumber(res,
"fdwhandler");
10441 i_fdwvalidator =
PQfnumber(res,
"fdwvalidator");
10443 i_acldefault =
PQfnumber(res,
"acldefault");
10444 i_fdwoptions =
PQfnumber(res,
"fdwoptions");
10446 for (
i = 0;
i < ntups;
i++)
10453 fdwinfo[
i].
dobj.namespace = NULL;
10503 "srvfdw, srvtype, srvversion, srvacl, "
10504 "acldefault('S', srvowner) AS acldefault, "
10505 "array_to_string(ARRAY("
10506 "SELECT quote_ident(option_name) || ' ' || "
10507 "quote_literal(option_value) "
10508 "FROM pg_options_to_table(srvoptions) "
10509 "ORDER BY option_name"
10510 "), E',\n ') AS srvoptions "
10511 "FROM pg_foreign_server");
10519 i_tableoid =
PQfnumber(res,
"tableoid");
10522 i_srvowner =
PQfnumber(res,
"srvowner");
10525 i_srvversion =
PQfnumber(res,
"srvversion");
10527 i_acldefault =
PQfnumber(res,
"acldefault");
10528 i_srvoptions =
PQfnumber(res,
"srvoptions");
10530 for (
i = 0;
i < ntups;
i++)
10537 srvinfo[
i].
dobj.namespace = NULL;
10578 int i_defaclnamespace;
10579 int i_defaclobjtype;
10600 "SELECT oid, tableoid, "
10602 "defaclnamespace, "
10605 "CASE WHEN defaclnamespace = 0 THEN "
10606 "acldefault(CASE WHEN defaclobjtype = 'S' "
10607 "THEN 's'::\"char\" ELSE defaclobjtype END, "
10608 "defaclrole) ELSE '{}' END AS acldefault "
10609 "FROM pg_default_acl");
10618 i_tableoid =
PQfnumber(res,
"tableoid");
10619 i_defaclrole =
PQfnumber(res,
"defaclrole");
10620 i_defaclnamespace =
PQfnumber(res,
"defaclnamespace");
10621 i_defaclobjtype =
PQfnumber(res,
"defaclobjtype");
10622 i_defaclacl =
PQfnumber(res,
"defaclacl");
10623 i_acldefault =
PQfnumber(res,
"acldefault");
10625 for (
i = 0;
i < ntups;
i++)
10639 daclinfo[
i].
dobj.namespace = NULL;
10678 while (low <= high)
10682 if (roleoid < middle->roleoid)
10684 else if (roleoid > middle->
roleoid)
10691 pg_fatal(
"role with OID %u does not exist", roleoid);
10708 query =
"SELECT oid, rolname FROM pg_catalog.pg_roles ORDER BY 1";
10746 "SELECT DISTINCT attrelid FROM pg_attribute "
10747 "WHERE attacl IS NOT NULL");
10752 for (
i = 0;
i < ntups;
i++)
10771 "SELECT objoid, classoid, objsubid, privtype, initprivs "
10772 "FROM pg_init_privs");
10777 for (
i = 0;
i < ntups;
i++)
10788 objId.
oid = objoid;
10800 ((
TableInfo *) dobj)->hascolumnACLs =
true;
10804 classoid, objoid, objsubid);
10813 strcmp(dobj->
name,
"public") == 0)
10833 classoid, objoid, objsubid);
10867 const char *
name,
const char *
namespace,
10868 const char *owner,
CatalogId catalogId,
10869 int subid,
DumpId dumpId,
10870 const char *initdb_comment)
10881 if (strcmp(
type,
"LARGE OBJECT") != 0)
10906 if (initdb_comment != NULL)
10932 if (
namespace && *
namespace)
10947 .namespace =
namespace,
10949 .description =
"COMMENT",
10951 .createStmt = query->
data,
10967 const char *
name,
const char *
namespace,
10968 const char *owner,
CatalogId catalogId,
10969 int subid,
DumpId dumpId)
10972 catalogId, subid, dumpId, NULL);
10983 const char *argtype,
const char *argval)
11008 static bool restarted;
11047 for (; te != AH->
toc && count < max_rels; te = te->
next)
11050 strcmp(te->
desc,
"STATISTICS DATA") == 0)
11103 int i_most_common_vals;
11104 int i_most_common_freqs;
11105 int i_histogram_bounds;
11107 int i_most_common_elems;
11108 int i_most_common_elem_freqs;
11109 int i_elem_count_histogram;
11110 int i_range_length_histogram;
11111 int i_range_empty_frac;
11112 int i_range_bounds_histogram;
11122 expected_te = expected_te->
next;
11124 strcmp(expected_te->
desc,
"STATISTICS DATA") != 0)
11125 expected_te = expected_te->
next;
11127 if (te != expected_te)
11128 pg_fatal(
"statistics dumped out of order (current: %d %s %s, expected: %d %s %s)",
11136 "PREPARE getAttributeStats(pg_catalog.name[], pg_catalog.name[]) AS\n"
11137 "SELECT s.schemaname, s.tablename, s.attname, s.inherited, "
11138 "s.null_frac, s.avg_width, s.n_distinct, "
11139 "s.most_common_vals, s.most_common_freqs, "
11140 "s.histogram_bounds, s.correlation, "
11141 "s.most_common_elems, s.most_common_elem_freqs, "
11142 "s.elem_count_histogram, ");
11146 "s.range_length_histogram, "
11147 "s.range_empty_frac, "
11148 "s.range_bounds_histogram ");
11151 "NULL AS range_length_histogram,"
11152 "NULL AS range_empty_frac,"
11153 "NULL AS range_bounds_histogram ");
11170 "FROM pg_catalog.pg_stats s "
11171 "JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
11172 "ON s.schemaname = u.schemaname "
11173 "AND s.tablename = u.tablename "
11174 "WHERE s.tablename = ANY($2) "
11175 "ORDER BY u.ord, s.attname, s.inherited");
11178 "FROM pg_catalog.pg_stats s "
11179 "WHERE s.schemaname = $1[1] "
11180 "AND s.tablename = $2[1] "
11181 "ORDER BY s.attname, s.inherited");
11232 i_schemaname =
PQfnumber(res,
"schemaname");
11233 i_tablename =
PQfnumber(res,
"tablename");
11235 i_inherited =
PQfnumber(res,
"inherited");
11236 i_null_frac =
PQfnumber(res,
"null_frac");
11237 i_avg_width =
PQfnumber(res,
"avg_width");
11238 i_n_distinct =
PQfnumber(res,
"n_distinct");
11239 i_most_common_vals =
PQfnumber(res,
"most_common_vals");
11240 i_most_common_freqs =
PQfnumber(res,
"most_common_freqs");
11241 i_histogram_bounds =
PQfnumber(res,
"histogram_bounds");
11242 i_correlation =
PQfnumber(res,
"correlation");
11243 i_most_common_elems =
PQfnumber(res,
"most_common_elems");
11244 i_most_common_elem_freqs =
PQfnumber(res,
"most_common_elem_freqs");
11245 i_elem_count_histogram =
PQfnumber(res,
"elem_count_histogram");
11246 i_range_length_histogram =
PQfnumber(res,
"range_length_histogram");
11247 i_range_empty_frac =
PQfnumber(res,
"range_empty_frac");
11248 i_range_bounds_histogram =
PQfnumber(res,
"range_bounds_histogram");
11251 for (; rownum <
PQntuples(res); rownum++)
11256 if (strcmp(te->
tag,
PQgetvalue(res, rownum, i_tablename)) != 0 ||
11257 strcmp(te->namespace,
PQgetvalue(res, rownum, i_schemaname)) != 0)
11269 pg_fatal(
"unexpected null attname");
11284 bool found =
false;
11313 if (!
PQgetisnull(res, rownum, i_most_common_vals))
11315 PQgetvalue(res, rownum, i_most_common_vals));
11316 if (!
PQgetisnull(res, rownum, i_most_common_freqs))
11318 PQgetvalue(res, rownum, i_most_common_freqs));
11319 if (!
PQgetisnull(res, rownum, i_histogram_bounds))
11321 PQgetvalue(res, rownum, i_histogram_bounds));
11325 if (!
PQgetisnull(res, rownum, i_most_common_elems))
11327 PQgetvalue(res, rownum, i_most_common_elems));
11328 if (!
PQgetisnull(res, rownum, i_most_common_elem_freqs))
11330 PQgetvalue(res, rownum, i_most_common_elem_freqs));
11331 if (!
PQgetisnull(res, rownum, i_elem_count_histogram))
11333 PQgetvalue(res, rownum, i_elem_count_histogram));
11336 if (!
PQgetisnull(res, rownum, i_range_length_histogram))
11338 PQgetvalue(res, rownum, i_range_length_histogram));
11339 if (!
PQgetisnull(res, rownum, i_range_empty_frac))
11341 PQgetvalue(res, rownum, i_range_empty_frac));
11342 if (!
PQgetisnull(res, rownum, i_range_bounds_histogram))
11344 PQgetvalue(res, rownum, i_range_bounds_histogram));
11371 .namespace = dobj->namespace->dobj.
name,
11372 .description =
"STATISTICS DATA",
11377 .nDeps = dobj->
nDeps));
11388 const char *reltypename)
11435 .namespace = tbinfo->
dobj.namespace->dobj.
name,
11437 .description =
"COMMENT",
11439 .createStmt = query->
data,
11443 else if (objsubid > 0 && objsubid <= tbinfo->numatts)
11460 .namespace = tbinfo->
dobj.namespace->dobj.
name,
11462 .description =
"COMMENT",
11464 .createStmt = query->
data,
11497 while (low <= high)
11499 middle = low + (high - low) / 2;
11501 if (classoid < middle->classoid)
11503 else if (classoid > middle->
classoid)
11505 else if (objoid < middle->objoid)
11507 else if (objoid > middle->
objoid)
11525 while (middle > low)
11527 if (classoid != middle[-1].classoid ||
11528 objoid != middle[-1].objoid)
11537 while (middle <= high)
11539 if (classoid != middle->
classoid ||
11540 objoid != middle->
objoid)
11577 "FROM pg_catalog.pg_description "
11578 "ORDER BY classoid, objoid, objsubid");
11584 i_description =
PQfnumber(res,
"description");
11585 i_classoid =
PQfnumber(res,
"classoid");
11587 i_objsubid =
PQfnumber(res,
"objsubid");
11595 for (
i = 0;
i < ntups;
i++)
11605 if (dobj == NULL ||
11618 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
11657 if (dobj->
dump == 0)
11783 if (loinfo == NULL)
11784 pg_fatal(
"missing metadata for large objects \"%s\"",
11790 .description =
"BLOBS",
11792 .deps = dobj->dependencies,
11793 .nDeps = dobj->nDeps,
11795 .dumpArg = loinfo));
11868 "-- *not* dropping schema, since initdb creates it\n");
11870 "-- *not* creating schema, since initdb creates it\n");
11875 "SCHEMA", qnspname, NULL);
11881 .description =
"SCHEMA",
11883 .createStmt = q->
data,
11884 .dropStmt = delq->
data));
11889 const char *initdb_comment = NULL;
11891 if (!nspinfo->
create && strcmp(qnspname,
"public") == 0)
11892 initdb_comment =
"standard public schema";
11906 qnspname, NULL, NULL,
11951 qextname,
fmtId(extinfo->namespace));
11966 appendPQExpBufferStr(q,
"-- For binary upgrade, create an empty extension and insert objects into it\n");
11976 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
12021 .description =
"EXTENSION",
12023 .createStmt = q->
data,
12024 .dropStmt = delq->
data));
12052 if (tyinfo->
typtype == TYPTYPE_BASE)
12054 else if (tyinfo->
typtype == TYPTYPE_DOMAIN)
12056 else if (tyinfo->
typtype == TYPTYPE_COMPOSITE)
12058 else if (tyinfo->
typtype == TYPTYPE_ENUM)
12060 else if (tyinfo->
typtype == TYPTYPE_RANGE)
12065 pg_log_warning(
"typtype of data type \"%s\" appears to be invalid",
12094 "PREPARE dumpEnumType(pg_catalog.oid) AS\n"
12095 "SELECT oid, enumlabel "
12096 "FROM pg_catalog.pg_enum "
12097 "WHERE enumtypid = $1 "
12098 "ORDER BY enumsortorder");
12106 "EXECUTE dumpEnumType('%u')",
12132 i_enumlabel =
PQfnumber(res,
"enumlabel");
12135 for (
i = 0;
i < num;
i++)
12150 i_enumlabel =
PQfnumber(res,
"enumlabel");
12153 for (
i = 0;
i < num;
i++)
12161 "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
12172 tyinfo->
dobj.namespace->dobj.
name);
12177 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12179 .description =
"TYPE",
12181 .createStmt = q->
data,
12182 .dropStmt = delq->
data));
12198 tyinfo->
dobj.namespace->dobj.
name,
12230 "PREPARE dumpRangeType(pg_catalog.oid) AS\n");
12237 "pg_catalog.format_type(rngmultitypid, NULL) AS rngmultitype, ");
12240 "NULL AS rngmultitype, ");
12243 "pg_catalog.format_type(rngsubtype, NULL) AS rngsubtype, "
12244 "opc.opcname AS opcname, "
12245 "(SELECT nspname FROM pg_catalog.pg_namespace nsp "
12246 " WHERE nsp.oid = opc.opcnamespace) AS opcnsp, "
12248 "CASE WHEN rngcollation = st.typcollation THEN 0 "
12249 " ELSE rngcollation END AS collation, "
12250 "rngcanonical, rngsubdiff "
12251 "FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
12252 " pg_catalog.pg_opclass opc "
12253 "WHERE st.oid = rngsubtype AND opc.oid = rngsubopc AND "
12262 "EXECUTE dumpRangeType('%u')",
12313 if (strcmp(procname,
"-") != 0)
12317 if (strcmp(procname,
"-") != 0)
12325 tyinfo->
dobj.namespace->dobj.
name);
12330 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12332 .description =
"TYPE",
12334 .createStmt = q->
data,
12335 .dropStmt = delq->
data));
12351 tyinfo->
dobj.namespace->dobj.
name,
12396 tyinfo->
dobj.namespace->dobj.
name);
12401 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12403 .description =
"TYPE",
12405 .createStmt = q->
data,
12406 .dropStmt = delq->
data));
12422 tyinfo->
dobj.namespace->dobj.
name,
12453 char *typsubscript;
12459 Oid typsubscriptoid;
12461 char *typispreferred;
12466 char *typcollatable;
12468 bool typdefault_is_literal =
false;
12474 "PREPARE dumpBaseType(pg_catalog.oid) AS\n"
12476 "typinput, typoutput, typreceive, typsend, "
12477 "typreceive::pg_catalog.oid AS typreceiveoid, "
12478 "typsend::pg_catalog.oid AS typsendoid, "
12480 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
12481 "typdelim, typbyval, typalign, typstorage, "
12482 "typmodin, typmodout, "
12483 "typmodin::pg_catalog.oid AS typmodinoid, "
12484 "typmodout::pg_catalog.oid AS typmodoutoid, "
12485 "typcategory, typispreferred, "
12486 "(typcollation <> 0) AS typcollatable, "
12487 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault, ");
12492 "typsubscript::pg_catalog.oid AS typsubscriptoid ");
12495 "'-' AS typsubscript, 0 AS typsubscriptoid ");
12506 "EXECUTE dumpBaseType('%u')",
12538 typdefault_is_literal =
true;
12563 "CREATE TYPE %s (\n"
12564 " INTERNALLENGTH = %s",
12566 (strcmp(typlen,
"-1") == 0) ?
"variable" : typlen);
12582 if (strcmp(typcollatable,
"t") == 0)
12585 if (typdefault != NULL)
12588 if (typdefault_is_literal)
12602 if (strcmp(typcategory,
"U") != 0)
12608 if (strcmp(typispreferred,
"t") == 0)
12611 if (typdelim && strcmp(typdelim,
",") != 0)
12619 else if (*
typalign == TYPALIGN_SHORT)
12621 else if (*
typalign == TYPALIGN_INT)
12623 else if (*
typalign == TYPALIGN_DOUBLE)
12626 if (*typstorage == TYPSTORAGE_PLAIN)
12628 else if (*typstorage == TYPSTORAGE_EXTERNAL)
12630 else if (*typstorage == TYPSTORAGE_EXTENDED)
12632 else if (*typstorage == TYPSTORAGE_MAIN)
12635 if (strcmp(typbyval,
"t") == 0)
12643 tyinfo->
dobj.namespace->dobj.
name);
12648 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12650 .description =
"TYPE",
12652 .createStmt = q->
data,
12653 .dropStmt = delq->
data));
12669 tyinfo->
dobj.namespace->dobj.
name,
12699 bool typdefault_is_literal =
false;
12705 "PREPARE dumpDomain(pg_catalog.oid) AS\n");
12708 "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
12709 "pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
12711 "CASE WHEN t.typcollation <> u.typcollation "
12712 "THEN t.typcollation ELSE 0 END AS typcollation "
12713 "FROM pg_catalog.pg_type t "
12714 "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
12715 "WHERE t.oid = $1");
12723 "EXECUTE dumpDomain('%u')",
12735 typdefault_is_literal =
true;
12751 "CREATE DOMAIN %s AS %s",
12771 if (typnotnull[0] ==
't')
12781 char *default_name;
12786 if (strcmp(default_name, notnull->
dobj.
name) == 0)
12791 free(default_name);
12796 if (typdefault != NULL)
12799 if (typdefault_is_literal)
12825 "DOMAIN", qtypname,
12826 tyinfo->
dobj.namespace->dobj.
name);
12831 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12833 .description =
"DOMAIN",
12835 .createStmt = q->
data,
12836 .dropStmt = delq->
data));
12852 tyinfo->
dobj.namespace->dobj.
name,
12871 tyinfo->
dobj.namespace->dobj.
name,
12891 tyinfo->
dobj.namespace->dobj.
name,
12925 int i_attisdropped;
12926 int i_attcollation;
12941 "PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
12942 "SELECT a.attname, a.attnum, "
12943 "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
12944 "a.attlen, a.attalign, a.attisdropped, "
12945 "CASE WHEN a.attcollation <> at.typcollation "
12946 "THEN a.attcollation ELSE 0 END AS attcollation "
12947 "FROM pg_catalog.pg_type ct "
12948 "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
12949 "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
12950 "WHERE ct.oid = $1 "
12951 "ORDER BY a.attnum");
12959 "EXECUTE dumpCompositeType('%u')",
12967 i_atttypdefn =
PQfnumber(res,
"atttypdefn");
12969 i_attalign =
PQfnumber(res,
"attalign");
12970 i_attisdropped =
PQfnumber(res,
"attisdropped");
12971 i_attcollation =
PQfnumber(res,
"attcollation");
12988 for (
i = 0;
i < ntups;
i++)
13001 attisdropped = (
PQgetvalue(res,
i, i_attisdropped)[0] ==
't');
13008 if (actual_atts++ > 0)
13039 "\n-- For binary upgrade, recreate dropped column.\n");
13041 "SET attlen = %s, "
13042 "attalign = '%s', attbyval = false\n"
13063 tyinfo->
dobj.namespace->dobj.
name);
13068 .namespace = tyinfo->
dobj.namespace->dobj.
name,
13070 .description =
"TYPE",
13072 .createStmt = q->
data,
13073 .dropStmt = delq->
data));
13090 tyinfo->
dobj.namespace->dobj.
name,
13127 int i_attisdropped;
13148 i_attisdropped =
PQfnumber(res,
"attisdropped");
13154 for (
i = 0;
i < ntups;
i++)
13181 .namespace = tyinfo->
dobj.namespace->dobj.
name,
13183 .description =
"COMMENT",
13185 .createStmt = query->
data,
13236 .namespace = stinfo->
dobj.namespace->dobj.
name,
13238 .description =
"SHELL TYPE",
13240 .createStmt = q->
data));
13275 if (funcInfo != NULL && !funcInfo->
dobj.
dump)
13281 if (inlineInfo != NULL && !inlineInfo->
dobj.
dump)
13288 if (validatorInfo != NULL && !validatorInfo->
dobj.
dump)
13289 validatorInfo = NULL;
13297 useParams = (funcInfo != NULL &&
13341 "LANGUAGE", qlanname, NULL);
13347 .description =
"PROCEDURAL LANGUAGE",
13349 .createStmt = defqry->
data,
13350 .dropStmt = delqry->
data,
13366 qlanname, NULL, NULL,
13389 if (is_agg && finfo->
nargs == 0)
13416 for (
j = 0;
j < finfo->
nargs;
j++)
13444 char *funcfullsig = NULL;
13446 char *qual_funcsig;
13459 char *proleakproof;
13466 char **configitems = NULL;
13467 int nconfigitems = 0;
13468 const char *keyword;
13483 "PREPARE dumpFunc(pg_catalog.oid) AS\n");
13497 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
13498 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
13499 "pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
13500 "proleakproof,\n");
13504 "array_to_string(protrftypes, ' ') AS protrftypes,\n");
13507 "NULL AS protrftypes,\n");
13514 "'u' AS proparallel,\n");
13521 "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n");
13528 "'-' AS prosupport,\n");
13532 "pg_get_function_sqlbody(p.oid) AS prosqlbody\n");
13535 "NULL AS prosqlbody\n");
13538 "FROM pg_catalog.pg_proc p, pg_catalog.pg_language l\n"
13539 "WHERE p.oid = $1 "
13540 "AND l.oid = p.prolang");
13548 "EXECUTE dumpFunc('%u')",
13590 else if (probin[0] !=
'\0')
13594 if (prosrc[0] !=
'\0')
13603 (strchr(prosrc,
'\'') == NULL && strchr(prosrc,
'\\') == NULL))
13621 if (!
parsePGArray(proconfig, &configitems, &nconfigitems))
13622 pg_fatal(
"could not parse %s array",
"proconfig");
13626 configitems = NULL;
13639 if (prokind[0] == PROKIND_PROCEDURE)
13640 keyword =
"PROCEDURE";
13642 keyword =
"FUNCTION";
13645 keyword, qual_funcsig);
13650 funcfullsig ? funcfullsig :
13653 if (prokind[0] == PROKIND_PROCEDURE)
13655 else if (funcresult)
13659 (proretset[0] ==
't') ?
"SETOF " :
"",
13672 for (
i = 0; typeids[
i];
i++)
13683 if (prokind[0] == PROKIND_WINDOW)
13686 if (provolatile[0] != PROVOLATILE_VOLATILE)
13688 if (provolatile[0] == PROVOLATILE_IMMUTABLE)
13690 else if (provolatile[0] == PROVOLATILE_STABLE)
13692 else if (provolatile[0] != PROVOLATILE_VOLATILE)
13693 pg_fatal(
"unrecognized provolatile value for function \"%s\"",
13697 if (proisstrict[0] ==
't')
13700 if (prosecdef[0] ==
't')
13703 if (proleakproof[0] ==
't')
13711 if (strcmp(procost,
"0") != 0)
13713 if (strcmp(lanname,
"internal") == 0 || strcmp(lanname,
"c") == 0)
13716 if (strcmp(procost,
"1") != 0)
13722 if (strcmp(procost,
"100") != 0)
13726 if (proretset[0] ==
't' &&
13727 strcmp(prorows,
"0") != 0 && strcmp(prorows,
"1000") != 0)
13730 if (strcmp(prosupport,
"-") != 0)
13736 if (proparallel[0] != PROPARALLEL_UNSAFE)
13738 if (proparallel[0] == PROPARALLEL_SAFE)
13740 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
13742 else if (proparallel[0] != PROPARALLEL_UNSAFE)
13743 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
13747 for (
int i = 0;
i < nconfigitems;
i++)
13750 char *configitem = configitems[
i];
13753 pos = strchr(configitem,
'=');
13785 if (*namelist == NULL)
13787 for (nameptr = namelist; *nameptr; nameptr++)
13789 if (nameptr != namelist)
13803 "pg_catalog.pg_proc", keyword,
13809 finfo->
dobj.namespace->dobj.
name);
13814 .
namespace = finfo->
dobj.namespace->dobj.
name,
13816 .description = keyword,
13819 .createStmt = q->
data,
13820 .dropStmt = delqry->
data));
13848 free(qual_funcsig);
13865 const char *sourceType;
13866 const char *targetType;
13876 if (funcInfo == NULL)
13877 pg_fatal(
"could not find function definition for function with OID %u",
13889 sourceType, targetType);
13892 sourceType, targetType);
13896 case COERCION_METHOD_BINARY:
13899 case COERCION_METHOD_INOUT:
13902 case COERCION_METHOD_FUNCTION:
13916 pg_log_warning(
"bogus value in pg_cast.castfunc or pg_cast.castmethod field");
13929 sourceType, targetType);
13932 sourceType, targetType);
13936 "CAST", castargs->
data, NULL);
13941 .description =
"CAST",
13943 .createStmt = defqry->
data,
13944 .dropStmt = delqry->
data));
13972 const char *transformType;
13982 if (fromsqlFuncInfo == NULL)
13983 pg_fatal(
"could not find function definition for function with OID %u",
13989 if (tosqlFuncInfo == NULL)
13990 pg_fatal(
"could not find function definition for function with OID %u",
14003 transformType, lanname);
14006 transformType, lanname);
14009 pg_log_warning(
"bogus transform definition, at least one of trffromsql and trftosql should be nonzero");
14013 if (fromsqlFuncInfo)
14053 transformType, lanname);
14056 transformType, lanname);
14060 "TRANSFORM", transformargs->
data, NULL);
14065 .description =
"TRANSFORM",
14067 .createStmt = defqry->
data,
14068 .dropStmt = delqry->
data,
14144 "PREPARE dumpOpr(pg_catalog.oid) AS\n"
14146 "oprcode::pg_catalog.regprocedure, "
14147 "oprleft::pg_catalog.regtype, "
14148 "oprright::pg_catalog.regtype, "
14151 "oprrest::pg_catalog.regprocedure, "
14152 "oprjoin::pg_catalog.regprocedure, "
14153 "oprcanmerge, oprcanhash "
14154 "FROM pg_catalog.pg_operator "
14163 "EXECUTE dumpOpr('%u')",
14171 i_oprright =
PQfnumber(res,
"oprright");
14173 i_oprnegate =
PQfnumber(res,
"oprnegate");
14176 i_oprcanmerge =
PQfnumber(res,
"oprcanmerge");
14177 i_oprcanhash =
PQfnumber(res,
"oprcanhash");
14184 oprnegate =
PQgetvalue(res, 0, i_oprnegate);
14187 oprcanmerge =
PQgetvalue(res, 0, i_oprcanmerge);
14188 oprcanhash =
PQgetvalue(res, 0, i_oprcanhash);
14191 if (strcmp(oprkind,
"r") == 0)
14192 pg_log_warning(
"postfix operators are not supported anymore (operator \"%s\")",
14210 if (strcmp(oprkind,
"r") == 0 ||
14211 strcmp(oprkind,
"b") == 0)
14219 if (strcmp(oprkind,
"l") == 0 ||
14220 strcmp(oprkind,
"b") == 0)
14242 if (strcmp(oprcanmerge,
"t") == 0)
14245 if (strcmp(oprcanhash,
"t") == 0)
14272 "OPERATOR",
oprid->data,
14273 oprinfo->
dobj.namespace->dobj.
name);
14278 .namespace = oprinfo->
dobj.namespace->dobj.
name,
14280 .description =
"OPERATOR",
14282 .createStmt = q->
data,
14283 .dropStmt = delq->
data));
14317 if (strcmp(proc,
"-") == 0)
14323 for (paren =
name; *paren; paren++)
14325 if (*paren ==
'(' && !inquote)
14331 inquote = !inquote;
14356 if (strcmp(oproid,
"0") == 0)
14360 if (oprInfo == NULL)
14367 return psprintf(
"OPERATOR(%s.%s)",
14388 "SELECT '%u'::pg_catalog.regproc", funcOid);
14431 aminfo->
amtype, qamname);
14445 "ACCESS METHOD", qamname, NULL);
14450 .description =
"ACCESS METHOD",
14452 .createStmt = q->
data,
14453 .dropStmt = delq->
data));
14484 int i_opcfamilyname;
14485 int i_opcfamilynsp;
14487 int i_amopstrategy;
14490 int i_sortfamilynsp;
14493 int i_amproclefttype;
14494 int i_amprocrighttype;
14499 char *opcfamilyname;
14500 char *opcfamilynsp;
14502 char *amopstrategy;
14505 char *sortfamilynsp;
14508 char *amproclefttype;
14509 char *amprocrighttype;
14524 "opckeytype::pg_catalog.regtype, "
14525 "opcdefault, opcfamily, "
14526 "opfname AS opcfamilyname, "
14527 "nspname AS opcfamilynsp, "
14528 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS amname "
14529 "FROM pg_catalog.pg_opclass c "
14530 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily "
14531 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14532 "WHERE c.oid = '%u'::pg_catalog.oid",
14537 i_opcintype =
PQfnumber(res,
"opcintype");
14538 i_opckeytype =
PQfnumber(res,
"opckeytype");
14539 i_opcdefault =
PQfnumber(res,
"opcdefault");
14540 i_opcfamily =
PQfnumber(res,
"opcfamily");
14541 i_opcfamilyname =
PQfnumber(res,
"opcfamilyname");
14542 i_opcfamilynsp =
PQfnumber(res,
"opcfamilynsp");
14547 opckeytype =
PQgetvalue(res, 0, i_opckeytype);
14548 opcdefault =
PQgetvalue(res, 0, i_opcdefault);
14551 opcfamilyname =
PQgetvalue(res, 0, i_opcfamilyname);
14552 opcfamilynsp =
PQgetvalue(res, 0, i_opcfamilynsp);
14564 if (strcmp(opcdefault,
"t") == 0)
14569 if (strlen(opcfamilyname) > 0)
14579 if (strcmp(opckeytype,
"-") != 0)
14596 "amopopr::pg_catalog.regoperator, "
14597 "opfname AS sortfamily, "
14598 "nspname AS sortfamilynsp "
14599 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14600 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14601 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14602 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14603 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14604 "AND refobjid = '%u'::pg_catalog.oid "
14605 "AND amopfamily = '%s'::pg_catalog.oid "
14606 "ORDER BY amopstrategy",
14614 i_amopstrategy =
PQfnumber(res,
"amopstrategy");
14616 i_sortfamily =
PQfnumber(res,
"sortfamily");
14617 i_sortfamilynsp =
PQfnumber(res,
"sortfamilynsp");
14619 for (
i = 0;
i < ntups;
i++)
14621 amopstrategy =
PQgetvalue(res,
i, i_amopstrategy);
14624 sortfamilynsp =
PQgetvalue(res,
i, i_sortfamilynsp);
14630 amopstrategy, amopopr);
14632 if (strlen(sortfamily) > 0)
14657 "amproc::pg_catalog.regprocedure, "
14658 "amproclefttype::pg_catalog.regtype, "
14659 "amprocrighttype::pg_catalog.regtype "
14660 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14661 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14662 "AND refobjid = '%u'::pg_catalog.oid "
14663 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14664 "AND objid = ap.oid "
14665 "ORDER BY amprocnum",
14672 i_amprocnum =
PQfnumber(res,
"amprocnum");
14674 i_amproclefttype =
PQfnumber(res,
"amproclefttype");
14675 i_amprocrighttype =
PQfnumber(res,
"amprocrighttype");
14677 for (
i = 0;
i < ntups;
i++)
14681 amproclefttype =
PQgetvalue(res,
i, i_amproclefttype);
14682 amprocrighttype =
PQgetvalue(res,
i, i_amprocrighttype);
14689 if (*amproclefttype && *amprocrighttype)
14716 "OPERATOR CLASS", nameusing->
data,
14717 opcinfo->
dobj.namespace->dobj.
name);
14722 .namespace = opcinfo->
dobj.namespace->dobj.
name,
14724 .description =
"OPERATOR CLASS",
14726 .createStmt = q->
data,
14727 .dropStmt = delq->
data));
14764 int i_amopstrategy;
14767 int i_sortfamilynsp;
14770 int i_amproclefttype;
14771 int i_amprocrighttype;
14773 char *amopstrategy;
14776 char *sortfamilynsp;
14779 char *amproclefttype;
14780 char *amprocrighttype;
14798 "amopopr::pg_catalog.regoperator, "
14799 "opfname AS sortfamily, "
14800 "nspname AS sortfamilynsp "
14801 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14802 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14803 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14804 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14805 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14806 "AND refobjid = '%u'::pg_catalog.oid "
14807 "AND amopfamily = '%u'::pg_catalog.oid "
14808 "ORDER BY amopstrategy",
14817 "amproc::pg_catalog.regprocedure, "
14818 "amproclefttype::pg_catalog.regtype, "
14819 "amprocrighttype::pg_catalog.regtype "
14820 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14821 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14822 "AND refobjid = '%u'::pg_catalog.oid "
14823 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14824 "AND objid = ap.oid "
14825 "ORDER BY amprocnum",
14834 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opfmethod) AS amname "
14835 "FROM pg_catalog.pg_opfamily "
14836 "WHERE oid = '%u'::pg_catalog.oid",
14874 i_amopstrategy =
PQfnumber(res_ops,
"amopstrategy");
14875 i_amopopr =
PQfnumber(res_ops,
"amopopr");
14876 i_sortfamily =
PQfnumber(res_ops,
"sortfamily");
14877 i_sortfamilynsp =
PQfnumber(res_ops,
"sortfamilynsp");
14879 for (
i = 0;
i < ntups;
i++)
14881 amopstrategy =
PQgetvalue(res_ops,
i, i_amopstrategy);
14883 sortfamily =
PQgetvalue(res_ops,
i, i_sortfamily);
14884 sortfamilynsp =
PQgetvalue(res_ops,
i, i_sortfamilynsp);
14890 amopstrategy, amopopr);
14892 if (strlen(sortfamily) > 0)
14907 i_amprocnum =
PQfnumber(res_procs,
"amprocnum");
14908 i_amproc =
PQfnumber(res_procs,
"amproc");
14909 i_amproclefttype =
PQfnumber(res_procs,
"amproclefttype");
14910 i_amprocrighttype =
PQfnumber(res_procs,
"amprocrighttype");
14912 for (
i = 0;
i < ntups;
i++)
14914 amprocnum =
PQgetvalue(res_procs,
i, i_amprocnum);
14916 amproclefttype =
PQgetvalue(res_procs,
i, i_amproclefttype);
14917 amprocrighttype =
PQgetvalue(res_procs,
i, i_amprocrighttype);
14923 amprocnum, amproclefttype, amprocrighttype,
14938 "OPERATOR FAMILY", nameusing->
data,
14939 opfinfo->
dobj.namespace->dobj.
name);
14944 .namespace = opfinfo->
dobj.namespace->dobj.
name,
14946 .description =
"OPERATOR FAMILY",
14948 .createStmt = q->
data,
14949 .dropStmt = delq->
data));
14979 int i_collprovider;
14980 int i_collisdeterministic;
14984 int i_collicurules;
14985 const char *collprovider;
14986 const char *collcollate;
14987 const char *collctype;
14988 const char *colllocale;
14989 const char *collicurules;
15010 "'c' AS collprovider, "
15011 "NULL AS collversion, ");
15015 "collisdeterministic, ");
15018 "true AS collisdeterministic, ");
15025 "colliculocale AS colllocale, ");
15028 "NULL AS colllocale, ");
15035 "NULL AS collicurules, ");
15040 "FROM pg_catalog.pg_collation c "
15041 "WHERE c.oid = '%u'::pg_catalog.oid",
15046 i_collprovider =
PQfnumber(res,
"collprovider");
15047 i_collisdeterministic =
PQfnumber(res,
"collisdeterministic");
15048 i_collcollate =
PQfnumber(res,
"collcollate");
15049 i_collctype =
PQfnumber(res,
"collctype");
15050 i_colllocale =
PQfnumber(res,
"colllocale");
15051 i_collicurules =
PQfnumber(res,
"collicurules");
15053 collprovider =
PQgetvalue(res, 0, i_collprovider);
15056 collcollate =
PQgetvalue(res, 0, i_collcollate);
15058 collcollate = NULL;
15061 collctype =
PQgetvalue(res, 0, i_collctype);
15071 if (collcollate[0] ==
'\0')
15072 collcollate = NULL;
15073 if (collctype[0] ==
'\0')
15078 colllocale =
PQgetvalue(res, 0, i_colllocale);
15083 collicurules =
PQgetvalue(res, 0, i_collicurules);
15085 collicurules = NULL;
15094 if (collprovider[0] ==
'b')
15096 else if (collprovider[0] ==
'c')
15098 else if (collprovider[0] ==
'i')
15100 else if (collprovider[0] ==
'd')
15104 pg_fatal(
"unrecognized collation provider: %s",
15107 if (strcmp(
PQgetvalue(res, 0, i_collisdeterministic),
"f") == 0)
15110 if (collprovider[0] ==
'd')
15112 if (collcollate || collctype || colllocale || collicurules)
15117 else if (collprovider[0] ==
'b')
15119 if (collcollate || collctype || !colllocale || collicurules)
15126 else if (collprovider[0] ==
'i')
15130 if (collcollate || collctype || !colllocale)
15139 if (!collcollate || !collctype || colllocale ||
15140 strcmp(collcollate, collctype) != 0)
15153 else if (collprovider[0] ==
'c')
15155 if (colllocale || collicurules || !collcollate || !collctype)
15158 if (collcollate && collctype && strcmp(collcollate, collctype) == 0)
15172 pg_fatal(
"unrecognized collation provider: %s", collprovider);
15182 i_collversion =
PQfnumber(res,
"collversion");
15196 "COLLATION", qcollname,
15197 collinfo->
dobj.namespace->dobj.
name);
15202 .namespace = collinfo->
dobj.namespace->dobj.
name,
15204 .description =
"COLLATION",
15206 .createStmt = q->
data,
15207 .dropStmt = delq->
data));
15236 int i_conforencoding;
15237 int i_contoencoding;
15240 const char *conforencoding;
15241 const char *contoencoding;
15242 const char *conproc;
15257 "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
15258 "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
15259 "conproc, condefault "
15260 "FROM pg_catalog.pg_conversion c "
15261 "WHERE c.oid = '%u'::pg_catalog.oid",
15266 i_conforencoding =
PQfnumber(res,
"conforencoding");
15267 i_contoencoding =
PQfnumber(res,
"contoencoding");
15269 i_condefault =
PQfnumber(res,
"condefault");
15271 conforencoding =
PQgetvalue(res, 0, i_conforencoding);
15272 contoencoding =
PQgetvalue(res, 0, i_contoencoding);
15274 condefault = (
PQgetvalue(res, 0, i_condefault)[0] ==
't');
15280 (condefault) ?
"DEFAULT " :
"",
15290 "CONVERSION", qconvname,
15291 convinfo->
dobj.namespace->dobj.
name);
15296 .namespace = convinfo->
dobj.namespace->dobj.
name,
15298 .description =
"CONVERSION",
15300 .createStmt = q->
data,
15301 .dropStmt = delq->
data));
15335 if (agginfo->aggfn.nargs == 0)
15340 for (
j = 0;
j < agginfo->aggfn.nargs;
j++)
15342 (
j > 0) ?
", " :
"",
15344 agginfo->aggfn.argtypes[
j],
15364 char *aggfullsig = NULL;
15369 const char *aggtransfn;
15370 const char *aggfinalfn;
15371 const char *aggcombinefn;
15372 const char *aggserialfn;
15373 const char *aggdeserialfn;
15374 const char *aggmtransfn;
15375 const char *aggminvtransfn;
15376 const char *aggmfinalfn;
15377 bool aggfinalextra;
15378 bool aggmfinalextra;
15379 char aggfinalmodify;
15380 char aggmfinalmodify;
15381 const char *aggsortop;
15382 char *aggsortconvop;
15384 const char *aggtranstype;
15385 const char *aggtransspace;
15386 const char *aggmtranstype;
15387 const char *aggmtransspace;
15388 const char *agginitval;
15389 const char *aggminitval;
15390 const char *proparallel;
15391 char defaultfinalmodify;
15406 "PREPARE dumpAgg(pg_catalog.oid) AS\n");
15412 "aggtranstype::pg_catalog.regtype,\n"
15415 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
15416 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
15422 "aggminvtransfn,\n"
15424 "aggmtranstype::pg_catalog.regtype,\n"
15426 "aggmfinalextra,\n"
15428 "aggmtransspace,\n"
15432 "'n' AS aggkind,\n"
15433 "'-' AS aggmtransfn,\n"
15434 "'-' AS aggminvtransfn,\n"
15435 "'-' AS aggmfinalfn,\n"
15436 "0 AS aggmtranstype,\n"
15437 "false AS aggfinalextra,\n"
15438 "false AS aggmfinalextra,\n"
15439 "0 AS aggtransspace,\n"
15440 "0 AS aggmtransspace,\n"
15441 "NULL AS aggminitval,\n");
15451 "'-' AS aggcombinefn,\n"
15452 "'-' AS aggserialfn,\n"
15453 "'-' AS aggdeserialfn,\n"
15454 "'u' AS proparallel,\n");
15458 "aggfinalmodify,\n"
15459 "aggmfinalmodify\n");
15462 "'0' AS aggfinalmodify,\n"
15463 "'0' AS aggmfinalmodify\n");
15466 "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
15467 "WHERE a.aggfnoid = p.oid "
15476 "EXECUTE dumpAgg('%u')",
15477 agginfo->aggfn.dobj.catId.oid);
15481 i_agginitval =
PQfnumber(res,
"agginitval");
15482 i_aggminitval =
PQfnumber(res,
"aggminitval");
15502 agginitval =
PQgetvalue(res, 0, i_agginitval);
15503 aggminitval =
PQgetvalue(res, 0, i_aggminitval);
15519 defaultfinalmodify = (aggkind == AGGKIND_NORMAL) ? AGGMODIFY_READ_ONLY : AGGMODIFY_READ_WRITE;
15521 if (aggfinalmodify ==
'0')
15522 aggfinalmodify = defaultfinalmodify;
15523 if (aggmfinalmodify ==
'0')
15524 aggmfinalmodify = defaultfinalmodify;
15528 aggtransfn, aggtranstype);
15530 if (strcmp(aggtransspace,
"0") != 0)
15542 if (strcmp(aggfinalfn,
"-") != 0)
15548 if (aggfinalmodify != defaultfinalmodify)
15550 switch (aggfinalmodify)
15552 case AGGMODIFY_READ_ONLY:
15555 case AGGMODIFY_SHAREABLE:
15558 case AGGMODIFY_READ_WRITE:
15562 pg_fatal(
"unrecognized aggfinalmodify value for aggregate \"%s\"",
15563 agginfo->aggfn.dobj.name);
15569 if (strcmp(aggcombinefn,
"-") != 0)
15572 if (strcmp(aggserialfn,
"-") != 0)
15575 if (strcmp(aggdeserialfn,
"-") != 0)
15578 if (strcmp(aggmtransfn,
"-") != 0)
15586 if (strcmp(aggmtransspace,
"0") != 0)
15598 if (strcmp(aggmfinalfn,
"-") != 0)
15602 if (aggmfinalextra)
15604 if (aggmfinalmodify != defaultfinalmodify)
15606 switch (aggmfinalmodify)
15608 case AGGMODIFY_READ_ONLY:
15611 case AGGMODIFY_SHAREABLE:
15614 case AGGMODIFY_READ_WRITE:
15618 pg_fatal(
"unrecognized aggmfinalmodify value for aggregate \"%s\"",
15619 agginfo->aggfn.dobj.name);
15630 free(aggsortconvop);
15633 if (aggkind == AGGKIND_HYPOTHETICAL)
15636 if (proparallel[0] != PROPARALLEL_UNSAFE)
15638 if (proparallel[0] == PROPARALLEL_SAFE)
15640 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
15642 else if (proparallel[0] != PROPARALLEL_UNSAFE)
15643 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
15644 agginfo->aggfn.dobj.name);
15648 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
15652 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
15653 aggfullsig ? aggfullsig : aggsig, details->
data);
15657 "AGGREGATE", aggsig,
15658 agginfo->aggfn.dobj.namespace->dobj.name);
15662 agginfo->aggfn.dobj.dumpId,
15664 .
namespace = agginfo->aggfn.dobj.namespace->dobj.name,
15665 .owner = agginfo->aggfn.rolname,
15666 .description =
"AGGREGATE",
15668 .createStmt = q->
data,
15669 .dropStmt = delq->
data));
15674 agginfo->aggfn.dobj.namespace->dobj.name,
15675 agginfo->aggfn.rolname,
15676 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
15680 agginfo->aggfn.dobj.namespace->dobj.name,
15681 agginfo->aggfn.rolname,
15682 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
15695 "FUNCTION", aggsig, NULL,
15696 agginfo->aggfn.dobj.namespace->dobj.name,
15697 NULL, agginfo->aggfn.rolname, &agginfo->aggfn.dacl);
15752 "TEXT SEARCH PARSER", qprsname,
15753 prsinfo->
dobj.namespace->dobj.
name);
15758 .namespace = prsinfo->
dobj.namespace->dobj.
name,
15759 .description =
"TEXT SEARCH PARSER",
15761 .createStmt = q->
data,
15762 .dropStmt = delq->
data));
15766 dumpComment(fout,
"TEXT SEARCH PARSER", qprsname,
15767 prsinfo->
dobj.namespace->dobj.
name,
"",
15803 "FROM pg_ts_template p, pg_namespace n "
15804 "WHERE p.oid = '%u' AND n.oid = tmplnamespace",
15830 "TEXT SEARCH DICTIONARY", qdictname,
15831 dictinfo->
dobj.namespace->dobj.
name);
15836 .namespace = dictinfo->
dobj.namespace->dobj.
name,
15838 .description =
"TEXT SEARCH DICTIONARY",
15840 .createStmt = q->
data,
15841 .dropStmt = delq->
data));
15845 dumpComment(fout,
"TEXT SEARCH DICTIONARY", qdictname,
15890 "TEXT SEARCH TEMPLATE", qtmplname,
15891 tmplinfo->
dobj.namespace->dobj.
name);
15896 .namespace = tmplinfo->
dobj.namespace->dobj.
name,
15897 .description =
"TEXT SEARCH TEMPLATE",
15899 .createStmt = q->
data,
15900 .dropStmt = delq->
data));
15904 dumpComment(fout,
"TEXT SEARCH TEMPLATE", qtmplname,
15905 tmplinfo->
dobj.namespace->dobj.
name,
"",
15945 "FROM pg_ts_parser p, pg_namespace n "
15946 "WHERE p.oid = '%u' AND n.oid = prsnamespace",
15963 " ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
15964 " WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
15965 " m.mapdict::pg_catalog.regdictionary AS dictname\n"
15966 "FROM pg_catalog.pg_ts_config_map AS m\n"
15967 "WHERE m.mapcfg = '%u'\n"
15968 "ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
15974 i_tokenname =
PQfnumber(res,
"tokenname");
15975 i_dictname =
PQfnumber(res,
"dictname");
15977 for (
i = 0;
i < ntups;
i++)
15979 char *tokenname =
PQgetvalue(res,
i, i_tokenname);
15983 strcmp(tokenname,
PQgetvalue(res,
i - 1, i_tokenname)) != 0)
15992 fmtId(tokenname), dictname);
16008 "TEXT SEARCH CONFIGURATION", qcfgname,
16009 cfginfo->
dobj.namespace->dobj.
name);
16014 .namespace = cfginfo->
dobj.namespace->dobj.
name,
16016 .description =
"TEXT SEARCH CONFIGURATION",
16018 .createStmt = q->
data,
16019 .dropStmt = delq->
data));
16023 dumpComment(fout,
"TEXT SEARCH CONFIGURATION", qcfgname,
16073 "FOREIGN DATA WRAPPER", qfdwname,
16080 .description =
"FOREIGN DATA WRAPPER",
16082 .createStmt = q->
data,
16083 .dropStmt = delq->
data));
16087 dumpComment(fout,
"FOREIGN DATA WRAPPER", qfdwname,
16094 "FOREIGN DATA WRAPPER", qfdwname, NULL, NULL,
16130 "FROM pg_foreign_data_wrapper w "
16131 "WHERE w.oid = '%u'",
16161 "SERVER", qsrvname, NULL);
16167 .description =
"SERVER",
16169 .createStmt = q->
data,
16170 .dropStmt = delq->
data));
16181 "FOREIGN SERVER", qsrvname, NULL, NULL,
16209 const char *servername,
const char *
namespace,
16238 "array_to_string(ARRAY("
16239 "SELECT quote_ident(option_name) || ' ' || "
16240 "quote_literal(option_value) "
16241 "FROM pg_options_to_table(umoptions) "
16242 "ORDER BY option_name"
16243 "), E',\n ') AS umoptions "
16244 "FROM pg_user_mappings "
16245 "WHERE srvid = '%u' "
16246 "ORDER BY usename",
16253 i_umoptions =
PQfnumber(res,
"umoptions");
16255 for (
i = 0;
i < ntups;
i++)
16267 if (umoptions && strlen(umoptions) > 0)
16278 usename, servername);
16282 .namespace =
namespace,
16284 .description =
"USER MAPPING",
16286 .createStmt = q->
data,
16287 .dropStmt = delq->
data));
16318 case DEFACLOBJ_RELATION:
16321 case DEFACLOBJ_SEQUENCE:
16322 type =
"SEQUENCES";
16324 case DEFACLOBJ_FUNCTION:
16325 type =
"FUNCTIONS";
16327 case DEFACLOBJ_TYPE:
16330 case DEFACLOBJ_NAMESPACE:
16333 case DEFACLOBJ_LARGEOBJECT:
16334 type =
"LARGE OBJECTS";
16338 pg_fatal(
"unrecognized object type in default privileges: %d",
16347 daclinfo->
dobj.namespace != NULL ?
16348 daclinfo->
dobj.namespace->dobj.
name : NULL,
16354 pg_fatal(
"could not parse default ACL list (%s)",
16360 .namespace = daclinfo->
dobj.namespace ?
16361 daclinfo->
dobj.namespace->dobj.
name : NULL,
16363 .description =
"DEFAULT ACL",
16365 .createStmt = q->
data));
16396 const char *nspname,
const char *tag,
const char *owner,
16401 const char *acls = dacl->
acl;
16404 const char *initprivs = dacl->
initprivs;
16405 const char *baseacls;
16432 initprivs && *initprivs !=
'\0')
16438 pg_fatal(
"could not parse initial ACL list (%s) or default (%s) for object \"%s\" (%s)",
16440 appendPQExpBufferStr(sql,
"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
16451 if (initprivs && *initprivs !=
'\0')
16453 baseacls = initprivs;
16454 if (acls == NULL || *acls ==
'\0')
16461 acls, baseacls, owner,
16463 pg_fatal(
"could not parse ACL list (%s) or default (%s) for object \"%s\" (%s)",
16479 aclDeps[nDeps++] = objDumpId;
16481 aclDeps[nDeps++] = altDumpId;
16487 .namespace = nspname,
16489 .description =
"ACL",
16491 .createStmt = sql->
data,
16523 const char *
namespace,
const char *owner,
16540 if (strcmp(
type,
"LARGE OBJECT") != 0)
16557 for (
i = 0;
i < nlabels;
i++)
16562 if (labels[
i].objsubid != subid)
16566 "SECURITY LABEL FOR %s ON %s ",
16568 if (
namespace && *
namespace)
16575 if (query->
len > 0)
16582 .namespace =
namespace,
16584 .description =
"SECURITY LABEL",
16586 .createStmt = query->
data,
16631 for (
i = 0;
i < nlabels;
i++)
16633 const char *colname;
16657 if (query->
len > 0)
16664 .namespace = tbinfo->
dobj.namespace->dobj.
name,
16666 .description =
"SECURITY LABEL",
16668 .createStmt = query->
data,
16702 while (low <= high)
16704 middle = low + (high - low) / 2;
16706 if (classoid < middle->classoid)
16708 else if (classoid > middle->
classoid)
16710 else if (objoid < middle->objoid)
16712 else if (objoid > middle->
objoid)
16730 while (middle > low)
16732 if (classoid != middle[-1].classoid ||
16733 objoid != middle[-1].objoid)
16742 while (middle <= high)
16744 if (classoid != middle->
classoid ||
16745 objoid != middle->
objoid)
16779 "SELECT label, provider, classoid, objoid, objsubid "
16780 "FROM pg_catalog.pg_seclabels "
16781 "ORDER BY classoid, objoid, objsubid");
16787 i_provider =
PQfnumber(res,
"provider");
16788 i_classoid =
PQfnumber(res,
"classoid");
16790 i_objsubid =
PQfnumber(res,
"objsubid");
16798 for (
i = 0;
i < ntups;
i++)
16808 if (dobj == NULL ||
16821 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
16861 if (tbinfo->
relkind == RELKIND_SEQUENCE)
16871 const char *objtype =
16872 (tbinfo->
relkind == RELKIND_SEQUENCE) ?
"SEQUENCE" :
"TABLE";
16876 objtype, namecopy, NULL,
16877 tbinfo->
dobj.namespace->dobj.
name,
16897 "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
16912 "SELECT at.attname, "
16914 "'{}' AS acldefault, "
16915 "pip.privtype, pip.initprivs "
16916 "FROM pg_catalog.pg_attribute at "
16917 "LEFT JOIN pg_catalog.pg_init_privs pip ON "
16918 "(at.attrelid = pip.objoid "
16919 "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
16920 "AND at.attnum = pip.objsubid) "
16921 "WHERE at.attrelid = $1 AND "
16922 "NOT at.attisdropped "
16923 "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
16924 "ORDER BY at.attnum");
16929 "SELECT attname, attacl, '{}' AS acldefault, "
16930 "NULL AS privtype, NULL AS initprivs "
16931 "FROM pg_catalog.pg_attribute "
16932 "WHERE attrelid = $1 AND NOT attisdropped "
16933 "AND attacl IS NOT NULL "
16934 "ORDER BY attnum");
16943 "EXECUTE getColumnACLs('%u')",
16958 coldacl.
acl = attacl;
16970 "TABLE", namecopy, attnamecopy,
16971 tbinfo->
dobj.namespace->dobj.
name,
16972 NULL, tbinfo->
rolname, &coldacl);
16998 "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
17006 pg_fatal(
"query to obtain definition of view \"%s\" returned no data",
17009 pg_fatal(
"query to obtain definition of view \"%s\" returned more than one definition",
17016 pg_fatal(
"definition of view \"%s\" appears to be empty (length zero)",
17089 const char *reltypename;
17101 pg_log_warning(
"WITH OIDS is not supported anymore (table \"%s\")",
17108 if (tbinfo->
relkind == RELKIND_VIEW)
17116 reltypename =
"VIEW";
17147 char *partkeydef = NULL;
17148 char *ftoptions = NULL;
17149 char *srvname = NULL;
17150 const char *foreign =
"";
17158 case RELKIND_PARTITIONED_TABLE:
17163 reltypename =
"TABLE";
17167 "SELECT pg_get_partkeydef('%u')",
17175 case RELKIND_FOREIGN_TABLE:
17182 reltypename =
"FOREIGN TABLE";
17186 "SELECT fs.srvname, "
17187 "pg_catalog.array_to_string(ARRAY("
17188 "SELECT pg_catalog.quote_ident(option_name) || "
17189 "' ' || pg_catalog.quote_literal(option_value) "
17190 "FROM pg_catalog.pg_options_to_table(ftoptions) "
17191 "ORDER BY option_name"
17192 "), E',\n ') AS ftoptions "
17193 "FROM pg_catalog.pg_foreign_table ft "
17194 "JOIN pg_catalog.pg_foreign_server fs "
17195 "ON (fs.oid = ft.ftserver) "
17196 "WHERE ft.ftrelid = '%u'",
17200 i_ftoptions =
PQfnumber(res,
"ftoptions");
17206 foreign =
"FOREIGN ";
17209 case RELKIND_MATVIEW:
17210 reltypename =
"MATERIALIZED VIEW";
17213 reltypename =
"TABLE";
17232 tbinfo->
relkind != RELKIND_PARTITIONED_TABLE) ?
17246 if (tbinfo->
relkind != RELKIND_MATVIEW)
17260 bool print_default;
17261 bool print_notnull;
17267 print_default = (tbinfo->
attrdefs[
j] != NULL &&
17286 !print_default && !print_notnull &&
17291 if (actual_atts == 0)
17330 else if (tbinfo->
attgenerated[
j] == ATTRIBUTE_GENERATED_VIRTUAL)
17378 if (actual_atts == 0)
17411 if (actual_atts == 0)
17442 for (k = 0; k < numParents; k++)
17453 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
17456 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
17463 bool addcomma =
false;
17482 if (ftoptions && ftoptions[0])
17489 if (tbinfo->
relkind == RELKIND_MATVIEW)
17502 if (tbinfo->
relkind == RELKIND_MATVIEW)
17504 "pg_catalog.pg_class",
17505 "MATERIALIZED VIEW",
17520 "SELECT pg_catalog.binary_upgrade_set_missing_value(");
17553 (tbinfo->
relkind == RELKIND_RELATION ||
17554 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ||
17555 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE))
17558 bool firstitem_extra;
17575 "UPDATE pg_catalog.pg_attribute\n"
17576 "SET attlen = v.dlen, "
17577 "attalign = v.dalign, "
17578 "attbyval = false\n"
17591 foreign, qualrelname);
17599 "WHERE attrelid = ");
17602 " AND attname = v.dname;\n");
17621 "SET attislocal = false\n"
17622 "WHERE attrelid = ");
17625 " AND attname IN (");
17643 firstitem_extra =
true;
17664 "SET conislocal = false\n"
17665 "WHERE contype = 'n' AND conrelid = ");
17677 if (firstitem_extra)
17680 "SET conislocal = false\n"
17681 "WHERE contype = 'n' AND conrelid = ");
17685 firstitem_extra =
false;
17695 if (!firstitem_extra)
17698 if (extra->
len > 0)
17715 for (k = 0; k < tbinfo->
ncheck; k++)
17725 foreign, qualrelname,
17732 "SET conislocal = false\n"
17733 "WHERE contype = 'c' AND conrelid = ");
17752 for (k = 0; k < numParents; k++)
17780 (tbinfo->
relkind == RELKIND_RELATION ||
17781 tbinfo->
relkind == RELKIND_MATVIEW))
17785 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17797 appendPQExpBufferStr(q,
"\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
17799 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17800 "WHERE oid = '%u';\n",
17818 "SET relispopulated = 't'\n"
17840 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STATISTICS %d;\n",
17841 foreign, qualrelname,
17853 case TYPSTORAGE_PLAIN:
17856 case TYPSTORAGE_EXTERNAL:
17859 case TYPSTORAGE_EXTENDED:
17862 case TYPSTORAGE_MAIN:
17873 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STORAGE %s;\n",
17874 foreign, qualrelname,
17884 const char *cmname;
17899 if (cmname != NULL)
17900 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET COMPRESSION %s;\n",
17901 foreign, qualrelname,
17911 foreign, qualrelname,
17918 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
17921 "ALTER FOREIGN TABLE ONLY %s ALTER COLUMN %s OPTIONS (\n"
17937 if ((tbinfo->
relkind == RELKIND_RELATION ||
17938 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ||
17939 tbinfo->
relkind == RELKIND_MATVIEW) &&
17946 else if (tbinfo->
relreplident == REPLICA_IDENTITY_NOTHING)
17951 else if (tbinfo->
relreplident == REPLICA_IDENTITY_FULL)
17964 reltypename, qrelname,
17965 tbinfo->
dobj.namespace->dobj.
name);
17970 char *tableam = NULL;
17979 if (RELKIND_HAS_TABLESPACE(tbinfo->
relkind))
17982 if (RELKIND_HAS_TABLE_AM(tbinfo->
relkind) ||
17983 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
17984 tableam = tbinfo->
amname;
17988 .namespace = tbinfo->
dobj.namespace->dobj.
name,
17990 .tableam = tableam,
17993 .description = reltypename,
17996 .createStmt = q->
data,
17997 .dropStmt = delq->
data));
18044 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18046 .description =
"COMMENT",
18110 "PREPARE dumpTableAttach(pg_catalog.oid) AS\n");
18113 "SELECT pg_get_expr(c.relpartbound, c.oid) "
18115 "WHERE c.oid = $1");
18123 "EXECUTE dumpTableAttach('%u')",
18131 "ALTER TABLE ONLY %s ",
18134 "ATTACH PARTITION %s %s;\n",
18147 .namespace = attachinfo->
dobj.namespace->dobj.
name,
18149 .description =
"TABLE ATTACH",
18151 .createStmt = q->
data));
18165 int adnum = adinfo->
adnum;
18185 foreign = tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
18188 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET DEFAULT %s;\n",
18193 foreign, qualrelname,
18201 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18203 .description =
"DEFAULT",
18205 .createStmt = q->
data,
18206 .dropStmt = delq->
data));
18224 if (attrnum > 0 && attrnum <= tblInfo->numatts)
18225 return tblInfo->
attnames[attrnum - 1];
18241 pg_fatal(
"invalid column number %d for table \"%s\"",
18278 if (!is_constraint)
18282 char **indstatcolsarray = NULL;
18283 char **indstatvalsarray = NULL;
18314 if (strlen(indstatcols) != 0 || strlen(indstatvals) != 0)
18318 if (!
parsePGArray(indstatcols, &indstatcolsarray, &nstatcols))
18319 pg_fatal(
"could not parse index statistic columns");
18320 if (!
parsePGArray(indstatvals, &indstatvalsarray, &nstatvals))
18321 pg_fatal(
"could not parse index statistic values");
18322 if (nstatcols != nstatvals)
18323 pg_fatal(
"mismatched number of columns and values for index statistics");
18325 for (
j = 0;
j < nstatcols;
j++)
18334 indstatcolsarray[
j]);
18336 indstatvalsarray[
j]);
18342 "pg_catalog.pg_class",
18343 "INDEX", qqindxname);
18370 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18373 .description =
"INDEX",
18375 .createStmt = q->
data,
18376 .dropStmt = delq->
data));
18378 free(indstatcolsarray);
18379 free(indstatvalsarray);
18385 tbinfo->
dobj.namespace->dobj.
name,
18430 .namespace = attachinfo->
dobj.namespace->dobj.
name,
18432 .description =
"INDEX ATTACH",
18434 .createStmt = q->
data));
18451 char *qstatsextname;
18466 "pg_catalog.pg_get_statisticsobjdef('%u'::pg_catalog.oid)",
18495 .namespace = statsextinfo->
dobj.namespace->dobj.
name,
18496 .owner = statsextinfo->
rolname,
18497 .description =
"STATISTICS",
18499 .createStmt = q->
data,
18500 .dropStmt = delq->
data));
18505 statsextinfo->
dobj.namespace->dobj.
name,
18514 free(qstatsextname);
18538 foreign = tbinfo &&
18539 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
18541 if (coninfo->
contype ==
'p' ||
18551 if (indxinfo == NULL)
18552 pg_fatal(
"missing index for constraint \"%s\"",
18572 coninfo->
contype ==
'p' ?
"PRIMARY KEY" :
"UNIQUE");
18585 int indkey = (int) indxinfo->
indkeys[k];
18593 (k == 0) ?
"" :
", ",
18602 for (k = indxinfo->
indnkeyattrs; k < indxinfo->indnattrs; k++)
18604 int indkey = (int) indxinfo->
indkeys[k];
18663 "pg_catalog.pg_class",
"INDEX",
18676 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18679 .description =
"CONSTRAINT",
18681 .createStmt = q->
data,
18682 .dropStmt = delq->
data));
18684 else if (coninfo->
contype ==
'f')
18694 only = tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ?
"" :
"ONLY ";
18716 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18718 .description =
"FK CONSTRAINT",
18720 .createStmt = q->
data,
18721 .dropStmt = delq->
data));
18723 else if ((coninfo->
contype ==
'c' || coninfo->
contype ==
'n') && tbinfo)
18730 const char *keyword;
18733 keyword =
"CHECK CONSTRAINT";
18735 keyword =
"CONSTRAINT";
18754 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18756 .description = keyword,
18758 .createStmt = q->
data,
18759 .dropStmt = delq->
data));
18762 else if (tbinfo == NULL)
18772 const char *keyword;
18775 keyword =
"CHECK CONSTRAINT";
18777 keyword =
"CONSTRAINT";
18795 .
namespace = tyinfo->
dobj.namespace->dobj.
name,
18797 .description = keyword,
18799 .createStmt = q->
data,
18800 .dropStmt = delq->
data));
18811 tyinfo->
dobj.namespace->dobj.
name,
18821 pg_fatal(
"unrecognized constraint type: %c",
18826 if (tbinfo && coninfo->
separate &&
18856 tbinfo->
dobj.namespace->dobj.
name,
18914 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
18915 "seqstart, seqincrement, "
18917 "seqcache, seqcycle, "
18919 "FROM pg_catalog.pg_sequence "
18920 "ORDER BY seqrelid";
18922 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
18923 "seqstart, seqincrement, "
18925 "seqcache, seqcycle, "
18926 "last_value, is_called "
18927 "FROM pg_catalog.pg_sequence, "
18928 "pg_get_sequence_data(seqrelid) "
18929 "ORDER BY seqrelid;";
18963 int64 default_minv,
18998 "SELECT 'bigint' AS sequence_type, "
18999 "start_value, increment_by, max_value, min_value, "
19000 "cache_value, is_cycled FROM %s",
19006 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19007 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19024 is_ascending = (seq->
incby >= 0);
19043 default_minv = default_maxv = 0;
19076 "ALTER COLUMN %s ADD GENERATED ",
19092 "UNLOGGED" :
"LOGGED");
19097 "CREATE %sSEQUENCE %s\n",
19110 if (seq->
minv != default_minv)
19115 if (seq->
maxv != default_maxv)
19133 "SEQUENCE", qseqname,
19134 tbinfo->
dobj.namespace->dobj.
name);
19139 .namespace = tbinfo->
dobj.namespace->dobj.
name,
19141 .description =
"SEQUENCE",
19143 .createStmt = query->
data,
19144 .dropStmt = delqry->
data));
19162 if (owning_tab == NULL)
19163 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
19179 .namespace = tbinfo->
dobj.namespace->dobj.
name,
19181 .description =
"SEQUENCE OWNED BY",
19183 .createStmt = query->
data,
19232 "SELECT last_value, is_called FROM %s",
19238 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19239 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19243 last = strtoi64(
PQgetvalue(res, 0, 0), NULL, 10);
19244 called = (strcmp(
PQgetvalue(res, 0, 1),
"t") == 0);
19268 last, (called ?
"true" :
"false"));
19273 .namespace = tbinfo->
dobj.namespace->dobj.
name,
19275 .description =
"SEQUENCE SET",
19277 .createStmt = query->
data,
19319 "pg_catalog.pg_trigger",
"TRIGGER",
19320 trigidentity->
data);
19335 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
19360 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
19390 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
19392 .description =
"TRIGGER",
19394 .createStmt = query->
data,
19395 .dropStmt = delqry->
data));
19436 if (strcmp(
"", evtinfo->
evttags) != 0)
19474 "EVENT TRIGGER", qevtname, NULL);
19480 .description =
"EVENT TRIGGER",
19482 .createStmt = query->
data,
19483 .dropStmt = delqry->
data));
19570 "SELECT pg_catalog.pg_get_ruledef('%u'::pg_catalog.oid)",
19576 pg_fatal(
"query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
19639 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
19641 .description =
"RULE",
19643 .createStmt = cmd->
data,
19644 .dropStmt = delcmd->
data));
19649 tbinfo->
dobj.namespace->dobj.
name,
19685 if (numExtensions == 0)
19692 "classid, objid, refobjid "
19694 "WHERE refclassid = 'pg_extension'::regclass "
19695 "AND deptype = 'e' "
19704 i_refobjid =
PQfnumber(res,
"refobjid");
19713 for (
i = 0;
i < ntups;
i++)
19729 pg_log_warning(
"could not find referenced extension %u", extId);
19777 if (numExtensions == 0)
19791 for (
i = 0;
i < numExtensions;
i++)
19796 char **extconfigarray = NULL;
19797 char **extconditionarray = NULL;
19798 int nconfigitems = 0;
19799 int nconditionitems = 0;
19819 if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
19823 if (!
parsePGArray(extconfig, &extconfigarray, &nconfigitems))
19824 pg_fatal(
"could not parse %s array",
"extconfig");
19825 if (!
parsePGArray(extcondition, &extconditionarray, &nconditionitems))
19826 pg_fatal(
"could not parse %s array",
"extcondition");
19827 if (nconfigitems != nconditionitems)
19828 pg_fatal(
"mismatched number of configurations and conditions for extension");
19830 for (
j = 0;
j < nconfigitems;
j++)
19833 Oid configtbloid =
atooid(extconfigarray[
j]);
19838 if (configtbl == NULL)
19854 if (configtbl->
dobj.namespace->dobj.
dump &
19873 if (configtbl->
dataObj != NULL)
19875 if (strlen(extconditionarray[
j]) > 0)
19881 if (extconfigarray)
19882 free(extconfigarray);
19883 if (extconditionarray)
19884 free(extconditionarray);
19899 "SELECT conrelid, confrelid "
19900 "FROM pg_constraint "
19901 "JOIN pg_depend ON (objid = confrelid) "
19902 "WHERE contype = 'f' "
19903 "AND refclassid = 'pg_extension'::regclass "
19904 "AND classid = 'pg_class'::regclass;");
19909 i_conrelid =
PQfnumber(res,
"conrelid");
19910 i_confrelid =
PQfnumber(res,
"confrelid");
19913 for (
i = 0;
i < ntups;
i++)
19925 if (reftable == NULL ||
19927 contable == NULL ||
19973 "classid, objid, refclassid, refobjid, deptype "
19975 "WHERE deptype != 'p' AND deptype != 'e'\n");
19988 "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
19989 "FROM pg_depend d, pg_amop o "
19990 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
19991 "classid = 'pg_amop'::regclass AND objid = o.oid "
19992 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
19996 "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
19997 "FROM pg_depend d, pg_amproc p "
19998 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
19999 "classid = 'pg_amproc'::regclass AND objid = p.oid "
20000 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
20011 i_refclassid =
PQfnumber(res,
"refclassid");
20012 i_refobjid =
PQfnumber(res,
"refobjid");
20022 for (
i = 0;
i < ntups;
i++)
20034 if (dobj == NULL ||
20054 if (refdobj == NULL)
20069 if (deptype ==
'x')
20079 if (deptype ==
'i' &&
20130 for (
i = 0;
i < numObjs;
i++)
20194 if (((
RuleInfo *) dobj)->separate)
20273 if (dobj->
nDeps <= 0)
20281 &dependencies, &nDeps, &allocDeps);
20286 nDeps *
sizeof(
DumpId));
20291 free(dependencies);
20298 DumpId **dependencies,
int *nDeps,
int *allocDeps)
20317 if (*nDeps >= *allocDeps)
20321 *allocDeps *
sizeof(
DumpId));
20323 (*dependencies)[*nDeps] = depid;
20337 dependencies, nDeps, allocDeps);
20370 if (typeInfo && typeInfo->
ftypname)
20374 appendPQExpBuffer(query,
"SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
20415 for (
i = 0;
i < numatts;
i++)
20417 if (attisdropped[
i])
20419 if (attgenerated[
i])
20431 return buffer->
data;
20441 return (reloptions != NULL && strlen(reloptions) > 2);
20451 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)
char * generate_restrict_key(void)
bool buildACLCommands(const char *name, const char *subname, const char *nspname, const char *type, const char *acls, const char *baseacls, const char *owner, const char *prefix, int remoteVersion, PQExpBuffer sql)
bool valid_restrict_key(const char *restrict_key)
void buildShSecLabelQuery(const char *catalog_name, Oid objectId, PQExpBuffer sql)
void makeAlterConfigCommand(PGconn *conn, const char *configitem, const char *type, const char *name, const char *type2, const char *name2, PQExpBuffer buf)
bool buildDefaultACLCommands(const char *type, const char *nspname, const char *acls, const char *acldefault, const char *owner, int remoteVersion, PQExpBuffer sql)
char * sanitize_line(const char *str, bool want_hyphen)
bool variable_is_guc_list_quote(const char *name)
void quoteAclUserName(PQExpBuffer output, const char *input)
void emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer, const char *objtype, const char *objname)
char * PQdb(const PGconn *conn)
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
int PQclientEncoding(const PGconn *conn)
char * PQerrorMessage(const PGconn *conn)
int PQsetClientEncoding(PGconn *conn, const char *encoding)
void PQfreemem(void *ptr)
Oid PQftype(const PGresult *res, int field_num)
int PQfnumber(const PGresult *res, const char *field_name)
int PQgetCopyData(PGconn *conn, char **buffer, int async)
int lo_close(PGconn *conn, int fd)
int lo_open(PGconn *conn, Oid lobjId, int mode)
void * pg_malloc(size_t size)
char * pg_strdup(const char *in)
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 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 RestoreArchive(Archive *AHX)
void archputs(const char *s, Archive *AH)
void InitDumpOptions(DumpOptions *opts)
void WriteData(Archive *AHX, const void *data, size_t dLen)
int 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)
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 DumpId lo_metadata_dumpId
static void setup_connection(Archive *AH, const char *dumpencoding, const char *dumpsnapshot, char *use_role)
static void dumpTableConstraintComment(Archive *fout, const ConstraintInfo *coninfo)
static void dumpUndefinedType(Archive *fout, const TypeInfo *tyinfo)
static void selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
static const char * fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer)
static void expand_table_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names, bool with_child_tables)
static void findDumpableDependencies(ArchiveHandle *AH, const DumpableObject *dobj, DumpId **dependencies, int *nDeps, int *allocDeps)
static void determineNotNullFlags(Archive *fout, PGresult *res, int r, TableInfo *tbinfo, int j, int i_notnull_name, int i_notnull_comment, int i_notnull_invalidoid, int i_notnull_noinherit, int i_notnull_islocal, PQExpBuffer *invalidnotnulloids)
static void dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
static void dumpTSParser(Archive *fout, const TSParserInfo *prsinfo)
static void expand_foreign_server_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids)
TableInfo * getTables(Archive *fout, int *numTables)
static void dumpRule(Archive *fout, const RuleInfo *rinfo)
static void dumpCompositeType(Archive *fout, const TypeInfo *tyinfo)
static void dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
static void dumpExtension(Archive *fout, const ExtensionInfo *extinfo)
#define fmtQualifiedDumpable(obj)
static bool nonemptyReloptions(const char *reloptions)
static SimpleStringList extension_exclude_patterns
static BinaryUpgradeClassOidItem * binaryUpgradeClassOids
static SimpleOidList table_include_oids
void getExtendedStatistics(Archive *fout)
static NamespaceInfo * findNamespace(Oid nsoid)
static char * get_synchronized_snapshot(Archive *fout)
static int dumpLOs(Archive *fout, const void *arg)
static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
static void appendNamedArgument(PQExpBuffer out, Archive *fout, const char *argname, const char *argtype, const char *argval)
void processExtensionTables(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
static void dumpEventTrigger(Archive *fout, const EventTriggerInfo *evtinfo)
static int BinaryUpgradeClassOidItemCmp(const void *p1, const void *p2)
static void dumpCommentExtended(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId, const char *initdb_comment)
void getDefaultACLs(Archive *fout)
static SimpleStringList tabledata_exclude_patterns
static void dumpConversion(Archive *fout, const ConvInfo *convinfo)
static void dumpForeignDataWrapper(Archive *fout, const FdwInfo *fdwinfo)
static void dumpProcLang(Archive *fout, const ProcLangInfo *plang)
static void dumpSecLabel(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId)
void getSubscriptions(Archive *fout)
static void collectSecLabels(Archive *fout)
static void selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
static void collectSequences(Archive *fout)
static Oid g_last_builtin_oid
#define MAX_ATTR_STATS_RELS
void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
void getTransforms(Archive *fout)
void getEventTriggers(Archive *fout)
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode)
static void read_dump_filters(const char *filename, DumpOptions *dopt)
static void dumpTSConfig(Archive *fout, const TSConfigInfo *cfginfo)
static SecLabelItem * seclabels
static SimpleStringList tabledata_exclude_patterns_and_children
static char * get_language_name(Archive *fout, Oid langid)
static bool checkExtensionMembership(DumpableObject *dobj, Archive *fout)
static CommentItem * comments
static int dumpTableData_insert(Archive *fout, const void *dcontext)
static SimpleOidList tabledata_exclude_oids
static SimpleStringList table_exclude_patterns_and_children
static void binary_upgrade_set_pg_class_oids(Archive *fout, PQExpBuffer upgrade_buffer, Oid pg_class_oid)
void getTSTemplates(Archive *fout)
static void set_restrict_relation_kind(Archive *AH, const char *value)
static char * format_aggregate_signature(const AggInfo *agginfo, Archive *fout, bool honor_quotes)
void getProcLangs(Archive *fout)
static void dumpSequence(Archive *fout, const TableInfo *tbinfo)
bool shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
static TableInfo * getRootTableInfo(const TableInfo *tbinfo)
void getSubscriptionRelations(Archive *fout)
void getOperators(Archive *fout)
static SimpleOidList foreign_servers_include_oids
static void dumpCollation(Archive *fout, const CollInfo *collinfo)
static void dumpTableSecLabel(Archive *fout, const TableInfo *tbinfo, const char *reltypename)
static void dumpCompositeTypeColComments(Archive *fout, const TypeInfo *tyinfo, PGresult *res)
static void expand_extension_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names)
void getOpfamilies(Archive *fout)
static void selectDumpableType(TypeInfo *tyinfo, Archive *fout)
static SimpleOidList schema_include_oids
static void dumpOpclass(Archive *fout, const OpclassInfo *opcinfo)
static SimpleStringList schema_exclude_patterns
#define DUMP_COMPONENT_COMMENT
#define DUMP_COMPONENT_DATA
#define DUMP_COMPONENT_USERMAP
#define DUMP_COMPONENT_POLICY
#define DUMP_COMPONENT_SECLABEL
#define DUMP_COMPONENT_ALL
#define DUMP_COMPONENT_ACL
#define DUMP_COMPONENT_NONE
#define DUMP_COMPONENTS_REQUIRING_LOCK
void sortDumpableObjects(DumpableObject **objs, int numObjs, DumpId preBoundaryId, DumpId postBoundaryId)
#define DUMP_COMPONENT_DEFINITION
@ DO_PUBLICATION_TABLE_IN_SCHEMA
void sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs)
#define DUMP_COMPONENT_STATISTICS
static int statistics_only
static int with_statistics
PGDLLIMPORT char * optarg
#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
struct _constraintInfo * notnull
#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)