* Parse XLOG_HEAP_DELETE from wal into proper tuplebufs. * * Deletes can possibly contain the old primary key. */
| 971 | * Deletes can possibly contain the old primary key. |
| 972 | */ |
| 973 | static void |
| 974 | DecodeDelete(LogicalDecodingContext *ctx, XLogRecordBuffer *buf) |
| 975 | { |
| 976 | XLogReaderState *r = buf->record; |
| 977 | xl_heap_delete *xlrec; |
| 978 | ReorderBufferChange *change; |
| 979 | RelFileNode target_node; |
| 980 | |
| 981 | xlrec = (xl_heap_delete *) XLogRecGetData(r); |
| 982 | |
| 983 | /* only interested in our database */ |
| 984 | XLogRecGetBlockTag(r, 0, &target_node, NULL, NULL); |
| 985 | if (target_node.dbNode != ctx->slot->data.database) |
| 986 | return; |
| 987 | |
| 988 | /* output plugin doesn't look for this origin, no need to queue */ |
| 989 | if (FilterByOrigin(ctx, XLogRecGetOrigin(r))) |
| 990 | return; |
| 991 | |
| 992 | change = ReorderBufferGetChange(ctx->reorder); |
| 993 | |
| 994 | if (xlrec->flags & XLH_DELETE_IS_SUPER) |
| 995 | change->action = REORDER_BUFFER_CHANGE_INTERNAL_SPEC_ABORT; |
| 996 | else |
| 997 | change->action = REORDER_BUFFER_CHANGE_DELETE; |
| 998 | |
| 999 | change->origin_id = XLogRecGetOrigin(r); |
| 1000 | |
| 1001 | memcpy(&change->data.tp.relnode, &target_node, sizeof(RelFileNode)); |
| 1002 | |
| 1003 | /* old primary key stored */ |
| 1004 | if (xlrec->flags & XLH_DELETE_CONTAINS_OLD) |
| 1005 | { |
| 1006 | Size datalen = XLogRecGetDataLen(r) - SizeOfHeapDelete; |
| 1007 | Size tuplelen = datalen - SizeOfHeapHeader; |
| 1008 | |
| 1009 | Assert(XLogRecGetDataLen(r) > (SizeOfHeapDelete + SizeOfHeapHeader)); |
| 1010 | |
| 1011 | change->data.tp.oldtuple = |
| 1012 | ReorderBufferGetTupleBuf(ctx->reorder, tuplelen); |
| 1013 | |
| 1014 | DecodeXLogTuple((char *) xlrec + SizeOfHeapDelete, |
| 1015 | datalen, change->data.tp.oldtuple); |
| 1016 | } |
| 1017 | |
| 1018 | change->data.tp.clear_toast_afterwards = true; |
| 1019 | |
| 1020 | ReorderBufferQueueChange(ctx->reorder, XLogRecGetXid(r), buf->origptr, |
| 1021 | change, false); |
| 1022 | } |
| 1023 | |
| 1024 | /* |
| 1025 | * Parse XLOG_HEAP_TRUNCATE from wal |
no test coverage detected