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
"
20
#include "
storage/sharedfileset.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
*/
27
typedef
char
ConcurrentChangeKind
;
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
*/
40
typedef
struct
RepackDecodingState
41
{
42
/* The relation whose changes we're decoding. */
43
Oid
relid
;
44
45
/* Per-change memory context. */
46
MemoryContext
change_cxt
;
47
48
/* A tuple slot used to pass tuples back and forth */
49
TupleTableSlot
*
slot
;
50
51
/*
52
* Memory context and resource owner of the decoding worker's transaction.
53
*/
54
MemoryContext
worker_cxt
;
55
ResourceOwner
worker_resowner
;
56
57
/* The current output file. */
58
BufFile
*
file
;
59
}
RepackDecodingState
;
60
61
/*
62
* Shared memory used for communication between the backend running REPACK and
63
* the worker that performs logical decoding of data changes.
64
*/
65
typedef
struct
DecodingWorkerShared
66
{
67
/* Is the decoding initialized? */
68
bool
initialized
;
69
70
/*
71
* Once the worker has reached this LSN, it should close the current
72
* output file and either create a new one or exit, according to the field
73
* 'done'. If the value is InvalidXLogRecPtr, the worker should decode all
74
* the WAL available and keep checking this field. It is ok if the worker
75
* had already decoded records whose LSN is >= lsn_upto before this field
76
* has been set.
77
*/
78
XLogRecPtr
lsn_upto
;
79
80
/* Exit after closing the current file? */
81
bool
done
;
82
83
/* The output is stored here. */
84
SharedFileSet
sfs
;
85
86
/* Number of the last file exported by the worker. */
87
int
last_exported
;
88
89
/* Synchronize access to the fields above. */
90
slock_t
mutex
;
91
92
/* Database to connect to. */
93
Oid
dbid
;
94
95
/* Role to connect as. */
96
Oid
roleid
;
97
98
/* Relation from which data changes to decode. */
99
Oid
relid
;
100
101
/* CV the backend waits on */
102
ConditionVariable
cv
;
103
104
/* Info to signal the backend. */
105
PGPROC
*
backend_proc
;
106
pid_t
backend_pid
;
107
ProcNumber
backend_proc_number
;
108
109
/*
110
* Memory the queue is located in.
111
*
112
* For considerations on the value see the comments of
113
* PARALLEL_ERROR_QUEUE_SIZE.
114
*/
115
#define REPACK_ERROR_QUEUE_SIZE 16384
116
char
error_queue
[
FLEXIBLE_ARRAY_MEMBER
];
117
}
DecodingWorkerShared
;
118
119
extern
void
DecodingWorkerFileName
(
char
*fname,
Oid
relid,
uint32
seq
);
120
121
122
#endif
/* REPACK_INTERNAL_H */
bgworker.h
buffile.h
FLEXIBLE_ARRAY_MEMBER
#define FLEXIBLE_ARRAY_MEMBER
Definition
c.h:558
uint32
uint32_t uint32
Definition
c.h:624
decode.h
execnodes.h
logical.h
Oid
unsigned int Oid
Definition
postgres_ext.h:32
fb
static int fb(int x)
Definition
preproc-init.c:92
ProcNumber
int ProcNumber
Definition
procnumber.h:24
DecodingWorkerFileName
void DecodingWorkerFileName(char *fname, Oid relid, uint32 seq)
Definition
repack.c:3641
ConcurrentChangeKind
char ConcurrentChangeKind
Definition
repack_internal.h:27
resowner.h
sharedfileset.h
shm_mq.h
BufFile
Definition
buffile.c:72
ConditionVariable
Definition
condition_variable.h:29
DecodingWorkerShared
Definition
repack_internal.h:66
DecodingWorkerShared::sfs
SharedFileSet sfs
Definition
repack_internal.h:84
DecodingWorkerShared::initialized
bool initialized
Definition
repack_internal.h:68
DecodingWorkerShared::cv
ConditionVariable cv
Definition
repack_internal.h:102
DecodingWorkerShared::roleid
Oid roleid
Definition
repack_internal.h:96
DecodingWorkerShared::done
bool done
Definition
repack_internal.h:81
DecodingWorkerShared::relid
Oid relid
Definition
repack_internal.h:99
DecodingWorkerShared::lsn_upto
XLogRecPtr lsn_upto
Definition
repack_internal.h:78
DecodingWorkerShared::mutex
slock_t mutex
Definition
repack_internal.h:90
DecodingWorkerShared::backend_pid
pid_t backend_pid
Definition
repack_internal.h:106
DecodingWorkerShared::last_exported
int last_exported
Definition
repack_internal.h:87
DecodingWorkerShared::error_queue
char error_queue[FLEXIBLE_ARRAY_MEMBER]
Definition
repack_internal.h:116
DecodingWorkerShared::backend_proc_number
ProcNumber backend_proc_number
Definition
repack_internal.h:107
DecodingWorkerShared::backend_proc
PGPROC * backend_proc
Definition
repack_internal.h:105
DecodingWorkerShared::dbid
Oid dbid
Definition
repack_internal.h:93
MemoryContextData
Definition
memnodes.h:118
PGPROC
Definition
proc.h:179
RepackDecodingState
Definition
repack_internal.h:41
RepackDecodingState::file
BufFile * file
Definition
repack_internal.h:58
RepackDecodingState::worker_cxt
MemoryContext worker_cxt
Definition
repack_internal.h:54
RepackDecodingState::worker_resowner
ResourceOwner worker_resowner
Definition
repack_internal.h:55
RepackDecodingState::change_cxt
MemoryContext change_cxt
Definition
repack_internal.h:46
RepackDecodingState::slot
TupleTableSlot * slot
Definition
repack_internal.h:49
RepackDecodingState::relid
Oid relid
Definition
repack_internal.h:43
ResourceOwnerData
Definition
resowner.c:113
SharedFileSet
Definition
sharedfileset.h:27
TupleTableSlot
Definition
tuptable.h:121
XLogRecPtr
uint64 XLogRecPtr
Definition
xlogdefs.h:21
src
include
commands
repack_internal.h
Generated on Thu Jun 11 2026 19:13:17 for PostgreSQL Source Code by
1.9.8