PostgreSQL Source Code  git master
basebackup_sink.h File Reference
Include dependency graph for basebackup_sink.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  bbsink_state
 
struct  bbsink
 
struct  bbsink_ops
 

Typedefs

typedef struct bbsink bbsink
 
typedef struct bbsink_ops bbsink_ops
 
typedef struct bbsink_state bbsink_state
 

Functions

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_archive_contents (bbsink *sink, size_t len)
 
static void bbsink_end_archive (bbsink *sink)
 
static void bbsink_begin_manifest (bbsink *sink)
 
static void bbsink_manifest_contents (bbsink *sink, size_t len)
 
static void bbsink_end_manifest (bbsink *sink)
 
static void bbsink_end_backup (bbsink *sink, XLogRecPtr endptr, TimeLineID endtli)
 
static void bbsink_cleanup (bbsink *sink)
 
void bbsink_forward_begin_backup (bbsink *sink)
 
void bbsink_forward_begin_archive (bbsink *sink, const char *archive_name)
 
void bbsink_forward_archive_contents (bbsink *sink, size_t len)
 
void bbsink_forward_end_archive (bbsink *sink)
 
void bbsink_forward_begin_manifest (bbsink *sink)
 
void bbsink_forward_manifest_contents (bbsink *sink, size_t len)
 
void bbsink_forward_end_manifest (bbsink *sink)
 
void bbsink_forward_end_backup (bbsink *sink, XLogRecPtr endptr, TimeLineID endtli)
 
void bbsink_forward_cleanup (bbsink *sink)
 
bbsinkbbsink_copystream_new (bool send_to_client)
 
bbsinkbbsink_gzip_new (bbsink *next, pg_compress_specification *)
 
bbsinkbbsink_lz4_new (bbsink *next, pg_compress_specification *)
 
bbsinkbbsink_zstd_new (bbsink *next, pg_compress_specification *)
 
bbsinkbbsink_progress_new (bbsink *next, bool estimate_backup_size)
 
bbsinkbbsink_server_new (bbsink *next, char *pathname)
 
bbsinkbbsink_throttle_new (bbsink *next, uint32 maxrate)
 
void basebackup_progress_wait_checkpoint (void)
 
void basebackup_progress_estimate_backup_size (void)
 
void basebackup_progress_wait_wal_archive (bbsink_state *)
 
void basebackup_progress_transfer_wal (void)
 
void basebackup_progress_done (void)
 

Typedef Documentation

◆ bbsink

typedef struct bbsink bbsink

Definition at line 1 of file basebackup_sink.h.

◆ bbsink_ops

typedef struct bbsink_ops bbsink_ops

Definition at line 1 of file basebackup_sink.h.

◆ bbsink_state

typedef struct bbsink_state bbsink_state

Function Documentation

◆ basebackup_progress_done()

void basebackup_progress_done ( void  )

Definition at line 243 of file basebackup_progress.c.

244 {
246 }
void pgstat_progress_end_command(void)

References pgstat_progress_end_command().

Referenced by perform_base_backup().

◆ basebackup_progress_estimate_backup_size()

void basebackup_progress_estimate_backup_size ( void  )

Definition at line 200 of file basebackup_progress.c.

201 {
204 }
void pgstat_progress_update_param(int index, int64 val)
#define PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE
Definition: progress.h:131
#define PROGRESS_BASEBACKUP_PHASE
Definition: progress.h:123

References pgstat_progress_update_param(), PROGRESS_BASEBACKUP_PHASE, and PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE.

Referenced by perform_base_backup().

◆ basebackup_progress_transfer_wal()

void basebackup_progress_transfer_wal ( void  )

◆ basebackup_progress_wait_checkpoint()

void basebackup_progress_wait_checkpoint ( void  )

◆ basebackup_progress_wait_wal_archive()

void basebackup_progress_wait_wal_archive ( bbsink_state state)

Definition at line 210 of file basebackup_progress.c.

211 {
212  const int index[] = {
215  };
216  int64 val[2];
217 
218  /*
219  * We report having finished all tablespaces at this point, even if the
220  * archive for the main tablespace is still open, because what's going to
221  * be added is WAL files, not files that are really from the main
222  * tablespace.
223  */
225  val[1] = list_length(state->tablespaces);
227 }
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
long val
Definition: informix.c:664
static int list_length(const List *l)
Definition: pg_list.h:149
#define PROGRESS_BASEBACKUP_PHASE_WAIT_WAL_ARCHIVE
Definition: progress.h:133
#define PROGRESS_BASEBACKUP_TBLSPC_STREAMED
Definition: progress.h:127
Definition: type.h:90
Definition: regguts.h:318

