PostgreSQL Source Code  git master
logicalfuncs.c File Reference
#include "postgres.h"
#include <unistd.h>
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "access/xlogutils.h"
#include "catalog/pg_type.h"
#include "fmgr.h"
#include "funcapi.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "replication/decode.h"
#include "replication/logical.h"
#include "replication/message.h"
#include "storage/fd.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/pg_lsn.h"
#include "utils/regproc.h"
#include "utils/resowner.h"
Include dependency graph for logicalfuncs.c:

Go to the source code of this file.

Data Structures

struct  DecodingOutputState
 

Typedefs

typedef struct DecodingOutputState DecodingOutputState
 

Functions

static void LogicalOutputPrepareWrite (LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid, bool last_write)
 
static void LogicalOutputWrite (LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid, bool last_write)
 
static void check_permissions (void)
 
static Datum pg_logical_slot_get_changes_guts (FunctionCallInfo fcinfo, bool confirm, bool binary)
 
Datum pg_logical_slot_get_changes (PG_FUNCTION_ARGS)
 
Datum pg_logical_slot_peek_changes (PG_FUNCTION_ARGS)
 
Datum pg_logical_slot_get_binary_changes (PG_FUNCTION_ARGS)
 
Datum pg_logical_slot_peek_binary_changes (PG_FUNCTION_ARGS)
 
Datum pg_logical_emit_message_bytea (PG_FUNCTION_ARGS)
 
Datum pg_logical_emit_message_text (PG_FUNCTION_ARGS)
 

Typedef Documentation

◆ DecodingOutputState

Function Documentation

◆ check_permissions()

static void check_permissions ( void  )
static

Definition at line 99 of file logicalfuncs.c.

References ereport, errcode(), errmsg(), ERROR, GetUserId(), has_rolreplication(), and superuser().

Referenced by pg_logical_slot_get_changes_guts().

100 {
101  if (!superuser() && !has_rolreplication(GetUserId()))
102  ereport(ERROR,
103  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
104  errmsg("must be superuser or replication role to use replication slots")));
105 }
Oid GetUserId(void)
Definition: miscinit.c:478
int errcode(int sqlerrcode)
Definition: elog.c:698
bool superuser(void)
Definition: superuser.c:46
#define ERROR
Definition: elog.h:46
#define ereport(elevel,...)
Definition: elog.h:157
bool has_rolreplication(Oid roleid)
Definition: miscinit.c:659
int errmsg(const char *fmt,...)
Definition: elog.c:909

◆ LogicalOutputPrepareWrite()

static void LogicalOutputPrepareWrite ( LogicalDecodingContext ctx,
XLogRecPtr  lsn,
TransactionId  xid,
bool  last_write 
)
static

Definition at line 55 of file logicalfuncs.c.

References LogicalDecodingContext::out, and resetStringInfo().

Referenced by pg_logical_slot_get_changes_guts().

57 {
58  resetStringInfo(ctx->out);
59 }
void resetStringInfo(StringInfo str)
Definition: stringinfo.c:75
StringInfo out
Definition: logical.h:73

◆ LogicalOutputWrite()

static void LogicalOutputWrite ( LogicalDecodingContext ctx,
XLogRecPtr  lsn,
TransactionId  xid,
bool  last_write 
)
static

Definition at line 65 of file logicalfuncs.c.

References Assert, DecodingOutputState::binary_output, cstring_to_text_with_len(), StringInfoData::data, elog, ERROR, GetDatabaseEncoding(), StringInfoData::len, LSNGetDatum, MaxAllocSize, LogicalDecodingContext::out, LogicalDecodingContext::output_writer_private, pg_verify_mbstr(), PointerGetDatum, DecodingOutputState::returned_rows, TransactionIdGetDatum, DecodingOutputState::tupdesc, tuplestore_putvalues(), DecodingOutputState::tupstore, values, and VARHDRSZ.

Referenced by pg_logical_slot_get_changes_guts().

