PostgreSQL Source Code git master
|
#include "postgres.h"
#include <unistd.h>
#include <sys/time.h>
#include "common/connect.h"
#include "funcapi.h"
#include "libpq-fe.h"
#include "libpq/libpq-be-fe-helpers.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "pqexpbuffer.h"
#include "replication/walreceiver.h"
#include "storage/latch.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/pg_lsn.h"
#include "utils/tuplestore.h"
Go to the source code of this file.
Data Structures | |
struct | WalReceiverConn |
Functions | |
PG_MODULE_MAGIC_EXT (.name="libpqwalreceiver",.version=PG_VERSION) | |
static WalReceiverConn * | libpqrcv_connect (const char *conninfo, bool replication, bool logical, bool must_use_password, const char *appname, char **err) |
static void | libpqrcv_check_conninfo (const char *conninfo, bool must_use_password) |
static char * | libpqrcv_get_conninfo (WalReceiverConn *conn) |
static void | libpqrcv_get_senderinfo (WalReceiverConn *conn, char **sender_host, int *sender_port) |
static char * | libpqrcv_identify_system (WalReceiverConn *conn, TimeLineID *primary_tli) |
static char * | libpqrcv_get_dbname_from_conninfo (const char *connInfo) |
static int | libpqrcv_server_version (WalReceiverConn *conn) |
static void | libpqrcv_readtimelinehistoryfile (WalReceiverConn *conn, TimeLineID tli, char **filename, char **content, int *len) |
static bool | libpqrcv_startstreaming (WalReceiverConn *conn, const WalRcvStreamOptions *options) |
static void | libpqrcv_endstreaming (WalReceiverConn *conn, TimeLineID *next_tli) |
static int | libpqrcv_receive (WalReceiverConn *conn, char **buffer, pgsocket *wait_fd) |
static void | libpqrcv_send (WalReceiverConn *conn, const char *buffer, int nbytes) |
static char * | libpqrcv_create_slot (WalReceiverConn *conn, const char *slotname, bool temporary, bool two_phase, bool failover, CRSSnapshotAction snapshot_action, XLogRecPtr *lsn) |
static void | libpqrcv_alter_slot (WalReceiverConn *conn, const char *slotname, const bool *failover, const bool *two_phase) |
static pid_t | libpqrcv_get_backend_pid (WalReceiverConn *conn) |
static WalRcvExecResult * | libpqrcv_exec (WalReceiverConn *conn, const char *query, const int nRetTypes, const Oid *retTypes) |
static void | libpqrcv_disconnect (WalReceiverConn *conn) |
static char * | stringlist_to_identifierstr (PGconn *conn, List *strings) |
void | _PG_init (void) |
static void | libpqrcv_processTuples (PGresult *pgres, WalRcvExecResult *walres, const int nRetTypes, const Oid *retTypes) |
Variables | |
static WalReceiverFunctionsType | PQWalReceiverFunctions |
void _PG_init | ( | void | ) |
Definition at line 123 of file libpqwalreceiver.c.
References elog, ERROR, PQWalReceiverFunctions, and WalReceiverFunctions.
|
static |
Definition at line 1000 of file libpqwalreceiver.c.
References appendStringInfo(), appendStringInfoString(), conn, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, failover, initStringInfo(), libpqsrv_exec(), pchomp(), pfree(), PGRES_COMMAND_OK, PQclear(), PQerrorMessage(), PQresultStatus(), quote_identifier(), and two_phase.
|
static |
Definition at line 280 of file libpqwalreceiver.c.
References ereport, err(), errcode(), errdetail(), errmsg(), ERROR, _PQconninfoOption::keyword, opts, PQconninfoFree(), PQconninfoParse(), PQfreemem(), pstrdup(), and _PQconninfoOption::val.
Referenced by libpqrcv_connect().
|
static |
Definition at line 146 of file libpqwalreceiver.c.
References _, ALWAYS_SECURE_SEARCH_PATH_SQL, Assert(), conn, CONNECTION_OK, ereport, err(), errcode(), errdetail(), errhint(), errmsg(), ERROR, GetDatabaseEncodingName(), i, lengthof, libpqrcv_check_conninfo(), libpqsrv_connect_params(), libpqsrv_disconnect(), libpqsrv_exec(), palloc0(), pchomp(), pfree(), PGRES_TUPLES_OK, PQclear(), PQconnectionUsedPassword(), PQerrorMessage(), PQresultStatus(), PQstatus(), and psprintf().
|
static |
Definition at line 885 of file libpqwalreceiver.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), conn, CRS_EXPORT_SNAPSHOT, CRS_NOEXPORT_SNAPSHOT, CRS_USE_SNAPSHOT, CStringGetDatum(), StringInfoData::data, DatumGetLSN(), DirectFunctionCall1Coll(), ereport, errcode(), errmsg(), ERROR, failover, initStringInfo(), InvalidOid, libpqsrv_exec(), pchomp(), pfree(), pg_lsn_in(), PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQgetisnull(), PQgetvalue(), PQresultStatus(), PQserverVersion(), pstrdup(), and two_phase.
|
static |
Definition at line 753 of file libpqwalreceiver.c.
References conn, libpqsrv_disconnect(), pfree(), and PQfreemem().
|
static |
Definition at line 623 of file libpqwalreceiver.c.
References conn, ereport, errcode(), errmsg(), ERROR, libpqsrv_get_result(), pchomp(), pg_strtoint32(), PGRES_COMMAND_OK, PGRES_COPY_OUT, PGRES_TUPLES_OK, PQclear(), PQendcopy(), PQerrorMessage(), PQflush(), PQgetvalue(), PQnfields(), PQntuples(), PQputCopyEnd(), and PQresultStatus().
|
static |
Definition at line 1125 of file libpqwalreceiver.c.
References _, conn, ereport, WalRcvExecResult::err, errcode(), errmsg(), ERROR, InvalidOid, libpqrcv_processTuples(), libpqsrv_exec(), MAKE_SQLSTATE, MyDatabaseId, palloc0(), pchomp(), PG_DIAG_SQLSTATE, PGRES_BAD_RESPONSE, PGRES_COMMAND_OK, PGRES_COPY_BOTH, PGRES_COPY_IN, PGRES_COPY_OUT, PGRES_EMPTY_QUERY, PGRES_FATAL_ERROR, PGRES_NONFATAL_ERROR, PGRES_PIPELINE_ABORTED, PGRES_PIPELINE_SYNC, PGRES_SINGLE_TUPLE, PGRES_TUPLES_CHUNK, PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQresultErrorField(), PQresultStatus(), WalRcvExecResult::sqlstate, WalRcvExecResult::status, WALRCV_ERROR, WALRCV_OK_COMMAND, WALRCV_OK_COPY_BOTH, WALRCV_OK_COPY_IN, WALRCV_OK_COPY_OUT, and WALRCV_OK_TUPLES.
|
static |
Definition at line 1040 of file libpqwalreceiver.c.
References conn, and PQbackendPID().
|
static |
Definition at line 335 of file libpqwalreceiver.c.
References _, appendPQExpBuffer(), Assert(), buf, conn, _PQconninfoOption::dispchar, ereport, errcode(), errmsg(), ERROR, initPQExpBuffer(), _PQconninfoOption::keyword, PQconninfo(), PQconninfoFree(), PQExpBufferDataBroken, pstrdup(), termPQExpBuffer(), and _PQconninfoOption::val.
|
static |
Definition at line 468 of file libpqwalreceiver.c.
References dbname, ereport, err(), errcode(), errmsg(), ERROR, opts, pfree(), PQconninfoFree(), PQconninfoParse(), PQfreemem(), and pstrdup().
|
static |
Definition at line 384 of file libpqwalreceiver.c.
References Assert(), conn, PQhost(), PQport(), and pstrdup().
|
static |
Definition at line 408 of file libpqwalreceiver.c.
References conn, ereport, errcode(), errdetail(), errmsg(), ERROR, libpqsrv_exec(), pchomp(), pg_strtoint32(), PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), and pstrdup().
|
static |
Definition at line 1049 of file libpqwalreceiver.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, BuildTupleFromCStrings(), CHECK_FOR_INTERRUPTS, CreateTemplateTupleDesc(), CurrentMemoryContext, ereport, errcode(), errdetail(), errmsg(), ERROR, MaxTupleAttributeNumber, MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), PQfname(), PQgetisnull(), PQgetvalue(), PQnfields(), PQntuples(), WalRcvExecResult::tupledesc, TupleDescGetAttInMetadata(), TupleDescInitEntry(), WalRcvExecResult::tuplestore, tuplestore_begin_heap(), tuplestore_puttuple(), and work_mem.
Referenced by libpqrcv_exec().
|
static |
Definition at line 704 of file libpqwalreceiver.c.
References Assert(), conn, ereport, errcode(), errdetail(), errmsg(), ERROR, filename, len, libpqsrv_exec(), palloc(), pchomp(), PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQgetlength(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), pstrdup(), and snprintf.
|
static |
Definition at line 777 of file libpqwalreceiver.c.
References conn, CONNECTION_BAD, ereport, errcode(), errmsg(), ERROR, libpqsrv_get_result(), pchomp(), PGRES_COMMAND_OK, PGRES_COPY_IN, PQclear(), PQconsumeInput(), PQerrorMessage(), PQfreemem(), PQgetCopyData(), PQresultStatus(), PQsocket(), and PQstatus().
|
static |
Definition at line 869 of file libpqwalreceiver.c.
References conn, ereport, errcode(), errmsg(), ERROR, pchomp(), PQerrorMessage(), PQflush(), and PQputCopyData().
|
static |
Definition at line 457 of file libpqwalreceiver.c.
References conn, and PQserverVersion().
|
static |
Definition at line 517 of file libpqwalreceiver.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert(), conn, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, initStringInfo(), libpqsrv_exec(), LSN_FORMAT_ARGS, pchomp(), pfree(), PGRES_COMMAND_OK, PGRES_COPY_BOTH, PQclear(), PQerrorMessage(), PQescapeLiteral(), PQfreemem(), PQresultStatus(), PQserverVersion(), and stringlist_to_identifierstr().
PG_MODULE_MAGIC_EXT | ( | . | name = "libpqwalreceiver" , |
. | version = PG_VERSION |
||
) |
Definition at line 1207 of file libpqwalreceiver.c.
References appendStringInfoChar(), appendStringInfoString(), conn, StringInfoData::data, free, initStringInfo(), lfirst, PQescapeIdentifier(), PQfreemem(), strVal, and val.
Referenced by libpqrcv_startstreaming().
|
static |
Definition at line 96 of file libpqwalreceiver.c.
Referenced by _PG_init().