1/*-------------------------------------------------------------------------
4 * Abstraction for fetching from source server.
6 * The source server can be either a libpq connection to a live system,
7 * or a local data directory. The 'rewind_source' struct abstracts the
8 * operations to fetch data from the source system, so that the rest of
9 * the code doesn't need to care what kind of a source its dealing with.
11 * Copyright (c) 2013-2025, PostgreSQL Global Development Group
13 *-------------------------------------------------------------------------
15#ifndef REWIND_SOURCE_H
16#define REWIND_SOURCE_H
26 * Traverse all files in the source data directory, and call 'callback' on
33 * Fetch a single file into a malloc'd buffer. The file size is returned
34 * in *filesize. The returned buffer is always zero-terminated, which is
35 * handy for text files.
41 * Request to fetch (part of) a file in the source system, specified by an
42 * offset and length, and write it to the same offset in the corresponding
43 * target file. The source implementation may queue up the request and
44 * execute it later when convenient. Call finish_fetch() to flush the
45 * queue and execute all requests.
48 off_t offset,
size_t len);
51 * Like queue_fetch_range(), but requests replacing the whole local file
52 * from the source system. 'len' is the expected length of the file,
53 * although when the source is a live server, the file may change
54 * concurrently. The implementation is not obliged to copy more than 'len'
55 * bytes, even if the file is larger. However, to avoid copying a
56 * truncated version of the file, which can cause trouble if e.g. a
57 * configuration file is modified concurrently, the implementation should
58 * try to copy the whole file, even if it's larger than expected.
64 * Execute all requests queued up with queue_fetch_range().
69 * Get the current WAL insert position in the source system.
74 * Free this rewind_source object.
80/* in libpq_source.c */
83/* in local_source.c */
86#endif /* REWIND_SOURCE_H */
void(* process_file_callback_t)(const char *path, file_type_t type, size_t size, const char *link_target)
rewind_source * init_local_source(const char *datadir)
struct rewind_source rewind_source
rewind_source * init_libpq_source(PGconn *conn)
void(* queue_fetch_file)(struct rewind_source *, const char *path, size_t len)
void(* traverse_files)(struct rewind_source *, process_file_callback_t callback)
void(* finish_fetch)(struct rewind_source *)
XLogRecPtr(* get_current_wal_insert_lsn)(struct rewind_source *)
void(* queue_fetch_range)(struct rewind_source *, const char *path, off_t offset, size_t len)
void(* destroy)(struct rewind_source *)
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)