2015-03-23 18:47:52 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* filemap.c
|
|
|
|
* A data structure for keeping track of files that have changed.
|
|
|
|
*
|
2019-01-02 18:44:25 +01:00
|
|
|
* Copyright (c) 2013-2019, PostgreSQL Global Development Group
|
2015-03-23 18:47:52 +01:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "postgres_fe.h"
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2019-10-23 06:08:53 +02:00
|
|
|
#include "catalog/pg_tablespace_d.h"
|
|
|
|
#include "common/string.h"
|
2015-03-23 18:47:52 +01:00
|
|
|
#include "datapagemap.h"
|
|
|
|
#include "filemap.h"
|
|
|
|
#include "pg_rewind.h"
|
|
|
|
#include "storage/fd.h"
|
|
|
|
|
|
|
|
filemap_t *filemap = NULL;
|
|
|
|
|
|
|
|
static bool isRelDataFile(const char *path);
|
|
|
|
static char *datasegpath(RelFileNode rnode, ForkNumber forknum,
|
2019-05-22 19:04:48 +02:00
|
|
|
BlockNumber segno);
|
2015-03-23 18:47:52 +01:00
|
|
|
static int path_cmp(const void *a, const void *b);
|
|
|
|
static int final_filemap_cmp(const void *a, const void *b);
|
2015-03-30 02:02:14 +02:00
|
|
|
static void filemap_list_to_array(filemap_t *map);
|
2018-09-13 23:35:43 +02:00
|
|
|
static bool check_file_excluded(const char *path, bool is_source);
|
2018-03-28 21:56:52 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The contents of these directories are removed or recreated during server
|
|
|
|
* start so they are not included in data processed by pg_rewind.
|
|
|
|
*
|
|
|
|
* Note: those lists should be kept in sync with what basebackup.c provides.
|
|
|
|
* Some of the values, contrary to what basebackup.c uses, are hardcoded as
|
|
|
|
* they are defined in backend-only headers. So this list is maintained
|
|
|
|
* with a best effort in mind.
|
|
|
|
*/
|
|
|
|
static const char *excludeDirContents[] =
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Skip temporary statistics files. PG_STAT_TMP_DIR must be skipped even
|
|
|
|
* when stats_temp_directory is set because PGSS_TEXT_FILE is always
|
|
|
|
* created there.
|
|
|
|
*/
|
2018-04-26 20:47:16 +02:00
|
|
|
"pg_stat_tmp", /* defined as PG_STAT_TMP_DIR */
|
2018-03-28 21:56:52 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* It is generally not useful to backup the contents of this directory
|
|
|
|
* even if the intention is to restore to another master. See backup.sgml
|
|
|
|
* for a more detailed description.
|
|
|
|
*/
|
|
|
|
"pg_replslot",
|
|
|
|
|
|
|
|
/* Contents removed on startup, see dsm_cleanup_for_mmap(). */
|
2018-04-26 20:47:16 +02:00
|
|
|
"pg_dynshmem", /* defined as PG_DYNSHMEM_DIR */
|
2018-03-28 21:56:52 +02:00
|
|
|
|
|
|
|
/* Contents removed on startup, see AsyncShmemInit(). */
|
|
|
|
"pg_notify",
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Old contents are loaded for possible debugging but are not required for
|
|
|
|
* normal operation, see OldSerXidInit().
|
|
|
|
*/
|
|
|
|
"pg_serial",
|
|
|
|
|
|
|
|
/* Contents removed on startup, see DeleteAllExportedSnapshotFiles(). */
|
|
|
|
"pg_snapshots",
|
|
|
|
|
|
|
|
/* Contents zeroed on startup, see StartupSUBTRANS(). */
|
|
|
|
"pg_subtrans",
|
|
|
|
|
|
|
|
/* end of list */
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* List of files excluded from filemap processing.
|
|
|
|
*/
|
|
|
|
static const char *excludeFiles[] =
|
|
|
|
{
|
|
|
|
/* Skip auto conf temporary file. */
|
|
|
|
"postgresql.auto.conf.tmp", /* defined as PG_AUTOCONF_FILENAME */
|
|
|
|
|
|
|
|
/* Skip current log file temporary file */
|
|
|
|
"current_logfiles.tmp", /* defined as LOG_METAINFO_DATAFILE_TMP */
|
|
|
|
|
|
|
|
/* Skip relation cache because it is rebuilt on startup */
|
|
|
|
"pg_internal.init", /* defined as RELCACHE_INIT_FILENAME */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there's a backup_label or tablespace_map file, it belongs to a
|
|
|
|
* backup started by the user with pg_start_backup(). It is *not* correct
|
|
|
|
* for this backup. Our backup_label is written later on separately.
|
|
|
|
*/
|
|
|
|
"backup_label", /* defined as BACKUP_LABEL_FILE */
|
|
|
|
"tablespace_map", /* defined as TABLESPACE_MAP */
|
|
|
|
|
|
|
|
"postmaster.pid",
|
|
|
|
"postmaster.opts",
|
|
|
|
|
|
|
|
/* end of list */
|
|
|
|
NULL
|
|
|
|
};
|
2015-03-23 18:47:52 +01:00
|
|
|
|
|
|
|
/*
|
2015-03-30 02:02:14 +02:00
|
|
|
* Create a new file map (stored in the global pointer "filemap").
|
2015-03-23 18:47:52 +01:00
|
|
|
*/
|
2015-03-30 02:02:14 +02:00
|
|
|
void
|
2015-03-23 18:47:52 +01:00
|
|
|
filemap_create(void)
|
|
|
|
{
|
|
|
|
filemap_t *map;
|
|
|
|
|
|
|
|
map = pg_malloc(sizeof(filemap_t));
|
|
|
|
map->first = map->last = NULL;
|
|
|
|
map->nlist = 0;
|
|
|
|
map->array = NULL;
|
|
|
|
map->narray = 0;
|
|
|
|
|
|
|
|
Assert(filemap == NULL);
|
|
|
|
filemap = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-04-15 21:52:00 +02:00
|
|
|
* Callback for processing source file list.
|
2015-03-23 18:47:52 +01:00
|
|
|
*
|
|
|
|
* This is called once for every file in the source server. We decide what
|
|
|
|
* action needs to be taken for the file, depending on whether the file
|
|
|
|
* exists in the target and whether the size matches.
|
|
|
|
*/
|
|
|
|
void
|
2015-04-15 21:52:00 +02:00
|
|
|
process_source_file(const char *path, file_type_t type, size_t newsize,
|
2015-03-23 18:47:52 +01:00
|
|
|
const char *link_target)
|
|
|
|
{
|
|
|
|
bool exists;
|
|
|
|
char localpath[MAXPGPATH];
|
|
|
|
struct stat statbuf;
|
|
|
|
filemap_t *map = filemap;
|
|
|
|
file_action_t action = FILE_ACTION_NONE;
|
|
|
|
size_t oldsize = 0;
|
|
|
|
file_entry_t *entry;
|
|
|
|
|
|
|
|
Assert(map->array == NULL);
|
|
|
|
|
Fix pg_rewind when rewinding new database with tables included
This fixes an issue introduced by 266b6ac, which has added filters to
exclude file patterns on the target and source data directories to
reduce the number of files transferred. Filters get applied to both
the target and source data files, and include pg_internal.init which is
present for each database once relations are created on it. However, if
the target differed from the source with at least one new database with
relations, the rewind would fail due to the exclusion filters applied on
the target files, causing pg_internal.init to still be present on the
target database folder, while its contents should have been completely
removed so as there is nothing remaining inside at the time of the
folder deletion.
Applying exclusion filters on the source files is fine, because this way
the amount of data copied from the source to the target is reduced. And
actually, not applying the filters on the target is what pg_rewind
should do, because this causes such files to be automatically removed
during the rewind on the target. Exclusion filters apply to paths which
are removed or recreated automatically at startup, so removing all those
files on the target during the rewind is a win.
The existing set of TAP tests already stresses the rewind of databases,
but it did not include any tables on those newly-created databases.
Creating extra tables in this case is enough to reproduce the failure,
so the existing tests are extended to close the gap.
Reported-by: Mithun Cy
Author: Michael Paquier
Discussion: https://postgr.es/m/CADq3xVYt6_pO7ZzmjOqPgY9HWsL=kLd-_tNyMtdfjKqEALDyTA@mail.gmail.com
Backpatch-through: 11
2019-03-18 02:34:45 +01:00
|
|
|
/*
|
|
|
|
* Skip any files matching the exclusion filters. This has the effect to
|
|
|
|
* remove all those files on the target.
|
|
|
|
*/
|
2018-09-13 23:35:43 +02:00
|
|
|
if (check_file_excluded(path, true))
|
2015-03-23 18:47:52 +01:00
|
|
|
return;
|
|
|
|
|
2015-08-03 14:32:06 +02:00
|
|
|
/*
|
2016-10-20 17:24:37 +02:00
|
|
|
* Pretend that pg_wal is a directory, even if it's really a symlink. We
|
2016-06-10 00:02:36 +02:00
|
|
|
* don't want to mess with the symlink itself, nor complain if it's a
|
2015-08-03 14:32:06 +02:00
|
|
|
* symlink in source but not in target or vice versa.
|
|
|
|
*/
|
2016-10-20 17:24:37 +02:00
|
|
|
if (strcmp(path, "pg_wal") == 0 && type == FILE_TYPE_SYMLINK)
|
2015-08-03 14:32:06 +02:00
|
|
|
type = FILE_TYPE_DIRECTORY;
|
|
|
|
|
2015-03-23 18:47:52 +01:00
|
|
|
/*
|
|
|
|
* Skip temporary files, .../pgsql_tmp/... and .../pgsql_tmp.* in source.
|
|
|
|
* This has the effect that all temporary files in the destination will be
|
|
|
|
* removed.
|
|
|
|
*/
|
|
|
|
if (strstr(path, "/" PG_TEMP_FILE_PREFIX) != NULL)
|
|
|
|
return;
|
|
|
|
if (strstr(path, "/" PG_TEMP_FILES_DIR "/") != NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sanity check: a filename that looks like a data file better be a
|
|
|
|
* regular file
|
|
|
|
*/
|
|
|
|
if (type != FILE_TYPE_REGULAR && isRelDataFile(path))
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_fatal("data file \"%s\" in source is not a regular file", path);
|
2015-03-23 18:47:52 +01:00
|
|
|
|
|
|
|
snprintf(localpath, sizeof(localpath), "%s/%s", datadir_target, path);
|
|
|
|
|
2015-04-15 21:52:00 +02:00
|
|
|
/* Does the corresponding file exist in the target data dir? */
|
2015-03-23 18:47:52 +01:00
|
|
|
if (lstat(localpath, &statbuf) < 0)
|
|
|
|
{
|
|
|
|
if (errno != ENOENT)
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_fatal("could not stat file \"%s\": %m",
|
|
|
|
localpath);
|
2015-03-23 18:47:52 +01:00
|
|
|
|
|
|
|
exists = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
exists = true;
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case FILE_TYPE_DIRECTORY:
|
2016-10-20 17:24:37 +02:00
|
|
|
if (exists && !S_ISDIR(statbuf.st_mode) && strcmp(path, "pg_wal") != 0)
|
2015-03-23 18:47:52 +01:00
|
|
|
{
|
2015-06-11 15:31:18 +02:00
|
|
|
/* it's a directory in source, but not in target. Strange.. */
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_fatal("\"%s\" is not a directory", localpath);
|
2015-03-23 18:47:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!exists)
|
|
|
|
action = FILE_ACTION_CREATE;
|
|
|
|
else
|
|
|
|
action = FILE_ACTION_NONE;
|
|
|
|
oldsize = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FILE_TYPE_SYMLINK:
|
|
|
|
if (exists &&
|
|
|
|
#ifndef WIN32
|
|
|
|
!S_ISLNK(statbuf.st_mode)
|
|
|
|
#else
|
|
|
|
!pgwin32_is_junction(localpath)
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
{
|
|
|
|
/*
|
2015-06-11 15:31:18 +02:00
|
|
|
* It's a symbolic link in source, but not in target.
|
2015-03-23 18:47:52 +01:00
|
|
|
* Strange..
|
|
|
|
*/
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_fatal("\"%s\" is not a symbolic link", localpath);
|
2015-03-23 18:47:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!exists)
|
|
|
|
action = FILE_ACTION_CREATE;
|
|
|
|
else
|
|
|
|
action = FILE_ACTION_NONE;
|
|
|
|
oldsize = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FILE_TYPE_REGULAR:
|
|
|
|
if (exists && !S_ISREG(statbuf.st_mode))
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_fatal("\"%s\" is not a regular file", localpath);
|
2015-03-23 18:47:52 +01:00
|
|
|
|
|
|
|
if (!exists || !isRelDataFile(path))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* File exists in source, but not in target. Or it's a
|
|
|
|
* non-data file that we have no special processing for. Copy
|
|
|
|
* it in toto.
|
|
|
|
*
|
|
|
|
* An exception: PG_VERSIONs should be identical, but avoid
|
|
|
|
* overwriting it for paranoia.
|
|
|
|
*/
|
|
|
|
if (pg_str_endswith(path, "PG_VERSION"))
|
|
|
|
{
|
|
|
|
action = FILE_ACTION_NONE;
|
|
|
|
oldsize = statbuf.st_size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
action = FILE_ACTION_COPY;
|
|
|
|
oldsize = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* It's a data file that exists in both.
|
|
|
|
*
|
|
|
|
* If it's larger in target, we can truncate it. There will
|
|
|
|
* also be a WAL record of the truncation in the source
|
|
|
|
* system, so WAL replay would eventually truncate the target
|
|
|
|
* too, but we might as well do it now.
|
|
|
|
*
|
|
|
|
* If it's smaller in the target, it means that it has been
|
|
|
|
* truncated in the target, or enlarged in the source, or
|
2015-05-24 03:35:49 +02:00
|
|
|
* both. If it was truncated in the target, we need to copy
|
|
|
|
* the missing tail from the source system. If it was enlarged
|
|
|
|
* in the source system, there will be WAL records in the
|
|
|
|
* source system for the new blocks, so we wouldn't need to
|
|
|
|
* copy them here. But we don't know which scenario we're
|
|
|
|
* dealing with, and there's no harm in copying the missing
|
|
|
|
* blocks now, so do it now.
|
2015-03-23 18:47:52 +01:00
|
|
|
*
|
2015-04-15 21:52:00 +02:00
|
|
|
* If it's the same size, do nothing here. Any blocks modified
|
|
|
|
* in the target will be copied based on parsing the target
|
|
|
|
* system's WAL, and any blocks modified in the source will be
|
|
|
|
* updated after rewinding, when the source system's WAL is
|
|
|
|
* replayed.
|
2015-03-23 18:47:52 +01:00
|
|
|
*/
|
|
|
|
oldsize = statbuf.st_size;
|
|
|
|
if (oldsize < newsize)
|
|
|
|
action = FILE_ACTION_COPY_TAIL;
|
|
|
|
else if (oldsize > newsize)
|
|
|
|
action = FILE_ACTION_TRUNCATE;
|
|
|
|
else
|
|
|
|
action = FILE_ACTION_NONE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create a new entry for this file */
|
|
|
|
entry = pg_malloc(sizeof(file_entry_t));
|
|
|
|
entry->path = pg_strdup(path);
|
|
|
|
entry->type = type;
|
|
|
|
entry->action = action;
|
|
|
|
entry->oldsize = oldsize;
|
|
|
|
entry->newsize = newsize;
|
|
|
|
entry->link_target = link_target ? pg_strdup(link_target) : NULL;
|
|
|
|
entry->next = NULL;
|
|
|
|
entry->pagemap.bitmap = NULL;
|
|
|
|
entry->pagemap.bitmapsize = 0;
|
|
|
|
entry->isrelfile = isRelDataFile(path);
|
|
|
|
|
|
|
|
if (map->last)
|
|
|
|
{
|
|
|
|
map->last->next = entry;
|
|
|
|
map->last = entry;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
map->first = map->last = entry;
|
|
|
|
map->nlist++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-04-15 21:52:00 +02:00
|
|
|
* Callback for processing target file list.
|
2015-03-23 18:47:52 +01:00
|
|
|
*
|
2015-04-15 21:52:00 +02:00
|
|
|
* All source files must be already processed before calling this. This only
|
|
|
|
* marks target data directory's files that didn't exist in the source for
|
|
|
|
* deletion.
|
2015-03-23 18:47:52 +01:00
|
|
|
*/
|
|
|
|
void
|
2015-04-15 21:52:00 +02:00
|
|
|
process_target_file(const char *path, file_type_t type, size_t oldsize,
|
|
|
|
const char *link_target)
|
2015-03-23 18:47:52 +01:00
|
|
|
{
|
|
|
|
bool exists;
|
|
|
|
char localpath[MAXPGPATH];
|
|
|
|
struct stat statbuf;
|
|
|
|
file_entry_t key;
|
|
|
|
file_entry_t *key_ptr;
|
|
|
|
filemap_t *map = filemap;
|
|
|
|
file_entry_t *entry;
|
|
|
|
|
2018-03-28 21:56:52 +02:00
|
|
|
/*
|
Fix pg_rewind when rewinding new database with tables included
This fixes an issue introduced by 266b6ac, which has added filters to
exclude file patterns on the target and source data directories to
reduce the number of files transferred. Filters get applied to both
the target and source data files, and include pg_internal.init which is
present for each database once relations are created on it. However, if
the target differed from the source with at least one new database with
relations, the rewind would fail due to the exclusion filters applied on
the target files, causing pg_internal.init to still be present on the
target database folder, while its contents should have been completely
removed so as there is nothing remaining inside at the time of the
folder deletion.
Applying exclusion filters on the source files is fine, because this way
the amount of data copied from the source to the target is reduced. And
actually, not applying the filters on the target is what pg_rewind
should do, because this causes such files to be automatically removed
during the rewind on the target. Exclusion filters apply to paths which
are removed or recreated automatically at startup, so removing all those
files on the target during the rewind is a win.
The existing set of TAP tests already stresses the rewind of databases,
but it did not include any tables on those newly-created databases.
Creating extra tables in this case is enough to reproduce the failure,
so the existing tests are extended to close the gap.
Reported-by: Mithun Cy
Author: Michael Paquier
Discussion: https://postgr.es/m/CADq3xVYt6_pO7ZzmjOqPgY9HWsL=kLd-_tNyMtdfjKqEALDyTA@mail.gmail.com
Backpatch-through: 11
2019-03-18 02:34:45 +01:00
|
|
|
* Do not apply any exclusion filters here. This has advantage to remove
|
|
|
|
* from the target data folder all paths which have been filtered out from
|
|
|
|
* the source data folder when processing the source files.
|
2018-03-28 21:56:52 +02:00
|
|
|
*/
|
|
|
|
|
2015-03-23 18:47:52 +01:00
|
|
|
snprintf(localpath, sizeof(localpath), "%s/%s", datadir_target, path);
|
|
|
|
if (lstat(localpath, &statbuf) < 0)
|
|
|
|
{
|
|
|
|
if (errno != ENOENT)
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_fatal("could not stat file \"%s\": %m",
|
|
|
|
localpath);
|
2015-03-23 18:47:52 +01:00
|
|
|
|
|
|
|
exists = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map->array == NULL)
|
|
|
|
{
|
|
|
|
/* on first call, initialize lookup array */
|
|
|
|
if (map->nlist == 0)
|
|
|
|
{
|
|
|
|
/* should not happen */
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_fatal("source file list is empty");
|
2015-03-23 18:47:52 +01:00
|
|
|
}
|
|
|
|
|
2015-03-30 02:02:14 +02:00
|
|
|
filemap_list_to_array(map);
|
|
|
|
|
|
|
|
Assert(map->array != NULL);
|
|
|
|
|
2015-03-23 18:47:52 +01:00
|
|
|
qsort(map->array, map->narray, sizeof(file_entry_t *), path_cmp);
|
|
|
|
}
|
|
|
|
|
2015-08-03 14:32:06 +02:00
|
|
|
/*
|
|
|
|
* Like in process_source_file, pretend that xlog is always a directory.
|
|
|
|
*/
|
2016-10-20 17:24:37 +02:00
|
|
|
if (strcmp(path, "pg_wal") == 0 && type == FILE_TYPE_SYMLINK)
|
2015-08-03 14:32:06 +02:00
|
|
|
type = FILE_TYPE_DIRECTORY;
|
|
|
|
|
2015-03-23 18:47:52 +01:00
|
|
|
key.path = (char *) path;
|
|
|
|
key_ptr = &key;
|
2015-03-30 02:02:14 +02:00
|
|
|
exists = (bsearch(&key_ptr, map->array, map->narray, sizeof(file_entry_t *),
|
|
|
|
path_cmp) != NULL);
|
2015-03-23 18:47:52 +01:00
|
|
|
|
2015-04-15 21:52:00 +02:00
|
|
|
/* Remove any file or folder that doesn't exist in the source system. */
|
2015-03-23 18:47:52 +01:00
|
|
|
if (!exists)
|
|
|
|
{
|
|
|
|
entry = pg_malloc(sizeof(file_entry_t));
|
|
|
|
entry->path = pg_strdup(path);
|
|
|
|
entry->type = type;
|
|
|
|
entry->action = FILE_ACTION_REMOVE;
|
|
|
|
entry->oldsize = oldsize;
|
|
|
|
entry->newsize = 0;
|
|
|
|
entry->link_target = link_target ? pg_strdup(link_target) : NULL;
|
|
|
|
entry->next = NULL;
|
|
|
|
entry->pagemap.bitmap = NULL;
|
|
|
|
entry->pagemap.bitmapsize = 0;
|
|
|
|
entry->isrelfile = isRelDataFile(path);
|
|
|
|
|
|
|
|
if (map->last == NULL)
|
|
|
|
map->first = entry;
|
|
|
|
else
|
|
|
|
map->last->next = entry;
|
|
|
|
map->last = entry;
|
|
|
|
map->nlist++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
2015-04-15 21:52:00 +02:00
|
|
|
* We already handled all files that exist in the source system in
|
|
|
|
* process_source_file().
|
2015-03-23 18:47:52 +01:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-04-15 21:52:00 +02:00
|
|
|
* This callback gets called while we read the WAL in the target, for every
|
|
|
|
* block that have changed in the target system. It makes note of all the
|
|
|
|
* changed blocks in the pagemap of the file.
|
2015-03-23 18:47:52 +01:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
process_block_change(ForkNumber forknum, RelFileNode rnode, BlockNumber blkno)
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
file_entry_t key;
|
|
|
|
file_entry_t *key_ptr;
|
|
|
|
file_entry_t *entry;
|
|
|
|
BlockNumber blkno_inseg;
|
|
|
|
int segno;
|
|
|
|
filemap_t *map = filemap;
|
|
|
|
file_entry_t **e;
|
|
|
|
|
2015-03-30 02:02:14 +02:00
|
|
|
Assert(map->array);
|
2015-03-23 18:47:52 +01:00
|
|
|
|
|
|
|
segno = blkno / RELSEG_SIZE;
|
|
|
|
blkno_inseg = blkno % RELSEG_SIZE;
|
|
|
|
|
|
|
|
path = datasegpath(rnode, forknum, segno);
|
|
|
|
|
|
|
|
key.path = (char *) path;
|
|
|
|
key_ptr = &key;
|
|
|
|
|
|
|
|
e = bsearch(&key_ptr, map->array, map->narray, sizeof(file_entry_t *),
|
|
|
|
path_cmp);
|
|
|
|
if (e)
|
|
|
|
entry = *e;
|
|
|
|
else
|
|
|
|
entry = NULL;
|
2015-06-11 15:31:18 +02:00
|
|
|
pfree(path);
|
2015-03-23 18:47:52 +01:00
|
|
|
|
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
Assert(entry->isrelfile);
|
|
|
|
|
|
|
|
switch (entry->action)
|
|
|
|
{
|
|
|
|
case FILE_ACTION_NONE:
|
|
|
|
case FILE_ACTION_TRUNCATE:
|
|
|
|
/* skip if we're truncating away the modified block anyway */
|
|
|
|
if ((blkno_inseg + 1) * BLCKSZ <= entry->newsize)
|
|
|
|
datapagemap_add(&entry->pagemap, blkno_inseg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FILE_ACTION_COPY_TAIL:
|
2015-05-24 03:35:49 +02:00
|
|
|
|
2015-03-23 18:47:52 +01:00
|
|
|
/*
|
|
|
|
* skip the modified block if it is part of the "tail" that
|
|
|
|
* we're copying anyway.
|
|
|
|
*/
|
|
|
|
if ((blkno_inseg + 1) * BLCKSZ <= entry->oldsize)
|
|
|
|
datapagemap_add(&entry->pagemap, blkno_inseg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FILE_ACTION_COPY:
|
|
|
|
case FILE_ACTION_REMOVE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FILE_ACTION_CREATE:
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_fatal("unexpected page modification for directory or symbolic link \"%s\"", entry->path);
|
2015-03-23 18:47:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If we don't have any record of this file in the file map, it means
|
2015-04-15 21:52:00 +02:00
|
|
|
* that it's a relation that doesn't exist in the source system, and
|
2015-05-24 03:35:49 +02:00
|
|
|
* it was subsequently removed in the target system, too. We can
|
|
|
|
* safely ignore it.
|
2015-03-23 18:47:52 +01:00
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-28 21:56:52 +02:00
|
|
|
/*
|
|
|
|
* Is this the path of file that pg_rewind can skip copying?
|
|
|
|
*/
|
|
|
|
static bool
|
2018-09-13 23:35:43 +02:00
|
|
|
check_file_excluded(const char *path, bool is_source)
|
2018-03-28 21:56:52 +02:00
|
|
|
{
|
2018-04-26 20:47:16 +02:00
|
|
|
char localpath[MAXPGPATH];
|
|
|
|
int excludeIdx;
|
|
|
|
const char *filename;
|
2018-03-28 21:56:52 +02:00
|
|
|
|
|
|
|
/* check individual files... */
|
|
|
|
for (excludeIdx = 0; excludeFiles[excludeIdx] != NULL; excludeIdx++)
|
|
|
|
{
|
|
|
|
filename = last_dir_separator(path);
|
|
|
|
if (filename == NULL)
|
|
|
|
filename = path;
|
|
|
|
else
|
|
|
|
filename++;
|
|
|
|
if (strcmp(filename, excludeFiles[excludeIdx]) == 0)
|
|
|
|
{
|
2018-09-13 23:35:43 +02:00
|
|
|
if (is_source)
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_debug("entry \"%s\" excluded from source file list",
|
2019-05-22 18:55:34 +02:00
|
|
|
path);
|
2018-09-13 23:35:43 +02:00
|
|
|
else
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_debug("entry \"%s\" excluded from target file list",
|
2019-05-22 18:55:34 +02:00
|
|
|
path);
|
2018-03-28 21:56:52 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ... And check some directories. Note that this includes any contents
|
|
|
|
* within the directories themselves.
|
|
|
|
*/
|
|
|
|
for (excludeIdx = 0; excludeDirContents[excludeIdx] != NULL; excludeIdx++)
|
|
|
|
{
|
|
|
|
snprintf(localpath, sizeof(localpath), "%s/",
|
|
|
|
excludeDirContents[excludeIdx]);
|
|
|
|
if (strstr(path, localpath) == path)
|
|
|
|
{
|
2018-09-13 23:35:43 +02:00
|
|
|
if (is_source)
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_debug("entry \"%s\" excluded from source file list",
|
2019-05-22 18:55:34 +02:00
|
|
|
path);
|
2018-09-13 23:35:43 +02:00
|
|
|
else
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_debug("entry \"%s\" excluded from target file list",
|
2019-05-22 18:55:34 +02:00
|
|
|
path);
|
2018-03-28 21:56:52 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-23 18:47:52 +01:00
|
|
|
/*
|
2015-03-30 02:02:14 +02:00
|
|
|
* Convert the linked list of entries in map->first/last to the array,
|
|
|
|
* map->array.
|
2015-03-23 18:47:52 +01:00
|
|
|
*/
|
|
|
|
static void
|
2015-03-30 02:02:14 +02:00
|
|
|
filemap_list_to_array(filemap_t *map)
|
2015-03-23 18:47:52 +01:00
|
|
|
{
|
|
|
|
int narray;
|
|
|
|
file_entry_t *entry,
|
|
|
|
*next;
|
|
|
|
|
2015-03-30 02:02:14 +02:00
|
|
|
map->array = (file_entry_t **)
|
|
|
|
pg_realloc(map->array,
|
|
|
|
(map->nlist + map->narray) * sizeof(file_entry_t *));
|
2015-03-23 18:47:52 +01:00
|
|
|
|
2015-03-30 02:02:14 +02:00
|
|
|
narray = map->narray;
|
|
|
|
for (entry = map->first; entry != NULL; entry = next)
|
2015-03-23 18:47:52 +01:00
|
|
|
{
|
2015-03-30 02:02:14 +02:00
|
|
|
map->array[narray++] = entry;
|
2015-03-23 18:47:52 +01:00
|
|
|
next = entry->next;
|
|
|
|
entry->next = NULL;
|
|
|
|
}
|
2015-03-30 02:02:14 +02:00
|
|
|
Assert(narray == map->nlist + map->narray);
|
|
|
|
map->narray = narray;
|
|
|
|
map->nlist = 0;
|
|
|
|
map->first = map->last = NULL;
|
2015-03-23 18:47:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
filemap_finalize(void)
|
|
|
|
{
|
2015-03-30 02:02:14 +02:00
|
|
|
filemap_t *map = filemap;
|
|
|
|
|
|
|
|
filemap_list_to_array(map);
|
|
|
|
qsort(map->array, map->narray, sizeof(file_entry_t *),
|
2015-03-23 18:47:52 +01:00
|
|
|
final_filemap_cmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
action_to_str(file_action_t action)
|
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case FILE_ACTION_NONE:
|
|
|
|
return "NONE";
|
|
|
|
case FILE_ACTION_COPY:
|
|
|
|
return "COPY";
|
|
|
|
case FILE_ACTION_TRUNCATE:
|
|
|
|
return "TRUNCATE";
|
|
|
|
case FILE_ACTION_COPY_TAIL:
|
|
|
|
return "COPY_TAIL";
|
|
|
|
case FILE_ACTION_CREATE:
|
|
|
|
return "CREATE";
|
|
|
|
case FILE_ACTION_REMOVE:
|
|
|
|
return "REMOVE";
|
|
|
|
|
|
|
|
default:
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the totals needed for progress reports.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
calculate_totals(void)
|
|
|
|
{
|
|
|
|
file_entry_t *entry;
|
|
|
|
int i;
|
|
|
|
filemap_t *map = filemap;
|
|
|
|
|
|
|
|
map->total_size = 0;
|
|
|
|
map->fetch_size = 0;
|
|
|
|
|
2015-03-30 02:02:14 +02:00
|
|
|
for (i = 0; i < map->narray; i++)
|
2015-03-23 18:47:52 +01:00
|
|
|
{
|
2015-03-30 02:02:14 +02:00
|
|
|
entry = map->array[i];
|
2015-03-23 18:47:52 +01:00
|
|
|
|
|
|
|
if (entry->type != FILE_TYPE_REGULAR)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
map->total_size += entry->newsize;
|
|
|
|
|
|
|
|
if (entry->action == FILE_ACTION_COPY)
|
|
|
|
{
|
|
|
|
map->fetch_size += entry->newsize;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry->action == FILE_ACTION_COPY_TAIL)
|
|
|
|
map->fetch_size += (entry->newsize - entry->oldsize);
|
|
|
|
|
|
|
|
if (entry->pagemap.bitmapsize > 0)
|
|
|
|
{
|
|
|
|
datapagemap_iterator_t *iter;
|
|
|
|
BlockNumber blk;
|
|
|
|
|
|
|
|
iter = datapagemap_iterate(&entry->pagemap);
|
|
|
|
while (datapagemap_next(iter, &blk))
|
|
|
|
map->fetch_size += BLCKSZ;
|
|
|
|
|
|
|
|
pg_free(iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
print_filemap(void)
|
|
|
|
{
|
2015-03-30 02:02:14 +02:00
|
|
|
filemap_t *map = filemap;
|
2015-03-23 18:47:52 +01:00
|
|
|
file_entry_t *entry;
|
|
|
|
int i;
|
|
|
|
|
2015-03-30 02:02:14 +02:00
|
|
|
for (i = 0; i < map->narray; i++)
|
2015-03-23 18:47:52 +01:00
|
|
|
{
|
2015-03-30 02:02:14 +02:00
|
|
|
entry = map->array[i];
|
2015-03-23 18:47:52 +01:00
|
|
|
if (entry->action != FILE_ACTION_NONE ||
|
|
|
|
entry->pagemap.bitmapsize > 0)
|
|
|
|
{
|
Unified logging system for command-line programs
This unifies the various ad hoc logging (message printing, error
printing) systems used throughout the command-line programs.
Features:
- Program name is automatically prefixed.
- Message string does not end with newline. This removes a common
source of inconsistencies and omissions.
- Additionally, a final newline is automatically stripped, simplifying
use of PQerrorMessage() etc., another common source of mistakes.
- I converted error message strings to use %m where possible.
- As a result of the above several points, more translatable message
strings can be shared between different components and between
frontends and backend, without gratuitous punctuation or whitespace
differences.
- There is support for setting a "log level". This is not meant to be
user-facing, but can be used internally to implement debug or
verbose modes.
- Lazy argument evaluation, so no significant overhead if logging at
some level is disabled.
- Some color in the messages, similar to gcc and clang. Set
PG_COLOR=auto to try it out. Some colors are predefined, but can be
customized by setting PG_COLORS.
- Common files (common/, fe_utils/, etc.) can handle logging much more
simply by just using one API without worrying too much about the
context of the calling program, requiring callbacks, or having to
pass "progname" around everywhere.
- Some programs called setvbuf() to make sure that stderr is
unbuffered, even on Windows. But not all programs did that. This
is now done centrally.
Soft goals:
- Reduces vertical space use and visual complexity of error reporting
in the source code.
- Encourages more deliberate classification of messages. For example,
in some cases it wasn't clear without analyzing the surrounding code
whether a message was meant as an error or just an info.
- Concepts and terms are vaguely aligned with popular logging
frameworks such as log4j and Python logging.
This is all just about printing stuff out. Nothing affects program
flow (e.g., fatal exits). The uses are just too varied to do that.
Some existing code had wrappers that do some kind of print-and-exit,
and I adapted those.
I tried to keep the output mostly the same, but there is a lot of
historical baggage to unwind and special cases to consider, and I
might not always have succeeded. One significant change is that
pg_rewind used to write all error messages to stdout. That is now
changed to stderr.
Reviewed-by: Donald Dong <xdong@csumb.edu>
Reviewed-by: Arthur Zakirov <a.zakirov@postgrespro.ru>
Discussion: https://www.postgresql.org/message-id/flat/6a609b43-4f57-7348-6480-bd022f924310@2ndquadrant.com
2019-04-01 14:24:37 +02:00
|
|
|
pg_log_debug("%s (%s)", entry->path,
|
2019-05-22 18:55:34 +02:00
|
|
|
action_to_str(entry->action));
|
2015-03-23 18:47:52 +01:00
|
|
|
|
|
|
|
if (entry->pagemap.bitmapsize > 0)
|
|
|
|
datapagemap_print(&entry->pagemap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Does it look like a relation data file?
|
|
|
|
*
|
|
|
|
* For our purposes, only files belonging to the main fork are considered
|
2015-06-11 15:31:18 +02:00
|
|
|
* relation files. Other forks are always copied in toto, because we cannot
|
2015-03-23 18:47:52 +01:00
|
|
|
* reliably track changes to them, because WAL only contains block references
|
|
|
|
* for the main fork.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
isRelDataFile(const char *path)
|
|
|
|
{
|
|
|
|
RelFileNode rnode;
|
|
|
|
unsigned int segNo;
|
|
|
|
int nmatch;
|
|
|
|
bool matched;
|
|
|
|
|
|
|
|
/*----
|
|
|
|
* Relation data files can be in one of the following directories:
|
|
|
|
*
|
|
|
|
* global/
|
|
|
|
* shared relations
|
|
|
|
*
|
|
|
|
* base/<db oid>/
|
|
|
|
* regular relations, default tablespace
|
|
|
|
*
|
2018-03-05 18:08:18 +01:00
|
|
|
* pg_tblspc/<tblspc oid>/<tblspc version>/
|
2015-03-23 18:47:52 +01:00
|
|
|
* within a non-default tablespace (the name of the directory
|
|
|
|
* depends on version)
|
|
|
|
*
|
|
|
|
* And the relation data files themselves have a filename like:
|
|
|
|
*
|
|
|
|
* <oid>.<segment number>
|
|
|
|
*
|
|
|
|
*----
|
|
|
|
*/
|
|
|
|
rnode.spcNode = InvalidOid;
|
|
|
|
rnode.dbNode = InvalidOid;
|
|
|
|
rnode.relNode = InvalidOid;
|
|
|
|
segNo = 0;
|
|
|
|
matched = false;
|
|
|
|
|
|
|
|
nmatch = sscanf(path, "global/%u.%u", &rnode.relNode, &segNo);
|
|
|
|
if (nmatch == 1 || nmatch == 2)
|
|
|
|
{
|
|
|
|
rnode.spcNode = GLOBALTABLESPACE_OID;
|
|
|
|
rnode.dbNode = 0;
|
|
|
|
matched = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nmatch = sscanf(path, "base/%u/%u.%u",
|
|
|
|
&rnode.dbNode, &rnode.relNode, &segNo);
|
|
|
|
if (nmatch == 2 || nmatch == 3)
|
|
|
|
{
|
|
|
|
rnode.spcNode = DEFAULTTABLESPACE_OID;
|
|
|
|
matched = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-03-05 18:08:18 +01:00
|
|
|
nmatch = sscanf(path, "pg_tblspc/%u/" TABLESPACE_VERSION_DIRECTORY "/%u/%u.%u",
|
|
|
|
&rnode.spcNode, &rnode.dbNode, &rnode.relNode,
|
2015-03-23 18:47:52 +01:00
|
|
|
&segNo);
|
2018-03-05 18:08:18 +01:00
|
|
|
if (nmatch == 3 || nmatch == 4)
|
2015-03-23 18:47:52 +01:00
|
|
|
matched = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The sscanf tests above can match files that have extra characters at
|
2018-03-05 18:08:18 +01:00
|
|
|
* the end. To eliminate such cases, cross-check that GetRelationPath
|
2018-04-26 20:47:16 +02:00
|
|
|
* creates the exact same filename, when passed the RelFileNode
|
|
|
|
* information we extracted from the filename.
|
2015-03-23 18:47:52 +01:00
|
|
|
*/
|
|
|
|
if (matched)
|
|
|
|
{
|
|
|
|
char *check_path = datasegpath(rnode, MAIN_FORKNUM, segNo);
|
|
|
|
|
|
|
|
if (strcmp(check_path, path) != 0)
|
|
|
|
matched = false;
|
|
|
|
|
|
|
|
pfree(check_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return matched;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A helper function to create the path of a relation file and segment.
|
|
|
|
*
|
|
|
|
* The returned path is palloc'd
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
datasegpath(RelFileNode rnode, ForkNumber forknum, BlockNumber segno)
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
char *segpath;
|
|
|
|
|
|
|
|
path = relpathperm(rnode, forknum);
|
|
|
|
if (segno > 0)
|
|
|
|
{
|
|
|
|
segpath = psprintf("%s.%u", path, segno);
|
|
|
|
pfree(path);
|
|
|
|
return segpath;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
path_cmp(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
file_entry_t *fa = *((file_entry_t **) a);
|
|
|
|
file_entry_t *fb = *((file_entry_t **) b);
|
|
|
|
|
|
|
|
return strcmp(fa->path, fb->path);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In the final stage, the filemap is sorted so that removals come last.
|
|
|
|
* From disk space usage point of view, it would be better to do removals
|
|
|
|
* first, but for now, safety first. If a whole directory is deleted, all
|
|
|
|
* files and subdirectories inside it need to removed first. On creation,
|
|
|
|
* parent directory needs to be created before files and directories inside
|
|
|
|
* it. To achieve that, the file_action_t enum is ordered so that we can
|
|
|
|
* just sort on that first. Furthermore, sort REMOVE entries in reverse
|
|
|
|
* path order, so that "foo/bar" subdirectory is removed before "foo".
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
final_filemap_cmp(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
file_entry_t *fa = *((file_entry_t **) a);
|
|
|
|
file_entry_t *fb = *((file_entry_t **) b);
|
|
|
|
|
|
|
|
if (fa->action > fb->action)
|
|
|
|
return 1;
|
|
|
|
if (fa->action < fb->action)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (fa->action == FILE_ACTION_REMOVE)
|
Allow btree comparison functions to return INT_MIN.
Historically we forbade datatype-specific comparison functions from
returning INT_MIN, so that it would be safe to invert the sort order
just by negating the comparison result. However, this was never
really safe for comparison functions that directly return the result
of memcmp(), strcmp(), etc, as POSIX doesn't place any such restriction
on those library functions. Buildfarm results show that at least on
recent Linux on s390x, memcmp() actually does return INT_MIN sometimes,
causing sort failures.
The agreed-on answer is to remove this restriction and fix relevant
call sites to not make such an assumption; code such as "res = -res"
should be replaced by "INVERT_COMPARE_RESULT(res)". The same is needed
in a few places that just directly negated the result of memcmp or
strcmp.
To help find places having this problem, I've also added a compile option
to nbtcompare.c that causes some of the commonly used comparators to
return INT_MIN/INT_MAX instead of their usual -1/+1. It'd likely be
a good idea to have at least one buildfarm member running with
"-DSTRESS_SORT_INT_MIN". That's far from a complete test of course,
but it should help to prevent fresh introductions of such bugs.
This is a longstanding portability hazard, so back-patch to all supported
branches.
Discussion: https://postgr.es/m/20180928185215.ffoq2xrq5d3pafna@alap3.anarazel.de
2018-10-05 22:01:29 +02:00
|
|
|
return strcmp(fb->path, fa->path);
|
2015-03-23 18:47:52 +01:00
|
|
|
else
|
|
|
|
return strcmp(fa->path, fb->path);
|
|
|
|
}
|