References list_length(), pgstat_progress_update_multi_param(), PROGRESS_BASEBACKUP_PHASE, PROGRESS_BASEBACKUP_PHASE_WAIT_WAL_ARCHIVE, PROGRESS_BASEBACKUP_TBLSPC_STREAMED, and val.

Referenced by perform_base_backup().

◆ bbsink_archive_contents()

static void bbsink_archive_contents ( bbsink sink,
size_t  len 
)
inlinestatic

Definition at line 200 of file basebackup_sink.h.

201 {
202  Assert(sink != NULL);
203 
204  /*
205  * The caller should make a reasonable attempt to fill the buffer before
206  * calling this function, so it shouldn't be completely empty. Nor should
207  * it be filled beyond capacity.
208  */
209  Assert(len > 0 && len <= sink->bbs_buffer_length);
210 
211  sink->bbs_ops->archive_contents(sink, len);
212 }
Assert(fmt[strlen(fmt) - 1] !='\n')
const void size_t len
void(* archive_contents)(bbsink *sink, size_t len)
const bbsink_ops * bbs_ops

References bbsink_ops::archive_contents, Assert(), bbsink::bbs_ops, and len.

Referenced by _tarWriteHeader(), _tarWritePadding(), bbsink_forward_archive_contents(), perform_base_backup(), sendFile(), and sendFileWithContent().

◆ bbsink_begin_archive()

static void bbsink_begin_archive ( bbsink sink,
const char *  archive_name 
)
inlinestatic

Definition at line 191 of file basebackup_sink.h.

192 {
193  Assert(sink != NULL);
194 
195  sink->bbs_ops->begin_archive(sink, archive_name);
196 }
void(* begin_archive)(bbsink *sink, const char *archive_name)

References Assert(), bbsink::bbs_ops, and bbsink_ops::begin_archive.

Referenced by bbsink_forward_begin_archive(), and perform_base_backup().

◆ bbsink_begin_backup()

static void bbsink_begin_backup ( bbsink sink,
bbsink_state state,
int  buffer_length 
)
inlinestatic

Definition at line 175 of file basebackup_sink.h.

176 {
177  Assert(sink != NULL);
178 
179  Assert(buffer_length > 0);
180 
181  sink->bbs_state = state;
182  sink->bbs_buffer_length = buffer_length;
183  sink->bbs_ops->begin_backup(sink);
184 
185  Assert(sink->bbs_buffer != NULL);
186  Assert((sink->bbs_buffer_length % BLCKSZ) == 0);
187 }
void(* begin_backup)(bbsink *sink)
bbsink_state * bbs_state
char * bbs_buffer
size_t bbs_buffer_length

References Assert(), bbsink::bbs_buffer, bbsink::bbs_buffer_length, bbsink::bbs_ops, bbsink::bbs_state, and bbsink_ops::begin_backup.

Referenced by bbsink_forward_begin_backup(), and perform_base_backup().

◆ bbsink_begin_manifest()

static void bbsink_begin_manifest ( bbsink sink)
inlinestatic

Definition at line 225 of file basebackup_sink.h.

226 {
227  Assert(sink != NULL);
228 
229  sink->bbs_ops->begin_manifest(sink);
230 }
void(* begin_manifest)(bbsink *sink)

References Assert(), bbsink::bbs_ops, and bbsink_ops::begin_manifest.

Referenced by bbsink_forward_begin_manifest(), and SendBackupManifest().

◆ bbsink_cleanup()

static void bbsink_cleanup ( bbsink sink)
inlinestatic

Definition at line 265 of file basebackup_sink.h.

266 {
267  Assert(sink != NULL);
268 
269  sink->bbs_ops->cleanup(sink);
270 }
void(* cleanup)(bbsink *sink)

References Assert(), bbsink::bbs_ops, and bbsink_ops::cleanup.

Referenced by bbsink_forward_cleanup(), and SendBaseBackup().

◆ bbsink_copystream_new()

bbsink* bbsink_copystream_new ( bool  send_to_client)

Definition at line 105 of file basebackup_copy.c.

