diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2020-11-04 11:21:09 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2020-11-04 11:21:09 +0200 |
commit | eb00f1d4bf96bdba236bcc089f3ae94db9b7c603 (patch) | |
tree | 1f5b070298ec7d383c1bbf92c8dca94062eb03f1 /src/bin/pg_rewind/libpq_fetch.c | |
parent | ffb4e27e9c5ea87f9fecb7036dfc7cc1f38169b6 (diff) | |
download | postgresql-eb00f1d4bf96bdba236bcc089f3ae94db9b7c603.tar.gz postgresql-eb00f1d4bf96bdba236bcc089f3ae94db9b7c603.zip |
Refactor pg_rewind for more clear decision making.
Deciding what to do with each file is now a separate step after all the
necessary information has been gathered. It is more clear that way.
Previously, the decision-making was divided between process_source_file()
and process_target_file(), and it was a bit hard to piece together what
the overall rules were.
Reviewed-by: Kyotaro Horiguchi, Soumyadeep Chakraborty
Discussion: https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi
Diffstat (limited to 'src/bin/pg_rewind/libpq_fetch.c')
-rw-r--r-- | src/bin/pg_rewind/libpq_fetch.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c index bf4dfc23b96..2fc4a784bdb 100644 --- a/src/bin/pg_rewind/libpq_fetch.c +++ b/src/bin/pg_rewind/libpq_fetch.c @@ -465,7 +465,7 @@ libpq_executeFileMap(filemap_t *map) entry = map->array[i]; /* If this is a relation file, copy the modified blocks */ - execute_pagemap(&entry->pagemap, entry->path); + execute_pagemap(&entry->target_pages_to_overwrite, entry->path); switch (entry->action) { @@ -476,15 +476,15 @@ libpq_executeFileMap(filemap_t *map) case FILE_ACTION_COPY: /* Truncate the old file out of the way, if any */ open_target_file(entry->path, true); - fetch_file_range(entry->path, 0, entry->newsize); + fetch_file_range(entry->path, 0, entry->source_size); break; case FILE_ACTION_TRUNCATE: - truncate_target_file(entry->path, entry->newsize); + truncate_target_file(entry->path, entry->source_size); break; case FILE_ACTION_COPY_TAIL: - fetch_file_range(entry->path, entry->oldsize, entry->newsize); + fetch_file_range(entry->path, entry->target_size, entry->source_size); break; case FILE_ACTION_REMOVE: @@ -494,6 +494,10 @@ libpq_executeFileMap(filemap_t *map) case FILE_ACTION_CREATE: create_target(entry); break; + + case FILE_ACTION_UNDECIDED: + pg_fatal("no action decided for \"%s\"", entry->path); + break; } } |