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
131 {
"postgresql.auto.conf.tmp",
false},
134 {
"current_logfiles.tmp",
false},
138 {
"pg_internal.init",
true},
145 {
"backup_label",
false},
146 {
"tablespace_map",
false},
154 {
"backup_manifest",
false},
156 {
"postmaster.pid",
false},
157 {
"postmaster.opts",
false},
179 entry = filehash_insert(
filehash, path, &found);
206 return filehash_lookup(
filehash, path);
218 const char *link_target)
235 pg_fatal(
"data file \"%s\" in source is not a regular file", path);
240 pg_fatal(
"duplicate source file \"%s\"", path);
254 const char *link_target)
273 pg_fatal(
"duplicate source file \"%s\"", path);
298 segno = blkno / RELSEG_SIZE;
299 blkno_inseg = blkno % RELSEG_SIZE;
328 pg_fatal(
"unexpected page modification for non-regular file \"%s\"",
335 end_offset = (blkno_inseg + 1) * BLCKSZ;
336 if (end_offset <= entry->source_size && end_offset <= entry->target_size)
378 pg_log_debug(
"entry \"%s\" excluded from source file list",
381 pg_log_debug(
"entry \"%s\" excluded from target file list",
393 snprintf(localpath,
sizeof(localpath),
"%s/",
395 if (strstr(path, localpath) == path)
398 pg_log_debug(
"entry \"%s\" excluded from source file list",
401 pg_log_debug(
"entry \"%s\" excluded from target file list",
540 nmatch = sscanf(path,
"global/%u.%u", &rlocator.
relNumber, &segNo);
541 if (nmatch == 1 || nmatch == 2)
543 rlocator.
spcOid = GLOBALTABLESPACE_OID;
549 nmatch = sscanf(path,
"base/%u/%u.%u",
551 if (nmatch == 2 || nmatch == 3)
553 rlocator.
spcOid = DEFAULTTABLESPACE_OID;
561 if (nmatch == 3 || nmatch == 4)
576 if (strcmp(check_path, path) != 0)
599 segpath =
psprintf(
"%s.%u", path, segno);
623 if (
fa->action >
fb->action)
625 if (
fa->action <
fb->action)
629 return strcmp(
fb->path,
fa->path);
631 return strcmp(
fa->path,
fb->path);
640 const char *path = entry->
path;
646 if (strcmp(path,
"global/pg_control") == 0)
650 if (strstr(path,
".DS_Store") != NULL)
709 pg_fatal(
"file \"%s\" is of different type in source and target", entry->
path);
776 pg_fatal(
"unknown file type for \"%s\"", path);
781 pg_fatal(
"could not decide what to do with file \"%s\"", path);
794 filehash_iterator it;
798 filehash_start_iterate(
filehash, &it);
799 while ((entry = filehash_iterate(
filehash, &it)) != NULL)
811 filehash_start_iterate(
filehash, &it);
813 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)
void datapagemap_add(datapagemap_t *map, BlockNumber blkno)
datapagemap_iterator_t * datapagemap_iterate(datapagemap_t *map)
char * pg_strdup(const char *in)
void * pg_malloc(size_t size)
#define PG_TEMP_FILES_DIR
#define PG_TEMP_FILE_PREFIX
static const struct exclude_list_item excludeFiles[]
static bool isRelDataFile(const char *path)
void process_source_file(const char *path, file_type_t type, size_t size, const char *link_target)
static const char *const excludeDirContents[]
static const char * action_to_str(file_action_t action)
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)
void process_target_wal_block_change(ForkNumber forknum, RelFileLocator rlocator, BlockNumber blkno)
filemap_t * decide_file_actions(void)
static file_action_t decide_file_action(file_entry_t *entry)
static file_entry_t * lookup_filehash_entry(const char *path)
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]