summaryrefslogtreecommitdiffstats
path: root/src/backend/backup/basebackup_sink.c
blob: 4536029d847b62ed484501a8228d69ee014eab88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*-------------------------------------------------------------------------
 *
 * basebackup_sink.c
 *	  Default implementations for bbsink (basebackup sink) callbacks.
 *
 * Portions Copyright (c) 2010-2022, PostgreSQL Global Development Group
 *
 * src/backend/backup/basebackup_sink.c
 *
 *-------------------------------------------------------------------------
 */

#include "postgres.h"

#include "backup/basebackup_sink.h"

/*
 * Forward begin_backup callback.
 *
 * Only use this implementation if you want the bbsink you're implementing to
 * share a buffer with the successor bbsink.
 */
void
bbsink_forward_begin_backup(bbsink *sink)
{
	Assert(sink->bbs_next != NULL);
	Assert(sink->bbs_state != NULL);
	bbsink_begin_backup(sink->bbs_next, sink->bbs_state,
						sink->bbs_buffer_length);
	sink->bbs_buffer = sink->bbs_next->bbs_buffer;
}

/*
 * Forward begin_archive callback.
 */
void
bbsink_forward_begin_archive(bbsink *sink, const char *archive_name)
{
	Assert(sink->bbs_next != NULL);
	bbsink_begin_archive(sink->bbs_next, archive_name);
}

/*
 * Forward archive_contents callback.
 *
 * Code that wants to use this should initialize its own bbs_buffer and
 * bbs_buffer_length fields to the values from the successor sink. In cases
 * where the buffer isn't shared, the data needs to be copied before forwarding
 * the callback. We don't do try to do that here, because there's really no
 * reason to have separately allocated buffers containing the same identical
 * data.
 */
void
bbsink_forward_archive_contents(bbsink *sink, size_t len)
{
	Assert(sink->bbs_next != NULL);
	Assert(sink->bbs_buffer == sink->bbs_next->bbs_buffer);
	Assert(sink->bbs_buffer_length == sink->bbs_next->bbs_buffer_length);
	bbsink_archive_contents(sink->bbs_next, len);
}

/*
 * Forward end_archive callback.
 */
void
bbsink_forward_end_archive(bbsink *sink)
{
	Assert(sink->bbs_next != NULL);
	bbsink_end_archive(sink->bbs_next);
}

/*
 * Forward begin_manifest callback.
 */
void
bbsink_forward_begin_manifest(bbsink *sink)
{
	Assert(sink->bbs_next != NULL);
	bbsink_begin_manifest(sink->bbs_next);
}

/*
 * Forward manifest_contents callback.
 *
 * As with the archive_contents callback, it's expected that the buffer is
 * shared.
 */
void
bbsink_forward_manifest_contents(bbsink *sink, size_t len)
{
	Assert(sink->bbs_next != NULL);
	Assert(sink->bbs_buffer == sink->bbs_next->bbs_buffer);
	Assert(sink->bbs_buffer_length == sink->bbs_next->bbs_buffer_length);
	bbsink_manifest_contents(sink->bbs_next, len);
}

/*
 * Forward end_manifest callback.
 */
void
bbsink_forward_end_manifest(bbsink *sink)
{
	Assert(sink->bbs_next != NULL);
	bbsink_end_manifest(sink->bbs_next);
}

/*
 * Forward end_backup callback.
 */
void
bbsink_forward_end_backup(bbsink *sink, XLogRecPtr endptr, TimeLineID endtli)
{
	Assert(sink->bbs_next != NULL);
	bbsink_end_backup(sink->bbs_next, endptr, endtli);
}

/*
 * Forward cleanup callback.
 */
void
bbsink_forward_cleanup(bbsink *sink)
{
	Assert(sink->bbs_next != NULL);
	bbsink_cleanup(sink->bbs_next);
}