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 "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 | |
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 PGresult * | libpqrcv_PQexec (PGconn *streamConn, const char *query) |
static PGresult * | libpqrcv_PQgetResult (PGconn *streamConn) |
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 | |
PG_MODULE_MAGIC | |
static WalReceiverFunctionsType | PQWalReceiverFunctions |
void _PG_init | ( | void | ) |
Definition at line 121 of file libpqwalreceiver.c.
References elog, ERROR, PQWalReceiverFunctions, and WalReceiverFunctions.
|
static |
Definition at line 1124 of file libpqwalreceiver.c.
References appendStringInfo(), appendStringInfoString(), conn, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, initStringInfo(), libpqrcv_PQexec(), pchomp(), pfree(), PGRES_COMMAND_OK, PQclear(), PQerrorMessage(), PQresultStatus(), quote_identifier(), res, and two_phase.
|
static |
Definition at line 317 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 144 of file libpqwalreceiver.c.
References _, ALWAYS_SECURE_SEARCH_PATH_SQL, Assert, conn, CONNECTION_BAD, CONNECTION_OK, CONNECTION_STARTED, ereport, err(), errcode(), errdetail(), errhint(), errmsg(), ERROR, GetDatabaseEncodingName(), i, libpqrcv_check_conninfo(), libpqrcv_PQexec(), MyLatch, palloc0(), pchomp(), pfree(), PGRES_POLLING_FAILED, PGRES_POLLING_OK, PGRES_POLLING_READING, PGRES_POLLING_WRITING, PGRES_TUPLES_OK, PQclear(), PQconnectionUsedPassword(), PQconnectPoll(), PQconnectStartParams(), PQerrorMessage(), PQfinish(), PQresultStatus(), PQsocket(), PQstatus(), ProcessWalRcvInterrupts(), psprintf(), res, ResetLatch(), WaitLatchOrSocket(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_SOCKET_CONNECTED, WL_SOCKET_READABLE, and WL_SOCKET_WRITEABLE.
|
static |
Definition at line 1011 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, initStringInfo(), InvalidOid, libpqrcv_PQexec(), pchomp(), pfree(), pg_lsn_in(), PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQgetisnull(), PQgetvalue(), PQresultStatus(), PQserverVersion(), pstrdup(), res, and two_phase.
|
static |
Definition at line 881 of file libpqwalreceiver.c.
References conn, pfree(), PQfinish(), and PQfreemem().
|
static |
Definition at line 656 of file libpqwalreceiver.c.
References conn, ereport, errcode(), errmsg(), ERROR, libpqrcv_PQgetResult(), pchomp(), pg_strtoint32(), PGRES_COMMAND_OK, PGRES_COPY_OUT, PGRES_TUPLES_OK, PQclear(), PQendcopy(), PQerrorMessage(), PQflush(), PQgetvalue(), PQnfields(), PQntuples(), PQputCopyEnd(), PQresultStatus(), and res.
|
static |
Definition at line 1248 of file libpqwalreceiver.c.
References _, conn, ereport, WalRcvExecResult::err, errcode(), errmsg(), ERROR, InvalidOid, libpqrcv_PQexec(), libpqrcv_processTuples(), 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 |
|
static |
Definition at line 372 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 503 of file libpqwalreceiver.c.
References dbname, ereport, err(), errcode(), errmsg(), ERROR, opts, pfree(), PQconninfoFree(), PQconninfoParse(), PQfreemem(), and pstrdup().
|
static |
Definition at line 421 of file libpqwalreceiver.c.
|
static |
Definition at line 445 of file libpqwalreceiver.c.
References conn, ereport, errcode(), errdetail(), errmsg(), ERROR, libpqrcv_PQexec(), pchomp(), pg_strtoint32(), PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), pstrdup(), and res.
Definition at line 787 of file libpqwalreceiver.c.
References CONNECTION_BAD, libpqrcv_PQgetResult(), PGRES_COPY_BOTH, PGRES_COPY_IN, PGRES_COPY_OUT, PQclear(), PQresultStatus(), PQsendQuery(), and PQstatus().
Referenced by libpqrcv_alter_slot(), libpqrcv_connect(), libpqrcv_create_slot(), libpqrcv_exec(), libpqrcv_identify_system(), libpqrcv_readtimelinehistoryfile(), and libpqrcv_startstreaming().
Definition at line 836 of file libpqwalreceiver.c.
References MyLatch, PQconsumeInput(), PQgetResult(), PQisBusy(), PQsocket(), ProcessWalRcvInterrupts(), ResetLatch(), WaitLatchOrSocket(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, and WL_SOCKET_READABLE.
Referenced by libpqrcv_endstreaming(), libpqrcv_PQexec(), and libpqrcv_receive().
|
static |
Definition at line 1172 of file libpqwalreceiver.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, BuildTupleFromCStrings(), CreateTemplateTupleDesc(), CurrentMemoryContext, ereport, errcode(), errdetail(), errmsg(), ERROR, MaxTupleAttributeNumber, MemoryContextDelete(), MemoryContextReset(), MemoryContextSwitchTo(), PQfname(), PQgetisnull(), PQgetvalue(), PQnfields(), PQntuples(), ProcessWalRcvInterrupts(), WalRcvExecResult::tupledesc, TupleDescGetAttInMetadata(), TupleDescInitEntry(), WalRcvExecResult::tuplestore, tuplestore_begin_heap(), tuplestore_puttuple(), and work_mem.
Referenced by libpqrcv_exec().
|
static |
Definition at line 733 of file libpqwalreceiver.c.
References Assert, conn, ereport, errcode(), errdetail(), errmsg(), ERROR, filename, len, libpqrcv_PQexec(), palloc(), pchomp(), PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQgetlength(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), pstrdup(), res, and snprintf.
|
static |
Definition at line 905 of file libpqwalreceiver.c.
References conn, CONNECTION_BAD, ereport, errcode(), errmsg(), ERROR, libpqrcv_PQgetResult(), pchomp(), PGRES_COMMAND_OK, PGRES_COPY_IN, PQclear(), PQconsumeInput(), PQerrorMessage(), PQfreemem(), PQgetCopyData(), PQresultStatus(), PQsocket(), PQstatus(), and res.
|
static |
Definition at line 995 of file libpqwalreceiver.c.
References conn, ereport, errcode(), errmsg(), ERROR, pchomp(), PQerrorMessage(), PQflush(), and PQputCopyData().
|
static |
Definition at line 492 of file libpqwalreceiver.c.
References conn, and PQserverVersion().
|
static |
Definition at line 552 of file libpqwalreceiver.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert, conn, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, initStringInfo(), libpqrcv_PQexec(), LSN_FORMAT_ARGS, pchomp(), pfree(), PGRES_COMMAND_OK, PGRES_COPY_BOTH, PQclear(), PQerrorMessage(), PQescapeLiteral(), PQfreemem(), PQresultStatus(), PQserverVersion(), res, and stringlist_to_identifierstr().
Definition at line 1328 of file libpqwalreceiver.c.
References appendStringInfoChar(), appendStringInfoString(), conn, free, initStringInfo(), lfirst, PQescapeIdentifier(), PQfreemem(), res, strVal, and val.
Referenced by libpqrcv_startstreaming().
PG_MODULE_MAGIC |
Definition at line 39 of file libpqwalreceiver.c.
|
static |
Definition at line 92 of file libpqwalreceiver.c.
Referenced by _PG_init().