82 elog(
ERROR,
"too much output for sql interface");
86 memset(nulls, 0,
sizeof(nulls));
112 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
113 (
errmsg(
"must be superuser or replication role to use replication slots"))));
121 targetRecPtr, cur_page, pageTLI);
151 (
errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
152 errmsg(
"slot name must not be null")));
167 (
errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
168 errmsg(
"options array must not be null")));
174 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
175 errmsg(
"set-valued function called in context that cannot accept a set")));
178 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
179 errmsg(
"materialize mode required, but it is not allowed in this context")));
184 p->binary_output = binary;
188 elog(
ERROR,
"return type must be a row type");
198 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
199 errmsg(
"array must be one-dimensional")));
204 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
205 errmsg(
"array must not contain nulls")));
216 &datum_opts,
NULL, &nelems);
220 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
221 errmsg(
"array must have even number of elements")));
223 for (i = 0; i < nelems; i += 2)
263 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
264 errmsg(
"logical decoding output plugin \"%s\" produces binary output, but function \"%s\" expects textual data",
268 ctx->output_writer_private = p;
283 (ctx->reader->EndRecPtr !=
InvalidXLogRecPtr && ctx->reader->EndRecPtr < end_of_wal))
307 upto_lsn <= ctx->reader->EndRecPtr)
309 if (upto_nchanges != 0 &&
310 upto_nchanges <= p->returned_rows)
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, Datum *values, bool *isnull)
Value * makeString(char *str)
#define PG_GETARG_INT32(n)
#define InvalidXLogRecPtr
#define IsA(nodeptr, _type_)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
int logical_read_local_xlog_page(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *cur_page, TimeLineID *pageTLI)
#define PointerGetDatum(X)
ResourceOwner CurrentResourceOwner
static void check_permissions(void)
#define tuplestore_donestoring(state)
Datum pg_logical_emit_message_bytea(PG_FUNCTION_ARGS)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
int errcode(int sqlerrcode)
Datum pg_logical_slot_get_binary_changes(PG_FUNCTION_ARGS)
Tuplestorestate * tupstore
XLogRecPtr GetFlushRecPtr(void)
#define PG_GETARG_BOOL(n)
ReplicationSlotPersistentData data
bool RecoveryInProgress(void)
void InvalidateSystemCaches(void)
XLogRecord * XLogReadRecord(XLogReaderState *state, XLogRecPtr RecPtr, char **errormsg)
#define PG_GETARG_TEXT_PP(n)
int read_local_xlog_page(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen, XLogRecPtr targetRecPtr, char *cur_page, TimeLineID *pageTLI)
#define PG_GETARG_ARRAYTYPE_P(n)
static Datum pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool binary)
void LogicalDecodingProcessRecord(LogicalDecodingContext *ctx, XLogReaderState *record)
struct DecodingOutputState DecodingOutputState
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
LogicalDecodingContext * CreateDecodingContext(XLogRecPtr start_lsn, List *output_plugin_options, XLogPageReadCB read_page, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write)
text * cstring_to_text_with_len(const char *s, int len)
void resetStringInfo(StringInfo str)
void ReplicationSlotRelease(void)
static void LogicalOutputPrepareWrite(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid, bool last_write)
bool pg_verify_mbstr(int encoding, const char *mbstr, int len, bool noError)
#define ereport(elevel, rest)
List * lappend(List *list, void *datum)
XLogRecPtr LogLogicalMessage(const char *prefix, const char *message, size_t size, bool transactional)
DefElem * makeDefElem(char *name, Node *arg)
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
#define TextDatumGetCString(d)
#define TransactionIdGetDatum(X)
void * palloc0(Size size)
int GetDatabaseEncoding(void)
char * format_procedure(Oid procedure_oid)
Datum pg_logical_slot_get_changes(PG_FUNCTION_ARGS)
SetFunctionReturnMode returnMode
ReplicationSlot * MyReplicationSlot
#define Assert(condition)
void FreeDecodingContext(LogicalDecodingContext *ctx)
void ReplicationSlotAcquire(const char *name)
#define PG_GETARG_BYTEA_PP(n)
bool has_rolreplication(Oid roleid)
void LogicalConfirmReceivedLocation(XLogRecPtr lsn)
MemoryContext ecxt_per_query_memory
Tuplestorestate * setResult
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
static Datum values[MAXATTR]
char * text_to_cstring(const text *t)
#define VARSIZE_ANY_EXHDR(PTR)
int errmsg(const char *fmt,...)
Datum pg_logical_slot_peek_changes(PG_FUNCTION_ARGS)
#define CHECK_FOR_INTERRUPTS()
bool array_contains_nulls(ArrayType *array)
void CheckLogicalDecodingRequirements(void)
void * output_writer_private
static void LogicalOutputWrite(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid, bool last_write)
#define PG_GETARG_NAME(n)
Datum pg_logical_emit_message_text(PG_FUNCTION_ARGS)
ResourceOwner ResourceOwnerCreate(ResourceOwner parent, const char *name)
Datum pg_logical_slot_peek_binary_changes(PG_FUNCTION_ARGS)