106 {
108 
109  *((const bbsink_ops **) &sink->base.bbs_ops) = &bbsink_copystream_ops;
110  sink->send_to_client = send_to_client;
111 
112  /* Set up for periodic progress reporting. */
114  sink->bytes_done_at_last_time_check = UINT64CONST(0);
115 
116  return &sink->base;
117 }
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1574
static const bbsink_ops bbsink_copystream_ops
void * palloc0(Size size)
Definition: mcxt.c:1099
TimestampTz last_progress_report_time
uint64 bytes_done_at_last_time_check

References bbsink_copystream::base, bbsink::bbs_ops, bbsink_copystream_ops, bbsink_copystream::bytes_done_at_last_time_check, GetCurrentTimestamp(), bbsink_copystream::last_progress_report_time, palloc0(), and bbsink_copystream::send_to_client.

Referenced by SendBaseBackup().

◆ bbsink_end_archive()

static void bbsink_end_archive ( bbsink sink)
inlinestatic

Definition at line 216 of file basebackup_sink.h.

217 {
218  Assert(sink != NULL);
219 
220  sink->bbs_ops->end_archive(sink);
221 }
void(* end_archive)(bbsink *sink)

References Assert(), bbsink::bbs_ops, and bbsink_ops::end_archive.

Referenced by bbsink_forward_end_archive(), and perform_base_backup().

◆ bbsink_end_backup()

static void bbsink_end_backup ( bbsink sink,
XLogRecPtr  endptr,
TimeLineID  endtli 
)
inlinestatic

Definition at line 255 of file basebackup_sink.h.

256 {
257  Assert(sink != NULL);
259 
260  sink->bbs_ops->end_backup(sink, endptr, endtli);
261 }
void(* end_backup)(bbsink *sink, XLogRecPtr endptr, TimeLineID endtli)
List * tablespaces

References Assert(), bbsink::bbs_ops, bbsink::bbs_state, bbsink_ops::end_backup, list_length(), bbsink_state::tablespace_num, and bbsink_state::tablespaces.

Referenced by bbsink_forward_end_backup(), and perform_base_backup().

◆ bbsink_end_manifest()

static void bbsink_end_manifest ( bbsink sink)
inlinestatic

Definition at line 246 of file basebackup_sink.h.

247 {
248  Assert(sink != NULL);
249 
250  sink->bbs_ops->end_manifest(sink);
251 }
void(* end_manifest)(bbsink *sink)

References Assert(), bbsink::bbs_ops, and bbsink_ops::end_manifest.

Referenced by bbsink_forward_end_manifest(), and SendBackupManifest().

◆ bbsink_forward_archive_contents()

void bbsink_forward_archive_contents ( bbsink sink,
size_t  len 
)

◆ bbsink_forward_begin_archive()

void bbsink_forward_begin_archive ( bbsink sink,
const char *  archive_name 
)

Definition at line 37 of file basebackup_sink.c.

38 {
39  Assert(sink->bbs_next != NULL);
40  bbsink_begin_archive(sink->bbs_next, archive_name);
41 }
static void bbsink_begin_archive(bbsink *sink, const char *archive_name)

References Assert(), bbsink::bbs_next, and bbsink_begin_archive().

Referenced by bbsink_server_begin_archive(), and bbsink_shell_begin_archive().

◆ bbsink_forward_begin_backup()

void bbsink_forward_begin_backup ( bbsink sink)

Definition at line 24 of file basebackup_sink.c.

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 }
static void bbsink_begin_backup(bbsink *sink, bbsink_state *state, int buffer_length)

References Assert(), bbsink::bbs_buffer, bbsink::bbs_buffer_length, bbsink::bbs_next, bbsink::bbs_state, and bbsink_begin_backup().

Referenced by bbsink_progress_begin_backup(), and bbsink_throttle_begin_backup().

◆ bbsink_forward_begin_manifest()

void bbsink_forward_begin_manifest ( bbsink sink)

Definition at line 76 of file basebackup_sink.c.

77 {
78  Assert(sink->bbs_next != NULL);
80 }
static void bbsink_begin_manifest(bbsink *sink)

References Assert(), bbsink::bbs_next, and bbsink_begin_manifest().

Referenced by bbsink_server_begin_manifest(), and bbsink_shell_begin_manifest().

◆ bbsink_forward_cleanup()

void bbsink_forward_cleanup ( bbsink sink)

