PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <time.h>
#include <unistd.h>
#include "common/connect.h"
#include "common/file_utils.h"
#include "common/logging.h"
#include "common/string.h"
#include "dumputils.h"
#include "fe_utils/string_utils.h"
#include "getopt_long.h"
#include "pg_backup.h"
Go to the source code of this file.
Macros | |
#define | PGDUMP_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n" |
#define | PG_AUTHID "pg_authid" |
#define | PG_ROLES "pg_roles " |
#define | exit_nicely(code) exit(code) |
Functions | |
static void | help (void) |
static void | dropRoles (PGconn *conn) |
static void | dumpRoles (PGconn *conn) |
static void | dumpRoleMembership (PGconn *conn) |
static void | dumpGroups (PGconn *conn) |
static void | dropTablespaces (PGconn *conn) |
static void | dumpTablespaces (PGconn *conn) |
static void | dropDBs (PGconn *conn) |
static void | dumpUserConfig (PGconn *conn, const char *username) |
static void | dumpDatabases (PGconn *conn) |
static void | dumpTimestamp (const char *msg) |
static int | runPgDump (const char *dbname, const char *create_opts) |
static void | buildShSecLabels (PGconn *conn, const char *catalog_name, Oid objectId, const char *objtype, const char *objname, PQExpBuffer buffer) |
static PGconn * | connectDatabase (const char *dbname, const char *connstr, const char *pghost, const char *pgport, const char *pguser, trivalue prompt_password, bool fail_on_error) |
static char * | constructConnStr (const char **keywords, const char **values) |
static PGresult * | executeQuery (PGconn *conn, const char *query) |
static void | executeCommand (PGconn *conn, const char *query) |
static void | expand_dbname_patterns (PGconn *conn, SimpleStringList *patterns, SimpleStringList *names) |
int | main (int argc, char *argv[]) |
Variables | |
static char | pg_dump_bin [MAXPGPATH] |
static const char * | progname |
static PQExpBuffer | pgdumpopts |
static char * | connstr = "" |
static bool | output_clean = false |
static bool | skip_acls = false |
static bool | verbose = false |
static bool | dosync = true |
static int | binary_upgrade = 0 |
static int | column_inserts = 0 |
static int | disable_dollar_quoting = 0 |
static int | disable_triggers = 0 |
static int | if_exists = 0 |
static int | inserts = 0 |
static int | no_tablespaces = 0 |
static int | use_setsessauth = 0 |
static int | no_comments = 0 |
static int | no_publications = 0 |
static int | no_security_labels = 0 |
static int | no_subscriptions = 0 |
static int | no_unlogged_table_data = 0 |
static int | no_role_passwords = 0 |
static int | server_version |
static int | load_via_partition_root = 0 |
static int | on_conflict_do_nothing = 0 |
static char | role_catalog [10] |
static FILE * | OPF |
static char * | filename = NULL |
static SimpleStringList | database_exclude_patterns = {NULL, NULL} |
static SimpleStringList | database_exclude_names = {NULL, NULL} |
#define exit_nicely | ( | code | ) | exit(code) |
Definition at line 96 of file pg_dumpall.c.
Referenced by connectDatabase(), dumpDatabases(), dumpPolicy(), dumpRule(), dumpSequence(), dumpSequenceData(), dumpTableData_copy(), dumpTablespaces(), dumpTrigger(), executeCommand(), executeQuery(), findParentsByOid(), getTableAttrs(), init_parallel_dump_utils(), main(), parseOidArray(), and warn_or_exit_horribly().
#define PG_AUTHID "pg_authid" |
Definition at line 87 of file pg_dumpall.c.
Referenced by main().
#define PG_ROLES "pg_roles " |
Definition at line 88 of file pg_dumpall.c.
Referenced by main().
#define PGDUMP_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n" |
Definition at line 31 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 1610 of file pg_dumpall.c.
References buildShSecLabelQuery(), createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), emitShSecLabels(), executeQuery(), and PQclear().
Referenced by dumpRoles(), and dumpTablespaces().
|
static |
Definition at line 1636 of file pg_dumpall.c.
References ALWAYS_SECURE_SEARCH_PATH_SQL, conn, CONNECTION_BAD, connstr, constructConnStr(), dbname, executeQuery(), exit_nicely, free, i, _PQconninfoOption::keyword, password, pg_log_error, pg_malloc0(), pghost, pgport, PQclear(), PQconnectdbParams(), PQconnectionNeedsPassword(), PQconninfoFree(), PQconninfoParse(), PQerrorMessage(), PQfinish(), PQparameterStatus(), PQserverVersion(), PQstatus(), progname, server_version, simple_prompt(), TRI_NO, TRI_YES, _PQconninfoOption::val, and values.
Referenced by cluster_one_database(), main(), ParallelSlotsSetup(), reindex_one_database(), and vacuum_one_database().
|
static |
Definition at line 1844 of file pg_dumpall.c.
References appendConnStrVal(), appendPQExpBuffer(), appendPQExpBufferChar(), buf, connstr, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), i, and pg_strdup().
Referenced by connectDatabase().
|
static |
Definition at line 1312 of file pg_dumpall.c.
References dbname, executeQuery(), fmtId(), fprintf, i, if_exists, OPF, PQclear(), PQgetvalue(), and PQntuples().
Referenced by main().
|
static |
Definition at line 683 of file pg_dumpall.c.
References buf, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), executeQuery(), fmtId(), fprintf, i, if_exists, OPF, PQclear(), PQfnumber(), PQgetvalue(), PQntuples(), printfPQExpBuffer(), role_catalog, and server_version.
Referenced by main().
|
static |
Definition at line 1121 of file pg_dumpall.c.
References executeQuery(), fmtId(), fprintf, i, if_exists, OPF, PQclear(), PQgetvalue(), and PQntuples().
Referenced by main().
|
static |
Definition at line 1458 of file pg_dumpall.c.
References dbname, executeQuery(), exit_nicely, filename, fprintf, i, OPF, output_clean, PG_BINARY_A, pg_log_error, pg_log_info, PQclear(), PQgetvalue(), PQntuples(), runPgDump(), and simple_string_list_member().
Referenced by main().
|
static |
Definition at line 1056 of file pg_dumpall.c.
References buf, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), executeQuery(), fmtId(), fprintf, free, i, OPF, pg_strdup(), PQclear(), PQgetvalue(), PQntuples(), and printfPQExpBuffer().
Referenced by main().
|
static |
Definition at line 996 of file pg_dumpall.c.
References buf, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), executeQuery(), fmtId(), fprintf, grantor, i, member, OPF, PQclear(), PQgetisnull(), PQgetvalue(), PQntuples(), printfPQExpBuffer(), and role_catalog.
Referenced by main().
|
static |
Definition at line 738 of file pg_dumpall.c.
References appendPQExpBuffer(), appendPQExpBufferStr(), appendStringLiteralConn(), atooid, binary_upgrade, buf, buildShSecLabels(), createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), dumpUserConfig(), executeQuery(), fmtId(), fprintf, i, no_comments, no_role_passwords, no_security_labels, OPF, pg_log_warning, PQclear(), PQfnumber(), PQgetisnull(), PQgetvalue(), PQntuples(), printfPQExpBuffer(), resetPQExpBuffer(), role_catalog, and server_version.
Referenced by main().
|
static |
Definition at line 1156 of file pg_dumpall.c.
References appendPQExpBuffer(), appendPQExpBufferStr(), appendStringLiteralConn(), atooid, buf, buildACLCommands(), buildShSecLabels(), createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), executeQuery(), exit_nicely, fmtId(), fprintf, free, i, no_comments, no_security_labels, OPF, pg_log_error, pg_strdup(), PQclear(), PQfinish(), PQgetvalue(), PQntuples(), server_version, and skip_acls.
Referenced by main().
|
static |
Definition at line 1922 of file pg_dumpall.c.
References buf, fprintf, now(), OPF, and PGDUMP_STRFTIME_FMT.
Referenced by main().
|
static |
Definition at line 1359 of file pg_dumpall.c.
References appendPQExpBufferChar(), appendStringLiteralConn(), buf, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), executeQuery(), fprintf, makeAlterConfigCommand(), OPF, PQclear(), PQgetisnull(), PQgetvalue(), PQntuples(), printfPQExpBuffer(), resetPQExpBuffer(), role_catalog, and server_version.
Referenced by dumpRoles().
|
static |
Definition at line 1898 of file pg_dumpall.c.
References exit_nicely, pg_log_error, pg_log_info, PGRES_COMMAND_OK, PQclear(), PQerrorMessage(), PQexec(), PQfinish(), and PQresultStatus().
Referenced by main(), and vacuum_one_database().
Definition at line 1875 of file pg_dumpall.c.
References exit_nicely, pg_log_error, pg_log_info, PGRES_TUPLES_OK, PQerrorMessage(), PQexec(), PQfinish(), and PQresultStatus().
Referenced by buildShSecLabels(), cluster_all_databases(), connectDatabase(), dropDBs(), dropRoles(), dropTablespaces(), dumpDatabases(), dumpGroups(), dumpRoleMembership(), dumpRoles(), dumpTablespaces(), dumpUserConfig(), expand_dbname_patterns(), get_parallel_object_list(), reindex_all_databases(), vacuum_all_databases(), and vacuum_one_database().
|
static |
Definition at line 1416 of file pg_dumpall.c.
References appendPQExpBufferStr(), createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), executeQuery(), SimpleStringList::head, i, SimpleStringListCell::next, PQclear(), PQgetvalue(), PQntuples(), processSQLNamePattern(), resetPQExpBuffer(), and simple_string_list_append().
Referenced by main().
|
static |
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 99 of file pg_dumpall.c.
References _, appendPQExpBuffer(), appendPQExpBufferStr(), appendShellString(), binary_upgrade, column_inserts, conn, connectDatabase(), connstr, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), disable_dollar_quoting, disable_triggers, dosync, dropDBs(), dropRoles(), dropTablespaces(), dumpDatabases(), dumpGroups(), dumpRoleMembership(), dumpRoles(), dumpTablespaces(), dumpTimestamp(), encoding, executeCommand(), exit_nicely, expand_dbname_patterns(), filename, find_my_exec(), find_other_exec(), fmtId(), fprintf, fsync_fname(), get_progname(), getopt_long(), SimpleStringList::head, help(), if_exists, inserts, load_via_partition_root, MAXPGPATH, no_argument, no_comments, no_publications, no_role_passwords, no_security_labels, no_subscriptions, no_tablespaces, no_unlogged_table_data, on_conflict_do_nothing, OPF, optarg, optind, output_clean, PG_AUTHID, PG_BINARY_W, pg_dump_bin, pg_encoding_to_char(), pg_log_error, PG_LOG_WARNING, pg_logging_increase_verbosity(), pg_logging_init(), pg_logging_set_level(), PG_ROLES, pg_strdup(), PG_TEXTDOMAIN, PGDUMP_VERSIONSTR, pghost, pgport, PQclientEncoding(), PQfinish(), PQparameterStatus(), PQsetClientEncoding(), progname, quote_all_identifiers, required_argument, role_catalog, server_version, set_pglocale_pgservice(), simple_string_list_append(), skip_acls, sprintf, generate_unaccent_rules::stdout, strlcpy(), TRI_DEFAULT, TRI_NO, TRI_YES, use_setsessauth, and verbose.
|
static |
Definition at line 1558 of file pg_dumpall.c.
References appendConnStrVal(), appendPQExpBuffer(), appendPQExpBufferStr(), appendShellString(), connstr, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), filename, pg_dump_bin, pg_log_info, and generate_unaccent_rules::stdout.
Referenced by dumpDatabases().
|
static |
Definition at line 68 of file pg_dumpall.c.
Referenced by dumpRoles(), and main().
|
static |
Definition at line 69 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 62 of file pg_dumpall.c.
Referenced by appendPsqlMetaConnect(), connectDatabase(), constructConnStr(), dblink_connect(), dblink_get_conn(), generate_old_dump(), main(), and runPgDump().
|
static |
Definition at line 94 of file pg_dumpall.c.
|
static |
Definition at line 93 of file pg_dumpall.c.
|
static |
Definition at line 70 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 71 of file pg_dumpall.c.
Referenced by main().
Definition at line 66 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 91 of file pg_dumpall.c.
Referenced by _copyCopyStmt(), _copyLoadStmt(), _equalCopyStmt(), _equalLoadStmt(), adjust_data_dir(), BaseBackup(), be_lo_export(), be_lo_import(), be_lo_import_with_oid(), check_file_excluded(), CheckXLogRemoved(), cleanup(), convert_and_check_filename(), CreateExtensionInternal(), db_dir_size(), dsynonym_init(), dumpDatabases(), dxsyn_init(), errfinish(), execute_extension_script(), expand_tilde(), file_acquire_sample_rows(), file_fdw_validator(), fileAnalyzeForeignTable(), fileBeginForeignScan(), fileExplainForeignScan(), get_cfp_error(), get_sock_dir(), llvm_compile_module(), load_libraries(), logfile_getname(), logfile_rotate(), LogicalTapeSetCreate(), ltsConcatWorkerTapes(), main(), parse_extension_control_file(), parseCommandLine(), pg_file_sync(), pg_file_unlink(), pg_file_unlink_v1_1(), pg_file_write_internal(), pg_log_generic_v(), pg_read_binary_file(), pg_read_file(), pg_read_file_v2(), pg_stat_file(), PLy_traceback(), process_file(), process_queued_fetch_requests(), readstoplist(), rmtree(), runPgDump(), sendFile(), splitTzLine(), SysLogger_Start(), tsearch_readline_begin(), verify_backup_directory(), and WriteRecoveryConfig().
|
static |
Definition at line 72 of file pg_dumpall.c.
Referenced by dropDBs(), dropRoles(), dropTablespaces(), and main().
|
static |
Definition at line 73 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 83 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 76 of file pg_dumpall.c.
Referenced by dumpRoles(), dumpTablespaces(), and main().
|
static |
Definition at line 77 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 81 of file pg_dumpall.c.
Referenced by dumpRoles(), and main().
|
static |
Definition at line 78 of file pg_dumpall.c.
Referenced by dumpRoles(), dumpTablespaces(), and main().
|
static |
Definition at line 79 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 74 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 80 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 84 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 90 of file pg_dumpall.c.
Referenced by dropDBs(), dropRoles(), dropTablespaces(), dumpDatabases(), dumpGroups(), dumpRoleMembership(), dumpRoles(), dumpTablespaces(), dumpTimestamp(), dumpUserConfig(), and main().
Definition at line 63 of file pg_dumpall.c.
Referenced by dumpDatabases(), and main().
|
static |
Definition at line 59 of file pg_dumpall.c.
Referenced by main(), and runPgDump().
|
static |
Definition at line 61 of file pg_dumpall.c.
|
static |
Definition at line 60 of file pg_dumpall.c.
Referenced by connectDatabase(), help(), and main().
|
static |
Definition at line 86 of file pg_dumpall.c.
Referenced by dropRoles(), dumpRoleMembership(), dumpRoles(), dumpUserConfig(), and main().
|
static |
Definition at line 82 of file pg_dumpall.c.
Referenced by connectDatabase(), connection_warnings(), dropRoles(), dumpRoles(), dumpTablespaces(), dumpUserConfig(), main(), and SyncVariables().
Definition at line 64 of file pg_dumpall.c.
Referenced by dumpTablespaces(), and main().
|
static |
Definition at line 75 of file pg_dumpall.c.
Referenced by main().
Definition at line 65 of file pg_dumpall.c.
Referenced by main().