PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <sys/time.h>
#include <unistd.h>
#include "access/xlog_internal.h"
#include "common/connect.h"
#include "common/fe_memutils.h"
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
#include "datatype/timestamp.h"
#include "port/pg_bswap.h"
#include "pqexpbuffer.h"
#include "receivelog.h"
#include "streamutil.h"
Go to the source code of this file.
Macros | |
#define | ERRCODE_DUPLICATE_OBJECT "42710" |
#define | MINIMUM_VERSION_FOR_SHOW_CMD 100000 |
#define | MINIMUM_VERSION_FOR_GROUP_ACCESS 110000 |
Functions | |
static bool | RetrieveDataDirCreatePerm (PGconn *conn) |
PGconn * | GetConnection (void) |
bool | RetrieveWalSegSize (PGconn *conn) |
bool | RunIdentifySystem (PGconn *conn, char **sysid, TimeLineID *starttli, XLogRecPtr *startpos, char **db_name) |
bool | CreateReplicationSlot (PGconn *conn, const char *slot_name, const char *plugin, bool is_temporary, bool is_physical, bool reserve_wal, bool slot_exists_ok) |
bool | DropReplicationSlot (PGconn *conn, const char *slot_name) |
TimestampTz | feGetCurrentTimestamp (void) |
void | feTimestampDifference (TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs) |
bool | feTimestampDifferenceExceeds (TimestampTz start_time, TimestampTz stop_time, int msec) |
void | fe_sendint64 (int64 i, char *buf) |
int64 | fe_recvint64 (char *buf) |
Variables | |
uint32 | WalSegSz |
const char * | progname |
char * | connection_string = NULL |
char * | dbhost = NULL |
char * | dbuser = NULL |
char * | dbport = NULL |
char * | dbname = NULL |
int | dbgetpassword = 0 |
static char * | password = NULL |
PGconn * | conn = NULL |
#define ERRCODE_DUPLICATE_OBJECT "42710" |
Definition at line 32 of file streamutil.c.
Referenced by AddEnumLabel(), AddRelationNewConstraints(), AlterTypeNamespaceInternal(), ATExecAddConstraint(), CastCreate(), CollationCreate(), ConversionCreate(), CreateAccessMethod(), CreateEventTrigger(), CreateExtension(), CreateForeignDataWrapper(), CreateForeignServer(), createNewConnection(), CreateOpFamily(), CreatePolicy(), CreateProceduralLanguage(), CreatePublication(), CreateReplicationSlot(), CreateRole(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTrigger(), CreateUserMapping(), DefineCompositeType(), DefineDomain(), DefineEnum(), DefineOpClass(), DefineRange(), DefineType(), domainAddConstraint(), GetDefaultOpClass(), heap_create_with_catalog(), index_create(), InsertRule(), IsThereCollationInNamespace(), IsThereOpClassInNamespace(), IsThereOpFamilyInNamespace(), makeArrayTypeName(), makeMultirangeTypeName(), MarkAsPreparing(), MergeCheckConstraint(), MergeWithExistingConstraint(), publication_add_relation(), RegisterExtensibleNodeEntry(), rename_policy(), RenameConstraintById(), RenameEnumLabel(), RenameRewriteRule(), RenameRole(), RenameTableSpace(), renametrig(), RenameTypeInternal(), ReplicationSlotCreate(), report_name_conflict(), report_namespace_conflict(), storeOperators(), storeProcedures(), transformGenericOptions(), and TypeCreate().
#define MINIMUM_VERSION_FOR_GROUP_ACCESS 110000 |
Definition at line 44 of file streamutil.c.
Referenced by RetrieveDataDirCreatePerm().
#define MINIMUM_VERSION_FOR_SHOW_CMD 100000 |
Definition at line 39 of file streamutil.c.
Referenced by RetrieveWalSegSize().
bool CreateReplicationSlot | ( | PGconn * | conn, |
const char * | slot_name, | ||
const char * | plugin, | ||
bool | is_temporary, | ||
bool | is_physical, | ||
bool | reserve_wal, | ||
bool | slot_exists_ok | ||
) |
Definition at line 487 of file streamutil.c.
References appendPQExpBuffer(), appendPQExpBufferStr(), Assert, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), ERRCODE_DUPLICATE_OBJECT, PG_DIAG_SQLSTATE, pg_log_error, PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQnfields(), PQntuples(), PQresultErrorField(), PQresultStatus(), and PQserverVersion().
Definition at line 563 of file streamutil.c.
References appendPQExpBuffer(), Assert, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), pg_log_error, PGRES_COMMAND_OK, PQclear(), PQerrorMessage(), PQexec(), PQnfields(), PQntuples(), and PQresultStatus().
int64 fe_recvint64 | ( | char * | buf | ) |
Definition at line 673 of file streamutil.c.
References pg_ntoh64.
Referenced by ProcessXLogDataMsg(), and StreamLogicalLog().
void fe_sendint64 | ( | int64 | i, |
char * | buf | ||
) |
TimestampTz feGetCurrentTimestamp | ( | void | ) |
Definition at line 608 of file streamutil.c.
References gettimeofday(), POSTGRES_EPOCH_JDATE, SECS_PER_DAY, UNIX_EPOCH_JDATE, and USECS_PER_SEC.
Referenced by flushAndSendFeedback(), HandleCopyStream(), ProcessKeepaliveMsg(), and StreamLogicalLog().
void feTimestampDifference | ( | TimestampTz | start_time, |
TimestampTz | stop_time, | ||
long * | secs, | ||
int * | microsecs | ||
) |
Definition at line 627 of file streamutil.c.
References start_time, and USECS_PER_SEC.
Referenced by CalculateCopyStreamSleeptime(), and StreamLogicalLog().
bool feTimestampDifferenceExceeds | ( | TimestampTz | start_time, |
TimestampTz | stop_time, | ||
int | msec | ||
) |
Definition at line 649 of file streamutil.c.
References start_time.
Referenced by HandleCopyStream(), and StreamLogicalLog().
PGconn* GetConnection | ( | void | ) |
Definition at line 62 of file streamutil.c.
References ALWAYS_SECURE_SEARCH_PATH_SQL, Assert, CONNECTION_BAD, CONNECTION_OK, connection_string, dbgetpassword, dbhost, dbname, dbport, dbuser, free, i, _PQconninfoOption::keyword, password, pg_log_error, pg_malloc0(), PGRES_TUPLES_OK, PQclear(), PQconnectdbParams(), PQconnectionNeedsPassword(), PQconninfoFree(), PQconninfoParse(), PQerrorMessage(), PQexec(), PQfinish(), PQparameterStatus(), PQresultStatus(), PQserverVersion(), PQstatus(), progname, RetrieveDataDirCreatePerm(), simple_prompt(), _PQconninfoOption::val, and values.
Definition at line 355 of file streamutil.c.
References Assert, data_directory_mode, MINIMUM_VERSION_FOR_GROUP_ACCESS, pg_log_error, PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), PQserverVersion(), and SetDataDirectoryCreatePerm().
Referenced by GetConnection().
Definition at line 277 of file streamutil.c.
References Assert, DEFAULT_XLOG_SEG_SIZE, IsValidWalSegSize, MINIMUM_VERSION_FOR_SHOW_CMD, ngettext, pg_log_error, PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), PQserverVersion(), and WalSegSz.
Referenced by main().
bool RunIdentifySystem | ( | PGconn * | conn, |
char ** | sysid, | ||
TimeLineID * | starttli, | ||
XLogRecPtr * | startpos, | ||
char ** | db_name | ||
) |
Definition at line 409 of file streamutil.c.
References Assert, pg_log_error, pg_strdup(), PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQgetisnull(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), and PQserverVersion().
Referenced by BaseBackup(), main(), and StreamLog().
PGconn* conn = NULL |
Definition at line 54 of file streamutil.c.
Referenced by BaseBackup(), build_client_final_message(), build_client_first_message(), check_for_data_type_usage(), check_for_isn_and_int8_passing_mismatch(), check_for_jsonb_9_4_usage(), check_for_pg_role_prefix(), check_for_prepared_transactions(), check_for_reg_data_type_usage(), check_for_tables_with_oids(), check_for_user_defined_postfix_ops(), check_is_install_user(), check_loadable_libraries(), cluster_all_databases(), cluster_one_database(), connectDatabase(), connectMaintenanceDatabase(), connectToServer(), disconnect_atexit(), doConnect(), dumpBlobs(), dumpDatabase(), dumpDatabaseConfig(), dumpTableData_copy(), ExecuteSqlCommand(), freePGconn(), get_db_conn(), get_db_infos(), get_loadable_libraries(), get_rel_infos(), get_tablespace_paths(), init_libpq_source(), init_slot(), libpq_fetch_file(), libpq_get_current_wal_insert_lsn(), libpq_traverse_files(), libpqrcv_connect(), main(), makeEmptyPGconn(), new_9_0_populate_pg_largeobject_metadata(), old_9_6_invalidate_hash_indexes(), ParallelSlotsTerminate(), pg_fe_scram_exchange(), pg_fe_scram_init(), pgtls_write(), PQconnectdb(), PQconnectdbParams(), PQconnectStart(), PQconnectStartParams(), PQfireResultCreateEvents(), PQgetResult(), PQping(), PQpingParams(), PQregisterEventProc(), PQreset(), PQresetPoll(), PQsetdbLogin(), read_server_final_message(), read_server_first_message(), reindex_all_databases(), reindex_one_database(), run_permutation(), set_frozenxids(), setKeepalivesCount(), setup_connection(), sql_conn(), start_postmaster(), StartLogStreamer(), StreamLog(), StreamLogicalLog(), try_complete_step(), vacuum_all_databases(), vacuum_one_database(), and vacuumlo().
char* connection_string = NULL |
Definition at line 47 of file streamutil.c.
Referenced by GetConnection(), and main().
int dbgetpassword = 0 |
Definition at line 52 of file streamutil.c.
Referenced by GetConnection(), and main().
char* dbhost = NULL |
Definition at line 48 of file streamutil.c.
Referenced by GetConnection(), and main().
char* dbname = NULL |
Definition at line 51 of file streamutil.c.
Referenced by _copyAlterDatabaseSetStmt(), _copyAlterDatabaseStmt(), _copyCreatedbStmt(), _copyDropdbStmt(), _equalAlterDatabaseSetStmt(), _equalAlterDatabaseStmt(), _equalCreatedbStmt(), _equalDropdbStmt(), AutoVacWorkerMain(), cluster_all_databases(), connectDatabase(), conninfo_uri_parse_options(), convert_database_name(), createdb(), do_connect(), dropDBs(), dumpDatabaseConfig(), dumpDatabases(), ECPGconnect(), GetConnection(), IdentifySystem(), InitPostgres(), log_line_prefix(), main(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), objectNamesToOids(), and reindex_all_databases().
char* dbport = NULL |
Definition at line 50 of file streamutil.c.
Referenced by GetConnection(), and main().
char* dbuser = NULL |
Definition at line 49 of file streamutil.c.
Referenced by GetConnection(), and main().
|
static |
Definition at line 53 of file streamutil.c.
Referenced by AlterRole(), auth_peer(), check_password(), connectDatabase(), ConnectDatabase(), conninfo_uri_parse_options(), CreateRole(), do_connect(), doConnect(), GetConnection(), main(), pg_fe_sendauth(), pg_password_sendauth(), pg_SASL_init(), PQconnectionNeedsPassword(), PQpass(), sql_conn(), and vacuumlo().
const char* progname |
Definition at line 46 of file streamutil.c.
Referenced by GetConnection().
uint32 WalSegSz |
Definition at line 34 of file streamutil.c.
Referenced by RetrieveWalSegSize().