PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
basebackup_sink.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * basebackup_sink.c
4 * Default implementations for bbsink (basebackup sink) callbacks.
5 *
6 * Portions Copyright (c) 2010-2025, PostgreSQL Global Development Group
7 *
8 * src/backend/backup/basebackup_sink.c
9 *
10 *-------------------------------------------------------------------------
11 */
12
13#include "postgres.h"
14
16
17/*
18 * Forward begin_backup callback.
19 *
20 * Only use this implementation if you want the bbsink you're implementing to
21 * share a buffer with the successor bbsink.
22 */
23void
25{
26 Assert(sink->bbs_next != NULL);
27 Assert(sink->bbs_state != NULL);
29 sink->bbs_buffer_length);
30 sink->bbs_buffer = sink->bbs_next->bbs_buffer;
31}
32
33/*
34 * Forward begin_archive callback.
35 */
36void
37bbsink_forward_begin_archive(bbsink *sink, const char *archive_name)
38{
39 Assert(sink->bbs_next != NULL);
40 bbsink_begin_archive(sink->bbs_next, archive_name);
41}
42
43/*
44 * Forward archive_contents callback.
45 *
46 * Code that wants to use this should initialize its own bbs_buffer and
47 * bbs_buffer_length fields to the values from the successor sink. In cases
48 * where the buffer isn't shared, the data needs to be copied before forwarding
49 * the callback. We don't do try to do that here, because there's really no
50 * reason to have separately allocated buffers containing the same identical
51 * data.
52 */
53void
55{
56 Assert(sink->bbs_next != NULL);
57 Assert(sink->bbs_buffer == sink->bbs_next->bbs_buffer);
60}
61
62/*
63 * Forward end_archive callback.
64 */
65void
67{
68 Assert(sink->bbs_next != NULL);
70}
71
72/*
73 * Forward begin_manifest callback.
74 */
75void
77{
78 Assert(sink->bbs_next != NULL);
80}
81
82/*
83 * Forward manifest_contents callback.
84 *
85 * As with the archive_contents callback, it's expected that the buffer is
86 * shared.
87 */
88void
90{
91 Assert(sink->bbs_next != NULL);
92 Assert(sink->bbs_buffer == sink->bbs_next->bbs_buffer);
95}
96
97/*
98 * Forward end_manifest callback.
99 */
100void
102{
103 Assert(sink->bbs_next != NULL);
105}
106
107/*
108 * Forward end_backup callback.
109 */
110void
112{
113 Assert(sink->bbs_next != NULL);
114 bbsink_end_backup(sink->bbs_next, endptr, endtli);
115}
116
117/*
118 * Forward cleanup callback.
119 */
120void
122{
123 Assert(sink->bbs_next != NULL);
125}
void bbsink_forward_begin_backup(bbsink *sink)
void bbsink_forward_begin_manifest(bbsink *sink)
void bbsink_forward_end_backup(bbsink *sink, XLogRecPtr endptr, TimeLineID endtli)
void bbsink_forward_cleanup(bbsink *sink)
void bbsink_forward_manifest_contents(bbsink *sink, size_t len)
void bbsink_forward_end_archive(bbsink *sink)
void bbsink_forward_archive_contents(bbsink *sink, size_t len)
void bbsink_forward_begin_archive(bbsink *sink, const char *archive_name)
void bbsink_forward_end_manifest(bbsink *sink)
static void bbsink_begin_backup(bbsink *sink, bbsink_state *state, int buffer_length)
static void bbsink_begin_archive(bbsink *sink, const char *archive_name)
static void bbsink_end_archive(bbsink *sink)
static void bbsink_begin_manifest(bbsink *sink)
static void bbsink_end_backup(bbsink *sink, XLogRecPtr endptr, TimeLineID endtli)
static void bbsink_cleanup(bbsink *sink)
static void bbsink_end_manifest(bbsink *sink)
static void bbsink_archive_contents(bbsink *sink, size_t len)
static void bbsink_manifest_contents(bbsink *sink, size_t len)
#define Assert(condition)
Definition: c.h:812
const void size_t len
bbsink * bbs_next
bbsink_state * bbs_state
char * bbs_buffer
size_t bbs_buffer_length
uint64 XLogRecPtr
Definition: xlogdefs.h:21
uint32 TimeLineID
Definition: xlogdefs.h:59