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 and %s cannot be used together",
835 "-s/--schema-only",
"-a/--data-only");
837 pg_fatal(
"options %s and %s cannot be used together",
838 "-s/--schema-only",
"--statistics-only");
840 pg_fatal(
"options %s and %s cannot be used together",
841 "-a/--data-only",
"--statistics-only");
845 pg_fatal(
"options %s and %s cannot be used together",
846 "-a/--data-only",
"--no-data");
848 pg_fatal(
"options %s and %s cannot be used together",
849 "-s/--schema-only",
"--no-schema");
851 pg_fatal(
"options %s and %s cannot be used together",
852 "--statistics-only",
"--no-statistics");
856 pg_fatal(
"options %s and %s cannot be used together",
857 "--statistics",
"--no-statistics");
861 pg_fatal(
"options %s and %s cannot be used together",
862 "-a/--data-only",
"--statistics");
864 pg_fatal(
"options %s and %s cannot be used together",
865 "-s/--schema-only",
"--statistics");
868 pg_fatal(
"options %s and %s cannot be used together",
869 "-s/--schema-only",
"--include-foreign-data");
872 pg_fatal(
"option %s is not supported with parallel backup",
873 "--include-foreign-data");
876 pg_fatal(
"options %s and %s cannot be used together",
877 "-c/--clean",
"-a/--data-only");
880 pg_fatal(
"option %s requires option %s",
881 "--if-exists",
"-c/--clean");
901 pg_fatal(
"option %s requires option %s, %s, or %s",
902 "--on-conflict-do-nothing",
903 "--inserts",
"--rows-per-insert",
"--column-inserts");
919 pg_fatal(
"could not generate restrict key");
924 pg_fatal(
"option %s can only be used with %s",
925 "--restrict-key",
"--format=plain");
933 !user_compression_defined)
936 compression_algorithm_str =
"gzip";
938 compression_algorithm_str =
"none";
947 pg_fatal(
"unrecognized compression algorithm: \"%s\"",
948 compression_algorithm_str);
953 if (error_detail != NULL)
954 pg_fatal(
"invalid compression specification: %s",
958 if (error_detail != NULL)
967 pg_log_warning(
"compression option \"%s\" is not currently supported by pg_dump",
979 pg_fatal(
"parallel backup only supported by the directory format");
1034 pg_fatal(
"no matching schemas were found");
1051 pg_fatal(
"no matching tables were found");
1079 pg_fatal(
"no matching extensions were found");
1118 getTableData(&dopt, tblinfo, numTables, RELKIND_SEQUENCE);
1146 "AND dbid = (SELECT oid FROM pg_database "
1147 " WHERE datname = current_database())";
1161 "(SELECT objoid FROM pg_description "
1162 "WHERE classoid = " CppAsString2(LargeObjectRelationId)
" "
1163 "UNION SELECT objoid FROM pg_seclabel "
1164 "WHERE classoid = " CppAsString2(LargeObjectRelationId)
")";
1221 boundaryObjs[0].dumpId, boundaryObjs[1].dumpId);
1240 for (
i = 0;
i < numObjs;
i++)
1320 printf(
_(
"%s exports a PostgreSQL database as an SQL script or to other formats.\n\n"),
progname);
1324 printf(
_(
"\nGeneral options:\n"));
1325 printf(
_(
" -f, --file=FILENAME output file or directory name\n"));
1326 printf(
_(
" -F, --format=c|d|t|p output file format (custom, directory, tar,\n"
1327 " plain text (default))\n"));
1328 printf(
_(
" -j, --jobs=NUM use this many parallel jobs to dump\n"));
1329 printf(
_(
" -v, --verbose verbose mode\n"));
1330 printf(
_(
" -V, --version output version information, then exit\n"));
1331 printf(
_(
" -Z, --compress=METHOD[:DETAIL]\n"
1332 " compress as specified\n"));
1333 printf(
_(
" --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock\n"));
1334 printf(
_(
" --no-sync do not wait for changes to be written safely to disk\n"));
1335 printf(
_(
" --sync-method=METHOD set method for syncing files to disk\n"));
1336 printf(
_(
" -?, --help show this help, then exit\n"));
1338 printf(
_(
"\nOptions controlling the output content:\n"));
1339 printf(
_(
" -a, --data-only dump only the data, not the schema or statistics\n"));
1340 printf(
_(
" -b, --large-objects include large objects in dump\n"));
1341 printf(
_(
" --blobs (same as --large-objects, deprecated)\n"));
1342 printf(
_(
" -B, --no-large-objects exclude large objects in dump\n"));
1343 printf(
_(
" --no-blobs (same as --no-large-objects, deprecated)\n"));
1344 printf(
_(
" -c, --clean clean (drop) database objects before recreating\n"));
1345 printf(
_(
" -C, --create include commands to create database in dump\n"));
1346 printf(
_(
" -e, --extension=PATTERN dump the specified extension(s) only\n"));
1347 printf(
_(
" -E, --encoding=ENCODING dump the data in encoding ENCODING\n"));
1348 printf(
_(
" -n, --schema=PATTERN dump the specified schema(s) only\n"));
1349 printf(
_(
" -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
1350 printf(
_(
" -O, --no-owner skip restoration of object ownership in\n"
1351 " plain-text format\n"));
1352 printf(
_(
" -s, --schema-only dump only the schema, no data or statistics\n"));
1353 printf(
_(
" -S, --superuser=NAME superuser user name to use in plain-text format\n"));
1354 printf(
_(
" -t, --table=PATTERN dump only the specified table(s)\n"));
1355 printf(
_(
" -T, --exclude-table=PATTERN do NOT dump the specified table(s)\n"));
1356 printf(
_(
" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
1357 printf(
_(
" --binary-upgrade for use by upgrade utilities only\n"));
1358 printf(
_(
" --column-inserts dump data as INSERT commands with column names\n"));
1359 printf(
_(
" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
1360 printf(
_(
" --disable-triggers disable triggers during data-only restore\n"));
1361 printf(
_(
" --enable-row-security enable row security (dump only content user has\n"
1363 printf(
_(
" --exclude-extension=PATTERN do NOT dump the specified extension(s)\n"));
1364 printf(
_(
" --exclude-table-and-children=PATTERN\n"
1365 " do NOT dump the specified table(s), including\n"
1366 " child and partition tables\n"));
1367 printf(
_(
" --exclude-table-data=PATTERN do NOT dump data for the specified table(s)\n"));
1368 printf(
_(
" --exclude-table-data-and-children=PATTERN\n"
1369 " do NOT dump data for the specified table(s),\n"
1370 " including child and partition tables\n"));
1371 printf(
_(
" --extra-float-digits=NUM override default setting for extra_float_digits\n"));
1372 printf(
_(
" --filter=FILENAME include or exclude objects and data from dump\n"
1373 " based on expressions in FILENAME\n"));
1374 printf(
_(
" --if-exists use IF EXISTS when dropping objects\n"));
1375 printf(
_(
" --include-foreign-data=PATTERN\n"
1376 " include data of foreign tables on foreign\n"
1377 " servers matching PATTERN\n"));
1378 printf(
_(
" --inserts dump data as INSERT commands, rather than COPY\n"));
1379 printf(
_(
" --load-via-partition-root load partitions via the root table\n"));
1380 printf(
_(
" --no-comments do not dump comment commands\n"));
1381 printf(
_(
" --no-data do not dump data\n"));
1382 printf(
_(
" --no-policies do not dump row security policies\n"));
1383 printf(
_(
" --no-publications do not dump publications\n"));
1384 printf(
_(
" --no-schema do not dump schema\n"));
1385 printf(
_(
" --no-security-labels do not dump security label assignments\n"));
1386 printf(
_(
" --no-statistics do not dump statistics\n"));
1387 printf(
_(
" --no-subscriptions do not dump subscriptions\n"));
1388 printf(
_(
" --no-table-access-method do not dump table access methods\n"));
1389 printf(
_(
" --no-tablespaces do not dump tablespace assignments\n"));
1390 printf(
_(
" --no-toast-compression do not dump TOAST compression methods\n"));
1391 printf(
_(
" --no-unlogged-table-data do not dump unlogged table data\n"));
1392 printf(
_(
" --on-conflict-do-nothing add ON CONFLICT DO NOTHING to INSERT commands\n"));
1393 printf(
_(
" --quote-all-identifiers quote all identifiers, even if not key words\n"));
1394 printf(
_(
" --restrict-key=RESTRICT_KEY use provided string as psql \\restrict key\n"));
1395 printf(
_(
" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
1396 printf(
_(
" --section=SECTION dump named section (pre-data, data, or post-data)\n"));
1397 printf(
_(
" --sequence-data include sequence data in dump\n"));
1398 printf(
_(
" --serializable-deferrable wait until the dump can run without anomalies\n"));
1399 printf(
_(
" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
1400 printf(
_(
" --statistics dump the statistics\n"));
1401 printf(
_(
" --statistics-only dump only the statistics, not schema or data\n"));
1402 printf(
_(
" --strict-names require table and/or schema include patterns to\n"
1403 " match at least one entity each\n"));
1404 printf(
_(
" --table-and-children=PATTERN dump only the specified table(s), including\n"
1405 " child and partition tables\n"));
1406 printf(
_(
" --use-set-session-authorization\n"
1407 " use SET SESSION AUTHORIZATION commands instead of\n"
1408 " ALTER OWNER commands to set ownership\n"));
1410 printf(
_(
"\nConnection options:\n"));
1411 printf(
_(
" -d, --dbname=DBNAME database to dump\n"));
1412 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
1413 printf(
_(
" -p, --port=PORT database server port number\n"));
1414 printf(
_(
" -U, --username=NAME connect as specified database user\n"));
1415 printf(
_(
" -w, --no-password never prompt for password\n"));
1416 printf(
_(
" -W, --password force password prompt (should happen automatically)\n"));
1417 printf(
_(
" --role=ROLENAME do SET ROLE before dump\n"));
1419 printf(
_(
"\nIf no database name is supplied, then the PGDATABASE environment\n"
1420 "variable value is used.\n\n"));
1421 printf(
_(
"Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
1422 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
1427 const char *dumpsnapshot,
char *use_role)
1431 const char *std_strings;
1441 pg_fatal(
"invalid client encoding \"%s\" specified",
1453 AH->
std_strings = (std_strings && strcmp(std_strings,
"on") == 0);
1562 "SET TRANSACTION ISOLATION LEVEL "
1563 "SERIALIZABLE, READ ONLY, DEFERRABLE");
1566 "SET TRANSACTION ISOLATION LEVEL "
1567 "REPEATABLE READ, READ ONLY");
1589 pg_fatal(
"parallel dumps from standby servers are not supported by this server version");
1613 char *query =
"SELECT pg_catalog.pg_export_snapshot()";
1655 return archiveFormat;
1673 if (patterns->
head == NULL)
1683 for (cell = patterns->
head; cell; cell = cell->
next)
1689 "SELECT oid FROM pg_catalog.pg_namespace n\n");
1692 false, NULL,
"n.nspname", NULL, NULL, &dbbuf,
1695 pg_fatal(
"improper qualified name (too many dotted names): %s",
1697 else if (dotcnt == 1)
1703 pg_fatal(
"no matching schemas were found for pattern \"%s\"", cell->
val);
1732 if (patterns->
head == NULL)
1741 for (cell = patterns->
head; cell; cell = cell->
next)
1746 "SELECT oid FROM pg_catalog.pg_extension e\n");
1748 false, NULL,
"e.extname", NULL, NULL, NULL,
1751 pg_fatal(
"improper qualified name (too many dotted names): %s",
1756 pg_fatal(
"no matching extensions were found for pattern \"%s\"", cell->
val);
1784 if (patterns->
head == NULL)
1794 for (cell = patterns->
head; cell; cell = cell->
next)
1799 "SELECT oid FROM pg_catalog.pg_foreign_server s\n");
1801 false, NULL,
"s.srvname", NULL, NULL, NULL,
1804 pg_fatal(
"improper qualified name (too many dotted names): %s",
1809 pg_fatal(
"no matching foreign servers were found for pattern \"%s\"", cell->
val);
1836 if (patterns->
head == NULL)
1846 for (cell = patterns->
head; cell; cell = cell->
next)
1859 if (with_child_tables)
1866 "\nFROM pg_catalog.pg_class c"
1867 "\n LEFT JOIN pg_catalog.pg_namespace n"
1868 "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace"
1869 "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY"
1870 "\n (array['%c', '%c', '%c', '%c', '%c', '%c'])\n",
1871 RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW,
1872 RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE,
1873 RELKIND_PARTITIONED_TABLE);
1876 false,
"n.nspname",
"c.relname", NULL,
1877 "pg_catalog.pg_table_is_visible(c.oid)", &dbbuf,
1880 pg_fatal(
"improper relation name (too many dotted names): %s",
1882 else if (dotcnt == 2)
1886 if (with_child_tables)
1889 "\nSELECT i.inhrelid"
1890 "\nFROM partition_tree p"
1891 "\n JOIN pg_catalog.pg_inherits i"
1892 "\n ON p.relid OPERATOR(pg_catalog.=) i.inhparent"
1894 "\nSELECT relid FROM partition_tree");
1902 pg_fatal(
"no matching tables were found for pattern \"%s\"", cell->
val);
1929 pg_fatal(
"You are currently not connected to a database.");
1931 if (strcmp(db,
dbname) != 0)
1932 pg_fatal(
"cross-database references are not implemented: %s",
2020 strcmp(nsinfo->
dobj.
name,
"pg_catalog") == 0)
2029 else if (strncmp(nsinfo->
dobj.
name,
"pg_", 3) == 0 ||
2030 strcmp(nsinfo->
dobj.
name,
"information_schema") == 0)
2035 else if (strcmp(nsinfo->
dobj.
name,
"public") == 0)
2047 if (nsinfo->
nspowner == ROLE_PG_DATABASE_OWNER)
2048 nsinfo->
dobj.
dump &= ~DUMP_COMPONENT_DEFINITION;
2127 tyinfo->
typrelkind != RELKIND_COMPOSITE_TYPE)
2132 if (tytable != NULL)
2172 if (dinfo->
dobj.namespace)
2367 if (dobj->namespace)
2384 const char *classname = tbinfo->
dobj.
name;
2396 const char *column_list;
2398 pg_log_info(
"dumping contents of table \"%s.%s\"",
2399 tbinfo->
dobj.namespace->dobj.
name, classname);
2417 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2422 if (strlen(column_list) > 2)
2508 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetCopyData() failed.", classname);
2518 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetResult() failed.", classname);
2527 pg_log_warning(
"unexpected extra results during COPY of table \"%s\"",
2533 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2560 int rows_this_statement = 0;
2563 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2609 pg_fatal(
"wrong number of fields retrieved from table \"%s\"",
2619 if (insertStmt == NULL)
2651 for (
int field = 0; field < nfields; field++)
2668 for (
int tuple = 0; tuple <
PQntuples(res); tuple++)
2671 if (rows_this_statement == 0)
2687 if (rows_per_statement == 1)
2689 else if (rows_this_statement > 0)
2694 for (
int field = 0; field < nfields; field++)
2698 if (attgenerated[field])
2731 const char *s =
PQgetvalue(res, tuple, field);
2733 if (strspn(s,
"0123456789 +-eE.") == strlen(s))
2747 if (strcmp(
PQgetvalue(res, tuple, field),
"t") == 0)
2768 if (++rows_this_statement >= rows_per_statement)
2771 archputs(
" ON CONFLICT DO NOTHING;\n", fout);
2775 rows_this_statement = 0;
2788 if (rows_this_statement > 0)
2791 archputs(
" ON CONFLICT DO NOTHING;\n", fout);
2801 if (insertStmt != NULL)
2806 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2824 parentTbinfo = tbinfo->
parents[0];
2828 parentTbinfo = parentTbinfo->
parents[0];
2831 return parentTbinfo;
2849 parentTbinfo = tbinfo->
parents[0];
2855 parentTbinfo = parentTbinfo->
parents[0];
2877 char *tdDefn = NULL;
2879 const char *copyFrom;
2917 copyStmt = copyBuf->
data;
2937 .namespace = tbinfo->
dobj.namespace->dobj.
name,
2939 .description =
"TABLE DATA",
2941 .createStmt = tdDefn,
2942 .copyStmt = copyStmt,
2946 .dumpArg = tdinfo));
3004 .namespace = tbinfo->
dobj.namespace->dobj.
name,
3006 .description =
"MATERIALIZED VIEW DATA",
3008 .createStmt = q->
data,
3024 for (
i = 0;
i < numTables;
i++)
3027 (!relkind || tblinfo[
i].
relkind == relkind))
3051 if (tbinfo->
relkind == RELKIND_VIEW)
3054 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
3060 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
3076 if (tbinfo->
relkind == RELKIND_MATVIEW)
3078 else if (tbinfo->
relkind == RELKIND_SEQUENCE)
3091 tdinfo->
dobj.namespace = tbinfo->
dobj.namespace;
3108 if (tbinfo->
relkind == RELKIND_MATVIEW && tbinfo->
stats != NULL)
3144 "SELECT d1.objid, d2.refobjid, c2.relkind AS refrelkind "
3145 "FROM pg_depend d1 "
3146 "JOIN pg_class c1 ON c1.oid = d1.objid "
3148 " JOIN pg_rewrite r1 ON r1.ev_class = d1.objid "
3149 "JOIN pg_depend d2 ON d2.classid = 'pg_rewrite'::regclass "
3150 "AND d2.objid = r1.oid "
3151 "AND d2.refobjid <> d1.objid "
3152 "JOIN pg_class c2 ON c2.oid = d2.refobjid "
3153 "AND c2.relkind IN (" CppAsString2(RELKIND_MATVIEW)
","
3155 "WHERE d1.classid = 'pg_class'::regclass "
3157 "SELECT w.objid, d3.refobjid, c3.relkind "
3159 "JOIN pg_rewrite r3 ON r3.ev_class = w.refobjid "
3160 "JOIN pg_depend d3 ON d3.classid = 'pg_rewrite'::regclass "
3161 "AND d3.objid = r3.oid "
3162 "AND d3.refobjid <> w.refobjid "
3163 "JOIN pg_class c3 ON c3.oid = d3.refobjid "
3164 "AND c3.relkind IN (" CppAsString2(RELKIND_MATVIEW)
","
3167 "SELECT 'pg_class'::regclass::oid AS classid, objid, refobjid "
3177 i_refobjid =
PQfnumber(res,
"refobjid");
3179 for (
i = 0;
i < ntups;
i++)
3206 if (refdobj == NULL)
3213 if (refdobj == NULL)
3249 for (
i = 0;
i < numObjs;
i++)
3261 if (ftable == NULL ||
3334 "pg_encoding_to_char(encoding) AS encoding, "
3335 "datcollate, datctype, datfrozenxid, "
3336 "datacl, acldefault('d', datdba) AS acldefault, "
3337 "datistemplate, datconnlimit, ");
3347 appendPQExpBufferStr(dbQry,
"'c' AS datlocprovider, NULL AS datlocale, NULL AS datcollversion, ");
3353 "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
3354 "shobj_description(oid, 'pg_database') AS description "
3356 "WHERE datname = current_database()");
3360 i_tableoid =
PQfnumber(res,
"tableoid");
3364 i_encoding =
PQfnumber(res,
"encoding");
3365 i_datlocprovider =
PQfnumber(res,
"datlocprovider");
3366 i_collate =
PQfnumber(res,
"datcollate");
3368 i_datlocale =
PQfnumber(res,
"datlocale");
3369 i_daticurules =
PQfnumber(res,
"daticurules");
3370 i_frozenxid =
PQfnumber(res,
"datfrozenxid");
3371 i_minmxid =
PQfnumber(res,
"datminmxid");
3373 i_acldefault =
PQfnumber(res,
"acldefault");
3374 i_datistemplate =
PQfnumber(res,
"datistemplate");
3375 i_datconnlimit =
PQfnumber(res,
"datconnlimit");
3376 i_datcollversion =
PQfnumber(res,
"datcollversion");
3377 i_tablespace =
PQfnumber(res,
"tablespace");
3392 icurules =
PQgetvalue(res, 0, i_daticurules);
3419 "CREATE DATABASE %s WITH TEMPLATE = template0 "
3420 "OID = %u STRATEGY = FILE_COPY",
3421 qdatname, dbCatId.
oid);
3442 pg_fatal(
"unrecognized locale provider: %s",
3445 if (strlen(collate) > 0 && strcmp(collate, ctype) == 0)
3452 if (strlen(collate) > 0)
3457 if (strlen(ctype) > 0)
3520 .createStmt = creaQry->
data,
3521 .dropStmt = delQry->
data));
3550 .description =
"COMMENT",
3552 .createStmt = dbQry->
data,
3570 if (seclabelQry->
len > 0)
3574 .description =
"SECURITY LABEL",
3576 .createStmt = seclabelQry->
data,
3591 qdatname, NULL, NULL,
3592 NULL, dba, &dbdacl);
3622 "SET datistemplate = false WHERE datname = ");
3643 "SET datfrozenxid = '%u', datminmxid = '%u'\n"
3645 frozenxid, minmxid);
3650 if (creaQry->
len > 0)
3656 .createStmt = creaQry->
data,
3657 .dropStmt = delQry->
data,
3658 .deps = &dbDumpId));
3678 int ii_relfrozenxid,
3684 appendPQExpBuffer(loFrozenQry,
"SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
3685 "FROM pg_catalog.pg_class\n"
3686 "WHERE oid IN (%u, %u, %u, %u);\n",
3687 LargeObjectRelationId, LargeObjectLOidPNIndexId,
3688 LargeObjectMetadataRelationId, LargeObjectMetadataOidIndexId);
3690 appendPQExpBuffer(loFrozenQry,
"SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
3691 "FROM pg_catalog.pg_class\n"
3692 "WHERE oid IN (%u, %u);\n",
3693 LargeObjectRelationId, LargeObjectLOidPNIndexId);
3697 ii_relfrozenxid =
PQfnumber(lo_res,
"relfrozenxid");
3698 ii_relminmxid =
PQfnumber(lo_res,
"relminmxid");
3699 ii_relfilenode =
PQfnumber(lo_res,
"relfilenode");
3702 appendPQExpBufferStr(loHorizonQry,
"\n-- For binary upgrade, set pg_largeobject relfrozenxid and relminmxid\n");
3703 appendPQExpBufferStr(lomHorizonQry,
"\n-- For binary upgrade, set pg_largeobject_metadata relfrozenxid and relminmxid\n");
3704 appendPQExpBufferStr(loOutQry,
"\n-- For binary upgrade, preserve pg_largeobject and index relfilenodes\n");
3705 appendPQExpBufferStr(lomOutQry,
"\n-- For binary upgrade, preserve pg_largeobject_metadata and index relfilenodes\n");
3716 if (oid == LargeObjectRelationId ||
3717 oid == LargeObjectLOidPNIndexId)
3719 horizonQry = loHorizonQry;
3724 horizonQry = lomHorizonQry;
3729 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
3730 "WHERE oid = %u;\n",
3735 if (oid == LargeObjectRelationId ||
3736 oid == LargeObjectMetadataRelationId)
3738 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
3740 else if (oid == LargeObjectLOidPNIndexId ||
3741 oid == LargeObjectMetadataOidIndexId)
3743 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
3748 "TRUNCATE pg_catalog.pg_largeobject;\n");
3750 "TRUNCATE pg_catalog.pg_largeobject_metadata;\n");
3759 .createStmt = loOutQry->
data));
3766 .createStmt = lomOutQry->
data));
3800 "WHERE setrole = 0 AND setdatabase = '%u'::oid",
3807 "DATABASE",
dbname, NULL, NULL,
3814 "FROM pg_db_role_setting s, pg_roles r "
3815 "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
3850 .createStmt = qry->
data));
3862 const char *stdstrings = AH->
std_strings ?
"on" :
"off";
3865 pg_log_info(
"saving \"standard_conforming_strings = %s\"",
3875 .createStmt = qry->
data));
3889 char **schemanames = NULL;
3890 int nschemanames = 0;
3901 "SELECT pg_catalog.current_schemas(false)");
3904 pg_fatal(
"could not parse result of current_schemas()");
3912 for (
i = 0;
i < nschemanames;
i++)
3929 .createStmt = qry->
data));
3966 "SELECT oid, lomowner, lomacl, "
3967 "acldefault('L', lomowner) AS acldefault "
3968 "FROM pg_largeobject_metadata "
3969 "ORDER BY lomowner, lomacl::pg_catalog.text, oid");
3974 i_lomowner =
PQfnumber(res,
"lomowner");
3976 i_acldefault =
PQfnumber(res,
"acldefault");
3988 for (
i = 0;
i < ntups;
i += n)
4001 if (strcmp(thisowner,
PQgetvalue(res,
i + n, i_lomowner)) != 0 ||
4002 strcmp(thisacl,
PQgetvalue(res,
i + n, i_lomacl)) != 0)
4016 snprintf(namebuf,
sizeof(namebuf),
"%u..%u", thisoid,
4019 snprintf(namebuf,
sizeof(namebuf),
"%u", thisoid);
4027 loinfo->
looids[0] = thisoid;
4029 for (
int k = 1; k < n; k++)
4036 extraID.
tableoid = LargeObjectRelationId;
4082 loinfo->
dobj.
dump &= ~DUMP_COMPONENT_DATA;
4119 for (
int i = 0;
i < loinfo->
numlos;
i++)
4126 .description =
"BLOB METADATA",
4128 .createStmt = cquery->
data,
4129 .dropStmt =
"-- dummy"));
4138 for (
int i = 0;
i < loinfo->
numlos;
i++)
4178 snprintf(tagbuf,
sizeof(tagbuf),
"LARGE OBJECTS %u..%u",
4182 "LARGE OBJECT", namebuf, NULL, NULL,
4188 "LARGE OBJECT", namebuf, NULL, NULL,
4209 for (
int i = 0;
i < loinfo->
numlos;
i++)
4218 pg_fatal(
"could not open large object %u: %s",
4228 pg_fatal(
"error reading large object %u: %s",
4259 int i_polpermissive;
4282 for (
i = 0;
i < numTables;
i++)
4291 if (tbinfo->
relkind != RELKIND_RELATION &&
4292 tbinfo->
relkind != RELKIND_PARTITIONED_TABLE)
4296 if (tbloids->
len > 1)
4317 polinfo->
dobj.namespace = tbinfo->
dobj.namespace;
4336 pg_log_info(
"reading row-level security policies");
4339 "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
4345 "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
4346 " 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, "
4347 "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
4348 "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
4349 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
4350 "JOIN pg_catalog.pg_policy pol ON (src.tbloid = pol.polrelid)",
4359 i_tableoid =
PQfnumber(res,
"tableoid");
4360 i_polrelid =
PQfnumber(res,
"polrelid");
4363 i_polpermissive =
PQfnumber(res,
"polpermissive");
4364 i_polroles =
PQfnumber(res,
"polroles");
4366 i_polwithcheck =
PQfnumber(res,
"polwithcheck");
4370 for (
j = 0;
j < ntups;
j++)
4382 polinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
4391 polinfo[
j].polroles = NULL;
4454 .namespace = polinfo->
dobj.namespace->dobj.
name,
4456 .description =
"ROW SECURITY",
4458 .createStmt = query->
data,
4466 if (polinfo->
polcmd ==
'*')
4468 else if (polinfo->
polcmd ==
'r')
4469 cmd =
" FOR SELECT";
4470 else if (polinfo->
polcmd ==
'a')
4471 cmd =
" FOR INSERT";
4472 else if (polinfo->
polcmd ==
'w')
4473 cmd =
" FOR UPDATE";
4474 else if (polinfo->
polcmd ==
'd')
4475 cmd =
" FOR DELETE";
4477 pg_fatal(
"unexpected policy command type: %c",
4513 .
namespace = polinfo->
dobj.namespace->dobj.
name,
4515 .description =
"POLICY",
4517 .createStmt = query->
data,
4518 .dropStmt = delqry->
data));
4548 int i_puballsequences;
4565 "p.pubowner, p.puballtables, p.pubinsert, "
4566 "p.pubupdate, p.pubdelete, ");
4597 i_tableoid =
PQfnumber(res,
"tableoid");
4600 i_pubowner =
PQfnumber(res,
"pubowner");
4601 i_puballtables =
PQfnumber(res,
"puballtables");
4602 i_puballsequences =
PQfnumber(res,
"puballsequences");
4603 i_pubinsert =
PQfnumber(res,
"pubinsert");
4604 i_pubupdate =
PQfnumber(res,
"pubupdate");
4605 i_pubdelete =
PQfnumber(res,
"pubdelete");
4606 i_pubtruncate =
PQfnumber(res,
"pubtruncate");
4607 i_pubviaroot =
PQfnumber(res,
"pubviaroot");
4608 i_pubgencols =
PQfnumber(res,
"pubgencols");
4612 for (
i = 0;
i < ntups;
i++)
4622 (strcmp(
PQgetvalue(res,
i, i_puballtables),
"t") == 0);
4624 (strcmp(
PQgetvalue(res,
i, i_puballsequences),
"t") == 0);
4626 (strcmp(
PQgetvalue(res,
i, i_pubinsert),
"t") == 0);
4628 (strcmp(
PQgetvalue(res,
i, i_pubupdate),
"t") == 0);
4630 (strcmp(
PQgetvalue(res,
i, i_pubdelete),
"t") == 0);
4632 (strcmp(
PQgetvalue(res,
i, i_pubtruncate),
"t") == 0);
4634 (strcmp(
PQgetvalue(res,
i, i_pubviaroot),
"t") == 0);
4731 .description =
"PUBLICATION",
4733 .createStmt = query->
data,
4734 .dropStmt = delq->
data));
4777 "SELECT tableoid, oid, pnpubid, pnnspid "
4778 "FROM pg_catalog.pg_publication_namespace");
4783 i_tableoid =
PQfnumber(res,
"tableoid");
4792 for (
i = 0;
i < ntups;
i++)
4804 if (pubinfo == NULL)
4807 if (nspinfo == NULL)
4816 pubsinfo[
j].
dobj.namespace = nspinfo->
dobj.namespace;
4860 "SELECT tableoid, oid, prpubid, prrelid, "
4861 "pg_catalog.pg_get_expr(prqual, prrelid) AS prrelqual, "
4863 " WHEN pr.prattrs IS NOT NULL THEN\n"
4864 " (SELECT array_agg(attname)\n"
4866 " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
4867 " pg_catalog.pg_attribute\n"
4868 " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
4869 " ELSE NULL END) prattrs "
4870 "FROM pg_catalog.pg_publication_rel pr");
4873 "SELECT tableoid, oid, prpubid, prrelid, "
4874 "NULL AS prrelqual, NULL AS prattrs "
4875 "FROM pg_catalog.pg_publication_rel");
4880 i_tableoid =
PQfnumber(res,
"tableoid");
4884 i_prrelqual =
PQfnumber(res,
"prrelqual");
4891 for (
i = 0;
i < ntups;
i++)
4903 if (pubinfo == NULL)
4911 pubrinfo[
j].dobj.catId.tableoid =
4915 pubrinfo[
j].dobj.namespace = tbinfo->
dobj.namespace;
4916 pubrinfo[
j].dobj.name = tbinfo->
dobj.
name;
4917 pubrinfo[
j].publication = pubinfo;
4918 pubrinfo[
j].pubtable = tbinfo;
4920 pubrinfo[
j].pubrelqual = NULL;
4931 &attnames, &nattnames))
4932 pg_fatal(
"could not parse %s array",
"prattrs");
4934 for (
int k = 0; k < nattnames; k++)
4941 pubrinfo[
j].pubrattrs = attribs->
data;
4946 pubrinfo[
j].pubrattrs = NULL;
4989 .
namespace = schemainfo->
dobj.
name,
4991 .description =
"PUBLICATION TABLES IN SCHEMA",
4993 .createStmt = query->
data));
5027 if (pubrinfo->pubrattrs)
5030 if (pubrinfo->pubrelqual)
5049 ArchiveEntry(fout, pubrinfo->dobj.catId, pubrinfo->dobj.dumpId,
5051 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
5053 .description =
"PUBLICATION TABLE",
5055 .createStmt = query->
data));
5074 if (
val && strcmp(
val,
"on") == 0)
5092 "SELECT set_config(name, '%s', false) "
5094 "WHERE name = 'restrict_nonsystem_relation_kind'",
5119 int i_subtwophasestate;
5120 int i_subdisableonerr;
5121 int i_subpasswordrequired;
5122 int i_subrunasowner;
5125 int i_subsynccommit;
5126 int i_subpublications;
5128 int i_suboriginremotelsn;
5131 int i_subretaindeadtuples;
5132 int i_submaxretention;
5144 "SELECT count(*) FROM pg_subscription "
5145 "WHERE subdbid = (SELECT oid FROM pg_database"
5146 " WHERE datname = current_database())",
5150 pg_log_warning(
"subscriptions not dumped because current user is not a superuser");
5159 "SELECT s.tableoid, s.oid, s.subname,\n"
5161 " s.subconninfo, s.subslotname, s.subsynccommit,\n"
5162 " s.subpublications,\n");
5176 " s.subtwophasestate,\n"
5177 " s.subdisableonerr,\n");
5180 " '%c' AS subtwophasestate,\n"
5181 " false AS subdisableonerr,\n",
5182 LOGICALREP_TWOPHASE_STATE_DISABLED);
5186 " s.subpasswordrequired,\n"
5187 " s.subrunasowner,\n"
5191 " 't' AS subpasswordrequired,\n"
5192 " 't' AS subrunasowner,\n"
5193 " '%s' AS suborigin,\n",
5194 LOGICALREP_ORIGIN_ANY);
5198 " s.subenabled,\n");
5201 " false AS subenabled,\n");
5205 " s.subfailover,\n");
5208 " false AS subfailover,\n");
5212 " s.subretaindeadtuples,\n");
5215 " false AS subretaindeadtuples,\n");
5219 " s.submaxretention\n");
5222 " 0 AS submaxretention\n");
5225 "FROM pg_subscription s\n");
5229 "LEFT JOIN pg_catalog.pg_replication_origin_status o \n"
5230 " ON o.external_id = 'pg_' || s.oid::text \n");
5233 "WHERE s.subdbid = (SELECT oid FROM pg_database\n"
5234 " WHERE datname = current_database())");
5244 i_tableoid =
PQfnumber(res,
"tableoid");
5247 i_subowner =
PQfnumber(res,
"subowner");
5248 i_subenabled =
PQfnumber(res,
"subenabled");
5249 i_subbinary =
PQfnumber(res,
"subbinary");
5250 i_substream =
PQfnumber(res,
"substream");
5251 i_subtwophasestate =
PQfnumber(res,
"subtwophasestate");
5252 i_subdisableonerr =
PQfnumber(res,
"subdisableonerr");
5253 i_subpasswordrequired =
PQfnumber(res,
"subpasswordrequired");
5254 i_subrunasowner =
PQfnumber(res,
"subrunasowner");
5255 i_subfailover =
PQfnumber(res,
"subfailover");
5256 i_subretaindeadtuples =
PQfnumber(res,
"subretaindeadtuples");
5257 i_submaxretention =
PQfnumber(res,
"submaxretention");
5258 i_subconninfo =
PQfnumber(res,
"subconninfo");
5259 i_subslotname =
PQfnumber(res,
"subslotname");
5260 i_subsynccommit =
PQfnumber(res,
"subsynccommit");
5261 i_subpublications =
PQfnumber(res,
"subpublications");
5262 i_suborigin =
PQfnumber(res,
"suborigin");
5263 i_suboriginremotelsn =
PQfnumber(res,
"suboriginremotelsn");
5267 for (
i = 0;
i < ntups;
i++)
5278 (strcmp(
PQgetvalue(res,
i, i_subenabled),
"t") == 0);
5280 (strcmp(
PQgetvalue(res,
i, i_subbinary),
"t") == 0);
5284 (strcmp(
PQgetvalue(res,
i, i_subdisableonerr),
"t") == 0);
5286 (strcmp(
PQgetvalue(res,
i, i_subpasswordrequired),
"t") == 0);
5288 (strcmp(
PQgetvalue(res,
i, i_subrunasowner),
"t") == 0);
5290 (strcmp(
PQgetvalue(res,
i, i_subfailover),
"t") == 0);
5292 (strcmp(
PQgetvalue(res,
i, i_subretaindeadtuples),
"t") == 0);
5345 "SELECT srsubid, srrelid, srsubstate, srsublsn "
5346 "FROM pg_catalog.pg_subscription_rel "
5356 i_srsubstate =
PQfnumber(res,
"srsubstate");
5357 i_srsublsn =
PQfnumber(res,
"srsublsn");
5360 for (
int i = 0;
i < ntups;
i++)
5370 if (cur_srsubid != last_srsubid)
5373 if (subinfo == NULL)
5374 pg_fatal(
"subscription with OID %u does not exist", cur_srsubid);
5376 last_srsubid = cur_srsubid;
5380 if (tblinfo == NULL)
5381 pg_fatal(
"failed sanity check, relation with OID %u not found",
5438 "\n-- For binary upgrade, must preserve the subscriber table.\n");
5440 "SELECT pg_catalog.binary_upgrade_add_sub_rel_state(");
5467 .description =
"SUBSCRIPTION TABLE",
5469 .createStmt = query->
data));
5489 char **pubnames = NULL;
5511 pg_fatal(
"could not parse %s array",
"subpublications");
5514 for (
i = 0;
i < npubnames;
i++)
5522 appendPQExpBuffer(query,
" PUBLICATION %s WITH (connect = false, slot_name = ", publications->
data);
5531 if (subinfo->
substream == LOGICALREP_STREAM_ON)
5533 else if (subinfo->
substream == LOGICALREP_STREAM_PARALLEL)
5585 "\n-- For binary upgrade, must preserve the remote_lsn for the subscriber's replication origin.\n");
5587 "SELECT pg_catalog.binary_upgrade_replorigin_advance(");
5599 "\n-- For binary upgrade, must preserve the subscriber's running state.\n");
5608 .description =
"SUBSCRIPTION",
5610 .createStmt = query->
data,
5611 .dropStmt = delq->
data));
5639 const char *catalog,
5640 const char *keyword,
5641 const char *objname)
5658 "FROM pg_catalog.pg_depend d, pg_catalog.pg_extension e "
5659 "WHERE d.refobjid = e.oid AND classid = '%s'::pg_catalog.regclass "
5660 "AND objid = '%u'::pg_catalog.oid AND deptype = 'x' "
5661 "AND refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass",
5667 for (
i = 0;
i < ntups;
i++)
5697 ++next_possible_free_oid;
5699 "SELECT EXISTS(SELECT 1 "
5700 "FROM pg_catalog.pg_type "
5701 "WHERE oid = '%u'::pg_catalog.oid);",
5702 next_possible_free_oid);
5708 return next_possible_free_oid;
5715 bool force_array_type,
5716 bool include_multirange_type)
5720 Oid pg_type_array_oid;
5721 Oid pg_type_multirange_oid;
5722 Oid pg_type_multirange_array_oid;
5727 "SELECT pg_catalog.binary_upgrade_set_next_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5732 pg_type_array_oid =
tinfo->typarray;
5736 if (!
OidIsValid(pg_type_array_oid) && force_array_type)
5742 "\n-- For binary upgrade, must preserve pg_type array oid\n");
5744 "SELECT pg_catalog.binary_upgrade_set_next_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5751 if (include_multirange_type)
5756 "SELECT t.oid, t.typarray "
5757 "FROM pg_catalog.pg_type t "
5758 "JOIN pg_catalog.pg_range r "
5759 "ON t.oid = r.rngmultitypid "
5760 "WHERE r.rngtypid = '%u'::pg_catalog.oid;",
5777 "\n-- For binary upgrade, must preserve multirange pg_type oid\n");
5779 "SELECT pg_catalog.binary_upgrade_set_next_multirange_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5780 pg_type_multirange_oid);
5782 "\n-- For binary upgrade, must preserve multirange pg_type array oid\n");
5784 "SELECT pg_catalog.binary_upgrade_set_next_multirange_array_pg_type_oid('%u'::pg_catalog.oid);\n\n",
5785 pg_type_multirange_array_oid);
5800 pg_type_oid,
false,
false);
5828 query =
"SELECT c.oid, c.relkind, c.relfilenode, c.reltoastrelid, "
5829 "ct.relfilenode, i.indexrelid, cti.relfilenode "
5830 "FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_index i "
5831 "ON (c.reltoastrelid = i.indrelid AND i.indisvalid) "
5832 "LEFT JOIN pg_catalog.pg_class ct ON (c.reltoastrelid = ct.oid) "
5833 "LEFT JOIN pg_catalog.pg_class AS cti ON (i.indexrelid = cti.oid) "
5876 key.oid = pg_class_oid;
5882 "\n-- For binary upgrade, must preserve pg_class oids and relfilenodes\n");
5884 if (entry->
relkind != RELKIND_INDEX &&
5885 entry->
relkind != RELKIND_PARTITIONED_INDEX)
5888 "SELECT pg_catalog.binary_upgrade_set_next_heap_pg_class_oid('%u'::pg_catalog.oid);\n",
5897 entry->
relkind != RELKIND_PARTITIONED_TABLE)
5899 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
5907 entry->
relkind != RELKIND_PARTITIONED_TABLE)
5910 "SELECT pg_catalog.binary_upgrade_set_next_toast_pg_class_oid('%u'::pg_catalog.oid);\n",
5913 "SELECT pg_catalog.binary_upgrade_set_next_toast_relfilenode('%u'::pg_catalog.oid);\n",
5918 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5921 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5929 "SELECT pg_catalog.binary_upgrade_set_next_index_pg_class_oid('%u'::pg_catalog.oid);\n",
5932 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
5949 const char *objtype,
5950 const char *objname,
5951 const char *objnamespace)
5973 pg_fatal(
"could not find parent extension for %s %s",
5977 "\n-- For binary upgrade, handle extension membership the hard way\n");
5981 if (objnamespace && *objnamespace)
6014 "acldefault('n', n.nspowner) AS acldefault "
6015 "FROM pg_namespace n");
6023 i_tableoid =
PQfnumber(res,
"tableoid");
6026 i_nspowner =
PQfnumber(res,
"nspowner");
6028 i_acldefault =
PQfnumber(res,
"acldefault");
6030 for (
i = 0;
i < ntups;
i++)
6032 const char *nspowner;
6070 if (strcmp(nsinfo[
i].dobj.name,
"public") == 0)
6111 pg_fatal(
"schema with OID %u does not exist", nsoid);
6135 int i_extrelocatable;
6143 "x.extname, n.nspname, x.extrelocatable, x.extversion, x.extconfig, x.extcondition "
6144 "FROM pg_extension x "
6145 "JOIN pg_namespace n ON n.oid = x.extnamespace");
6155 i_tableoid =
PQfnumber(res,
"tableoid");
6159 i_extrelocatable =
PQfnumber(res,
"extrelocatable");
6160 i_extversion =
PQfnumber(res,
"extversion");
6161 i_extconfig =
PQfnumber(res,
"extconfig");
6162 i_extcondition =
PQfnumber(res,
"extcondition");
6164 for (
i = 0;
i < ntups;
i++)
6185 *numExtensions = ntups;
6237 "typnamespace, typacl, "
6238 "acldefault('T', typowner) AS acldefault, "
6240 "typelem, typrelid, typarray, "
6241 "CASE WHEN typrelid = 0 THEN ' '::\"char\" "
6242 "ELSE (SELECT relkind FROM pg_class WHERE oid = typrelid) END AS typrelkind, "
6243 "typtype, typisdefined, "
6244 "typname[0] = '_' AND typelem != 0 AND "
6245 "(SELECT typarray FROM pg_type te WHERE oid = pg_type.typelem) = oid AS isarray "
6254 i_tableoid =
PQfnumber(res,
"tableoid");
6257 i_typnamespace =
PQfnumber(res,
"typnamespace");
6259 i_acldefault =
PQfnumber(res,
"acldefault");
6260 i_typowner =
PQfnumber(res,
"typowner");
6262 i_typrelid =
PQfnumber(res,
"typrelid");
6263 i_typrelkind =
PQfnumber(res,
"typrelkind");
6265 i_typisdefined =
PQfnumber(res,
"typisdefined");
6267 i_typarray =
PQfnumber(res,
"typarray");
6269 for (
i = 0;
i < ntups;
i++)
6276 tyinfo[
i].
dobj.namespace =
6290 if (strcmp(
PQgetvalue(res,
i, i_typisdefined),
"t") == 0)
6295 if (strcmp(
PQgetvalue(res,
i, i_isarray),
"t") == 0)
6302 if (tyinfo[
i].typtype == TYPTYPE_MULTIRANGE)
6321 tyinfo[
i].
typtype == TYPTYPE_DOMAIN)
6335 (tyinfo[
i].
typtype == TYPTYPE_BASE ||
6336 tyinfo[
i].
typtype == TYPTYPE_RANGE))
6343 stinfo->
dobj.namespace = tyinfo[
i].
dobj.namespace;
6394 "oprcode::oid AS oprcode "
6395 "FROM pg_operator");
6403 i_tableoid =
PQfnumber(res,
"tableoid");
6406 i_oprnamespace =
PQfnumber(res,
"oprnamespace");
6407 i_oprowner =
PQfnumber(res,
"oprowner");
6410 i_oprright =
PQfnumber(res,
"oprright");
6413 for (
i = 0;
i < ntups;
i++)
6420 oprinfo[
i].
dobj.namespace =
6452 int i_collnamespace;
6467 "FROM pg_collation");
6475 i_tableoid =
PQfnumber(res,
"tableoid");
6477 i_collname =
PQfnumber(res,
"collname");
6478 i_collnamespace =
PQfnumber(res,
"collnamespace");
6479 i_collowner =
PQfnumber(res,
"collowner");
6480 i_collencoding =
PQfnumber(res,
"collencoding");
6482 for (
i = 0;
i < ntups;
i++)
6489 collinfo[
i].
dobj.namespace =
6531 "FROM pg_conversion");
6539 i_tableoid =
PQfnumber(res,
"tableoid");
6542 i_connamespace =
PQfnumber(res,
"connamespace");
6543 i_conowner =
PQfnumber(res,
"conowner");
6545 for (
i = 0;
i < ntups;
i++)
6552 convinfo[
i].
dobj.namespace =
6599 "amhandler::pg_catalog.regproc AS amhandler ");
6602 "'i'::pg_catalog.\"char\" AS amtype, "
6603 "'-'::pg_catalog.regproc AS amhandler ");
6612 i_tableoid =
PQfnumber(res,
"tableoid");
6615 i_amhandler =
PQfnumber(res,
"amhandler");
6618 for (
i = 0;
i < ntups;
i++)
6625 aminfo[
i].
dobj.namespace = NULL;
6674 i_tableoid =
PQfnumber(res,
"tableoid");
6676 i_opcmethod =
PQfnumber(res,
"opcmethod");
6678 i_opcnamespace =
PQfnumber(res,
"opcnamespace");
6679 i_opcowner =
PQfnumber(res,
"opcowner");
6681 for (
i = 0;
i < ntups;
i++)
6688 opcinfo[
i].
dobj.namespace =
6731 "FROM pg_opfamily");
6739 i_tableoid =
PQfnumber(res,
"tableoid");
6742 i_opfmethod =
PQfnumber(res,
"opfmethod");
6743 i_opfnamespace =
PQfnumber(res,
"opfnamespace");
6744 i_opfowner =
PQfnumber(res,
"opfowner");
6746 for (
i = 0;
i < ntups;
i++)
6753 opfinfo[
i].
dobj.namespace =
6796 const char *agg_check;
6798 agg_check = (fout->
remoteVersion >= 110000 ?
"p.prokind = 'a'"
6802 "p.proname AS aggname, "
6803 "p.pronamespace AS aggnamespace, "
6804 "p.pronargs, p.proargtypes, "
6806 "p.proacl AS aggacl, "
6807 "acldefault('f', p.proowner) AS acldefault "
6809 "LEFT JOIN pg_init_privs pip ON "
6810 "(p.oid = pip.objoid "
6811 "AND pip.classoid = 'pg_proc'::regclass "
6812 "AND pip.objsubid = 0) "
6814 "p.pronamespace != "
6815 "(SELECT oid FROM pg_namespace "
6816 "WHERE nspname = 'pg_catalog') OR "
6817 "p.proacl IS DISTINCT FROM pip.initprivs",
6821 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6822 "classid = 'pg_proc'::regclass AND "
6823 "objid = p.oid AND "
6824 "refclassid = 'pg_extension'::regclass AND "
6831 "pronamespace AS aggnamespace, "
6832 "pronargs, proargtypes, "
6834 "proacl AS aggacl, "
6835 "acldefault('f', proowner) AS acldefault "
6837 "WHERE proisagg AND ("
6839 "(SELECT oid FROM pg_namespace "
6840 "WHERE nspname = 'pg_catalog')");
6843 " OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6844 "classid = 'pg_proc'::regclass AND "
6845 "objid = p.oid AND "
6846 "refclassid = 'pg_extension'::regclass AND "
6857 i_tableoid =
PQfnumber(res,
"tableoid");
6860 i_aggnamespace =
PQfnumber(res,
"aggnamespace");
6861 i_pronargs =
PQfnumber(res,
"pronargs");
6862 i_proargtypes =
PQfnumber(res,
"proargtypes");
6863 i_proowner =
PQfnumber(res,
"proowner");
6865 i_acldefault =
PQfnumber(res,
"acldefault");
6867 for (
i = 0;
i < ntups;
i++)
6869 agginfo[
i].aggfn.dobj.objType =
DO_AGG;
6874 agginfo[
i].aggfn.dobj.namespace =
6878 agginfo[
i].aggfn.dacl.privtype = 0;
6879 agginfo[
i].aggfn.dacl.initprivs = NULL;
6883 agginfo[
i].aggfn.nargs = atoi(
PQgetvalue(res,
i, i_pronargs));
6884 if (agginfo[
i].aggfn.nargs == 0)
6885 agginfo[
i].aggfn.argtypes = NULL;
6888 agginfo[
i].aggfn.argtypes = (
Oid *)
pg_malloc(agginfo[
i].aggfn.nargs *
sizeof(
Oid));
6890 agginfo[
i].aggfn.argtypes,
6891 agginfo[
i].aggfn.nargs);
6893 agginfo[
i].aggfn.postponed_def =
false;
6956 const char *not_agg_check;
6958 not_agg_check = (fout->
remoteVersion >= 110000 ?
"p.prokind <> 'a'"
6959 :
"NOT p.proisagg");
6962 "SELECT p.tableoid, p.oid, p.proname, p.prolang, "
6963 "p.pronargs, p.proargtypes, p.prorettype, "
6965 "acldefault('f', p.proowner) AS acldefault, "
6969 "LEFT JOIN pg_init_privs pip ON "
6970 "(p.oid = pip.objoid "
6971 "AND pip.classoid = 'pg_proc'::regclass "
6972 "AND pip.objsubid = 0) "
6974 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
6975 "WHERE classid = 'pg_proc'::regclass AND "
6976 "objid = p.oid AND deptype = 'i')"
6978 "\n pronamespace != "
6979 "(SELECT oid FROM pg_namespace "
6980 "WHERE nspname = 'pg_catalog')"
6981 "\n OR EXISTS (SELECT 1 FROM pg_cast"
6982 "\n WHERE pg_cast.oid > %u "
6983 "\n AND p.oid = pg_cast.castfunc)"
6984 "\n OR EXISTS (SELECT 1 FROM pg_transform"
6985 "\n WHERE pg_transform.oid > %u AND "
6986 "\n (p.oid = pg_transform.trffromsql"
6987 "\n OR p.oid = pg_transform.trftosql))",
6993 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
6994 "classid = 'pg_proc'::regclass AND "
6995 "objid = p.oid AND "
6996 "refclassid = 'pg_extension'::regclass AND "
6999 "\n OR p.proacl IS DISTINCT FROM pip.initprivs");
7005 "SELECT tableoid, oid, proname, prolang, "
7006 "pronargs, proargtypes, prorettype, proacl, "
7007 "acldefault('f', proowner) AS acldefault, "
7011 "WHERE NOT proisagg"
7012 "\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
7013 "WHERE classid = 'pg_proc'::regclass AND "
7014 "objid = p.oid AND deptype = 'i')"
7016 "\n pronamespace != "
7017 "(SELECT oid FROM pg_namespace "
7018 "WHERE nspname = 'pg_catalog')"
7019 "\n OR EXISTS (SELECT 1 FROM pg_cast"
7020 "\n WHERE pg_cast.oid > '%u'::oid"
7021 "\n AND p.oid = pg_cast.castfunc)",
7026 "\n OR EXISTS (SELECT 1 FROM pg_transform"
7027 "\n WHERE pg_transform.oid > '%u'::oid"
7028 "\n AND (p.oid = pg_transform.trffromsql"
7029 "\n OR p.oid = pg_transform.trftosql))",
7034 "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
7035 "classid = 'pg_proc'::regclass AND "
7036 "objid = p.oid AND "
7037 "refclassid = 'pg_extension'::regclass AND "
7048 i_tableoid =
PQfnumber(res,
"tableoid");
7051 i_pronamespace =
PQfnumber(res,
"pronamespace");
7052 i_proowner =
PQfnumber(res,
"proowner");
7054 i_pronargs =
PQfnumber(res,
"pronargs");
7055 i_proargtypes =
PQfnumber(res,
"proargtypes");
7056 i_prorettype =
PQfnumber(res,
"prorettype");
7058 i_acldefault =
PQfnumber(res,
"acldefault");
7060 for (
i = 0;
i < ntups;
i++)
7067 finfo[
i].
dobj.namespace =
7077 if (finfo[
i].nargs == 0)
7083 finfo[
i].argtypes, finfo[
i].nargs);
7109 char *reltuples,
int32 relallvisible,
7110 int32 relallfrozen,
char relkind,
7111 char **indAttNames,
int nindAttNames)
7116 if ((relkind == RELKIND_RELATION) ||
7117 (relkind == RELKIND_PARTITIONED_TABLE) ||
7118 (relkind == RELKIND_INDEX) ||
7119 (relkind == RELKIND_PARTITIONED_INDEX) ||
7120 (relkind == RELKIND_MATVIEW ||
7121 relkind == RELKIND_FOREIGN_TABLE))
7136 dobj->namespace = rel->namespace;
7157 case RELKIND_RELATION:
7158 case RELKIND_PARTITIONED_TABLE:
7159 case RELKIND_MATVIEW:
7160 case RELKIND_FOREIGN_TABLE:
7164 case RELKIND_PARTITIONED_INDEX:
7168 pg_fatal(
"cannot dump statistics for relation kind \"%c\"",
7205 int i_relallvisible;
7210 int i_reltablespace;
7212 int i_relhastriggers;
7213 int i_relpersistence;
7214 int i_relispopulated;
7217 int i_relforcerowsec;
7219 int i_toastfrozenxid;
7225 int i_toastreloptions;
7227 int i_foreignserver;
7229 int i_is_identity_sequence;
7252 "SELECT c.tableoid, c.oid, c.relname, "
7253 "c.relnamespace, c.relkind, c.reltype, "
7256 "c.relhasindex, c.relhasrules, c.relpages, "
7257 "c.reltuples, c.relallvisible, ");
7265 "c.relhastriggers, c.relpersistence, "
7268 "acldefault(CASE WHEN c.relkind = " CppAsString2(RELKIND_SEQUENCE)
7269 " THEN 's'::\"char\" ELSE 'r'::\"char\" END, c.relowner) AS acldefault, "
7270 "CASE WHEN c.relkind = " CppAsString2(RELKIND_FOREIGN_TABLE)
" THEN "
7271 "(SELECT ftserver FROM pg_catalog.pg_foreign_table WHERE ftrelid = c.oid) "
7272 "ELSE 0 END AS foreignserver, "
7273 "c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, "
7275 "tc.relpages AS toastpages, "
7276 "tc.reloptions AS toast_reloptions, "
7277 "d.refobjid AS owning_tab, "
7278 "d.refobjsubid AS owning_col, "
7279 "tsp.spcname AS reltablespace, ");
7283 "false AS relhasoids, ");
7290 "c.relispopulated, ");
7293 "'t' as relispopulated, ");
7297 "c.relreplident, ");
7300 "'d' AS relreplident, ");
7304 "c.relrowsecurity, c.relforcerowsecurity, ");
7307 "false AS relrowsecurity, "
7308 "false AS relforcerowsecurity, ");
7312 "c.relminmxid, tc.relminmxid AS tminmxid, ");
7315 "0 AS relminmxid, 0 AS tminmxid, ");
7319 "array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, "
7320 "CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text "
7321 "WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, ");
7324 "c.reloptions, NULL AS checkoption, ");
7331 "NULL AS amname, ");
7335 "(d.deptype = 'i') IS TRUE AS is_identity_sequence, ");
7338 "false AS is_identity_sequence, ");
7342 "c.relispartition AS ispartition ");
7345 "false AS ispartition ");
7354 "\nFROM pg_class c\n"
7355 "LEFT JOIN pg_depend d ON "
7357 "d.classid = 'pg_class'::regclass AND d.objid = c.oid AND "
7358 "d.objsubid = 0 AND "
7359 "d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))\n"
7360 "LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)\n");
7367 "LEFT JOIN pg_am am ON (c.relam = am.oid)\n");
7375 "LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid"
7377 " AND c.relkind <> " CppAsString2(RELKIND_PARTITIONED_TABLE)
")\n");
7390 "WHERE c.relkind IN ("
7417 i_reltableoid =
PQfnumber(res,
"tableoid");
7420 i_relnamespace =
PQfnumber(res,
"relnamespace");
7423 i_relowner =
PQfnumber(res,
"relowner");
7424 i_relchecks =
PQfnumber(res,
"relchecks");
7425 i_relhasindex =
PQfnumber(res,
"relhasindex");
7426 i_relhasrules =
PQfnumber(res,
"relhasrules");
7427 i_relpages =
PQfnumber(res,
"relpages");
7428 i_reltuples =
PQfnumber(res,
"reltuples");
7429 i_relallvisible =
PQfnumber(res,
"relallvisible");
7430 i_relallfrozen =
PQfnumber(res,
"relallfrozen");
7431 i_toastpages =
PQfnumber(res,
"toastpages");
7432 i_owning_tab =
PQfnumber(res,
"owning_tab");
7433 i_owning_col =
PQfnumber(res,
"owning_col");
7434 i_reltablespace =
PQfnumber(res,
"reltablespace");
7435 i_relhasoids =
PQfnumber(res,
"relhasoids");
7436 i_relhastriggers =
PQfnumber(res,
"relhastriggers");
7437 i_relpersistence =
PQfnumber(res,
"relpersistence");
7438 i_relispopulated =
PQfnumber(res,
"relispopulated");
7439 i_relreplident =
PQfnumber(res,
"relreplident");
7440 i_relrowsec =
PQfnumber(res,
"relrowsecurity");
7441 i_relforcerowsec =
PQfnumber(res,
"relforcerowsecurity");
7442 i_relfrozenxid =
PQfnumber(res,
"relfrozenxid");
7443 i_toastfrozenxid =
PQfnumber(res,
"tfrozenxid");
7445 i_relminmxid =
PQfnumber(res,
"relminmxid");
7446 i_toastminmxid =
PQfnumber(res,
"tminmxid");
7447 i_reloptions =
PQfnumber(res,
"reloptions");
7448 i_checkoption =
PQfnumber(res,
"checkoption");
7449 i_toastreloptions =
PQfnumber(res,
"toast_reloptions");
7450 i_reloftype =
PQfnumber(res,
"reloftype");
7451 i_foreignserver =
PQfnumber(res,
"foreignserver");
7453 i_is_identity_sequence =
PQfnumber(res,
"is_identity_sequence");
7455 i_acldefault =
PQfnumber(res,
"acldefault");
7456 i_ispartition =
PQfnumber(res,
"ispartition");
7475 for (
i = 0;
i < ntups;
i++)
7485 tblinfo[
i].
dobj.namespace =
7545 if (tblinfo[
i].relkind == RELKIND_COMPOSITE_TYPE)
7578 if (tblinfo[
i].interesting)
7583 tblinfo[
i].relpages,
7585 relallvisible, relallfrozen,
7586 tblinfo[
i].relkind, NULL, 0);
7587 if (tblinfo[
i].relkind == RELKIND_MATVIEW)
7588 tblinfo[
i].
stats = stats;
7607 (tblinfo[
i].
relkind == RELKIND_RELATION ||
7608 tblinfo[
i].
relkind == RELKIND_PARTITIONED_TABLE))
7615 if (query->
len == 0)
7624 if (query->
len >= 100000)
7635 if (query->
len != 0)
7670 for (
i = 0;
i < numTables;
i++)
7679 if (owning_tab == NULL)
7680 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
7745 *numInherits = ntups;
7749 i_inhrelid =
PQfnumber(res,
"inhrelid");
7750 i_inhparent =
PQfnumber(res,
"inhparent");
7752 for (
i = 0;
i < ntups;
i++)
7807 "SELECT partrelid FROM pg_partitioned_table WHERE\n"
7808 "(SELECT c.oid FROM pg_opclass c JOIN pg_am a "
7809 "ON c.opcmethod = a.oid\n"
7810 "WHERE opcname = 'enum_ops' "
7811 "AND opcnamespace = 'pg_catalog'::regnamespace "
7812 "AND amname = 'hash') = ANY(partclass)");
7818 for (
int i = 0;
i < ntups;
i++)
7825 pg_fatal(
"failed sanity check, table OID %u appearing in pg_partitioned_table not found",
7866 i_indnullsnotdistinct,
7890 for (
int i = 0;
i < numTables;
i++)
7904 if (tbloids->
len > 1)
7911 "SELECT t.tableoid, t.oid, i.indrelid, "
7912 "t.relname AS indexname, "
7913 "t.relpages, t.reltuples, t.relallvisible, ");
7921 "pg_catalog.pg_get_indexdef(i.indexrelid) AS indexdef, "
7922 "i.indkey, i.indisclustered, "
7923 "c.contype, c.conname, "
7924 "c.condeferrable, c.condeferred, "
7925 "c.tableoid AS contableoid, "
7927 "pg_catalog.pg_get_constraintdef(c.oid, false) AS condef, "
7928 "CASE WHEN i.indexprs IS NOT NULL THEN "
7929 "(SELECT pg_catalog.array_agg(attname ORDER BY attnum)"
7930 " FROM pg_catalog.pg_attribute "
7931 " WHERE attrelid = i.indexrelid) "
7932 "ELSE NULL END AS indattnames, "
7933 "(SELECT spcname FROM pg_catalog.pg_tablespace s WHERE s.oid = t.reltablespace) AS tablespace, "
7934 "t.reloptions AS indreloptions, ");
7939 "i.indisreplident, ");
7942 "false AS indisreplident, ");
7946 "inh.inhparent AS parentidx, "
7947 "i.indnkeyatts AS indnkeyatts, "
7948 "i.indnatts AS indnatts, "
7949 "(SELECT pg_catalog.array_agg(attnum ORDER BY attnum) "
7950 " FROM pg_catalog.pg_attribute "
7951 " WHERE attrelid = i.indexrelid AND "
7952 " attstattarget >= 0) AS indstatcols, "
7953 "(SELECT pg_catalog.array_agg(attstattarget ORDER BY attnum) "
7954 " FROM pg_catalog.pg_attribute "
7955 " WHERE attrelid = i.indexrelid AND "
7956 " attstattarget >= 0) AS indstatvals, ");
7960 "i.indnatts AS indnkeyatts, "
7961 "i.indnatts AS indnatts, "
7962 "'' AS indstatcols, "
7963 "'' AS indstatvals, ");
7967 "i.indnullsnotdistinct, ");
7970 "false AS indnullsnotdistinct, ");
7977 "NULL AS conperiod ");
7991 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
7992 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
7993 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
7994 "JOIN pg_catalog.pg_class t2 ON (t2.oid = i.indrelid) "
7995 "LEFT JOIN pg_catalog.pg_constraint c "
7996 "ON (i.indrelid = c.conrelid AND "
7997 "i.indexrelid = c.conindid AND "
7998 "c.contype IN ('p','u','x')) "
7999 "LEFT JOIN pg_catalog.pg_inherits inh "
8000 "ON (inh.inhrelid = indexrelid) "
8001 "WHERE (i.indisvalid OR t2.relkind = 'p') "
8003 "ORDER BY i.indrelid, indexname",
8013 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8014 "JOIN pg_catalog.pg_index i ON (src.tbloid = i.indrelid) "
8015 "JOIN pg_catalog.pg_class t ON (t.oid = i.indexrelid) "
8016 "LEFT JOIN pg_catalog.pg_constraint c "
8017 "ON (i.indrelid = c.conrelid AND "
8018 "i.indexrelid = c.conindid AND "
8019 "c.contype IN ('p','u','x')) "
8020 "WHERE i.indisvalid AND i.indisready "
8021 "ORDER BY i.indrelid, indexname",
8029 i_tableoid =
PQfnumber(res,
"tableoid");
8031 i_indrelid =
PQfnumber(res,
"indrelid");
8032 i_indexname =
PQfnumber(res,
"indexname");
8033 i_relpages =
PQfnumber(res,
"relpages");
8034 i_reltuples =
PQfnumber(res,
"reltuples");
8035 i_relallvisible =
PQfnumber(res,
"relallvisible");
8036 i_relallfrozen =
PQfnumber(res,
"relallfrozen");
8037 i_parentidx =
PQfnumber(res,
"parentidx");
8038 i_indexdef =
PQfnumber(res,
"indexdef");
8039 i_indnkeyatts =
PQfnumber(res,
"indnkeyatts");
8040 i_indnatts =
PQfnumber(res,
"indnatts");
8042 i_indisclustered =
PQfnumber(res,
"indisclustered");
8043 i_indisreplident =
PQfnumber(res,
"indisreplident");
8044 i_indnullsnotdistinct =
PQfnumber(res,
"indnullsnotdistinct");
8047 i_condeferrable =
PQfnumber(res,
"condeferrable");
8048 i_condeferred =
PQfnumber(res,
"condeferred");
8049 i_conperiod =
PQfnumber(res,
"conperiod");
8050 i_contableoid =
PQfnumber(res,
"contableoid");
8053 i_indattnames =
PQfnumber(res,
"indattnames");
8054 i_tablespace =
PQfnumber(res,
"tablespace");
8055 i_indreloptions =
PQfnumber(res,
"indreloptions");
8056 i_indstatcols =
PQfnumber(res,
"indstatcols");
8057 i_indstatvals =
PQfnumber(res,
"indstatvals");
8066 for (
int j = 0;
j < ntups;)
8070 char **indAttNames = NULL;
8071 int nindAttNames = 0;
8075 for (numinds = 1; numinds < ntups -
j; numinds++)
8083 while (++curtblindx < numTables)
8085 tbinfo = &tblinfo[curtblindx];
8089 if (curtblindx >= numTables)
8090 pg_fatal(
"unrecognized table OID %u", indrelid);
8094 pg_fatal(
"unexpected index data for table \"%s\"",
8101 for (
int c = 0;
c < numinds;
c++,
j++)
8116 indxinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8127 indxinfo[
j].indkeys, indxinfo[
j].indnattrs);
8137 if (indxinfo[
j].parentidx == 0)
8138 indexkind = RELKIND_INDEX;
8140 indexkind = RELKIND_PARTITIONED_INDEX;
8145 &indAttNames, &nindAttNames))
8146 pg_fatal(
"could not parse %s array",
"indattnames");
8151 relallvisible, relallfrozen, indexkind,
8152 indAttNames, nindAttNames);
8155 if (contype ==
'p' || contype ==
'u' || contype ==
'x')
8170 constrinfo->
dobj.namespace = tbinfo->
dobj.namespace;
8173 constrinfo->
contype = contype;
8177 constrinfo->
condef = NULL;
8187 if (relstats != NULL)
8235 "stxnamespace, stxowner, stxrelid, NULL AS stxstattarget "
8236 "FROM pg_catalog.pg_statistic_ext");
8239 "stxnamespace, stxowner, stxrelid, stxstattarget "
8240 "FROM pg_catalog.pg_statistic_ext");
8246 i_tableoid =
PQfnumber(res,
"tableoid");
8249 i_stxnamespace =
PQfnumber(res,
"stxnamespace");
8250 i_stxowner =
PQfnumber(res,
"stxowner");
8251 i_stxrelid =
PQfnumber(res,
"stxrelid");
8252 i_stattarget =
PQfnumber(res,
"stxstattarget");
8256 for (
i = 0;
i < ntups;
i++)
8263 statsextinfo[
i].
dobj.namespace =
8317 for (
int i = 0;
i < numTables;
i++)
8325 if (tbloids->
len > 1)
8332 "SELECT c.tableoid, c.oid, "
8333 "conrelid, conname, confrelid, ");
8339 "pg_catalog.pg_get_constraintdef(c.oid) AS condef\n"
8340 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8341 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
8342 "WHERE contype = 'f' ",
8346 "AND conparentid = 0 ");
8348 "ORDER BY conrelid, conname");
8354 i_contableoid =
PQfnumber(res,
"tableoid");
8356 i_conrelid =
PQfnumber(res,
"conrelid");
8358 i_confrelid =
PQfnumber(res,
"confrelid");
8359 i_conindid =
PQfnumber(res,
"conindid");
8365 for (
int j = 0;
j < ntups;
j++)
8374 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != conrelid)
8376 while (++curtblindx < numTables)
8378 tbinfo = &tblinfo[curtblindx];
8382 if (curtblindx >= numTables)
8383 pg_fatal(
"unrecognized table OID %u", conrelid);
8391 constrinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8410 if (reftable && reftable->
relkind == RELKIND_PARTITIONED_TABLE)
8416 for (
int k = 0; k < reftable->
numIndexes; k++)
8424 refidx = &reftable->
indexes[k];
8494 "PREPARE getDomainConstraints(pg_catalog.oid) AS\n"
8495 "SELECT tableoid, oid, conname, "
8496 "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
8497 "convalidated, contype "
8498 "FROM pg_catalog.pg_constraint "
8499 "WHERE contypid = $1 AND contype IN (%s) "
8509 "EXECUTE getDomainConstraints('%u')",
8516 i_tableoid =
PQfnumber(res,
"tableoid");
8520 i_convalidated =
PQfnumber(res,
"convalidated");
8527 for (
int i = 0,
j = 0;
i < ntups;
i++)
8529 bool validated =
PQgetvalue(res,
i, i_convalidated)[0] ==
't';
8530 char contype = (
PQgetvalue(res,
i, i_contype))[0];
8533 if (contype == CONSTRAINT_CHECK)
8535 constraint = &constrinfo[
j++];
8540 Assert(contype == CONSTRAINT_NOTNULL);
8543 tyinfo->
notnull = &(constrinfo[ntups - 1]);
8552 constraint->
dobj.namespace = tyinfo->
dobj.namespace;
8555 constraint->
contype = contype;
8601 "tableoid, oid, rulename, "
8602 "ev_class AS ruletable, ev_type, is_instead, "
8613 i_tableoid =
PQfnumber(res,
"tableoid");
8615 i_rulename =
PQfnumber(res,
"rulename");
8616 i_ruletable =
PQfnumber(res,
"ruletable");
8618 i_is_instead =
PQfnumber(res,
"is_instead");
8619 i_ev_enabled =
PQfnumber(res,
"ev_enabled");
8621 for (
i = 0;
i < ntups;
i++)
8632 if (ruleinfo[
i].ruletable == NULL)
8633 pg_fatal(
"failed sanity check, parent table with OID %u of pg_rewrite entry with OID %u not found",
8634 ruletableoid, ruleinfo[
i].dobj.catId.oid);
8640 if (ruleinfo[
i].ruletable)
8649 if ((ruleinfo[
i].ruletable->relkind == RELKIND_VIEW ||
8707 for (
int i = 0;
i < numTables;
i++)
8716 if (tbloids->
len > 1)
8733 "SELECT t.tgrelid, t.tgname, "
8734 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8735 "t.tgenabled, t.tableoid, t.oid, "
8736 "t.tgparentid <> 0 AS tgispartition\n"
8737 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8738 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8739 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8740 "WHERE ((NOT t.tgisinternal AND t.tgparentid = 0) "
8741 "OR t.tgenabled != u.tgenabled) "
8742 "ORDER BY t.tgrelid, t.tgname",
8756 "SELECT t.tgrelid, t.tgname, "
8757 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8758 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition\n"
8759 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8760 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8761 "LEFT JOIN pg_catalog.pg_trigger u ON (u.oid = t.tgparentid) "
8762 "WHERE (NOT t.tgisinternal OR t.tgenabled != u.tgenabled) "
8763 "ORDER BY t.tgrelid, t.tgname",
8776 "SELECT t.tgrelid, t.tgname, "
8777 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8778 "t.tgenabled, t.tableoid, t.oid, t.tgisinternal as tgispartition "
8779 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8780 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8781 "LEFT JOIN pg_catalog.pg_depend AS d ON "
8782 " d.classid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8783 " d.refclassid = 'pg_catalog.pg_trigger'::pg_catalog.regclass AND "
8785 "LEFT JOIN pg_catalog.pg_trigger AS pt ON pt.oid = refobjid "
8786 "WHERE (NOT t.tgisinternal OR t.tgenabled != pt.tgenabled) "
8787 "ORDER BY t.tgrelid, t.tgname",
8794 "SELECT t.tgrelid, t.tgname, "
8795 "pg_catalog.pg_get_triggerdef(t.oid, false) AS tgdef, "
8796 "t.tgenabled, false as tgispartition, "
8797 "t.tableoid, t.oid "
8798 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
8799 "JOIN pg_catalog.pg_trigger t ON (src.tbloid = t.tgrelid) "
8800 "WHERE NOT tgisinternal "
8801 "ORDER BY t.tgrelid, t.tgname",
8809 i_tableoid =
PQfnumber(res,
"tableoid");
8813 i_tgenabled =
PQfnumber(res,
"tgenabled");
8814 i_tgispartition =
PQfnumber(res,
"tgispartition");
8824 for (
int j = 0;
j < ntups;)
8831 for (numtrigs = 1; numtrigs < ntups -
j; numtrigs++)
8839 while (++curtblindx < numTables)
8841 tbinfo = &tblinfo[curtblindx];
8845 if (curtblindx >= numTables)
8846 pg_fatal(
"unrecognized table OID %u", tgrelid);
8852 for (
int c = 0;
c < numtrigs;
c++,
j++)
8859 tginfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
8901 "SELECT e.tableoid, e.oid, evtname, evtenabled, "
8902 "evtevent, evtowner, "
8903 "array_to_string(array("
8904 "select quote_literal(x) "
8905 " from unnest(evttags) as t(x)), ', ') as evttags, "
8906 "e.evtfoid::regproc as evtfname "
8907 "FROM pg_event_trigger e "
8916 i_tableoid =
PQfnumber(res,
"tableoid");
8919 i_evtevent =
PQfnumber(res,
"evtevent");
8920 i_evtowner =
PQfnumber(res,
"evtowner");
8922 i_evtfname =
PQfnumber(res,
"evtfname");
8923 i_evtenabled =
PQfnumber(res,
"evtenabled");
8925 for (
i = 0;
i < ntups;
i++)
8967 int i_lanplcallfoid;
8975 "lanname, lanpltrusted, lanplcallfoid, "
8976 "laninline, lanvalidator, "
8978 "acldefault('l', lanowner) AS acldefault, "
8990 i_tableoid =
PQfnumber(res,
"tableoid");
8993 i_lanpltrusted =
PQfnumber(res,
"lanpltrusted");
8994 i_lanplcallfoid =
PQfnumber(res,
"lanplcallfoid");
8995 i_laninline =
PQfnumber(res,
"laninline");
8996 i_lanvalidator =
PQfnumber(res,
"lanvalidator");
8998 i_acldefault =
PQfnumber(res,
"acldefault");
8999 i_lanowner =
PQfnumber(res,
"lanowner");
9001 for (
i = 0;
i < ntups;
i++)
9058 "castsource, casttarget, castfunc, castcontext, "
9061 "WHERE NOT EXISTS ( "
9062 "SELECT 1 FROM pg_range r "
9063 "WHERE c.castsource = r.rngtypid "
9064 "AND c.casttarget = r.rngmultitypid "
9071 "castsource, casttarget, castfunc, castcontext, "
9073 "FROM pg_cast ORDER BY 3,4");
9082 i_tableoid =
PQfnumber(res,
"tableoid");
9084 i_castsource =
PQfnumber(res,
"castsource");
9085 i_casttarget =
PQfnumber(res,
"casttarget");
9086 i_castfunc =
PQfnumber(res,
"castfunc");
9087 i_castcontext =
PQfnumber(res,
"castcontext");
9088 i_castmethod =
PQfnumber(res,
"castmethod");
9090 for (
i = 0;
i < ntups;
i++)
9114 if (sTypeInfo && tTypeInfo)
9136 appendPQExpBuffer(query,
"SELECT lanname FROM pg_language WHERE oid = %u", langid);
9171 "trftype, trflang, trffromsql::oid, trftosql::oid "
9172 "FROM pg_transform "
9181 i_tableoid =
PQfnumber(res,
"tableoid");
9185 i_trffromsql =
PQfnumber(res,
"trffromsql");
9186 i_trftosql =
PQfnumber(res,
"trftosql");
9188 for (
i = 0;
i < ntups;
i++)
9211 if (typeInfo && lanname)
9248 int i_attstattarget;
9258 int i_notnull_comment;
9259 int i_notnull_noinherit;
9260 int i_notnull_islocal;
9261 int i_notnull_invalidoid;
9264 int i_attcompression;
9265 int i_attfdwoptions;
9266 int i_attmissingval;
9281 for (
int i = 0;
i < numTables;
i++)
9286 if (tbinfo->
relkind == RELKIND_SEQUENCE)
9301 (tbinfo->
dobj.
catId.
oid == LargeObjectMetadataRelationId ||
9306 if (tbloids->
len > 1)
9313 if (checkoids->
len > 1)
9333 "a.attstattarget,\n"
9341 "pg_catalog.format_type(t.oid, a.atttypmod) AS atttypname,\n"
9342 "array_to_string(a.attoptions, ', ') AS attoptions,\n"
9343 "CASE WHEN a.attcollation <> t.typcollation "
9344 "THEN a.attcollation ELSE 0 END AS attcollation,\n"
9345 "pg_catalog.array_to_string(ARRAY("
9346 "SELECT pg_catalog.quote_ident(option_name) || "
9347 "' ' || pg_catalog.quote_literal(option_value) "
9348 "FROM pg_catalog.pg_options_to_table(attfdwoptions) "
9349 "ORDER BY option_name"
9350 "), E',\n ') AS attfdwoptions,\n");
9372 "co.conname AS notnull_name,\n"
9373 "CASE WHEN co.convalidated THEN pt.description"
9374 " ELSE NULL END AS notnull_comment,\n"
9375 "CASE WHEN NOT co.convalidated THEN co.oid "
9376 "ELSE NULL END AS notnull_invalidoid,\n"
9377 "co.connoinherit AS notnull_noinherit,\n"
9378 "co.conislocal AS notnull_islocal,\n");
9381 "CASE WHEN a.attnotnull THEN '' ELSE NULL END AS notnull_name,\n"
9382 "NULL AS notnull_comment,\n"
9383 "NULL AS notnull_invalidoid,\n"
9384 "false AS notnull_noinherit,\n"
9385 "CASE WHEN a.attislocal THEN true\n"
9386 " WHEN a.attnotnull AND NOT a.attislocal THEN true\n"
9388 "END AS notnull_islocal,\n");
9392 "a.attcompression AS attcompression,\n");
9395 "'' AS attcompression,\n");
9399 "a.attidentity,\n");
9402 "'' AS attidentity,\n");
9406 "CASE WHEN a.atthasmissing AND NOT a.attisdropped "
9407 "THEN a.attmissingval ELSE null END AS attmissingval,\n");
9410 "NULL AS attmissingval,\n");
9414 "a.attgenerated\n");
9417 "'' AS attgenerated\n");
9421 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9422 "JOIN pg_catalog.pg_attribute a ON (src.tbloid = a.attrelid) "
9423 "LEFT JOIN pg_catalog.pg_type t "
9424 "ON (a.atttypid = t.oid)\n",
9433 " LEFT JOIN pg_catalog.pg_constraint co ON "
9434 "(a.attrelid = co.conrelid\n"
9435 " AND co.contype = 'n' AND "
9436 "co.conkey = array[a.attnum])\n"
9437 " LEFT JOIN pg_catalog.pg_description pt ON "
9438 "(pt.classoid = co.tableoid AND pt.objoid = co.oid)\n");
9441 "WHERE a.attnum > 0::pg_catalog.int2\n"
9442 "ORDER BY a.attrelid, a.attnum");
9448 i_attrelid =
PQfnumber(res,
"attrelid");
9451 i_atttypname =
PQfnumber(res,
"atttypname");
9452 i_attstattarget =
PQfnumber(res,
"attstattarget");
9453 i_attstorage =
PQfnumber(res,
"attstorage");
9454 i_typstorage =
PQfnumber(res,
"typstorage");
9455 i_attidentity =
PQfnumber(res,
"attidentity");
9456 i_attgenerated =
PQfnumber(res,
"attgenerated");
9457 i_attisdropped =
PQfnumber(res,
"attisdropped");
9459 i_attalign =
PQfnumber(res,
"attalign");
9460 i_attislocal =
PQfnumber(res,
"attislocal");
9461 i_notnull_name =
PQfnumber(res,
"notnull_name");
9462 i_notnull_comment =
PQfnumber(res,
"notnull_comment");
9463 i_notnull_invalidoid =
PQfnumber(res,
"notnull_invalidoid");
9464 i_notnull_noinherit =
PQfnumber(res,
"notnull_noinherit");
9465 i_notnull_islocal =
PQfnumber(res,
"notnull_islocal");
9466 i_attoptions =
PQfnumber(res,
"attoptions");
9467 i_attcollation =
PQfnumber(res,
"attcollation");
9468 i_attcompression =
PQfnumber(res,
"attcompression");
9469 i_attfdwoptions =
PQfnumber(res,
"attfdwoptions");
9470 i_attmissingval =
PQfnumber(res,
"attmissingval");
9471 i_atthasdef =
PQfnumber(res,
"atthasdef");
9482 for (
int r = 0; r < ntups;)
9490 for (numatts = 1; numatts < ntups - r; numatts++)
9498 while (++curtblindx < numTables)
9500 tbinfo = &tblinfo[curtblindx];
9504 if (curtblindx >= numTables)
9505 pg_fatal(
"unrecognized table OID %u", attrelid);
9507 if (tbinfo->
relkind == RELKIND_SEQUENCE ||
9510 (tbinfo->
dobj.
catId.
oid == LargeObjectMetadataRelationId ||
9512 pg_fatal(
"unexpected column data for table \"%s\"",
9539 hasdefaults =
false;
9541 for (
int j = 0;
j < numatts;
j++, r++)
9544 pg_fatal(
"invalid column numbering in table \"%s\"",
9567 i_notnull_invalidoid,
9568 i_notnull_noinherit,
9570 &invalidnotnulloids);
9580 if (
PQgetvalue(res, r, i_atthasdef)[0] ==
't')
9587 if (tbloids->
len > 1)
9594 if (invalidnotnulloids != NULL)
9614 "pg_catalog.pg_get_expr(adbin, adrelid) AS adsrc\n"
9615 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9616 "JOIN pg_catalog.pg_attrdef a ON (src.tbloid = a.adrelid)\n"
9617 "ORDER BY a.adrelid, a.adnum",
9626 for (
int j = 0;
j < numDefaults;
j++)
9638 if (tbinfo == NULL || tbinfo->
dobj.
catId.
oid != adrelid)
9640 while (++curtblindx < numTables)
9642 tbinfo = &tblinfo[curtblindx];
9646 if (curtblindx >= numTables)
9647 pg_fatal(
"unrecognized table OID %u", adrelid);
9650 if (adnum <= 0 || adnum > tbinfo->
numatts)
9651 pg_fatal(
"invalid adnum value %d for table \"%s\"",
9666 attrdefs[
j].
adnum = adnum;
9670 attrdefs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9693 else if (tbinfo->
relkind == RELKIND_VIEW)
9711 if (!attrdefs[
j].separate)
9723 tbinfo->
attrdefs[adnum - 1] = &attrdefs[
j];
9744 pg_log_info(
"finding invalid not-null constraints");
9748 "SELECT c.tableoid, c.oid, conrelid, conname, "
9749 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9750 "conislocal, convalidated "
9751 "FROM unnest('%s'::pg_catalog.oid[]) AS src(conoid)\n"
9752 "JOIN pg_catalog.pg_constraint c ON (src.conoid = c.oid)\n"
9753 "ORDER BY c.conrelid, c.conname",
9754 invalidnotnulloids->
data);
9761 i_tableoid =
PQfnumber(res,
"tableoid");
9763 i_conrelid =
PQfnumber(res,
"conrelid");
9766 i_conislocal =
PQfnumber(res,
"conislocal");
9770 for (
int j = 0;
j < numConstrs;)
9777 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9785 while (++curtblindx < numTables)
9787 tbinfo = &tblinfo[curtblindx];
9791 if (curtblindx >= numTables)
9792 pg_fatal(
"unrecognized table OID %u", conrelid);
9794 for (
int c = 0;
c < numcons;
c++,
j++)
9801 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9846 "SELECT c.tableoid, c.oid, conrelid, conname, "
9847 "pg_catalog.pg_get_constraintdef(c.oid) AS consrc, "
9848 "conislocal, convalidated "
9849 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
9850 "JOIN pg_catalog.pg_constraint c ON (src.tbloid = c.conrelid)\n"
9851 "WHERE contype = 'c' "
9852 "ORDER BY c.conrelid, c.conname",
9860 i_tableoid =
PQfnumber(res,
"tableoid");
9862 i_conrelid =
PQfnumber(res,
"conrelid");
9865 i_conislocal =
PQfnumber(res,
"conislocal");
9866 i_convalidated =
PQfnumber(res,
"convalidated");
9870 for (
int j = 0;
j < numConstrs;)
9877 for (numcons = 1; numcons < numConstrs -
j; numcons++)
9885 while (++curtblindx < numTables)
9887 tbinfo = &tblinfo[curtblindx];
9891 if (curtblindx >= numTables)
9892 pg_fatal(
"unrecognized table OID %u", conrelid);
9894 if (numcons != tbinfo->
ncheck)
9897 "expected %d check constraints on table \"%s\" but found %d",
9906 for (
int c = 0;
c < numcons;
c++,
j++)
9908 bool validated =
PQgetvalue(res,
j, i_convalidated)[0] ==
't';
9915 constrs[
j].
dobj.namespace = tbinfo->
dobj.namespace;
9944 if (!constrs[
j].separate)
10013 int i_notnull_name,
10014 int i_notnull_comment,
10015 int i_notnull_invalidoid,
10016 int i_notnull_noinherit,
10017 int i_notnull_islocal,
10033 char *constroid =
PQgetvalue(res, r, i_notnull_invalidoid);
10035 if (*invalidnotnulloids == NULL)
10101 char *default_name;
10106 if (strcmp(default_name,
10114 free(default_name);
10163 int i_prsnamespace;
10178 "prsstart::oid, prstoken::oid, "
10179 "prsend::oid, prsheadline::oid, prslextype::oid "
10180 "FROM pg_ts_parser");
10188 i_tableoid =
PQfnumber(res,
"tableoid");
10191 i_prsnamespace =
PQfnumber(res,
"prsnamespace");
10192 i_prsstart =
PQfnumber(res,
"prsstart");
10193 i_prstoken =
PQfnumber(res,
"prstoken");
10195 i_prsheadline =
PQfnumber(res,
"prsheadline");
10196 i_prslextype =
PQfnumber(res,
"prslextype");
10198 for (
i = 0;
i < ntups;
i++)
10205 prsinfo[
i].
dobj.namespace =
10237 int i_dictnamespace;
10239 int i_dicttemplate;
10240 int i_dictinitoption;
10245 "dictnamespace, dictowner, "
10246 "dicttemplate, dictinitoption "
10247 "FROM pg_ts_dict");
10255 i_tableoid =
PQfnumber(res,
"tableoid");
10257 i_dictname =
PQfnumber(res,
"dictname");
10258 i_dictnamespace =
PQfnumber(res,
"dictnamespace");
10259 i_dictowner =
PQfnumber(res,
"dictowner");
10260 i_dictinitoption =
PQfnumber(res,
"dictinitoption");
10261 i_dicttemplate =
PQfnumber(res,
"dicttemplate");
10263 for (
i = 0;
i < ntups;
i++)
10270 dictinfo[
i].
dobj.namespace =
10303 int i_tmplnamespace;
10310 "tmplnamespace, tmplinit::oid, tmpllexize::oid "
10311 "FROM pg_ts_template");
10319 i_tableoid =
PQfnumber(res,
"tableoid");
10321 i_tmplname =
PQfnumber(res,
"tmplname");
10322 i_tmplnamespace =
PQfnumber(res,
"tmplnamespace");
10323 i_tmplinit =
PQfnumber(res,
"tmplinit");
10324 i_tmpllexize =
PQfnumber(res,
"tmpllexize");
10326 for (
i = 0;
i < ntups;
i++)
10333 tmplinfo[
i].
dobj.namespace =
10362 int i_cfgnamespace;
10369 "cfgnamespace, cfgowner, cfgparser "
10370 "FROM pg_ts_config");
10378 i_tableoid =
PQfnumber(res,
"tableoid");
10381 i_cfgnamespace =
PQfnumber(res,
"cfgnamespace");
10382 i_cfgowner =
PQfnumber(res,
"cfgowner");
10383 i_cfgparser =
PQfnumber(res,
"cfgparser");
10385 for (
i = 0;
i < ntups;
i++)
10392 cfginfo[
i].
dobj.namespace =
10423 int i_fdwvalidator;
10432 "fdwhandler::pg_catalog.regproc, "
10433 "fdwvalidator::pg_catalog.regproc, "
10435 "acldefault('F', fdwowner) AS acldefault, "
10436 "array_to_string(ARRAY("
10437 "SELECT quote_ident(option_name) || ' ' || "
10438 "quote_literal(option_value) "
10439 "FROM pg_options_to_table(fdwoptions) "
10440 "ORDER BY option_name"
10441 "), E',\n ') AS fdwoptions "
10442 "FROM pg_foreign_data_wrapper");
10450 i_tableoid =
PQfnumber(res,
"tableoid");
10453 i_fdwowner =
PQfnumber(res,
"fdwowner");
10454 i_fdwhandler =
PQfnumber(res,
"fdwhandler");
10455 i_fdwvalidator =
PQfnumber(res,
"fdwvalidator");
10457 i_acldefault =
PQfnumber(res,
"acldefault");
10458 i_fdwoptions =
PQfnumber(res,
"fdwoptions");
10460 for (
i = 0;
i < ntups;
i++)
10467 fdwinfo[
i].
dobj.namespace = NULL;
10517 "srvfdw, srvtype, srvversion, srvacl, "
10518 "acldefault('S', srvowner) AS acldefault, "
10519 "array_to_string(ARRAY("
10520 "SELECT quote_ident(option_name) || ' ' || "
10521 "quote_literal(option_value) "
10522 "FROM pg_options_to_table(srvoptions) "
10523 "ORDER BY option_name"
10524 "), E',\n ') AS srvoptions "
10525 "FROM pg_foreign_server");
10533 i_tableoid =
PQfnumber(res,
"tableoid");
10536 i_srvowner =
PQfnumber(res,
"srvowner");
10539 i_srvversion =
PQfnumber(res,
"srvversion");
10541 i_acldefault =
PQfnumber(res,
"acldefault");
10542 i_srvoptions =
PQfnumber(res,
"srvoptions");
10544 for (
i = 0;
i < ntups;
i++)
10551 srvinfo[
i].
dobj.namespace = NULL;
10592 int i_defaclnamespace;
10593 int i_defaclobjtype;
10614 "SELECT oid, tableoid, "
10616 "defaclnamespace, "
10619 "CASE WHEN defaclnamespace = 0 THEN "
10620 "acldefault(CASE WHEN defaclobjtype = 'S' "
10621 "THEN 's'::\"char\" ELSE defaclobjtype END, "
10622 "defaclrole) ELSE '{}' END AS acldefault "
10623 "FROM pg_default_acl");
10632 i_tableoid =
PQfnumber(res,
"tableoid");
10633 i_defaclrole =
PQfnumber(res,
"defaclrole");
10634 i_defaclnamespace =
PQfnumber(res,
"defaclnamespace");
10635 i_defaclobjtype =
PQfnumber(res,
"defaclobjtype");
10636 i_defaclacl =
PQfnumber(res,
"defaclacl");
10637 i_acldefault =
PQfnumber(res,
"acldefault");
10639 for (
i = 0;
i < ntups;
i++)
10653 daclinfo[
i].
dobj.namespace = NULL;
10692 while (low <= high)
10696 if (roleoid < middle->roleoid)
10698 else if (roleoid > middle->
roleoid)
10705 pg_fatal(
"role with OID %u does not exist", roleoid);
10722 query =
"SELECT oid, rolname FROM pg_catalog.pg_roles ORDER BY 1";
10760 "SELECT DISTINCT attrelid FROM pg_attribute "
10761 "WHERE attacl IS NOT NULL");
10766 for (
i = 0;
i < ntups;
i++)
10785 "SELECT objoid, classoid, objsubid, privtype, initprivs "
10786 "FROM pg_init_privs");
10791 for (
i = 0;
i < ntups;
i++)
10802 objId.
oid = objoid;
10814 ((
TableInfo *) dobj)->hascolumnACLs =
true;
10818 classoid, objoid, objsubid);
10827 strcmp(dobj->
name,
"public") == 0)
10847 classoid, objoid, objsubid);
10881 const char *
name,
const char *
namespace,
10882 const char *owner,
CatalogId catalogId,
10883 int subid,
DumpId dumpId,
10884 const char *initdb_comment)
10895 if (strcmp(
type,
"LARGE OBJECT") != 0)
10920 if (initdb_comment != NULL)
10946 if (
namespace && *
namespace)
10961 .namespace =
namespace,
10963 .description =
"COMMENT",
10965 .createStmt = query->
data,
10981 const char *
name,
const char *
namespace,
10982 const char *owner,
CatalogId catalogId,
10983 int subid,
DumpId dumpId)
10986 catalogId, subid, dumpId, NULL);
10997 const char *argtype,
const char *argval)
11022 static bool restarted;
11061 for (; te != AH->
toc && count < max_rels; te = te->
next)
11064 strcmp(te->
desc,
"STATISTICS DATA") == 0)
11117 int i_most_common_vals;
11118 int i_most_common_freqs;
11119 int i_histogram_bounds;
11121 int i_most_common_elems;
11122 int i_most_common_elem_freqs;
11123 int i_elem_count_histogram;
11124 int i_range_length_histogram;
11125 int i_range_empty_frac;
11126 int i_range_bounds_histogram;
11136 expected_te = expected_te->
next;
11138 strcmp(expected_te->
desc,
"STATISTICS DATA") != 0)
11139 expected_te = expected_te->
next;
11141 if (te != expected_te)
11142 pg_fatal(
"statistics dumped out of order (current: %d %s %s, expected: %d %s %s)",
11150 "PREPARE getAttributeStats(pg_catalog.name[], pg_catalog.name[]) AS\n"
11151 "SELECT s.schemaname, s.tablename, s.attname, s.inherited, "
11152 "s.null_frac, s.avg_width, s.n_distinct, "
11153 "s.most_common_vals, s.most_common_freqs, "
11154 "s.histogram_bounds, s.correlation, "
11155 "s.most_common_elems, s.most_common_elem_freqs, "
11156 "s.elem_count_histogram, ");
11160 "s.range_length_histogram, "
11161 "s.range_empty_frac, "
11162 "s.range_bounds_histogram ");
11165 "NULL AS range_length_histogram,"
11166 "NULL AS range_empty_frac,"
11167 "NULL AS range_bounds_histogram ");
11184 "FROM pg_catalog.pg_stats s "
11185 "JOIN unnest($1, $2) WITH ORDINALITY AS u (schemaname, tablename, ord) "
11186 "ON s.schemaname = u.schemaname "
11187 "AND s.tablename = u.tablename "
11188 "WHERE s.tablename = ANY($2) "
11189 "ORDER BY u.ord, s.attname, s.inherited");
11192 "FROM pg_catalog.pg_stats s "
11193 "WHERE s.schemaname = $1[1] "
11194 "AND s.tablename = $2[1] "
11195 "ORDER BY s.attname, s.inherited");
11246 i_schemaname =
PQfnumber(res,
"schemaname");
11247 i_tablename =
PQfnumber(res,
"tablename");
11249 i_inherited =
PQfnumber(res,
"inherited");
11250 i_null_frac =
PQfnumber(res,
"null_frac");
11251 i_avg_width =
PQfnumber(res,
"avg_width");
11252 i_n_distinct =
PQfnumber(res,
"n_distinct");
11253 i_most_common_vals =
PQfnumber(res,
"most_common_vals");
11254 i_most_common_freqs =
PQfnumber(res,
"most_common_freqs");
11255 i_histogram_bounds =
PQfnumber(res,
"histogram_bounds");
11256 i_correlation =
PQfnumber(res,
"correlation");
11257 i_most_common_elems =
PQfnumber(res,
"most_common_elems");
11258 i_most_common_elem_freqs =
PQfnumber(res,
"most_common_elem_freqs");
11259 i_elem_count_histogram =
PQfnumber(res,
"elem_count_histogram");
11260 i_range_length_histogram =
PQfnumber(res,
"range_length_histogram");
11261 i_range_empty_frac =
PQfnumber(res,
"range_empty_frac");
11262 i_range_bounds_histogram =
PQfnumber(res,
"range_bounds_histogram");
11265 for (; rownum <
PQntuples(res); rownum++)
11270 if (strcmp(te->
tag,
PQgetvalue(res, rownum, i_tablename)) != 0 ||
11271 strcmp(te->namespace,
PQgetvalue(res, rownum, i_schemaname)) != 0)
11283 pg_fatal(
"unexpected null attname");
11298 bool found =
false;
11327 if (!
PQgetisnull(res, rownum, i_most_common_vals))
11329 PQgetvalue(res, rownum, i_most_common_vals));
11330 if (!
PQgetisnull(res, rownum, i_most_common_freqs))
11332 PQgetvalue(res, rownum, i_most_common_freqs));
11333 if (!
PQgetisnull(res, rownum, i_histogram_bounds))
11335 PQgetvalue(res, rownum, i_histogram_bounds));
11339 if (!
PQgetisnull(res, rownum, i_most_common_elems))
11341 PQgetvalue(res, rownum, i_most_common_elems));
11342 if (!
PQgetisnull(res, rownum, i_most_common_elem_freqs))
11344 PQgetvalue(res, rownum, i_most_common_elem_freqs));
11345 if (!
PQgetisnull(res, rownum, i_elem_count_histogram))
11347 PQgetvalue(res, rownum, i_elem_count_histogram));
11350 if (!
PQgetisnull(res, rownum, i_range_length_histogram))
11352 PQgetvalue(res, rownum, i_range_length_histogram));
11353 if (!
PQgetisnull(res, rownum, i_range_empty_frac))
11355 PQgetvalue(res, rownum, i_range_empty_frac));
11356 if (!
PQgetisnull(res, rownum, i_range_bounds_histogram))
11358 PQgetvalue(res, rownum, i_range_bounds_histogram));
11385 .namespace = dobj->namespace->dobj.
name,
11386 .description =
"STATISTICS DATA",
11391 .nDeps = dobj->
nDeps));
11402 const char *reltypename)
11449 .namespace = tbinfo->
dobj.namespace->dobj.
name,
11451 .description =
"COMMENT",
11453 .createStmt = query->
data,
11457 else if (objsubid > 0 && objsubid <= tbinfo->numatts)
11474 .namespace = tbinfo->
dobj.namespace->dobj.
name,
11476 .description =
"COMMENT",
11478 .createStmt = query->
data,
11511 while (low <= high)
11513 middle = low + (high - low) / 2;
11515 if (classoid < middle->classoid)
11517 else if (classoid > middle->
classoid)
11519 else if (objoid < middle->objoid)
11521 else if (objoid > middle->
objoid)
11539 while (middle > low)
11541 if (classoid != middle[-1].classoid ||
11542 objoid != middle[-1].objoid)
11551 while (middle <= high)
11553 if (classoid != middle->
classoid ||
11554 objoid != middle->
objoid)
11591 "FROM pg_catalog.pg_description "
11592 "ORDER BY classoid, objoid, objsubid");
11598 i_description =
PQfnumber(res,
"description");
11599 i_classoid =
PQfnumber(res,
"classoid");
11601 i_objsubid =
PQfnumber(res,
"objsubid");
11609 for (
i = 0;
i < ntups;
i++)
11619 if (dobj == NULL ||
11632 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
11671 if (dobj->
dump == 0)
11797 if (loinfo == NULL)
11798 pg_fatal(
"missing metadata for large objects \"%s\"",
11804 .description =
"BLOBS",
11806 .deps = dobj->dependencies,
11807 .nDeps = dobj->nDeps,
11809 .dumpArg = loinfo));
11882 "-- *not* dropping schema, since initdb creates it\n");
11884 "-- *not* creating schema, since initdb creates it\n");
11889 "SCHEMA", qnspname, NULL);
11895 .description =
"SCHEMA",
11897 .createStmt = q->
data,
11898 .dropStmt = delq->
data));
11903 const char *initdb_comment = NULL;
11905 if (!nspinfo->
create && strcmp(qnspname,
"public") == 0)
11906 initdb_comment =
"standard public schema";
11920 qnspname, NULL, NULL,
11965 qextname,
fmtId(extinfo->namespace));
11980 appendPQExpBufferStr(q,
"-- For binary upgrade, create an empty extension and insert objects into it\n");
11990 "SELECT pg_catalog.binary_upgrade_create_empty_extension(");
12035 .description =
"EXTENSION",
12037 .createStmt = q->
data,
12038 .dropStmt = delq->
data));
12066 if (tyinfo->
typtype == TYPTYPE_BASE)
12068 else if (tyinfo->
typtype == TYPTYPE_DOMAIN)
12070 else if (tyinfo->
typtype == TYPTYPE_COMPOSITE)
12072 else if (tyinfo->
typtype == TYPTYPE_ENUM)
12074 else if (tyinfo->
typtype == TYPTYPE_RANGE)
12079 pg_log_warning(
"typtype of data type \"%s\" appears to be invalid",
12108 "PREPARE dumpEnumType(pg_catalog.oid) AS\n"
12109 "SELECT oid, enumlabel "
12110 "FROM pg_catalog.pg_enum "
12111 "WHERE enumtypid = $1 "
12112 "ORDER BY enumsortorder");
12120 "EXECUTE dumpEnumType('%u')",
12146 i_enumlabel =
PQfnumber(res,
"enumlabel");
12149 for (
i = 0;
i < num;
i++)
12164 i_enumlabel =
PQfnumber(res,
"enumlabel");
12167 for (
i = 0;
i < num;
i++)
12175 "SELECT pg_catalog.binary_upgrade_set_next_pg_enum_oid('%u'::pg_catalog.oid);\n",
12186 tyinfo->
dobj.namespace->dobj.
name);
12191 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12193 .description =
"TYPE",
12195 .createStmt = q->
data,
12196 .dropStmt = delq->
data));
12212 tyinfo->
dobj.namespace->dobj.
name,
12244 "PREPARE dumpRangeType(pg_catalog.oid) AS\n");
12251 "pg_catalog.format_type(rngmultitypid, NULL) AS rngmultitype, ");
12254 "NULL AS rngmultitype, ");
12257 "pg_catalog.format_type(rngsubtype, NULL) AS rngsubtype, "
12258 "opc.opcname AS opcname, "
12259 "(SELECT nspname FROM pg_catalog.pg_namespace nsp "
12260 " WHERE nsp.oid = opc.opcnamespace) AS opcnsp, "
12262 "CASE WHEN rngcollation = st.typcollation THEN 0 "
12263 " ELSE rngcollation END AS collation, "
12264 "rngcanonical, rngsubdiff "
12265 "FROM pg_catalog.pg_range r, pg_catalog.pg_type st, "
12266 " pg_catalog.pg_opclass opc "
12267 "WHERE st.oid = rngsubtype AND opc.oid = rngsubopc AND "
12276 "EXECUTE dumpRangeType('%u')",
12327 if (strcmp(procname,
"-") != 0)
12331 if (strcmp(procname,
"-") != 0)
12339 tyinfo->
dobj.namespace->dobj.
name);
12344 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12346 .description =
"TYPE",
12348 .createStmt = q->
data,
12349 .dropStmt = delq->
data));
12365 tyinfo->
dobj.namespace->dobj.
name,
12410 tyinfo->
dobj.namespace->dobj.
name);
12415 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12417 .description =
"TYPE",
12419 .createStmt = q->
data,
12420 .dropStmt = delq->
data));
12436 tyinfo->
dobj.namespace->dobj.
name,
12467 char *typsubscript;
12473 Oid typsubscriptoid;
12475 char *typispreferred;
12480 char *typcollatable;
12482 bool typdefault_is_literal =
false;
12488 "PREPARE dumpBaseType(pg_catalog.oid) AS\n"
12490 "typinput, typoutput, typreceive, typsend, "
12491 "typreceive::pg_catalog.oid AS typreceiveoid, "
12492 "typsend::pg_catalog.oid AS typsendoid, "
12494 "typanalyze::pg_catalog.oid AS typanalyzeoid, "
12495 "typdelim, typbyval, typalign, typstorage, "
12496 "typmodin, typmodout, "
12497 "typmodin::pg_catalog.oid AS typmodinoid, "
12498 "typmodout::pg_catalog.oid AS typmodoutoid, "
12499 "typcategory, typispreferred, "
12500 "(typcollation <> 0) AS typcollatable, "
12501 "pg_catalog.pg_get_expr(typdefaultbin, 0) AS typdefaultbin, typdefault, ");
12506 "typsubscript::pg_catalog.oid AS typsubscriptoid ");
12509 "'-' AS typsubscript, 0 AS typsubscriptoid ");
12520 "EXECUTE dumpBaseType('%u')",
12552 typdefault_is_literal =
true;
12577 "CREATE TYPE %s (\n"
12578 " INTERNALLENGTH = %s",
12580 (strcmp(typlen,
"-1") == 0) ?
"variable" : typlen);
12596 if (strcmp(typcollatable,
"t") == 0)
12599 if (typdefault != NULL)
12602 if (typdefault_is_literal)
12616 if (strcmp(typcategory,
"U") != 0)
12622 if (strcmp(typispreferred,
"t") == 0)
12625 if (typdelim && strcmp(typdelim,
",") != 0)
12633 else if (*
typalign == TYPALIGN_SHORT)
12635 else if (*
typalign == TYPALIGN_INT)
12637 else if (*
typalign == TYPALIGN_DOUBLE)
12640 if (*typstorage == TYPSTORAGE_PLAIN)
12642 else if (*typstorage == TYPSTORAGE_EXTERNAL)
12644 else if (*typstorage == TYPSTORAGE_EXTENDED)
12646 else if (*typstorage == TYPSTORAGE_MAIN)
12649 if (strcmp(typbyval,
"t") == 0)
12657 tyinfo->
dobj.namespace->dobj.
name);
12662 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12664 .description =
"TYPE",
12666 .createStmt = q->
data,
12667 .dropStmt = delq->
data));
12683 tyinfo->
dobj.namespace->dobj.
name,
12713 bool typdefault_is_literal =
false;
12719 "PREPARE dumpDomain(pg_catalog.oid) AS\n");
12722 "pg_catalog.format_type(t.typbasetype, t.typtypmod) AS typdefn, "
12723 "pg_catalog.pg_get_expr(t.typdefaultbin, 'pg_catalog.pg_type'::pg_catalog.regclass) AS typdefaultbin, "
12725 "CASE WHEN t.typcollation <> u.typcollation "
12726 "THEN t.typcollation ELSE 0 END AS typcollation "
12727 "FROM pg_catalog.pg_type t "
12728 "LEFT JOIN pg_catalog.pg_type u ON (t.typbasetype = u.oid) "
12729 "WHERE t.oid = $1");
12737 "EXECUTE dumpDomain('%u')",
12749 typdefault_is_literal =
true;
12765 "CREATE DOMAIN %s AS %s",
12785 if (typnotnull[0] ==
't')
12795 char *default_name;
12800 if (strcmp(default_name, notnull->
dobj.
name) == 0)
12805 free(default_name);
12810 if (typdefault != NULL)
12813 if (typdefault_is_literal)
12839 "DOMAIN", qtypname,
12840 tyinfo->
dobj.namespace->dobj.
name);
12845 .namespace = tyinfo->
dobj.namespace->dobj.
name,
12847 .description =
"DOMAIN",
12849 .createStmt = q->
data,
12850 .dropStmt = delq->
data));
12866 tyinfo->
dobj.namespace->dobj.
name,
12885 tyinfo->
dobj.namespace->dobj.
name,
12905 tyinfo->
dobj.namespace->dobj.
name,
12939 int i_attisdropped;
12940 int i_attcollation;
12955 "PREPARE dumpCompositeType(pg_catalog.oid) AS\n"
12956 "SELECT a.attname, a.attnum, "
12957 "pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
12958 "a.attlen, a.attalign, a.attisdropped, "
12959 "CASE WHEN a.attcollation <> at.typcollation "
12960 "THEN a.attcollation ELSE 0 END AS attcollation "
12961 "FROM pg_catalog.pg_type ct "
12962 "JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
12963 "LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
12964 "WHERE ct.oid = $1 "
12965 "ORDER BY a.attnum");
12973 "EXECUTE dumpCompositeType('%u')",
12981 i_atttypdefn =
PQfnumber(res,
"atttypdefn");
12983 i_attalign =
PQfnumber(res,
"attalign");
12984 i_attisdropped =
PQfnumber(res,
"attisdropped");
12985 i_attcollation =
PQfnumber(res,
"attcollation");
13002 for (
i = 0;
i < ntups;
i++)
13015 attisdropped = (
PQgetvalue(res,
i, i_attisdropped)[0] ==
't');
13022 if (actual_atts++ > 0)
13053 "\n-- For binary upgrade, recreate dropped column.\n");
13055 "SET attlen = %s, "
13056 "attalign = '%s', attbyval = false\n"
13077 tyinfo->
dobj.namespace->dobj.
name);
13082 .namespace = tyinfo->
dobj.namespace->dobj.
name,
13084 .description =
"TYPE",
13086 .createStmt = q->
data,
13087 .dropStmt = delq->
data));
13104 tyinfo->
dobj.namespace->dobj.
name,
13141 int i_attisdropped;
13162 i_attisdropped =
PQfnumber(res,
"attisdropped");
13168 for (
i = 0;
i < ntups;
i++)
13195 .namespace = tyinfo->
dobj.namespace->dobj.
name,
13197 .description =
"COMMENT",
13199 .createStmt = query->
data,
13250 .namespace = stinfo->
dobj.namespace->dobj.
name,
13252 .description =
"SHELL TYPE",
13254 .createStmt = q->
data));
13289 if (funcInfo != NULL && !funcInfo->
dobj.
dump)
13295 if (inlineInfo != NULL && !inlineInfo->
dobj.
dump)
13302 if (validatorInfo != NULL && !validatorInfo->
dobj.
dump)
13303 validatorInfo = NULL;
13311 useParams = (funcInfo != NULL &&
13355 "LANGUAGE", qlanname, NULL);
13361 .description =
"PROCEDURAL LANGUAGE",
13363 .createStmt = defqry->
data,
13364 .dropStmt = delqry->
data,
13380 qlanname, NULL, NULL,
13403 if (is_agg && finfo->
nargs == 0)
13430 for (
j = 0;
j < finfo->
nargs;
j++)
13458 char *funcfullsig = NULL;
13460 char *qual_funcsig;
13473 char *proleakproof;
13480 char **configitems = NULL;
13481 int nconfigitems = 0;
13482 const char *keyword;
13497 "PREPARE dumpFunc(pg_catalog.oid) AS\n");
13511 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
13512 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n"
13513 "pg_catalog.pg_get_function_result(p.oid) AS funcresult,\n"
13514 "proleakproof,\n");
13518 "array_to_string(protrftypes, ' ') AS protrftypes,\n");
13521 "NULL AS protrftypes,\n");
13528 "'u' AS proparallel,\n");
13535 "CASE WHEN proiswindow THEN 'w' ELSE 'f' END AS prokind,\n");
13542 "'-' AS prosupport,\n");
13546 "pg_get_function_sqlbody(p.oid) AS prosqlbody\n");
13549 "NULL AS prosqlbody\n");
13552 "FROM pg_catalog.pg_proc p, pg_catalog.pg_language l\n"
13553 "WHERE p.oid = $1 "
13554 "AND l.oid = p.prolang");
13562 "EXECUTE dumpFunc('%u')",
13604 else if (probin[0] !=
'\0')
13608 if (prosrc[0] !=
'\0')
13617 (strchr(prosrc,
'\'') == NULL && strchr(prosrc,
'\\') == NULL))
13635 if (!
parsePGArray(proconfig, &configitems, &nconfigitems))
13636 pg_fatal(
"could not parse %s array",
"proconfig");
13640 configitems = NULL;
13653 if (prokind[0] == PROKIND_PROCEDURE)
13654 keyword =
"PROCEDURE";
13656 keyword =
"FUNCTION";
13659 keyword, qual_funcsig);
13664 funcfullsig ? funcfullsig :
13667 if (prokind[0] == PROKIND_PROCEDURE)
13669 else if (funcresult)
13673 (proretset[0] ==
't') ?
"SETOF " :
"",
13686 for (
i = 0; typeids[
i];
i++)
13697 if (prokind[0] == PROKIND_WINDOW)
13700 if (provolatile[0] != PROVOLATILE_VOLATILE)
13702 if (provolatile[0] == PROVOLATILE_IMMUTABLE)
13704 else if (provolatile[0] == PROVOLATILE_STABLE)
13706 else if (provolatile[0] != PROVOLATILE_VOLATILE)
13707 pg_fatal(
"unrecognized provolatile value for function \"%s\"",
13711 if (proisstrict[0] ==
't')
13714 if (prosecdef[0] ==
't')
13717 if (proleakproof[0] ==
't')
13725 if (strcmp(procost,
"0") != 0)
13727 if (strcmp(lanname,
"internal") == 0 || strcmp(lanname,
"c") == 0)
13730 if (strcmp(procost,
"1") != 0)
13736 if (strcmp(procost,
"100") != 0)
13740 if (proretset[0] ==
't' &&
13741 strcmp(prorows,
"0") != 0 && strcmp(prorows,
"1000") != 0)
13744 if (strcmp(prosupport,
"-") != 0)
13750 if (proparallel[0] != PROPARALLEL_UNSAFE)
13752 if (proparallel[0] == PROPARALLEL_SAFE)
13754 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
13756 else if (proparallel[0] != PROPARALLEL_UNSAFE)
13757 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
13761 for (
int i = 0;
i < nconfigitems;
i++)
13764 char *configitem = configitems[
i];
13767 pos = strchr(configitem,
'=');
13799 if (*namelist == NULL)
13801 for (nameptr = namelist; *nameptr; nameptr++)
13803 if (nameptr != namelist)
13817 "pg_catalog.pg_proc", keyword,
13823 finfo->
dobj.namespace->dobj.
name);
13828 .
namespace = finfo->
dobj.namespace->dobj.
name,
13830 .description = keyword,
13833 .createStmt = q->
data,
13834 .dropStmt = delqry->
data));
13862 free(qual_funcsig);
13879 const char *sourceType;
13880 const char *targetType;
13890 if (funcInfo == NULL)
13891 pg_fatal(
"could not find function definition for function with OID %u",
13903 sourceType, targetType);
13906 sourceType, targetType);
13910 case COERCION_METHOD_BINARY:
13913 case COERCION_METHOD_INOUT:
13916 case COERCION_METHOD_FUNCTION:
13930 pg_log_warning(
"bogus value in pg_cast.castfunc or pg_cast.castmethod field");
13943 sourceType, targetType);
13946 sourceType, targetType);
13950 "CAST", castargs->
data, NULL);
13955 .description =
"CAST",
13957 .createStmt = defqry->
data,
13958 .dropStmt = delqry->
data));
13986 const char *transformType;
13996 if (fromsqlFuncInfo == NULL)
13997 pg_fatal(
"could not find function definition for function with OID %u",
14003 if (tosqlFuncInfo == NULL)
14004 pg_fatal(
"could not find function definition for function with OID %u",
14017 transformType, lanname);
14020 transformType, lanname);
14023 pg_log_warning(
"bogus transform definition, at least one of trffromsql and trftosql should be nonzero");
14027 if (fromsqlFuncInfo)
14067 transformType, lanname);
14070 transformType, lanname);
14074 "TRANSFORM", transformargs->
data, NULL);
14079 .description =
"TRANSFORM",
14081 .createStmt = defqry->
data,
14082 .dropStmt = delqry->
data,
14158 "PREPARE dumpOpr(pg_catalog.oid) AS\n"
14160 "oprcode::pg_catalog.regprocedure, "
14161 "oprleft::pg_catalog.regtype, "
14162 "oprright::pg_catalog.regtype, "
14165 "oprrest::pg_catalog.regprocedure, "
14166 "oprjoin::pg_catalog.regprocedure, "
14167 "oprcanmerge, oprcanhash "
14168 "FROM pg_catalog.pg_operator "
14177 "EXECUTE dumpOpr('%u')",
14185 i_oprright =
PQfnumber(res,
"oprright");
14187 i_oprnegate =
PQfnumber(res,
"oprnegate");
14190 i_oprcanmerge =
PQfnumber(res,
"oprcanmerge");
14191 i_oprcanhash =
PQfnumber(res,
"oprcanhash");
14198 oprnegate =
PQgetvalue(res, 0, i_oprnegate);
14201 oprcanmerge =
PQgetvalue(res, 0, i_oprcanmerge);
14202 oprcanhash =
PQgetvalue(res, 0, i_oprcanhash);
14205 if (strcmp(oprkind,
"r") == 0)
14206 pg_log_warning(
"postfix operators are not supported anymore (operator \"%s\")",
14224 if (strcmp(oprkind,
"r") == 0 ||
14225 strcmp(oprkind,
"b") == 0)
14233 if (strcmp(oprkind,
"l") == 0 ||
14234 strcmp(oprkind,
"b") == 0)
14256 if (strcmp(oprcanmerge,
"t") == 0)
14259 if (strcmp(oprcanhash,
"t") == 0)
14286 "OPERATOR",
oprid->data,
14287 oprinfo->
dobj.namespace->dobj.
name);
14292 .namespace = oprinfo->
dobj.namespace->dobj.
name,
14294 .description =
"OPERATOR",
14296 .createStmt = q->
data,
14297 .dropStmt = delq->
data));
14331 if (strcmp(proc,
"-") == 0)
14337 for (paren =
name; *paren; paren++)
14339 if (*paren ==
'(' && !inquote)
14345 inquote = !inquote;
14370 if (strcmp(oproid,
"0") == 0)
14374 if (oprInfo == NULL)
14381 return psprintf(
"OPERATOR(%s.%s)",
14402 "SELECT '%u'::pg_catalog.regproc", funcOid);
14445 aminfo->
amtype, qamname);
14459 "ACCESS METHOD", qamname, NULL);
14464 .description =
"ACCESS METHOD",
14466 .createStmt = q->
data,
14467 .dropStmt = delq->
data));
14498 int i_opcfamilyname;
14499 int i_opcfamilynsp;
14501 int i_amopstrategy;
14504 int i_sortfamilynsp;
14507 int i_amproclefttype;
14508 int i_amprocrighttype;
14513 char *opcfamilyname;
14514 char *opcfamilynsp;
14516 char *amopstrategy;
14519 char *sortfamilynsp;
14522 char *amproclefttype;
14523 char *amprocrighttype;
14538 "opckeytype::pg_catalog.regtype, "
14539 "opcdefault, opcfamily, "
14540 "opfname AS opcfamilyname, "
14541 "nspname AS opcfamilynsp, "
14542 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opcmethod) AS amname "
14543 "FROM pg_catalog.pg_opclass c "
14544 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = opcfamily "
14545 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14546 "WHERE c.oid = '%u'::pg_catalog.oid",
14551 i_opcintype =
PQfnumber(res,
"opcintype");
14552 i_opckeytype =
PQfnumber(res,
"opckeytype");
14553 i_opcdefault =
PQfnumber(res,
"opcdefault");
14554 i_opcfamily =
PQfnumber(res,
"opcfamily");
14555 i_opcfamilyname =
PQfnumber(res,
"opcfamilyname");
14556 i_opcfamilynsp =
PQfnumber(res,
"opcfamilynsp");
14561 opckeytype =
PQgetvalue(res, 0, i_opckeytype);
14562 opcdefault =
PQgetvalue(res, 0, i_opcdefault);
14565 opcfamilyname =
PQgetvalue(res, 0, i_opcfamilyname);
14566 opcfamilynsp =
PQgetvalue(res, 0, i_opcfamilynsp);
14578 if (strcmp(opcdefault,
"t") == 0)
14583 if (strlen(opcfamilyname) > 0)
14593 if (strcmp(opckeytype,
"-") != 0)
14610 "amopopr::pg_catalog.regoperator, "
14611 "opfname AS sortfamily, "
14612 "nspname AS sortfamilynsp "
14613 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14614 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14615 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14616 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14617 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14618 "AND refobjid = '%u'::pg_catalog.oid "
14619 "AND amopfamily = '%s'::pg_catalog.oid "
14620 "ORDER BY amopstrategy",
14628 i_amopstrategy =
PQfnumber(res,
"amopstrategy");
14630 i_sortfamily =
PQfnumber(res,
"sortfamily");
14631 i_sortfamilynsp =
PQfnumber(res,
"sortfamilynsp");
14633 for (
i = 0;
i < ntups;
i++)
14635 amopstrategy =
PQgetvalue(res,
i, i_amopstrategy);
14638 sortfamilynsp =
PQgetvalue(res,
i, i_sortfamilynsp);
14644 amopstrategy, amopopr);
14646 if (strlen(sortfamily) > 0)
14671 "amproc::pg_catalog.regprocedure, "
14672 "amproclefttype::pg_catalog.regtype, "
14673 "amprocrighttype::pg_catalog.regtype "
14674 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14675 "WHERE refclassid = 'pg_catalog.pg_opclass'::pg_catalog.regclass "
14676 "AND refobjid = '%u'::pg_catalog.oid "
14677 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14678 "AND objid = ap.oid "
14679 "ORDER BY amprocnum",
14686 i_amprocnum =
PQfnumber(res,
"amprocnum");
14688 i_amproclefttype =
PQfnumber(res,
"amproclefttype");
14689 i_amprocrighttype =
PQfnumber(res,
"amprocrighttype");
14691 for (
i = 0;
i < ntups;
i++)
14695 amproclefttype =
PQgetvalue(res,
i, i_amproclefttype);
14696 amprocrighttype =
PQgetvalue(res,
i, i_amprocrighttype);
14703 if (*amproclefttype && *amprocrighttype)
14730 "OPERATOR CLASS", nameusing->
data,
14731 opcinfo->
dobj.namespace->dobj.
name);
14736 .namespace = opcinfo->
dobj.namespace->dobj.
name,
14738 .description =
"OPERATOR CLASS",
14740 .createStmt = q->
data,
14741 .dropStmt = delq->
data));
14778 int i_amopstrategy;
14781 int i_sortfamilynsp;
14784 int i_amproclefttype;
14785 int i_amprocrighttype;
14787 char *amopstrategy;
14790 char *sortfamilynsp;
14793 char *amproclefttype;
14794 char *amprocrighttype;
14812 "amopopr::pg_catalog.regoperator, "
14813 "opfname AS sortfamily, "
14814 "nspname AS sortfamilynsp "
14815 "FROM pg_catalog.pg_amop ao JOIN pg_catalog.pg_depend ON "
14816 "(classid = 'pg_catalog.pg_amop'::pg_catalog.regclass AND objid = ao.oid) "
14817 "LEFT JOIN pg_catalog.pg_opfamily f ON f.oid = amopsortfamily "
14818 "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = opfnamespace "
14819 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14820 "AND refobjid = '%u'::pg_catalog.oid "
14821 "AND amopfamily = '%u'::pg_catalog.oid "
14822 "ORDER BY amopstrategy",
14831 "amproc::pg_catalog.regprocedure, "
14832 "amproclefttype::pg_catalog.regtype, "
14833 "amprocrighttype::pg_catalog.regtype "
14834 "FROM pg_catalog.pg_amproc ap, pg_catalog.pg_depend "
14835 "WHERE refclassid = 'pg_catalog.pg_opfamily'::pg_catalog.regclass "
14836 "AND refobjid = '%u'::pg_catalog.oid "
14837 "AND classid = 'pg_catalog.pg_amproc'::pg_catalog.regclass "
14838 "AND objid = ap.oid "
14839 "ORDER BY amprocnum",
14848 "(SELECT amname FROM pg_catalog.pg_am WHERE oid = opfmethod) AS amname "
14849 "FROM pg_catalog.pg_opfamily "
14850 "WHERE oid = '%u'::pg_catalog.oid",
14888 i_amopstrategy =
PQfnumber(res_ops,
"amopstrategy");
14889 i_amopopr =
PQfnumber(res_ops,
"amopopr");
14890 i_sortfamily =
PQfnumber(res_ops,
"sortfamily");
14891 i_sortfamilynsp =
PQfnumber(res_ops,
"sortfamilynsp");
14893 for (
i = 0;
i < ntups;
i++)
14895 amopstrategy =
PQgetvalue(res_ops,
i, i_amopstrategy);
14897 sortfamily =
PQgetvalue(res_ops,
i, i_sortfamily);
14898 sortfamilynsp =
PQgetvalue(res_ops,
i, i_sortfamilynsp);
14904 amopstrategy, amopopr);
14906 if (strlen(sortfamily) > 0)
14921 i_amprocnum =
PQfnumber(res_procs,
"amprocnum");
14922 i_amproc =
PQfnumber(res_procs,
"amproc");
14923 i_amproclefttype =
PQfnumber(res_procs,
"amproclefttype");
14924 i_amprocrighttype =
PQfnumber(res_procs,
"amprocrighttype");
14926 for (
i = 0;
i < ntups;
i++)
14928 amprocnum =
PQgetvalue(res_procs,
i, i_amprocnum);
14930 amproclefttype =
PQgetvalue(res_procs,
i, i_amproclefttype);
14931 amprocrighttype =
PQgetvalue(res_procs,
i, i_amprocrighttype);
14937 amprocnum, amproclefttype, amprocrighttype,
14952 "OPERATOR FAMILY", nameusing->
data,
14953 opfinfo->
dobj.namespace->dobj.
name);
14958 .namespace = opfinfo->
dobj.namespace->dobj.
name,
14960 .description =
"OPERATOR FAMILY",
14962 .createStmt = q->
data,
14963 .dropStmt = delq->
data));
14993 int i_collprovider;
14994 int i_collisdeterministic;
14998 int i_collicurules;
14999 const char *collprovider;
15000 const char *collcollate;
15001 const char *collctype;
15002 const char *colllocale;
15003 const char *collicurules;
15024 "'c' AS collprovider, "
15025 "NULL AS collversion, ");
15029 "collisdeterministic, ");
15032 "true AS collisdeterministic, ");
15039 "colliculocale AS colllocale, ");
15042 "NULL AS colllocale, ");
15049 "NULL AS collicurules, ");
15054 "FROM pg_catalog.pg_collation c "
15055 "WHERE c.oid = '%u'::pg_catalog.oid",
15060 i_collprovider =
PQfnumber(res,
"collprovider");
15061 i_collisdeterministic =
PQfnumber(res,
"collisdeterministic");
15062 i_collcollate =
PQfnumber(res,
"collcollate");
15063 i_collctype =
PQfnumber(res,
"collctype");
15064 i_colllocale =
PQfnumber(res,
"colllocale");
15065 i_collicurules =
PQfnumber(res,
"collicurules");
15067 collprovider =
PQgetvalue(res, 0, i_collprovider);
15070 collcollate =
PQgetvalue(res, 0, i_collcollate);
15072 collcollate = NULL;
15075 collctype =
PQgetvalue(res, 0, i_collctype);
15085 if (collcollate[0] ==
'\0')
15086 collcollate = NULL;
15087 if (collctype[0] ==
'\0')
15092 colllocale =
PQgetvalue(res, 0, i_colllocale);
15097 collicurules =
PQgetvalue(res, 0, i_collicurules);
15099 collicurules = NULL;
15108 if (collprovider[0] ==
'b')
15110 else if (collprovider[0] ==
'c')
15112 else if (collprovider[0] ==
'i')
15114 else if (collprovider[0] ==
'd')
15118 pg_fatal(
"unrecognized collation provider: %s",
15121 if (strcmp(
PQgetvalue(res, 0, i_collisdeterministic),
"f") == 0)
15124 if (collprovider[0] ==
'd')
15126 if (collcollate || collctype || colllocale || collicurules)
15131 else if (collprovider[0] ==
'b')
15133 if (collcollate || collctype || !colllocale || collicurules)
15140 else if (collprovider[0] ==
'i')
15144 if (collcollate || collctype || !colllocale)
15153 if (!collcollate || !collctype || colllocale ||
15154 strcmp(collcollate, collctype) != 0)
15167 else if (collprovider[0] ==
'c')
15169 if (colllocale || collicurules || !collcollate || !collctype)
15172 if (collcollate && collctype && strcmp(collcollate, collctype) == 0)
15186 pg_fatal(
"unrecognized collation provider: %s", collprovider);
15196 i_collversion =
PQfnumber(res,
"collversion");
15210 "COLLATION", qcollname,
15211 collinfo->
dobj.namespace->dobj.
name);
15216 .namespace = collinfo->
dobj.namespace->dobj.
name,
15218 .description =
"COLLATION",
15220 .createStmt = q->
data,
15221 .dropStmt = delq->
data));
15250 int i_conforencoding;
15251 int i_contoencoding;
15254 const char *conforencoding;
15255 const char *contoencoding;
15256 const char *conproc;
15271 "pg_catalog.pg_encoding_to_char(conforencoding) AS conforencoding, "
15272 "pg_catalog.pg_encoding_to_char(contoencoding) AS contoencoding, "
15273 "conproc, condefault "
15274 "FROM pg_catalog.pg_conversion c "
15275 "WHERE c.oid = '%u'::pg_catalog.oid",
15280 i_conforencoding =
PQfnumber(res,
"conforencoding");
15281 i_contoencoding =
PQfnumber(res,
"contoencoding");
15283 i_condefault =
PQfnumber(res,
"condefault");
15285 conforencoding =
PQgetvalue(res, 0, i_conforencoding);
15286 contoencoding =
PQgetvalue(res, 0, i_contoencoding);
15288 condefault = (
PQgetvalue(res, 0, i_condefault)[0] ==
't');
15294 (condefault) ?
"DEFAULT " :
"",
15304 "CONVERSION", qconvname,
15305 convinfo->
dobj.namespace->dobj.
name);
15310 .namespace = convinfo->
dobj.namespace->dobj.
name,
15312 .description =
"CONVERSION",
15314 .createStmt = q->
data,
15315 .dropStmt = delq->
data));
15349 if (agginfo->aggfn.nargs == 0)
15354 for (
j = 0;
j < agginfo->aggfn.nargs;
j++)
15356 (
j > 0) ?
", " :
"",
15358 agginfo->aggfn.argtypes[
j],
15378 char *aggfullsig = NULL;
15383 const char *aggtransfn;
15384 const char *aggfinalfn;
15385 const char *aggcombinefn;
15386 const char *aggserialfn;
15387 const char *aggdeserialfn;
15388 const char *aggmtransfn;
15389 const char *aggminvtransfn;
15390 const char *aggmfinalfn;
15391 bool aggfinalextra;
15392 bool aggmfinalextra;
15393 char aggfinalmodify;
15394 char aggmfinalmodify;
15395 const char *aggsortop;
15396 char *aggsortconvop;
15398 const char *aggtranstype;
15399 const char *aggtransspace;
15400 const char *aggmtranstype;
15401 const char *aggmtransspace;
15402 const char *agginitval;
15403 const char *aggminitval;
15404 const char *proparallel;
15405 char defaultfinalmodify;
15420 "PREPARE dumpAgg(pg_catalog.oid) AS\n");
15426 "aggtranstype::pg_catalog.regtype,\n"
15429 "pg_catalog.pg_get_function_arguments(p.oid) AS funcargs,\n"
15430 "pg_catalog.pg_get_function_identity_arguments(p.oid) AS funciargs,\n");
15436 "aggminvtransfn,\n"
15438 "aggmtranstype::pg_catalog.regtype,\n"
15440 "aggmfinalextra,\n"
15442 "aggmtransspace,\n"
15446 "'n' AS aggkind,\n"
15447 "'-' AS aggmtransfn,\n"
15448 "'-' AS aggminvtransfn,\n"
15449 "'-' AS aggmfinalfn,\n"
15450 "0 AS aggmtranstype,\n"
15451 "false AS aggfinalextra,\n"
15452 "false AS aggmfinalextra,\n"
15453 "0 AS aggtransspace,\n"
15454 "0 AS aggmtransspace,\n"
15455 "NULL AS aggminitval,\n");
15465 "'-' AS aggcombinefn,\n"
15466 "'-' AS aggserialfn,\n"
15467 "'-' AS aggdeserialfn,\n"
15468 "'u' AS proparallel,\n");
15472 "aggfinalmodify,\n"
15473 "aggmfinalmodify\n");
15476 "'0' AS aggfinalmodify,\n"
15477 "'0' AS aggmfinalmodify\n");
15480 "FROM pg_catalog.pg_aggregate a, pg_catalog.pg_proc p "
15481 "WHERE a.aggfnoid = p.oid "
15490 "EXECUTE dumpAgg('%u')",
15491 agginfo->aggfn.dobj.catId.oid);
15495 i_agginitval =
PQfnumber(res,
"agginitval");
15496 i_aggminitval =
PQfnumber(res,
"aggminitval");
15516 agginitval =
PQgetvalue(res, 0, i_agginitval);
15517 aggminitval =
PQgetvalue(res, 0, i_aggminitval);
15533 defaultfinalmodify = (aggkind == AGGKIND_NORMAL) ? AGGMODIFY_READ_ONLY : AGGMODIFY_READ_WRITE;
15535 if (aggfinalmodify ==
'0')
15536 aggfinalmodify = defaultfinalmodify;
15537 if (aggmfinalmodify ==
'0')
15538 aggmfinalmodify = defaultfinalmodify;
15542 aggtransfn, aggtranstype);
15544 if (strcmp(aggtransspace,
"0") != 0)
15556 if (strcmp(aggfinalfn,
"-") != 0)
15562 if (aggfinalmodify != defaultfinalmodify)
15564 switch (aggfinalmodify)
15566 case AGGMODIFY_READ_ONLY:
15569 case AGGMODIFY_SHAREABLE:
15572 case AGGMODIFY_READ_WRITE:
15576 pg_fatal(
"unrecognized aggfinalmodify value for aggregate \"%s\"",
15577 agginfo->aggfn.dobj.name);
15583 if (strcmp(aggcombinefn,
"-") != 0)
15586 if (strcmp(aggserialfn,
"-") != 0)
15589 if (strcmp(aggdeserialfn,
"-") != 0)
15592 if (strcmp(aggmtransfn,
"-") != 0)
15600 if (strcmp(aggmtransspace,
"0") != 0)
15612 if (strcmp(aggmfinalfn,
"-") != 0)
15616 if (aggmfinalextra)
15618 if (aggmfinalmodify != defaultfinalmodify)
15620 switch (aggmfinalmodify)
15622 case AGGMODIFY_READ_ONLY:
15625 case AGGMODIFY_SHAREABLE:
15628 case AGGMODIFY_READ_WRITE:
15632 pg_fatal(
"unrecognized aggmfinalmodify value for aggregate \"%s\"",
15633 agginfo->aggfn.dobj.name);
15644 free(aggsortconvop);
15647 if (aggkind == AGGKIND_HYPOTHETICAL)
15650 if (proparallel[0] != PROPARALLEL_UNSAFE)
15652 if (proparallel[0] == PROPARALLEL_SAFE)
15654 else if (proparallel[0] == PROPARALLEL_RESTRICTED)
15656 else if (proparallel[0] != PROPARALLEL_UNSAFE)
15657 pg_fatal(
"unrecognized proparallel value for function \"%s\"",
15658 agginfo->aggfn.dobj.name);
15662 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
15666 fmtId(agginfo->aggfn.dobj.namespace->dobj.name),
15667 aggfullsig ? aggfullsig : aggsig, details->
data);
15671 "AGGREGATE", aggsig,
15672 agginfo->aggfn.dobj.namespace->dobj.name);
15676 agginfo->aggfn.dobj.dumpId,
15678 .
namespace = agginfo->aggfn.dobj.namespace->dobj.name,
15679 .owner = agginfo->aggfn.rolname,
15680 .description =
"AGGREGATE",
15682 .createStmt = q->
data,
15683 .dropStmt = delq->
data));
15688 agginfo->aggfn.dobj.namespace->dobj.name,
15689 agginfo->aggfn.rolname,
15690 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
15694 agginfo->aggfn.dobj.namespace->dobj.name,
15695 agginfo->aggfn.rolname,
15696 agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
15709 "FUNCTION", aggsig, NULL,
15710 agginfo->aggfn.dobj.namespace->dobj.name,
15711 NULL, agginfo->aggfn.rolname, &agginfo->aggfn.dacl);
15766 "TEXT SEARCH PARSER", qprsname,
15767 prsinfo->
dobj.namespace->dobj.
name);
15772 .namespace = prsinfo->
dobj.namespace->dobj.
name,
15773 .description =
"TEXT SEARCH PARSER",
15775 .createStmt = q->
data,
15776 .dropStmt = delq->
data));
15780 dumpComment(fout,
"TEXT SEARCH PARSER", qprsname,
15781 prsinfo->
dobj.namespace->dobj.
name,
"",
15817 "FROM pg_ts_template p, pg_namespace n "
15818 "WHERE p.oid = '%u' AND n.oid = tmplnamespace",
15844 "TEXT SEARCH DICTIONARY", qdictname,
15845 dictinfo->
dobj.namespace->dobj.
name);
15850 .namespace = dictinfo->
dobj.namespace->dobj.
name,
15852 .description =
"TEXT SEARCH DICTIONARY",
15854 .createStmt = q->
data,
15855 .dropStmt = delq->
data));
15859 dumpComment(fout,
"TEXT SEARCH DICTIONARY", qdictname,
15904 "TEXT SEARCH TEMPLATE", qtmplname,
15905 tmplinfo->
dobj.namespace->dobj.
name);
15910 .namespace = tmplinfo->
dobj.namespace->dobj.
name,
15911 .description =
"TEXT SEARCH TEMPLATE",
15913 .createStmt = q->
data,
15914 .dropStmt = delq->
data));
15918 dumpComment(fout,
"TEXT SEARCH TEMPLATE", qtmplname,
15919 tmplinfo->
dobj.namespace->dobj.
name,
"",
15959 "FROM pg_ts_parser p, pg_namespace n "
15960 "WHERE p.oid = '%u' AND n.oid = prsnamespace",
15977 " ( SELECT alias FROM pg_catalog.ts_token_type('%u'::pg_catalog.oid) AS t\n"
15978 " WHERE t.tokid = m.maptokentype ) AS tokenname,\n"
15979 " m.mapdict::pg_catalog.regdictionary AS dictname\n"
15980 "FROM pg_catalog.pg_ts_config_map AS m\n"
15981 "WHERE m.mapcfg = '%u'\n"
15982 "ORDER BY m.mapcfg, m.maptokentype, m.mapseqno",
15988 i_tokenname =
PQfnumber(res,
"tokenname");
15989 i_dictname =
PQfnumber(res,
"dictname");
15991 for (
i = 0;
i < ntups;
i++)
15993 char *tokenname =
PQgetvalue(res,
i, i_tokenname);
15997 strcmp(tokenname,
PQgetvalue(res,
i - 1, i_tokenname)) != 0)
16006 fmtId(tokenname), dictname);
16022 "TEXT SEARCH CONFIGURATION", qcfgname,
16023 cfginfo->
dobj.namespace->dobj.
name);
16028 .namespace = cfginfo->
dobj.namespace->dobj.
name,
16030 .description =
"TEXT SEARCH CONFIGURATION",
16032 .createStmt = q->
data,
16033 .dropStmt = delq->
data));
16037 dumpComment(fout,
"TEXT SEARCH CONFIGURATION", qcfgname,
16087 "FOREIGN DATA WRAPPER", qfdwname,
16094 .description =
"FOREIGN DATA WRAPPER",
16096 .createStmt = q->
data,
16097 .dropStmt = delq->
data));
16101 dumpComment(fout,
"FOREIGN DATA WRAPPER", qfdwname,
16108 "FOREIGN DATA WRAPPER", qfdwname, NULL, NULL,
16144 "FROM pg_foreign_data_wrapper w "
16145 "WHERE w.oid = '%u'",
16175 "SERVER", qsrvname, NULL);
16181 .description =
"SERVER",
16183 .createStmt = q->
data,
16184 .dropStmt = delq->
data));
16195 "FOREIGN SERVER", qsrvname, NULL, NULL,
16223 const char *servername,
const char *
namespace,
16252 "array_to_string(ARRAY("
16253 "SELECT quote_ident(option_name) || ' ' || "
16254 "quote_literal(option_value) "
16255 "FROM pg_options_to_table(umoptions) "
16256 "ORDER BY option_name"
16257 "), E',\n ') AS umoptions "
16258 "FROM pg_user_mappings "
16259 "WHERE srvid = '%u' "
16260 "ORDER BY usename",
16267 i_umoptions =
PQfnumber(res,
"umoptions");
16269 for (
i = 0;
i < ntups;
i++)
16281 if (umoptions && strlen(umoptions) > 0)
16292 usename, servername);
16296 .namespace =
namespace,
16298 .description =
"USER MAPPING",
16300 .createStmt = q->
data,
16301 .dropStmt = delq->
data));
16332 case DEFACLOBJ_RELATION:
16335 case DEFACLOBJ_SEQUENCE:
16336 type =
"SEQUENCES";
16338 case DEFACLOBJ_FUNCTION:
16339 type =
"FUNCTIONS";
16341 case DEFACLOBJ_TYPE:
16344 case DEFACLOBJ_NAMESPACE:
16347 case DEFACLOBJ_LARGEOBJECT:
16348 type =
"LARGE OBJECTS";
16352 pg_fatal(
"unrecognized object type in default privileges: %d",
16361 daclinfo->
dobj.namespace != NULL ?
16362 daclinfo->
dobj.namespace->dobj.
name : NULL,
16368 pg_fatal(
"could not parse default ACL list (%s)",
16374 .namespace = daclinfo->
dobj.namespace ?
16375 daclinfo->
dobj.namespace->dobj.
name : NULL,
16377 .description =
"DEFAULT ACL",
16379 .createStmt = q->
data));
16410 const char *nspname,
const char *tag,
const char *owner,
16415 const char *acls = dacl->
acl;
16418 const char *initprivs = dacl->
initprivs;
16419 const char *baseacls;
16446 initprivs && *initprivs !=
'\0')
16452 pg_fatal(
"could not parse initial ACL list (%s) or default (%s) for object \"%s\" (%s)",
16454 appendPQExpBufferStr(sql,
"SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
16465 if (initprivs && *initprivs !=
'\0')
16467 baseacls = initprivs;
16468 if (acls == NULL || *acls ==
'\0')
16475 acls, baseacls, owner,
16477 pg_fatal(
"could not parse ACL list (%s) or default (%s) for object \"%s\" (%s)",
16493 aclDeps[nDeps++] = objDumpId;
16495 aclDeps[nDeps++] = altDumpId;
16501 .namespace = nspname,
16503 .description =
"ACL",
16505 .createStmt = sql->
data,
16537 const char *
namespace,
const char *owner,
16554 if (strcmp(
type,
"LARGE OBJECT") != 0)
16571 for (
i = 0;
i < nlabels;
i++)
16576 if (labels[
i].objsubid != subid)
16580 "SECURITY LABEL FOR %s ON %s ",
16582 if (
namespace && *
namespace)
16589 if (query->
len > 0)
16596 .namespace =
namespace,
16598 .description =
"SECURITY LABEL",
16600 .createStmt = query->
data,
16645 for (
i = 0;
i < nlabels;
i++)
16647 const char *colname;
16671 if (query->
len > 0)
16678 .namespace = tbinfo->
dobj.namespace->dobj.
name,
16680 .description =
"SECURITY LABEL",
16682 .createStmt = query->
data,
16716 while (low <= high)
16718 middle = low + (high - low) / 2;
16720 if (classoid < middle->classoid)
16722 else if (classoid > middle->
classoid)
16724 else if (objoid < middle->objoid)
16726 else if (objoid > middle->
objoid)
16744 while (middle > low)
16746 if (classoid != middle[-1].classoid ||
16747 objoid != middle[-1].objoid)
16756 while (middle <= high)
16758 if (classoid != middle->
classoid ||
16759 objoid != middle->
objoid)
16793 "SELECT label, provider, classoid, objoid, objsubid "
16794 "FROM pg_catalog.pg_seclabels "
16795 "ORDER BY classoid, objoid, objsubid");
16801 i_provider =
PQfnumber(res,
"provider");
16802 i_classoid =
PQfnumber(res,
"classoid");
16804 i_objsubid =
PQfnumber(res,
"objsubid");
16812 for (
i = 0;
i < ntups;
i++)
16822 if (dobj == NULL ||
16835 ((
TableInfo *) dobj)->relkind == RELKIND_COMPOSITE_TYPE)
16875 if (tbinfo->
relkind == RELKIND_SEQUENCE)
16885 const char *objtype =
16886 (tbinfo->
relkind == RELKIND_SEQUENCE) ?
"SEQUENCE" :
"TABLE";
16890 objtype, namecopy, NULL,
16891 tbinfo->
dobj.namespace->dobj.
name,
16911 "PREPARE getColumnACLs(pg_catalog.oid) AS\n");
16926 "SELECT at.attname, "
16928 "'{}' AS acldefault, "
16929 "pip.privtype, pip.initprivs "
16930 "FROM pg_catalog.pg_attribute at "
16931 "LEFT JOIN pg_catalog.pg_init_privs pip ON "
16932 "(at.attrelid = pip.objoid "
16933 "AND pip.classoid = 'pg_catalog.pg_class'::pg_catalog.regclass "
16934 "AND at.attnum = pip.objsubid) "
16935 "WHERE at.attrelid = $1 AND "
16936 "NOT at.attisdropped "
16937 "AND (at.attacl IS NOT NULL OR pip.initprivs IS NOT NULL) "
16938 "ORDER BY at.attnum");
16943 "SELECT attname, attacl, '{}' AS acldefault, "
16944 "NULL AS privtype, NULL AS initprivs "
16945 "FROM pg_catalog.pg_attribute "
16946 "WHERE attrelid = $1 AND NOT attisdropped "
16947 "AND attacl IS NOT NULL "
16948 "ORDER BY attnum");
16957 "EXECUTE getColumnACLs('%u')",
16972 coldacl.
acl = attacl;
16984 "TABLE", namecopy, attnamecopy,
16985 tbinfo->
dobj.namespace->dobj.
name,
16986 NULL, tbinfo->
rolname, &coldacl);
17012 "SELECT pg_catalog.pg_get_viewdef('%u'::pg_catalog.oid) AS viewdef",
17020 pg_fatal(
"query to obtain definition of view \"%s\" returned no data",
17023 pg_fatal(
"query to obtain definition of view \"%s\" returned more than one definition",
17030 pg_fatal(
"definition of view \"%s\" appears to be empty (length zero)",
17103 const char *reltypename;
17115 pg_log_warning(
"WITH OIDS is not supported anymore (table \"%s\")",
17122 if (tbinfo->
relkind == RELKIND_VIEW)
17130 reltypename =
"VIEW";
17161 char *partkeydef = NULL;
17162 char *ftoptions = NULL;
17163 char *srvname = NULL;
17164 const char *foreign =
"";
17172 case RELKIND_PARTITIONED_TABLE:
17177 reltypename =
"TABLE";
17181 "SELECT pg_get_partkeydef('%u')",
17189 case RELKIND_FOREIGN_TABLE:
17196 reltypename =
"FOREIGN TABLE";
17200 "SELECT fs.srvname, "
17201 "pg_catalog.array_to_string(ARRAY("
17202 "SELECT pg_catalog.quote_ident(option_name) || "
17203 "' ' || pg_catalog.quote_literal(option_value) "
17204 "FROM pg_catalog.pg_options_to_table(ftoptions) "
17205 "ORDER BY option_name"
17206 "), E',\n ') AS ftoptions "
17207 "FROM pg_catalog.pg_foreign_table ft "
17208 "JOIN pg_catalog.pg_foreign_server fs "
17209 "ON (fs.oid = ft.ftserver) "
17210 "WHERE ft.ftrelid = '%u'",
17214 i_ftoptions =
PQfnumber(res,
"ftoptions");
17220 foreign =
"FOREIGN ";
17223 case RELKIND_MATVIEW:
17224 reltypename =
"MATERIALIZED VIEW";
17227 reltypename =
"TABLE";
17246 tbinfo->
relkind != RELKIND_PARTITIONED_TABLE) ?
17260 if (tbinfo->
relkind != RELKIND_MATVIEW)
17274 bool print_default;
17275 bool print_notnull;
17281 print_default = (tbinfo->
attrdefs[
j] != NULL &&
17300 !print_default && !print_notnull &&
17305 if (actual_atts == 0)
17344 else if (tbinfo->
attgenerated[
j] == ATTRIBUTE_GENERATED_VIRTUAL)
17392 if (actual_atts == 0)
17425 if (actual_atts == 0)
17456 for (k = 0; k < numParents; k++)
17467 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
17470 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
17477 bool addcomma =
false;
17496 if (ftoptions && ftoptions[0])
17503 if (tbinfo->
relkind == RELKIND_MATVIEW)
17516 if (tbinfo->
relkind == RELKIND_MATVIEW)
17518 "pg_catalog.pg_class",
17519 "MATERIALIZED VIEW",
17534 "SELECT pg_catalog.binary_upgrade_set_missing_value(");
17567 (tbinfo->
relkind == RELKIND_RELATION ||
17568 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ||
17569 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE))
17572 bool firstitem_extra;
17589 "UPDATE pg_catalog.pg_attribute\n"
17590 "SET attlen = v.dlen, "
17591 "attalign = v.dalign, "
17592 "attbyval = false\n"
17605 foreign, qualrelname);
17613 "WHERE attrelid = ");
17616 " AND attname = v.dname;\n");
17635 "SET attislocal = false\n"
17636 "WHERE attrelid = ");
17639 " AND attname IN (");
17657 firstitem_extra =
true;
17678 "SET conislocal = false\n"
17679 "WHERE contype = 'n' AND conrelid = ");
17691 if (firstitem_extra)
17694 "SET conislocal = false\n"
17695 "WHERE contype = 'n' AND conrelid = ");
17699 firstitem_extra =
false;
17709 if (!firstitem_extra)
17712 if (extra->
len > 0)
17729 for (k = 0; k < tbinfo->
ncheck; k++)
17739 foreign, qualrelname,
17746 "SET conislocal = false\n"
17747 "WHERE contype = 'c' AND conrelid = ");
17766 for (k = 0; k < numParents; k++)
17794 (tbinfo->
relkind == RELKIND_RELATION ||
17795 tbinfo->
relkind == RELKIND_MATVIEW))
17799 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17811 appendPQExpBufferStr(q,
"\n-- For binary upgrade, set toast's relfrozenxid and relminmxid\n");
17813 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
17814 "WHERE oid = '%u';\n",
17832 "SET relispopulated = 't'\n"
17854 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STATISTICS %d;\n",
17855 foreign, qualrelname,
17867 case TYPSTORAGE_PLAIN:
17870 case TYPSTORAGE_EXTERNAL:
17873 case TYPSTORAGE_EXTENDED:
17876 case TYPSTORAGE_MAIN:
17887 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET STORAGE %s;\n",
17888 foreign, qualrelname,
17898 const char *cmname;
17913 if (cmname != NULL)
17914 appendPQExpBuffer(q,
"ALTER %sTABLE ONLY %s ALTER COLUMN %s SET COMPRESSION %s;\n",
17915 foreign, qualrelname,
17925 foreign, qualrelname,
17932 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
17935 "ALTER FOREIGN TABLE ONLY %s ALTER COLUMN %s OPTIONS (\n"
17951 if ((tbinfo->
relkind == RELKIND_RELATION ||
17952 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ||
17953 tbinfo->
relkind == RELKIND_MATVIEW) &&
17960 else if (tbinfo->
relreplident == REPLICA_IDENTITY_NOTHING)
17965 else if (tbinfo->
relreplident == REPLICA_IDENTITY_FULL)
17978 reltypename, qrelname,
17979 tbinfo->
dobj.namespace->dobj.
name);
17984 char *tableam = NULL;
17993 if (RELKIND_HAS_TABLESPACE(tbinfo->
relkind))
17996 if (RELKIND_HAS_TABLE_AM(tbinfo->
relkind) ||
17997 tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
17998 tableam = tbinfo->
amname;
18002 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18004 .tableam = tableam,
18007 .description = reltypename,
18010 .createStmt = q->
data,
18011 .dropStmt = delq->
data));
18058 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18060 .description =
"COMMENT",
18124 "PREPARE dumpTableAttach(pg_catalog.oid) AS\n");
18127 "SELECT pg_get_expr(c.relpartbound, c.oid) "
18129 "WHERE c.oid = $1");
18137 "EXECUTE dumpTableAttach('%u')",
18145 "ALTER TABLE ONLY %s ",
18148 "ATTACH PARTITION %s %s;\n",
18161 .namespace = attachinfo->
dobj.namespace->dobj.
name,
18163 .description =
"TABLE ATTACH",
18165 .createStmt = q->
data));
18179 int adnum = adinfo->
adnum;
18199 foreign = tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
18202 "ALTER %sTABLE ONLY %s ALTER COLUMN %s SET DEFAULT %s;\n",
18207 foreign, qualrelname,
18215 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18217 .description =
"DEFAULT",
18219 .createStmt = q->
data,
18220 .dropStmt = delq->
data));
18238 if (attrnum > 0 && attrnum <= tblInfo->numatts)
18239 return tblInfo->
attnames[attrnum - 1];
18255 pg_fatal(
"invalid column number %d for table \"%s\"",
18292 if (!is_constraint)
18296 char **indstatcolsarray = NULL;
18297 char **indstatvalsarray = NULL;
18328 if (strlen(indstatcols) != 0 || strlen(indstatvals) != 0)
18332 if (!
parsePGArray(indstatcols, &indstatcolsarray, &nstatcols))
18333 pg_fatal(
"could not parse index statistic columns");
18334 if (!
parsePGArray(indstatvals, &indstatvalsarray, &nstatvals))
18335 pg_fatal(
"could not parse index statistic values");
18336 if (nstatcols != nstatvals)
18337 pg_fatal(
"mismatched number of columns and values for index statistics");
18339 for (
j = 0;
j < nstatcols;
j++)
18348 indstatcolsarray[
j]);
18350 indstatvalsarray[
j]);
18356 "pg_catalog.pg_class",
18357 "INDEX", qqindxname);
18384 .namespace = tbinfo->
dobj.namespace->dobj.
name,
18387 .description =
"INDEX",
18389 .createStmt = q->
data,
18390 .dropStmt = delq->
data));
18392 free(indstatcolsarray);
18393 free(indstatvalsarray);
18399 tbinfo->
dobj.namespace->dobj.
name,
18444 .namespace = attachinfo->
dobj.namespace->dobj.
name,
18446 .description =
"INDEX ATTACH",
18448 .createStmt = q->
data));
18465 char *qstatsextname;
18480 "pg_catalog.pg_get_statisticsobjdef('%u'::pg_catalog.oid)",
18509 .namespace = statsextinfo->
dobj.namespace->dobj.
name,
18510 .owner = statsextinfo->
rolname,
18511 .description =
"STATISTICS",
18513 .createStmt = q->
data,
18514 .dropStmt = delq->
data));
18519 statsextinfo->
dobj.namespace->dobj.
name,
18528 free(qstatsextname);
18552 foreign = tbinfo &&
18553 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"";
18555 if (coninfo->
contype ==
'p' ||
18565 if (indxinfo == NULL)
18566 pg_fatal(
"missing index for constraint \"%s\"",
18586 coninfo->
contype ==
'p' ?
"PRIMARY KEY" :
"UNIQUE");
18599 int indkey = (int) indxinfo->
indkeys[k];
18607 (k == 0) ?
"" :
", ",
18616 for (k = indxinfo->
indnkeyattrs; k < indxinfo->indnattrs; k++)
18618 int indkey = (int) indxinfo->
indkeys[k];
18677 "pg_catalog.pg_class",
"INDEX",
18690 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18693 .description =
"CONSTRAINT",
18695 .createStmt = q->
data,
18696 .dropStmt = delq->
data));
18698 else if (coninfo->
contype ==
'f')
18708 only = tbinfo->
relkind == RELKIND_PARTITIONED_TABLE ?
"" :
"ONLY ";
18730 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18732 .description =
"FK CONSTRAINT",
18734 .createStmt = q->
data,
18735 .dropStmt = delq->
data));
18737 else if ((coninfo->
contype ==
'c' || coninfo->
contype ==
'n') && tbinfo)
18744 const char *keyword;
18747 keyword =
"CHECK CONSTRAINT";
18749 keyword =
"CONSTRAINT";
18768 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
18770 .description = keyword,
18772 .createStmt = q->
data,
18773 .dropStmt = delq->
data));
18776 else if (tbinfo == NULL)
18786 const char *keyword;
18789 keyword =
"CHECK CONSTRAINT";
18791 keyword =
"CONSTRAINT";
18809 .
namespace = tyinfo->
dobj.namespace->dobj.
name,
18811 .description = keyword,
18813 .createStmt = q->
data,
18814 .dropStmt = delq->
data));
18825 tyinfo->
dobj.namespace->dobj.
name,
18835 pg_fatal(
"unrecognized constraint type: %c",
18840 if (tbinfo && coninfo->
separate &&
18870 tbinfo->
dobj.namespace->dobj.
name,
18928 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
18929 "seqstart, seqincrement, "
18931 "seqcache, seqcycle, "
18933 "FROM pg_catalog.pg_sequence "
18934 "ORDER BY seqrelid";
18936 query =
"SELECT seqrelid, format_type(seqtypid, NULL), "
18937 "seqstart, seqincrement, "
18939 "seqcache, seqcycle, "
18940 "last_value, is_called "
18941 "FROM pg_catalog.pg_sequence, "
18942 "pg_get_sequence_data(seqrelid) "
18943 "ORDER BY seqrelid;";
18977 int64 default_minv,
19012 "SELECT 'bigint' AS sequence_type, "
19013 "start_value, increment_by, max_value, min_value, "
19014 "cache_value, is_cycled FROM %s",
19020 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19021 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19038 is_ascending = (seq->
incby >= 0);
19057 default_minv = default_maxv = 0;
19090 "ALTER COLUMN %s ADD GENERATED ",
19106 "UNLOGGED" :
"LOGGED");
19111 "CREATE %sSEQUENCE %s\n",
19124 if (seq->
minv != default_minv)
19129 if (seq->
maxv != default_maxv)
19147 "SEQUENCE", qseqname,
19148 tbinfo->
dobj.namespace->dobj.
name);
19153 .namespace = tbinfo->
dobj.namespace->dobj.
name,
19155 .description =
"SEQUENCE",
19157 .createStmt = query->
data,
19158 .dropStmt = delqry->
data));
19176 if (owning_tab == NULL)
19177 pg_fatal(
"failed sanity check, parent table with OID %u of sequence with OID %u not found",
19193 .namespace = tbinfo->
dobj.namespace->dobj.
name,
19195 .description =
"SEQUENCE OWNED BY",
19197 .createStmt = query->
data,
19246 "SELECT last_value, is_called FROM %s",
19252 pg_fatal(
ngettext(
"query to get data of sequence \"%s\" returned %d row (expected 1)",
19253 "query to get data of sequence \"%s\" returned %d rows (expected 1)",
19257 last = strtoi64(
PQgetvalue(res, 0, 0), NULL, 10);
19258 called = (strcmp(
PQgetvalue(res, 0, 1),
"t") == 0);
19282 last, (called ?
"true" :
"false"));
19287 .namespace = tbinfo->
dobj.namespace->dobj.
name,
19289 .description =
"SEQUENCE SET",
19291 .createStmt = query->
data,
19333 "pg_catalog.pg_trigger",
"TRIGGER",
19334 trigidentity->
data);
19349 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
19374 tbinfo->
relkind == RELKIND_FOREIGN_TABLE ?
"FOREIGN " :
"",
19404 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
19406 .description =
"TRIGGER",
19408 .createStmt = query->
data,
19409 .dropStmt = delqry->
data));
19450 if (strcmp(
"", evtinfo->
evttags) != 0)
19488 "EVENT TRIGGER", qevtname, NULL);
19494 .description =
"EVENT TRIGGER",
19496 .createStmt = query->
data,
19497 .dropStmt = delqry->
data));
19584 "SELECT pg_catalog.pg_get_ruledef('%u'::pg_catalog.oid)",
19590 pg_fatal(
"query to get rule \"%s\" for table \"%s\" failed: wrong number of rows returned",
19653 .
namespace = tbinfo->
dobj.namespace->dobj.
name,
19655 .description =
"RULE",
19657 .createStmt = cmd->
data,
19658 .dropStmt = delcmd->
data));
19663 tbinfo->
dobj.namespace->dobj.
name,
19699 if (numExtensions == 0)
19706 "classid, objid, refobjid "
19708 "WHERE refclassid = 'pg_extension'::regclass "
19709 "AND deptype = 'e' "
19718 i_refobjid =
PQfnumber(res,
"refobjid");
19727 for (
i = 0;
i < ntups;
i++)
19743 pg_log_warning(
"could not find referenced extension %u", extId);
19791 if (numExtensions == 0)
19805 for (
i = 0;
i < numExtensions;
i++)
19810 char **extconfigarray = NULL;
19811 char **extconditionarray = NULL;
19812 int nconfigitems = 0;
19813 int nconditionitems = 0;
19833 if (strlen(extconfig) != 0 || strlen(extcondition) != 0)
19837 if (!
parsePGArray(extconfig, &extconfigarray, &nconfigitems))
19838 pg_fatal(
"could not parse %s array",
"extconfig");
19839 if (!
parsePGArray(extcondition, &extconditionarray, &nconditionitems))
19840 pg_fatal(
"could not parse %s array",
"extcondition");
19841 if (nconfigitems != nconditionitems)
19842 pg_fatal(
"mismatched number of configurations and conditions for extension");
19844 for (
j = 0;
j < nconfigitems;
j++)
19847 Oid configtbloid =
atooid(extconfigarray[
j]);
19852 if (configtbl == NULL)
19868 if (configtbl->
dobj.namespace->dobj.
dump &
19887 if (configtbl->
dataObj != NULL)
19889 if (strlen(extconditionarray[
j]) > 0)
19895 if (extconfigarray)
19896 free(extconfigarray);
19897 if (extconditionarray)
19898 free(extconditionarray);
19913 "SELECT conrelid, confrelid "
19914 "FROM pg_constraint "
19915 "JOIN pg_depend ON (objid = confrelid) "
19916 "WHERE contype = 'f' "
19917 "AND refclassid = 'pg_extension'::regclass "
19918 "AND classid = 'pg_class'::regclass;");
19923 i_conrelid =
PQfnumber(res,
"conrelid");
19924 i_confrelid =
PQfnumber(res,
"confrelid");
19927 for (
i = 0;
i < ntups;
i++)
19939 if (reftable == NULL ||
19941 contable == NULL ||
19987 "classid, objid, refclassid, refobjid, deptype "
19989 "WHERE deptype != 'p' AND deptype != 'e'\n");
20002 "SELECT 'pg_opfamily'::regclass AS classid, amopfamily AS objid, refclassid, refobjid, deptype "
20003 "FROM pg_depend d, pg_amop o "
20004 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20005 "classid = 'pg_amop'::regclass AND objid = o.oid "
20006 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amopfamily = refobjid)\n");
20010 "SELECT 'pg_opfamily'::regclass AS classid, amprocfamily AS objid, refclassid, refobjid, deptype "
20011 "FROM pg_depend d, pg_amproc p "
20012 "WHERE deptype NOT IN ('p', 'e', 'i') AND "
20013 "classid = 'pg_amproc'::regclass AND objid = p.oid "
20014 "AND NOT (refclassid = 'pg_opfamily'::regclass AND amprocfamily = refobjid)\n");
20025 i_refclassid =
PQfnumber(res,
"refclassid");
20026 i_refobjid =
PQfnumber(res,
"refobjid");
20036 for (
i = 0;
i < ntups;
i++)
20048 if (dobj == NULL ||
20068 if (refdobj == NULL)
20083 if (deptype ==
'x')
20093 if (deptype ==
'i' &&
20144 for (
i = 0;
i < numObjs;
i++)
20208 if (((
RuleInfo *) dobj)->separate)
20287 if (dobj->
nDeps <= 0)
20295 &dependencies, &nDeps, &allocDeps);
20300 nDeps *
sizeof(
DumpId));
20305 free(dependencies);
20312 DumpId **dependencies,
int *nDeps,
int *allocDeps)
20331 if (*nDeps >= *allocDeps)
20335 *allocDeps *
sizeof(
DumpId));
20337 (*dependencies)[*nDeps] = depid;
20351 dependencies, nDeps, allocDeps);
20384 if (typeInfo && typeInfo->
ftypname)
20388 appendPQExpBuffer(query,
"SELECT pg_catalog.format_type('%u'::pg_catalog.oid, NULL)",
20429 for (
i = 0;
i < numatts;
i++)
20431 if (attisdropped[
i])
20433 if (attgenerated[
i])
20445 return buffer->
data;
20455 return (reloptions != NULL && strlen(reloptions) > 2);
20465 const char *prefix,
Archive *fout)
Acl * acldefault(ObjectType objtype, Oid ownerId)
#define InvalidAttrNumber
int lo_read(int fd, char *buf, int len)
void recordAdditionalCatalogID(CatalogId catId, DumpableObject *dobj)
void recordExtensionMembership(CatalogId catId, ExtensionInfo *ext)
FuncInfo * findFuncByOid(Oid oid)
TableInfo * findTableByOid(Oid oid)
ExtensionInfo * findExtensionByOid(Oid oid)
CollInfo * findCollationByOid(Oid oid)
SubscriptionInfo * findSubscriptionByOid(Oid oid)
OprInfo * findOprByOid(Oid oid)
NamespaceInfo * findNamespaceByOid(Oid oid)
void addObjectDependency(DumpableObject *dobj, DumpId refId)
DumpableObject * findObjectByDumpId(DumpId dumpId)
void parseOidArray(const char *str, Oid *array, int arraysize)
ExtensionInfo * findOwningExtension(CatalogId catalogId)
TableInfo * getSchemaData(Archive *fout, int *numTablesPtr)
TypeInfo * findTypeByOid(Oid oid)
DumpId createDumpId(void)
DumpableObject * findObjectByCatalogId(CatalogId catalogId)
void AssignDumpId(DumpableObject *dobj)
void getDumpableObjects(DumpableObject ***objs, int *numObjs)
PublicationInfo * findPublicationByOid(Oid oid)
void on_exit_close_archive(Archive *AHX)
void init_parallel_dump_utils(void)
static void cleanup(void)
static const gbtree_vinfo tinfo
#define ngettext(s, p, n)
#define PG_TEXTDOMAIN(domain)
#define OidIsValid(objectId)
void set_pglocale_pgservice(const char *argv0, const char *app)
char * supports_compression(const pg_compress_specification compression_spec)
char * validate_compress_specification(pg_compress_specification *spec)
bool parse_compress_algorithm(char *name, pg_compress_algorithm *algorithm)
void parse_compress_specification(pg_compress_algorithm algorithm, char *specification, pg_compress_specification *result)
#define PG_COMPRESSION_OPTION_WORKERS
void parse_compress_options(const char *option, char **algorithm, char **detail)
#define ALWAYS_SECURE_SEARCH_PATH_SQL
PGconn * GetConnection(UserMapping *user, bool will_prep_stmt, PgFdwConnState **state)
char * generate_restrict_key(void)
bool buildACLCommands(const char *name, const char *subname, const char *nspname, const char *type, const char *acls, const char *baseacls, const char *owner, const char *prefix, int remoteVersion, PQExpBuffer sql)
bool valid_restrict_key(const char *restrict_key)
void buildShSecLabelQuery(const char *catalog_name, Oid objectId, PQExpBuffer sql)
void makeAlterConfigCommand(PGconn *conn, const char *configitem, const char *type, const char *name, const char *type2, const char *name2, PQExpBuffer buf)
bool buildDefaultACLCommands(const char *type, const char *nspname, const char *acls, const char *acldefault, const char *owner, int remoteVersion, PQExpBuffer sql)
char * sanitize_line(const char *str, bool want_hyphen)
bool variable_is_guc_list_quote(const char *name)
void quoteAclUserName(PQExpBuffer output, const char *input)
void emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer, const char *objtype, const char *objname)
char * PQdb(const PGconn *conn)
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
int PQclientEncoding(const PGconn *conn)
char * PQerrorMessage(const PGconn *conn)
int PQsetClientEncoding(PGconn *conn, const char *encoding)
void PQfreemem(void *ptr)
Oid PQftype(const PGresult *res, int field_num)
int PQfnumber(const PGresult *res, const char *field_name)
int PQgetCopyData(PGconn *conn, char **buffer, int async)
int lo_close(PGconn *conn, int fd)
int lo_open(PGconn *conn, Oid lobjId, int mode)
void * pg_malloc(size_t size)
char * pg_strdup(const char *in)
void * pg_malloc0(size_t size)
void * pg_realloc(void *ptr, size_t size)
@ DATA_DIR_SYNC_METHOD_FSYNC
void filter_init(FilterStateData *fstate, const char *filename, exit_function f_exit)
void filter_free(FilterStateData *fstate)
const char * filter_object_type_name(FilterObjectType fot)
bool filter_read_item(FilterStateData *fstate, char **objname, FilterCommandType *comtype, FilterObjectType *objtype)
void pg_log_filter_error(FilterStateData *fstate, const char *fmt,...)
@ FILTER_OBJECT_TYPE_TABLE_DATA_AND_CHILDREN
@ FILTER_OBJECT_TYPE_SCHEMA
@ FILTER_OBJECT_TYPE_INDEX
@ FILTER_OBJECT_TYPE_TRIGGER
@ FILTER_OBJECT_TYPE_FOREIGN_DATA
@ FILTER_OBJECT_TYPE_DATABASE
@ FILTER_OBJECT_TYPE_FUNCTION
@ FILTER_OBJECT_TYPE_TABLE_DATA
@ FILTER_OBJECT_TYPE_NONE
@ FILTER_OBJECT_TYPE_TABLE_AND_CHILDREN
@ FILTER_OBJECT_TYPE_EXTENSION
@ FILTER_OBJECT_TYPE_TABLE
@ FILTER_COMMAND_TYPE_NONE
@ FILTER_COMMAND_TYPE_EXCLUDE
@ FILTER_COMMAND_TYPE_INCLUDE
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
Assert(PointerIsAligned(start, uint64))
static DataDirSyncMethod sync_method
static int pg_cmp_u32(uint32 a, uint32 b)
if(TABLE==NULL||TABLE_index==NULL)
void pg_logging_increase_verbosity(void)
void pg_logging_init(const char *argv0)
void pg_logging_set_level(enum pg_log_level new_level)
#define pg_log_error(...)
#define pg_log_error_hint(...)
#define pg_log_error_detail(...)
char * pstrdup(const char *in)
bool option_parse_int(const char *optarg, const char *optname, int min_range, int max_range, int *result)
bool parse_sync_method(const char *optarg, DataDirSyncMethod *sync_method)
static AmcheckOptions opts
int EndLO(Archive *AHX, Oid oid)
void ProcessArchiveRestoreOptions(Archive *AHX)
RestoreOptions * NewRestoreOptions(void)
#define appendStringLiteralAH(buf, str, AH)
int StartLO(Archive *AHX, Oid oid)
enum _archiveFormat ArchiveFormat
void ConnectDatabaseAhx(Archive *AHX, const ConnParams *cparams, bool isReconnect)
void CloseArchive(Archive *AHX)
Archive * CreateArchive(const char *FileSpec, const ArchiveFormat fmt, const pg_compress_specification compression_spec, bool dosync, ArchiveMode mode, SetupWorkerPtrType setupDumpWorker, DataDirSyncMethod sync_method)
@ PREPQUERY_DUMPTABLEATTACH
@ PREPQUERY_DUMPRANGETYPE
@ PREPQUERY_GETATTRIBUTESTATS
@ PREPQUERY_DUMPCOMPOSITETYPE
@ PREPQUERY_GETCOLUMNACLS
@ PREPQUERY_GETDOMAINCONSTRAINTS
int archprintf(Archive *AH, const char *fmt,...) pg_attribute_printf(2
void SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)
void RestoreArchive(Archive *AHX)
void archputs(const char *s, Archive *AH)
void InitDumpOptions(DumpOptions *opts)
void WriteData(Archive *AHX, const void *data, size_t dLen)
int TocIDRequired(ArchiveHandle *AH, DumpId id)
TocEntry * ArchiveEntry(Archive *AHX, CatalogId catalogId, DumpId dumpId, ArchiveOpts *opts)
#define ARCHIVE_OPTS(...)
int(* DataDumperPtr)(Archive *AH, const void *userArg)
void ExecuteSqlStatement(Archive *AHX, const char *query)
PGresult * ExecuteSqlQuery(Archive *AHX, const char *query, ExecStatusType status)
PGresult * ExecuteSqlQueryForSingleRow(Archive *fout, const char *query)
void exit_nicely(int code)
void set_dump_section(const char *arg, int *dumpSections)
static PgChecksumMode mode
static void expand_schema_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names)
static const CatalogId nilCatalogId
static void dumpEncoding(Archive *AH)
void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
static DumpId dumpACL(Archive *fout, DumpId objDumpId, DumpId altDumpId, const char *type, const char *name, const char *subname, const char *nspname, const char *tag, const char *owner, const DumpableAcl *dacl)
static SimpleStringList schema_include_patterns
static void dumpAttrDef(Archive *fout, const AttrDefInfo *adinfo)
ExtensionInfo * getExtensions(Archive *fout, int *numExtensions)
static void selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
static void collectBinaryUpgradeClassOids(Archive *fout)
static PQExpBuffer createDummyViewAsClause(Archive *fout, const TableInfo *tbinfo)
static void dumpUserMappings(Archive *fout, const char *servername, const char *namespace, const char *owner, CatalogId catalogId, DumpId dumpId)
static void dumpPublicationNamespace(Archive *fout, const PublicationSchemaInfo *pubsinfo)
static void addBoundaryDependencies(DumpableObject **dobjs, int numObjs, DumpableObject *boundaryObjs)
void getPublicationNamespaces(Archive *fout)
static void dumpSearchPath(Archive *AH)
static void selectDumpableTable(TableInfo *tbinfo, Archive *fout)
static DumpableObject * createBoundaryObjects(void)
static char * convertTSFunction(Archive *fout, Oid funcOid)
static void dumpDatabase(Archive *fout)
static SimpleStringList table_include_patterns
static void append_depends_on_extension(Archive *fout, PQExpBuffer create, const DumpableObject *dobj, const char *catalog, const char *keyword, const char *objname)
static Oid get_next_possible_free_pg_type_oid(Archive *fout, PQExpBuffer upgrade_query)
static void dumpNamespace(Archive *fout, const NamespaceInfo *nspinfo)
static bool forcePartitionRootLoad(const TableInfo *tbinfo)
static void dumpCast(Archive *fout, const CastInfo *cast)
static SimpleOidList schema_exclude_oids
static bool have_extra_float_digits
static void dumpIndex(Archive *fout, const IndxInfo *indxinfo)
void getPartitioningInfo(Archive *fout)
static int nbinaryUpgradeClassOids
static void dumpBaseType(Archive *fout, const TypeInfo *tyinfo)
static char * dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
static SimpleOidList extension_include_oids
static void dumpTSDictionary(Archive *fout, const TSDictInfo *dictinfo)
static void dumpAgg(Archive *fout, const AggInfo *agginfo)
static int extra_float_digits
static int SequenceItemCmp(const void *p1, const void *p2)
static void dumpRelationStats(Archive *fout, const RelStatsInfo *rsinfo)
static void dumpTableComment(Archive *fout, const TableInfo *tbinfo, const char *reltypename)
static SimpleStringList extension_include_patterns
static void selectDumpableNamespace(NamespaceInfo *nsinfo, Archive *fout)
InhInfo * getInherits(Archive *fout, int *numInherits)
void getForeignDataWrappers(Archive *fout)
static void dumpTrigger(Archive *fout, const TriggerInfo *tginfo)
static void binary_upgrade_set_type_oids_by_rel(Archive *fout, PQExpBuffer upgrade_buffer, const TableInfo *tbinfo)
static void dumpTable(Archive *fout, const TableInfo *tbinfo)
static SimpleOidList extension_exclude_oids
static SimpleStringList table_exclude_patterns
static PQExpBuffer createViewAsClause(Archive *fout, const TableInfo *tbinfo)
static void dumpStatisticsExt(Archive *fout, const StatsExtInfo *statsextinfo)
void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
static void dumpRangeType(Archive *fout, const TypeInfo *tyinfo)
void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
static void dumpComment(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId)
static char * getFormattedOperatorName(const char *oproid)
static char * format_function_signature(Archive *fout, const FuncInfo *finfo, bool honor_quotes)
static pg_compress_algorithm compression_algorithm
static void dumpStdStrings(Archive *AH)
static void dumpConstraint(Archive *fout, const ConstraintInfo *coninfo)
static void dumpType(Archive *fout, const TypeInfo *tyinfo)
static void dumpTableAttach(Archive *fout, const TableAttachInfo *attachinfo)
static void help(const char *progname)
void getTypes(Archive *fout)
static void dumpAccessMethod(Archive *fout, const AccessMethodInfo *aminfo)
int main(int argc, char **argv)
static void dumpOpr(Archive *fout, const OprInfo *oprinfo)
static void selectDumpableStatisticsObject(StatsExtInfo *sobj, Archive *fout)
static void selectDumpablePublicationObject(DumpableObject *dobj, Archive *fout)
static void dumpSequenceData(Archive *fout, const TableDataInfo *tdinfo)
static void dumpFunc(Archive *fout, const FuncInfo *finfo)
static void selectDumpableDefaultACL(DefaultACLInfo *dinfo, DumpOptions *dopt)
static void BuildArchiveDependencies(Archive *fout)
static RelStatsInfo * getRelationStatistics(Archive *fout, DumpableObject *rel, int32 relpages, char *reltuples, int32 relallvisible, int32 relallfrozen, char relkind, char **indAttNames, int nindAttNames)
static const char *const SeqTypeNames[]
void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo)
static const char * getAttrName(int attrnum, const TableInfo *tblInfo)
static void dumpForeignServer(Archive *fout, const ForeignServerInfo *srvinfo)
static RoleNameItem * rolenames
static void collectRoleNames(Archive *fout)
static PGresult * fetchAttributeStats(Archive *fout)
static void appendReloptionsArrayAH(PQExpBuffer buffer, const char *reloptions, const char *prefix, Archive *fout)
void getOpclasses(Archive *fout)
void getForeignServers(Archive *fout)
void getFuncs(Archive *fout)
static void dumpTableData(Archive *fout, const TableDataInfo *tdinfo)
static void prohibit_crossdb_refs(PGconn *conn, const char *dbname, const char *pattern)
static int dumpTableData_copy(Archive *fout, const void *dcontext)
#define MAX_BLOBS_PER_ARCHIVE_ENTRY
static const char * getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts)
static void getDependencies(Archive *fout)
static void buildMatViewRefreshDependencies(Archive *fout)
void getTSDictionaries(Archive *fout)
static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, PQExpBuffer upgrade_buffer, Oid pg_type_oid, bool force_array_type, bool include_multirange_type)
#define DUMP_DEFAULT_ROWS_PER_INSERT
void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
static SeqType parse_sequence_type(const char *name)
static const char * getRoleName(const char *roleoid_str)
static void dumpShellType(Archive *fout, const ShellTypeInfo *stinfo)
static SequenceItem * sequences
static void refreshMatViewData(Archive *fout, const TableDataInfo *tdinfo)
static int findComments(Oid classoid, Oid objoid, CommentItem **items)
static SimpleStringList foreign_servers_include_patterns
static void selectDumpableCast(CastInfo *cast, Archive *fout)
void getCasts(Archive *fout)
static void dumpPublication(Archive *fout, const PublicationInfo *pubinfo)
static void dumpPolicy(Archive *fout, const PolicyInfo *polinfo)
void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
static void setupDumpWorker(Archive *AH)
static void addConstrChildIdxDeps(DumpableObject *dobj, const IndxInfo *refidx)
void getTSConfigurations(Archive *fout)
static int findSecLabels(Oid classoid, Oid objoid, SecLabelItem **items)
static SimpleStringList table_include_patterns_and_children
static char * convertRegProcReference(const char *proc)
static void getAdditionalACLs(Archive *fout)
StaticAssertDecl(lengthof(SeqTypeNames)==(SEQTYPE_BIGINT+1), "array length mismatch")
static bool is_superuser(Archive *fout)
static void getTableDataFKConstraints(void)
static void getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, char relkind)
static SimpleOidList table_exclude_oids
void getAccessMethods(Archive *fout)
void getConversions(Archive *fout)
void getRules(Archive *fout)
static void dumpDomain(Archive *fout, const TypeInfo *tyinfo)
void getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
static void collectComments(Archive *fout)
static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo)
static void dumpOpfamily(Archive *fout, const OpfamilyInfo *opfinfo)
static void dumpDefaultACL(Archive *fout, const DefaultACLInfo *daclinfo)
static void selectDumpableObject(DumpableObject *dobj, Archive *fout)
static void dumpTSTemplate(Archive *fout, const TSTemplateInfo *tmplinfo)
static void dumpIndexAttach(Archive *fout, const IndexAttachInfo *attachinfo)
static void dumpSubscriptionTable(Archive *fout, const SubRelInfo *subrinfo)
void getCollations(Archive *fout)
static char * format_function_arguments(const FuncInfo *finfo, const char *funcargs, bool is_agg)
static void dumpTransform(Archive *fout, const TransformInfo *transform)
void getAggregates(Archive *fout)
static void dumpLO(Archive *fout, const LoInfo *loinfo)
void getNamespaces(Archive *fout)
static void dumpPublicationTable(Archive *fout, const PublicationRelInfo *pubrinfo)
void getPublications(Archive *fout)
static void binary_upgrade_extension_member(PQExpBuffer upgrade_buffer, const DumpableObject *dobj, const char *objtype, const char *objname, const char *objnamespace)
static void dumpDumpableObject(Archive *fout, DumpableObject *dobj)
static void getLOs(Archive *fout)
static void dumpDatabaseConfig(Archive *AH, PQExpBuffer outbuf, const char *dbname, Oid dboid)
void getTSParsers(Archive *fout)
static DumpId lo_metadata_dumpId
static void setup_connection(Archive *AH, const char *dumpencoding, const char *dumpsnapshot, char *use_role)
static void dumpTableConstraintComment(Archive *fout, const ConstraintInfo *coninfo)
static void dumpUndefinedType(Archive *fout, const TypeInfo *tyinfo)
static void selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
static const char * fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer)
static void expand_table_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names, bool with_child_tables)
static void findDumpableDependencies(ArchiveHandle *AH, const DumpableObject *dobj, DumpId **dependencies, int *nDeps, int *allocDeps)
static void determineNotNullFlags(Archive *fout, PGresult *res, int r, TableInfo *tbinfo, int j, int i_notnull_name, int i_notnull_comment, int i_notnull_invalidoid, int i_notnull_noinherit, int i_notnull_islocal, PQExpBuffer *invalidnotnulloids)
static void dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
static void dumpTSParser(Archive *fout, const TSParserInfo *prsinfo)
static void expand_foreign_server_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids)
TableInfo * getTables(Archive *fout, int *numTables)
static void dumpRule(Archive *fout, const RuleInfo *rinfo)
static void dumpCompositeType(Archive *fout, const TypeInfo *tyinfo)
static void dumpEnumType(Archive *fout, const TypeInfo *tyinfo)
static void dumpExtension(Archive *fout, const ExtensionInfo *extinfo)
#define fmtQualifiedDumpable(obj)
static bool nonemptyReloptions(const char *reloptions)
static SimpleStringList extension_exclude_patterns
static BinaryUpgradeClassOidItem * binaryUpgradeClassOids
static SimpleOidList table_include_oids
void getExtendedStatistics(Archive *fout)
static NamespaceInfo * findNamespace(Oid nsoid)
static char * get_synchronized_snapshot(Archive *fout)
static int dumpLOs(Archive *fout, const void *arg)
static void dumpSubscription(Archive *fout, const SubscriptionInfo *subinfo)
static void appendNamedArgument(PQExpBuffer out, Archive *fout, const char *argname, const char *argtype, const char *argval)
void processExtensionTables(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
static void dumpEventTrigger(Archive *fout, const EventTriggerInfo *evtinfo)
static int BinaryUpgradeClassOidItemCmp(const void *p1, const void *p2)
static void dumpCommentExtended(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId, const char *initdb_comment)
void getDefaultACLs(Archive *fout)
static SimpleStringList tabledata_exclude_patterns
static void dumpConversion(Archive *fout, const ConvInfo *convinfo)
static void dumpForeignDataWrapper(Archive *fout, const FdwInfo *fdwinfo)
static void dumpProcLang(Archive *fout, const ProcLangInfo *plang)
static void dumpSecLabel(Archive *fout, const char *type, const char *name, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId)
void getSubscriptions(Archive *fout)
static void collectSecLabels(Archive *fout)
static void selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
static void collectSequences(Archive *fout)
static Oid g_last_builtin_oid
#define MAX_ATTR_STATS_RELS
void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
void getTransforms(Archive *fout)
void getEventTriggers(Archive *fout)
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode)
static void read_dump_filters(const char *filename, DumpOptions *dopt)
static void dumpTSConfig(Archive *fout, const TSConfigInfo *cfginfo)
static SecLabelItem * seclabels
static SimpleStringList tabledata_exclude_patterns_and_children
static char * get_language_name(Archive *fout, Oid langid)
static bool checkExtensionMembership(DumpableObject *dobj, Archive *fout)
static CommentItem * comments
static int dumpTableData_insert(Archive *fout, const void *dcontext)
static SimpleOidList tabledata_exclude_oids
static SimpleStringList table_exclude_patterns_and_children
static void binary_upgrade_set_pg_class_oids(Archive *fout, PQExpBuffer upgrade_buffer, Oid pg_class_oid)
void getTSTemplates(Archive *fout)
static void set_restrict_relation_kind(Archive *AH, const char *value)
static char * format_aggregate_signature(const AggInfo *agginfo, Archive *fout, bool honor_quotes)
void getProcLangs(Archive *fout)
static void dumpSequence(Archive *fout, const TableInfo *tbinfo)
bool shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
static TableInfo * getRootTableInfo(const TableInfo *tbinfo)
void getSubscriptionRelations(Archive *fout)
void getOperators(Archive *fout)
static SimpleOidList foreign_servers_include_oids
static void dumpCollation(Archive *fout, const CollInfo *collinfo)
static void dumpTableSecLabel(Archive *fout, const TableInfo *tbinfo, const char *reltypename)
static void dumpCompositeTypeColComments(Archive *fout, const TypeInfo *tyinfo, PGresult *res)
static void expand_extension_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids, bool strict_names)
void getOpfamilies(Archive *fout)
static void selectDumpableType(TypeInfo *tyinfo, Archive *fout)
static SimpleOidList schema_include_oids
static void dumpOpclass(Archive *fout, const OpclassInfo *opcinfo)
static SimpleStringList schema_exclude_patterns
#define DUMP_COMPONENT_COMMENT
#define DUMP_COMPONENT_DATA
#define DUMP_COMPONENT_USERMAP
#define DUMP_COMPONENT_POLICY
#define DUMP_COMPONENT_SECLABEL
#define DUMP_COMPONENT_ALL
#define DUMP_COMPONENT_ACL
#define DUMP_COMPONENT_NONE
#define DUMP_COMPONENTS_REQUIRING_LOCK
void sortDumpableObjects(DumpableObject **objs, int numObjs, DumpId preBoundaryId, DumpId postBoundaryId)
#define DUMP_COMPONENT_DEFINITION
@ DO_PUBLICATION_TABLE_IN_SCHEMA
void sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs)
#define DUMP_COMPONENT_STATISTICS
static int statistics_only
static int with_statistics
PGDLLIMPORT char * optarg
static char buf[DEFAULT_XLOG_SEG_SIZE]
#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)