Skip to content

Commit d29b005

Browse files
oleg gurevpostgres-dev
authored andcommitted
Rename default-units to no-scale-units
1 parent 79d2b9d commit d29b005

File tree

10 files changed

+34
-21
lines changed

10 files changed

+34
-21
lines changed

doc/pgprobackup.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4267,6 +4267,7 @@ pg_probackup set-backup -B <replaceable>backup_dir</replaceable> --instance <rep
42674267
<title>show-config</title>
42684268
<programlisting>
42694269
pg_probackup show-config -B <replaceable>backup_dir</replaceable> --instance <replaceable>instance_name</replaceable> [--format=plain|json]
4270+
[--no-scale-units] [<replaceable>logging_options</replaceable>]
42704271
</programlisting>
42714272
<para>
42724273
Displays the contents of the <filename>pg_probackup.conf</filename> configuration
@@ -4277,6 +4278,18 @@ pg_probackup show-config -B <replaceable>backup_dir</replaceable> --instance <re
42774278
in the <acronym>JSON</acronym> format. By default, configuration settings are
42784279
shown as plain text.
42794280
</para>
4281+
<para>
4282+
You can also specify the <option>--no-scale-units</option>
4283+
option to display time and memory configuration settings in their base (unscaled) units.
4284+
Otherwise, the values are scaled to larger units for optimal display.
4285+
For example, if <literal>archive-timeout</literal> is 300, then
4286+
<literal>5min</literal> is displayed, but if <literal>archive-timeout</literal>
4287+
is 301, then <literal>301s</literal> is displayed.
4288+
Also, if the <option>--no-scale-units</option> option is specified, configuration
4289+
settings are displayed without units and for the JSON format,
4290+
numeric and boolean values are not enclosed in quotes. This facilitates parsing
4291+
the output.
4292+
</para>
42804293
<para>
42814294
To edit <filename>pg_probackup.conf</filename>, use the
42824295
<xref linkend="pbk-set-config"/> command.

src/configure.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,21 +269,21 @@ static const char *current_group = NULL;
269269
* Show configure options including default values.
270270
*/
271271
void
272-
do_show_config(bool show_default_units)
272+
do_show_config(bool show_base_units)
273273
{
274274
int i;
275275

276276
show_configure_start();
277277

278278
for (i = 0; instance_options[i].type; i++)
279279
{
280-
if (show_default_units && strchr("bBiIuU", instance_options[i].type) && instance_options[i].get_value == *option_get_value)
281-
instance_options[i].flags |= GET_VAL_IN_DEFAULT_UNITS; /* Set flag */
280+
if (show_base_units && strchr("bBiIuU", instance_options[i].type) && instance_options[i].get_value == *option_get_value)
281+
instance_options[i].flags |= GET_VAL_IN_BASE_UNITS; /* Set flag */
282282
if (show_format == SHOW_PLAIN)
283283
show_configure_plain(&instance_options[i]);
284284
else
285285
show_configure_json(&instance_options[i]);
286-
instance_options[i].flags &= ~(GET_VAL_IN_DEFAULT_UNITS); /* Reset flag. It was resetted in option_get_value(). Probably this reset isn't needed */
286+
instance_options[i].flags &= ~(GET_VAL_IN_BASE_UNITS); /* Reset flag. It was resetted in option_get_value(). Probably this reset isn't needed */
287287
}
288288

289289
show_configure_end();
@@ -804,6 +804,6 @@ show_configure_json(ConfigOption *opt)
804804
return;
805805

806806
json_add_value(&show_buf, opt->lname, value, json_level,
807-
!(opt->flags & GET_VAL_IN_DEFAULT_UNITS));
807+
!(opt->flags & GET_VAL_IN_BASE_UNITS));
808808
pfree(value);
809809
}

src/help.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ help_pg_probackup(void)
121121

122122
printf(_("\n %s show-config -B backup-dir --instance=instance-name\n"), PROGRAM_NAME);
123123
printf(_(" [--format=format]\n"));
124-
printf(_(" [--default-units]\n"));
124+
printf(_(" [--no-scale-units]\n"));
125125
printf(_(" [--help]\n"));
126126

127127
printf(_("\n %s backup -B backup-dir -b backup-mode --instance=instance-name\n"), PROGRAM_NAME);
@@ -955,7 +955,7 @@ help_show_config(void)
955955
printf(_(" -B, --backup-path=backup-dir location of the backup storage area\n"));
956956
printf(_(" --instance=instance-name name of the instance\n"));
957957
printf(_(" --format=format show format=PLAIN|JSON\n"));
958-
printf(_(" --default-units show memory and time values in default units\n\n"));
958+
printf(_(" --no-scale-units show memory and time values in default units\n\n"));
959959
}
960960

961961
static void

src/pg_probackup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ bool no_validate_wal = false;
164164
/* show options */
165165
ShowFormat show_format = SHOW_PLAIN;
166166
bool show_archive = false;
167-
static bool show_default_units = false;
167+
static bool show_base_units = false;
168168

