44#include "catalog/pg_aggregate_d.h"
45#include "catalog/pg_am_d.h"
46#include "catalog/pg_attribute_d.h"
47#include "catalog/pg_authid_d.h"
48#include "catalog/pg_cast_d.h"
49#include "catalog/pg_class_d.h"
50#include "catalog/pg_default_acl_d.h"
51#include "catalog/pg_largeobject_d.h"
52#include "catalog/pg_proc_d.h"
53#include "catalog/pg_publication_d.h"
54#include "catalog/pg_subscription_d.h"
55#include "catalog/pg_type_d.h"
122 "array length mismatch");
215#define DUMP_DEFAULT_ROWS_PER_INSERT 1
222#define MAX_BLOBS_PER_ARCHIVE_ENTRY 1000
227#define fmtQualifiedDumpable(obj) \
228 fmtQualifiedId((obj)->dobj.namespace->dobj.name, \
233 const char *dumpencoding,
const char *dumpsnapshot,
251 bool with_child_tables);
253 const char *pattern);
258static const char *
getRoleName(
const char *roleoid_str);
262 const char *
name,
const char *
namespace,
265 const char *initdb_comment);
267 const char *
name,
const char *
namespace,
269 int subid,
DumpId dumpId);
273 const char *
namespace,
const char *owner,
323 const char *servername,
const char *
namespace,
329 const char *nspname,
const char *tag,
const char *owner,
335 DumpId **dependencies,
int *nDeps,
int *allocDeps);
349 int i_notnull_name,
int i_notnull_noinherit,
350 int i_notnull_islocal);
354 const FuncInfo *finfo,
bool honor_quotes);
376 bool force_array_type,
377 bool include_multirange_type);
389 const char *objnamespace);
394 const char *prefix,
Archive *fout);
418 bool g_verbose =
false;
419 const char *dumpencoding = NULL;
420 const char *dumpsnapshot = NULL;
421 char *use_role = NULL;
427 char *compression_detail = NULL;
428 char *compression_algorithm_str =
"none";
429 char *error_detail = NULL;
430 bool user_compression_defined =
false;
432 bool data_only =
false;
433 bool schema_only =
false;
437 static struct option long_options[] = {
450 {
"jobs", 1, NULL,
'j'},
529 if (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-?") == 0)
534 if (strcmp(argv[1],
"--version") == 0 || strcmp(argv[1],
"-V") == 0)
536 puts(
"pg_dump (PostgreSQL) " PG_VERSION);
543 while ((
c =
getopt_long(argc, argv,
"abBcCd:e:E:f:F:h:j:n:N:Op:RsS:t:T:U:vwWxZ:",
544 long_options, &optindex)) != -1)
661 &compression_detail);
662 user_compression_defined =
true;
768 pg_log_error(
"too many command-line arguments (first is \"%s\")",
786 if (data_only && schema_only)
787 pg_fatal(
"options -s/--schema-only and -a/--data-only cannot be used together");
790 pg_fatal(
"options -s/--schema-only and --include-foreign-data cannot be used together");
793 pg_fatal(
"option --include-foreign-data is not supported with parallel backup");
796 pg_fatal(
"options -c/--clean and -a/--data-only cannot be used together");
799 pg_fatal(
"option --if-exists requires option -c/--clean");
810 pg_fatal(
"option --on-conflict-do-nothing requires option --inserts, --rows-per-insert, or --column-inserts");
825 !user_compression_defined)
828 compression_algorithm_str =
"gzip";
830 compression_algorithm_str =
"none";
839 pg_fatal(
"unrecognized compression algorithm: \"%s\"",
840 compression_algorithm_str);
845 if (error_detail != NULL)
846 pg_fatal(
"invalid compression specification: %s",
850 if (error_detail != NULL)
859 pg_log_warning(
"compression option \"%s\" is not currently supported by pg_dump",
871 pg_fatal(
"parallel backup only supported by the directory format");
926 pg_fatal(
"no matching schemas were found");
943 pg_fatal(
"no matching tables were found");
971 pg_fatal(
"no matching extensions were found");
1010 getTableData(&dopt, tblinfo, numTables, RELKIND_SEQUENCE);
1066 boundaryObjs[0].dumpId, boundaryObjs[1].dumpId);
1085 for (
i = 0;
i < numObjs;
i++)
1162 printf(
_(
"%s dumps a database as a text file or to other formats.\n\n"),
progname);
1166 printf(
_(
"\nGeneral options:\n"));
1167 printf(
_(
" -f, --file=FILENAME output file or directory name\n"));
1168 printf(
_(
" -F, --format=c|d|t|p output file format (custom, directory, tar,\n"
1169 " plain text (default))\n"));
1170 printf(
_(
" -j, --jobs=NUM use this many parallel jobs to dump\n"));
1171 printf(
_(
" -v, --verbose verbose mode\n"));
1172 printf(
_(
" -V, --version output version information, then exit\n"));
1173 printf(
_(
" -Z, --compress=METHOD[:DETAIL]\n"
1174 " compress as specified\n"));
1175 printf(
_(
" --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock\n"));
1176 printf(
_(
" --no-sync do not wait for changes to be written safely to disk\n"));
1177 printf(
_(
" --sync-method=METHOD set method for syncing files to disk\n"));
1178 printf(
_(
" -?, --help show this help, then exit\n"));
1180 printf(
_(
"\nOptions controlling the output content:\n"));
1181 printf(
_(
" -a, --data-only dump only the data, not the schema\n"));
1182 printf(
_(
" -b, --large-objects include large objects in dump\n"));
1183 printf(
_(
" --blobs (same as --large-objects, deprecated)\n"));
1184 printf(
_(
" -B, --no-large-objects exclude large objects in dump\n"));
1185 printf(
_(
" --no-blobs (same as --no-large-objects, deprecated)\n"));
1186 printf(
_(
" -c, --clean clean (drop) database objects before recreating\n"));
1187 printf(
_(
" -C, --create include commands to create database in dump\n"));
1188 printf(
_(
" -e, --extension=PATTERN dump the specified extension(s) only\n"));
1189 printf(
_(
" -E, --encoding=ENCODING dump the data in encoding ENCODING\n"));
1190 printf(
_(
" -n, --schema=PATTERN dump the specified schema(s) only\n"));
1191 printf(
_(
" -N, --exclude-schema=PATTERN do NOT dump the specified schema(s)\n"));
1192 printf(
_(
" -O, --no-owner skip restoration of object ownership in\n"
1193 " plain-text format\n"));
1194 printf(
_(
" -s, --schema-only dump only the schema, no data\n"));
1195 printf(
_(
" -S, --superuser=NAME superuser user name to use in plain-text format\n"));
1196 printf(
_(
" -t, --table=PATTERN dump only the specified table(s)\n"));
1197 printf(
_(
" -T, --exclude-table=PATTERN do NOT dump the specified table(s)\n"));
1198 printf(
_(
" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
1199 printf(
_(
" --binary-upgrade for use by upgrade utilities only\n"));
1200 printf(
_(
" --column-inserts dump data as INSERT commands with column names\n"));
1201 printf(
_(
" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
1202 printf(
_(
" --disable-triggers disable triggers during data-only restore\n"));
1203 printf(
_(
" --enable-row-security enable row security (dump only content user has\n"
1205 printf(
_(
" --exclude-extension=PATTERN do NOT dump the specified extension(s)\n"));
1206 printf(
_(
" --exclude-table-and-children=PATTERN\n"
1207 " do NOT dump the specified table(s), including\n"
1208 " child and partition tables\n"));
1209 printf(
_(
" --exclude-table-data=PATTERN do NOT dump data for the specified table(s)\n"));
1210 printf(
_(
" --exclude-table-data-and-children=PATTERN\n"
1211 " do NOT dump data for the specified table(s),\n"
1212 " including child and partition tables\n"));
1213 printf(
_(
" --extra-float-digits=NUM override default setting for extra_float_digits\n"));
1214 printf(
_(
" --filter=FILENAME include or exclude objects and data from dump\n"
1215 " based on expressions in FILENAME\n"));
1216 printf(
_(
" --if-exists use IF EXISTS when dropping objects\n"));
1217 printf(
_(
" --include-foreign-data=PATTERN\n"
1218 " include data of foreign tables on foreign\n"
1219 " servers matching PATTERN\n"));
1220 printf(
_(
" --inserts dump data as INSERT commands, rather than COPY\n"));
1221 printf(
_(
" --load-via-partition-root load partitions via the root table\n"));
1222 printf(
_(
" --no-comments do not dump comment commands\n"));
1223 printf(
_(
" --no-publications do not dump publications\n"));
1224 printf(
_(
" --no-security-labels do not dump security label assignments\n"));
1225 printf(
_(
" --no-subscriptions do not dump subscriptions\n"));
1226 printf(
_(
" --no-table-access-method do not dump table access methods\n"));
1227 printf(
_(
" --no-tablespaces do not dump tablespace assignments\n"));
1228 printf(
_(
" --no-toast-compression do not dump TOAST compression methods\n"));
1229 printf(
_(
" --no-unlogged-table-data do not dump unlogged table data\n"));
1230 printf(
_(
" --on-conflict-do-nothing add ON CONFLICT DO NOTHING to INSERT commands\n"));
1231 printf(
_(
" --quote-all-identifiers quote all identifiers, even if not key words\n"));
1232 printf(
_(
" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
1233 printf(
_(
" --section=SECTION dump named section (pre-data, data, or post-data)\n"));
1234 printf(
_(
" --serializable-deferrable wait until the dump can run without anomalies\n"));
1235 printf(
_(
" --snapshot=SNAPSHOT use given snapshot for the dump\n"));
1236 printf(
_(
" --strict-names require table and/or schema include patterns to\n"
1237 " match at least one entity each\n"));
1238 printf(
_(
" --table-and-children=PATTERN dump only the specified table(s), including\n"
1239 " child and partition tables\n"));
1240 printf(
_(
" --use-set-session-authorization\n"
1241 " use SET SESSION AUTHORIZATION commands instead of\n"
1242 " ALTER OWNER commands to set ownership\n"));
1244 printf(
_(
"\nConnection options:\n"));
1245 printf(
_(
" -d, --dbname=DBNAME database to dump\n"));
1246 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
1247 printf(
_(
" -p, --port=PORT database server port number\n"));
1248 printf(
_(
" -U, --username=NAME connect as specified database user\n"));
1249 printf(
_(
" -w, --no-password never prompt for password\n"));
1250 printf(
_(
" -W, --password force password prompt (should happen automatically)\n"));
1251 printf(
_(
" --role=ROLENAME do SET ROLE before dump\n"));
1253 printf(
_(
"\nIf no database name is supplied, then the PGDATABASE environment\n"
1254 "variable value is used.\n\n"));
1255 printf(
_(
"Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
1256 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
1261 const char *dumpsnapshot,
char *use_role)
1265 const char *std_strings;
1275 pg_fatal(
"invalid client encoding \"%s\" specified",
1287 AH->
std_strings = (std_strings && strcmp(std_strings,
"on") == 0);
1396 "SET TRANSACTION ISOLATION LEVEL "
1397 "SERIALIZABLE, READ ONLY, DEFERRABLE");
1400 "SET TRANSACTION ISOLATION LEVEL "
1401 "REPEATABLE READ, READ ONLY");
1423 pg_fatal(
"parallel dumps from standby servers are not supported by this server version");
1447 char *query =
"SELECT pg_catalog.pg_export_snapshot()";
1489 return archiveFormat;
1507 if (patterns->
head == NULL)
1517 for (cell = patterns->
head; cell; cell = cell->
next)
1523 "SELECT oid FROM pg_catalog.pg_namespace n\n");
1526 false, NULL,
"n.nspname", NULL, NULL, &dbbuf,
1529 pg_fatal(
"improper qualified name (too many dotted names): %s",
1531 else if (dotcnt == 1)
1537 pg_fatal(
"no matching schemas were found for pattern \"%s\"", cell->
val);
1566 if (patterns->
head == NULL)
1575 for (cell = patterns->
head; cell; cell = cell->
next)
1580 "SELECT oid FROM pg_catalog.pg_extension e\n");
1582 false, NULL,
"e.extname", NULL, NULL, NULL,
1585 pg_fatal(
"improper qualified name (too many dotted names): %s",
1590 pg_fatal(
"no matching extensions were found for pattern \"%s\"", cell->
val);
1618 if (patterns->
head == NULL)
1628 for (cell = patterns->
head; cell; cell = cell->
next)
1633 "SELECT oid FROM pg_catalog.pg_foreign_server s\n");
1635 false, NULL,
"s.srvname", NULL, NULL, NULL,
1638 pg_fatal(
"improper qualified name (too many dotted names): %s",
1643 pg_fatal(
"no matching foreign servers were found for pattern \"%s\"", cell->
val);
1670 if (patterns->
head == NULL)
1680 for (cell = patterns->
head; cell; cell = cell->
next)
1693 if (with_child_tables)
1700 "\nFROM pg_catalog.pg_class c"
1701 "\n LEFT JOIN pg_catalog.pg_namespace n"
1702 "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace"
1703 "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY"
1704 "\n (array['%c', '%c', '%c', '%c', '%c', '%c'])\n",
1705 RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW,
1706 RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE,
1707 RELKIND_PARTITIONED_TABLE);
1710 false,
"n.nspname",
"c.relname", NULL,
1711 "pg_catalog.pg_table_is_visible(c.oid)", &dbbuf,
1714 pg_fatal(
"improper relation name (too many dotted names): %s",
1716 else if (dotcnt == 2)
1720 if (with_child_tables)
1723 "\nSELECT i.inhrelid"
1724 "\nFROM partition_tree p"
1725 "\n JOIN pg_catalog.pg_inherits i"
1726 "\n ON p.relid OPERATOR(pg_catalog.=) i.inhparent"
1728 "\nSELECT relid FROM partition_tree");
1736 pg_fatal(
"no matching tables were found for pattern \"%s\"", cell->
val);
1763 pg_fatal(
"You are currently not connected to a database.");
1765 if (strcmp(db,
dbname) != 0)
1766 pg_fatal(
"cross-database references are not implemented: %s",
1854 strcmp(nsinfo->
dobj.
name,
"pg_catalog") == 0)
1863 else if (strncmp(nsinfo->
dobj.
name,
"pg_", 3) == 0 ||
1864 strcmp(nsinfo->
dobj.
name,
"information_schema") == 0)
1869 else if (strcmp(nsinfo->
dobj.
name,
"public") == 0)
1881 if (nsinfo->
nspowner == ROLE_PG_DATABASE_OWNER)
1882 nsinfo->
dobj.
dump &= ~DUMP_COMPONENT_DEFINITION;
1961 tyinfo->
typrelkind != RELKIND_COMPOSITE_TYPE)
1966 if (tytable != NULL)
2006 if (dinfo->
dobj.namespace)
2194 if (dobj->namespace)
2211 const char *classname = tbinfo->
dobj.
name;
2223 const char *column_list;
2225 pg_log_info(
"dumping contents of table \"%s.%s\"",
2226 tbinfo->
dobj.namespace->dobj.
name, classname);
2244 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2249 if (strlen(column_list) > 2)
2335 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetCopyData() failed.", classname);
2345 pg_log_error(
"Dumping the contents of table \"%s\" failed: PQgetResult() failed.", classname);
2354 pg_log_warning(
"unexpected extra results during COPY of table \"%s\"",
2360 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2387 int rows_this_statement = 0;
2390 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2436 pg_fatal(
"wrong number of fields retrieved from table \"%s\"",
2446 if (insertStmt == NULL)
2478 for (
int field = 0; field < nfields; field++)
2498 if (rows_this_statement == 0)
2514 if (rows_per_statement == 1)
2516 else if (rows_this_statement > 0)
2521 for (
int field = 0; field < nfields; field++)
2525 if (attgenerated[field])
2560 if (strspn(s,
"0123456789 +-eE.") == strlen(s))
2595 if (++rows_this_statement >= rows_per_statement)
2598 archputs(
" ON CONFLICT DO NOTHING;\n", fout);
2602 rows_this_statement = 0;
2615 if (rows_this_statement > 0)
2618 archputs(
" ON CONFLICT DO NOTHING;\n", fout);
2628 if (insertStmt != NULL)
2633 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE)
2651 parentTbinfo = tbinfo->
parents[0];
2655 parentTbinfo = parentTbinfo->
parents[0];
2658 return parentTbinfo;
2676 parentTbinfo = tbinfo->
parents[0];
2682 parentTbinfo = parentTbinfo->
parents[0];
2704 char *tdDefn = NULL;
2706 const char *copyFrom;
2741 copyStmt = copyBuf->
data;
2761 .namespace = tbinfo->
dobj.namespace->dobj.
name,
2763 .description =
"TABLE DATA",
2765 .createStmt = tdDefn,
2766 .copyStmt = copyStmt,
2770 .dumpArg = tdinfo));
2828 .namespace = tbinfo->
dobj.namespace->dobj.
name,
2830 .description =
"MATERIALIZED VIEW DATA",
2832 .createStmt = q->
data,
2848 for (
i = 0;
i < numTables;
i++)
2851 (!relkind || tblinfo[
i].
relkind == relkind))
2875 if (tbinfo->
relkind == RELKIND_VIEW)
2878 if (tbinfo->
relkind == RELKIND_FOREIGN_TABLE &&
2884 if (tbinfo->
relkind == RELKIND_PARTITIONED_TABLE)
2900 if (tbinfo->
relkind == RELKIND_MATVIEW)
2902 else if (tbinfo->
relkind == RELKIND_SEQUENCE)
2915 tdinfo->
dobj.namespace = tbinfo->
dobj.namespace;
2955 "SELECT d1.objid, d2.refobjid, c2.relkind AS refrelkind "
2956 "FROM pg_depend d1 "
2957 "JOIN pg_class c1 ON c1.oid = d1.objid "
2959 " JOIN pg_rewrite r1 ON r1.ev_class = d1.objid "
2960 "JOIN pg_depend d2 ON d2.classid = 'pg_rewrite'::regclass "
2961 "AND d2.objid = r1.oid "
2962 "AND d2.refobjid <> d1.objid "
2963 "JOIN pg_class c2 ON c2.oid = d2.refobjid "
2964 "AND c2.relkind IN (" CppAsString2(RELKIND_MATVIEW)
","
2966 "WHERE d1.classid = 'pg_class'::regclass "
2968 "SELECT w.objid, d3.refobjid, c3.relkind "
2970 "JOIN pg_rewrite r3 ON r3.ev_class = w.refobjid "
2971 "JOIN pg_depend d3 ON d3.classid = 'pg_rewrite'::regclass "
2972 "AND d3.objid = r3.oid "
2973 "AND d3.refobjid <> w.refobjid "
2974 "JOIN pg_class c3 ON c3.oid = d3.refobjid "
2975 "AND c3.relkind IN (" CppAsString2(RELKIND_MATVIEW)
","
2978 "SELECT 'pg_class'::regclass::oid AS classid, objid, refobjid "
2990 for (
i = 0;
i < ntups;
i++)
3017 if (refdobj == NULL)
3024 if (refdobj == NULL)
3060 for (
i = 0;
i < numObjs;
i++)
3072 if (ftable == NULL ||
3145 "pg_encoding_to_char(encoding) AS encoding, "
3146 "datcollate, datctype, datfrozenxid, "
3147 "datacl, acldefault('d', datdba) AS acldefault, "
3148 "datistemplate, datconnlimit, ");
3158 appendPQExpBufferStr(dbQry,
"'c' AS datlocprovider, NULL AS datlocale, NULL AS datcollversion, ");
3164 "(SELECT spcname FROM pg_tablespace t WHERE t.oid = dattablespace) AS tablespace, "
3165 "shobj_description(oid, 'pg_database') AS description "
3167 "WHERE datname = current_database()");
3230 "CREATE DATABASE %s WITH TEMPLATE = template0 "
3231 "OID = %u STRATEGY = FILE_COPY",
3232 qdatname, dbCatId.
oid);
3253 pg_fatal(
"unrecognized locale provider: %s",
3256 if (strlen(collate) > 0 && strcmp(collate, ctype) == 0)
3263 if (strlen(collate) > 0)
3268 if (strlen(ctype) > 0)
3331 .createStmt = creaQry->
data,
3332 .dropStmt = delQry->
data));
3361 .description =
"COMMENT",
3363 .createStmt = dbQry->
data,
3381 if (seclabelQry->
len > 0)
3385 .description =
"SECURITY LABEL",
3387 .createStmt = seclabelQry->
data,
3402 qdatname, NULL, NULL,
3403 NULL, dba, &dbdacl);
3433 "SET datistemplate = false WHERE datname = ");
3454 "SET datfrozenxid = '%u', datminmxid = '%u'\n"
3456 frozenxid, minmxid);
3461 if (creaQry->
len > 0)
3467 .createStmt = creaQry->
data,
3468 .dropStmt = delQry->
data,
3469 .deps = &dbDumpId));
3481 int ii_relfrozenxid,
3490 appendPQExpBuffer(loFrozenQry,
"SELECT relfrozenxid, relminmxid, relfilenode, oid\n"
3491 "FROM pg_catalog.pg_class\n"
3492 "WHERE oid IN (%u, %u);\n",
3493 LargeObjectRelationId, LargeObjectLOidPNIndexId);
3495 appendPQExpBuffer(loFrozenQry,
"SELECT relfrozenxid, 0 AS relminmxid, relfilenode, oid\n"
3496 "FROM pg_catalog.pg_class\n"
3497 "WHERE oid IN (%u, %u);\n",
3498 LargeObjectRelationId, LargeObjectLOidPNIndexId);
3502 ii_relfrozenxid =
PQfnumber(lo_res,
"relfrozenxid");
3503 ii_relminmxid =
PQfnumber(lo_res,
"relminmxid");
3504 ii_relfilenode =
PQfnumber(lo_res,
"relfilenode");
3507 appendPQExpBufferStr(loHorizonQry,
"\n-- For binary upgrade, set pg_largeobject relfrozenxid and relminmxid\n");
3508 appendPQExpBufferStr(loOutQry,
"\n-- For binary upgrade, preserve pg_largeobject and index relfilenodes\n");
3515 "SET relfrozenxid = '%u', relminmxid = '%u'\n"
3516 "WHERE oid = %u;\n",
3524 if (oid == LargeObjectRelationId)
3526 "SELECT pg_catalog.binary_upgrade_set_next_heap_relfilenode('%u'::pg_catalog.oid);\n",
3528 else if (oid == LargeObjectLOidPNIndexId)
3530 "SELECT pg_catalog.binary_upgrade_set_next_index_relfilenode('%u'::pg_catalog.oid);\n",
3535 "TRUNCATE pg_catalog.pg_largeobject;\n");
3542 .createStmt = loOutQry->
data));
3574 "WHERE setrole = 0 AND setdatabase = '%u'::oid",
3581 "DATABASE",
dbname, NULL, NULL,
3588 "FROM pg_db_role_setting s, pg_roles r "
3589 "WHERE setrole = r.oid AND setdatabase = '%u'::oid",
3624 .createStmt = qry->
data));
3636 const char *stdstrings = AH->
std_strings ?
"on" :
"off";
3639 pg_log_info(
"saving \"standard_conforming_strings = %s\"",
3649 .createStmt = qry->
data));
3663 char **schemanames = NULL;
3664 int nschemanames = 0;
3675 "SELECT pg_catalog.current_schemas(false)");
3678 pg_fatal(
"could not parse result of current_schemas()");
3686 for (
i = 0;
i < nschemanames;
i++)
3703 .createStmt = qry->
data));
3740 "SELECT oid, lomowner, lomacl, "
3741 "acldefault('L', lomowner) AS acldefault "
3742 "FROM pg_largeobject_metadata "
3743 "ORDER BY lomowner, lomacl::pg_catalog.text, oid");
3762 for (
i = 0;
i < ntups;
i += n)
3775 if (strcmp(thisowner,
PQgetvalue(
res,
i + n, i_lomowner)) != 0 ||
3790 snprintf(namebuf,
sizeof(namebuf),
"%u..%u", thisoid,
3793 snprintf(namebuf,
sizeof(namebuf),
"%u", thisoid);
3801 loinfo->
looids[0] = thisoid;
3803 for (
int k = 1; k < n; k++)
3810 extraID.
tableoid = LargeObjectRelationId;
3830 loinfo->
dobj.
dump &= ~DUMP_COMPONENT_DATA;
3866 for (
int i = 0;
i < loinfo->
numlos;
i++)
3873 .description =
"BLOB METADATA",
3875 .createStmt = cquery->
data,
3876 .dropStmt =
"-- dummy"));
3885 for (
int i = 0;
i < loinfo->
numlos;
i++)
3925 snprintf(tagbuf,
sizeof(tagbuf),
"LARGE OBJECTS %u..%u",
3929 "LARGE OBJECT", namebuf, NULL, NULL,
3935 "LARGE OBJECT", namebuf, NULL, NULL,
3956 for (
int i = 0;
i < loinfo->
numlos;
i++)
3965 pg_fatal(
"could not open large object %u: %s",
3975 pg_fatal(
"error reading large object %u: %s",
4005 int i_polpermissive;
4024 for (
i = 0;
i < numTables;
i++)
4033 if (tbinfo->
relkind != RELKIND_RELATION &&
4034 tbinfo->
relkind != RELKIND_PARTITIONED_TABLE)
4038 if (tbloids->
len > 1)
4059 polinfo->
dobj.namespace = tbinfo->
dobj.namespace;
4078 pg_log_info(
"reading row-level security policies");
4081 "SELECT pol.oid, pol.tableoid, pol.polrelid, pol.polname, pol.polcmd, ");
4087 "CASE WHEN pol.polroles = '{0}' THEN NULL ELSE "
4088 " 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, "
4089 "pg_catalog.pg_get_expr(pol.polqual, pol.polrelid) AS polqual, "
4090 "pg_catalog.pg_get_expr(pol.polwithcheck, pol.polrelid) AS polwithcheck "
4091 "FROM unnest('%s'::pg_catalog.oid[]) AS src(tbloid)\n"
4092 "JOIN pg_catalog.pg_policy pol ON (src.tbloid = pol.polrelid)",
4112 for (
j = 0;
j < ntups;
j++)
4124 polinfo[
j].
dobj.namespace = tbinfo->
dobj.namespace;
4133 polinfo[
j].polroles = NULL;
4196 .namespace = polinfo->
dobj.namespace->dobj.
name,
4198 .description =
"ROW SECURITY",
4200 .createStmt = query->
data,
4208 if (polinfo->
polcmd ==
'*')
4210 else if (polinfo->
polcmd ==
'r')
4211 cmd =
" FOR SELECT";
4212 else if (polinfo->
polcmd ==
'a')
4213 cmd =
" FOR INSERT";
4214 else if (polinfo->
polcmd ==
'w')
4215 cmd =
" FOR UPDATE";
4216 else if (polinfo->
polcmd ==
'd')
4217 cmd =
" FOR DELETE";
4219 pg_fatal(
"unexpected policy command type: %c",
4255 .
namespace = polinfo->
dobj.namespace->dobj.
name,
4257 .description =
"POLICY",
4259 .createStmt = query->
data,
4260 .dropStmt = delqry->
data));
4306 "p.pubowner, p.puballtables, p.pubinsert, "
4307 "p.pubupdate, p.pubdelete, ");
4347 for (
i = 0;
i < ntups;
i++)
4460 .description =
"PUBLICATION",
4462 .createStmt = query->
data,
4463 .dropStmt = delq->
data));
4506 "SELECT tableoid, oid, pnpubid, pnnspid "
4507 "FROM pg_catalog.pg_publication_namespace");
4521 for (
i = 0;
i < ntups;
i++)
4533 if (pubinfo == NULL)
4536 if (nspinfo == NULL)
4552 pubsinfo[
j].
dobj.namespace = nspinfo->
dobj.namespace;
4596 "SELECT tableoid, oid, prpubid, prrelid, "
4597 "pg_catalog.pg_get_expr(prqual, prrelid) AS prrelqual, "
4599 " WHEN pr.prattrs IS NOT NULL THEN\n"
4600 " (SELECT array_agg(attname)\n"
4602 " pg_catalog.generate_series(0, pg_catalog.array_upper(pr.prattrs::pg_catalog.int2[], 1)) s,\n"
4603 " pg_catalog.pg_attribute\n"
4604 " WHERE attrelid = pr.prrelid AND attnum = prattrs[s])\n"
4605 " ELSE NULL END) prattrs "
4606 "FROM pg_catalog.pg_publication_rel pr");
4609 "SELECT tableoid, oid, prpubid, prrelid, "
4610 "NULL AS prrelqual, NULL AS prattrs "
4611 "FROM pg_catalog.pg_publication_rel");