Definition at line 121 of file basebackup_sink.c.

122 {
123  Assert(sink->bbs_next != NULL);
124  bbsink_cleanup(sink->bbs_next);
125 }
static void bbsink_cleanup(bbsink *sink)

References Assert(), bbsink::bbs_next, and bbsink_cleanup().

◆ bbsink_forward_end_archive()

void bbsink_forward_end_archive ( bbsink sink)

Definition at line 66 of file basebackup_sink.c.

67 {
68  Assert(sink->bbs_next != NULL);
70 }
static void bbsink_end_archive(bbsink *sink)

References Assert(), bbsink::bbs_next, and bbsink_end_archive().

Referenced by bbsink_progress_end_archive(), bbsink_server_end_archive(), and bbsink_shell_end_archive().

◆ bbsink_forward_end_backup()

void bbsink_forward_end_backup ( bbsink sink,
XLogRecPtr  endptr,
TimeLineID  endtli 
)

Definition at line 111 of file basebackup_sink.c.

112 {
113  Assert(sink->bbs_next != NULL);
114  bbsink_end_backup(sink->bbs_next, endptr, endtli);
115 }
static void bbsink_end_backup(bbsink *sink, XLogRecPtr endptr, TimeLineID endtli)

References Assert(), bbsink::bbs_next, and bbsink_end_backup().

◆ bbsink_forward_end_manifest()

void bbsink_forward_end_manifest ( bbsink sink)

Definition at line 101 of file basebackup_sink.c.

102 {
103  Assert(sink->bbs_next != NULL);
105 }
static void bbsink_end_manifest(bbsink *sink)

References Assert(), bbsink::bbs_next, and bbsink_end_manifest().

Referenced by bbsink_server_end_manifest(), and bbsink_shell_end_manifest().

◆ bbsink_forward_manifest_contents()

void bbsink_forward_manifest_contents ( bbsink sink,
size_t  len 
)

Definition at line 89 of file basebackup_sink.c.

90 {
91  Assert(sink->bbs_next != NULL);
92  Assert(sink->bbs_buffer == sink->bbs_next->bbs_buffer);
95 }
static void bbsink_manifest_contents(bbsink *sink, size_t len)

References Assert(), bbsink::bbs_buffer, bbsink::bbs_buffer_length, bbsink::bbs_next, bbsink_manifest_contents(), and len.

Referenced by bbsink_server_manifest_contents(), bbsink_shell_manifest_contents(), and bbsink_throttle_manifest_contents().

◆ bbsink_gzip_new()

bbsink* bbsink_gzip_new ( bbsink next,
pg_compress_specification compress 
)

Definition at line 62 of file basebackup_gzip.c.

63 {
64 #ifndef HAVE_LIBZ
65  ereport(ERROR,
66  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
67  errmsg("gzip compression is not supported by this build")));
68  return NULL; /* keep compiler quiet */
69 #else
70  bbsink_gzip *sink;
71  int compresslevel;
72 
73  Assert(next != NULL);
74 
75  if ((compress->options & PG_COMPRESSION_OPTION_LEVEL) == 0)
77  else
78  {
79  compresslevel = compress->level;
80  Assert(compresslevel >= 1 && compresslevel <= 9);
81  }
82 
83  sink = palloc0(sizeof(bbsink_gzip));
84  *((const bbsink_ops **) &sink->base.bbs_ops) = &bbsink_gzip_ops;
85  sink->base.bbs_next = next;
86  sink->compresslevel = compresslevel;
87 
88  return &sink->base;
89 #endif
90 }
static int32 next
Definition: blutils.c:219
#define PG_COMPRESSION_OPTION_LEVEL
Definition: compression.h:25
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define ERROR
Definition: elog.h:33
#define ereport(elevel,...)
Definition: elog.h:143
#define Z_DEFAULT_COMPRESSION
static int compresslevel
Definition: pg_receivewal.c:45

References Assert(), compresslevel, ereport, errcode(), errmsg(), ERROR, pg_compress_specification::level, next, pg_compress_specification::options, palloc0(), PG_COMPRESSION_OPTION_LEVEL, and Z_DEFAULT_COMPRESSION.

Referenced by SendBaseBackup().

◆ bbsink_lz4_new()

bbsink* bbsink_lz4_new ( bbsink next,
pg_compress_specification compress 
)

Definition at line 62 of file basebackup_lz4.c.

