Update variable/field names relating to pg_basebackup's -X option

Now the "xlog nomenclature" Pg versions are fading into the past,
rename things related to handling pg_basebackup's -X option
(was: --xlog-method, now: --wal-method) to start with "wal_"
rather than "xlog_".

This is a cosmetic change for code clarity.
This commit is contained in:
Ian Barwick
2019-05-30 09:32:06 +09:00
parent 9085ca46a8
commit 45e17223b9
3 changed files with 24 additions and 21 deletions

View File

@@ -2058,18 +2058,10 @@ parse_pg_basebackup_options(const char *pg_basebackup_options, t_basebackup_opti
struct option *long_options = NULL;
/* We're only interested in these options */
static struct option long_options_9[] =
{
{"slot", required_argument, NULL, 'S'},
{"xlog-method", required_argument, NULL, 'X'},
{NULL, 0, NULL, 0}
};
/*
* From PostgreSQL 10, --xlog-method is renamed --wal-method and there's
* also --no-slot, which we'll want to consider.
* We're only interested in these options.
*/
static struct option long_options_10[] =
{
{"slot", required_argument, NULL, 'S'},
@@ -2078,6 +2070,17 @@ parse_pg_basebackup_options(const char *pg_basebackup_options, t_basebackup_opti
{NULL, 0, NULL, 0}
};
/*
* Pre-PostgreSQL 10 options
*/
static struct option long_options_legacy[] =
{
{"slot", required_argument, NULL, 'S'},
{"xlog-method", required_argument, NULL, 'X'},
{NULL, 0, NULL, 0}
};
/* Don't attempt to tokenise an empty string */
if (!strlen(pg_basebackup_options))
return backup_options_ok;
@@ -2085,7 +2088,7 @@ parse_pg_basebackup_options(const char *pg_basebackup_options, t_basebackup_opti
if (server_version_num >= 100000)
long_options = long_options_10;
else
long_options = long_options_9;
long_options = long_options_legacy;
argc_item = parse_output_to_argv(pg_basebackup_options, &argv_array);
@@ -2104,7 +2107,7 @@ parse_pg_basebackup_options(const char *pg_basebackup_options, t_basebackup_opti
strncpy(backup_options->slot, optarg, MAXLEN);
break;
case 'X':
strncpy(backup_options->xlog_method, optarg, MAXLEN);
strncpy(backup_options->wal_method, optarg, MAXLEN);
break;
case 1:
backup_options->no_slot = true;

View File

@@ -251,7 +251,7 @@ typedef struct
typedef struct
{
char slot[MAXLEN];
char xlog_method[MAXLEN];
char wal_method[MAXLEN];
bool no_slot; /* from PostgreSQL 10 */
} t_basebackup_options;

View File

@@ -5196,7 +5196,7 @@ check_upstream_config(PGconn *conn, int server_version_num, t_node_info *upstrea
t_basebackup_options backup_options = T_BASEBACKUP_OPTIONS_INITIALIZER;
bool backup_options_ok = true;
ItemList backup_option_errors = {NULL, NULL};
bool xlog_stream = true;
bool wal_method_stream = true;
standy_clone_mode mode;
bool pg_setting_ok;
@@ -5206,7 +5206,7 @@ check_upstream_config(PGconn *conn, int server_version_num, t_node_info *upstrea
mode = get_standby_clone_mode();
/*
* Parse `pg_basebackup_options`, if set, to detect whether --xlog-method
* Parse "pg_basebackup_options", if set, to detect whether --wal-method
* has been set to something other than `stream` (i.e. `fetch`), as this
* will influence some checks
*/
@@ -5229,8 +5229,8 @@ check_upstream_config(PGconn *conn, int server_version_num, t_node_info *upstrea
config_ok = false;
}
if (strlen(backup_options.xlog_method) && strcmp(backup_options.xlog_method, "stream") != 0)
xlog_stream = false;
if (strlen(backup_options.wal_method) && strcmp(backup_options.wal_method, "stream") != 0)
wal_method_stream = false;
/* Check that WAL level is set correctly */
if (server_version_num < 90400)
@@ -5338,7 +5338,7 @@ check_upstream_config(PGconn *conn, int server_version_num, t_node_info *upstrea
* required if pg_basebackup is being used with --xlog-method=fetch,
* *and* no restore command has been specified
*/
if (xlog_stream == false
if (wal_method_stream == false
&& strcmp(config_file_options.restore_command, "") == 0)
{
check_wal_keep_segments = true;
@@ -5483,7 +5483,7 @@ check_upstream_config(PGconn *conn, int server_version_num, t_node_info *upstrea
* work out how many replication connections are required (1 or 2)
*/
if (xlog_stream == true)
if (wal_method_stream == true)
min_replication_connections += 1;
log_notice(_("checking for available walsenders on the source node (%i required)"),
@@ -5889,7 +5889,7 @@ run_basebackup(t_node_info *node_record)
* avoid WAL buildup on the primary using the -S/--slot, which requires
* -X/--xlog-method=stream (from 10, -X/--wal-method=stream)
*/
if (!strlen(backup_options.xlog_method))
if (!strlen(backup_options.wal_method))
{
appendPQExpBufferStr(&params, " -X stream");
}
@@ -5917,7 +5917,7 @@ run_basebackup(t_node_info *node_record)
* option set, or if --wal-method (--xlog-method) is set to a value
* other than "stream" (in which case we can't use --slot).
*/
if (strlen(backup_options.slot) || (strlen(backup_options.xlog_method) && strcmp(backup_options.xlog_method, "stream") != 0))
if (strlen(backup_options.slot) || (strlen(backup_options.wal_method) && strcmp(backup_options.wal_method, "stream") != 0))
{
slot_add = false;
}