if (find_my_exec(argv[0], full_path) < 0)
strlcpy(full_path, progname, sizeof(full_path));
if (ret == -1)
pg_fatal("program \"%s\" is needed by %s but was not found in the same directory as \"%s\"", "pg_dump", progname, full_path); else
pg_fatal("program \"%s\" was found by \"%s\" but was not the same version as %s", "pg_dump", full_path, progname);
}
default: /* getopt_long already emitted a complaint */
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
}
/* Complain if any arguments remain */ if (optind < argc)
{
pg_log_error("too many command-line arguments (first is \"%s\")",
argv[optind]);
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
if (database_exclude_patterns.head != NULL &&
(globals_only || roles_only || tablespaces_only))
{
pg_log_error("option %s cannot be used together with %s, %s, or %s", "--exclude-database", "-g/--globals-only", "-r/--roles-only", "-t/--tablespaces-only");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
/* Make sure the user hasn't specified a mix of globals-only options */ if (globals_only && roles_only)
{
pg_log_error("options %s and %s cannot be used together", "-g/--globals-only", "-r/--roles-only");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
if (globals_only && tablespaces_only)
{
pg_log_error("options %s and %s cannot be used together", "-g/--globals-only", "-t/--tablespaces-only");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
if (roles_only && tablespaces_only)
{
pg_log_error("options %s and %s cannot be used together", "-r/--roles-only", "-t/--tablespaces-only");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
/* Add long options to the pg_dump argument list */ if (binary_upgrade)
appendPQExpBufferStr(pgdumpopts, " --binary-upgrade"); if (column_inserts)
appendPQExpBufferStr(pgdumpopts, " --column-inserts"); if (disable_dollar_quoting)
appendPQExpBufferStr(pgdumpopts, " --disable-dollar-quoting"); if (disable_triggers)
appendPQExpBufferStr(pgdumpopts, " --disable-triggers"); if (inserts)
appendPQExpBufferStr(pgdumpopts, " --inserts"); if (no_table_access_method)
appendPQExpBufferStr(pgdumpopts, " --no-table-access-method"); if (no_tablespaces)
appendPQExpBufferStr(pgdumpopts, " --no-tablespaces"); if (quote_all_identifiers)
appendPQExpBufferStr(pgdumpopts, " --quote-all-identifiers"); if (load_via_partition_root)
appendPQExpBufferStr(pgdumpopts, " --load-via-partition-root"); if (use_setsessauth)
appendPQExpBufferStr(pgdumpopts, " --use-set-session-authorization"); if (no_comments)
appendPQExpBufferStr(pgdumpopts, " --no-comments"); if (no_data)
appendPQExpBufferStr(pgdumpopts, " --no-data"); if (no_policies)
appendPQExpBufferStr(pgdumpopts, " --no-policies"); if (no_publications)
appendPQExpBufferStr(pgdumpopts, " --no-publications"); if (no_security_labels)
appendPQExpBufferStr(pgdumpopts, " --no-security-labels"); if (no_schema)
appendPQExpBufferStr(pgdumpopts, " --no-schema"); if (no_statistics)
appendPQExpBufferStr(pgdumpopts, " --no-statistics"); if (no_subscriptions)
appendPQExpBufferStr(pgdumpopts, " --no-subscriptions"); if (no_toast_compression)
appendPQExpBufferStr(pgdumpopts, " --no-toast-compression"); if (no_unlogged_table_data)
appendPQExpBufferStr(pgdumpopts, " --no-unlogged-table-data"); if (with_statistics)
appendPQExpBufferStr(pgdumpopts, " --statistics"); if (on_conflict_do_nothing)
appendPQExpBufferStr(pgdumpopts, " --on-conflict-do-nothing"); if (statistics_only)
appendPQExpBufferStr(pgdumpopts, " --statistics-only"); if (sequence_data)
appendPQExpBufferStr(pgdumpopts, " --sequence-data");
/* *Ifyoudon'tprovidearestrictkey,onewillbeappointedforyou.
*/ if (!restrict_key)
restrict_key = generate_restrict_key(); if (!restrict_key)
pg_fatal("could not generate restrict key"); if (!valid_restrict_key(restrict_key))
pg_fatal("invalid restrict key");
if (!conn)
{
pg_log_error("could not connect to databases \"postgres\" or \"template1\"\n" "Please specify an alternative database.");
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
exit_nicely(1);
}
}
/* sync the resulting file, errors are not fatal */ if (dosync)
(void) fsync_fname(filename, false);
}
exit_nicely(0);
}
staticvoid
help(void)
{
printf(_("%s exports a PostgreSQL database cluster as an SQL script.\n\n"), progname);
printf(_("Usage:\n"));
printf(_(" %s [OPTION]...\n"), progname);
printf(_("\nGeneral options:\n"));
printf(_(" -f, --file=FILENAME output file name\n"));
printf(_(" -v, --verbose verbose mode\n"));
printf(_(" -V, --version output version information, then exit\n"));
printf(_(" --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock\n"));
printf(_(" -?, --help show this help, then exit\n"));
printf(_("\nOptions controlling the output content:\n"));
printf(_(" -a, --data-only dump only the data, not the schema or statistics\n"));
printf(_(" -c, --clean clean (drop) databases before recreating\n"));
printf(_(" -E, --encoding=ENCODING dump the data in encoding ENCODING\n"));
printf(_(" -g, --globals-only dump only global objects, no databases\n"));
printf(_(" -O, --no-owner skip restoration of object ownership\n"));
printf(_(" -r, --roles-only dump only roles, no databases or tablespaces\n"));
printf(_(" -s, --schema-only dump only the schema, no data or statistics\n"));
printf(_(" -S, --superuser=NAME superuser user name to use in the dump\n"));
printf(_(" -t, --tablespaces-only dump only tablespaces, no databases or roles\n"));
printf(_(" -x, --no-privileges do not dump privileges (grant/revoke)\n"));
printf(_(" --binary-upgrade for use by upgrade utilities only\n"));
printf(_(" --column-inserts dump data as INSERT commands with column names\n"));
printf(_(" --disable-dollar-quoting disable dollar quoting, use SQL standard quoting\n"));
printf(_(" --disable-triggers disable triggers during data-only restore\n"));
printf(_(" --exclude-database=PATTERN exclude databases whose name matches PATTERN\n"));
printf(_(" --extra-float-digits=NUM override default setting for extra_float_digits\n"));
printf(_(" --filter=FILENAME exclude databases based on expressions in FILENAME\n"));
printf(_(" --if-exists use IF EXISTS when dropping objects\n"));
printf(_(" --inserts dump data as INSERT commands, rather than COPY\n"));
printf(_(" --load-via-partition-root load partitions via the root table\n"));
printf(_(" --no-comments do not dump comment commands\n"));
printf(_(" --no-data do not dump data\n"));
printf(_(" --no-policies do not dump row security policies\n"));
printf(_(" --no-publications do not dump publications\n"));
printf(_(" --no-role-passwords do not dump passwords for roles\n"));
printf(_(" --no-schema do not dump schema\n"));
printf(_(" --no-security-labels do not dump security label assignments\n"));
printf(_(" --no-statistics do not dump statistics\n"));
printf(_(" --no-subscriptions do not dump subscriptions\n"));
printf(_(" --no-sync do not wait for changes to be written safely to disk\n"));
printf(_(" --no-table-access-method do not dump table access methods\n"));
printf(_(" --no-tablespaces do not dump tablespace assignments\n"));
printf(_(" --no-toast-compression do not dump TOAST compression methods\n"));
printf(_(" --no-unlogged-table-data do not dump unlogged table data\n"));
printf(_(" --on-conflict-do-nothing add ON CONFLICT DO NOTHING to INSERT commands\n"));
printf(_(" --quote-all-identifiers quote all identifiers, even if not key words\n"));
printf(_(" --restrict-key=RESTRICT_KEY use provided string as psql \\restrict key\n"));
printf(_(" --rows-per-insert=NROWS number of rows per INSERT; implies --inserts\n"));
printf(_(" --sequence-data include sequence data in dump\n"));
printf(_(" --statistics dump the statistics\n"));
printf(_(" --statistics-only dump only the statistics, not schema or data\n"));
printf(_(" --use-set-session-authorization\n" " use SET SESSION AUTHORIZATION commands instead of\n" " ALTER OWNER commands to set ownership\n"));
printf(_("\nConnection options:\n"));
printf(_(" -d, --dbname=CONNSTR connect using connection string\n"));
printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
printf(_(" -l, --database=DBNAME alternative default database\n"));
printf(_(" -p, --port=PORT database server port number\n"));
printf(_(" -U, --username=NAME connect as specified database user\n"));
printf(_(" -w, --no-password never prompt for password\n"));
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
printf(_(" --role=ROLENAME do SET ROLE before dump\n"));
printf(_("\nIf -f/--file is not used, then the SQL script will be written to the standard\n" "output.\n\n"));
printf(_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
}
/* *Droproles
*/ staticvoid
dropRoles(PGconn *conn)
{
PQExpBuffer buf = createPQExpBuffer();
PGresult *res; int i_rolname; int i;
if (PQntuples(res) > 0)
fprintf(OPF, "--\n-- Roles\n--\n\n");
for (i = 0; i < PQntuples(res); i++)
{ constchar *rolename;
Oid auth_oid;
auth_oid = atooid(PQgetvalue(res, i, i_oid));
rolename = PQgetvalue(res, i, i_rolname);
if (strncmp(rolename, "pg_", 3) == 0)
{
pg_log_warning("role name starting with \"pg_\" skipped (%s)",
rolename); continue;
}
resetPQExpBuffer(buf);
if (binary_upgrade)
{
appendPQExpBufferStr(buf, "\n-- For binary upgrade, must preserve pg_authid.oid\n");
appendPQExpBuffer(buf, "SELECT pg_catalog.binary_upgrade_set_next_pg_authid_oid('%u'::pg_catalog.oid);\n\n",
auth_oid);
}
/* *WedumpCREATEROLEfollowedbyALTERROLEtoensurethattherole *willacquiretherightpropertiesevenifitalreadyexists(ie,it *won'thurtfortheCREATEtofail).Thisisparticularlyimportant *fortheroleweareconnectedas,sinceevenwith--cleanwewill *havefailedtodropit.binary_upgradecannotgenerateanyerrors, *soweassumethecurrentroleisalreadycreated.
*/ if (!binary_upgrade ||
strcmp(PQgetvalue(res, i, i_is_current_user), "f") == 0)
appendPQExpBuffer(buf, "CREATE ROLE %s;\n", fmtId(rolename));
appendPQExpBuffer(buf, "ALTER ROLE %s WITH", fmtId(rolename));
if (strcmp(PQgetvalue(res, i, i_rolsuper), "t") == 0)
appendPQExpBufferStr(buf, " SUPERUSER"); else
appendPQExpBufferStr(buf, " NOSUPERUSER");
if (strcmp(PQgetvalue(res, i, i_rolinherit), "t") == 0)
appendPQExpBufferStr(buf, " INHERIT"); else
appendPQExpBufferStr(buf, " NOINHERIT");
if (strcmp(PQgetvalue(res, i, i_rolcreaterole), "t") == 0)
appendPQExpBufferStr(buf, " CREATEROLE"); else
appendPQExpBufferStr(buf, " NOCREATEROLE");
if (strcmp(PQgetvalue(res, i, i_rolcreatedb), "t") == 0)
appendPQExpBufferStr(buf, " CREATEDB"); else
appendPQExpBufferStr(buf, " NOCREATEDB");
if (strcmp(PQgetvalue(res, i, i_rolcanlogin), "t") == 0)
appendPQExpBufferStr(buf, " LOGIN"); else
appendPQExpBufferStr(buf, " NOLOGIN");
if (strcmp(PQgetvalue(res, i, i_rolreplication), "t") == 0)
appendPQExpBufferStr(buf, " REPLICATION"); else
appendPQExpBufferStr(buf, " NOREPLICATION");
if (strcmp(PQgetvalue(res, i, i_rolbypassrls), "t") == 0)
appendPQExpBufferStr(buf, " BYPASSRLS"); else
appendPQExpBufferStr(buf, " NOBYPASSRLS");
if (strcmp(PQgetvalue(res, i, i_rolconnlimit), "-1") != 0)
appendPQExpBuffer(buf, " CONNECTION LIMIT %s",
PQgetvalue(res, i, i_rolconnlimit));
if (!PQgetisnull(res, i, i_rolpassword) && !no_role_passwords)
{
appendPQExpBufferStr(buf, " PASSWORD ");
appendStringLiteralConn(buf, PQgetvalue(res, i, i_rolpassword), conn);
}
if (!PQgetisnull(res, i, i_rolvaliduntil))
appendPQExpBuffer(buf, " VALID UNTIL '%s'",
PQgetvalue(res, i, i_rolvaliduntil));
appendPQExpBufferStr(buf, ";\n");
if (!no_comments && !PQgetisnull(res, i, i_rolcomment))
{
appendPQExpBuffer(buf, "COMMENT ON ROLE %s IS ", fmtId(rolename));
appendStringLiteralConn(buf, PQgetvalue(res, i, i_rolcomment), conn);
appendPQExpBufferStr(buf, ";\n");
}
if (!no_security_labels)
buildShSecLabels(conn, "pg_authid", auth_oid, "ROLE", rolename,
buf);
fprintf(OPF, "%s", buf->data);
}
/* *Dumpconfigurationsettingsforrolesafterallroleshavebeendumped. *Wedoitthiswaybecauseconfigsettingsforrolescouldmentionthe *namesofotherroles.
*/ if (PQntuples(res) > 0)
fprintf(OPF, "\n--\n-- User Configurations\n--\n");
for (i = 0; i < PQntuples(res); i++)
dumpUserConfig(conn, PQgetvalue(res, i, i_rolname));
PQclear(res);
fprintf(OPF, "\n\n");
destroyPQExpBuffer(buf);
}
/* *Dumprolememberships. * *Note:weexpectdumpRolesalreadycreatedalltheroles,butthereis *nomembershipyet.
*/ staticvoid
dumpRoleMembership(PGconn *conn)
{
PQExpBuffer buf = createPQExpBuffer();
PQExpBuffer optbuf = createPQExpBuffer();
PGresult *res; int start = 0,
end,
total; bool dump_grantors; bool dump_grant_options; int i_role; int i_member; int i_grantor; int i_roleid; int i_memberid; int i_grantorid; int i_admin_option; int i_inherit_option; int i_set_option;
/* Generate and execute query. */
printfPQExpBuffer(buf, "SELECT ur.rolname AS role, " "um.rolname AS member, " "ug.rolname AS grantor, " "a.roleid AS roleid, " "a.member AS memberid, " "a.grantor AS grantorid, " "a.admin_option"); if (dump_grant_options)
appendPQExpBufferStr(buf, ", a.inherit_option, a.set_option");
appendPQExpBuffer(buf, " FROM pg_auth_members a " "LEFT JOIN %s ur on ur.oid = a.roleid " "LEFT JOIN %s um on um.oid = a.member " "LEFT JOIN %s ug on ug.oid = a.grantor " "WHERE NOT (ur.rolname ~ '^pg_' AND um.rolname ~ '^pg_')" "ORDER BY 1,2,3", role_catalog, role_catalog, role_catalog);
res = executeQuery(conn, buf->data);
i_role = PQfnumber(res, "role");
i_member = PQfnumber(res, "member");
i_grantor = PQfnumber(res, "grantor");
i_roleid = PQfnumber(res, "roleid");
i_memberid = PQfnumber(res, "memberid");
i_grantorid = PQfnumber(res, "grantorid");
i_admin_option = PQfnumber(res, "admin_option");
i_inherit_option = PQfnumber(res, "inherit_option");
i_set_option = PQfnumber(res, "set_option");
if (PQntuples(res) > 0)
fprintf(OPF, "--\n-- Role memberships\n--\n\n");
/* *Wecan'tdumptheseGRANTcommandsinarbitraryorder,becausearole *thatisnamedasagrantormustalreadyhaveADMINOPTIONontherole *forwhichitisgrantingpermissions,exceptforthebootstrap *superuser,whocanalwaysbenamedasthegrantor. * *Wehandlethisbyconsideringthesegrantsrolebyrole.Foreachrole, *weinitiallyconsidertheonlyallowablegrantortobethebootstrap *superuser.EverytimewegrantADMINOPTIONontheroletosomeuser, *thatuseralsobecomesanallowablegrantor.Wemakerepeatedpasses *overthegrantsfortherole,eachtimedumpingthosewhosegrantors *areallowableandwhichwehaven'tdoneyet.Eventuallythisshouldlet *usdumpallthegrants.
*/
total = PQntuples(res); while (start < total)
{ char *role = PQgetvalue(res, start, i_role); int i; bool *done; int remaining; int prev_remaining = 0;
rolename_hash *ht;
/* If we hit a null roleid, we're done (nulls sort to the end). */ if (PQgetisnull(res, start, i_role))
{ /* translator: %s represents a numeric role OID */
pg_log_warning("ignoring role grant for missing role with OID %s",
PQgetvalue(res, start, i_roleid)); break;
}
/* All memberships for a single role should be adjacent. */ for (end = start; end < total; ++end)
{ char *otherrole;
/* *Makerepeatedpassesoverthegrantsforthisroleuntilallhave *beendumped.
*/ while (remaining > 0)
{ /* *Weshouldmakeprogressoneveryiteration,becauseanotional *graphwhoseverticesaregrantsandwhoseedgespointfrom *grantorstomembersshouldbeconnectedandacyclic.Ifwefail *tomakeprogress,eitherweortheserverhavemessedup.
*/ if (remaining == prev_remaining)
{
pg_log_error("could not find a legal dump ordering for memberships in role \"%s\"",
role);
PQfinish(conn);
exit_nicely(1);
}
prev_remaining = remaining;
/* Make one pass over the grants for this role. */ for (i = start; i < end; ++i)
{ char *member; char *grantorid; char *grantor = NULL; bool dump_this_grantor = dump_grantors; char *set_option = "true"; char *admin_option; bool found;
/* If we already did this grant, don't do it again. */ if (done[i - start]) continue;
/* Complain about, then ignore, entries for unknown members. */ if (PQgetisnull(res, i, i_member))
{ /* translator: %s represents a numeric role OID */
pg_log_warning("ignoring role grant to missing role with OID %s",
PQgetvalue(res, i, i_memberid));
done[i - start] = true;
--remaining; continue;
}
member = PQgetvalue(res, i, i_member);
/* If the grantor is unknown, complain and dump without it. */
grantorid = PQgetvalue(res, i, i_grantorid); if (dump_this_grantor)
{ if (PQgetisnull(res, i, i_grantor))
{ /* translator: %s represents a numeric role OID */
pg_log_warning("grant of role \"%s\" to \"%s\" has invalid grantor OID %s",
role, member, grantorid);
pg_log_warning_detail("This grant will be dumped without GRANTED BY.");
dump_this_grantor = false;
} else
grantor = PQgetvalue(res, i, i_grantor);
}
admin_option = PQgetvalue(res, i, i_admin_option); if (dump_grant_options)
set_option = PQgetvalue(res, i, i_set_option);
/* Generate the actual GRANT statement. */
resetPQExpBuffer(optbuf);
fprintf(OPF, "GRANT %s", fmtId(role));
fprintf(OPF, " TO %s", fmtId(member)); if (*admin_option == 't')
appendPQExpBufferStr(optbuf, "ADMIN OPTION"); if (dump_grant_options)
{ char *inherit_option;
if (optbuf->data[0] != '\0')
appendPQExpBufferStr(optbuf, ", ");
inherit_option = PQgetvalue(res, i, i_inherit_option);
appendPQExpBuffer(optbuf, "INHERIT %s",
*inherit_option == 't' ? "TRUE" : "FALSE");
} if (*set_option != 't')
{ if (optbuf->data[0] != '\0')
appendPQExpBufferStr(optbuf, ", ");
appendPQExpBufferStr(optbuf, "SET FALSE");
} if (optbuf->data[0] != '\0')
fprintf(OPF, " WITH %s", optbuf->data); if (dump_this_grantor)
fprintf(OPF, " GRANTED BY %s", fmtId(grantor));
fprintf(OPF, ";\n");
}
}
while (filter_read_item(&fstate, &objname, &comtype, &objtype))
{ if (comtype == FILTER_COMMAND_TYPE_INCLUDE)
{
pg_log_filter_error(&fstate, _("%s filter for \"%s\" is not allowed"), "include",
filter_object_type_name(objtype));
exit_nicely(1);
}
switch (objtype)
{ case FILTER_OBJECT_TYPE_NONE: break; case FILTER_OBJECT_TYPE_FUNCTION: case FILTER_OBJECT_TYPE_INDEX: case FILTER_OBJECT_TYPE_TABLE_DATA: case FILTER_OBJECT_TYPE_TABLE_DATA_AND_CHILDREN: case FILTER_OBJECT_TYPE_TRIGGER: case FILTER_OBJECT_TYPE_EXTENSION: case FILTER_OBJECT_TYPE_FOREIGN_DATA: case FILTER_OBJECT_TYPE_SCHEMA: case FILTER_OBJECT_TYPE_TABLE: case FILTER_OBJECT_TYPE_TABLE_AND_CHILDREN:
pg_log_filter_error(&fstate, _("unsupported filter object"));
exit_nicely(1); break;
case FILTER_OBJECT_TYPE_DATABASE:
simple_string_list_append(pattern, objname); break;
}
if (objname)
free(objname);
}
filter_free(&fstate);
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.29Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-08-07)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.