63 {
64 #ifndef USE_LZ4
65  ereport(ERROR,
66  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
67  errmsg("lz4 compression is not supported by this build")));
68  return NULL; /* keep compiler quiet */
69 #else
70  bbsink_lz4 *sink;
71  int compresslevel;
72 
73  Assert(next != NULL);
74 
75  if ((compress->options & PG_COMPRESSION_OPTION_LEVEL) == 0)
76  compresslevel = 0;
77  else
78  {
79  compresslevel = compress->level;
80  Assert(compresslevel >= 1 && compresslevel <= 12);
81  }
82 
83  sink = palloc0(sizeof(bbsink_lz4));
84  *((const bbsink_ops **) &sink->base.bbs_ops) = &bbsink_lz4_ops;
85  sink->base.bbs_next = next;
86  sink->compresslevel = compresslevel;
87 
88  return &sink->base;
89 #endif
90 }

References Assert(), compresslevel, ereport, errcode(), errmsg(), ERROR, pg_compress_specification::level, next, pg_compress_specification::options, palloc0(), and PG_COMPRESSION_OPTION_LEVEL.

Referenced by SendBaseBackup().

◆ bbsink_manifest_contents()

static void bbsink_manifest_contents ( bbsink sink,
size_t  len 
)
inlinestatic

Definition at line 234 of file basebackup_sink.h.

235 {
236  Assert(sink != NULL);
237 
238  /* See comments in bbsink_archive_contents. */
239  Assert(len > 0 && len <= sink->bbs_buffer_length);
240 
241  sink->bbs_ops->manifest_contents(sink, len);
242 }
void(* manifest_contents)(bbsink *sink, size_t len)

References Assert(), bbsink::bbs_ops, len, and bbsink_ops::manifest_contents.

Referenced by bbsink_forward_manifest_contents(), and SendBackupManifest().

◆ bbsink_progress_new()

bbsink* bbsink_progress_new ( bbsink next,
bool  estimate_backup_size 
)

Definition at line 63 of file basebackup_progress.c.

64 {
65  bbsink *sink;
66 
67  Assert(next != NULL);
68 
69  sink = palloc0(sizeof(bbsink));
70  *((const bbsink_ops **) &sink->bbs_ops) = &bbsink_progress_ops;
71  sink->bbs_next = next;
72 
73  /*
74  * Report that a base backup is in progress, and set the total size of the
75  * backup to -1, which will get translated to NULL. If we're estimating
76  * the backup size, we'll insert the real estimate when we have it.
77  */
80 
81  return sink;
82 }
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
@ PROGRESS_COMMAND_BASEBACKUP
static const bbsink_ops bbsink_progress_ops
#define InvalidOid
Definition: postgres_ext.h:36
#define PROGRESS_BASEBACKUP_BACKUP_TOTAL
Definition: progress.h:124

References Assert(), bbsink::bbs_next, bbsink::bbs_ops, bbsink_progress_ops, InvalidOid, next, palloc0(), pgstat_progress_start_command(), pgstat_progress_update_param(), PROGRESS_BASEBACKUP_BACKUP_TOTAL, and PROGRESS_COMMAND_BASEBACKUP.

Referenced by SendBaseBackup().

◆ bbsink_server_new()

bbsink* bbsink_server_new ( bbsink next,
char *  pathname 
)

Definition at line 62 of file basebackup_server.c.