67 {
68  Datum values[3];
69  bool nulls[3];
71 
72  /* SQL Datums can only be of a limited length... */
73  if (ctx->out->len > MaxAllocSize - VARHDRSZ)
74  elog(ERROR, "too much output for sql interface");
75 
77 
78  memset(nulls, 0, sizeof(nulls));
79  values[0] = LSNGetDatum(lsn);
80  values[1] = TransactionIdGetDatum(xid);
81 
82  /*
83  * Assert ctx->out is in database encoding when we're writing textual
84  * output.
85  */
86  if (!p->binary_output)
88  ctx->out->data, ctx->out->len,
89  false));
90 
91  /* ick, but cstring_to_text_with_len works for bytea perfectly fine */
92  values[2] = PointerGetDatum(cstring_to_text_with_len(ctx->out->data, ctx->out->len));
93 
94  tuplestore_putvalues(p->tupstore, p->tupdesc, values, nulls);
95  p->returned_rows++;
96 }
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, Datum *values, bool *isnull)
Definition: tuplestore.c:750
#define PointerGetDatum(X)
Definition: postgres.h:600
#define VARHDRSZ
Definition: c.h:627
#define LSNGetDatum(X)
Definition: pg_lsn.h:22
Tuplestorestate * tupstore
Definition: logicalfuncs.c:45
bool pg_verify_mbstr(int encoding, const char *mbstr, int len, bool noError)
Definition: mbutils.c:1515
#define ERROR
Definition: elog.h:46
text * cstring_to_text_with_len(const char *s, int len)
Definition: varlena.c:202
#define MaxAllocSize
Definition: memutils.h:40
#define TransactionIdGetDatum(X)
Definition: postgres.h:565
uintptr_t Datum
Definition: postgres.h:411
int GetDatabaseEncoding(void)
Definition: mbutils.c:1210
#define Assert(condition)
Definition: c.h:804
static Datum values[MAXATTR]
Definition: bootstrap.c:166
#define elog(elevel,...)
Definition: elog.h:232
StringInfo out
Definition: logical.h:73
void * output_writer_private
Definition: logical.h:83

◆ pg_logical_emit_message_bytea()

Datum pg_logical_emit_message_bytea ( PG_FUNCTION_ARGS  )

Definition at line 405 of file logicalfuncs.c.

References LogLogicalMessage(), PG_GETARG_BOOL, PG_GETARG_BYTEA_PP, PG_GETARG_TEXT_PP, PG_RETURN_LSN, text_to_cstring(), VARDATA_ANY, and VARSIZE_ANY_EXHDR.

Referenced by pg_logical_emit_message_text().

406 {
407  bool transactional = PG_GETARG_BOOL(0);
408  char *prefix = text_to_cstring(PG_GETARG_TEXT_PP(1));
409  bytea *data = PG_GETARG_BYTEA_PP(2);
410  XLogRecPtr lsn;
411 
412  lsn = LogLogicalMessage(prefix, VARDATA_ANY(data), VARSIZE_ANY_EXHDR(data),
413  transactional);
414  PG_RETURN_LSN(lsn);
415 }
#define VARDATA_ANY(PTR)
Definition: postgres.h:361
#define PG_GETARG_BOOL(n)
Definition: fmgr.h:274
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:309
#define PG_RETURN_LSN(x)
Definition: pg_lsn.h:25
XLogRecPtr LogLogicalMessage(const char *prefix, const char *message, size_t size, bool transactional)
Definition: message.c:45
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define PG_GETARG_BYTEA_PP(n)
Definition: fmgr.h:308
char * text_to_cstring(const text *t)
Definition: varlena.c:223
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:354
Definition: c.h:621

◆ pg_logical_emit_message_text()

Datum pg_logical_emit_message_text ( PG_FUNCTION_ARGS  )

Definition at line 418 of file logicalfuncs.c.

References pg_logical_emit_message_bytea().

419 {
420  /* bytea and text are compatible */
421  return pg_logical_emit_message_bytea(fcinfo);
422 }
Datum pg_logical_emit_message_bytea(PG_FUNCTION_ARGS)
Definition: logicalfuncs.c:405

◆ pg_logical_slot_get_binary_changes()

Datum pg_logical_slot_get_binary_changes ( PG_FUNCTION_ARGS  )

Definition at line 386 of file logicalfuncs.c.

References pg_logical_slot_get_changes_guts().

387 {
388  return pg_logical_slot_get_changes_guts(fcinfo, true, true);
389 }
static Datum pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool binary)
Definition: logicalfuncs.c:111

◆ pg_logical_slot_get_changes()

