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_utils.h"
#include "common/hashfn_unstable.h"
#include "common/logging.h"
#include "common/string.h"
#include "dumputils.h"
#include "fe_utils/string_utils.h"
#include "filter.h"
#include "getopt_long.h"
#include "pg_backup.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 " |
#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 | 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) |
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 *connection_string, 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) |
static void | read_dumpall_filters (const char *filename, SimpleStringList *pattern) |
int | main (int argc, char *argv[]) |
#define exit_nicely | ( | code | ) | exit(code) |
Definition at line 124 of file pg_dumpall.c.
#define PG_AUTHID "pg_authid" |
Definition at line 115 of file pg_dumpall.c.
#define PG_ROLES "pg_roles " |
Definition at line 116 of file pg_dumpall.c.
#define PGDUMP_VERSIONSTR "pg_dump (PostgreSQL) " PG_VERSION "\n" |
Definition at line 34 of file pg_dumpall.c.
#define SH_DECLARE |
Definition at line 53 of file pg_dumpall.c.
#define SH_DEFINE |
Definition at line 54 of file pg_dumpall.c.
#define SH_ELEMENT_TYPE RoleNameEntry |
Definition at line 44 of file pg_dumpall.c.
Definition at line 50 of file pg_dumpall.c.
#define SH_HASH_KEY | ( | tb, | |
key | |||
) | hash_string(key) |
Definition at line 47 of file pg_dumpall.c.
#define SH_KEY rolename |
Definition at line 46 of file pg_dumpall.c.
#define SH_KEY_TYPE char * |
Definition at line 45 of file pg_dumpall.c.
#define SH_PREFIX rolename |
Definition at line 43 of file pg_dumpall.c.
#define SH_RAW_ALLOCATOR pg_malloc0 |
Definition at line 52 of file pg_dumpall.c.
#define SH_SCOPE static inline |
Definition at line 51 of file pg_dumpall.c.
#define SH_STORE_HASH |
Definition at line 49 of file pg_dumpall.c.
|
static |
Definition at line 1637 of file pg_dumpall.c.
References buildShSecLabelQuery(), conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), emitShSecLabels(), executeQuery(), PQclear(), and res.
Referenced by dumpRoles(), and dumpTablespaces().
|
static |
Definition at line 1663 of file pg_dumpall.c.
References ALWAYS_SECURE_SEARCH_PATH_SQL, conn, CONNECTION_BAD, connection_string, connstr, constructConnStr(), dbname, executeQuery(), exit_nicely, free, i, _PQconninfoOption::keyword, password, pg_fatal, pg_log_error, pg_log_error_detail, 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(), connect_slot(), main(), reindex_one_database(), and vacuum_one_database().
|
static |
Definition at line 1852 of file pg_dumpall.c.
References appendConnStrVal(), appendPQExpBuffer(), appendPQExpBufferChar(), buf, connstr, createPQExpBuffer(), destroyPQExpBuffer(), i, pg_strdup(), and values.
Referenced by connectDatabase().
|
static |
Definition at line 1354 of file pg_dumpall.c.
References conn, dbname, executeQuery(), fmtId(), fprintf, i, if_exists, OPF, PQclear(), PQgetvalue(), PQntuples(), and res.
Referenced by main().
|
static |
Definition at line 703 of file pg_dumpall.c.
References buf, conn, createPQExpBuffer(), destroyPQExpBuffer(), executeQuery(), fmtId(), fprintf, i, if_exists, OPF, PQclear(), PQfnumber(), PQgetvalue(), PQntuples(), printfPQExpBuffer(), res, role_catalog, and server_version.
Referenced by main().
|
static |
Definition at line 1215 of file pg_dumpall.c.
References conn, executeQuery(), fmtId(), fprintf, i, if_exists, OPF, PQclear(), PQgetvalue(), PQntuples(), and res.
Referenced by main().
|
static |
Definition at line 1490 of file pg_dumpall.c.
References conn, database_exclude_names, dbname, executeQuery(), filename, fprintf, i, OPF, output_clean, PG_BINARY_A, pg_fatal, pg_log_info, PQclear(), PQgetvalue(), PQntuples(), res, runPgDump(), and simple_string_list_member().
Referenced by main().
|
static |
Definition at line 1160 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(), res, and server_version.
Referenced by main().
|
static |
Definition at line 958 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_malloc0(), PQclear(), PQfinish(), PQfnumber(), PQgetvalue(), PQntuples(), PQserverVersion(), printfPQExpBuffer(), remaining, res, resetPQExpBuffer(), role_catalog, server_version, set_option, and start.
Referenced by main().
|
static |
Definition at line 750 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(), res, resetPQExpBuffer(), role_catalog, and server_version.
Referenced by main().
|
static |
Definition at line 1250 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(), res, server_version, and skip_acls.
Referenced by main().
|
static |
Definition at line 1930 of file pg_dumpall.c.
References buf, fprintf, now(), OPF, and PGDUMP_STRFTIME_FMT.
Referenced by main().
|
static |
Definition at line 1401 of file pg_dumpall.c.
References appendPQExpBufferChar(), appendStringLiteralConn(), buf, conn, createPQExpBuffer(), destroyPQExpBuffer(), executeQuery(), fprintf, i, makeAlterConfigCommand(), OPF, PQclear(), PQgetvalue(), PQntuples(), printfPQExpBuffer(), res, resetPQExpBuffer(), role_catalog, and username.
Referenced by dumpRoles().
|
static |
Definition at line 1906 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(), PQresultStatus(), and res.
Referenced by appendQualifiedRelation(), connect_slot(), main(), and vacuum_one_database().
Definition at line 1883 of file pg_dumpall.c.
References conn, exit_nicely, pg_log_error, pg_log_error_detail, pg_log_info, PGRES_TUPLES_OK, PQerrorMessage(), PQexec(), PQfinish(), PQresultStatus(), and res.
Referenced by appendQualifiedRelation(), buildShSecLabels(), cluster_all_databases(), compile_database_list(), compile_relation_list_one_db(), connectDatabase(), dropDBs(), dropRoles(), dropTablespaces(), dumpDatabases(), dumpRoleGUCPrivs(), dumpRoleMembership(), dumpRoles(), dumpTablespaces(), dumpUserConfig(), expand_dbname_patterns(), get_parallel_object_list(), main(), reindex_all_databases(), vacuum_all_databases(), and vacuum_one_database().
|
static |
Definition at line 1437 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(), res, resetPQExpBuffer(), and simple_string_list_append().
Referenced by main().
|
static |
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 127 of file pg_dumpall.c.
References appendPQExpBuffer(), appendPQExpBufferStr(), appendShellString(), binary_upgrade, column_inserts, conn, connectDatabase(), connstr, 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_publications, no_role_passwords, no_security_labels, no_subscriptions, no_table_access_method, no_tablespaces, no_toast_compression, 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_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(), 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 1949 of file pg_dumpall.c.
References _, exit(), 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 1583 of file pg_dumpall.c.
References appendConnStrVal(), appendPQExpBuffer(), appendPQExpBufferStr(), appendShellString(), connstr, PQExpBufferData::data, dbname, fflush(), filename, initPQExpBuffer(), pg_dump_bin, pg_log_info, pgdumpopts, printfPQExpBuffer(), and termPQExpBuffer().
Referenced by dumpDatabases().
|
static |
Definition at line 94 of file pg_dumpall.c.
Referenced by dumpRoles(), dumpTablespaces(), and main().
|
static |
Definition at line 95 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 88 of file pg_dumpall.c.
Referenced by appendPsqlMetaConnect(), connectDatabase(), constructConnStr(), dblink_connect(), dblink_connstr_check(), dblink_connstr_has_pw(), dblink_get_conn(), dblink_security_check(), generate_old_dump(), main(), parse_connection_string(), recognized_connection_string(), runPgDump(), and uri_prefix_length().
|
static |
Definition at line 122 of file pg_dumpall.c.
Referenced by dumpDatabases(), and main().
|
static |
Definition at line 121 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().
Definition at line 92 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 119 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_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(), 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(), 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 98 of file pg_dumpall.c.
Referenced by dropDBs(), dropRoles(), dropTablespaces(), and main().
|
static |
Definition at line 99 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 103 of file pg_dumpall.c.
Referenced by dumpRoles(), dumpTablespaces(), and main().
|
static |
Definition at line 104 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 105 of file pg_dumpall.c.
Referenced by dumpRoles(), dumpTablespaces(), and main().
|
static |
Definition at line 106 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 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 112 of file pg_dumpall.c.
Referenced by main().
|
static |
Definition at line 118 of file pg_dumpall.c.
Referenced by dropDBs(), dropRoles(), dropTablespaces(), dumpDatabases(), dumpRoleGUCPrivs(), dumpRoleMembership(), dumpRoles(), dumpTablespaces(), dumpTimestamp(), dumpUserConfig(), and main().
Definition at line 89 of file pg_dumpall.c.
Referenced by dumpDatabases(), and main().
|
static |
Definition at line 85 of file pg_dumpall.c.
Referenced by main(), and runPgDump().
|
static |
Definition at line 87 of file pg_dumpall.c.
Referenced by main(), and runPgDump().
|
static |
Definition at line 86 of file pg_dumpall.c.
Referenced by connectDatabase(), help(), and main().
|
static |
Definition at line 114 of file pg_dumpall.c.
Referenced by dropRoles(), dumpRoleMembership(), dumpRoles(), dumpUserConfig(), and main().
|
static |
Definition at line 110 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().
Definition at line 90 of file pg_dumpall.c.
Referenced by dumpTablespaces(), and main().
|
static |
Definition at line 102 of file pg_dumpall.c.
Referenced by main().
Definition at line 91 of file pg_dumpall.c.
Referenced by main().