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
#ifdef USE_ASSERT_CHECKING
43
/* The relation whose changes we're decoding. */
44
Oid
relid;
45
#endif
46
47
/* Per-change memory context. */
48
MemoryContext
change_cxt
;
49
50
/* A tuple slot used to pass tuples back and forth */
51
TupleTableSlot
*
slot
;
52
53
/*
54
* Memory context and resource owner of the decoding worker's transaction.
55
*/
56
MemoryContext
worker_cxt
;
57
ResourceOwner
worker_resowner
;
58
59
/* The current output file. */
60
BufFile
*
file
;
61
}
RepackDecodingState
;
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
*/
67
typedef
struct
DecodingWorkerShared
68
{
69
/* Is the decoding initialized? */
70
bool
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
*/
80
XLogRecPtr
lsn_upto
;
81
82
/* Exit after closing the current file? */
83
bool
done
;
84
85
/* The output is stored here. */
86
SharedFileSet
sfs
;
87
88
/* Number of the last file exported by the worker. */
89
int
last_exported
;
90
91
/* Synchronize access to the fields above. */
92
slock_t
mutex
;
93
94
/* Database to connect to. */
95
Oid
dbid
;
96
97
/* Role to connect as. */
98
Oid
roleid
;
99
100
/* Relation from which data changes to decode. */
101
Oid
relid
;
102
103
/* CV the backend waits on */
104
ConditionVariable
cv
;
105
106
/* Info to signal the backend. */
107
PGPROC
*
backend_proc
;
108
pid_t
backend_pid
;
109
ProcNumber
backend_proc_number
;
110
dsm_segment
*
dsm_seg
;
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
119
char
error_queue
[
FLEXIBLE_ARRAY_MEMBER
];
120
}
DecodingWorkerShared
;
121
122
extern
void
DecodingWorkerFileName
(
char
*fname,
Oid
relid,
uint32
seq
);
123
124
125
#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:3494
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:68
DecodingWorkerShared::sfs
SharedFileSet sfs
Definition
repack_internal.h:86
DecodingWorkerShared::initialized
bool initialized
Definition
repack_internal.h:70
DecodingWorkerShared::cv
ConditionVariable cv
Definition
repack_internal.h:104
DecodingWorkerShared::roleid
Oid roleid
Definition
repack_internal.h:98
DecodingWorkerShared::done
bool done
Definition
repack_internal.h:83
DecodingWorkerShared::relid
Oid relid
Definition
repack_internal.h:101
DecodingWorkerShared::lsn_upto
XLogRecPtr lsn_upto
Definition
repack_internal.h:80
DecodingWorkerShared::mutex
slock_t mutex
Definition
repack_internal.h:92
DecodingWorkerShared::backend_pid
pid_t backend_pid
Definition
repack_internal.h:108
DecodingWorkerShared::dsm_seg
dsm_segment * dsm_seg
Definition
repack_internal.h:110
DecodingWorkerShared::last_exported
int last_exported
Definition
repack_internal.h:89
DecodingWorkerShared::error_queue
char error_queue[FLEXIBLE_ARRAY_MEMBER]
Definition
repack_internal.h:119
DecodingWorkerShared::backend_proc_number
ProcNumber backend_proc_number
Definition
repack_internal.h:109
DecodingWorkerShared::backend_proc
PGPROC * backend_proc
Definition
repack_internal.h:107
DecodingWorkerShared::dbid
Oid dbid
Definition
repack_internal.h:95
MemoryContextData
Definition
memnodes.h:118
PGPROC
Definition
proc.h:179
RepackDecodingState
Definition
repack_internal.h:41
RepackDecodingState::file
BufFile * file
Definition
repack_internal.h:60
RepackDecodingState::worker_cxt
MemoryContext worker_cxt
Definition
repack_internal.h:56
RepackDecodingState::worker_resowner
ResourceOwner worker_resowner
Definition
repack_internal.h:57
RepackDecodingState::change_cxt
MemoryContext change_cxt
Definition
repack_internal.h:48
RepackDecodingState::slot
TupleTableSlot * slot
Definition
repack_internal.h:51
ResourceOwnerData
Definition
resowner.c:113
SharedFileSet
Definition
sharedfileset.h:27
TupleTableSlot
Definition
tuptable.h:121
dsm_segment
Definition
dsm.c:68
XLogRecPtr
uint64 XLogRecPtr
Definition
xlogdefs.h:21
src
include
commands
repack_internal.h
Generated on Tue Apr 7 2026 02:13:16 for PostgreSQL Source Code by
1.9.8