Datum pg_logical_slot_get_changes ( PG_FUNCTION_ARGS  )

Definition at line 368 of file logicalfuncs.c.

References pg_logical_slot_get_changes_guts().

369 {
370  return pg_logical_slot_get_changes_guts(fcinfo, true, false);
371 }
static Datum pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool binary)
Definition: logicalfuncs.c:111

◆ pg_logical_slot_get_changes_guts()

static Datum pg_logical_slot_get_changes_guts ( FunctionCallInfo  fcinfo,
bool  confirm,
bool  binary 
)
static

Definition at line 111 of file logicalfuncs.c.

References ReturnSetInfo::allowedModes, ARR_ELEMTYPE, ARR_NDIM, array_contains_nulls(), Assert, CHECK_FOR_INTERRUPTS, check_permissions(), CheckLogicalDecodingRequirements(), CreateDecodingContext(), CurrentResourceOwner, ReplicationSlot::data, deconstruct_array(), ReturnSetInfo::econtext, ExprContext::ecxt_per_query_memory, elog, ereport, errcode(), errdetail(), errmsg(), ERROR, FunctionCallInfoBaseData::flinfo, FmgrInfo::fn_oid, format_procedure(), FreeDecodingContext(), get_call_result_type(), GetFlushRecPtr(), GetXLogReplayRecPtr(), i, InvalidateSystemCaches(), InvalidXLogRecPtr, IsA, lappend(), LogicalConfirmReceivedLocation(), LogicalDecodingProcessRecord(), LogicalOutputPrepareWrite(), LogicalOutputWrite(), makeDefElem(), makeString(), MemoryContextSwitchTo(), MyReplicationSlot, name, NameStr, NIL, OUTPUT_PLUGIN_TEXTUAL_OUTPUT, palloc0(), PG_ARGISNULL, PG_CATCH, PG_END_TRY, PG_GETARG_ARRAYTYPE_P, PG_GETARG_INT32, PG_GETARG_LSN, PG_GETARG_NAME, PG_RE_THROW, PG_TRY, ReplicationSlotPersistentData::plugin, read_local_xlog_page(), RecoveryInProgress(), ReplicationSlotAcquire(), ReplicationSlotMarkDirty(), ReplicationSlotRelease(), ReplicationSlotPersistentData::restart_lsn, FunctionCallInfoBaseData::resultinfo, DecodingOutputState::returned_rows, ReturnSetInfo::returnMode, SAB_Error, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SFRM_Materialize, TextDatumGetCString, ThisTimeLineID, tuplestore_begin_heap(), tuplestore_donestoring, DecodingOutputState::tupstore, TYPEFUNC_COMPOSITE, wal_segment_close(), work_mem, XLogBeginRead(), XLogReadRecord(), XLogRecPtrIsInvalid, and XLREAD_NEED_DATA.

Referenced by pg_logical_slot_get_binary_changes(), pg_logical_slot_get_changes(), pg_logical_slot_peek_binary_changes(), and pg_logical_slot_peek_changes().