169169
/* set-backup options */
170170
int64 ttl = -1;
@@ -277,7 +277,7 @@ static ConfigOption cmd_options[] =
277277
{ 'f', 165, "format", opt_show_format, SOURCE_CMD_STRICT },
278278
{ 'b', 166, "archive", &show_archive, SOURCE_CMD_STRICT },
279279
/* show-config options */
280-
{ 'b', 167, "default-units", &show_default_units,SOURCE_CMD_STRICT },
280+
{ 'b', 167, "no-scale-units", &show_base_units,SOURCE_CMD_STRICT },
281281
/* set-backup options */
282282
{ 'I', 170, "ttl", &ttl, SOURCE_CMD_STRICT, SOURCE_DEFAULT, 0, OPTION_UNIT_S, option_get_value},
283283
{ 's', 171, "expire-time", &expire_time_string, SOURCE_CMD_STRICT },
@@ -1052,7 +1052,7 @@ main(int argc, char *argv[])
10521052
do_merge(instanceState, current.backup_id, no_validate, no_sync);
10531053
break;
10541054
case SHOW_CONFIG_CMD:
1055-
do_show_config(show_default_units);
1055+
do_show_config(show_base_units);
10561056
break;
10571057
case SET_CONFIG_CMD:
10581058
do_set_config(instanceState, false);

src/pg_probackup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ extern void do_archive_get(InstanceState *instanceState, InstanceConfig *instanc
939939
char *wal_file_name, int batch_size, bool validate_wal);
940940

941941
/* in configure.c */
942-
extern void do_show_config(bool show_default_units);
942+
extern void do_show_config(bool show_base_units);
943943
extern void do_set_config(InstanceState *instanceState, bool missing_ok);
944944
extern void init_config(InstanceConfig *config, const char *instance_name);
945945
extern InstanceConfig *readInstanceConfigFile(InstanceState *instanceState);

src/utils/configuration.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ config_set_opt(ConfigOption options[], void *var, OptionSource source)
678678
/*
679679
* Return value of the function in the string representation. Result is
680680
* allocated string.
681-
* We can set GET_VAL_IN_DEFAULT_UNITS flag in opt->flags
681+
* We can set GET_VAL_IN_BASE_UNITS flag in opt->flags
682682
* before call option_get_value() to get option value in default units
683683
*/
684684
char *
@@ -694,7 +694,7 @@ option_get_value(ConfigOption *opt)
694694
*/
695695
if (opt->flags & OPTION_UNIT)
696696
{
697-
if (opt->flags & GET_VAL_IN_DEFAULT_UNITS){
697+
if (opt->flags & GET_VAL_IN_BASE_UNITS){
698698
if (opt->type == 'i')
699699
value = *((int32 *) opt->var);
700700
else if (opt->type == 'I')

src/utils/configuration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct ConfigOption
100100
#define OPTION_UNIT_TIME 0xF0000 /* mask for time-related units */
101101

102102
#define OPTION_UNIT (OPTION_UNIT_MEMORY | OPTION_UNIT_TIME)
103-
#define GET_VAL_IN_DEFAULT_UNITS 0x80000000 /* bitflag to get memory and time values in default units*/
103+
#define GET_VAL_IN_BASE_UNITS 0x80000000 /* bitflag to get memory and time values in default units*/
104104

105105
extern ProbackupSubcmd parse_subcmd(char const * const subcmd_str);
106106
extern char const *get_subcmd_name(ProbackupSubcmd const subcmd);

tests/expected/option_help.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pg_probackup - utility to manage backup/recovery of PostgreSQL database.
3939

4040
pg_probackup show-config -B backup-dir --instance=instance-name
4141
[--format=format]
42-
[--default-units]
42+
[--no-scale-units]
4343
[--help]
4444

4545
pg_probackup backup -B backup-dir -b backup-mode --instance=instance-name

tests/expected/option_help_ru.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pg_probackup - утилита для управления резервным к
3939

4040
pg_probackup show-config -B backup-dir --instance=instance-name
4141
[--format=format]
42-
[--default-units]
42+
[--no-scale-units]
4343
[--help]
4444

4545
pg_probackup backup -B backup-dir -b backup-mode --instance=instance-name

tests/option_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,21 @@ def test_help_6(self):
222222
'You need configure PostgreSQL with --enabled-nls option for this test')
223223

224224
# @unittest.skip("skip")
225-
def test_options_default_units(self):
226-
"""check --default-units option"""
225+
def test_options_no_scale_units(self):
226+
"""check --no-scale-units option"""
227227
backup_dir = os.path.join(self.tmp_path, self.module_name, self.fname, 'backup')
228228
node = self.make_simple_node(
229229
base_dir=os.path.join(self.module_name, self.fname, 'node'))
230230
self.init_pb(backup_dir)
231231
self.add_instance(backup_dir, 'node', node)
232-
# check that --default-units option works correctly
232+
# check that --no-scale-units option works correctly
233233
output = self.run_pb(["show-config", "--backup-path", backup_dir, "--instance=node"])
234234
self.assertIn(container=output, member="archive-timeout = 5min")
235-
output = self.run_pb(["show-config", "--backup-path", backup_dir, "--instance=node", "--default-units"])
235+
output = self.run_pb(["show-config", "--backup-path", backup_dir, "--instance=node", "--no-scale-units"])
236236
self.assertIn(container=output, member="archive-timeout = 300")
237237
self.assertNotIn(container=output, member="archive-timeout = 300s")
238238
# check that we have now quotes ("") in json output
239-
output = self.run_pb(["show-config", "--backup-path", backup_dir, "--instance=node", "--default-units", "--format=json"])
239+
output = self.run_pb(["show-config", "--backup-path", backup_dir, "--instance=node", "--no-scale-units", "--format=json"])
240240
self.assertIn(container=output, member='"archive-timeout": 300,')
241241
self.assertIn(container=output, member='"retention-redundancy": 0,')
242242
self.assertNotIn(container=output, member='"archive-timeout": "300",')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy