PostgreSQL Source Code git master
|
#include "postgres_fe.h"
#include <time.h>
#include <unistd.h>
#include "catalog/pg_authid_d.h"
#include "common/connect.h"
#include "common/file_perm.h"
#include "common/file_utils.h"
#include "common/hashfn_unstable.h"
#include "common/logging.h"
#include "common/string.h"
#include "connectdb.h"
#include "dumputils.h"
#include "fe_utils/string_utils.h"
#include "filter.h"
#include "getopt_long.h"
#include "lib/simplehash.h"
Go to the source code of this file.
Data Structures | |
struct | RoleNameEntry |
Macros | |
#define | PGDUMP_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n" |
#define | SH_PREFIX rolename |
#define | SH_ELEMENT_TYPE RoleNameEntry |
#define | SH_KEY_TYPE char * |
#define | SH_KEY rolename |
#define | SH_HASH_KEY(tb, key) hash_string(key) |
#define | SH_EQUAL(tb, a, b) (strcmp(a, b) == 0) |
#define | SH_STORE_HASH |
#define | SH_GET_HASH(tb, a) (a)->hashval |
#define | SH_SCOPE static inline |
#define | SH_RAW_ALLOCATOR pg_malloc0 |
#define | SH_DECLARE |
#define | SH_DEFINE |
#define | PG_AUTHID "pg_authid" |
#define | PG_ROLES "pg_roles " |
Functions | |
static void | help (void) |
static void | dropRoles (PGconn *conn) |
static void | dumpRoles (PGconn *conn) |
static void | dumpRoleMembership (PGconn *conn) |
static void | dumpRoleGUCPrivs (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, ArchiveFormat archDumpFormat) |
static void | dumpTimestamp (const char *msg) |
static int | runPgDump (const char *dbname, const char *create_opts, char *dbfile, ArchiveFormat archDumpFormat) |
static void | buildShSecLabels (PGconn *conn, const char *catalog_name, Oid objectId, const char *objtype, const char *objname, PQExpBuffer buffer) |
static void | executeCommand (PGconn *conn, const char *query) |
static void | expand_dbname_patterns (PGconn *conn, SimpleStringList *patterns, SimpleStringList *names) |
static void | read_dumpall_filters (const char *filename, SimpleStringList *pattern) |
static ArchiveFormat | parseDumpFormat (const char *format) |
int | main (int argc, char *argv[]) |
Variables | |
static char | pg_dump_bin [MAXPGPATH] |
static PQExpBuffer | pgdumpopts |
static const 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_table_access_method = 0 |
static int | no_tablespaces = 0 |
static int | use_setsessauth = 0 |
static int | no_comments = 0 |
static int | no_policies = 0 |
static int | no_publications = 0 |
static int | no_security_labels = 0 |
static int | no_data = 0 |
static int | no_schema = 0 |
static int | no_statistics = 0 |
static int | no_subscriptions = 0 |
static int | no_toast_compression = 0 |
static int | no_unlogged_table_data = 0 |
static int | no_role_passwords = 0 |
static int | with_data = 0 |
static int | with_schema = 0 |
static int | with_statistics = 0 |
static int | server_version |
static int | load_via_partition_root = 0 |
static int | on_conflict_do_nothing = 0 |
static int | statistics_only = 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 PG_AUTHID "pg_authid" |
Definition at line 119 of file pg_dumpall.c.
#define PG_ROLES "pg_roles " |
Definition at line 120 of file pg_dumpall.c.
#define PGDUMP_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n" |
Definition at line 35 of file pg_dumpall.c.
#define SH_DECLARE |
Definition at line 54 of file pg_dumpall.c.
#define SH_DEFINE |
Definition at line 55 of file pg_dumpall.c.
#define SH_ELEMENT_TYPE RoleNameEntry |
Definition at line 45 of file pg_dumpall.c.
Definition at line 51 of file pg_dumpall.c.
#define SH_HASH_KEY | ( | tb, | |
key | |||
) | hash_string(key) |
Definition at line 48 of file pg_dumpall.c.
#define SH_KEY rolename |
Definition at line 47 of file pg_dumpall.c.
#define SH_KEY_TYPE char * |
Definition at line 46 of file pg_dumpall.c.
#define SH_PREFIX rolename |
Definition at line 44 of file pg_dumpall.c.
#define SH_RAW_ALLOCATOR pg_malloc0 |
Definition at line 53 of file pg_dumpall.c.
#define SH_SCOPE static inline |
Definition at line 52 of file pg_dumpall.c.
#define SH_STORE_HASH |
Definition at line 50 of file pg_dumpall.c.
|
static |
Definition at line 1836 of file pg_dumpall.c.
References buildShSecLabelQuery(), conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), emitShSecLabels(), executeQuery(), and PQclear().
Referenced by dumpRoles(), and dumpTablespaces().
|
static |
Definition at line 1473 of file pg_dumpall.c.
References conn, dbname, executeQuery(), fmtId(), fprintf, i, if_exists, OPF, PQclear(), PQgetvalue(), and PQntuples().
Referenced by main().
|
static |
Definition at line 777 of file pg_dumpall.c.
References buf, conn, createPQExpBuffer(), 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 1334 of file pg_dumpall.c.
References conn, executeQuery(), fmtId(), fprintf, i, if_exists, OPF, PQclear(), PQgetvalue(), and PQntuples().
Referenced by main().
|
static |
Definition at line 1616 of file pg_dumpall.c.
References archCustom, archNull, archTar, conn, database_exclude_names, dbname, executeQuery(), filename, fprintf, i, MAXPGPATH, mkdir, OPF, output_clean, PG_BINARY_A, PG_BINARY_W, pg_dir_create_mode, pg_fatal, pg_log_info, PQclear(), PQgetvalue(), PQntuples(), runPgDump(), simple_string_list_member(), snprintf, and strerror.
Referenced by main().
|
static |
Definition at line 1279 of file pg_dumpall.c.
References acldefault(), buf, buildACLCommands(), conn, CppAsString2, createPQExpBuffer(), destroyPQExpBuffer(), executeQuery(), exit_nicely(), fmtId(), fprintf, free, i, OPF, pg_log_error, pg_strdup(), PQclear(), PQfinish(), PQgetvalue(), PQntuples(), and server_version.
Referenced by main().
|
static |
Definition at line 1029 of file pg_dumpall.c.
References admin_option, appendPQExpBuffer(), appendPQExpBufferStr(), atooid, buf, conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), executeQuery(), exit_nicely(), fmtId(), fprintf, i, inherit_option, OPF, pg_free(), pg_log_error, pg_log_warning, pg_malloc0(), PQclear(), PQfinish(), PQfnumber(), PQgetisnull(), PQgetvalue(), PQntuples(), PQserverVersion(), printfPQExpBuffer(), remaining, resetPQExpBuffer(), role_catalog, server_version, set_option, and start.
Referenced by main().
|
static |
Definition at line 824 of file pg_dumpall.c.
References appendPQExpBuffer(), appendPQExpBufferStr(), appendStringLiteralConn(), atooid, binary_upgrade, buf, buildShSecLabels(), conn, createPQExpBuffer(), 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 1369 of file pg_dumpall.c.
References acldefault(), appendPQExpBuffer(), appendPQExpBufferStr(), appendStringLiteralConn(), atooid, binary_upgrade, buf, buildACLCommands(), buildShSecLabels(), conn, createPQExpBuffer(), destroyPQExpBuffer(), executeQuery(), exit_nicely(), fmtId(), fprintf, free, i, is_absolute_path, 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 1879 of file pg_dumpall.c.
References buf, fprintf, now(), OPF, and PGDUMP_STRFTIME_FMT.
Referenced by main().
|
static |
Definition at line 1520 of file pg_dumpall.c.
References appendPQExpBufferChar(), appendStringLiteralConn(), buf, conn, createPQExpBuffer(), destroyPQExpBuffer(), executeQuery(), fprintf, i, makeAlterConfigCommand(), OPF, PQclear(), PQgetvalue(), PQntuples(), printfPQExpBuffer(), resetPQExpBuffer(), role_catalog, and username.
Referenced by dumpRoles().
|
static |
Definition at line 1855 of file pg_dumpall.c.
References conn, exit_nicely(), pg_log_error, pg_log_error_detail, pg_log_info, PGRES_COMMAND_OK, PQclear(), PQerrorMessage(), PQexec(), PQfinish(), and PQresultStatus().
Referenced by appendQualifiedRelation(), connect_slot(), main(), retrieve_objects(), and vacuum_one_database().
|
static |
Definition at line 1563 of file pg_dumpall.c.
References appendPQExpBufferStr(), conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), executeQuery(), exit_nicely(), SimpleStringList::head, i, SimpleStringListCell::next, pg_log_error, PQclear(), PQfinish(), PQgetvalue(), PQntuples(), processSQLNamePattern(), resetPQExpBuffer(), and simple_string_list_append().
Referenced by main().
|
static |
Definition at line 696 of file pg_dumpall.c.
References _, printf, and progname.
Referenced by main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 129 of file pg_dumpall.c.
References appendPQExpBuffer(), appendPQExpBufferStr(), appendShellString(), archNull, binary_upgrade, column_inserts, conn, ConnectDatabase(), connstr, create_or_open_dir(), createPQExpBuffer(), PQExpBufferData::data, database_exclude_names, database_exclude_patterns, destroyPQExpBuffer(), disable_dollar_quoting, disable_triggers, dosync, dropDBs(), dropRoles(), dropTablespaces(), dumpDatabases(), dumpRoleGUCPrivs(), 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_data, no_policies, no_publications, no_role_passwords, no_schema, no_security_labels, no_statistics, no_subscriptions, no_table_access_method, no_tablespaces, no_toast_compression, no_unlogged_table_data, on_conflict_do_nothing, OPF, optarg, optind, output_clean, parseDumpFormat(), PG_AUTHID, PG_BINARY_W, pg_dump_bin, pg_encoding_to_char, pg_fatal, pg_log_error, pg_log_error_hint, PG_LOG_WARNING, pg_logging_increase_verbosity(), pg_logging_init(), pg_logging_set_level(), PG_ROLES, pg_strdup(), PG_TEXTDOMAIN, PGDUMP_VERSIONSTR, pgdumpopts, pghost, pgport, PQclientEncoding(), PQfinish(), PQparameterStatus(), PQsetClientEncoding(), progname, quote_all_identifiers, read_dumpall_filters(), required_argument, role_catalog, server_version, set_pglocale_pgservice(), setFmtEncoding(), simple_string_list_append(), skip_acls, snprintf, sprintf, statistics_only, generate_unaccent_rules::stdout, strlcpy(), TRI_DEFAULT, TRI_NO, TRI_YES, use_setsessauth, verbose, with_data, with_schema, and with_statistics.
|
static |
Definition at line 1953 of file pg_dumpall.c.
References archCustom, archDirectory, archNull, archTar, format, pg_fatal, and pg_strcasecmp().
Referenced by main().
|
static |
Definition at line 1898 of file pg_dumpall.c.
References _, exit_nicely(), filename, FILTER_COMMAND_TYPE_INCLUDE, filter_free(), filter_init(), FILTER_OBJECT_TYPE_DATABASE, FILTER_OBJECT_TYPE_EXTENSION, FILTER_OBJECT_TYPE_FOREIGN_DATA, FILTER_OBJECT_TYPE_FUNCTION, FILTER_OBJECT_TYPE_INDEX, filter_object_type_name(), FILTER_OBJECT_TYPE_NONE, FILTER_OBJECT_TYPE_SCHEMA, FILTER_OBJECT_TYPE_TABLE, FILTER_OBJECT_TYPE_TABLE_AND_CHILDREN, FILTER_OBJECT_TYPE_TABLE_DATA, FILTER_OBJECT_TYPE_TABLE_DATA_AND_CHILDREN, FILTER_OBJECT_TYPE_TRIGGER, filter_read_item(), free, pg_log_filter_error(), and simple_string_list_append().
Referenced by main().
|
static |
Definition at line 1762 of file pg_dumpall.c.
References appendConnStrVal(), appendPQExpBuffer(), appendPQExpBufferStr(), appendShellString(), archCustom, archDirectory, archNull, archTar, connstr, PQExpBufferData::data, dbname, filename, initPQExpBuffer(), pg_dump_bin, pg_log_info, pgdumpopts, printfPQExpBuffer(), and termPQExpBuffer().
Referenced by dumpDatabases().
|
static |
Definition at line 90 of file pg_dumpall.c.
Referenced by dumpRoles(), dumpTablespaces(), and main().
|
static |
Definition at line 91 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 84 of file pg_dumpall.c.
Referenced by appendPsqlMetaConnect(), ConnectDatabase(), constructConnStr(), dblink_connect(), dblink_connstr_check(), dblink_connstr_has_pw(), dblink_connstr_has_required_scram_options(), dblink_get_conn(), dblink_security_check(), generate_old_dump(), GetDbnameFromConnectionOptions(), main(), parse_connection_string(), recognized_connection_string(), runPgDump(), and uri_prefix_length().
|
static |
Definition at line 126 of file pg_dumpall.c.
Referenced by dumpDatabases(), and main().
|
static |
Definition at line 125 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 92 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 93 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 88 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 123 of file pg_dumpall.c.
Referenced by _fileExistsInDirectory(), _PrintFileData(), _tarPositionTo(), _tarWriteHeader(), adjust_data_dir(), BaseBackup(), basebackup_read_file(), bbsink_server_begin_archive(), bbsink_server_end_manifest(), be_lo_export(), be_lo_import(), be_lo_import_with_oid(), BeginCopyFrom(), BeginCopyTo(), check_file_excluded(), CheckXLogRemoved(), convert_and_check_filename(), create_file_for_extract(), CreateExtensionInternal(), CreateLockFile(), db_dir_size(), dir_close(), dir_get_file_name(), dir_open_for_write(), dsynonym_init(), dumpDatabases(), dxsyn_init(), ecpg_postprocess_result(), errfinish(), errsave_finish(), execute_extension_script(), execute_sql_string(), expand_tilde(), exportFile(), extract_directory(), extract_link(), file_acquire_sample_rows(), file_exists_in_directory(), file_fdw_validator(), fileAnalyzeForeignTable(), fileBeginForeignScan(), fileExplainForeignScan(), fileGetOptions(), fill_hba_line(), fill_ident_line(), filter_init(), first_dir_separator(), get_sock_dir(), GetConfFilesInDir(), hasSuffix(), importFile(), initTrie(), internal_load_library(), is_extension_control_filename(), is_extension_script_filename(), is_xlogfilename(), IsWalSummaryFilename(), last_dir_separator(), libpqrcv_readtimelinehistoryfile(), llvm_compile_module(), lo_export(), lo_import(), lo_import_internal(), lo_import_with_oid(), load_dh_file(), load_external_function(), load_file(), load_libraries(), load_tzoffsets(), log_locus_callback(), logfile_getname(), logfile_open(), logfile_rotate_dest(), LogicalTapeImport(), LogicalTapeSetCreate(), main(), make_incremental_rfile(), make_native_path(), make_outputdirs(), make_rfile(), next_field_expand(), NIImportAffixes(), NIImportDictionary(), NIImportOOAffixes(), open_auth_file(), parse_backup_label(), parse_extension_control_file(), parse_relfilenumber(), parse_snapshot_filename(), parseIntFromText(), ParseTzFile(), parseVxidFromText(), parseXidFromText(), pg_log_generic_v(), pg_stat_file(), PLy_traceback(), process_file(), process_psqlrc_file(), process_queued_fetch_requests(), progress_update_filename(), read_binary_file(), read_dictionary(), read_dump_filters(), read_dumpall_filters(), read_extension_script_file(), read_pg_version_file(), read_restore_filters(), read_text_file(), read_whole_file(), readstoplist(), reconstruct_from_incremental_file(), regcomp_auth_token(), run_diff(), runPgDump(), sendFileWithContent(), set_input(), set_stack_entry_location(), SetOutput(), setup_run_file(), shell_construct_command(), shell_run_command(), should_allow_existing_directory(), slurp_file(), splitTzLine(), SysLogger_Start(), tar_get_file_name(), tarCreateHeader(), tarOpen(), test_slru_scan_cb(), thesaurusRead(), tokenize_auth_file(), TrimExtension(), tsearch_readline_begin(), UpdateLastRemovedPtr(), verify_plain_backup_directory(), verify_tar_backup(), write_auto_conf_file(), WriteRecoveryConfig(), writeTimeLineHistoryFile(), and XLogRecordSaveFPWs().
|
static |
Definition at line 94 of file pg_dumpall.c.
Referenced by dropDBs(), dropRoles(), dropTablespaces(), and main().
|
static |
Definition at line 95 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 114 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 99 of file pg_dumpall.c.
Referenced by dumpRoles(), dumpTablespaces(), and main().
|
static |
Definition at line 103 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 100 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 101 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 109 of file pg_dumpall.c.
Referenced by dumpRoles(), and main().
|
static |
Definition at line 104 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 102 of file pg_dumpall.c.
Referenced by dumpRoles(), dumpTablespaces(), and main().
|
static |
Definition at line 105 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 106 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 96 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 97 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 107 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 108 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 115 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 122 of file pg_dumpall.c.
Referenced by copy_or_print_global_file(), dropDBs(), dropRoles(), dropTablespaces(), dumpDatabases(), dumpRoleGUCPrivs(), dumpRoleMembership(), dumpRoles(), dumpTablespaces(), dumpTimestamp(), dumpUserConfig(), and main().
|
static |
Definition at line 85 of file pg_dumpall.c.
Referenced by dumpDatabases(), and main().
|
static |
Definition at line 82 of file pg_dumpall.c.
Referenced by main(), and runPgDump().
|
static |
Definition at line 83 of file pg_dumpall.c.
Referenced by main(), and runPgDump().
|
static |
Definition at line 118 of file pg_dumpall.c.
Referenced by dropRoles(), dumpRoleMembership(), dumpRoles(), dumpUserConfig(), and main().
|
static |
Definition at line 113 of file pg_dumpall.c.
Referenced by ConnectDatabase(), connection_warnings(), dropRoles(), dumpRoleGUCPrivs(), dumpRoleMembership(), dumpRoles(), dumpTablespaces(), fetch_remote_table_info(), fetch_table_list(), main(), printVersion(), set_stream_options(), and SyncVariables().
|
static |
Definition at line 86 of file pg_dumpall.c.
Referenced by dumpTablespaces(), and main().
|
static |
Definition at line 116 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 98 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 87 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 110 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 111 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 112 of file pg_dumpall.c.
Referenced by main().