112 {
113  Name name;
114  XLogRecPtr upto_lsn;
115  int32 upto_nchanges;
116  ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
117  MemoryContext per_query_ctx;
118  MemoryContext oldcontext;
119  XLogRecPtr end_of_wal;
121  ResourceOwner old_resowner = CurrentResourceOwner;
122  ArrayType *arr;
123  Size ndim;
124  List *options = NIL;
126 
128 
130 
131  if (PG_ARGISNULL(0))
132  ereport(ERROR,
133  (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
134  errmsg("slot name must not be null")));
135  name = PG_GETARG_NAME(0);
136 
137  if (PG_ARGISNULL(1))
138  upto_lsn = InvalidXLogRecPtr;
139  else
140  upto_lsn = PG_GETARG_LSN(1);
141 
142  if (PG_ARGISNULL(2))
143  upto_nchanges = InvalidXLogRecPtr;
144  else
145  upto_nchanges = PG_GETARG_INT32(2);
146 
147  if (PG_ARGISNULL(3))
148  ereport(ERROR,
149  (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
150  errmsg("options array must not be null")));
151  arr = PG_GETARG_ARRAYTYPE_P(3);
152 
153  /* check to see if caller supports us returning a tuplestore */
154  if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
155  ereport(ERROR,
156  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
157  errmsg("set-valued function called in context that cannot accept a set")));
158  if (!(rsinfo->allowedModes & SFRM_Materialize))
159  ereport(ERROR,
160  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
161  errmsg("materialize mode required, but it is not allowed in this context")));
162 
163  /* state to write output to */
164  p = palloc0(sizeof(DecodingOutputState));
165 
166  p->binary_output = binary;
167 
168  /* Build a tuple descriptor for our result type */
169  if (get_call_result_type(fcinfo, NULL, &p->tupdesc) != TYPEFUNC_COMPOSITE)
170  elog(ERROR, "return type must be a row type");
171 
172  per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
173  oldcontext = MemoryContextSwitchTo(per_query_ctx);
174 
175  /* Deconstruct options array */
176  ndim = ARR_NDIM(arr);
177  if (ndim > 1)
178  {
179  ereport(ERROR,
180  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
181  errmsg("array must be one-dimensional")));
182  }
183  else if (array_contains_nulls(arr))
184  {
185  ereport(ERROR,
186  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
187  errmsg("array must not contain nulls")));
188  }
189  else if (ndim == 1)
190  {
191  int nelems;
192  Datum *datum_opts;
193  int i;
194 
195  Assert(ARR_ELEMTYPE(arr) == TEXTOID);
196 
197  deconstruct_array(arr, TEXTOID, -1, false, TYPALIGN_INT,
198  &datum_opts, NULL, &nelems);
199 
200  if (nelems % 2 != 0)
201  ereport(ERROR,
202  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
203  errmsg("array must have even number of elements")));
204 
205  for (i = 0; i < nelems; i += 2)
206  {
207  char *name = TextDatumGetCString(datum_opts[i]);
208  char *opt = TextDatumGetCString(datum_opts[i + 1]);
209 
210  options = lappend(options, makeDefElem(name, (Node *) makeString(opt), -1));
211  }
212  }
213 
214  p->tupstore = tuplestore_begin_heap(true, false, work_mem);
215  rsinfo->returnMode = SFRM_Materialize;
216  rsinfo->setResult = p->tupstore;
217  rsinfo->setDesc = p->tupdesc;
218 
219  /*
220  * Compute the current end-of-wal and maintain ThisTimeLineID.
221  * RecoveryInProgress() will update ThisTimeLineID on promotion.
222  */
223  if (!RecoveryInProgress())
224  end_of_wal = GetFlushRecPtr();
225  else
226  end_of_wal = GetXLogReplayRecPtr(&ThisTimeLineID);
227 
228  (void) ReplicationSlotAcquire(NameStr(*name), SAB_Error);
229 
230  PG_TRY();
231  {
232  /* restart at slot's confirmed_flush */
234  options,
235  false,
239  LogicalOutputWrite, NULL);
240 
241  /*
242  * After the sanity checks in CreateDecodingContext, make sure the
243  * restart_lsn is valid. Avoid "cannot get changes" wording in this
244  * errmsg because that'd be confusingly ambiguous about no changes
245  * being available.
246  */
248  ereport(ERROR,
249  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
250  errmsg("can no longer get changes from replication slot \"%s\"",
251  NameStr(*name)),
252  errdetail("This slot has never previously reserved WAL, or it has been invalidated.")));
253 
254  MemoryContextSwitchTo(oldcontext);
255 
256  /*
257  * Check whether the output plugin writes textual output if that's
258  * what we need.
259  */
260  if (!binary &&
261  ctx->options.output_type !=OUTPUT_PLUGIN_TEXTUAL_OUTPUT)
262  ereport(ERROR,
263  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
264  errmsg("logical decoding output plugin \"%s\" produces binary output, but function \"%s\" expects textual data",
266  format_procedure(fcinfo->flinfo->fn_oid))));
267 
268  ctx->output_writer_private = p;
269 
270  /*
271  * Decoding of WAL must start at restart_lsn so that the entirety of
272  * xacts that committed after the slot's confirmed_flush can be
273  * accumulated into reorder buffers.
274  */
276 
277  /* invalidate non-timetravel entries */
279 
280  /* Decode until we run out of records */
281  while (ctx->reader->EndRecPtr < end_of_wal)
282  {
283  XLogRecord *record;
284  char *errm = NULL;
285 
286  while (XLogReadRecord(ctx->reader, &record, &errm) ==
288  {
289  if (!ctx->page_read(ctx->reader))
290  break;
291  }
292 
293  if (errm)
294  elog(ERROR, "%s", errm);
295 
296  /*
297  * The {begin_txn,change,commit_txn}_wrapper callbacks above will
298  * store the description into our tuplestore.
299  */
300  if (record != NULL)
301  LogicalDecodingProcessRecord(ctx, ctx->reader);
302 
303  /* check limits */
304  if (upto_lsn != InvalidXLogRecPtr &&
305  upto_lsn <= ctx->reader->EndRecPtr)
306  break;
307  if (upto_nchanges != 0 &&
308  upto_nchanges <= p->returned_rows)
309  break;
311  }
312 
313  tuplestore_donestoring(tupstore);
314 
315  /*
316  * Logical decoding could have clobbered CurrentResourceOwner during
317  * transaction management, so restore the executor's value. (This is
318  * a kluge, but it's not worth cleaning up right now.)
319  */
320  CurrentResourceOwner = old_resowner;
321 
322  /*
323  * Next time, start where we left off. (Hunting things, the family
324  * business..)
325  */
326  if (ctx->reader->EndRecPtr != InvalidXLogRecPtr && confirm)
327  {
328  LogicalConfirmReceivedLocation(ctx->reader->EndRecPtr);
329 
330  /*
331  * If only the confirmed_flush_lsn has changed the slot won't get
332  * marked as dirty by the above. Callers on the walsender
333  * interface are expected to keep track of their own progress and
334  * don't need it written out. But SQL-interface users cannot
335  * specify their own start positions and it's harder for them to
336  * keep track of their progress, so we should make more of an
337  * effort to save it for them.
338  *
339  * Dirty the slot so it's written out at the next checkpoint.
340  * We'll still lose its position on crash, as documented, but it's
341  * better than always losing the position even on clean restart.
342  */
344  }
345 
346  /* free context, call shutdown callback */
347  FreeDecodingContext(ctx);
348 
351  }
352  PG_CATCH();
353  {
354  /* clear all timetravel entries */
356 
357  PG_RE_THROW();
358  }
359  PG_END_TRY();
360 
361  return (Datum) 0;
362 }
Value * makeString(char *str)
Definition: value.c:53
#define NIL
Definition: pg_list.h:65
#define PG_GETARG_INT32(n)
Definition: fmgr.h:269
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
#define IsA(nodeptr, _type_)
Definition: nodes.h:590
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition: funcapi.c:207
void wal_segment_close(XLogReaderState *state)
Definition: xlogutils.c:823
ResourceOwner CurrentResourceOwner
Definition: resowner.c:146
static void check_permissions(void)
Definition: logicalfuncs.c:99
LogicalDecodingContext * CreateDecodingContext(XLogRecPtr start_lsn, List *output_plugin_options, bool fast_forward, LogicalDecodingXLogPageReadCB page_read, WALSegmentCleanupCB cleanup_cb, LogicalOutputPluginWriterPrepareWrite prepare_write, LogicalOutputPluginWriterWrite do_write, LogicalOutputPluginWriterUpdateProgress update_progress)
Definition: logical.c:479
#define tuplestore_donestoring(state)
Definition: tuplestore.h:60
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
Definition: nodes.h:539
int errcode(int sqlerrcode)
Definition: elog.c:698
XLogRecPtr GetFlushRecPtr(void)
Definition: xlog.c:8589
ReplicationSlotPersistentData data
Definition: slot.h:156
bool RecoveryInProgress(void)
Definition: xlog.c:8237
XLogReadRecordResult XLogReadRecord(XLogReaderState *state, XLogRecord **record, char **errormsg)
Definition: xlogreader.c:346
DefElem * makeDefElem(char *name, Node *arg, int location)
Definition: makefuncs.c:546
void InvalidateSystemCaches(void)
Definition: inval.c:649
signed int int32
Definition: c.h:429
#define PG_GETARG_ARRAYTYPE_P(n)
Definition: array.h:256
#define ERROR
Definition: elog.h:46
void LogicalDecodingProcessRecord(LogicalDecodingContext *ctx, XLogReaderState *record)
Definition: decode.c:106
fmNodePtr resultinfo
Definition: fmgr.h:89
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
Definition: xlog.c:11728
Definition: c.h:675
int errdetail(const char *fmt,...)
Definition: elog.c:1042
void XLogBeginRead(XLogReaderState *state, XLogRecPtr RecPtr)
Definition: xlogreader.c:252
void ReplicationSlotRelease(void)
Definition: slot.c:497
static void LogicalOutputPrepareWrite(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid, bool last_write)
Definition: logicalfuncs.c:55
List * lappend(List *list, void *datum)
Definition: list.c:336
#define XLogRecPtrIsInvalid(r)
Definition: xlogdefs.h:29
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
Definition: tuplestore.c:318
#define TextDatumGetCString(d)
Definition: builtins.h:83
void * palloc0(Size size)
Definition: mcxt.c:1093
#define PG_GETARG_LSN(n)
Definition: pg_lsn.h:24
uintptr_t Datum
Definition: postgres.h:411
FmgrInfo * flinfo
Definition: fmgr.h:87
int work_mem
Definition: globals.c:124
TimeLineID ThisTimeLineID
Definition: xlog.c:196
Oid fn_oid
Definition: fmgr.h:59
#define ereport(elevel,...)
Definition: elog.h:157
int allowedModes
Definition: execnodes.h:305
char * format_procedure(Oid procedure_oid)
Definition: regproc.c:322
SetFunctionReturnMode returnMode
Definition: execnodes.h:307
#define PG_CATCH()
Definition: elog.h:323
ReplicationSlot * MyReplicationSlot
Definition: slot.c:96
#define PG_ARGISNULL(n)
Definition: fmgr.h:209
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:804
void FreeDecodingContext(LogicalDecodingContext *ctx)
Definition: logical.c:624
XLogRecPtr restart_lsn
Definition: slot.h:81
size_t Size
Definition: c.h:540
#define PG_RE_THROW()
Definition: elog.h:354
void LogicalConfirmReceivedLocation(XLogRecPtr lsn)
Definition: logical.c:1676
MemoryContext ecxt_per_query_memory
Definition: execnodes.h:233
#define ARR_NDIM(a)
Definition: array.h:283
const char * name
Definition: encode.c:515
Tuplestorestate * setResult
Definition: execnodes.h:310
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3488
ExprContext * econtext
Definition: execnodes.h:303
TupleDesc setDesc
Definition: execnodes.h:311
int errmsg(const char *fmt,...)
Definition: elog.c:909
int ReplicationSlotAcquire(const char *name, SlotAcquireBehavior behavior)
Definition: slot.c:388
#define elog(elevel,...)
Definition: elog.h:232
int i
Definition: slot.h:43
#define NameStr(name)
Definition: c.h:681
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:102
#define PG_TRY()
Definition: elog.h:313
bool array_contains_nulls(ArrayType *array)
Definition: arrayfuncs.c:3555
Definition: pg_list.h:50
void CheckLogicalDecodingRequirements(void)
Definition: logical.c:103
#define ARR_ELEMTYPE(a)
Definition: array.h:285
#define PG_END_TRY()
Definition: elog.h:338
static void LogicalOutputWrite(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid, bool last_write)
Definition: logicalfuncs.c:65
void ReplicationSlotMarkDirty(void)
Definition: slot.c:750
#define PG_GETARG_NAME(n)
Definition: fmgr.h:278
bool read_local_xlog_page(XLogReaderState *state)
Definition: xlogutils.c:842

◆ pg_logical_slot_peek_binary_changes()

Datum pg_logical_slot_peek_binary_changes ( PG_FUNCTION_ARGS  )

Definition at line 395 of file logicalfuncs.c.

References pg_logical_slot_get_changes_guts().

396 {
397  return pg_logical_slot_get_changes_guts(fcinfo, false, true);
398 }
static Datum pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool binary)
Definition: logicalfuncs.c:111

◆ pg_logical_slot_peek_changes()

Datum pg_logical_slot_peek_changes ( PG_FUNCTION_ARGS  )

Definition at line 377 of file logicalfuncs.c.

References pg_logical_slot_get_changes_guts().

378 {
379  return pg_logical_slot_get_changes_guts(fcinfo, false, false);
380 }
static Datum pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool binary)
Definition: logicalfuncs.c:111