Age Owner Branch data TLA Line data Source code
1 : : /* -------------------------------------------------------------------------
2 : : *
3 : : * decode.c
4 : : * This module decodes WAL records read using xlogreader.h's APIs for the
5 : : * purpose of logical decoding by passing information to the
6 : : * reorderbuffer module (containing the actual changes) and to the
7 : : * snapbuild module to build a fitting catalog snapshot (to be able to
8 : : * properly decode the changes in the reorderbuffer).
9 : : *
10 : : * NOTE:
11 : : * This basically tries to handle all low level xlog stuff for
12 : : * reorderbuffer.c and snapbuild.c. There's some minor leakage where a
13 : : * specific record's struct is used to pass data along, but those just
14 : : * happen to contain the right amount of data in a convenient
15 : : * format. There isn't and shouldn't be much intelligence about the
16 : : * contents of records in here except turning them into a more usable
17 : : * format.
18 : : *
19 : : * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
20 : : * Portions Copyright (c) 1994, Regents of the University of California
21 : : *
22 : : * IDENTIFICATION
23 : : * src/backend/replication/logical/decode.c
24 : : *
25 : : * -------------------------------------------------------------------------
26 : : */
27 : : #include "postgres.h"
28 : :
29 : : #include "access/heapam_xlog.h"
30 : : #include "access/transam.h"
31 : : #include "access/xact.h"
32 : : #include "access/xlog_internal.h"
33 : : #include "access/xlogreader.h"
34 : : #include "access/xlogrecord.h"
35 : : #include "catalog/pg_control.h"
36 : : #include "commands/repack.h"
37 : : #include "replication/decode.h"
38 : : #include "replication/logical.h"
39 : : #include "replication/message.h"
40 : : #include "replication/reorderbuffer.h"
41 : : #include "replication/snapbuild.h"
42 : : #include "storage/standbydefs.h"
43 : :
44 : : /* individual record(group)'s handlers */
45 : : static void DecodeInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf);
46 : : static void DecodeUpdate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf);
47 : : static void DecodeDelete(LogicalDecodingContext *ctx, XLogRecordBuffer *buf);
48 : : static void DecodeTruncate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf);
49 : : static void DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf);
50 : : static void DecodeSpecConfirm(LogicalDecodingContext *ctx, XLogRecordBuffer *buf);
51 : :
52 : : static void DecodeCommit(LogicalDecodingContext *ctx, XLogRecordBuffer *buf,
53 : : xl_xact_parsed_commit *parsed, TransactionId xid,
54 : : bool two_phase);
55 : : static void DecodeAbort(LogicalDecodingContext *ctx, XLogRecordBuffer *buf,
56 : : xl_xact_parsed_abort *parsed, TransactionId xid,
57 : : bool two_phase);
58 : : static void DecodePrepare(LogicalDecodingContext *ctx, XLogRecordBuffer *buf,
59 : : xl_xact_parsed_prepare *parsed);
60 : :
61 : :
62 : : /* common function to decode tuples */
63 : : static void DecodeXLogTuple(char *data, Size len, HeapTuple tuple);
64 : :
65 : : /* helper functions for decoding transactions */
66 : : static inline bool FilterPrepare(LogicalDecodingContext *ctx,
67 : : TransactionId xid, const char *gid);
68 : : static bool DecodeTXNNeedSkip(LogicalDecodingContext *ctx,
69 : : XLogRecordBuffer *buf, Oid txn_dbid,
70 : : ReplOriginId origin_id);
71 : :
72 : : /*
73 : : * Take every XLogReadRecord()ed record and perform the actions required to
74 : : * decode it using the output plugin already setup in the logical decoding
75 : : * context.
76 : : *
77 : : * NB: Note that every record's xid needs to be processed by reorderbuffer
78 : : * (xids contained in the content of records are not relevant for this rule).
79 : : * That means that for records which'd otherwise not go through the
80 : : * reorderbuffer ReorderBufferProcessXid() has to be called. We don't want to
81 : : * call ReorderBufferProcessXid for each record type by default, because
82 : : * e.g. empty xacts can be handled more efficiently if there's no previous
83 : : * state for them.
84 : : *
85 : : * We also support the ability to fast forward thru records, skipping some
86 : : * record types completely - see individual record types for details.
87 : : */
88 : : void
4391 heikki.linnakangas@i 89 :CBC 2391425 : LogicalDecodingProcessRecord(LogicalDecodingContext *ctx, XLogReaderState *record)
90 : : {
91 : : XLogRecordBuffer buf;
92 : : TransactionId txid;
93 : : RmgrData rmgr;
94 : :
4653 rhaas@postgresql.org 95 : 2391425 : buf.origptr = ctx->reader->ReadRecPtr;
96 : 2391425 : buf.endptr = ctx->reader->EndRecPtr;
4391 heikki.linnakangas@i 97 : 2391425 : buf.record = record;
98 : :
2322 akapila@postgresql.o 99 : 2391425 : txid = XLogRecGetTopXid(record);
100 : :
101 : : /*
102 : : * If the top-level xid is valid, we need to assign the subxact to the
103 : : * top-level xact. We need to do this for all records, hence we do it
104 : : * before the switch.
105 : : */
106 [ + + ]: 2391425 : if (TransactionIdIsValid(txid))
107 : : {
108 : 713 : ReorderBufferAssignChild(ctx->reorder,
109 : : txid,
1716 tmunro@postgresql.or 110 : 713 : XLogRecGetXid(record),
111 : : buf.origptr);
112 : : }
113 : :
1697 jdavis@postgresql.or 114 : 2391425 : rmgr = GetRmgr(XLogRecGetRmid(record));
115 : :
116 [ + + ]: 2391425 : if (rmgr.rm_decode != NULL)
117 : 1848218 : rmgr.rm_decode(ctx, &buf);
118 : : else
119 : : {
120 : : /* just deal with xid, and done */
1774 121 : 543207 : ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(record),
122 : : buf.origptr);
123 : : }
4653 rhaas@postgresql.org 124 : 2391406 : }
125 : :
126 : : /*
127 : : * Handle rmgr XLOG_ID records for LogicalDecodingProcessRecord().
128 : : */
129 : : void
1774 jdavis@postgresql.or 130 : 10715 : xlog_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
131 : : {
4653 rhaas@postgresql.org 132 : 10715 : SnapBuild *builder = ctx->snapshot_builder;
4391 heikki.linnakangas@i 133 : 10715 : uint8 info = XLogRecGetInfo(buf->record) & ~XLR_INFO_MASK;
134 : :
3920 andres@anarazel.de 135 : 10715 : ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(buf->record),
136 : : buf->origptr);
137 : :
4653 rhaas@postgresql.org 138 [ + + - + : 10715 : switch (info)
- ]
139 : : {
140 : : /* this is also used in END_OF_RECOVERY checkpoints */
141 : 122 : case XLOG_CHECKPOINT_SHUTDOWN:
142 : : case XLOG_END_OF_RECOVERY:
143 : 122 : SnapBuildSerializationPoint(builder, buf->origptr);
144 : :
145 : 122 : break;
146 : 87 : case XLOG_CHECKPOINT_ONLINE:
147 : :
148 : : /*
149 : : * a RUNNING_XACTS record will have been logged near to this, we
150 : : * can restart from there.
151 : : */
152 : 87 : break;
340 msawada@postgresql.o 153 :UBC 0 : case XLOG_LOGICAL_DECODING_STATUS_CHANGE:
154 : : {
155 : : bool logical_decoding;
156 : :
157 : 0 : memcpy(&logical_decoding, XLogRecGetData(buf->record), sizeof(bool));
158 : :
159 : : /*
160 : : * Error out as we should not decode this WAL record.
161 : : *
162 : : * Logical decoding is disabled, and existing logical slots on
163 : : * the standby are invalidated when this WAL record is
164 : : * replayed. No logical decoder can process this WAL record
165 : : * until replay completes, and by then the slots are already
166 : : * invalidated. Furthermore, no new logical slots can be
167 : : * created while logical decoding is disabled. This cannot
168 : : * occur even on primary either, since it will not restart
169 : : * with wal_level < replica if any logical slots exist.
170 : : */
171 [ # # ]: 0 : elog(ERROR, "unexpected logical decoding status change %d",
172 : : logical_decoding);
173 : :
174 : : break;
175 : : }
4653 rhaas@postgresql.org 176 :CBC 10506 : case XLOG_NOOP:
177 : : case XLOG_NEXTOID:
178 : : case XLOG_SWITCH:
179 : : case XLOG_BACKUP_END:
180 : : case XLOG_PARAMETER_CHANGE:
181 : : case XLOG_RESTORE_POINT:
182 : : case XLOG_FPW_CHANGE:
183 : : case XLOG_FPI_FOR_HINT:
184 : : case XLOG_FPI:
185 : : case XLOG_OVERWRITE_CONTRECORD:
186 : : case XLOG_CHECKPOINT_REDO:
187 : 10506 : break;
4653 rhaas@postgresql.org 188 :UBC 0 : default:
189 [ # # ]: 0 : elog(ERROR, "unexpected RM_XLOG_ID record type: %u", info);
190 : : }
4653 rhaas@postgresql.org 191 :CBC 10715 : }
192 : :
193 : : void
239 dgustafsson@postgres 194 :UNC 0 : xlog2_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
195 : : {
196 : 0 : uint8 info = XLogRecGetInfo(buf->record) & ~XLR_INFO_MASK;
197 : :
198 : 0 : ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(buf->record), buf->origptr);
199 : :
200 [ # # ]: 0 : switch (info)
201 : : {
202 : 0 : case XLOG2_CHECKSUMS:
203 : 0 : break;
204 : 0 : default:
205 [ # # ]: 0 : elog(ERROR, "unexpected RM_XLOG2_ID record type: %u", info);
206 : : }
207 : 0 : }
208 : :
209 : : /*
210 : : * Handle rmgr XACT_ID records for LogicalDecodingProcessRecord().
211 : : */
212 : : void
1774 jdavis@postgresql.or 213 :CBC 13464 : xact_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
214 : : {
4589 bruce@momjian.us 215 : 13464 : SnapBuild *builder = ctx->snapshot_builder;
216 : 13464 : ReorderBuffer *reorder = ctx->reorder;
4391 heikki.linnakangas@i 217 : 13464 : XLogReaderState *r = buf->record;
4276 andres@anarazel.de 218 : 13464 : uint8 info = XLogRecGetInfo(r) & XLOG_XACT_OPMASK;
219 : :
220 : : /*
221 : : * If the snapshot isn't yet fully built, we cannot decode anything, so
222 : : * bail out.
223 : : */
2322 akapila@postgresql.o 224 [ + + ]: 13464 : if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT)
4653 rhaas@postgresql.org 225 : 33 : return;
226 : :
227 [ + + + + : 13431 : switch (info)
+ - ]
228 : : {
229 : 4916 : case XLOG_XACT_COMMIT:
230 : : case XLOG_XACT_COMMIT_PREPARED:
231 : : {
232 : : xl_xact_commit *xlrec;
233 : : xl_xact_parsed_commit parsed;
234 : : TransactionId xid;
2154 akapila@postgresql.o 235 : 4916 : bool two_phase = false;
236 : :
4276 andres@anarazel.de 237 : 4916 : xlrec = (xl_xact_commit *) XLogRecGetData(r);
238 : 4916 : ParseCommitRecord(XLogRecGetInfo(buf->record), xlrec, &parsed);
239 : :
240 [ + + ]: 4916 : if (!TransactionIdIsValid(parsed.twophase_xid))
241 : 4786 : xid = XLogRecGetXid(r);
242 : : else
243 : 130 : xid = parsed.twophase_xid;
244 : :
245 : : /*
246 : : * We would like to process the transaction in a two-phase
247 : : * manner iff output plugin supports two-phase commits and
248 : : * doesn't filter the transaction at prepare time.
249 : : */
2154 akapila@postgresql.o 250 [ + + ]: 4916 : if (info == XLOG_XACT_COMMIT_PREPARED)
2069 251 : 130 : two_phase = !(FilterPrepare(ctx, xid,
252 : 130 : parsed.twophase_gid));
253 : :
2154 254 : 4916 : DecodeCommit(ctx, buf, &parsed, xid, two_phase);
4653 rhaas@postgresql.org 255 : 4899 : break;
256 : : }
257 : 233 : case XLOG_XACT_ABORT:
258 : : case XLOG_XACT_ABORT_PREPARED:
259 : : {
260 : : xl_xact_abort *xlrec;
261 : : xl_xact_parsed_abort parsed;
262 : : TransactionId xid;
2154 akapila@postgresql.o 263 : 233 : bool two_phase = false;
264 : :
4276 andres@anarazel.de 265 : 233 : xlrec = (xl_xact_abort *) XLogRecGetData(r);
266 : 233 : ParseAbortRecord(XLogRecGetInfo(buf->record), xlrec, &parsed);
267 : :
268 [ + + ]: 233 : if (!TransactionIdIsValid(parsed.twophase_xid))
269 : 184 : xid = XLogRecGetXid(r);
270 : : else
271 : 49 : xid = parsed.twophase_xid;
272 : :
273 : : /*
274 : : * We would like to process the transaction in a two-phase
275 : : * manner iff output plugin supports two-phase commits and
276 : : * doesn't filter the transaction at prepare time.
277 : : */
2154 akapila@postgresql.o 278 [ + + ]: 233 : if (info == XLOG_XACT_ABORT_PREPARED)
2069 279 : 49 : two_phase = !(FilterPrepare(ctx, xid,
280 : 49 : parsed.twophase_gid));
281 : :
2154 282 : 233 : DecodeAbort(ctx, buf, &parsed, xid, two_phase);
4653 rhaas@postgresql.org 283 : 233 : break;
284 : : }
285 : 144 : case XLOG_XACT_ASSIGNMENT:
286 : :
287 : : /*
288 : : * We assign subxact to the toplevel xact while processing each
289 : : * record if required. So, we don't need to do anything here. See
290 : : * LogicalDecodingProcessRecord.
291 : : */
2322 akapila@postgresql.o 292 : 144 : break;
2319 293 : 7936 : case XLOG_XACT_INVALIDATIONS:
294 : : {
295 : : TransactionId xid;
296 : : xl_xact_invals *invals;
297 : :
298 : 7936 : xid = XLogRecGetXid(r);
299 : 7936 : invals = (xl_xact_invals *) XLogRecGetData(r);
300 : :
301 : : /*
302 : : * Execute the invalidations for xid-less transactions,
303 : : * otherwise, accumulate them so that they can be processed at
304 : : * the commit time.
305 : : */
306 [ + + ]: 7936 : if (TransactionIdIsValid(xid))
307 : : {
308 [ + + ]: 7891 : if (!ctx->fast_forward)
309 : 7809 : ReorderBufferAddInvalidations(reorder, xid,
310 : : buf->origptr,
311 : 7809 : invals->nmsgs,
312 : 7809 : invals->msgs);
313 : 7891 : ReorderBufferXidSetCatalogChanges(ctx->reorder, xid,
314 : : buf->origptr);
315 : : }
880 michael@paquier.xyz 316 [ + - ]: 45 : else if (!ctx->fast_forward)
2319 akapila@postgresql.o 317 : 45 : ReorderBufferImmediateInvalidation(ctx->reorder,
318 : 45 : invals->nmsgs,
319 : 45 : invals->msgs);
320 : :
880 michael@paquier.xyz 321 : 7936 : break;
322 : : }
4653 rhaas@postgresql.org 323 : 202 : case XLOG_XACT_PREPARE:
324 : : {
325 : : xl_xact_parsed_prepare parsed;
326 : : xl_xact_prepare *xlrec;
327 : :
328 : : /* ok, parse it */
2154 akapila@postgresql.o 329 : 202 : xlrec = (xl_xact_prepare *) XLogRecGetData(r);
330 : 202 : ParsePrepareRecord(XLogRecGetInfo(buf->record),
331 : : xlrec, &parsed);
332 : :
333 : : /*
334 : : * We would like to process the transaction in a two-phase
335 : : * manner iff output plugin supports two-phase commits and
336 : : * doesn't filter the transaction at prepare time.
337 : : */
2069 338 [ + + ]: 202 : if (FilterPrepare(ctx, parsed.twophase_xid,
339 : : parsed.twophase_gid))
340 : : {
2154 341 : 22 : ReorderBufferProcessXid(reorder, parsed.twophase_xid,
342 : : buf->origptr);
343 : 22 : break;
344 : : }
345 : :
346 : : /*
347 : : * Note that if the prepared transaction has locked [user]
348 : : * catalog tables exclusively then decoding prepare can block
349 : : * till the main transaction is committed because it needs to
350 : : * lock the catalog tables.
351 : : *
352 : : * XXX Now, this can even lead to a deadlock if the prepare
353 : : * transaction is waiting to get it logically replicated for
354 : : * distributed 2PC. This can be avoided by disallowing
355 : : * preparing transactions that have locked [user] catalog
356 : : * tables exclusively but as of now, we ask users not to do
357 : : * such an operation.
358 : : */
359 : 180 : DecodePrepare(ctx, buf, &parsed);
360 : 180 : break;
361 : : }
4653 rhaas@postgresql.org 362 :UBC 0 : default:
363 [ # # ]: 0 : elog(ERROR, "unexpected RM_XACT_ID record type: %u", info);
364 : : }
365 : : }
366 : :
367 : : /*
368 : : * Handle rmgr STANDBY_ID records for LogicalDecodingProcessRecord().
369 : : */
370 : : void
1774 jdavis@postgresql.or 371 :CBC 5453 : standby_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
372 : : {
4653 rhaas@postgresql.org 373 : 5453 : SnapBuild *builder = ctx->snapshot_builder;
4391 heikki.linnakangas@i 374 : 5453 : XLogReaderState *r = buf->record;
375 : 5453 : uint8 info = XLogRecGetInfo(r) & ~XLR_INFO_MASK;
376 : :
3920 andres@anarazel.de 377 : 5453 : ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(r), buf->origptr);
378 : :
4653 rhaas@postgresql.org 379 [ + + + - ]: 5453 : switch (info)
380 : : {
381 : 1957 : case XLOG_RUNNING_XACTS:
382 : : {
4391 heikki.linnakangas@i 383 : 1957 : xl_running_xacts *running = (xl_running_xacts *) XLogRecGetData(r);
384 : :
385 : : /*
386 : : * Update this decoder's idea of transactions currently
387 : : * running. In doing so we will determine whether we have
388 : : * reached consistent status.
389 : : */
189 alvherre@kurilemu.de 390 : 1957 : SnapBuildProcessRunningXacts(builder, buf->origptr, running);
391 : :
392 : : /*
393 : : * Abort all transactions that we keep track of, that are
394 : : * older than the record's oldestRunningXid. This is the most
395 : : * convenient spot for doing so since, in contrast to shutdown
396 : : * or end-of-recovery checkpoints, we have information about
397 : : * all running transactions which includes prepared ones,
398 : : * while shutdown checkpoints just know that no non-prepared
399 : : * transactions are in progress.
400 : : */
401 : 1955 : ReorderBufferAbortOld(ctx->reorder, running->oldestRunningXid);
402 : : }
4653 rhaas@postgresql.org 403 : 1955 : break;
404 : 3448 : case XLOG_STANDBY_LOCK:
405 : 3448 : break;
3871 andres@anarazel.de 406 : 48 : case XLOG_INVALIDATIONS:
407 : :
408 : : /*
409 : : * We are processing the invalidations at the command level via
410 : : * XLOG_XACT_INVALIDATIONS. So we don't need to do anything here.
411 : : */
412 : 48 : break;
4653 rhaas@postgresql.org 413 :UBC 0 : default:
414 [ # # ]: 0 : elog(ERROR, "unexpected RM_STANDBY_ID record type: %u", info);
415 : : }
4653 rhaas@postgresql.org 416 :CBC 5451 : }
417 : :
418 : : /*
419 : : * Handle rmgr HEAP2_ID records for LogicalDecodingProcessRecord().
420 : : */
421 : : void
1774 jdavis@postgresql.or 422 : 46983 : heap2_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
423 : : {
4391 heikki.linnakangas@i 424 : 46983 : uint8 info = XLogRecGetInfo(buf->record) & XLOG_HEAP_OPMASK;
425 : 46983 : TransactionId xid = XLogRecGetXid(buf->record);
4653 rhaas@postgresql.org 426 : 46983 : SnapBuild *builder = ctx->snapshot_builder;
427 : :
3920 andres@anarazel.de 428 : 46983 : ReorderBufferProcessXid(ctx->reorder, xid, buf->origptr);
429 : :
430 : : /*
431 : : * If we don't have snapshot or we are just fast-forwarding, there is no
432 : : * point in decoding data changes. However, it's crucial to build the base
433 : : * snapshot during fast-forward mode (as is done in
434 : : * SnapBuildProcessChange()) because we require the snapshot's xmin when
435 : : * determining the candidate catalog_xmin for the replication slot. See
436 : : * SnapBuildProcessRunningXacts().
437 : : */
579 akapila@postgresql.o 438 [ + + ]: 46983 : if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT)
4653 rhaas@postgresql.org 439 : 30 : return;
440 : :
441 [ + + + + : 46953 : switch (info)
- ]
442 : : {
443 : 8724 : case XLOG_HEAP2_MULTI_INSERT:
579 akapila@postgresql.o 444 [ + - ]: 8724 : if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
236 alvherre@kurilemu.de 445 [ + + ]: 8724 : !ctx->fast_forward &&
446 [ + + ]: 8608 : !change_useless_for_repack(buf))
4653 rhaas@postgresql.org 447 : 8453 : DecodeMultiInsert(ctx, buf);
448 : 8724 : break;
449 : 36748 : case XLOG_HEAP2_NEW_CID:
579 akapila@postgresql.o 450 [ + + ]: 36748 : if (!ctx->fast_forward)
451 : : {
452 : : xl_heap_new_cid *xlrec;
453 : :
4391 heikki.linnakangas@i 454 : 36324 : xlrec = (xl_heap_new_cid *) XLogRecGetData(buf->record);
4653 rhaas@postgresql.org 455 : 36324 : SnapBuildProcessNewCid(builder, xid, buf->origptr, xlrec);
456 : : }
278 peter@eisentraut.org 457 : 36748 : break;
4653 rhaas@postgresql.org 458 : 90 : case XLOG_HEAP2_REWRITE:
459 : :
460 : : /*
461 : : * Although these records only exist to serve the needs of logical
462 : : * decoding, all the work happens as part of crash or archive
463 : : * recovery, so we don't need to do anything here.
464 : : */
465 : 90 : break;
466 : :
467 : : /*
468 : : * Everything else here is just low level physical stuff we're not
469 : : * interested in.
470 : : */
978 heikki.linnakangas@i 471 : 1391 : case XLOG_HEAP2_PRUNE_ON_ACCESS:
472 : : case XLOG_HEAP2_PRUNE_VACUUM_SCAN:
473 : : case XLOG_HEAP2_PRUNE_VACUUM_CLEANUP:
474 : : case XLOG_HEAP2_LOCK_UPDATED:
4653 rhaas@postgresql.org 475 : 1391 : break;
4653 rhaas@postgresql.org 476 :UBC 0 : default:
477 [ # # ]: 0 : elog(ERROR, "unexpected RM_HEAP2_ID record type: %u", info);
478 : : }
479 : : }
480 : :
481 : : /*
482 : : * Handle rmgr HEAP_ID records for LogicalDecodingProcessRecord().
483 : : */
484 : : void
1774 jdavis@postgresql.or 485 :CBC 1771481 : heap_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
486 : : {
4391 heikki.linnakangas@i 487 : 1771481 : uint8 info = XLogRecGetInfo(buf->record) & XLOG_HEAP_OPMASK;
488 : 1771481 : TransactionId xid = XLogRecGetXid(buf->record);
4653 rhaas@postgresql.org 489 : 1771481 : SnapBuild *builder = ctx->snapshot_builder;
490 : :
3920 andres@anarazel.de 491 : 1771481 : ReorderBufferProcessXid(ctx->reorder, xid, buf->origptr);
492 : :
493 : : /*
494 : : * If we don't have snapshot or we are just fast-forwarding, there is no
495 : : * point in decoding data changes. However, it's crucial to build the base
496 : : * snapshot during fast-forward mode (as is done in
497 : : * SnapBuildProcessChange()) because we require the snapshot's xmin when
498 : : * determining the candidate catalog_xmin for the replication slot. See
499 : : * SnapBuildProcessRunningXacts().
500 : : */
579 akapila@postgresql.o 501 [ + + ]: 1771481 : if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT)
4653 rhaas@postgresql.org 502 : 1283 : return;
503 : :
504 [ + + + + : 1770198 : switch (info)
+ + + - ]
505 : : {
506 : 1211174 : case XLOG_HEAP_INSERT:
579 akapila@postgresql.o 507 [ + + ]: 1211174 : if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
236 alvherre@kurilemu.de 508 [ + + ]: 1208188 : !ctx->fast_forward &&
509 [ + + ]: 1207981 : !change_useless_for_repack(buf))
4653 rhaas@postgresql.org 510 : 1207553 : DecodeInsert(ctx, buf);
511 : 1211174 : break;
512 : :
513 : : /*
514 : : * Treat HOT update as normal updates. There is no useful
515 : : * information in the fact that we could make it a HOT update
516 : : * locally and the WAL layout is compatible.
517 : : */
518 : 149144 : case XLOG_HEAP_HOT_UPDATE:
519 : : case XLOG_HEAP_UPDATE:
579 akapila@postgresql.o 520 [ + - ]: 149144 : if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
236 alvherre@kurilemu.de 521 [ + + ]: 149144 : !ctx->fast_forward &&
522 [ + + ]: 149127 : !change_useless_for_repack(buf))
4653 rhaas@postgresql.org 523 : 149060 : DecodeUpdate(ctx, buf);
524 : 149144 : break;
525 : :
526 : 226296 : case XLOG_HEAP_DELETE:
579 akapila@postgresql.o 527 [ + - ]: 226296 : if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
236 alvherre@kurilemu.de 528 [ + + ]: 226296 : !ctx->fast_forward &&
529 [ + + ]: 226202 : !change_useless_for_repack(buf))
4653 rhaas@postgresql.org 530 : 226150 : DecodeDelete(ctx, buf);
531 : 226296 : break;
532 : :
3157 peter_e@gmx.net 533 : 64 : case XLOG_HEAP_TRUNCATE:
579 akapila@postgresql.o 534 [ + - ]: 64 : if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
236 alvherre@kurilemu.de 535 [ + + ]: 64 : !ctx->fast_forward &&
536 [ + - ]: 62 : !change_useless_for_repack(buf))
3157 peter_e@gmx.net 537 : 62 : DecodeTruncate(ctx, buf);
538 : 64 : break;
539 : :
4653 rhaas@postgresql.org 540 : 1528 : case XLOG_HEAP_INPLACE:
541 : :
542 : : /*
543 : : * Inplace updates are only ever performed on catalog tuples and
544 : : * can, per definition, not change tuple visibility. Since we
545 : : * also don't decode catalog tuples, we're not interested in the
546 : : * record's contents.
547 : : */
548 : 1528 : break;
549 : :
4222 andres@anarazel.de 550 : 19702 : case XLOG_HEAP_CONFIRM:
579 akapila@postgresql.o 551 [ + - ]: 19702 : if (SnapBuildProcessChange(builder, xid, buf->origptr) &&
236 alvherre@kurilemu.de 552 [ + - ]: 19702 : !ctx->fast_forward &&
553 [ + - ]: 19702 : !change_useless_for_repack(buf))
4222 andres@anarazel.de 554 : 19702 : DecodeSpecConfirm(ctx, buf);
555 : 19702 : break;
556 : :
4653 rhaas@postgresql.org 557 : 162290 : case XLOG_HEAP_LOCK:
558 : : /* we don't care about row level locks for now */
559 : 162290 : break;
560 : :
4653 rhaas@postgresql.org 561 :UBC 0 : default:
562 [ # # ]: 0 : elog(ERROR, "unexpected RM_HEAP_ID record type: %u", info);
563 : : break;
564 : : }
565 : : }
566 : :
567 : : /*
568 : : * Ask output plugin whether we want to skip this PREPARE and send
569 : : * this transaction as a regular commit later.
570 : : */
571 : : static inline bool
2069 akapila@postgresql.o 572 :CBC 381 : FilterPrepare(LogicalDecodingContext *ctx, TransactionId xid,
573 : : const char *gid)
574 : : {
575 : : /*
576 : : * Skip if decoding of two-phase transactions at PREPARE time is not
577 : : * enabled. In that case, all two-phase transactions are considered
578 : : * filtered out and will be applied as regular transactions at COMMIT
579 : : * PREPARED.
580 : : */
2154 581 [ + + ]: 381 : if (!ctx->twophase)
582 : 24 : return true;
583 : :
584 : : /*
585 : : * The filter_prepare callback is optional. When not supplied, all
586 : : * prepared transactions should go through.
587 : : */
588 [ + + ]: 357 : if (ctx->callbacks.filter_prepare_cb == NULL)
589 : 187 : return false;
590 : :
2069 591 : 170 : return filter_prepare_cb_wrapper(ctx, xid, gid);
592 : : }
593 : :
594 : : static inline bool
304 msawada@postgresql.o 595 : 1597228 : FilterByOrigin(LogicalDecodingContext *ctx, ReplOriginId origin_id)
596 : : {
3881 andres@anarazel.de 597 [ + + ]: 1597228 : if (ctx->callbacks.filter_by_origin_cb == NULL)
598 : 235 : return false;
599 : :
600 : 1596993 : return filter_by_origin_cb_wrapper(ctx, origin_id);
601 : : }
602 : :
603 : : /*
604 : : * Handle rmgr LOGICALMSG_ID records for LogicalDecodingProcessRecord().
605 : : */
606 : : void
1774 jdavis@postgresql.or 607 : 122 : logicalmsg_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
608 : : {
3824 rhaas@postgresql.org 609 : 122 : SnapBuild *builder = ctx->snapshot_builder;
3888 simon@2ndQuadrant.co 610 : 122 : XLogReaderState *r = buf->record;
3824 rhaas@postgresql.org 611 : 122 : TransactionId xid = XLogRecGetXid(r);
612 : 122 : uint8 info = XLogRecGetInfo(r) & ~XLR_INFO_MASK;
304 msawada@postgresql.o 613 : 122 : ReplOriginId origin_id = XLogRecGetOrigin(r);
1375 tomas.vondra@postgre 614 : 122 : Snapshot snapshot = NULL;
615 : : xl_logical_message *message;
616 : :
3888 simon@2ndQuadrant.co 617 [ - + ]: 122 : if (info != XLOG_LOGICAL_MESSAGE)
3888 simon@2ndQuadrant.co 618 [ # # ]:UBC 0 : elog(ERROR, "unexpected RM_LOGICALMSG_ID record type: %u", info);
619 : :
3888 simon@2ndQuadrant.co 620 :CBC 122 : ReorderBufferProcessXid(ctx->reorder, XLogRecGetXid(r), buf->origptr);
621 : :
622 : : /* If we don't have snapshot, there is no point in decoding messages */
1129 akapila@postgresql.o 623 [ - + ]: 122 : if (SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT)
3888 simon@2ndQuadrant.co 624 :UBC 0 : return;
625 : :
3888 simon@2ndQuadrant.co 626 :CBC 122 : message = (xl_logical_message *) XLogRecGetData(r);
627 : :
3881 andres@anarazel.de 628 [ + + + + ]: 242 : if (message->dbId != ctx->slot->data.database ||
629 : 120 : FilterByOrigin(ctx, origin_id))
630 : 4 : return;
631 : :
3888 simon@2ndQuadrant.co 632 [ + + ]: 118 : if (message->transactional &&
633 [ - + ]: 55 : !SnapBuildProcessChange(builder, xid, buf->origptr))
3888 simon@2ndQuadrant.co 634 :UBC 0 : return;
3888 simon@2ndQuadrant.co 635 [ + + + - ]:CBC 181 : else if (!message->transactional &&
636 [ + + ]: 126 : (SnapBuildCurrentState(builder) != SNAPBUILD_CONSISTENT ||
637 : 63 : SnapBuildXactNeedsSkip(builder, buf->origptr)))
638 : 51 : return;
639 : :
640 : : /*
641 : : * We also skip decoding in fast_forward mode. This check must be last
642 : : * because we don't want to set the processing_required flag unless we
643 : : * have a decodable message.
644 : : */
1129 akapila@postgresql.o 645 [ + + ]: 67 : if (ctx->fast_forward)
646 : : {
647 : : /*
648 : : * We need to set processing_required flag to notify the message's
649 : : * existence to the caller. Usually, the flag is set when either the
650 : : * COMMIT or ABORT records are decoded, but this must be turned on
651 : : * here because the non-transactional logical message is decoded
652 : : * without waiting for these records.
653 : : */
654 [ + - ]: 3 : if (!message->transactional)
655 : 3 : ctx->processing_required = true;
656 : :
657 : 3 : return;
658 : : }
659 : :
660 : : /*
661 : : * If this is a non-transactional change, get the snapshot we're expected
662 : : * to use. We only get here when the snapshot is consistent, and the
663 : : * change is not meant to be skipped.
664 : : *
665 : : * For transactional changes we don't need a snapshot, we'll use the
666 : : * regular snapshot maintained by ReorderBuffer. We just leave it NULL.
667 : : */
1375 tomas.vondra@postgre 668 [ + + ]: 64 : if (!message->transactional)
669 : 9 : snapshot = SnapBuildGetOrBuildSnapshot(builder);
670 : :
671 : : /*
672 : : * Transactional messages use origptr as their LSN, like regular DML
673 : : * changes.
674 : : *
675 : : * Non-transactional messages use endptr instead, since we assume that
676 : : * each message is applied and confirmed as a unit of its own, like a
677 : : * commit. Using origptr would leave the replication slot's
678 : : * confirmed_flush pointing at the message record itself. Since decoding
679 : : * resumes from the confirmed position inclusive, the message could be
680 : : * decoded and sent again after a restart.
681 : : */
3 msawada@postgresql.o 682 :GNC 64 : ReorderBufferQueueMessage(ctx->reorder, xid, snapshot,
683 : 64 : message->transactional ? buf->origptr : buf->endptr,
3888 simon@2ndQuadrant.co 684 :CBC 64 : message->transactional,
3824 rhaas@postgresql.org 685 : 64 : message->message, /* first part of message is
686 : : * prefix */
687 : : message->message_size,
3888 simon@2ndQuadrant.co 688 [ + + ]: 64 : message->message + message->prefix_size);
689 : : }
690 : :
691 : : /*
692 : : * Consolidated commit record handling between the different form of commit
693 : : * records.
694 : : *
695 : : * 'two_phase' indicates that caller wants to process the transaction in two
696 : : * phases, first process prepare if not already done and then process
697 : : * commit_prepared.
698 : : */
699 : : static void
4653 rhaas@postgresql.org 700 : 4916 : DecodeCommit(LogicalDecodingContext *ctx, XLogRecordBuffer *buf,
701 : : xl_xact_parsed_commit *parsed, TransactionId xid,
702 : : bool two_phase)
703 : : {
4231 andres@anarazel.de 704 : 4916 : XLogRecPtr origin_lsn = InvalidXLogRecPtr;
3824 rhaas@postgresql.org 705 : 4916 : TimestampTz commit_time = parsed->xact_time;
304 msawada@postgresql.o 706 : 4916 : ReplOriginId origin_id = XLogRecGetOrigin(buf->record);
707 : : int i;
708 : :
4231 andres@anarazel.de 709 [ + + ]: 4916 : if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
710 : : {
711 : 201 : origin_lsn = parsed->origin_lsn;
712 : 201 : commit_time = parsed->origin_timestamp;
713 : : }
714 : :
4653 rhaas@postgresql.org 715 : 4916 : SnapBuildCommitTxn(ctx->snapshot_builder, buf->origptr, xid,
716 : : parsed->nsubxacts, parsed->subxacts,
717 : : parsed->xinfo);
718 : :
719 : : /* ----
720 : : * Check whether we are interested in this specific transaction, and tell
721 : : * the reorderbuffer to forget the content of the (sub-)transactions
722 : : * if not.
723 : : *
724 : : * We can't just use ReorderBufferAbort() here, because we need to execute
725 : : * the transaction's invalidations. This currently won't be needed if
726 : : * we're just skipping over the transaction because currently we only do
727 : : * so during startup, to get to the first transaction the client needs. As
728 : : * we have reset the catalog caches before starting to read WAL, and we
729 : : * haven't yet touched any catalogs, there can't be anything to invalidate.
730 : : * But if we're "forgetting" this commit because it happened in another
731 : : * database, the invalidations might be important, because they could be
732 : : * for shared catalogs and we might have loaded data into the relevant
733 : : * syscaches.
734 : : * ---
735 : : */
2154 akapila@postgresql.o 736 [ + + ]: 4916 : if (DecodeTXNNeedSkip(ctx, buf, parsed->dbId, origin_id))
737 : : {
4276 andres@anarazel.de 738 [ + + ]: 3314 : for (i = 0; i < parsed->nsubxacts; i++)
739 : : {
740 : 1072 : ReorderBufferForget(ctx->reorder, parsed->subxacts[i], buf->origptr);
741 : : }
4653 rhaas@postgresql.org 742 : 2242 : ReorderBufferForget(ctx->reorder, xid, buf->origptr);
743 : :
744 : 2242 : return;
745 : : }
746 : :
747 : : /* tell the reorderbuffer about the surviving subtransactions */
4276 andres@anarazel.de 748 [ + + ]: 2945 : for (i = 0; i < parsed->nsubxacts; i++)
749 : : {
750 : 271 : ReorderBufferCommitChild(ctx->reorder, xid, parsed->subxacts[i],
751 : : buf->origptr, buf->endptr);
752 : : }
753 : :
754 : : /*
755 : : * Send the final commit record if the transaction data is already
756 : : * decoded, otherwise, process the entire transaction.
757 : : */
2154 akapila@postgresql.o 758 [ + + ]: 2674 : if (two_phase)
759 : : {
760 : 38 : ReorderBufferFinishPrepared(ctx->reorder, xid, buf->origptr, buf->endptr,
1963 761 : 38 : SnapBuildGetTwoPhaseAt(ctx->snapshot_builder),
762 : : commit_time, origin_id, origin_lsn,
2154 763 : 38 : parsed->twophase_gid, true);
764 : : }
765 : : else
766 : : {
767 : 2636 : ReorderBufferCommit(ctx->reorder, xid, buf->origptr, buf->endptr,
768 : : commit_time, origin_id, origin_lsn);
769 : : }
770 : :
771 : : /*
772 : : * Update the decoding stats at transaction prepare/commit/abort.
773 : : * Additionally we send the stats when we spill or stream the changes to
774 : : * avoid losing them in case the decoding is interrupted. It is not clear
775 : : * that sending more or less frequently than this would be better.
776 : : */
777 : 2657 : UpdateDecodingStats(ctx);
778 : : }
779 : :
780 : : /*
781 : : * Decode PREPARE record. Similar logic as in DecodeCommit.
782 : : *
783 : : * Note that we don't skip prepare even if have detected concurrent abort
784 : : * because it is quite possible that we had already sent some changes before we
785 : : * detect abort in which case we need to abort those changes in the subscriber.
786 : : * To abort such changes, we do send the prepare and then the rollback prepared
787 : : * which is what happened on the publisher-side as well. Now, we can invent a
788 : : * new abort API wherein in such cases we send abort and skip sending prepared
789 : : * and rollback prepared but then it is not that straightforward because we
790 : : * might have streamed this transaction by that time in which case it is
791 : : * handled when the rollback is encountered. It is not impossible to optimize
792 : : * the concurrent abort case but it can introduce design complexity w.r.t
793 : : * handling different cases so leaving it for now as it doesn't seem worth it.
794 : : */
795 : : static void
796 : 180 : DecodePrepare(LogicalDecodingContext *ctx, XLogRecordBuffer *buf,
797 : : xl_xact_parsed_prepare *parsed)
798 : : {
799 : 180 : SnapBuild *builder = ctx->snapshot_builder;
800 : 180 : XLogRecPtr origin_lsn = parsed->origin_lsn;
801 : 180 : TimestampTz prepare_time = parsed->xact_time;
304 msawada@postgresql.o 802 : 180 : ReplOriginId origin_id = XLogRecGetOrigin(buf->record);
803 : : int i;
2154 akapila@postgresql.o 804 : 180 : TransactionId xid = parsed->twophase_xid;
805 : :
806 [ + + ]: 180 : if (parsed->origin_timestamp != 0)
807 : 8 : prepare_time = parsed->origin_timestamp;
808 : :
809 : : /*
810 : : * Remember the prepare info for a txn so that it can be used later in
811 : : * commit prepared if required. See ReorderBufferFinishPrepared.
812 : : */
813 [ - + ]: 180 : if (!ReorderBufferRememberPrepareInfo(ctx->reorder, xid, buf->origptr,
814 : : buf->endptr, prepare_time, origin_id,
815 : : origin_lsn))
2154 akapila@postgresql.o 816 :UBC 0 : return;
817 : :
818 : : /* We can't start streaming unless a consistent state is reached. */
2154 akapila@postgresql.o 819 [ + + ]:CBC 180 : if (SnapBuildCurrentState(builder) < SNAPBUILD_CONSISTENT)
820 : : {
821 : 3 : ReorderBufferSkipPrepare(ctx->reorder, xid);
822 : 3 : return;
823 : : }
824 : :
825 : : /*
826 : : * Check whether we need to process this transaction. See
827 : : * DecodeTXNNeedSkip for the reasons why we sometimes want to skip the
828 : : * transaction.
829 : : *
830 : : * We can't call ReorderBufferForget as we did in DecodeCommit as the txn
831 : : * hasn't yet been committed, removing this txn before a commit might
832 : : * result in the computation of an incorrect restart_lsn. See
833 : : * SnapBuildProcessRunningXacts. But we need to process cache
834 : : * invalidations if there are any for the reasons mentioned in
835 : : * DecodeCommit.
836 : : */
837 [ + + ]: 177 : if (DecodeTXNNeedSkip(ctx, buf, parsed->dbId, origin_id))
838 : : {
839 : 129 : ReorderBufferSkipPrepare(ctx->reorder, xid);
840 : 129 : ReorderBufferInvalidate(ctx->reorder, xid, buf->origptr);
841 : 129 : return;
842 : : }
843 : :
844 : : /* Tell the reorderbuffer about the surviving subtransactions. */
845 [ + + ]: 49 : for (i = 0; i < parsed->nsubxacts; i++)
846 : : {
847 : 1 : ReorderBufferCommitChild(ctx->reorder, xid, parsed->subxacts[i],
848 : : buf->origptr, buf->endptr);
849 : : }
850 : :
851 : : /* replay actions of all transaction + subtransactions in order */
852 : 48 : ReorderBufferPrepare(ctx->reorder, xid, parsed->twophase_gid);
853 : :
854 : : /*
855 : : * Update the decoding stats at transaction prepare/commit/abort.
856 : : * Additionally we send the stats when we spill or stream the changes to
857 : : * avoid losing them in case the decoding is interrupted. It is not clear
858 : : * that sending more or less frequently than this would be better.
859 : : */
2242 860 : 48 : UpdateDecodingStats(ctx);
861 : : }
862 : :
863 : :
864 : : /*
865 : : * Get the data from the various forms of abort records and pass it on to
866 : : * snapbuild.c and reorderbuffer.c.
867 : : *
868 : : * 'two_phase' indicates to finish prepared transaction.
869 : : */
870 : : static void
4276 andres@anarazel.de 871 : 233 : DecodeAbort(LogicalDecodingContext *ctx, XLogRecordBuffer *buf,
872 : : xl_xact_parsed_abort *parsed, TransactionId xid,
873 : : bool two_phase)
874 : : {
2154 akapila@postgresql.o 875 : 233 : XLogRecPtr origin_lsn = InvalidXLogRecPtr;
876 : 233 : TimestampTz abort_time = parsed->xact_time;
304 msawada@postgresql.o 877 : 233 : ReplOriginId origin_id = XLogRecGetOrigin(buf->record);
878 : : bool skip_xact;
879 : :
2154 akapila@postgresql.o 880 [ + + ]: 233 : if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
881 : : {
882 : 4 : origin_lsn = parsed->origin_lsn;
883 : 4 : abort_time = parsed->origin_timestamp;
884 : : }
885 : :
886 : : /*
887 : : * Check whether we need to process this transaction. See
888 : : * DecodeTXNNeedSkip for the reasons why we sometimes want to skip the
889 : : * transaction.
890 : : */
891 : 233 : skip_xact = DecodeTXNNeedSkip(ctx, buf, parsed->dbId, origin_id);
892 : :
893 : : /*
894 : : * Send the final rollback record for a prepared transaction unless we
895 : : * need to skip it. For non-two-phase xacts, simply forget the xact.
896 : : */
897 [ + + + + ]: 233 : if (two_phase && !skip_xact)
898 : : {
899 : 12 : ReorderBufferFinishPrepared(ctx->reorder, xid, buf->origptr, buf->endptr,
900 : : InvalidXLogRecPtr,
901 : : abort_time, origin_id, origin_lsn,
902 : 12 : parsed->twophase_gid, false);
903 : : }
904 : : else
905 : : {
906 : : /*
907 : : * Remove tuplecid changes queued by the aborted subtransactions from
908 : : * the toplevel's list.
909 : : */
45 alvherre@kurilemu.de 910 : 221 : ReorderBufferCleanupAbortedTupleCids(ctx->reorder, xid,
911 : : parsed->nsubxacts,
912 : : parsed->subxacts);
913 : :
914 [ + + ]: 229 : for (int i = 0; i < parsed->nsubxacts; i++)
915 : : {
2154 akapila@postgresql.o 916 : 8 : ReorderBufferAbort(ctx->reorder, parsed->subxacts[i],
1419 917 : 8 : buf->record->EndRecPtr, abort_time);
918 : : }
919 : :
920 : 221 : ReorderBufferAbort(ctx->reorder, xid, buf->record->EndRecPtr,
921 : : abort_time);
922 : : }
923 : :
924 : : /* update the decoding stats */
2242 925 : 233 : UpdateDecodingStats(ctx);
4653 rhaas@postgresql.org 926 : 233 : }
927 : :
928 : : /*
929 : : * Parse XLOG_HEAP_INSERT (not MULTI_INSERT!) records into tuplebufs.
930 : : *
931 : : * Inserts can contain the new tuple.
932 : : */
933 : : static void
934 : 1207553 : DecodeInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
935 : : {
936 : : Size datalen;
937 : : char *tupledata;
938 : : Size tuplelen;
4391 heikki.linnakangas@i 939 : 1207553 : XLogReaderState *r = buf->record;
940 : : xl_heap_insert *xlrec;
941 : : ReorderBufferChange *change;
942 : : RelFileLocator target_locator;
943 : :
944 : 1207553 : xlrec = (xl_heap_insert *) XLogRecGetData(r);
945 : :
946 : : /*
947 : : * Ignore insert records without new tuples (this does happen when
948 : : * raw_heap_insert marks the TOAST record as HEAP_INSERT_NO_LOGICAL).
949 : : */
2922 tomas.vondra@postgre 950 [ + + ]: 1207553 : if (!(xlrec->flags & XLH_INSERT_CONTAINS_NEW_TUPLE))
951 : 5916 : return;
952 : :
953 : : /* only interested in our database */
1606 rhaas@postgresql.org 954 : 1201758 : XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
955 [ - + ]: 1201758 : if (target_locator.dbOid != ctx->slot->data.database)
4653 rhaas@postgresql.org 956 :UBC 0 : return;
957 : :
958 : : /* output plugin doesn't look for this origin, no need to queue */
4231 andres@anarazel.de 959 [ + + ]:CBC 1201758 : if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
960 : 121 : return;
961 : :
626 heikki.linnakangas@i 962 : 1201637 : change = ReorderBufferAllocChange(ctx->reorder);
4222 andres@anarazel.de 963 [ + + ]: 1201637 : if (!(xlrec->flags & XLH_INSERT_IS_SPECULATIVE))
964 : 1181935 : change->action = REORDER_BUFFER_CHANGE_INSERT;
965 : : else
966 : 19702 : change->action = REORDER_BUFFER_CHANGE_INTERNAL_SPEC_INSERT;
4231 967 : 1201637 : change->origin_id = XLogRecGetOrigin(r);
968 : :
1606 rhaas@postgresql.org 969 : 1201637 : memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
970 : :
2922 tomas.vondra@postgre 971 : 1201637 : tupledata = XLogRecGetBlockData(r, 0, &datalen);
972 : 1201637 : tuplelen = datalen - SizeOfHeapHeader;
973 : :
974 : 1201637 : change->data.tp.newtuple =
626 heikki.linnakangas@i 975 : 1201637 : ReorderBufferAllocTupleBuf(ctx->reorder, tuplelen);
976 : :
2922 tomas.vondra@postgre 977 : 1201637 : DecodeXLogTuple(tupledata, datalen, change->data.tp.newtuple);
978 : :
4528 andres@anarazel.de 979 : 1201637 : change->data.tp.clear_toast_afterwards = true;
980 : :
2303 akapila@postgresql.o 981 : 1201637 : ReorderBufferQueueChange(ctx->reorder, XLogRecGetXid(r), buf->origptr,
982 : : change,
983 : 1201637 : xlrec->flags & XLH_INSERT_ON_TOAST_RELATION);
984 : : }
985 : :
986 : : /*
987 : : * Parse XLOG_HEAP_UPDATE and XLOG_HEAP_HOT_UPDATE, which have the same layout
988 : : * in the record, from wal into proper tuplebufs.
989 : : *
990 : : * Updates can possibly contain a new tuple and the old primary key.
991 : : */
992 : : static void
4653 rhaas@postgresql.org 993 : 149060 : DecodeUpdate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
994 : : {
4391 heikki.linnakangas@i 995 : 149060 : XLogReaderState *r = buf->record;
996 : : xl_heap_update *xlrec;
997 : : ReorderBufferChange *change;
998 : : char *data;
999 : : RelFileLocator target_locator;
1000 : :
1001 : 149060 : xlrec = (xl_heap_update *) XLogRecGetData(r);
1002 : :
1003 : : /*
1004 : : * Ignore update records without a new tuple. This happens when the update
1005 : : * is done on a catalog relation, or when the caller of heap_update()
1006 : : * asked for the change not to be decoded, as REPACK (CONCURRENTLY) does
1007 : : * for the transient heap.
1008 : : */
78 msawada@postgresql.o 1009 [ + + ]: 149060 : if (!(xlrec->flags & XLH_UPDATE_CONTAINS_NEW_TUPLE))
1010 : 2509 : return;
1011 : :
1012 : : /* only interested in our database */
1606 rhaas@postgresql.org 1013 : 146553 : XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
1014 [ - + ]: 146553 : if (target_locator.dbOid != ctx->slot->data.database)
4653 rhaas@postgresql.org 1015 :UBC 0 : return;
1016 : :
1017 : : /* output plugin doesn't look for this origin, no need to queue */
4231 andres@anarazel.de 1018 [ + + ]:CBC 146553 : if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
1019 : 2 : return;
1020 : :
626 heikki.linnakangas@i 1021 : 146551 : change = ReorderBufferAllocChange(ctx->reorder);
4653 rhaas@postgresql.org 1022 : 146551 : change->action = REORDER_BUFFER_CHANGE_UPDATE;
4231 andres@anarazel.de 1023 : 146551 : change->origin_id = XLogRecGetOrigin(r);
1606 rhaas@postgresql.org 1024 : 146551 : memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
1025 : :
4222 andres@anarazel.de 1026 [ + - ]: 146551 : if (xlrec->flags & XLH_UPDATE_CONTAINS_NEW_TUPLE)
1027 : : {
1028 : : Size datalen;
1029 : : Size tuplelen;
1030 : :
4391 heikki.linnakangas@i 1031 : 146551 : data = XLogRecGetBlockData(r, 0, &datalen);
1032 : :
3918 andres@anarazel.de 1033 : 146551 : tuplelen = datalen - SizeOfHeapHeader;
1034 : :
3920 1035 : 146551 : change->data.tp.newtuple =
626 heikki.linnakangas@i 1036 : 146551 : ReorderBufferAllocTupleBuf(ctx->reorder, tuplelen);
1037 : :
4391 1038 : 146551 : DecodeXLogTuple(data, datalen, change->data.tp.newtuple);
1039 : : }
1040 : :
4222 andres@anarazel.de 1041 [ + + ]: 146551 : if (xlrec->flags & XLH_UPDATE_CONTAINS_OLD)
1042 : : {
1043 : : Size datalen;
1044 : : Size tuplelen;
1045 : :
1046 : : /* caution, remaining data in record is not aligned */
4391 heikki.linnakangas@i 1047 : 469 : data = XLogRecGetData(r) + SizeOfHeapUpdate;
1048 : 469 : datalen = XLogRecGetDataLen(r) - SizeOfHeapUpdate;
3918 andres@anarazel.de 1049 : 469 : tuplelen = datalen - SizeOfHeapHeader;
1050 : :
3920 1051 : 469 : change->data.tp.oldtuple =
626 heikki.linnakangas@i 1052 : 469 : ReorderBufferAllocTupleBuf(ctx->reorder, tuplelen);
1053 : :
4391 1054 : 469 : DecodeXLogTuple(data, datalen, change->data.tp.oldtuple);
1055 : : }
1056 : :
4528 andres@anarazel.de 1057 : 146551 : change->data.tp.clear_toast_afterwards = true;
1058 : :
2303 akapila@postgresql.o 1059 : 146551 : ReorderBufferQueueChange(ctx->reorder, XLogRecGetXid(r), buf->origptr,
1060 : : change, false);
1061 : : }
1062 : :
1063 : : /*
1064 : : * Parse XLOG_HEAP_DELETE from wal into proper tuplebufs.
1065 : : *
1066 : : * Deletes can possibly contain the old primary key.
1067 : : */
1068 : : static void
4653 rhaas@postgresql.org 1069 : 226150 : DecodeDelete(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
1070 : : {
4391 heikki.linnakangas@i 1071 : 226150 : XLogReaderState *r = buf->record;
1072 : : xl_heap_delete *xlrec;
1073 : : ReorderBufferChange *change;
1074 : : RelFileLocator target_locator;
1075 : :
1076 : 226150 : xlrec = (xl_heap_delete *) XLogRecGetData(r);
1077 : :
1078 : : /*
1079 : : * Skip changes that were marked as ignorable at origin.
1080 : : *
1081 : : * (This is used for changes that affect relations not visible to other
1082 : : * transactions, such as the transient table during concurrent repack.)
1083 : : */
236 alvherre@kurilemu.de 1084 [ - + ]: 226150 : if (xlrec->flags & XLH_DELETE_NO_LOGICAL)
1085 : 75 : return;
1086 : :
1087 : : /* only interested in our database */
1606 rhaas@postgresql.org 1088 : 226150 : XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
1089 [ + + ]: 226150 : if (target_locator.dbOid != ctx->slot->data.database)
4653 1090 : 61 : return;
1091 : :
1092 : : /* output plugin doesn't look for this origin, no need to queue */
4231 andres@anarazel.de 1093 [ + + ]: 226089 : if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
1094 : 14 : return;
1095 : :
626 heikki.linnakangas@i 1096 : 226075 : change = ReorderBufferAllocChange(ctx->reorder);
1097 : :
1992 akapila@postgresql.o 1098 [ - + ]: 226075 : if (xlrec->flags & XLH_DELETE_IS_SUPER)
1992 akapila@postgresql.o 1099 :UBC 0 : change->action = REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT;
1100 : : else
1992 akapila@postgresql.o 1101 :CBC 226075 : change->action = REORDER_BUFFER_CHANGE_DELETE;
1102 : :
4231 andres@anarazel.de 1103 : 226075 : change->origin_id = XLogRecGetOrigin(r);
1104 : :
1606 rhaas@postgresql.org 1105 : 226075 : memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
1106 : :
1107 : : /* old primary key stored */
4222 andres@anarazel.de 1108 [ + + ]: 226075 : if (xlrec->flags & XLH_DELETE_CONTAINS_OLD)
1109 : : {
3918 1110 : 155941 : Size datalen = XLogRecGetDataLen(r) - SizeOfHeapDelete;
1111 : 155941 : Size tuplelen = datalen - SizeOfHeapHeader;
1112 : :
4391 heikki.linnakangas@i 1113 [ - + ]: 155941 : Assert(XLogRecGetDataLen(r) > (SizeOfHeapDelete + SizeOfHeapHeader));
1114 : :
3920 andres@anarazel.de 1115 : 155941 : change->data.tp.oldtuple =
626 heikki.linnakangas@i 1116 : 155941 : ReorderBufferAllocTupleBuf(ctx->reorder, tuplelen);
1117 : :
4653 rhaas@postgresql.org 1118 : 155941 : DecodeXLogTuple((char *) xlrec + SizeOfHeapDelete,
1119 : : datalen, change->data.tp.oldtuple);
1120 : : }
1121 : :
4528 andres@anarazel.de 1122 : 226075 : change->data.tp.clear_toast_afterwards = true;
1123 : :
2303 akapila@postgresql.o 1124 : 226075 : ReorderBufferQueueChange(ctx->reorder, XLogRecGetXid(r), buf->origptr,
1125 : : change, false);
1126 : : }
1127 : :
1128 : : /*
1129 : : * Parse XLOG_HEAP_TRUNCATE from wal
1130 : : */
1131 : : static void
3157 peter_e@gmx.net 1132 : 62 : DecodeTruncate(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
1133 : : {
1134 : 62 : XLogReaderState *r = buf->record;
1135 : : xl_heap_truncate *xlrec;
1136 : : ReorderBufferChange *change;
1137 : :
1138 : 62 : xlrec = (xl_heap_truncate *) XLogRecGetData(r);
1139 : :
1140 : : /* only interested in our database */
1141 [ - + ]: 62 : if (xlrec->dbId != ctx->slot->data.database)
3157 peter_e@gmx.net 1142 :UBC 0 : return;
1143 : :
1144 : : /* output plugin doesn't look for this origin, no need to queue */
3157 peter_e@gmx.net 1145 [ + + ]:CBC 62 : if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
1146 : 1 : return;
1147 : :
626 heikki.linnakangas@i 1148 : 61 : change = ReorderBufferAllocChange(ctx->reorder);
3157 peter_e@gmx.net 1149 : 61 : change->action = REORDER_BUFFER_CHANGE_TRUNCATE;
1150 : 61 : change->origin_id = XLogRecGetOrigin(r);
1151 [ + + ]: 61 : if (xlrec->flags & XLH_TRUNCATE_CASCADE)
1152 : 1 : change->data.truncate.cascade = true;
1153 [ + + ]: 61 : if (xlrec->flags & XLH_TRUNCATE_RESTART_SEQS)
1154 : 2 : change->data.truncate.restart_seqs = true;
1155 : 61 : change->data.truncate.nrelids = xlrec->nrelids;
626 heikki.linnakangas@i 1156 : 122 : change->data.truncate.relids = ReorderBufferAllocRelids(ctx->reorder,
1157 : 61 : xlrec->nrelids);
3157 peter_e@gmx.net 1158 : 61 : memcpy(change->data.truncate.relids, xlrec->relids,
1159 : 61 : xlrec->nrelids * sizeof(Oid));
1160 : 61 : ReorderBufferQueueChange(ctx->reorder, XLogRecGetXid(r),
1161 : : buf->origptr, change, false);
1162 : : }
1163 : :
1164 : : /*
1165 : : * Decode XLOG_HEAP2_MULTI_INSERT record into multiple tuplebufs.
1166 : : *
1167 : : * Currently MULTI_INSERT will always contain the full tuples.
1168 : : */
1169 : : static void
4653 rhaas@postgresql.org 1170 : 8453 : DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
1171 : : {
4391 heikki.linnakangas@i 1172 : 8453 : XLogReaderState *r = buf->record;
1173 : : xl_heap_multi_insert *xlrec;
1174 : : int i;
1175 : : char *data;
1176 : : char *tupledata;
1177 : : Size tuplelen;
1178 : : RelFileLocator rlocator;
1179 : :
1180 : 8453 : xlrec = (xl_heap_multi_insert *) XLogRecGetData(r);
1181 : :
1182 : : /*
1183 : : * Ignore insert records without new tuples. This happens when a
1184 : : * multi_insert is done on a catalog or on a non-persistent relation.
1185 : : */
2462 michael@paquier.xyz 1186 [ + + ]: 8453 : if (!(xlrec->flags & XLH_INSERT_CONTAINS_NEW_TUPLE))
1187 : 8433 : return;
1188 : :
1189 : : /* only interested in our database */
1606 rhaas@postgresql.org 1190 : 93 : XLogRecGetBlockTag(r, 0, &rlocator, NULL, NULL);
1191 [ + + ]: 93 : if (rlocator.dbOid != ctx->slot->data.database)
4653 1192 : 73 : return;
1193 : :
1194 : : /* output plugin doesn't look for this origin, no need to queue */
4231 andres@anarazel.de 1195 [ - + ]: 20 : if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
4231 andres@anarazel.de 1196 :UBC 0 : return;
1197 : :
1198 : : /*
1199 : : * We know that this multi_insert isn't for a catalog, so the block should
1200 : : * always have data even if a full-page write of it is taken.
1201 : : */
4391 heikki.linnakangas@i 1202 :CBC 20 : tupledata = XLogRecGetBlockData(r, 0, &tuplelen);
2670 michael@paquier.xyz 1203 [ - + ]: 20 : Assert(tupledata != NULL);
1204 : :
4391 heikki.linnakangas@i 1205 : 20 : data = tupledata;
4653 rhaas@postgresql.org 1206 [ + + ]: 1294 : for (i = 0; i < xlrec->ntuples; i++)
1207 : : {
1208 : : ReorderBufferChange *change;
1209 : : xl_multi_insert_tuple *xlhdr;
1210 : : int datalen;
1211 : : HeapTuple tuple;
1212 : : HeapTupleHeader header;
1213 : :
626 heikki.linnakangas@i 1214 : 1274 : change = ReorderBufferAllocChange(ctx->reorder);
4653 rhaas@postgresql.org 1215 : 1274 : change->action = REORDER_BUFFER_CHANGE_INSERT;
4231 andres@anarazel.de 1216 : 1274 : change->origin_id = XLogRecGetOrigin(r);
1217 : :
1606 rhaas@postgresql.org 1218 : 1274 : memcpy(&change->data.tp.rlocator, &rlocator, sizeof(RelFileLocator));
1219 : :
2670 michael@paquier.xyz 1220 : 1274 : xlhdr = (xl_multi_insert_tuple *) SHORTALIGN(data);
1221 : 1274 : data = ((char *) xlhdr) + SizeOfMultiInsertTuple;
1222 : 1274 : datalen = xlhdr->datalen;
1223 : :
2462 1224 : 1274 : change->data.tp.newtuple =
626 heikki.linnakangas@i 1225 : 1274 : ReorderBufferAllocTupleBuf(ctx->reorder, datalen);
1226 : :
2462 michael@paquier.xyz 1227 : 1274 : tuple = change->data.tp.newtuple;
1034 msawada@postgresql.o 1228 : 1274 : header = tuple->t_data;
1229 : :
1230 : : /* not a disk based tuple */
1231 : 1274 : ItemPointerSetInvalid(&tuple->t_self);
1232 : :
1233 : : /*
1234 : : * We can only figure this out after reassembling the transactions.
1235 : : */
1236 : 1274 : tuple->t_tableOid = InvalidOid;
1237 : :
1238 : 1274 : tuple->t_len = datalen + SizeofHeapTupleHeader;
1239 : :
2462 michael@paquier.xyz 1240 : 1274 : memset(header, 0, SizeofHeapTupleHeader);
1241 : :
654 peter@eisentraut.org 1242 : 1274 : memcpy((char *) tuple->t_data + SizeofHeapTupleHeader, data, datalen);
2462 michael@paquier.xyz 1243 : 1274 : header->t_infomask = xlhdr->t_infomask;
1244 : 1274 : header->t_infomask2 = xlhdr->t_infomask2;
1245 : 1274 : header->t_hoff = xlhdr->t_hoff;
1246 : :
1247 : : /*
1248 : : * Reset toast reassembly state only after the last row in the last
1249 : : * xl_multi_insert_tuple record emitted by one heap_multi_insert()
1250 : : * call.
1251 : : */
4222 andres@anarazel.de 1252 [ + + ]: 1274 : if (xlrec->flags & XLH_INSERT_LAST_IN_MULTI &&
4522 1253 [ + + ]: 242 : (i + 1) == xlrec->ntuples)
1254 : 14 : change->data.tp.clear_toast_afterwards = true;
1255 : : else
1256 : 1260 : change->data.tp.clear_toast_afterwards = false;
1257 : :
4391 heikki.linnakangas@i 1258 : 1274 : ReorderBufferQueueChange(ctx->reorder, XLogRecGetXid(r),
1259 : : buf->origptr, change, false);
1260 : :
1261 : : /* move to the next xl_multi_insert_tuple entry */
2670 michael@paquier.xyz 1262 : 1274 : data += datalen;
1263 : : }
4391 heikki.linnakangas@i 1264 [ - + ]: 20 : Assert(data == tupledata + tuplelen);
1265 : : }
1266 : :
1267 : : /*
1268 : : * Parse XLOG_HEAP_CONFIRM from wal into a confirmation change.
1269 : : *
1270 : : * This is pretty trivial, all the state essentially already setup by the
1271 : : * speculative insertion.
1272 : : */
1273 : : static void
4222 andres@anarazel.de 1274 : 19702 : DecodeSpecConfirm(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
1275 : : {
1276 : 19702 : XLogReaderState *r = buf->record;
1277 : : ReorderBufferChange *change;
1278 : : RelFileLocator target_locator;
1279 : :
1280 : : /* only interested in our database */
1606 rhaas@postgresql.org 1281 : 19702 : XLogRecGetBlockTag(r, 0, &target_locator, NULL, NULL);
1282 [ - + ]: 19702 : if (target_locator.dbOid != ctx->slot->data.database)
4222 andres@anarazel.de 1283 :UBC 0 : return;
1284 : :
1285 : : /* output plugin doesn't look for this origin, no need to queue */
4222 andres@anarazel.de 1286 [ - + ]:CBC 19702 : if (FilterByOrigin(ctx, XLogRecGetOrigin(r)))
4222 andres@anarazel.de 1287 :UBC 0 : return;
1288 : :
626 heikki.linnakangas@i 1289 :CBC 19702 : change = ReorderBufferAllocChange(ctx->reorder);
4222 andres@anarazel.de 1290 : 19702 : change->action = REORDER_BUFFER_CHANGE_INTERNAL_SPEC_CONFIRM;
1291 : 19702 : change->origin_id = XLogRecGetOrigin(r);
1292 : :
1606 rhaas@postgresql.org 1293 : 19702 : memcpy(&change->data.tp.rlocator, &target_locator, sizeof(RelFileLocator));
1294 : :
4222 andres@anarazel.de 1295 : 19702 : change->data.tp.clear_toast_afterwards = true;
1296 : :
2303 akapila@postgresql.o 1297 : 19702 : ReorderBufferQueueChange(ctx->reorder, XLogRecGetXid(r), buf->origptr,
1298 : : change, false);
1299 : : }
1300 : :
1301 : :
1302 : : /*
1303 : : * Read a HeapTuple as WAL logged by heap_insert, heap_update and heap_delete
1304 : : * (but not by heap_multi_insert) into a tuplebuf.
1305 : : *
1306 : : * The size 'len' and the pointer 'data' in the record need to be
1307 : : * computed outside as they are record specific.
1308 : : */
1309 : : static void
1034 msawada@postgresql.o 1310 : 1504598 : DecodeXLogTuple(char *data, Size len, HeapTuple tuple)
1311 : : {
1312 : : xl_heap_header xlhdr;
4653 rhaas@postgresql.org 1313 : 1504598 : int datalen = len - SizeOfHeapHeader;
1314 : : HeapTupleHeader header;
1315 : :
1316 [ - + ]: 1504598 : Assert(datalen >= 0);
1317 : :
1034 msawada@postgresql.o 1318 : 1504598 : tuple->t_len = datalen + SizeofHeapTupleHeader;
1319 : 1504598 : header = tuple->t_data;
1320 : :
1321 : : /* not a disk based tuple */
1322 : 1504598 : ItemPointerSetInvalid(&tuple->t_self);
1323 : :
1324 : : /* we can only figure this out after reassembling the transactions */
1325 : 1504598 : tuple->t_tableOid = InvalidOid;
1326 : :
1327 : : /* data is not stored aligned, copy to aligned storage */
654 peter@eisentraut.org 1328 : 1504598 : memcpy(&xlhdr, data, SizeOfHeapHeader);
1329 : :
3920 andres@anarazel.de 1330 : 1504598 : memset(header, 0, SizeofHeapTupleHeader);
1331 : :
1034 msawada@postgresql.o 1332 : 1504598 : memcpy(((char *) tuple->t_data) + SizeofHeapTupleHeader,
4653 rhaas@postgresql.org 1333 : 1504598 : data + SizeOfHeapHeader,
1334 : : datalen);
1335 : :
3920 andres@anarazel.de 1336 : 1504598 : header->t_infomask = xlhdr.t_infomask;
1337 : 1504598 : header->t_infomask2 = xlhdr.t_infomask2;
1338 : 1504598 : header->t_hoff = xlhdr.t_hoff;
4653 rhaas@postgresql.org 1339 : 1504598 : }
1340 : :
1341 : : /*
1342 : : * Check whether we are interested in this specific transaction.
1343 : : *
1344 : : * There can be several reasons we might not be interested in this
1345 : : * transaction:
1346 : : * 1) We might not be interested in decoding transactions up to this
1347 : : * LSN. This can happen because we previously decoded it and now just
1348 : : * are restarting or if we haven't assembled a consistent snapshot yet.
1349 : : * 2) The transaction happened in another database.
1350 : : * 3) The output plugin is not interested in the origin.
1351 : : * 4) We are doing fast-forwarding
1352 : : */
1353 : : static bool
2154 akapila@postgresql.o 1354 : 5326 : DecodeTXNNeedSkip(LogicalDecodingContext *ctx, XLogRecordBuffer *buf,
1355 : : Oid txn_dbid, ReplOriginId origin_id)
1356 : : {
1129 1357 [ + + + + ]: 5326 : if (SnapBuildXactNeedsSkip(ctx->snapshot_builder, buf->origptr) ||
1358 [ + + + + ]: 5793 : (txn_dbid != InvalidOid && txn_dbid != ctx->slot->data.database) ||
1359 : 2924 : FilterByOrigin(ctx, origin_id))
1360 : 2459 : return true;
1361 : :
1362 : : /*
1363 : : * We also skip decoding in fast_forward mode. In passing set the
1364 : : * processing_required flag to indicate that if it were not for
1365 : : * fast_forward mode, processing would have been required.
1366 : : */
1367 [ + + ]: 2867 : if (ctx->fast_forward)
1368 : : {
1369 : 43 : ctx->processing_required = true;
1370 : 43 : return true;
1371 : : }
1372 : :
1373 : 2824 : return false;
1374 : : }
|