63 {
64  bbsink_server *sink = palloc0(sizeof(bbsink_server));
65 
66  *((const bbsink_ops **) &sink->base.bbs_ops) = &bbsink_server_ops;
67  sink->pathname = pathname;
68  sink->base.bbs_next = next;
69 
70  /* Replication permission is not sufficient in this case. */
72  if (!has_privs_of_role(GetUserId(), ROLE_PG_WRITE_SERVER_FILES))
73  ereport(ERROR,
74  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
75  errmsg("must be superuser or a role with privileges of the pg_write_server_files role to create server backup")));
77 
78  /*
79  * It's not a good idea to store your backups in the same directory that
80  * you're backing up. If we allowed a relative path here, that could
81  * easily happen accidentally, so we don't. The user could still
82  * accomplish the same thing by including the absolute path to $PGDATA in
83  * the pathname, but that's likely an intentional bad decision rather than
84  * an accident.
85  */
86  if (!is_absolute_path(pathname))
87  ereport(ERROR,
88  (errcode(ERRCODE_INVALID_NAME),
89  errmsg("relative path not allowed for server backup")));
90 
91  switch (pg_check_dir(pathname))
92  {
93  case 0:
94 
95  /*
96  * Does not exist, so create it using the same permissions we'd
97  * use for a new subdirectory of the data directory itself.
98  */
99  if (MakePGDirectory(pathname) < 0)
100  ereport(ERROR,
102  errmsg("could not create directory \"%s\": %m", pathname)));
103  break;
104 
105  case 1:
106  /* Exists, empty. */
107  break;
108 
109  case 2:
110  case 3:
111  case 4:
112  /* Exists, not empty. */
113  ereport(ERROR,
114  (errcode(ERRCODE_DUPLICATE_FILE),
115  errmsg("directory \"%s\" exists but is not empty",
116  pathname)));
117  break;
118 
119  default:
120  /* Access problem. */
121  ereport(ERROR,
123  errmsg("could not access directory \"%s\": %m",
124  pathname)));
125  }
126 
127  return &sink->base;
128 }
bool has_privs_of_role(Oid member, Oid role)
Definition: acl.c:4951
static const bbsink_ops bbsink_server_ops
int errcode_for_file_access(void)
Definition: elog.c:716
int MakePGDirectory(const char *directoryName)
Definition: fd.c:3803
Oid GetUserId(void)
Definition: miscinit.c:492
#define is_absolute_path(filename)
Definition: port.h:89
int pg_check_dir(const char *dir)
Definition: pgcheckdir.c:33
void StartTransactionCommand(void)
Definition: xact.c:2925
void CommitTransactionCommand(void)
Definition: xact.c:3022

References bbsink_server::base, bbsink::bbs_next, bbsink::bbs_ops, bbsink_server_ops, CommitTransactionCommand(), ereport, errcode(), errcode_for_file_access(), errmsg(), ERROR, GetUserId(), has_privs_of_role(), is_absolute_path, MakePGDirectory(), next, palloc0(), bbsink_server::pathname, pg_check_dir(), and StartTransactionCommand().

Referenced by server_get_sink().

◆ bbsink_throttle_new()

bbsink* bbsink_throttle_new ( bbsink next,
uint32  maxrate 
)

Definition at line 68 of file basebackup_throttle.c.

69 {
70  bbsink_throttle *sink;
71 
72  Assert(next != NULL);
73  Assert(maxrate > 0);
74 
75  sink = palloc0(sizeof(bbsink_throttle));
76  *((const bbsink_ops **) &sink->base.bbs_ops) = &bbsink_throttle_ops;
77  sink->base.bbs_next = next;
78 
79  sink->throttling_sample =
80  (int64) maxrate * (int64) 1024 / THROTTLING_FREQUENCY;
81 
82  /*
83  * The minimum amount of time for throttling_sample bytes to be
84  * transferred.
85  */
87 
88  return &sink->base;
89 }
#define THROTTLING_FREQUENCY
static const bbsink_ops bbsink_throttle_ops
#define USECS_PER_SEC
Definition: timestamp.h:133
static int32 maxrate
TimeOffset elapsed_min_unit

References Assert(), bbsink_throttle::base, bbsink::bbs_next, bbsink::bbs_ops, bbsink_throttle_ops, bbsink_throttle::elapsed_min_unit, maxrate, next, palloc0(), THROTTLING_FREQUENCY, bbsink_throttle::throttling_sample, and USECS_PER_SEC.

Referenced by SendBaseBackup().

◆ bbsink_zstd_new()

bbsink* bbsink_zstd_new ( bbsink next,
pg_compress_specification compress 
)

Definition at line 61 of file basebackup_zstd.c.

62 {
63 #ifndef USE_ZSTD
64  ereport(ERROR,
65  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
66  errmsg("zstd compression is not supported by this build")));
67  return NULL; /* keep compiler quiet */
68 #else
69  bbsink_zstd *sink;
70 
71  Assert(next != NULL);
72 
73  sink = palloc0(sizeof(bbsink_zstd));
74  *((const bbsink_ops **) &sink->base.bbs_ops) = &bbsink_zstd_ops;
75  sink->base.bbs_next = next;
76  sink->compress = compress;
77 
78  return &sink->base;
79 #endif
80 }

References Assert(), ereport, errcode(), errmsg(), ERROR, next, and palloc0().

Referenced by SendBaseBackup().