29#include "catalog/pg_tablespace_d.h"
41#define SH_PREFIX filehash
42#define SH_ELEMENT_TYPE file_entry_t
43#define SH_KEY_TYPE const char *
45#define SH_HASH_KEY(tb, key) hash_string(key)
46#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
47#define SH_SCOPE static inline
48#define SH_RAW_ALLOCATOR pg_malloc0
53#define FILEHASH_INITIAL_SIZE 1000
73#define SH_PREFIX keepwal
74#define SH_ELEMENT_TYPE keepwal_entry
75#define SH_KEY_TYPE const char *
77#define SH_HASH_KEY(tb, key) hash_string(key)
78#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
79#define SH_SCOPE static inline
80#define SH_RAW_ALLOCATOR pg_malloc0
85#define KEEPWAL_INITIAL_SIZE 1000
160 {
"postgresql.auto.conf.tmp",
false},
163 {
"current_logfiles.tmp",
false},
167 {
"pg_internal.init",
true},
174 {
"backup_label",
false},
175 {
"tablespace_map",
false},
183 {
"backup_manifest",
false},
185 {
"postmaster.pid",
false},
186 {
"postmaster.opts",
false},
208 entry = filehash_insert(
filehash, path, &found);
235 return filehash_lookup(
filehash, path);
258 entry = keepwal_insert(
keepwal, path, &found);
268 return keepwal_lookup(
keepwal, path) != NULL;
280 const char *link_target)
297 pg_fatal(
"data file \"%s\" in source is not a regular file", path);
302 pg_fatal(
"duplicate source file \"%s\"", path);
316 const char *link_target)
335 pg_fatal(
"duplicate source file \"%s\"", path);
360 segno = blkno / RELSEG_SIZE;
361 blkno_inseg = blkno % RELSEG_SIZE;
390 pg_fatal(
"unexpected page modification for non-regular file \"%s\"",
397 end_offset = (blkno_inseg + 1) * BLCKSZ;
398 if (end_offset <= entry->source_size && end_offset <= entry->target_size)
440 pg_log_debug(
"entry \"%s\" excluded from source file list",
443 pg_log_debug(
"entry \"%s\" excluded from target file list",
455 snprintf(localpath,
sizeof(localpath),
"%s/",
457 if (strstr(path, localpath) == path)
460 pg_log_debug(
"entry \"%s\" excluded from source file list",
463 pg_log_debug(
"entry \"%s\" excluded from target file list",
602 nmatch = sscanf(path,
"global/%u.%u", &rlocator.
relNumber, &segNo);
603 if (nmatch == 1 || nmatch == 2)
605 rlocator.
spcOid = GLOBALTABLESPACE_OID;
611 nmatch = sscanf(path,
"base/%u/%u.%u",
613 if (nmatch == 2 || nmatch == 3)
615 rlocator.
spcOid = DEFAULTTABLESPACE_OID;
623 if (nmatch == 3 || nmatch == 4)
638 if (strcmp(check_path, path) != 0)
661 segpath =
psprintf(
"%s.%u", path, segno);
685 if (
fa->action >
fb->action)
687 if (
fa->action <
fb->action)
691 return strcmp(
fb->path,
fa->path);
693 return strcmp(
fa->path,
fb->path);
702 const char *path = entry->
path;
708 if (strcmp(path,
"global/pg_control") == 0)
712 if (strstr(path,
".DS_Store") != NULL)
756 pg_log_debug(
"Not removing file \"%s\" because it is required for recovery", path);
779 pg_fatal(
"file \"%s\" is of different type in source and target", entry->
path);
846 pg_fatal(
"unknown file type for \"%s\"", path);
851 pg_fatal(
"could not decide what to do with file \"%s\"", path);
864 filehash_iterator it;
868 filehash_start_iterate(
filehash, &it);
869 while ((entry = filehash_iterate(
filehash, &it)) != NULL)
881 filehash_start_iterate(
filehash, &it);
883 while ((entry = filehash_iterate(
filehash, &it)) != NULL)
#define Assert(condition)
bool datapagemap_next(datapagemap_iterator_t *iter, BlockNumber *blkno)
void datapagemap_print(datapagemap_t *map)
datapagemap_iterator_t * datapagemap_iterate(datapagemap_t *map)
void datapagemap_add(datapagemap_t *map, BlockNumber blkno)
void * pg_malloc(size_t size)
char * pg_strdup(const char *in)
#define PG_TEMP_FILES_DIR
#define PG_TEMP_FILE_PREFIX
static const struct exclude_list_item excludeFiles[]
struct keepwal_entry keepwal_entry
static bool isRelDataFile(const char *path)
static bool keepwal_entry_exists(const char *path)
static const char * action_to_str(file_action_t action)
void process_source_file(const char *path, file_type_t type, size_t size, const char *link_target)
static const char *const excludeDirContents[]
void print_filemap(filemap_t *filemap)
static char * datasegpath(RelFileLocator rlocator, ForkNumber forknum, BlockNumber segno)
static filehash_hash * filehash
void process_target_file(const char *path, file_type_t type, size_t size, const char *link_target)
filemap_t * decide_file_actions(void)
void process_target_wal_block_change(ForkNumber forknum, RelFileLocator rlocator, BlockNumber blkno)
void keepwal_add_entry(const char *path)
static keepwal_hash * keepwal
static file_action_t decide_file_action(file_entry_t *entry)
static file_entry_t * lookup_filehash_entry(const char *path)
#define KEEPWAL_INITIAL_SIZE
static file_entry_t * insert_filehash_entry(const char *path)
static bool check_file_excluded(const char *path, bool is_source)
#define FILEHASH_INITIAL_SIZE
static int final_filemap_cmp(const void *a, const void *b)
void calculate_totals(filemap_t *filemap)
static void const char fflush(stdout)
#define pg_log_debug(...)
void pfree(void *pointer)
char * last_dir_separator(const char *filename)
#define qsort(a, b, c, d)
char * psprintf(const char *fmt,...)
#define InvalidRelFileNumber
#define relpathperm(rlocator, forknum)
#define TABLESPACE_VERSION_DIRECTORY
static pg_noinline void Size size
bool pg_str_endswith(const char *str, const char *end)
datapagemap_t target_pages_to_overwrite
char * source_link_target
char * target_link_target
file_entry_t * entries[FLEXIBLE_ARRAY_MEMBER]