PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <unistd.h>
#include <ctype.h>
#include "common/connect.h"
#include "common/string.h"
#include "parallel.h"
#include "pg_backup_archiver.h"
#include "pg_backup_db.h"
#include "pg_backup_utils.h"
Go to the source code of this file.
Functions | |
static void | _check_database_version (ArchiveHandle *AH) |
static void | notice_processor (void *arg, const char *message) |
void | ReconnectToServer (ArchiveHandle *AH, const char *dbname) |
void | ConnectDatabase (Archive *AHX, const ConnParams *cparams, bool isReconnect) |
void | DisconnectDatabase (Archive *AHX) |
PGconn * | GetConnection (Archive *AHX) |
static void | die_on_query_failure (ArchiveHandle *AH, const char *query) |
void | ExecuteSqlStatement (Archive *AHX, const char *query) |
PGresult * | ExecuteSqlQuery (Archive *AHX, const char *query, ExecStatusType status) |
PGresult * | ExecuteSqlQueryForSingleRow (Archive *fout, const char *query) |
static void | ExecuteSqlCommand (ArchiveHandle *AH, const char *qry, const char *desc) |
static void | ExecuteSimpleCommands (ArchiveHandle *AH, const char *buf, size_t bufLen) |
int | ExecuteSqlCommandBuf (Archive *AHX, const char *buf, size_t bufLen) |
void | EndDBCopyMode (Archive *AHX, const char *tocEntryTag) |
void | StartTransaction (Archive *AHX) |
void | CommitTransaction (Archive *AHX) |
void | IssueCommandPerBlob (ArchiveHandle *AH, TocEntry *te, const char *cmdBegin, const char *cmdEnd) |
void | IssueACLPerBlob (ArchiveHandle *AH, TocEntry *te) |
void | DropLOIfExists (ArchiveHandle *AH, Oid oid) |
|
static |
Definition at line 31 of file pg_backup_db.c.
References _archiveHandle::archiveRemoteVersion, _archiveHandle::connection, ExecuteSqlQueryForSingleRow(), exit(), Archive::isStandby, Archive::maxRemoteVersion, pg_fatal, pg_log_error, pg_log_error_detail, pg_strdup(), PQclear(), PQgetvalue(), PQparameterStatus(), PQserverVersion(), progname, _archiveHandle::public, Archive::remoteVersion, Archive::remoteVersionStr, and res.
Referenced by ConnectDatabase().
void CommitTransaction | ( | Archive * | AHX | ) |
Definition at line 535 of file pg_backup_db.c.
References ExecuteSqlCommand().
Referenced by IssueCommandPerBlob().
void ConnectDatabase | ( | Archive * | AHX, |
const ConnParams * | cparams, | ||
bool | isReconnect | ||
) |
Definition at line 108 of file pg_backup_db.c.
References _check_database_version(), ALWAYS_SECURE_SEARCH_PATH_SQL, Assert, _archiveHandle::connection, CONNECTION_BAD, _connParams::dbname, ExecuteSqlQueryForSingleRow(), free, i, lengthof, notice_processor(), _connParams::override_dbname, password, pg_fatal, pg_strdup(), _connParams::pghost, _connParams::pgport, PQclear(), PQconnectdbParams(), PQconnectionNeedsPassword(), PQconnectionUsedPassword(), PQerrorMessage(), PQfinish(), PQpass(), PQsetNoticeProcessor(), PQstatus(), progname, _connParams::promptPassword, _archiveHandle::savedPassword, set_archive_cancel_info(), simple_prompt(), TRI_NO, TRI_YES, _connParams::username, and values.
Referenced by CloneArchive(), main(), ReconnectToServer(), restore_toc_entries_postfork(), and RestoreArchive().
|
static |
Definition at line 267 of file pg_backup_db.c.
References _archiveHandle::connection, exit(), pg_log_error, pg_log_error_detail, and PQerrorMessage().
Referenced by ExecuteSqlQuery(), and ExecuteSqlStatement().
void DisconnectDatabase | ( | Archive * | AHX | ) |
Definition at line 223 of file pg_backup_db.c.
References _archiveHandle::connCancel, _archiveHandle::connection, PQcancel(), PQfinish(), PQTRANS_ACTIVE, PQtransactionStatus(), and set_archive_cancel_info().
Referenced by archive_close_connection(), restore_toc_entries_prefork(), RestoreArchive(), and RunWorker().
void DropLOIfExists | ( | ArchiveHandle * | AH, |
Oid | oid | ||
) |
Definition at line 671 of file pg_backup_db.c.
References ahprintf().
Referenced by _StartLO(), RestoreArchive(), and StartRestoreLO().
void EndDBCopyMode | ( | Archive * | AHX, |
const char * | tocEntryTag | ||
) |
Definition at line 498 of file pg_backup_db.c.
References _archiveHandle::connection, pg_fatal, pg_log_warning, _archiveHandle::pgCopyIn, PGRES_COMMAND_OK, PQclear(), PQerrorMessage(), PQgetResult(), PQputCopyEnd(), PQresultStatus(), res, and warn_or_exit_horribly().
Referenced by restore_toc_entry().
|
static |
Definition at line 378 of file pg_backup_db.c.
References appendPQExpBufferChar(), sqlparseInfo::backSlash, buf, createPQExpBuffer(), sqlparseInfo::curCmd, PQExpBufferData::data, ExecuteSqlCommand(), PQExpBufferData::len, _archiveHandle::public, resetPQExpBuffer(), SQL_IN_DOUBLE_QUOTE, SQL_IN_SINGLE_QUOTE, SQL_SCAN, _archiveHandle::sqlparse, sqlparseInfo::state, and Archive::std_strings.
Referenced by ExecuteSqlCommandBuf().
|
static |
Definition at line 326 of file pg_backup_db.c.
References conn, _archiveHandle::connection, fprintf, _archiveHandle::pgCopyIn, PGRES_COMMAND_OK, PGRES_COPY_IN, PGRES_EMPTY_QUERY, PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQresultStatus(), res, and warn_or_exit_horribly().
Referenced by CommitTransaction(), ExecuteSimpleCommands(), ExecuteSqlCommandBuf(), and StartTransaction().
int ExecuteSqlCommandBuf | ( | Archive * | AHX, |
const char * | buf, | ||
size_t | bufLen | ||
) |
Definition at line 443 of file pg_backup_db.c.
References buf, _archiveHandle::connection, ExecuteSimpleCommands(), ExecuteSqlCommand(), free, OUTPUT_COPYDATA, OUTPUT_OTHERDATA, _archiveHandle::outputKind, pg_fatal, pg_malloc(), _archiveHandle::pgCopyIn, PQerrorMessage(), PQputCopyData(), and str.
Referenced by ahwrite().
PGresult* ExecuteSqlQuery | ( | Archive * | AHX, |
const char * | query, | ||
ExecStatusType | status | ||
) |
Definition at line 288 of file pg_backup_db.c.
References _archiveHandle::connection, die_on_query_failure(), PQexec(), PQresultStatus(), and res.
Referenced by append_depends_on_extension(), buildMatViewRefreshDependencies(), collectBinaryUpgradeClassOids(), collectComments(), collectRoleNames(), collectSecLabels(), collectSequences(), createViewAsClause(), dumpCompositeType(), dumpDatabase(), dumpDatabaseConfig(), dumpEnumType(), dumpOpclass(), dumpOpfamily(), dumpRule(), dumpSequence(), dumpSequenceData(), dumpTable(), dumpTableData_copy(), dumpTableData_insert(), dumpTSConfig(), dumpUserMappings(), ExecuteSqlQueryForSingleRow(), expand_extension_name_patterns(), expand_foreign_server_name_patterns(), expand_schema_name_patterns(), expand_table_name_patterns(), getAccessMethods(), getAdditionalACLs(), getAggregates(), getCasts(), getCollations(), getConstraints(), getConversions(), getDefaultACLs(), getDependencies(), getDomainConstraints(), getEventTriggers(), getExtendedStatistics(), getExtensionMembership(), getExtensions(), getForeignDataWrappers(), getForeignServers(), getFuncs(), getIndexes(), getInherits(), getLOs(), getNamespaces(), getOpclasses(), getOperators(), getOpfamilies(), getPartitioningInfo(), getPolicies(), getProcLangs(), getPublicationNamespaces(), getPublications(), getPublicationTables(), getRules(), getSubscriptions(), getSubscriptionTables(), getTableAttrs(), getTables(), getTransforms(), getTriggers(), getTSConfigurations(), getTSDictionaries(), getTSParsers(), getTSTemplates(), getTypes(), processExtensionTables(), and set_restrict_relation_kind().
Definition at line 303 of file pg_backup_db.c.
References ExecuteSqlQuery(), ngettext, pg_fatal, PGRES_TUPLES_OK, PQntuples(), and res.
Referenced by _check_database_version(), binary_upgrade_set_type_oids_by_type_oid(), ConnectDatabase(), convertTSFunction(), dumpAgg(), dumpBaseType(), dumpCollation(), dumpConversion(), dumpDatabase(), dumpDomain(), dumpForeignServer(), dumpFunc(), dumpOpclass(), dumpOpfamily(), dumpOpr(), dumpRangeType(), dumpSearchPath(), dumpStatisticsExt(), dumpTableAttach(), dumpTableSchema(), dumpTSConfig(), dumpTSDictionary(), expand_table_name_patterns(), get_language_name(), get_next_possible_free_pg_type_oid(), get_synchronized_snapshot(), getFormattedTypeName(), and setup_connection().
void ExecuteSqlStatement | ( | Archive * | AHX, |
const char * | query | ||
) |
Definition at line 276 of file pg_backup_db.c.
References _archiveHandle::connection, die_on_query_failure(), PGRES_COMMAND_OK, PQclear(), PQexec(), PQresultStatus(), and res.
Referenced by dumpAgg(), dumpBaseType(), dumpCompositeType(), dumpDomain(), dumpEnumType(), dumpFunc(), dumpOpr(), dumpRangeType(), dumpTable(), dumpTableAttach(), dumpTableData_insert(), expand_table_name_patterns(), getDomainConstraints(), getTables(), and setup_connection().
Definition at line 252 of file pg_backup_db.c.
References _archiveHandle::connection.
void IssueACLPerBlob | ( | ArchiveHandle * | AH, |
TocEntry * | te | ||
) |
Definition at line 597 of file pg_backup_db.c.
References Assert, buf, _tocEntry::defn, _tocEntry::dependencies, _tocEntry::desc, getTocEntryByDumpId(), IssueCommandPerBlob(), pg_fatal, pg_free(), and pg_strdup().
Referenced by _printTocEntry().
void IssueCommandPerBlob | ( | ArchiveHandle * | AH, |
TocEntry * | te, | ||
const char * | cmdBegin, | ||
const char * | cmdEnd | ||
) |
Definition at line 550 of file pg_backup_db.c.
References ahprintf(), buf, CommitTransaction(), _archiveHandle::connection, _tocEntry::defn, pg_free(), pg_strdup(), _archiveHandle::public, Archive::ropt, StartTransaction(), _restoreOptions::txn_size, and _archiveHandle::txnCount.
Referenced by _printTocEntry(), IssueACLPerBlob(), and RestoreArchive().
|
static |
Definition at line 260 of file pg_backup_db.c.
References pg_log_info.
Referenced by ConnectDatabase().
void ReconnectToServer | ( | ArchiveHandle * | AH, |
const char * | dbname | ||
) |
Definition at line 72 of file pg_backup_db.c.
References ConnectDatabase(), _archiveHandle::connection, _restoreOptions::cparams, dbname, _connParams::override_dbname, pg_strdup(), PQfinish(), _archiveHandle::public, and Archive::ropt.
Referenced by _reconnectToDB().
void StartTransaction | ( | Archive * | AHX | ) |
Definition at line 527 of file pg_backup_db.c.
References ExecuteSqlCommand().
Referenced by IssueCommandPerBlob().