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));
4550 "p.pubowner, p.puballtables, p.pubinsert, "
4551 "p.pubupdate, p.pubdelete, ");
4577 i_tableoid =
PQfnumber(res,
"tableoid");
4580 i_pubowner =
PQfnumber(res,
"pubowner");
4581 i_puballtables =
PQfnumber(res,
"puballtables");
4582 i_pubinsert =
PQfnumber(res,
"pubinsert");
4583 i_pubupdate =
PQfnumber(res,
"pubupdate");
4584 i_pubdelete =
PQfnumber(res,
"pubdelete");
4585 i_pubtruncate =
PQfnumber(res,
"pubtruncate");
4586 i_pubviaroot =
PQfnumber(res,
"pubviaroot");
4587 i_pubgencols =
PQfnumber(res,
"pubgencols");
4591 for (
i = 0;
i < ntups;
i++)
4601 (strcmp(
PQgetvalue(res,
i, i_puballtables),
"t") == 0);
4603 (strcmp(
PQgetvalue(res,
i, i_pubinsert),
"t") == 0);
4605 (strcmp(
PQgetvalue(res,
i, i_pubupdate),
"t") == 0);
4607 (strcmp(
PQgetvalue(res,
i, i_pubdelete),
"t") == 0);
4609 (strcmp(
PQgetvalue(res,
i, i_pubtruncate),
"t") == 0);
4611 (strcmp(
PQgetvalue(res,
i, i_pubviaroot),
"t") == 0);
4704 .description =
"PUBLICATION",
4706 .createStmt = query->
data,
4707 .dropStmt = delq->
data));
4750 "SELECT tableoid, oid, pnpubid, pnnspid "
4751 "FROM pg_catalog.pg_publication_namespace");
4756 i_tableoid =
PQfnumber(res,
"tableoid");
4765 for (
i = 0;
i < ntups;
i++)
4777 if (pubinfo == NULL)
4780 if (nspinfo == NULL)
4789 pubsinfo[
j].
dobj.namespace = nspinfo->
dobj.namespace;
4833 "SELECT tableoid, oid, prpubid, prrelid, "
4834 "pg_catalog.pg_get_expr(prqual, prrelid) AS prrelqual, "
4836 " WHEN pr.prattrs IS NOT NULL THEN\n"
4837 " (SELECT array_agg(attname)\n"
4839 " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
4840 " pg_catalog.pg_attribute\n"
4841 " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
4842 " ELSE NULL END) prattrs "
4843 "FROM pg_catalog.pg_publication_rel pr");
4846 "SELECT tableoid, oid, prpubid, prrelid, "
4847 "NULL AS prrelqual, NULL AS prattrs "
4848 "FROM pg_catalog.pg_publication_rel");
4853 i_tableoid =
PQfnumber(res,
"tableoid");
4857 i_prrelqual =
PQfnumber(res,
"prrelqual");
4864 for (
i = 0;
i < ntups;
i++)
4876 if (pubinfo == NULL)
4884 pubrinfo[
j].dobj.catId.tableoid =
4888 pubrinfo[
j].dobj.namespace = tbinfo->
dobj.namespace;
4889 pubrinfo[
j].dobj.name = tbinfo->
dobj.
name;
4890 pubrinfo[
j].publication = pubinfo;
4891 pubrinfo[
j].pubtable = tbinfo;
4893 pubrinfo[
j].pubrelqual = NULL;
4904 &attnames, &nattnames))
4905 pg_fatal(
"could not parse %s array",
"prattrs");
4907 for (
int k = 0; k < nattnames; k++)
4914 pubrinfo[
j].pubrattrs = attribs->
data;
4919 pubrinfo[
j].pubrattrs = NULL;
4962 .
namespace = schemainfo->
dobj.
name,
4964 .description =
"PUBLICATION TABLES IN SCHEMA",
4966 .createStmt = query->
data));
5000 if (pubrinfo->pubrattrs)
5003 if (pubrinfo->pubrelqual)
5022 ArchiveEntry(fout, pubrinfo->dobj.catId, pubrinfo->dobj.dumpId,
5024 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
5026 .description =
"PUBLICATION TABLE",
5028 .createStmt = query->
data));
5047 if (
val && strcmp(
val,
"on") == 0)
5065 "SELECT set_config(name, '%s', false) "
5067 "WHERE name = 'restrict_nonsystem_relation_kind'",
5092 int i_subtwophasestate;
5093 int i_subdisableonerr;
5094 int i_subpasswordrequired;
5095 int i_subrunasowner;
5098 int i_subsynccommit;
5099 int i_subpublications;
5101 int i_suboriginremotelsn;
5104 int i_subretaindeadtuples;
5105 int i_submaxretention;
5117 "SELECT count(*) FROM pg_subscription "
5118 "WHERE subdbid = (SELECT oid FROM pg_database"
5119 " WHERE datname = current_database())",
5123 pg_log_warning(
"subscriptions not dumped because current user is not a superuser");
5132 "SELECT s.tableoid, s.oid, s.subname,\n"
5134 " s.subconninfo, s.subslotname, s.subsynccommit,\n"
5135 " s.subpublications,\n");
5149 " s.subtwophasestate,\n"
5150 " s.subdisableonerr,\n");
5153 " '%c' AS subtwophasestate,\n"
5154 " false AS subdisableonerr,\n",
5155 LOGICALREP_TWOPHASE_STATE_DISABLED);
5159 " s.subpasswordrequired,\n"
5160 " s.subrunasowner,\n"
5164 " 't' AS subpasswordrequired,\n"
5165 " 't' AS subrunasowner,\n"
5166 " '%s' AS suborigin,\n",
5167 LOGICALREP_ORIGIN_ANY);
5171 " s.subenabled,\n");
5174 " false AS subenabled,\n");
5178 " s.subfailover,\n");
5181 " false AS subfailover,\n");
5185 " s.subretaindeadtuples,\n");
5188 " false AS subretaindeadtuples,\n");
5192 " s.submaxretention\n");
5195 " 0 AS submaxretention\n");
5198 "FROM pg_subscription s\n");
5202 "LEFT JOIN pg_catalog.pg_replication_origin_status o \n"
5203 " ON o.external_id = 'pg_' || s.oid::text \n");
5206 "WHERE s.subdbid = (SELECT oid FROM pg_database\n"
5207 " WHERE datname = current_database())");
5217 i_tableoid =
PQfnumber(res,
"tableoid");
5220 i_subowner =
PQfnumber(res,
"subowner");
5221 i_subenabled =
PQfnumber(res,
"subenabled");
5222 i_subbinary =
PQfnumber(res,
"subbinary");
5223 i_substream =
PQfnumber(res,
"substream");
5224 i_subtwophasestate =
PQfnumber(res,
"subtwophasestate");
5225 i_subdisableonerr =
PQfnumber(res,
"subdisableonerr");
5226 i_subpasswordrequired =
PQfnumber(res,
"subpasswordrequired");
5227 i_subrunasowner =
PQfnumber(res,
"subrunasowner");
5228 i_subfailover =
PQfnumber(res,
"subfailover");
5229 i_subretaindeadtuples =
PQfnumber(res,
"subretaindeadtuples");
5230 i_submaxretention =
PQfnumber(res,
"submaxretention");
5231 i_subconninfo =
PQfnumber(res,
"subconninfo");
5232 i_subslotname =
PQfnumber(res,
"subslotname");
5233 i_subsynccommit =
PQfnumber(res,
"subsynccommit");
5234 i_subpublications =
PQfnumber(res,
"subpublications");
5235 i_suborigin =
PQfnumber(res,
"suborigin");
5236 i_suboriginremotelsn =
PQfnumber(res,
"suboriginremotelsn");
5240 for (
i = 0;
i < ntups;
i++)
5251 (strcmp(
PQgetvalue(res,
i, i_subenabled),
"t") == 0);
5253 (strcmp(
PQgetvalue(res,
i, i_subbinary),
"t") == 0);
5257 (strcmp(
PQgetvalue(res,
i, i_subdisableonerr),
"t") == 0);
5259 (strcmp(
PQgetvalue(res,
i, i_subpasswordrequired),
"t") == 0);
5261 (strcmp(
PQgetvalue(res,
i, i_subrunasowner),
"t") == 0);
5263 (strcmp(
PQgetvalue(res,
i, i_subfailover),
"t") == 0);
5265 (strcmp(
PQgetvalue(res,
i, i_subretaindeadtuples),
"t") == 0);
5318 "SELECT srsubid, srrelid, srsubstate, srsublsn "
5319 "FROM pg_catalog.pg_subscription_rel "
5329 i_srsubstate =
PQfnumber(res,
"srsubstate");
5330 i_srsublsn =
PQfnumber(res,
"srsublsn");
5333 for (
int i = 0;
i < ntups;
i++)
5343 if (cur_srsubid != last_srsubid)
5346 if (subinfo == NULL)
5347 pg_fatal(
"subscription with OID %u does not exist", cur_srsubid);
5349 last_srsubid = cur_srsubid;
5353 if (tblinfo == NULL)
5354 pg_fatal(
"failed sanity check, table with OID %u not found",
5411 "\n-- For binary upgrade, must preserve the subscriber table.\n");
5413 "SELECT pg_catalog.binary_upgrade_add_sub_rel_state(");
5440 .description =
"SUBSCRIPTION TABLE",
5442 .createStmt = query->
data));
5462 char **pubnames = NULL;
5484 pg_fatal(
"could not parse %s array",
"subpublications");
5487 for (
i = 0;
i < npubnames;
i++)
5495 appendPQExpBuffer(query,
" PUBLICATION %s WITH (connect = false, slot_name = ", publications->
data);
5504 if (subinfo->
substream == LOGICALREP_STREAM_ON)
5506 else if (subinfo->
substream == LOGICALREP_STREAM_PARALLEL)
5558 "\n-- For binary upgrade, must preserve the remote_lsn for the subscriber's replication origin.\n");
5560 "SELECT pg_catalog.binary_upgrade_replorigin_advance(");
5572 "\n-- For binary upgrade, must preserve the subscriber's running state.\n");
5581 .description =
"SUBSCRIPTION",
5583 .createStmt = query->
data,
5584 .dropStmt = delq->
data));
5612 const char *catalog,
5613 const char *keyword,
5614 const char *objname)
5631 "FROM pg_catalog.pg_depend d, pg_catalog.pg_extension e "
5632 "WHERE d.refobjid = e.oid AND classid = '%s'::pg_catalog.regclass "
5633 "AND objid = '%u'::pg_catalog.oid AND deptype = 'x' "
5634 "AND refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass",
5640 for (
i = 0;
i < ntups;
i++)
5670 ++next_possible_free_oid;
5672 "SELECT EXISTS(SELECT 1 "
5673 "FROM pg_catalog.pg_type "
5674 "WHERE oid = '%u'::pg_catalog.oid);",
5675 next_possible_free_oid);
5681 return next_possible_free_oid;
5688 bool force_array_type,
5689 bool include_multirange_type)
5693 Oid pg_type_array_oid;
5694 Oid pg_type_multirange_oid;
5695 Oid pg_type_multirange_array_oid;
5700 "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5705 pg_type_array_oid =
tinfo->typarray;
5709 if (!
OidIsValid(pg_type_array_oid) && force_array_type)
5715 "\n-- For binary upgrade, must preserve pg_type array oid\n");
5717 "SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5724 if (include_multirange_type)
5729 "SELECT t.oid, t.typarray "
5730 "FROM pg_catalog.pg_type t "
5731 "JOIN pg_catalog.pg_range r "
5732 "ON t.oid = r.rngmultitypid "
5733 "WHERE r.rngtypid = '%u'::pg_catalog.oid;",
5750 "\n-- For binary upgrade, must preserve multirange pg_type oid\n");
5752 "SELECT pg_catalog.binary_upgrade_set_next_multirange_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5753 pg_type_multirange_oid);
5755 "\n-- For binary upgrade, must preserve multirange pg_type array oid\n");
5757 "SELECT pg_catalog.binary_upgrade_set_next_multirange_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5758 pg_type_multirange_array_oid);
5773 pg_type_oid,
false,
false);
5801 query =
"SELECT c.oid, c.relkind, c.relfilenode, c.reltoastrelid, "
5802 "ct.relfilenode, i.indexrelid, cti.relfilenode "
5803 "FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_index i "
5804 "ON (c.reltoastrelid = i.indrelid AND i.indisvalid) "
5805 "LEFT JOIN pg_catalog.pg_class ct ON (c.reltoastrelid = ct.oid) "
5806 "LEFT JOIN pg_catalog.pg_class AS cti ON (i.indexrelid = cti.oid) "
5849 key.oid = pg_class_oid;
5855 "\n-- For binary upgrade, must preserve pg_class oids and relfilenodes\n");
5857 if (entry->
relkind != RELKIND_INDEX &&
5858 entry->
relkind != RELKIND_PARTITIONED_INDEX)
5861 "SELECT pg_catalog.binary_upgrade_set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
5870 entry->
relkind != RELKIND_PARTITIONED_TABLE)
5872 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
5880 entry->
relkind != RELKIND_PARTITIONED_TABLE)
5883 "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
5886 "SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
5891 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5894 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5902 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5905 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5922 const char *objtype,
5923 const char *objname,
5924 const char *objnamespace)
5946 pg_fatal(
"could not find parent extension for %s %s",
5950 "\n-- For binary upgrade, handle extension membership the hard way\n");
5954 if (objnamespace && *objnamespace)
5987 "acldefault('n', n.nspowner) AS acldefault "
5988 "FROM pg_namespace n");
5996 i_tableoid =
PQfnumber(res,
"tableoid");
5999 i_nspowner =
PQfnumber(res,
"nspowner");
6001 i_acldefault =
PQfnumber(res,
"acldefault");
6003 for (
i = 0;
i < ntups;
i++)
6005 const char *nspowner;
6043 if (strcmp(nsinfo[
i].dobj.name,
"public") == 0)
6084 pg_fatal(
"schema with OID %u does not exist", nsoid);
6108 int i_extrelocatable;
6116 "x.extname, n.nspname, x.extrelocatable, x.extversion, x.extconfig, x.extcondition "
6117 "FROM pg_extension x "
6118 "JOIN pg_namespace n ON n.oid = x.extnamespace");
6128 i_tableoid =
PQfnumber(res,
"tableoid");
6132 i_extrelocatable =
PQfnumber(res,
"extrelocatable");
6133 i_extversion =
PQfnumber(res,
"extversion");
6134 i_extconfig =
PQfnumber(res,
"extconfig");
6135 i_extcondition =
PQfnumber(res,
"extcondition");
6137 for (
i = 0;
i < ntups;
i++)
6158 *numExtensions = ntups;
6210 "typnamespace, typacl, "
6211 "acldefault('T', typowner) AS acldefault, "
6213 "typelem, typrelid, typarray, "
6214 "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
6215 "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
6216 "typtype, typisdefined, "
6217 "typname[0] = '_' AND typelem != 0 AND "
6218 "(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray "
6227 i_tableoid =
PQfnumber(res,
"tableoid");
6230 i_typnamespace =
PQfnumber(res,
"typnamespace");
6232 i_acldefault =
PQfnumber(res,
"acldefault");
6233 i_typowner =
PQfnumber(res,
"typowner");
6235 i_typrelid =
PQfnumber(res,
"typrelid");
6236 i_typrelkind =
PQfnumber(res,
"typrelkind");
6238 i_typisdefined =
PQfnumber(res,
"typisdefined");
6240 i_typarray =
PQfnumber(res,
"typarray");
6242 for (
i = 0;
i < ntups;
i++)
6249 tyinfo[
i].
dobj.namespace =
6263 if (strcmp(
PQgetvalue(res,
i, i_typisdefined),
"t") == 0)
6268 if (strcmp(
PQgetvalue(res,
i, i_isarray),
"t") == 0)
6275 if (tyinfo[
i].typtype == TYPTYPE_MULTIRANGE)
6294 tyinfo[
i].
typtype == TYPTYPE_DOMAIN)
6308 (tyinfo[
i].
typtype == TYPTYPE_BASE ||
6309 tyinfo[
i].
typtype == TYPTYPE_RANGE))
6316 stinfo->
dobj.namespace = tyinfo[
i].
dobj.namespace;
6367 "oprcode::oid AS oprcode "
6368 "FROM pg_operator");
6376 i_tableoid =
PQfnumber(res,
"tableoid");
6379 i_oprnamespace =
PQfnumber(res,
"oprnamespace");
6380 i_oprowner =
PQfnumber(res,
"oprowner");
6383 i_oprright =
PQfnumber(res,
"oprright");
6386 for (
i = 0;
i < ntups;
i++)
6393 oprinfo[
i].
dobj.namespace =
6425 int i_collnamespace;
6440 "FROM pg_collation");
6448 i_tableoid =
PQfnumber(res,
"tableoid");
6450 i_collname =
PQfnumber(res,
"collname");
6451 i_collnamespace =
PQfnumber(res,
"collnamespace");
6452 i_collowner =
PQfnumber(res,
"collowner");
6453 i_collencoding =
PQfnumber(res,
"collencoding");
6455 for (
i = 0;
i < ntups;
i++)
6462 collinfo[
i].
dobj.namespace =
6504 "FROM pg_conversion");
6512 i_tableoid =
PQfnumber(res,
"tableoid");
6515 i_connamespace =
PQfnumber(res,
"connamespace");
6516 i_conowner =
PQfnumber(res,
"conowner");
6518 for (
i = 0;
i < ntups;
i++)
6525 convinfo[
i].
dobj.namespace =
6572 "amhandler::pg_catalog.regproc AS amhandler ");
6575 "'i'::pg_catalog.\"char\" AS amtype, "
6576 "'-'::pg_catalog.regproc AS amhandler ");
6585 i_tableoid =
PQfnumber(res,
"tableoid");
6588 i_amhandler =
PQfnumber(res,
"amhandler");
6591 for (
i = 0;
i < ntups;
i++)
6598 aminfo[
i].
dobj.namespace = NULL;
6647 i_tableoid =
PQfnumber(res,
"tableoid");
6649 i_opcmethod =
PQfnumber(res,
"opcmethod");
6651 i_opcnamespace =
PQfnumber(res,
"opcnamespace");
6652 i_opcowner =
PQfnumber(res,
"opcowner");
6654 for (
i = 0;
i < ntups;
i++)
6661 opcinfo[
i].
dobj.namespace =
6704 "FROM pg_opfamily");
6712 i_tableoid =
PQfnumber(res,
"tableoid");
6715 i_opfmethod =
PQfnumber(res,
"opfmethod");
6716 i_opfnamespace =
PQfnumber(res,
"opfnamespace");
6717 i_opfowner =
PQfnumber(res,
"opfowner");
6719 for (
i = 0;
i < ntups;
i++)
6726 opfinfo[
i].
dobj.namespace =
6769 const char *agg_check;
6771 agg_check = (fout->
remoteVersion >= 110000 ?
"p.prokind = 'a'"
6775 "p.proname AS aggname, "
6776 "p.pronamespace AS aggnamespace, "
6777 "p.pronargs, p.proargtypes, "
6779 "p.proacl AS aggacl, "
6780 "acldefault('f', p.proowner) AS acldefault "
6782 "LEFT JOIN pg_init_privs pip ON "
6783 "(p.oid = pip.objoid "
6784 "AND pip.classoid = 'pg_proc'::regclass "
6785 "AND pip.objsubid = 0) "
6787 "p.pronamespace != "
6788 "(SELECT oid FROM pg_namespace "
6789 "WHERE nspname = 'pg_catalog') OR "
6790 "p.proacl IS DISTINCT FROM pip.initprivs",
6794 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6795 "classid = 'pg_proc'::regclass AND "
6796 "objid = p.oid AND "
6797 "refclassid = 'pg_extension'::regclass AND "
6804 "pronamespace AS aggnamespace, "
6805 "pronargs, proargtypes, "
6807 "proacl AS aggacl, "
6808 "acldefault('f', proowner) AS acldefault "
6810 "WHERE proisagg AND ("
6812 "(SELECT oid FROM pg_namespace "
6813 "WHERE nspname = 'pg_catalog')");
6816 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6817 "classid = 'pg_proc'::regclass AND "
6818 "objid = p.oid AND "
6819 "refclassid = 'pg_extension'::regclass AND "
6830 i_tableoid =
PQfnumber(res,
"tableoid");
6833 i_aggnamespace =
PQfnumber(res,
"aggnamespace");
6834 i_pronargs =
PQfnumber(res,
"pronargs");
6835 i_proargtypes =
PQfnumber(res,
"proargtypes");
6836 i_proowner =
PQfnumber(res,
"proowner");
6838 i_acldefault =
PQfnumber(res,
"acldefault");
6840 for (
i = 0;
i < ntups;
i++)
6842 agginfo[
i].aggfn.dobj.objType =
DO_AGG;
6847 agginfo[
i].aggfn.dobj.namespace =
6851 agginfo[
i].aggfn.dacl.privtype = 0;
6852 agginfo[
i].aggfn.dacl.initprivs = NULL;
6856 agginfo[
i].aggfn.nargs = atoi(
PQgetvalue(res,
i, i_pronargs));
6857 if (agginfo[
i].aggfn.nargs == 0)
6858 agginfo[
i].aggfn.argtypes = NULL;
6861 agginfo[
i].aggfn.argtypes = (
Oid *)
pg_malloc(agginfo[
i].aggfn.nargs *
sizeof(
Oid));
6863 agginfo[
i].aggfn.argtypes,
6864 agginfo[
i].aggfn.nargs);
6866 agginfo[
i].aggfn.postponed_def =
false;
6929 const char *not_agg_check;
6931 not_agg_check = (fout->
remoteVersion >= 110000 ?
"p.prokind <> 'a'"
6932 :
"NOT p.proisagg");
6935 "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
6936 "p.pronargs, p.proargtypes, p.prorettype, "
6938 "acldefault('f', p.proowner) AS acldefault, "
6942 "LEFT JOIN pg_init_privs pip ON "
6943 "(p.oid = pip.objoid "
6944 "AND pip.classoid = 'pg_proc'::regclass "
6945 "AND pip.objsubid = 0) "
6947 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6948 "WHERE classid = 'pg_proc'::regclass AND "
6949 "objid = p.oid AND deptype = 'i')"
6951 "\n pronamespace != "
6952 "(SELECT oid FROM pg_namespace "
6953 "WHERE nspname = 'pg_catalog')"
6954 "\n OR EXISTS (SELECT 1 FROM pg_cast"
6955 "\n WHERE pg_cast.oid > %u "
6956 "\n AND p.oid = pg_cast.castfunc)"
6957 "\n OR EXISTS (SELECT 1 FROM pg_transform"
6958 "\n WHERE pg_transform.oid > %u AND "
6959 "\n (p.oid = pg_transform.trffromsql"
6960 "\n OR p.oid = pg_transform.trftosql))",
6966 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6967 "classid = 'pg_proc'::regclass AND "
6968 "objid = p.oid AND "
6969 "refclassid = 'pg_extension'::regclass AND "
6972 "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
6978 "SELECT tableoid, oid, proname, prolang, "
6979 "pronargs, proargtypes, prorettype, proacl, "
6980 "acldefault('f', proowner) AS acldefault, "
6984 "WHERE NOT proisagg"
6985 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6986 "WHERE classid = 'pg_proc'::regclass AND "
6987 "objid = p.oid AND deptype = 'i')"
6989 "\n pronamespace != "
6990 "(SELECT oid FROM pg_namespace "
6991 "WHERE nspname = 'pg_catalog')"
6992 "\n OR EXISTS (SELECT 1 FROM pg_cast"
6993 "\n WHERE pg_cast.oid > '%u'::oid"
6994 "\n AND p.oid = pg_cast.castfunc)",
6999 "\n OR EXISTS (SELECT 1 FROM pg_transform"
7000 "\n WHERE pg_transform.oid > '%u'::oid"
7001 "\n AND (p.oid = pg_transform.trffromsql"
7002 "\n OR p.oid = pg_transform.trftosql))",
7007 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
7008 "classid = 'pg_proc'::regclass AND "
7009 "objid = p.oid AND "
7010 "refclassid = 'pg_extension'::regclass AND "
7021 i_tableoid =
PQfnumber(res,
"tableoid");
7024 i_pronamespace =
PQfnumber(res,
"pronamespace");
7025 i_proowner =
PQfnumber(res,
"proowner");
7027 i_pronargs =
PQfnumber(res,
"pronargs");
7028 i_proargtypes =
PQfnumber(res,
"proargtypes");
7029 i_prorettype =
PQfnumber(res,
"prorettype");
7031 i_acldefault =
PQfnumber(res,
"acldefault");
7033 for (
i = 0;
i < ntups;
i++)
7040 finfo[
i].
dobj.namespace =
7050 if (finfo[
i].nargs == 0)
7056 finfo[
i].argtypes, finfo[
i].nargs);
7082 char *reltuples,
int32 relallvisible,
7083 int32 relallfrozen,
char relkind,
7084 char **indAttNames,
int nindAttNames)
7089 if ((relkind == RELKIND_RELATION) ||
7090 (relkind == RELKIND_PARTITIONED_TABLE) ||
7091 (relkind == RELKIND_INDEX) ||
7092 (relkind == RELKIND_PARTITIONED_INDEX) ||
7093 (relkind == RELKIND_MATVIEW ||
7094 relkind == RELKIND_FOREIGN_TABLE))
7109 dobj->namespace = rel->namespace;
7130 case RELKIND_RELATION:
7131 case RELKIND_PARTITIONED_TABLE:
7132 case RELKIND_MATVIEW:
7133 case RELKIND_FOREIGN_TABLE:
7137 case RELKIND_PARTITIONED_INDEX:
7141 pg_fatal(
"cannot dump statistics for relation kind \"%c\"",
7178 int i_relallvisible;
7183 int i_reltablespace;
7185 int i_relhastriggers;
7186 int i_relpersistence;
7187 int i_relispopulated;
7190 int i_relforcerowsec;
7192 int i_toastfrozenxid;
7198 int i_toastreloptions;
7200 int i_foreignserver;
7202 int i_is_identity_sequence;
7225 "SELECT c.tableoid, c.oid, c.relname, "
7226 "c.relnamespace, c.relkind, c.reltype, "
7229 "c.relhasindex, c.relhasrules, c.relpages, "
7230 "c.reltuples, c.relallvisible, ");
7238 "c.relhastriggers, c.relpersistence, "
7241 "acldefault(CASE WHEN c.relkind = " CppAsString2(RELKIND_SEQUENCE)
7242 " THEN 's'::\"char\" ELSE 'r'::\"char\" END, c.relowner) AS acldefault, "
7243 "CASE WHEN c.relkind = " CppAsString2(RELKIND_FOREIGN_TABLE)
" THEN "
7244 "(SELECT ftserver FROM pg_catalog.pg_foreign_table WHERE ftrelid = c.oid) "
7245 "ELSE 0 END AS foreignserver, "
7246 "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, "
7248 "tc.relpages AS toastpages, "
7249 "tc.reloptions AS toast_reloptions, "
7250 "d.refobjid AS owning_tab, "
7251 "d.refobjsubid AS owning_col, "
7252 "tsp.spcname AS reltablespace, ");
7256 "false AS relhasoids, ");
7263 "c.relispopulated, ");
7266 "'t' as relispopulated, ");
7270 "c.relreplident, ");
7273 "'d' AS relreplident, ");
7277 "c.relrowsecurity, c.relforcerowsecurity, ");
7280 "false AS relrowsecurity, "
7281 "false AS relforcerowsecurity, ");
7285 "c.relminmxid, tc.relminmxid AS tminmxid, ");
7288 "0 AS relminmxid, 0 AS tminmxid, ");
7292 "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
7293 "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
7294 "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
7297 "c.reloptions, NULL AS checkoption, ");
7304 "NULL AS amname, ");
7308 "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
7311 "false AS is_identity_sequence, ");
7315 "c.relispartition AS ispartition ");
7318 "false AS ispartition ");
7327 "\nFROM pg_class c\n"
7328 "LEFT JOIN pg_depend d ON "
7330 "d.classid = 'pg_class'::regclass AND d.objid = c.oid AND "
7331 "d.objsubid = 0 AND "
7332 "d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
7333 "LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
7340 "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
7348 "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid"
7350 " AND c.relkind <> " CppAsString2(RELKIND_PARTITIONED_TABLE)
")\n");
7363 "WHERE c.relkind IN ("
7390 i_reltableoid =
PQfnumber(res,
"tableoid");
7393 i_relnamespace =
PQfnumber(res,
"relnamespace");
7396 i_relowner =
PQfnumber(res,
"relowner");
7397 i_relchecks =
PQfnumber(res,
"relchecks");
7398 i_relhasindex =
PQfnumber(res,
"relhasindex");
7399 i_relhasrules =
PQfnumber(res,
"relhasrules");
7400 i_relpages =
PQfnumber(res,
"relpages");
7401 i_reltuples =
PQfnumber(res,
"reltuples");
7402 i_relallvisible =
PQfnumber(res,
"relallvisible");
7403 i_relallfrozen =
PQfnumber(res,
"relallfrozen");
7404 i_toastpages =
PQfnumber(res,
"toastpages");
7405 i_owning_tab =
PQfnumber(res,
"owning_tab");
7406 i_owning_col =
PQfnumber(res,
"owning_col");
7407 i_reltablespace =
PQfnumber(res,
"reltablespace");
7408 i_relhasoids =
PQfnumber(res,
"relhasoids");
7409 i_relhastriggers =
PQfnumber(res,
"relhastriggers");
7410 i_relpersistence =
PQfnumber(res,
"relpersistence");
7411 i_relispopulated =
PQfnumber(res,
"relispopulated");
7412 i_relreplident =
PQfnumber(res,
"relreplident");
7413 i_relrowsec =
PQfnumber(res,
"relrowsecurity");
7414 i_relforcerowsec =
PQfnumber(res,
"relforcerowsecurity");
7415 i_relfrozenxid =
PQfnumber(res,
"relfrozenxid");
7416 i_toastfrozenxid =
PQfnumber(res,
"tfrozenxid");
7418 i_relminmxid =
PQfnumber(res,
"relminmxid");
7419 i_toastminmxid =
PQfnumber(res,
"tminmxid");
7420 i_reloptions =
PQfnumber(res,
"reloptions");
7421 i_checkoption =
PQfnumber(res,
"checkoption");
7422 i_toastreloptions =
PQfnumber(res,
"toast_reloptions");
7423 i_reloftype =
PQfnumber(res,
"reloftype");
7424 i_foreignserver =
PQfnumber(res,
"foreignserver");
7426 i_is_identity_sequence =
PQfnumber(res,
"is_identity_sequence");
7428 i_acldefault =
PQfnumber(res,
"acldefault");
7429 i_ispartition =
PQfnumber(res,
"ispartition");
7448 for (
i = 0;
i < ntups;
i++)
7458 tblinfo[
i].
dobj.namespace =
7518 if (tblinfo[
i].relkind == RELKIND_COMPOSITE_TYPE)
7551 if (tblinfo[
i].interesting)
7556 tblinfo[
i].relpages,
7558 relallvisible, relallfrozen,
7559 tblinfo[
i].relkind, NULL, 0);
7560 if (tblinfo[
i].relkind == RELKIND_MATVIEW)
7561 tblinfo[
i].
stats = stats;
7580 (tblinfo[
i].
relkind == RELKIND_RELATION ||
7581 tblinfo[
i].
relkind == RELKIND_PARTITIONED_TABLE))
7588 if (query->
len == 0)
7597 if (query->
len >= 100000)
7608 if (query->
len != 0)
7643 for (
i = 0;
i < numTables;
i++)
7652 if (owning_tab == NULL)
7653 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
7718 *numInherits = ntups;
7722 i_inhrelid =
PQfnumber(res,
"inhrelid");
7723 i_inhparent =
PQfnumber(res,
"inhparent");
7725 for (
i = 0;
i < ntups;
i++)
7780 "SELECT partrelid FROM pg_partitioned_table WHERE\n"
7781 "(SELECT c.oid FROM pg_opclass c JOIN pg_am a "
7782 "ON c.opcmethod = a.oid\n"
7783 "WHERE opcname = 'enum_ops' "
7784 "AND opcnamespace = 'pg_catalog'::regnamespace "
7785 "AND amname = 'hash') = ANY(partclass)");
7791 for (
int i = 0;
i < ntups;
i++)
7798 pg_fatal(
"failed sanity check, table OID %u appearing in pg_partitioned_table not found",
7839 i_indnullsnotdistinct,
7863 for (
int i = 0;
i < numTables;
i++)
7877 if (tbloids->
len > 1)
7884 "SELECT t.tableoid, t.oid, i.indrelid, "
7885 "t.relname AS indexname, "
7886 "t.relpages, t.reltuples, t.relallvisible, ");
7894 "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
7895 "i.indkey, i.indisclustered, "
7896 "c.contype, c.conname, "
7897 "c.condeferrable, c.condeferred, "
7898 "c.tableoid AS contableoid, "
7900 "pg_catalog.pg_get_constraintdef(c.oid, false) AS condef, "
7901 "CASE WHEN i.indexprs IS NOT NULL THEN "
7902 "(SELECT pg_catalog.array_agg(attname ORDER BY attnum)"
7903 " FROM pg_catalog.pg_attribute "
7904 " WHERE attrelid = i.indexrelid) "
7905 "ELSE NULL END AS indattnames, "
7906 "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
7907 "t.reloptions AS indreloptions, ");
7912 "i.indisreplident, ");
7915 "false AS indisreplident, ");
7919 "inh.inhparent AS parentidx, "
7920 "i.indnkeyatts AS indnkeyatts, "
7921 "i.indnatts AS indnatts, "
7922 "(SELECT pg_catalog.array_agg(attnum ORDER BY attnum) "
7923 " FROM pg_catalog.pg_attribute "
7924 " WHERE attrelid = i.indexrelid AND "
7925 " attstattarget >= 0) AS indstatcols, "
7926 "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attnum) "
7927 " FROM pg_catalog.pg_attribute "
7928 " WHERE attrelid = i.indexrelid AND "
7929 " attstattarget >= 0) AS indstatvals, ");
7933 "i.indnatts AS indnkeyatts, "
7934 "i.indnatts AS indnatts, "
7935 "'' AS indstatcols, "
7936 "'' AS indstatvals, ");
7940 "i.indnullsnotdistinct, ");
7943 "false AS indnullsnotdistinct, ");
7950 "NULL AS conperiod ");
7964 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7965 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7966 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7967 "JOIN pg_catalog.pg_class t2 ON (t2.oid = i.indrelid) "
7968 "LEFT JOIN pg_catalog.pg_constraint c "
7969 "ON (i.indrelid = c.conrelid AND "
7970 "i.indexrelid = c.conindid AND "
7971 "c.contype IN ('p','u','x')) "
7972 "LEFT JOIN pg_catalog.pg_inherits inh "
7973 "ON (inh.inhrelid = indexrelid) "
7974 "WHERE (i.indisvalid OR t2.relkind = 'p') "
7976 "ORDER BY i.indrelid, indexname",
7986 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7987 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7988 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7989 "LEFT JOIN pg_catalog.pg_constraint c "
7990 "ON (i.indrelid = c.conrelid AND "
7991 "i.indexrelid = c.conindid AND "
7992 "c.contype IN ('p','u','x')) "
7993 "WHERE i.indisvalid AND i.indisready "
7994 "ORDER BY i.indrelid, indexname",
8002 i_tableoid =
PQfnumber(res,
"tableoid");
8004 i_indrelid =
PQfnumber(res,
"indrelid");
8005 i_indexname =
PQfnumber(res,
"indexname");
8006 i_relpages =
PQfnumber(res,
"relpages");
8007 i_reltuples =
PQfnumber(res,
"reltuples");
8008 i_relallvisible =
PQfnumber(res,
"relallvisible");
8009 i_relallfrozen =
PQfnumber(res,
"relallfrozen");
8010 i_parentidx =
PQfnumber(res,
"parentidx");
8011 i_indexdef =
PQfnumber(res,
"indexdef");
8012 i_indnkeyatts =
PQfnumber(res,
"indnkeyatts");
8013 i_indnatts =
PQfnumber(res,
"indnatts");
8015 i_indisclustered =
PQfnumber(res,
"indisclustered");
8016 i_indisreplident =
PQfnumber(res,
"indisreplident");
8017 i_indnullsnotdistinct =
PQfnumber(res,
"indnullsnotdistinct");
8020 i_condeferrable =
PQfnumber(res,
"condeferrable");
8021 i_condeferred =
PQfnumber(res,
"condeferred");
8022 i_conperiod =
PQfnumber(res,
"conperiod");
8023 i_contableoid =
PQfnumber(res,
"contableoid");
8026 i_indattnames =
PQfnumber(res,
"indattnames");
8027 i_tablespace =
PQfnumber(res,
"tablespace");
8028 i_indreloptions =
PQfnumber(res,
"indreloptions");
8029 i_indstatcols =
PQfnumber(res,
"indstatcols");
8030 i_indstatvals =
PQfnumber(res,
"indstatvals");
8039 for (
int j = 0;
j < ntups;)
8043 char **indAttNames = NULL;
8044 int nindAttNames = 0;
8048 for (numinds = 1; numinds < ntups -
j; numinds++)
8056 while (++curtblindx < numTables)
8058 tbinfo = &tblinfo[curtblindx];
8062 if (curtblindx >= numTables)
8063 pg_fatal(
"unrecognized table OID %u", indrelid);
8067 pg_fatal(
"unexpected index data for table \"%s\"",
8074 for (
int c = 0;
c < numinds;
c++,
j++)
8089 indxinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8100 indxinfo[
j].indkeys, indxinfo[
j].indnattrs);
8110 if (indxinfo[
j].parentidx == 0)
8111 indexkind = RELKIND_INDEX;
8113 indexkind = RELKIND_PARTITIONED_INDEX;
8118 &indAttNames, &nindAttNames))
8119 pg_fatal(
"could not parse %s array",
"indattnames");
8124 relallvisible, relallfrozen, indexkind,
8125 indAttNames, nindAttNames);
8128 if (contype ==
'p' || contype ==
'u' || contype ==
'x')
8143 constrinfo->
dobj.namespace = tbinfo->
dobj.namespace;
8146 constrinfo->
contype = contype;
8150 constrinfo->
condef = NULL;
8160 if (relstats != NULL)
8208 "stxnamespace, stxowner, stxrelid, NULL AS stxstattarget "
8209 "FROM pg_catalog.pg_statistic_ext");
8212 "stxnamespace, stxowner, stxrelid, stxstattarget "
8213 "FROM pg_catalog.pg_statistic_ext");
8219 i_tableoid =
PQfnumber(res,
"tableoid");
8222 i_stxnamespace =
PQfnumber(res,
"stxnamespace");
8223 i_stxowner =
PQfnumber(res,
"stxowner");
8224 i_stxrelid =
PQfnumber(res,
"stxrelid");
8225 i_stattarget =
PQfnumber(res,
"stxstattarget");
8229 for (
i = 0;
i < ntups;
i++)
8236 statsextinfo[
i].
dobj.namespace =
8290 for (
int i = 0;
i < numTables;
i++)
8298 if (tbloids->
len > 1)
8305 "SELECT c.tableoid, c.oid, "
8306 "conrelid, conname, confrelid, ");
8312 "pg_catalog.pg_get_constraintdef(c.oid) AS condef\n"
8313 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8314 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
8315 "WHERE contype = 'f' ",
8319 "AND conparentid = 0 ");
8321 "ORDER BY conrelid, conname");
8327 i_contableoid =
PQfnumber(res,
"tableoid");
8329 i_conrelid =
PQfnumber(res,
"conrelid");
8331 i_confrelid =
PQfnumber(res,
"confrelid");
8332 i_conindid =
PQfnumber(res,
"conindid");
8338 for (
int j = 0;
j < ntups;
j++)
8347 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != conrelid)
8349 while (++curtblindx < numTables)
8351 tbinfo = &tblinfo[curtblindx];
8355 if (curtblindx >= numTables)
8356 pg_fatal(
"unrecognized table OID %u", conrelid);
8364 constrinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8383 if (reftable && reftable->
relkind == RELKIND_PARTITIONED_TABLE)
8389 for (
int k = 0; k < reftable->
numIndexes; k++)
8397 refidx = &reftable->
indexes[k];
8467 "PREPARE getDomainConstraints(pg_catalog.oid) AS\n"
8468 "SELECT tableoid, oid, conname, "
8469 "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
8470 "convalidated, contype "
8471 "FROM pg_catalog.pg_constraint "
8472 "WHERE contypid = $1 AND contype IN (%s) "
8482 "EXECUTE getDomainConstraints('%u')",
8489 i_tableoid =
PQfnumber(res,
"tableoid");
8493 i_convalidated =
PQfnumber(res,
"convalidated");
8500 for (
int i = 0,
j = 0;
i < ntups;
i++)
8502 bool validated =
PQgetvalue(res,
i, i_convalidated)[0] ==
't';
8503 char contype = (
PQgetvalue(res,
i, i_contype))[0];
8506 if (contype == CONSTRAINT_CHECK)
8508 constraint = &constrinfo[
j++];
8513 Assert(contype == CONSTRAINT_NOTNULL);
8516 tyinfo->
notnull = &(constrinfo[ntups - 1]);
8525 constraint->
dobj.namespace = tyinfo->
dobj.namespace;
8528 constraint->
contype = contype;
8574 "tableoid, oid, rulename, "
8575 "ev_class AS ruletable, ev_type, is_instead, "
8586 i_tableoid =
PQfnumber(res,
"tableoid");
8588 i_rulename =
PQfnumber(res,
"rulename");
8589 i_ruletable =
PQfnumber(res,
"ruletable");
8591 i_is_instead =
PQfnumber(res,
"is_instead");
8592 i_ev_enabled =
PQfnumber(res,
"ev_enabled");
8594 for (
i = 0;
i < ntups;
i++)
8605 if (ruleinfo[
i].ruletable == NULL)
8606 pg_fatal(
"failed sanity check, parent table with OID %u of pg_rewrite entry with OID %u not found",
8607 ruletableoid, ruleinfo[
i].dobj.catId.oid);
8613 if (ruleinfo[
i].ruletable)
8622 if ((ruleinfo[
i].ruletable->relkind == RELKIND_VIEW ||
8680 for (
int i = 0;
i < numTables;
i++)
8689 if (tbloids->
len > 1)
8706 "SELECT t.tgrelid, t.tgname, "
8707 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8708 "t.tgenabled, t.tableoid, t.oid, "
8709 "t.tgparentid <> 0 AS tgispartition\n"
8710 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8711 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8712 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8713 "WHERE ((NOT t.tgisinternal AND t.tgparentid = 0) "
8714 "OR t.tgenabled != u.tgenabled) "
8715 "ORDER BY t.tgrelid, t.tgname",
8729 "SELECT t.tgrelid, t.tgname, "
8730 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8731 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition\n"
8732 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8733 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8734 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8735 "WHERE (NOT t.tgisinternal OR t.tgenabled != u.tgenabled) "
8736 "ORDER BY t.tgrelid, t.tgname",
8749 "SELECT t.tgrelid, t.tgname, "
8750 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8751 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition "
8752 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8753 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8754 "LEFT JOIN pg_catalog.pg_depend AS d ON "
8755 " d.classid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8756 " d.refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8758 "LEFT JOIN pg_catalog.pg_trigger AS pt ON pt.oid = refobjid "
8759 "WHERE (NOT t.tgisinternal OR t.tgenabled != pt.tgenabled) "
8760 "ORDER BY t.tgrelid, t.tgname",
8767 "SELECT t.tgrelid, t.tgname, "
8768 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8769 "t.tgenabled, false as tgispartition, "
8770 "t.tableoid, t.oid "
8771 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8772 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8773 "WHERE NOT tgisinternal "
8774 "ORDER BY t.tgrelid, t.tgname",
8782 i_tableoid =
PQfnumber(res,
"tableoid");
8786 i_tgenabled =
PQfnumber(res,
"tgenabled");
8787 i_tgispartition =
PQfnumber(res,
"tgispartition");
8797 for (
int j = 0;
j < ntups;)
8804 for (numtrigs = 1; numtrigs < ntups -
j; numtrigs++)
8812 while (++curtblindx < numTables)
8814 tbinfo = &tblinfo[curtblindx];
8818 if (curtblindx >= numTables)
8819 pg_fatal(
"unrecognized table OID %u", tgrelid);
8825 for (
int c = 0;
c < numtrigs;
c++,
j++)
8832 tginfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8874 "SELECT e.tableoid, e.oid, evtname, evtenabled, "
8875 "evtevent, evtowner, "
8876 "array_to_string(array("
8877 "select quote_literal(x) "
8878 " from unnest(evttags) as t(x)), ', ') as evttags, "
8879 "e.evtfoid::regproc as evtfname "
8880 "FROM pg_event_trigger e "
8889 i_tableoid =
PQfnumber(res,
"tableoid");
8892 i_evtevent =
PQfnumber(res,
"evtevent");
8893 i_evtowner =
PQfnumber(res,
"evtowner");
8895 i_evtfname =
PQfnumber(res,
"evtfname");
8896 i_evtenabled =
PQfnumber(res,
"evtenabled");
8898 for (
i = 0;
i < ntups;
i++)
8940 int i_lanplcallfoid;
8948 "lanname, lanpltrusted, lanplcallfoid, "
8949 "laninline, lanvalidator, "
8951 "acldefault('l', lanowner) AS acldefault, "
8963 i_tableoid =
PQfnumber(res,
"tableoid");
8966 i_lanpltrusted =
PQfnumber(res,
"lanpltrusted");
8967 i_lanplcallfoid =
PQfnumber(res,
"lanplcallfoid");
8968 i_laninline =
PQfnumber(res,
"laninline");
8969 i_lanvalidator =
PQfnumber(res,
"lanvalidator");
8971 i_acldefault =
PQfnumber(res,
"acldefault");
8972 i_lanowner =
PQfnumber(res,
"lanowner");
8974 for (
i = 0;
i < ntups;
i++)
9031 "castsource, casttarget, castfunc, castcontext, "
9034 "WHERE NOT EXISTS ( "
9035 "SELECT 1 FROM pg_range r "
9036 "WHERE c.castsource = r.rngtypid "
9037 "AND c.casttarget = r.rngmultitypid "
9044 "castsource, casttarget, castfunc, castcontext, "
9046 "FROM pg_cast ORDER BY 3,4");
9055 i_tableoid =
PQfnumber(res,
"tableoid");
9057 i_castsource =
PQfnumber(res,
"castsource");
9058 i_casttarget =
PQfnumber(res,
"casttarget");
9059 i_castfunc =
PQfnumber(res,
"castfunc");
9060 i_castcontext =
PQfnumber(res,
"castcontext");
9061 i_castmethod =
PQfnumber(res,
"castmethod");
9063 for (
i = 0;
i < ntups;
i++)
9087 if (sTypeInfo && tTypeInfo)
9109 appendPQExpBuffer(query,
"SELECT lanname FROM pg_language WHERE oid = %u", langid);
9144 "trftype, trflang, trffromsql::oid, trftosql::oid "
9145 "FROM pg_transform "
9154 i_tableoid =
PQfnumber(res,
"tableoid");
9158 i_trffromsql =
PQfnumber(res,
"trffromsql");
9159 i_trftosql =
PQfnumber(res,
"trftosql");
9161 for (
i = 0;
i < ntups;
i++)
9184 if (typeInfo && lanname)
9221 int i_attstattarget;
9231 int i_notnull_comment;
9232 int i_notnull_noinherit;
9233 int i_notnull_islocal;
9234 int i_notnull_invalidoid;
9237 int i_attcompression;
9238 int i_attfdwoptions;
9239 int i_attmissingval;
9254 for (
int i = 0;
i < numTables;
i++)
9259 if (tbinfo->
relkind == RELKIND_SEQUENCE)
9274 (tbinfo->
dobj.
catId.
oid == LargeObjectMetadataRelationId ||
9279 if (tbloids->
len > 1)
9286 if (checkoids->
len > 1)
9306 "a.attstattarget,\n"
9314 "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n"
9315 "array_to_string(a.attoptions, ', ') AS attoptions,\n"
9316 "CASE WHEN a.attcollation <> t.typcollation "
9317 "THEN a.attcollation ELSE 0 END AS attcollation,\n"
9318 "pg_catalog.array_to_string(ARRAY("
9319 "SELECT pg_catalog.quote_ident(option_name) || "
9320 "' ' || pg_catalog.quote_literal(option_value) "
9321 "FROM pg_catalog.pg_options_to_table(attfdwoptions) "
9322 "ORDER BY option_name"
9323 "), E',\n ') AS attfdwoptions,\n");
9346 "co.conname AS notnull_name,\n"
9347 "CASE WHEN co.convalidated THEN pt.description"
9348 " ELSE NULL END AS notnull_comment,\n"
9349 "CASE WHEN NOT co.convalidated THEN co.oid "
9350 "ELSE NULL END AS notnull_invalidoid,\n"
9351 "co.connoinherit AS notnull_noinherit,\n"
9352 "co.conislocal AS notnull_islocal,\n");
9355 "CASE WHEN a.attnotnull THEN '' ELSE NULL END AS notnull_name,\n"
9356 "NULL AS notnull_comment,\n"
9357 "NULL AS notnull_invalidoid,\n"
9358 "false AS notnull_noinherit,\n"
9359 "a.attislocal AS notnull_islocal,\n");
9363 "a.attcompression AS attcompression,\n");
9366 "'' AS attcompression,\n");
9370 "a.attidentity,\n");
9373 "'' AS attidentity,\n");
9377 "CASE WHEN a.atthasmissing AND NOT a.attisdropped "
9378 "THEN a.attmissingval ELSE null END AS attmissingval,\n");
9381 "NULL AS attmissingval,\n");
9385 "a.attgenerated\n");
9388 "'' AS attgenerated\n");
9392 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9393 "JOIN pg_catalog.pg_attribute a ON (src.tbloid = a.attrelid) "
9394 "LEFT JOIN pg_catalog.pg_type t "
9395 "ON (a.atttypid = t.oid)\n",
9404 " LEFT JOIN pg_catalog.pg_constraint co ON "
9405 "(a.attrelid = co.conrelid\n"
9406 " AND co.contype = 'n' AND "
9407 "co.conkey = array[a.attnum])\n"
9408 " LEFT JOIN pg_catalog.pg_description pt ON "
9409 "(pt.classoid = co.tableoid AND pt.objoid = co.oid)\n");
9412 "WHERE a.attnum > 0::pg_catalog.int2\n"
9413 "ORDER BY a.attrelid, a.attnum");
9419 i_attrelid =
PQfnumber(res,
"attrelid");
9422 i_atttypname =
PQfnumber(res,
"atttypname");
9423 i_attstattarget =
PQfnumber(res,
"attstattarget");
9424 i_attstorage =
PQfnumber(res,
"attstorage");
9425 i_typstorage =
PQfnumber(res,
"typstorage");
9426 i_attidentity =
PQfnumber(res,
"attidentity");
9427 i_attgenerated =
PQfnumber(res,
"attgenerated");
9428 i_attisdropped =
PQfnumber(res,
"attisdropped");
9430 i_attalign =
PQfnumber(res,
"attalign");
9431 i_attislocal =
PQfnumber(res,
"attislocal");
9432 i_notnull_name =
PQfnumber(res,
"notnull_name");
9433 i_notnull_comment =
PQfnumber(res,
"notnull_comment");
9434 i_notnull_invalidoid =
PQfnumber(res,
"notnull_invalidoid");
9435 i_notnull_noinherit =
PQfnumber(res,
"notnull_noinherit");
9436 i_notnull_islocal =
PQfnumber(res,
"notnull_islocal");
9437 i_attoptions =
PQfnumber(res,
"attoptions");
9438 i_attcollation =
PQfnumber(res,
"attcollation");
9439 i_attcompression =
PQfnumber(res,
"attcompression");
9440 i_attfdwoptions =
PQfnumber(res,
"attfdwoptions");
9441 i_attmissingval =
PQfnumber(res,
"attmissingval");
9442 i_atthasdef =
PQfnumber(res,
"atthasdef");
9453 for (
int r = 0; r < ntups;)
9461 for (numatts = 1; numatts < ntups - r; numatts++)
9469 while (++curtblindx < numTables)
9471 tbinfo = &tblinfo[curtblindx];
9475 if (curtblindx >= numTables)
9476 pg_fatal(
"unrecognized table OID %u", attrelid);
9478 if (tbinfo->
relkind == RELKIND_SEQUENCE ||
9481 (tbinfo->
dobj.
catId.
oid == LargeObjectMetadataRelationId ||
9483 pg_fatal(
"unexpected column data for table \"%s\"",
9510 hasdefaults =
false;
9512 for (
int j = 0;
j < numatts;
j++, r++)
9515 pg_fatal(
"invalid column numbering in table \"%s\"",
9538 i_notnull_invalidoid,
9539 i_notnull_noinherit,
9541 &invalidnotnulloids);
9551 if (
PQgetvalue(res, r, i_atthasdef)[0] ==
't')
9558 if (tbloids->
len > 1)
9565 if (invalidnotnulloids != NULL)
9585 "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc\n"
9586 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9587 "JOIN pg_catalog.pg_attrdef a ON (src.tbloid = a.adrelid)\n"
9588 "ORDER BY a.adrelid, a.adnum",
9597 for (
int j = 0;
j < numDefaults;
j++)
9609 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != adrelid)
9611 while (++curtblindx < numTables)
9613 tbinfo = &tblinfo[curtblindx];
9617 if (curtblindx >= numTables)
9618 pg_fatal(
"unrecognized table OID %u", adrelid);
9621 if (adnum <= 0 || adnum > tbinfo->
numatts)
9622 pg_fatal(
"invalid adnum value %d for table \"%s\"",
9637 attrdefs[
j].
adnum = adnum;
9641 attrdefs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9664 else if (tbinfo->
relkind == RELKIND_VIEW)
9682 if (!attrdefs[
j].separate)
9694 tbinfo->
attrdefs[adnum - 1] = &attrdefs[
j];
9715 pg_log_info(
"finding invalid not-null constraints");
9719 "SELECT c.tableoid, c.oid, conrelid, conname, "
9720 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9721 "conislocal, convalidated "
9722 "FROM unnest('%s'::pg_catalog.oid[]) AS src(conoid)\n"
9723 "JOIN pg_catalog.pg_constraint c ON (src.conoid = c.oid)\n"
9724 "ORDER BY c.conrelid, c.conname",
9725 invalidnotnulloids->
data);
9732 i_tableoid =
PQfnumber(res,
"tableoid");
9734 i_conrelid =
PQfnumber(res,
"conrelid");
9737 i_conislocal =
PQfnumber(res,
"conislocal");
9741 for (
int j = 0;
j < numConstrs;)
9748 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9756 while (++curtblindx < numTables)
9758 tbinfo = &tblinfo[curtblindx];
9762 if (curtblindx >= numTables)
9763 pg_fatal(
"unrecognized table OID %u", conrelid);
9765 for (
int c = 0;
c < numcons;
c++,
j++)
9772 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9817 "SELECT c.tableoid, c.oid, conrelid, conname, "
9818 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9819 "conislocal, convalidated "
9820 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9821 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
9822 "WHERE contype = 'c' "
9823 "ORDER BY c.conrelid, c.conname",
9831 i_tableoid =
PQfnumber(res,
"tableoid");
9833 i_conrelid =
PQfnumber(res,
"conrelid");
9836 i_conislocal =
PQfnumber(res,
"conislocal");
9837 i_convalidated =
PQfnumber(res,
"convalidated");
9841 for (
int j = 0;
j < numConstrs;)
9848 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9856 while (++curtblindx < numTables)
9858 tbinfo = &tblinfo[curtblindx];
9862 if (curtblindx >= numTables)
9863 pg_fatal(
"unrecognized table OID %u", conrelid);
9865 if (numcons != tbinfo->
ncheck)
9868 "expected %d check constraints on table \"%s\" but found %d",
9877 for (
int c = 0;
c < numcons;
c++,
j++)
9879 bool validated =
PQgetvalue(res,
j, i_convalidated)[0] ==
't';
9886 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9915 if (!constrs[
j].separate)
9985 int i_notnull_comment,
9986 int i_notnull_invalidoid,
9987 int i_notnull_noinherit,
9988 int i_notnull_islocal,
10004 char *constroid =
PQgetvalue(res, r, i_notnull_invalidoid);
10006 if (*invalidnotnulloids == NULL)
10072 char *default_name;
10077 if (strcmp(default_name,
10085 free(default_name);
10134 int i_prsnamespace;
10149 "prsstart::oid, prstoken::oid, "
10150 "prsend::oid, prsheadline::oid, prslextype::oid "
10151 "FROM pg_ts_parser");
10159 i_tableoid =
PQfnumber(res,
"tableoid");
10162 i_prsnamespace =
PQfnumber(res,
"prsnamespace");
10163 i_prsstart =
PQfnumber(res,
"prsstart");
10164 i_prstoken =
PQfnumber(res,
"prstoken");
10166 i_prsheadline =
PQfnumber(res,
"prsheadline");
10167 i_prslextype =
PQfnumber(res,
"prslextype");
10169 for (
i = 0;
i < ntups;
i++)
10176 prsinfo[
i].
dobj.namespace =
10208 int i_dictnamespace;
10210 int i_dicttemplate;
10211 int i_dictinitoption;
10216 "dictnamespace, dictowner, "
10217 "dicttemplate, dictinitoption "
10218 "FROM pg_ts_dict");
10226 i_tableoid =
PQfnumber(res,
"tableoid");
10228 i_dictname =
PQfnumber(res,
"dictname");
10229 i_dictnamespace =
PQfnumber(res,
"dictnamespace");
10230 i_dictowner =
PQfnumber(res,
"dictowner");
10231 i_dictinitoption =
PQfnumber(res,
"dictinitoption");
10232 i_dicttemplate =
PQfnumber(res,
"dicttemplate");
10234 for (
i = 0;
i < ntups;
i++)
10241 dictinfo[
i].
dobj.namespace =
10274 int i_tmplnamespace;
10281 "tmplnamespace, tmplinit::oid, tmpllexize::oid "
10282 "FROM pg_ts_template");
10290 i_tableoid =
PQfnumber(res,
"tableoid");
10292 i_tmplname =
PQfnumber(res,
"tmplname");
10293 i_tmplnamespace =
PQfnumber(res,
"tmplnamespace");
10294 i_tmplinit =
PQfnumber(res,
"tmplinit");
10295 i_tmpllexize =
PQfnumber(res,
"tmpllexize");
10297 for (
i = 0;
i < ntups;
i++)
10304 tmplinfo[
i].
dobj.namespace =
10333 int i_cfgnamespace;
10340 "cfgnamespace, cfgowner, cfgparser "
10341 "FROM pg_ts_config");
10349 i_tableoid =
PQfnumber(res,
"tableoid");
10352 i_cfgnamespace =
PQfnumber(res,
"cfgnamespace");
10353 i_cfgowner =
PQfnumber(res,
"cfgowner");
10354 i_cfgparser =
PQfnumber(res,
"cfgparser");
10356 for (
i = 0;
i < ntups;
i++)
10363 cfginfo[
i].
dobj.namespace =
10394 int i_fdwvalidator;
10403 "fdwhandler::pg_catalog.regproc, "
10404 "fdwvalidator::pg_catalog.regproc, "
10406 "acldefault('F', fdwowner) AS acldefault, "
10407 "array_to_string(ARRAY("
10408 "SELECT quote_ident(option_name) || ' ' || "
10409 "quote_literal(option_value) "
10410 "FROM pg_options_to_table(fdwoptions) "
10411 "ORDER BY option_name"
10412 "), E',\n ') AS fdwoptions "
10413 "FROM pg_foreign_data_wrapper");
10421 i_tableoid =
PQfnumber(res,
"tableoid");
10424 i_fdwowner =
PQfnumber(res,
"fdwowner");
10425 i_fdwhandler =
PQfnumber(res,
"fdwhandler");
10426 i_fdwvalidator =
PQfnumber(res,
"fdwvalidator");
10428 i_acldefault =
PQfnumber(res,
"acldefault");
10429 i_fdwoptions =
PQfnumber(res,
"fdwoptions");
10431 for (
i = 0;
i < ntups;
i++)
10438 fdwinfo[
i].
dobj.namespace = NULL;
10488 "srvfdw, srvtype, srvversion, srvacl, "
10489 "acldefault('S', srvowner) AS acldefault, "
10490 "array_to_string(ARRAY("
10491 "SELECT quote_ident(option_name) || ' ' || "
10492 "quote_literal(option_value) "
10493 "FROM pg_options_to_table(srvoptions) "
10494 "ORDER BY option_name"
10495 "), E',\n ') AS srvoptions "
10496 "FROM pg_foreign_server");
10504 i_tableoid =
PQfnumber(res,
"tableoid");
10507 i_srvowner =
PQfnumber(res,
"srvowner");
10510 i_srvversion =
PQfnumber(res,
"srvversion");
10512 i_acldefault =
PQfnumber(res,
"acldefault");
10513 i_srvoptions =
PQfnumber(res,
"srvoptions");
10515 for (
i = 0;
i < ntups;
i++)
10522 srvinfo[
i].
dobj.namespace = NULL;
10563 int i_defaclnamespace;
10564 int i_defaclobjtype;
10585 "SELECT oid, tableoid, "
10587 "defaclnamespace, "
10590 "CASE WHEN defaclnamespace = 0 THEN "
10591 "acldefault(CASE WHEN defaclobjtype = 'S' "
10592 "THEN 's'::\"char\" ELSE defaclobjtype END, "
10593 "defaclrole) ELSE '{}' END AS acldefault "
10594 "FROM pg_default_acl");
10603 i_tableoid =
PQfnumber(res,
"tableoid");
10604 i_defaclrole =
PQfnumber(res,
"defaclrole");
10605 i_defaclnamespace =
PQfnumber(res,
"defaclnamespace");
10606 i_defaclobjtype =
PQfnumber(res,
"defaclobjtype");
10607 i_defaclacl =
PQfnumber(res,
"defaclacl");
10608 i_acldefault =
PQfnumber(res,
"acldefault");
10610 for (
i = 0;
i < ntups;
i++)
10624 daclinfo[
i].
dobj.namespace = NULL;
10663 while (low <= high)
10667 if (roleoid < middle->roleoid)
10669 else if (roleoid > middle->
roleoid)
10676 pg_fatal(
"role with OID %u does not exist", roleoid);
10693 query =
"SELECT oid, rolname FROM pg_catalog.pg_roles ORDER BY 1";
10731 "SELECT DISTINCT attrelid FROM pg_attribute "
10732 "WHERE attacl IS NOT NULL");
10737 for (
i = 0;
i < ntups;
i++)
10756 "SELECT objoid, classoid, objsubid, privtype, initprivs "
10757 "FROM pg_init_privs");
10762 for (
i = 0;
i < ntups;
i++)
10773 objId.
oid = objoid;
10785 ((
TableInfo *) dobj)->hascolumnACLs =
true;
10789 classoid, objoid, objsubid);
10798 strcmp(dobj->
name,
"public") == 0)
10818 classoid, objoid, objsubid);
10852 const char *
name,
const char *
namespace,
10853 const char *owner,
CatalogId catalogId,
10854 int subid,
DumpId dumpId,
10855 const char *initdb_comment)
10866 if (strcmp(
type,
"LARGE OBJECT") != 0)
10891 if (initdb_comment != NULL)
10917 if (
namespace && *
namespace)
10932 .namespace =
namespace,
10934 .description =
"COMMENT",
10936 .createStmt = query->
data,
10952 const char *
name,
const char *
namespace,
10953 const char *owner,
CatalogId catalogId,
10954 int subid,
DumpId dumpId)
10957 catalogId, subid, dumpId, NULL);
10968 const char *argtype,
const char *argval)
10993 static bool restarted;
11032 for (; te != AH->
toc && count < max_rels; te = te->
next)
11035 strcmp(te->
desc,
"STATISTICS DATA") == 0)
11088 int i_most_common_vals;
11089 int i_most_common_freqs;
11090 int i_histogram_bounds;
11092 int i_most_common_elems;
11093 int i_most_common_elem_freqs;
11094 int i_elem_count_histogram;
11095 int i_range_length_histogram;
11096 int i_range_empty_frac;
11097 int i_range_bounds_histogram;
11107 expected_te = expected_te->
next;
11109 strcmp(expected_te->
desc,
"STATISTICS DATA") != 0)
11110 expected_te = expected_te->
next;
11112 if (te != expected_te)
11113 pg_fatal(
"statistics dumped out of order (current: %d %s %s, expected: %d %s %s)",
11121 "PREPARE getAttributeStats(pg_catalog.name[], pg_catalog.name[]) AS\n"
11122 "SELECT s.schemaname, s.tablename, s.attname, s.inherited, "
11123 "s.null_frac, s.avg_width, s.n_distinct, "
11124 "s.most_common_vals, s.most_common_freqs, "
11125 "s.histogram_bounds, s.correlation, "
11126 "s.most_common_elems, s.most_common_elem_freqs, "
11127 "s.elem_count_histogram, ");
11131 "s.range_length_histogram, "
11132 "s.range_empty_frac, "
11133 "s.range_bounds_histogram ");
11136 "NULL AS range_length_histogram,"
11137 "NULL AS range_empty_frac,"
11138 "NULL AS range_bounds_histogram ");
11155 "FROM pg_catalog.pg_stats s "
11156 "JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
11157 "ON s.schemaname = u.schemaname "
11158 "AND s.tablename = u.tablename "
11159 "WHERE s.tablename = ANY($2) "
11160 "ORDER BY u.ord, s.attname, s.inherited");
11163 "FROM pg_catalog.pg_stats s "
11164 "WHERE s.schemaname = $1[1] "
11165 "AND s.tablename = $2[1] "
11166 "ORDER BY s.attname, s.inherited");
11217 i_schemaname =
PQfnumber(res,
"schemaname");
11218 i_tablename =
PQfnumber(res,
"tablename");
11220 i_inherited =
PQfnumber(res,
"inherited");
11221 i_null_frac =
PQfnumber(res,
"null_frac");
11222 i_avg_width =
PQfnumber(res,
"avg_width");
11223 i_n_distinct =
PQfnumber(res,
"n_distinct");
11224 i_most_common_vals =
PQfnumber(res,
"most_common_vals");
11225 i_most_common_freqs =
PQfnumber(res,
"most_common_freqs");
11226 i_histogram_bounds =
PQfnumber(res,
"histogram_bounds");
11227 i_correlation =
PQfnumber(res,
"correlation");
11228 i_most_common_elems =
PQfnumber(res,
"most_common_elems");
11229 i_most_common_elem_freqs =
PQfnumber(res,
"most_common_elem_freqs");
11230 i_elem_count_histogram =
PQfnumber(res,
"elem_count_histogram");
11231 i_range_length_histogram =
PQfnumber(res,
"range_length_histogram");
11232 i_range_empty_frac =
PQfnumber(res,
"range_empty_frac");
11233 i_range_bounds_histogram =
PQfnumber(res,
"range_bounds_histogram");
11236 for (; rownum <
PQntuples(res); rownum++)
11241 if (strcmp(te->
tag,
PQgetvalue(res, rownum, i_tablename)) != 0 ||
11242 strcmp(te->namespace,
PQgetvalue(res, rownum, i_schemaname)) != 0)
11254 pg_fatal(
"unexpected null attname");
11269 bool found =
false;
11298 if (!
PQgetisnull(res, rownum, i_most_common_vals))
11300 PQgetvalue(res, rownum, i_most_common_vals));
11301 if (!
PQgetisnull(res, rownum, i_most_common_freqs))
11303 PQgetvalue(res, rownum, i_most_common_freqs));
11304 if (!
PQgetisnull(res, rownum, i_histogram_bounds))
11306 PQgetvalue(res, rownum, i_histogram_bounds));
11310 if (!
PQgetisnull(res, rownum, i_most_common_elems))
11312 PQgetvalue(res, rownum, i_most_common_elems));
11313 if (!
PQgetisnull(res, rownum, i_most_common_elem_freqs))
11315 PQgetvalue(res, rownum, i_most_common_elem_freqs));
11316 if (!
PQgetisnull(res, rownum, i_elem_count_histogram))
11318 PQgetvalue(res, rownum, i_elem_count_histogram));
11321 if (!
PQgetisnull(res, rownum, i_range_length_histogram))
11323 PQgetvalue(res, rownum, i_range_length_histogram));
11324 if (!
PQgetisnull(res, rownum, i_range_empty_frac))
11326 PQgetvalue(res, rownum, i_range_empty_frac));
11327 if (!
PQgetisnull(res, rownum, i_range_bounds_histogram))
11329 PQgetvalue(res, rownum, i_range_bounds_histogram));
11356 .namespace = dobj->namespace->dobj.
name,
11357 .description =
"STATISTICS DATA",
11362 .nDeps = dobj->
nDeps));
11373 const char *reltypename)
11420 .namespace = tbinfo->
dobj.namespace->dobj.
name,
11422 .description =
"COMMENT",
11424 .createStmt = query->
data,
11428 else if (objsubid > 0 && objsubid <= tbinfo->numatts)
11445 .namespace = tbinfo->
dobj.namespace->dobj.
name,
11447 .description =
"COMMENT",
11449 .createStmt = query->
data,
11482 while (low <= high)
11484 middle = low + (high - low) / 2;
11486 if (classoid < middle->classoid)
11488 else if (classoid > middle->
classoid)
11490 else if (objoid < middle->objoid)
11492 else if (objoid > middle->
objoid)
11510 while (middle > low)
11512 if (classoid != middle[-1].classoid ||
11513 objoid != middle[-1].objoid)
11522 while (middle <= high)
11524 if (classoid != middle->
classoid ||
11525 objoid != middle->
objoid)
11562 "FROM pg_catalog.pg_description "
11563 "ORDER BY classoid, objoid, objsubid");
11569 i_description =
PQfnumber(res,
"description");
11570 i_classoid =
PQfnumber(res,
"classoid");
11572 i_objsubid =
PQfnumber(res,
"objsubid");
11580 for (
i = 0;
i < ntups;
i++)
11590 if (dobj == NULL ||
11603 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
11642 if (dobj->
dump == 0)
11768 if (loinfo == NULL)
11769 pg_fatal(
"missing metadata for large objects \"%s\"",
11775 .description =
"BLOBS",
11777 .deps = dobj->dependencies,
11778 .nDeps = dobj->nDeps,
11780 .dumpArg = loinfo));
11853 "-- *not* dropping schema, since initdb creates it\n");
11855 "-- *not* creating schema, since initdb creates it\n");
11860 "SCHEMA", qnspname, NULL);
11866 .description =
"SCHEMA",
11868 .createStmt = q->
data,
11869 .dropStmt = delq->
data));
11874 const char *initdb_comment = NULL;
11876 if (!nspinfo->
create && strcmp(qnspname,
"public") == 0)
11877 initdb_comment =
"standard public schema";
11891 qnspname, NULL, NULL,
11936 qextname,
fmtId(extinfo->namespace));
11951 appendPQExpBufferStr(q,
"-- For binary upgrade, create an empty extension and insert objects into it\n");
11961 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
12006 .description =
"EXTENSION",
12008 .createStmt = q->
data,
12009 .dropStmt = delq->
data));
12042 if (tyinfo->
typtype == TYPTYPE_BASE)
12044 else if (tyinfo->
typtype == TYPTYPE_DOMAIN)
12046 else if (tyinfo->
typtype == TYPTYPE_COMPOSITE)
12048 else if (tyinfo->
typtype == TYPTYPE_ENUM)
12050 else if (tyinfo->
typtype == TYPTYPE_RANGE)
12055 pg_log_warning(
"typtype of data type \"%s\" appears to be invalid",
12084 "PREPARE dumpEnumType(pg_catalog.oid) AS\n"
12085 "SELECT oid, enumlabel "
12086 "FROM pg_catalog.pg_enum "
12087 "WHERE enumtypid = $1 "
12088 "ORDER BY enumsortorder");
12096 "EXECUTE dumpEnumType('%u')",
12122 i_enumlabel =
PQfnumber(res,
"enumlabel");
12125 for (
i = 0;
i < num;
i++)
12140 i_enumlabel =
PQfnumber(res,
"enumlabel");
12143 for (
i = 0;
i < num;
i++)
12151 "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
12162 tyinfo->
dobj.namespace->dobj.
name);
12167 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12169 .description =
"TYPE",
12171 .createStmt = q->
data,
12172 .dropStmt = delq->
data));
12188 tyinfo->
dobj.namespace->dobj.
name,
12220 "PREPARE dumpRangeType(pg_catalog.oid) AS\n");
12227 "pg_catalog.format_type(rngmultitypid, NULL) AS rngmultitype, ");
12230 "NULL AS rngmultitype, ");
12233 "pg_catalog.format_type(rngsubtype, NULL) AS rngsubtype, "
12234 "opc.opcname AS opcname, "
12235 "(SELECT nspname FROM pg_catalog.pg_namespace nsp "
12236 " WHERE nsp.oid = opc.opcnamespace) AS opcnsp, "
12238 "CASE WHEN rngcollation = st.typcollation THEN 0 "
12239 " ELSE rngcollation END AS collation, "
12240 "rngcanonical, rngsubdiff "
12241 "FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
12242 " pg_catalog.pg_opclass opc "
12243 "WHERE st.oid = rngsubtype AND opc.oid = rngsubopc AND "
12252 "EXECUTE dumpRangeType('%u')",
12303 if (strcmp(procname,
"-") != 0)
12307 if (strcmp(procname,
"-") != 0)
12315 tyinfo->
dobj.namespace->dobj.
name);
12320 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12322 .description =
"TYPE",
12324 .createStmt = q->
data,
12325 .dropStmt = delq->
data));
12341 tyinfo->
dobj.namespace->dobj.
name,
12386 tyinfo->
dobj.namespace->dobj.
name);
12391 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12393 .description =
"TYPE",
12395 .createStmt = q->
data,
12396 .dropStmt = delq->
data));
12412 tyinfo->
dobj.namespace->dobj.
name,
12443 char *typsubscript;
12449 Oid typsubscriptoid;
12451 char *typispreferred;
12456 char *typcollatable;
12458 bool typdefault_is_literal =
false;
12464 "PREPARE dumpBaseType(pg_catalog.oid) AS\n"
12466 "typinput, typoutput, typreceive, typsend, "
12467 "typreceive::pg_catalog.oid AS typreceiveoid, "
12468 "typsend::pg_catalog.oid AS typsendoid, "
12470 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
12471 "typdelim, typbyval, typalign, typstorage, "
12472 "typmodin, typmodout, "
12473 "typmodin::pg_catalog.oid AS typmodinoid, "
12474 "typmodout::pg_catalog.oid AS typmodoutoid, "
12475 "typcategory, typispreferred, "
12476 "(typcollation <> 0) AS typcollatable, "
12477 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault, ");
12482 "typsubscript::pg_catalog.oid AS typsubscriptoid ");
12485 "'-' AS typsubscript, 0 AS typsubscriptoid ");
12496 "EXECUTE dumpBaseType('%u')",
12528 typdefault_is_literal =
true;
12553 "CREATE TYPE %s (\n"
12554 " INTERNALLENGTH = %s",
12556 (strcmp(typlen,
"-1") == 0) ?
"variable" : typlen);
12572 if (strcmp(typcollatable,
"t") == 0)
12575 if (typdefault != NULL)
12578 if (typdefault_is_literal)
12592 if (strcmp(typcategory,
"U") != 0)
12598 if (strcmp(typispreferred,
"t") == 0)
12601 if (typdelim && strcmp(typdelim,
",") != 0)
12609 else if (*
typalign == TYPALIGN_SHORT)
12611 else if (*
typalign == TYPALIGN_INT)
12613 else if (*
typalign == TYPALIGN_DOUBLE)
12616 if (*typstorage == TYPSTORAGE_PLAIN)
12618 else if (*typstorage == TYPSTORAGE_EXTERNAL)
12620 else if (*typstorage == TYPSTORAGE_EXTENDED)
12622 else if (*typstorage == TYPSTORAGE_MAIN)
12625 if (strcmp(typbyval,
"t") == 0)
12633 tyinfo->
dobj.namespace->dobj.
name);
12638 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12640 .description =
"TYPE",
12642 .createStmt = q->
data,
12643 .dropStmt = delq->
data));
12659 tyinfo->
dobj.namespace->dobj.
name,
12689 bool typdefault_is_literal =
false;
12695 "PREPARE dumpDomain(pg_catalog.oid) AS\n");
12698 "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
12699 "pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
12701 "CASE WHEN t.typcollation <> u.typcollation "
12702 "THEN t.typcollation ELSE 0 END AS typcollation "
12703 "FROM pg_catalog.pg_type t "
12704 "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
12705 "WHERE t.oid = $1");
12713 "EXECUTE dumpDomain('%u')",
12725 typdefault_is_literal =
true;
12741 "CREATE DOMAIN %s AS %s",
12761 if (typnotnull[0] ==
't')
12771 char *default_name;
12776 if (strcmp(default_name, notnull->
dobj.
name) == 0)
12781 free(default_name);
12786 if (typdefault != NULL)
12789 if (typdefault_is_literal)
12815 "DOMAIN", qtypname,
12816 tyinfo->
dobj.namespace->dobj.
name);
12821 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12823 .description =
"DOMAIN",
12825 .createStmt = q->
data,
12826 .dropStmt = delq->
data));
12842 tyinfo->
dobj.namespace->dobj.
name,
12861 tyinfo->
dobj.namespace->dobj.
name,
12881 tyinfo->
dobj.namespace->dobj.
name,
12915 int i_attisdropped;
12916 int i_attcollation;
12931 "PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
12932 "SELECT a.attname, a.attnum, "
12933 "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
12934 "a.attlen, a.attalign, a.attisdropped, "
12935 "CASE WHEN a.attcollation <> at.typcollation "
12936 "THEN a.attcollation ELSE 0 END AS attcollation "
12937 "FROM pg_catalog.pg_type ct "
12938 "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
12939 "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
12940 "WHERE ct.oid = $1 "
12941 "ORDER BY a.attnum");
12949 "EXECUTE dumpCompositeType('%u')",
12957 i_atttypdefn =
PQfnumber(res,
"atttypdefn");
12959 i_attalign =
PQfnumber(res,
"attalign");
12960 i_attisdropped =
PQfnumber(res,
"attisdropped");
12961 i_attcollation =
PQfnumber(res,
"attcollation");
12978 for (
i = 0;
i < ntups;
i++)
12991 attisdropped = (
PQgetvalue(res,
i, i_attisdropped)[0] ==
't');
12998 if (actual_atts++ > 0)
13029 "\n-- For binary upgrade, recreate dropped column.\n");
13031 "SET attlen = %s, "
13032 "attalign = '%s', attbyval = false\n"
13053 tyinfo->
dobj.namespace->dobj.
name);
13058 .namespace = tyinfo->
dobj.namespace->dobj.
name,
13060 .description =
"TYPE",
13062 .createStmt = q->
data,
13063 .dropStmt = delq->
data));
13080 tyinfo->
dobj.namespace->dobj.
name,
13117 int i_attisdropped;
13138 i_attisdropped =
PQfnumber(res,
"attisdropped");
13144 for (
i = 0;
i < ntups;
i++)
13171 .namespace = tyinfo->
dobj.namespace->dobj.
name,
13173 .description =
"COMMENT",
13175 .createStmt = query->
data,
13226 .namespace = stinfo->
dobj.namespace->dobj.
name,
13228 .description =
"SHELL TYPE",
13230 .createStmt = q->
data));
13265 if (funcInfo != NULL && !funcInfo->
dobj.
dump)
13271 if (inlineInfo != NULL && !inlineInfo->
dobj.
dump)
13278 if (validatorInfo != NULL && !validatorInfo->
dobj.
dump)
13279 validatorInfo = NULL;
13287 useParams = (funcInfo != NULL &&
13331 "LANGUAGE", qlanname, NULL);
13337 .description =
"PROCEDURAL LANGUAGE",
13339 .createStmt = defqry->
data,
13340 .dropStmt = delqry->
data,
13356 qlanname, NULL, NULL,
13379 if (is_agg && finfo->
nargs == 0)
13406 for (
j = 0;
j < finfo->
nargs;
j++)
13434 char *funcfullsig = NULL;
13436 char *qual_funcsig;
13449 char *proleakproof;
13456 char **configitems = NULL;
13457 int nconfigitems = 0;
13458 const char *keyword;
13473 "PREPARE dumpFunc(pg_catalog.oid) AS\n");
13487 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
13488 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
13489 "pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
13490 "proleakproof,\n");
13494 "array_to_string(protrftypes, ' ') AS protrftypes,\n");
13497 "NULL AS protrftypes,\n");
13504 "'u' AS proparallel,\n");
13511 "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n");
13518 "'-' AS prosupport,\n");
13522 "pg_get_function_sqlbody(p.oid) AS prosqlbody\n");
13525 "NULL AS prosqlbody\n");
13528 "FROM pg_catalog.pg_proc p, pg_catalog.pg_language l\n"
13529 "WHERE p.oid = $1 "
13530 "AND l.oid = p.prolang");
13538 "EXECUTE dumpFunc('%u')",
13580 else if (probin[0] !=
'\0')
13584 if (prosrc[0] !=
'\0')
13593 (strchr(prosrc,
'\'') == NULL && strchr(prosrc,
'\\') == NULL))
13611 if (!
parsePGArray(proconfig, &configitems, &nconfigitems))
13612 pg_fatal(
"could not parse %s array",
"proconfig");
13616 configitems = NULL;
13629 if (prokind[0] == PROKIND_PROCEDURE)
13630 keyword =
"PROCEDURE";
13632 keyword =
"FUNCTION";
13635 keyword, qual_funcsig);
13640 funcfullsig ? funcfullsig :
13643 if (prokind[0] == PROKIND_PROCEDURE)
13645 else if (funcresult)
13649 (proretset[0] ==
't') ?
"SETOF " :
"",
13662 for (
i = 0; typeids[
i];
i++)
13673 if (prokind[0] == PROKIND_WINDOW)
13676 if (provolatile[0] != PROVOLATILE_VOLATILE)
13678 if (provolatile[0] == PROVOLATILE_IMMUTABLE)
13680 else if (provolatile[0] == PROVOLATILE_STABLE)
13682 else if (provolatile[0] != PROVOLATILE_VOLATILE)
13683 pg_fatal(
"unrecognized provolatile value for function \"%s\"",
13687 if (proisstrict[0] ==
't')
13690 if (prosecdef[0] ==
't')
13693 if (proleakproof[0] ==
't')
13701 if (strcmp(procost,
"0") != 0)
13703 if (strcmp(lanname,
"internal") == 0 || strcmp(lanname,
"c") == 0)
13706 if (strcmp(procost,
"1") != 0)
13712 if (strcmp(procost,
"100") != 0)
13716 if (proretset[0] ==
't' &&
13717 strcmp(prorows,
"0") != 0 && strcmp(prorows,
"1000") != 0)
13720 if (strcmp(prosupport,
"-") != 0)
13726 if (proparallel[0] != PROPARALLEL_UNSAFE)
13728 if (proparallel[0] == PROPARALLEL_SAFE)
13730 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
13732 else if (proparallel[0] != PROPARALLEL_UNSAFE)
13733 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
13737 for (
int i = 0;
i < nconfigitems;
i++)
13740 char *configitem = configitems[
i];
13743 pos = strchr(configitem,
'=');
13773 for (nameptr = namelist; *nameptr; nameptr++)
13775 if (nameptr != namelist)
13789 "pg_catalog.pg_proc", keyword,
13795 finfo->
dobj.namespace->dobj.
name);
13800 .
namespace = finfo->
dobj.namespace->dobj.
name,
13802 .description = keyword,
13805 .createStmt = q->
data,
13806 .dropStmt = delqry->
data));
13834 free(qual_funcsig);
13851 const char *sourceType;
13852 const char *targetType;
13862 if (funcInfo == NULL)
13863 pg_fatal(
"could not find function definition for function with OID %u",
13875 sourceType, targetType);
13878 sourceType, targetType);
13882 case COERCION_METHOD_BINARY:
13885 case COERCION_METHOD_INOUT:
13888 case COERCION_METHOD_FUNCTION:
13902 pg_log_warning(
"bogus value in pg_cast.castfunc or pg_cast.castmethod field");
13915 sourceType, targetType);
13918 sourceType, targetType);
13922 "CAST", castargs->
data, NULL);
13927 .description =
"CAST",
13929 .createStmt = defqry->
data,
13930 .dropStmt = delqry->
data));
13958 const char *transformType;
13968 if (fromsqlFuncInfo == NULL)
13969 pg_fatal(
"could not find function definition for function with OID %u",
13975 if (tosqlFuncInfo == NULL)
13976 pg_fatal(
"could not find function definition for function with OID %u",
13989 transformType, lanname);
13992 transformType, lanname);
13995 pg_log_warning(
"bogus transform definition, at least one of trffromsql and trftosql should be nonzero");
13999 if (fromsqlFuncInfo)
14039 transformType, lanname);
14042 transformType, lanname);
14046 "TRANSFORM", transformargs->
data, NULL);
14051 .description =
"TRANSFORM",
14053 .createStmt = defqry->
data,
14054 .dropStmt = delqry->
data,
14130 "PREPARE dumpOpr(pg_catalog.oid) AS\n"
14132 "oprcode::pg_catalog.regprocedure, "
14133 "oprleft::pg_catalog.regtype, "
14134 "oprright::pg_catalog.regtype, "
14137 "oprrest::pg_catalog.regprocedure, "
14138 "oprjoin::pg_catalog.regprocedure, "
14139 "oprcanmerge, oprcanhash "
14140 "FROM pg_catalog.pg_operator "
14149 "EXECUTE dumpOpr('%u')",
14157 i_oprright =
PQfnumber(res,
"oprright");
14159 i_oprnegate =
PQfnumber(res,
"oprnegate");
14162 i_oprcanmerge =
PQfnumber(res,
"oprcanmerge");
14163 i_oprcanhash =
PQfnumber(res,
"oprcanhash");
14170 oprnegate =
PQgetvalue(res, 0, i_oprnegate);
14173 oprcanmerge =
PQgetvalue(res, 0, i_oprcanmerge);
14174 oprcanhash =
PQgetvalue(res, 0, i_oprcanhash);
14177 if (strcmp(oprkind,
"r") == 0)
14178 pg_log_warning(
"postfix operators are not supported anymore (operator \"%s\")",
14196 if (strcmp(oprkind,
"r") == 0 ||
14197 strcmp(oprkind,
"b") == 0)
14205 if (strcmp(oprkind,
"l") == 0 ||
14206 strcmp(oprkind,
"b") == 0)
14228 if (strcmp(oprcanmerge,
"t") == 0)
14231 if (strcmp(oprcanhash,
"t") == 0)
14258 "OPERATOR",
oprid->data,
14259 oprinfo->
dobj.namespace->dobj.
name);
14264 .namespace = oprinfo->
dobj.namespace->dobj.
name,
14266 .description =
"OPERATOR",
14268 .createStmt = q->
data,
14269 .dropStmt = delq->
data));
14303 if (strcmp(proc,
"-") == 0)
14309 for (paren =
name; *paren; paren++)
14311 if (*paren ==
'(' && !inquote)
14317 inquote = !inquote;
14342 if (strcmp(oproid,
"0") == 0)
14346 if (oprInfo == NULL)
14353 return psprintf(
"OPERATOR(%s.%s)",
14374 "SELECT '%u'::pg_catalog.regproc", funcOid);
14417 aminfo->
amtype, qamname);
14431 "ACCESS METHOD", qamname, NULL);
14436 .description =
"ACCESS METHOD",
14438 .createStmt = q->
data,
14439 .dropStmt = delq->
data));
14470 int i_opcfamilyname;
14471 int i_opcfamilynsp;
14473 int i_amopstrategy;
14476 int i_sortfamilynsp;
14479 int i_amproclefttype;
14480 int i_amprocrighttype;
14485 char *opcfamilyname;
14486 char *opcfamilynsp;
14488 char *amopstrategy;
14491 char *sortfamilynsp;
14494 char *amproclefttype;
14495 char *amprocrighttype;
14510 "opckeytype::pg_catalog.regtype, "
14511 "opcdefault, opcfamily, "
14512 "opfname AS opcfamilyname, "
14513 "nspname AS opcfamilynsp, "
14514 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS amname "
14515 "FROM pg_catalog.pg_opclass c "
14516 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily "
14517 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14518 "WHERE c.oid = '%u'::pg_catalog.oid",
14523 i_opcintype =
PQfnumber(res,
"opcintype");
14524 i_opckeytype =
PQfnumber(res,
"opckeytype");
14525 i_opcdefault =
PQfnumber(res,
"opcdefault");
14526 i_opcfamily =
PQfnumber(res,
"opcfamily");
14527 i_opcfamilyname =
PQfnumber(res,
"opcfamilyname");
14528 i_opcfamilynsp =
PQfnumber(res,
"opcfamilynsp");
14533 opckeytype =
PQgetvalue(res, 0, i_opckeytype);
14534 opcdefault =
PQgetvalue(res, 0, i_opcdefault);
14537 opcfamilyname =
PQgetvalue(res, 0, i_opcfamilyname);
14538 opcfamilynsp =
PQgetvalue(res, 0, i_opcfamilynsp);
14550 if (strcmp(opcdefault,
"t") == 0)
14555 if (strlen(opcfamilyname) > 0)
14565 if (strcmp(opckeytype,
"-") != 0)
14582 "amopopr::pg_catalog.regoperator, "
14583 "opfname AS sortfamily, "
14584 "nspname AS sortfamilynsp "
14585 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14586 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14587 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14588 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14589 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14590 "AND refobjid = '%u'::pg_catalog.oid "
14591 "AND amopfamily = '%s'::pg_catalog.oid "
14592 "ORDER BY amopstrategy",
14600 i_amopstrategy =
PQfnumber(res,
"amopstrategy");
14602 i_sortfamily =
PQfnumber(res,
"sortfamily");
14603 i_sortfamilynsp =
PQfnumber(res,
"sortfamilynsp");
14605 for (
i = 0;
i < ntups;
i++)
14607 amopstrategy =
PQgetvalue(res,
i, i_amopstrategy);
14610 sortfamilynsp =
PQgetvalue(res,
i, i_sortfamilynsp);
14616 amopstrategy, amopopr);
14618 if (strlen(sortfamily) > 0)
14643 "amproc::pg_catalog.regprocedure, "
14644 "amproclefttype::pg_catalog.regtype, "
14645 "amprocrighttype::pg_catalog.regtype "
14646 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14647 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14648 "AND refobjid = '%u'::pg_catalog.oid "
14649 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14650 "AND objid = ap.oid "
14651 "ORDER BY amprocnum",
14658 i_amprocnum =
PQfnumber(res,
"amprocnum");
14660 i_amproclefttype =
PQfnumber(res,
"amproclefttype");
14661 i_amprocrighttype =
PQfnumber(res,
"amprocrighttype");
14663 for (
i = 0;
i < ntups;
i++)
14667 amproclefttype =
PQgetvalue(res,
i, i_amproclefttype);
14668 amprocrighttype =
PQgetvalue(res,
i, i_amprocrighttype);
14675 if (*amproclefttype && *amprocrighttype)
14702 "OPERATOR CLASS", nameusing->
data,
14703 opcinfo->
dobj.namespace->dobj.
name);
14708 .namespace = opcinfo->
dobj.namespace->dobj.
name,
14710 .description =
"OPERATOR CLASS",
14712 .createStmt = q->
data,
14713 .dropStmt = delq->
data));
14750 int i_amopstrategy;
14753 int i_sortfamilynsp;
14756 int i_amproclefttype;
14757 int i_amprocrighttype;
14759 char *amopstrategy;
14762 char *sortfamilynsp;
14765 char *amproclefttype;
14766 char *amprocrighttype;
14784 "amopopr::pg_catalog.regoperator, "
14785 "opfname AS sortfamily, "
14786 "nspname AS sortfamilynsp "
14787 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14788 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14789 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14790 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14791 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14792 "AND refobjid = '%u'::pg_catalog.oid "
14793 "AND amopfamily = '%u'::pg_catalog.oid "
14794 "ORDER BY amopstrategy",
14803 "amproc::pg_catalog.regprocedure, "
14804 "amproclefttype::pg_catalog.regtype, "
14805 "amprocrighttype::pg_catalog.regtype "
14806 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14807 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14808 "AND refobjid = '%u'::pg_catalog.oid "
14809 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14810 "AND objid = ap.oid "
14811 "ORDER BY amprocnum",
14820 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opfmethod) AS amname "
14821 "FROM pg_catalog.pg_opfamily "
14822 "WHERE oid = '%u'::pg_catalog.oid",
14860 i_amopstrategy =
PQfnumber(res_ops,
"amopstrategy");
14861 i_amopopr =
PQfnumber(res_ops,
"amopopr");
14862 i_sortfamily =
PQfnumber(res_ops,
"sortfamily");
14863 i_sortfamilynsp =
PQfnumber(res_ops,
"sortfamilynsp");
14865 for (
i = 0;
i < ntups;
i++)
14867 amopstrategy =
PQgetvalue(res_ops,
i, i_amopstrategy);
14869 sortfamily =
PQgetvalue(res_ops,
i, i_sortfamily);
14870 sortfamilynsp =
PQgetvalue(res_ops,
i, i_sortfamilynsp);
14876 amopstrategy, amopopr);
14878 if (strlen(sortfamily) > 0)
14893 i_amprocnum =
PQfnumber(res_procs,
"amprocnum");
14894 i_amproc =
PQfnumber(res_procs,
"amproc");
14895 i_amproclefttype =
PQfnumber(res_procs,
"amproclefttype");
14896 i_amprocrighttype =
PQfnumber(res_procs,
"amprocrighttype");
14898 for (
i = 0;
i < ntups;
i++)
14900 amprocnum =
PQgetvalue(res_procs,
i, i_amprocnum);
14902 amproclefttype =
PQgetvalue(res_procs,
i, i_amproclefttype);
14903 amprocrighttype =
PQgetvalue(res_procs,
i, i_amprocrighttype);
14909 amprocnum, amproclefttype, amprocrighttype,
14924 "OPERATOR FAMILY", nameusing->
data,
14925 opfinfo->
dobj.namespace->dobj.
name);
14930 .namespace = opfinfo->
dobj.namespace->dobj.
name,
14932 .description =
"OPERATOR FAMILY",
14934 .createStmt = q->
data,
14935 .dropStmt = delq->
data));
14965 int i_collprovider;
14966 int i_collisdeterministic;
14970 int i_collicurules;
14971 const char *collprovider;
14972 const char *collcollate;
14973 const char *collctype;
14974 const char *colllocale;
14975 const char *collicurules;
14996 "'c' AS collprovider, "
14997 "NULL AS collversion, ");
15001 "collisdeterministic, ");
15004 "true AS collisdeterministic, ");
15011 "colliculocale AS colllocale, ");
15014 "NULL AS colllocale, ");
15021 "NULL AS collicurules, ");
15026 "FROM pg_catalog.pg_collation c "
15027 "WHERE c.oid = '%u'::pg_catalog.oid",
15032 i_collprovider =
PQfnumber(res,
"collprovider");
15033 i_collisdeterministic =
PQfnumber(res,
"collisdeterministic");
15034 i_collcollate =
PQfnumber(res,
"collcollate");
15035 i_collctype =
PQfnumber(res,
"collctype");
15036 i_colllocale =
PQfnumber(res,
"colllocale");
15037 i_collicurules =
PQfnumber(res,
"collicurules");
15039 collprovider =
PQgetvalue(res, 0, i_collprovider);
15042 collcollate =
PQgetvalue(res, 0, i_collcollate);
15044 collcollate = NULL;
15047 collctype =
PQgetvalue(res, 0, i_collctype);
15057 if (collcollate[0] ==
'\0')
15058 collcollate = NULL;
15059 if (collctype[0] ==
'\0')
15064 colllocale =
PQgetvalue(res, 0, i_colllocale);
15069 collicurules =
PQgetvalue(res, 0, i_collicurules);
15071 collicurules = NULL;
15080 if (collprovider[0] ==
'b')
15082 else if (collprovider[0] ==
'c')
15084 else if (collprovider[0] ==
'i')
15086 else if (collprovider[0] ==
'd')
15090 pg_fatal(
"unrecognized collation provider: %s",
15093 if (strcmp(
PQgetvalue(res, 0, i_collisdeterministic),
"f") == 0)
15096 if (collprovider[0] ==
'd')
15098 if (collcollate || collctype || colllocale || collicurules)
15103 else if (collprovider[0] ==
'b')
15105 if (collcollate || collctype || !colllocale || collicurules)
15112 else if (collprovider[0] ==
'i')
15116 if (collcollate || collctype || !colllocale)
15125 if (!collcollate || !collctype || colllocale ||
15126 strcmp(collcollate, collctype) != 0)
15139 else if (collprovider[0] ==
'c')
15141 if (colllocale || collicurules || !collcollate || !collctype)
15144 if (collcollate && collctype && strcmp(collcollate, collctype) == 0)
15158 pg_fatal(
"unrecognized collation provider: %s", collprovider);
15168 i_collversion =
PQfnumber(res,
"collversion");
15182 "COLLATION", qcollname,
15183 collinfo->
dobj.namespace->dobj.
name);
15188 .namespace = collinfo->
dobj.namespace->dobj.
name,
15190 .description =
"COLLATION",
15192 .createStmt = q->
data,
15193 .dropStmt = delq->
data));
15222 int i_conforencoding;
15223 int i_contoencoding;
15226 const char *conforencoding;
15227 const char *contoencoding;
15228 const char *conproc;
15243 "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
15244 "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
15245 "conproc, condefault "
15246 "FROM pg_catalog.pg_conversion c "
15247 "WHERE c.oid = '%u'::pg_catalog.oid",
15252 i_conforencoding =
PQfnumber(res,
"conforencoding");
15253 i_contoencoding =
PQfnumber(res,
"contoencoding");
15255 i_condefault =
PQfnumber(res,
"condefault");
15257 conforencoding =
PQgetvalue(res, 0, i_conforencoding);
15258 contoencoding =
PQgetvalue(res, 0, i_contoencoding);
15260 condefault = (
PQgetvalue(res, 0, i_condefault)[0] ==
't');
15266 (condefault) ?
"DEFAULT " :
"",
15276 "CONVERSION", qconvname,
15277 convinfo->
dobj.namespace->dobj.
name);
15282 .namespace = convinfo->
dobj.namespace->dobj.
name,
15284 .description =
"CONVERSION",
15286 .createStmt = q->
data,
15287 .dropStmt = delq->
data));
15321 if (agginfo->aggfn.nargs == 0)
15326 for (
j = 0;
j < agginfo->aggfn.nargs;
j++)
15328 (
j > 0) ?
", " :
"",
15330 agginfo->aggfn.argtypes[
j],
15350 char *aggfullsig = NULL;
15355 const char *aggtransfn;
15356 const char *aggfinalfn;
15357 const char *aggcombinefn;
15358 const char *aggserialfn;
15359 const char *aggdeserialfn;
15360 const char *aggmtransfn;
15361 const char *aggminvtransfn;
15362 const char *aggmfinalfn;
15363 bool aggfinalextra;
15364 bool aggmfinalextra;
15365 char aggfinalmodify;
15366 char aggmfinalmodify;
15367 const char *aggsortop;
15368 char *aggsortconvop;
15370 const char *aggtranstype;
15371 const char *aggtransspace;
15372 const char *aggmtranstype;
15373 const char *aggmtransspace;
15374 const char *agginitval;
15375 const char *aggminitval;
15376 const char *proparallel;
15377 char defaultfinalmodify;
15392 "PREPARE dumpAgg(pg_catalog.oid) AS\n");
15398 "aggtranstype::pg_catalog.regtype,\n"
15401 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
15402 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
15408 "aggminvtransfn,\n"
15410 "aggmtranstype::pg_catalog.regtype,\n"
15412 "aggmfinalextra,\n"
15414 "aggmtransspace,\n"
15418 "'n' AS aggkind,\n"
15419 "'-' AS aggmtransfn,\n"
15420 "'-' AS aggminvtransfn,\n"
15421 "'-' AS aggmfinalfn,\n"
15422 "0 AS aggmtranstype,\n"
15423 "false AS aggfinalextra,\n"
15424 "false AS aggmfinalextra,\n"
15425 "0 AS aggtransspace,\n"
15426 "0 AS aggmtransspace,\n"
15427 "NULL AS aggminitval,\n");
15437 "'-' AS aggcombinefn,\n"
15438 "'-' AS aggserialfn,\n"
15439 "'-' AS aggdeserialfn,\n"
15440 "'u' AS proparallel,\n");
15444 "aggfinalmodify,\n"
15445 "aggmfinalmodify\n");
15448 "'0' AS aggfinalmodify,\n"
15449 "'0' AS aggmfinalmodify\n");
15452 "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
15453 "WHERE a.aggfnoid = p.oid "
15462 "EXECUTE dumpAgg('%u')",
15463 agginfo->aggfn.dobj.catId.oid);
15467 i_agginitval =
PQfnumber(res,
"agginitval");
15468 i_aggminitval =
PQfnumber(res,
"aggminitval");
15488 agginitval =
PQgetvalue(res, 0, i_agginitval);
15489 aggminitval =
PQgetvalue(res, 0, i_aggminitval);
15505 defaultfinalmodify = (aggkind == AGGKIND_NORMAL) ? AGGMODIFY_READ_ONLY : AGGMODIFY_READ_WRITE;
15507 if (aggfinalmodify ==
'0')
15508 aggfinalmodify = defaultfinalmodify;
15509 if (aggmfinalmodify ==
'0')
15510 aggmfinalmodify = defaultfinalmodify;
15514 aggtransfn, aggtranstype);
15516 if (strcmp(aggtransspace,
"0") != 0)
15528 if (strcmp(aggfinalfn,
"-") != 0)
15534 if (aggfinalmodify != defaultfinalmodify)
15536 switch (aggfinalmodify)
15538 case AGGMODIFY_READ_ONLY:
15541 case AGGMODIFY_SHAREABLE:
15544 case AGGMODIFY_READ_WRITE:
15548 pg_fatal(
"unrecognized aggfinalmodify value for aggregate \"%s\"",
15549 agginfo->aggfn.dobj.name);
15555 if (strcmp(aggcombinefn,
"-") != 0)
15558 if (strcmp(aggserialfn,
"-") != 0)
15561 if (strcmp(aggdeserialfn,
"-") != 0)
15564 if (strcmp(aggmtransfn,
"-") != 0)
15572 if (strcmp(aggmtransspace,
"0") != 0)
15584 if (strcmp(aggmfinalfn,
"-") != 0)
15588 if (aggmfinalextra)
15590 if (aggmfinalmodify != defaultfinalmodify)
15592 switch (aggmfinalmodify)
15594 case AGGMODIFY_READ_ONLY:
15597 case AGGMODIFY_SHAREABLE:
15600 case AGGMODIFY_READ_WRITE:
15604 pg_fatal(
"unrecognized aggmfinalmodify value for aggregate \"%s\"",
15605 agginfo->aggfn.dobj.name);
15616 free(aggsortconvop);
15619 if (aggkind == AGGKIND_HYPOTHETICAL)
15622 if (proparallel[0] != PROPARALLEL_UNSAFE)
15624 if (proparallel[0] == PROPARALLEL_SAFE)
15626 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
15628 else if (proparallel[0] != PROPARALLEL_UNSAFE)
15629 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
15630 agginfo->aggfn.dobj.name);
15634 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
15638 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
15639 aggfullsig ? aggfullsig : aggsig, details->
data);
15643 "AGGREGATE", aggsig,
15644 agginfo->aggfn.dobj.namespace->dobj.name);
15648 agginfo->aggfn.dobj.dumpId,
15650 .
namespace = agginfo->aggfn.dobj.namespace->dobj.name,
15651 .owner = agginfo->aggfn.rolname,
15652 .description =
"AGGREGATE",
15654 .createStmt = q->
data,
15655 .dropStmt = delq->
data));
15660 agginfo->aggfn.dobj.namespace->dobj.name,
15661 agginfo->aggfn.rolname,
15662 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
15666 agginfo->aggfn.dobj.namespace->dobj.name,
15667 agginfo->aggfn.rolname,
15668 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
15681 "FUNCTION", aggsig, NULL,
15682 agginfo->aggfn.dobj.namespace->dobj.name,
15683 NULL, agginfo->aggfn.rolname, &agginfo->aggfn.dacl);
15738 "TEXT SEARCH PARSER", qprsname,
15739 prsinfo->
dobj.namespace->dobj.
name);
15744 .namespace = prsinfo->
dobj.namespace->dobj.
name,
15745 .description =
"TEXT SEARCH PARSER",
15747 .createStmt = q->
data,
15748 .dropStmt = delq->
data));
15752 dumpComment(fout,
"TEXT SEARCH PARSER", qprsname,
15753 prsinfo->
dobj.namespace->dobj.
name,
"",
15789 "FROM pg_ts_template p, pg_namespace n "
15790 "WHERE p.oid = '%u' AND n.oid = tmplnamespace",
15816 "TEXT SEARCH DICTIONARY", qdictname,
15817 dictinfo->
dobj.namespace->dobj.
name);
15822 .namespace = dictinfo->
dobj.namespace->dobj.
name,
15824 .description =
"TEXT SEARCH DICTIONARY",
15826 .createStmt = q->
data,
15827 .dropStmt = delq->
data));
15831 dumpComment(fout,
"TEXT SEARCH DICTIONARY", qdictname,
15876 "TEXT SEARCH TEMPLATE", qtmplname,
15877 tmplinfo->
dobj.namespace->dobj.
name);
15882 .namespace = tmplinfo->
dobj.namespace->dobj.
name,
15883 .description =
"TEXT SEARCH TEMPLATE",
15885 .createStmt = q->
data,
15886 .dropStmt = delq->
data));
15890 dumpComment(fout,
"TEXT SEARCH TEMPLATE", qtmplname,
15891 tmplinfo->
dobj.namespace->dobj.
name,
"",
15931 "FROM pg_ts_parser p, pg_namespace n "
15932 "WHERE p.oid = '%u' AND n.oid = prsnamespace",
15949 " ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
15950 " WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
15951 " m.mapdict::pg_catalog.regdictionary AS dictname\n"
15952 "FROM pg_catalog.pg_ts_config_map AS m\n"
15953 "WHERE m.mapcfg = '%u'\n"
15954 "ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
15960 i_tokenname =
PQfnumber(res,
"tokenname");
15961 i_dictname =
PQfnumber(res,
"dictname");
15963 for (
i = 0;
i < ntups;
i++)
15965 char *tokenname =
PQgetvalue(res,
i, i_tokenname);
15969 strcmp(tokenname,
PQgetvalue(res,
i - 1, i_tokenname)) != 0)
15978 fmtId(tokenname), dictname);
15994 "TEXT SEARCH CONFIGURATION", qcfgname,
15995 cfginfo->
dobj.namespace->dobj.
name);
16000 .namespace = cfginfo->
dobj.namespace->dobj.
name,
16002 .description =
"TEXT SEARCH CONFIGURATION",
16004 .createStmt = q->
data,
16005 .dropStmt = delq->
data));
16009 dumpComment(fout,
"TEXT SEARCH CONFIGURATION", qcfgname,
16059 "FOREIGN DATA WRAPPER", qfdwname,
16066 .description =
"FOREIGN DATA WRAPPER",
16068 .createStmt = q->
data,
16069 .dropStmt = delq->
data));
16073 dumpComment(fout,
"FOREIGN DATA WRAPPER", qfdwname,
16080 "FOREIGN DATA WRAPPER", qfdwname, NULL, NULL,
16116 "FROM pg_foreign_data_wrapper w "
16117 "WHERE w.oid = '%u'",
16147 "SERVER", qsrvname, NULL);
16153 .description =
"SERVER",
16155 .createStmt = q->
data,
16156 .dropStmt = delq->
data));
16167 "FOREIGN SERVER", qsrvname, NULL, NULL,
16195 const char *servername,
const char *
namespace,
16224 "array_to_string(ARRAY("
16225 "SELECT quote_ident(option_name) || ' ' || "
16226 "quote_literal(option_value) "
16227 "FROM pg_options_to_table(umoptions) "
16228 "ORDER BY option_name"
16229 "), E',\n ') AS umoptions "
16230 "FROM pg_user_mappings "
16231 "WHERE srvid = '%u' "
16232 "ORDER BY usename",
16239 i_umoptions =
PQfnumber(res,
"umoptions");
16241 for (
i = 0;
i < ntups;
i++)
16253 if (umoptions && strlen(umoptions) > 0)
16264 usename, servername);
16268 .namespace =
namespace,
16270 .description =
"USER MAPPING",
16272 .createStmt = q->
data,
16273 .dropStmt = delq->
data));
16304 case DEFACLOBJ_RELATION:
16307 case DEFACLOBJ_SEQUENCE:
16308 type =
"SEQUENCES";
16310 case DEFACLOBJ_FUNCTION:
16311 type =
"FUNCTIONS";
16313 case DEFACLOBJ_TYPE:
16316 case DEFACLOBJ_NAMESPACE:
16319 case DEFACLOBJ_LARGEOBJECT:
16320 type =
"LARGE OBJECTS";
16324 pg_fatal(
"unrecognized object type in default privileges: %d",
16333 daclinfo->
dobj.namespace != NULL ?
16334 daclinfo->
dobj.namespace->dobj.
name : NULL,
16340 pg_fatal(
"could not parse default ACL list (%s)",
16346 .namespace = daclinfo->
dobj.namespace ?
16347 daclinfo->
dobj.namespace->dobj.
name : NULL,
16349 .description =
"DEFAULT ACL",
16351 .createStmt = q->
data));
16382 const char *nspname,
const char *tag,
const char *owner,
16387 const char *acls = dacl->
acl;
16390 const char *initprivs = dacl->
initprivs;
16391 const char *baseacls;
16418 initprivs && *initprivs !=
'\0')
16424 pg_fatal(
"could not parse initial ACL list (%s) or default (%s) for object \"%s\" (%s)",
16426 appendPQExpBufferStr(sql,
"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
16437 if (initprivs && *initprivs !=
'\0')
16439 baseacls = initprivs;
16440 if (acls == NULL || *acls ==
'\0')
16447 acls, baseacls, owner,
16449 pg_fatal(
"could not parse ACL list (%s) or default (%s) for object \"%s\" (%s)",
16465 aclDeps[nDeps++] = objDumpId;
16467 aclDeps[nDeps++] = altDumpId;
16473 .namespace = nspname,
16475 .description =
"ACL",
16477 .createStmt = sql->
data,
16509 const char *
namespace,
const char *owner,
16526 if (strcmp(
type,
"LARGE OBJECT") != 0)
16543 for (
i = 0;
i < nlabels;
i++)
16548 if (labels[
i].objsubid != subid)
16552 "SECURITY LABEL FOR %s ON %s ",
16554 if (
namespace && *
namespace)
16561 if (query->
len > 0)
16568 .namespace =
namespace,
16570 .description =
"SECURITY LABEL",
16572 .createStmt = query->
data,
16617 for (
i = 0;
i < nlabels;
i++)
16619 const char *colname;
16643 if (query->
len > 0)
16650 .namespace = tbinfo->
dobj.namespace->dobj.
name,
16652 .description =
"SECURITY LABEL",
16654 .createStmt = query->
data,
16688 while (low <= high)
16690 middle = low + (high - low) / 2;
16692 if (classoid < middle->classoid)
16694 else if (classoid > middle->
classoid)
16696 else if (objoid < middle->objoid)
16698 else if (objoid > middle->
objoid)
16716 while (middle > low)
16718 if (classoid != middle[-1].classoid ||
16719 objoid != middle[-1].objoid)
16728 while (middle <= high)
16730 if (classoid != middle->
classoid ||
16731 objoid != middle->
objoid)
16765 "SELECT label, provider, classoid, objoid, objsubid "
16766 "FROM pg_catalog.pg_seclabels "
16767 "ORDER BY classoid, objoid, objsubid");
16773 i_provider =
PQfnumber(res,
"provider");
16774 i_classoid =
PQfnumber(res,
"classoid");
16776 i_objsubid =
PQfnumber(res,
"objsubid");
16784 for (
i = 0;
i < ntups;
i++)
16794 if (dobj == NULL ||
16807 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
16847 if (tbinfo->
relkind == RELKIND_SEQUENCE)
16857 const char *objtype =
16858 (tbinfo->
relkind == RELKIND_SEQUENCE) ?
"SEQUENCE" :
"TABLE";
16862 objtype, namecopy, NULL,
16863 tbinfo->
dobj.namespace->dobj.
name,
16883 "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
16898 "SELECT at.attname, "
16900 "'{}' AS acldefault, "
16901 "pip.privtype, pip.initprivs "
16902 "FROM pg_catalog.pg_attribute at "
16903 "LEFT JOIN pg_catalog.pg_init_privs pip ON "
16904 "(at.attrelid = pip.objoid "
16905 "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
16906 "AND at.attnum = pip.objsubid) "
16907 "WHERE at.attrelid = $1 AND "
16908 "NOT at.attisdropped "
16909 "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
16910 "ORDER BY at.attnum");
16915 "SELECT attname, attacl, '{}' AS acldefault, "
16916 "NULL AS privtype, NULL AS initprivs "
16917 "FROM pg_catalog.pg_attribute "
16918 "WHERE attrelid = $1 AND NOT attisdropped "
16919 "AND attacl IS NOT NULL "
16920 "ORDER BY attnum");
16929 "EXECUTE getColumnACLs('%u')",
16944 coldacl.
acl = attacl;
16956 "TABLE", namecopy, attnamecopy,
16957 tbinfo->
dobj.namespace->dobj.
name,
16958 NULL, tbinfo->
rolname, &coldacl);
16984 "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
16992 pg_fatal(
"query to obtain definition of view \"%s\" returned no data",
16995 pg_fatal(
"query to obtain definition of view \"%s\" returned more than one definition",
17002 pg_fatal(
"definition of view \"%s\" appears to be empty (length zero)",
17075 const char *reltypename;
17087 pg_log_warning(
"WITH OIDS is not supported anymore (table \"%s\")",
17094 if (tbinfo->
relkind == RELKIND_VIEW)
17102 reltypename =
"VIEW";
17133 char *partkeydef = NULL;
17134 char *ftoptions = NULL;
17135 char *srvname = NULL;
17136 const char *foreign =
"";
17144 case RELKIND_PARTITIONED_TABLE:
17149 reltypename =
"TABLE";
17153 "SELECT pg_get_partkeydef('%u')",
17161 case RELKIND_FOREIGN_TABLE:
17168 reltypename =
"FOREIGN TABLE";
17172 "SELECT fs.srvname, "
17173 "pg_catalog.array_to_string(ARRAY("
17174 "SELECT pg_catalog.quote_ident(option_name) || "
17175 "' ' || pg_catalog.quote_literal(option_value) "
17176 "FROM pg_catalog.pg_options_to_table(ftoptions) "
17177 "ORDER BY option_name"
17178 "), E',\n ') AS ftoptions "
17179 "FROM pg_catalog.pg_foreign_table ft "
17180 "JOIN pg_catalog.pg_foreign_server fs "
17181 "ON (fs.oid = ft.ftserver) "
17182 "WHERE ft.ftrelid = '%u'",
17186 i_ftoptions =
PQfnumber(res,
"ftoptions");
17192 foreign =
"FOREIGN ";
17195 case RELKIND_MATVIEW:
17196 reltypename =
"MATERIALIZED VIEW";
17199 reltypename =
"TABLE";
17218 tbinfo->
relkind != RELKIND_PARTITIONED_TABLE) ?
17232 if (tbinfo->
relkind != RELKIND_MATVIEW)
17246 bool print_default;
17247 bool print_notnull;
17253 print_default = (tbinfo->
attrdefs[
j] != NULL &&
17272 !print_default && !print_notnull &&
17277 if (actual_atts == 0)
17316 else if (tbinfo->
attgenerated[
j] == ATTRIBUTE_GENERATED_VIRTUAL)
17364 if (actual_atts == 0)
17397 if (actual_atts == 0)
17428 for (k = 0; k < numParents; k++)
17439 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
17442 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
17449 bool addcomma =
false;
17468 if (ftoptions && ftoptions[0])
17475 if (tbinfo->
relkind == RELKIND_MATVIEW)
17488 if (tbinfo->
relkind == RELKIND_MATVIEW)
17490 "pg_catalog.pg_class",
17491 "MATERIALIZED VIEW",
17506 "SELECT pg_catalog.binary_upgrade_set_missing_value(");
17539 (tbinfo->
relkind == RELKIND_RELATION ||
17540 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ||
17541 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE))
17544 bool firstitem_extra;
17561 "UPDATE pg_catalog.pg_attribute\n"
17562 "SET attlen = v.dlen, "
17563 "attalign = v.dalign, "
17564 "attbyval = false\n"
17577 foreign, qualrelname);
17585 "WHERE attrelid = ");
17588 " AND attname = v.dname;\n");
17607 "SET attislocal = false\n"
17608 "WHERE attrelid = ");
17611 " AND attname IN (");
17629 firstitem_extra =
true;
17650 "SET conislocal = false\n"
17651 "WHERE contype = 'n' AND conrelid = ");
17663 if (firstitem_extra)
17666 "SET conislocal = false\n"
17667 "WHERE contype = 'n' AND conrelid = ");
17671 firstitem_extra =
false;
17681 if (!firstitem_extra)
17684 if (extra->
len > 0)
17701 for (k = 0; k < tbinfo->
ncheck; k++)
17711 foreign, qualrelname,
17718 "SET conislocal = false\n"
17719 "WHERE contype = 'c' AND conrelid = ");
17738 for (k = 0; k < numParents; k++)
17766 (tbinfo->
relkind == RELKIND_RELATION ||
17767 tbinfo->
relkind == RELKIND_MATVIEW))
17771 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17783 appendPQExpBufferStr(q,
"\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
17785 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17786 "WHERE oid = '%u';\n",
17804 "SET relispopulated = 't'\n"
17826 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STATISTICS %d;\n",
17827 foreign, qualrelname,
17839 case TYPSTORAGE_PLAIN:
17842 case TYPSTORAGE_EXTERNAL:
17845 case TYPSTORAGE_EXTENDED:
17848 case TYPSTORAGE_MAIN:
17859 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STORAGE %s;\n",
17860 foreign, qualrelname,
17870 const char *cmname;
17885 if (cmname != NULL)
17886 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET COMPRESSION %s;\n",
17887 foreign, qualrelname,
17897 foreign, qualrelname,
17904 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
17907 "ALTER FOREIGN TABLE ONLY %s ALTER COLUMN %s OPTIONS (\n"
17923 if ((tbinfo->
relkind == RELKIND_RELATION ||
17924 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ||
17925 tbinfo->
relkind == RELKIND_MATVIEW) &&
17932 else if (tbinfo->
relreplident == REPLICA_IDENTITY_NOTHING)
17937 else if (tbinfo->
relreplident == REPLICA_IDENTITY_FULL)
17950 reltypename, qrelname,
17951 tbinfo->
dobj.namespace->dobj.
name);
17956 char *tableam = NULL;
17965 if (RELKIND_HAS_TABLESPACE(tbinfo->
relkind))
17968 if (RELKIND_HAS_TABLE_AM(tbinfo->
relkind) ||
17969 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
17970 tableam = tbinfo->
amname;
17974 .namespace = tbinfo->
dobj.namespace->dobj.
name,
17976 .tableam = tableam,
17979 .description = reltypename,
17982 .createStmt = q->
data,
17983 .dropStmt = delq->
data));
18030 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18032 .description =
"COMMENT",
18096 "PREPARE dumpTableAttach(pg_catalog.oid) AS\n");
18099 "SELECT pg_get_expr(c.relpartbound, c.oid) "
18101 "WHERE c.oid = $1");
18109 "EXECUTE dumpTableAttach('%u')",
18117 "ALTER TABLE ONLY %s ",
18120 "ATTACH PARTITION %s %s;\n",
18133 .namespace = attachinfo->
dobj.namespace->dobj.
name,
18135 .description =
"TABLE ATTACH",
18137 .createStmt = q->
data));
18151 int adnum = adinfo->
adnum;
18171 foreign = tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
18174 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET DEFAULT %s;\n",
18179 foreign, qualrelname,
18187 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18189 .description =
"DEFAULT",
18191 .createStmt = q->
data,
18192 .dropStmt = delq->
data));
18210 if (attrnum > 0 && attrnum <= tblInfo->numatts)
18211 return tblInfo->
attnames[attrnum - 1];
18227 pg_fatal(
"invalid column number %d for table \"%s\"",
18264 if (!is_constraint)
18268 char **indstatcolsarray = NULL;
18269 char **indstatvalsarray = NULL;
18300 if (strlen(indstatcols) != 0 || strlen(indstatvals) != 0)
18304 if (!
parsePGArray(indstatcols, &indstatcolsarray, &nstatcols))
18305 pg_fatal(
"could not parse index statistic columns");
18306 if (!
parsePGArray(indstatvals, &indstatvalsarray, &nstatvals))
18307 pg_fatal(
"could not parse index statistic values");
18308 if (nstatcols != nstatvals)
18309 pg_fatal(
"mismatched number of columns and values for index statistics");
18311 for (
j = 0;
j < nstatcols;
j++)
18320 indstatcolsarray[
j]);
18322 indstatvalsarray[
j]);
18328 "pg_catalog.pg_class",
18329 "INDEX", qqindxname);
18356 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18359 .description =
"INDEX",
18361 .createStmt = q->
data,
18362 .dropStmt = delq->
data));
18364 free(indstatcolsarray);
18365 free(indstatvalsarray);
18371 tbinfo->
dobj.namespace->dobj.
name,
18416 .namespace = attachinfo->
dobj.namespace->dobj.
name,
18418 .description =
"INDEX ATTACH",
18420 .createStmt = q->
data));
18437 char *qstatsextname;
18452 "pg_catalog.pg_get_statisticsobjdef('%u'::pg_catalog.oid)",
18481 .namespace = statsextinfo->
dobj.namespace->dobj.
name,
18482 .owner = statsextinfo->
rolname,
18483 .description =
"STATISTICS",
18485 .createStmt = q->
data,
18486 .dropStmt = delq->
data));
18491 statsextinfo->
dobj.namespace->dobj.
name,
18500 free(qstatsextname);
18524 foreign = tbinfo &&
18525 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
18527 if (coninfo->
contype ==
'p' ||
18537 if (indxinfo == NULL)
18538 pg_fatal(
"missing index for constraint \"%s\"",
18558 coninfo->
contype ==
'p' ?
"PRIMARY KEY" :
"UNIQUE");
18571 int indkey = (int) indxinfo->
indkeys[k];
18579 (k == 0) ?
"" :
", ",
18588 for (k = indxinfo->
indnkeyattrs; k < indxinfo->indnattrs; k++)
18590 int indkey = (int) indxinfo->
indkeys[k];
18649 "pg_catalog.pg_class",
"INDEX",
18662 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18665 .description =
"CONSTRAINT",
18667 .createStmt = q->
data,
18668 .dropStmt = delq->
data));
18670 else if (coninfo->
contype ==
'f')
18680 only = tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ?
"" :
"ONLY ";
18702 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18704 .description =
"FK CONSTRAINT",
18706 .createStmt = q->
data,
18707 .dropStmt = delq->
data));
18709 else if ((coninfo->
contype ==
'c' || coninfo->
contype ==
'n') && tbinfo)
18716 const char *keyword;
18719 keyword =
"CHECK CONSTRAINT";
18721 keyword =
"CONSTRAINT";
18740 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18742 .description = keyword,
18744 .createStmt = q->
data,
18745 .dropStmt = delq->
data));
18748 else if (tbinfo == NULL)
18758 const char *keyword;
18761 keyword =
"CHECK CONSTRAINT";
18763 keyword =
"CONSTRAINT";
18781 .
namespace = tyinfo->
dobj.namespace->dobj.
name,
18783 .description = keyword,
18785 .createStmt = q->
data,
18786 .dropStmt = delq->
data));
18797 tyinfo->
dobj.namespace->dobj.
name,
18807 pg_fatal(
"unrecognized constraint type: %c",
18812 if (tbinfo && coninfo->
separate &&
18842 tbinfo->
dobj.namespace->dobj.
name,
18900 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
18901 "seqstart, seqincrement, "
18903 "seqcache, seqcycle, "
18905 "FROM pg_catalog.pg_sequence "
18906 "ORDER BY seqrelid";
18908 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
18909 "seqstart, seqincrement, "
18911 "seqcache, seqcycle, "
18912 "last_value, is_called "
18913 "FROM pg_catalog.pg_sequence, "
18914 "pg_get_sequence_data(seqrelid) "
18915 "ORDER BY seqrelid;";
18949 int64 default_minv,
18984 "SELECT 'bigint' AS sequence_type, "
18985 "start_value, increment_by, max_value, min_value, "
18986 "cache_value, is_cycled FROM %s",
18992 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
18993 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19010 is_ascending = (seq->
incby >= 0);
19029 default_minv = default_maxv = 0;
19062 "ALTER COLUMN %s ADD GENERATED ",
19078 "UNLOGGED" :
"LOGGED");
19083 "CREATE %sSEQUENCE %s\n",
19096 if (seq->
minv != default_minv)
19101 if (seq->
maxv != default_maxv)
19119 "SEQUENCE", qseqname,
19120 tbinfo->
dobj.namespace->dobj.
name);
19125 .namespace = tbinfo->
dobj.namespace->dobj.
name,
19127 .description =
"SEQUENCE",
19129 .createStmt = query->
data,
19130 .dropStmt = delqry->
data));
19148 if (owning_tab == NULL)
19149 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
19165 .namespace = tbinfo->
dobj.namespace->dobj.
name,
19167 .description =
"SEQUENCE OWNED BY",
19169 .createStmt = query->
data,
19218 "SELECT last_value, is_called FROM %s",
19224 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19225 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19229 last = strtoi64(
PQgetvalue(res, 0, 0), NULL, 10);
19230 called = (strcmp(
PQgetvalue(res, 0, 1),
"t") == 0);
19254 last, (called ?
"true" :
"false"));
19259 .namespace = tbinfo->
dobj.namespace->dobj.
name,
19261 .description =
"SEQUENCE SET",
19263 .createStmt = query->
data,
19305 "pg_catalog.pg_trigger",
"TRIGGER",
19306 trigidentity->
data);
19321 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
19346 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
19376 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
19378 .description =
"TRIGGER",
19380 .createStmt = query->
data,
19381 .dropStmt = delqry->
data));
19422 if (strcmp(
"", evtinfo->
evttags) != 0)
19460 "EVENT TRIGGER", qevtname, NULL);
19466 .description =
"EVENT TRIGGER",
19468 .createStmt = query->
data,
19469 .dropStmt = delqry->
data));
19556 "SELECT pg_catalog.pg_get_ruledef('%u'::pg_catalog.oid)",
19562 pg_fatal(
"query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
19625 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
19627 .description =
"RULE",
19629 .createStmt = cmd->
data,
19630 .dropStmt = delcmd->
data));
19635 tbinfo->
dobj.namespace->dobj.
name,
19671 if (numExtensions == 0)
19678 "classid, objid, refobjid "
19680 "WHERE refclassid = 'pg_extension'::regclass "
19681 "AND deptype = 'e' "
19690 i_refobjid =
PQfnumber(res,
"refobjid");
19699 for (
i = 0;
i < ntups;
i++)
19715 pg_log_warning(
"could not find referenced extension %u", extId);
19763 if (numExtensions == 0)
19777 for (
i = 0;
i < numExtensions;
i++)
19782 char **extconfigarray = NULL;
19783 char **extconditionarray = NULL;
19784 int nconfigitems = 0;
19785 int nconditionitems = 0;
19805 if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
19809 if (!
parsePGArray(extconfig, &extconfigarray, &nconfigitems))
19810 pg_fatal(
"could not parse %s array",
"extconfig");
19811 if (!
parsePGArray(extcondition, &extconditionarray, &nconditionitems))
19812 pg_fatal(
"could not parse %s array",
"extcondition");
19813 if (nconfigitems != nconditionitems)
19814 pg_fatal(
"mismatched number of configurations and conditions for extension");
19816 for (
j = 0;
j < nconfigitems;
j++)
19819 Oid configtbloid =
atooid(extconfigarray[
j]);
19824 if (configtbl == NULL)
19840 if (configtbl->
dobj.namespace->dobj.
dump &
19859 if (configtbl->
dataObj != NULL)
19861 if (strlen(extconditionarray[
j]) > 0)
19867 if (extconfigarray)
19868 free(extconfigarray);
19869 if (extconditionarray)
19870 free(extconditionarray);
19885 "SELECT conrelid, confrelid "
19886 "FROM pg_constraint "
19887 "JOIN pg_depend ON (objid = confrelid) "
19888 "WHERE contype = 'f' "
19889 "AND refclassid = 'pg_extension'::regclass "
19890 "AND classid = 'pg_class'::regclass;");
19895 i_conrelid =
PQfnumber(res,
"conrelid");
19896 i_confrelid =
PQfnumber(res,
"confrelid");
19899 for (
i = 0;
i < ntups;
i++)
19911 if (reftable == NULL ||
19913 contable == NULL ||
19959 "classid, objid, refclassid, refobjid, deptype "
19961 "WHERE deptype != 'p' AND deptype != 'e'\n");
19974 "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
19975 "FROM pg_depend d, pg_amop o "
19976 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
19977 "classid = 'pg_amop'::regclass AND objid = o.oid "
19978 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
19982 "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
19983 "FROM pg_depend d, pg_amproc p "
19984 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
19985 "classid = 'pg_amproc'::regclass AND objid = p.oid "
19986 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
19997 i_refclassid =
PQfnumber(res,
"refclassid");
19998 i_refobjid =
PQfnumber(res,
"refobjid");
20008 for (
i = 0;
i < ntups;
i++)
20020 if (dobj == NULL ||
20040 if (refdobj == NULL)
20055 if (deptype ==
'x')
20065 if (deptype ==
'i' &&
20116 for (
i = 0;
i < numObjs;
i++)
20180 if (((
RuleInfo *) dobj)->separate)
20259 if (dobj->
nDeps <= 0)
20267 &dependencies, &nDeps, &allocDeps);
20272 nDeps *
sizeof(
DumpId));
20277 free(dependencies);
20284 DumpId **dependencies,
int *nDeps,
int *allocDeps)
20303 if (*nDeps >= *allocDeps)
20307 *allocDeps *
sizeof(
DumpId));
20309 (*dependencies)[*nDeps] = depid;
20323 dependencies, nDeps, allocDeps);
20356 if (typeInfo && typeInfo->
ftypname)
20360 appendPQExpBuffer(query,
"SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
20401 for (
i = 0;
i < numatts;
i++)
20403 if (attisdropped[
i])
20405 if (attgenerated[
i])
20417 return buffer->
data;
20427 return (reloptions != NULL && strlen(reloptions) > 2);
20437 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)
void getSubscriptionTables(Archive *fout)
static void selectDumpableObject(DumpableObject *dobj, Archive *fout)
static void dumpTSTemplate(Archive *fout, const TSTemplateInfo *tmplinfo)
static void dumpIndexAttach(Archive *fout, const IndexAttachInfo *attachinfo)
static void dumpSubscriptionTable(Archive *fout, const SubRelInfo *subrinfo)
void getCollations(Archive *fout)
static char * format_function_arguments(const FuncInfo *finfo, const char *funcargs, bool is_agg)
static void dumpTransform(Archive *fout, const TransformInfo *transform)
void getAggregates(Archive *fout)
static void dumpLO(Archive *fout, const LoInfo *loinfo)
void getNamespaces(Archive *fout)
static void dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo)
void getPublications(Archive *fout)
static void binary_upgrade_extension_member(PQExpBuffer upgrade_buffer, const DumpableObject *dobj, const char *objtype, const char *objname, const char *objnamespace)
static void dumpDumpableObject(Archive *fout, DumpableObject *dobj)
static void getLOs(Archive *fout)
static void dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, const char *dbname, Oid dboid)
void getTSParsers(Archive *fout)
static 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 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)