1 /*-------------------------------------------------------------------------
4 * Default implementations for bbsink (basebackup sink) callbacks.
6 * Portions Copyright (c) 2010-2024, PostgreSQL Global Development Group
8 * src/backend/backup/basebackup_sink.c
10 *-------------------------------------------------------------------------
15 #include "backup/basebackup_sink.h"
18 * Forward begin_backup callback.
20 * Only use this implementation if you want the bbsink you're implementing to
21 * share a buffer with the successor bbsink.
24 bbsink_forward_begin_backup(bbsink
*sink
)
26 Assert(sink
->bbs_next
!= NULL
);
27 Assert(sink
->bbs_state
!= NULL
);
28 bbsink_begin_backup(sink
->bbs_next
, sink
->bbs_state
,
29 sink
->bbs_buffer_length
);
30 sink
->bbs_buffer
= sink
->bbs_next
->bbs_buffer
;
34 * Forward begin_archive callback.
37 bbsink_forward_begin_archive(bbsink
*sink
, const char *archive_name
)
39 Assert(sink
->bbs_next
!= NULL
);
40 bbsink_begin_archive(sink
->bbs_next
, archive_name
);
44 * Forward archive_contents callback.
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
54 bbsink_forward_archive_contents(bbsink
*sink
, size_t len
)
56 Assert(sink
->bbs_next
!= NULL
);
57 Assert(sink
->bbs_buffer
== sink
->bbs_next
->bbs_buffer
);
58 Assert(sink
->bbs_buffer_length
== sink
->bbs_next
->bbs_buffer_length
);
59 bbsink_archive_contents(sink
->bbs_next
, len
);
63 * Forward end_archive callback.
66 bbsink_forward_end_archive(bbsink
*sink
)
68 Assert(sink
->bbs_next
!= NULL
);
69 bbsink_end_archive(sink
->bbs_next
);
73 * Forward begin_manifest callback.
76 bbsink_forward_begin_manifest(bbsink
*sink
)
78 Assert(sink
->bbs_next
!= NULL
);
79 bbsink_begin_manifest(sink
->bbs_next
);
83 * Forward manifest_contents callback.
85 * As with the archive_contents callback, it's expected that the buffer is
89 bbsink_forward_manifest_contents(bbsink
*sink
, size_t len
)
91 Assert(sink
->bbs_next
!= NULL
);
92 Assert(sink
->bbs_buffer
== sink
->bbs_next
->bbs_buffer
);
93 Assert(sink
->bbs_buffer_length
== sink
->bbs_next
->bbs_buffer_length
);
94 bbsink_manifest_contents(sink
->bbs_next
, len
);
98 * Forward end_manifest callback.
101 bbsink_forward_end_manifest(bbsink
*sink
)
103 Assert(sink
->bbs_next
!= NULL
);
104 bbsink_end_manifest(sink
->bbs_next
);
108 * Forward end_backup callback.
111 bbsink_forward_end_backup(bbsink
*sink
, XLogRecPtr endptr
, TimeLineID endtli
)
113 Assert(sink
->bbs_next
!= NULL
);
114 bbsink_end_backup(sink
->bbs_next
, endptr
, endtli
);
118 * Forward cleanup callback.
121 bbsink_forward_cleanup(bbsink
*sink
)
123 Assert(sink
->bbs_next
!= NULL
);
124 bbsink_cleanup(sink
->bbs_next
);