PostgreSQL Source Code git master
Loading...
Searching...
No Matches
repack_internal.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * repack_internal.h
4 * header for REPACK internals
5 *
6 * Copyright (c) 2026, PostgreSQL Global Development Group
7 *
8 * src/include/commands/repack_internal.h
9 *
10 *-------------------------------------------------------------------------
11 */
12#ifndef REPACK_INTERNAL_H
13#define REPACK_INTERNAL_H
14
15#include "nodes/execnodes.h"
16#include "replication/decode.h"
17#include "postmaster/bgworker.h"
18#include "replication/logical.h"
19#include "storage/buffile.h"
21#include "storage/shm_mq.h"
22#include "utils/resowner.h"
23
24/*
25 * The type of a change stored in the output files.
26 */
28
29#define CHANGE_INSERT 'i'
30#define CHANGE_UPDATE_OLD 'u'
31#define CHANGE_UPDATE_NEW 'U'
32#define CHANGE_DELETE 'd'
33
34/*
35 * Logical decoding state.
36 *
37 * The output plugin uses it to store the data changes that it decodes from
38 * WAL while the table contents is being copied to a new storage.
39 */
40typedef struct RepackDecodingState
41{
42#ifdef USE_ASSERT_CHECKING
43 /* The relation whose changes we're decoding. */
44 Oid relid;
45#endif
46
47 /* Per-change memory context. */
49
50 /* A tuple slot used to pass tuples back and forth */
52
53 /*
54 * Memory context and resource owner of the decoding worker's transaction.
55 */
58
59 /* The current output file. */
62
63/*
64 * Shared memory used for communication between the backend running REPACK and
65 * the worker that performs logical decoding of data changes.
66 */
68{
69 /* Is the decoding initialized? */
71
72 /*
73 * Once the worker has reached this LSN, it should close the current
74 * output file and either create a new one or exit, according to the field
75 * 'done'. If the value is InvalidXLogRecPtr, the worker should decode all
76 * the WAL available and keep checking this field. It is ok if the worker
77 * had already decoded records whose LSN is >= lsn_upto before this field
78 * has been set.
79 */
81
82 /* Exit after closing the current file? */
83 bool done;
84
85 /* The output is stored here. */
87
88 /* Number of the last file exported by the worker. */
90
91 /* Synchronize access to the fields above. */
93
94 /* Database to connect to. */
96
97 /* Role to connect as. */
99
100 /* Relation from which data changes to decode. */
102
103 /* CV the backend waits on */
105
106 /* Info to signal the backend. */
111
112 /*
113 * Memory the queue is located in.
114 *
115 * For considerations on the value see the comments of
116 * PARALLEL_ERROR_QUEUE_SIZE.
117 */
118#define REPACK_ERROR_QUEUE_SIZE 16384
121
122extern void DecodingWorkerFileName(char *fname, Oid relid, uint32 seq);
123
124
125#endif /* REPACK_INTERNAL_H */
#define FLEXIBLE_ARRAY_MEMBER
Definition c.h:558
uint32_t uint32
Definition c.h:624
unsigned int Oid
static int fb(int x)
int ProcNumber
Definition procnumber.h:24
void DecodingWorkerFileName(char *fname, Oid relid, uint32 seq)
Definition repack.c:3494
char ConcurrentChangeKind
ConditionVariable cv
char error_queue[FLEXIBLE_ARRAY_MEMBER]
Definition proc.h:179
MemoryContext worker_cxt
ResourceOwner worker_resowner
MemoryContext change_cxt
TupleTableSlot * slot
uint64 XLogRecPtr
Definition xlogdefs.h:21