pgbackrest.git / summary / log / commit / refs

commit    09fdde359c8b70653fcafe9ad39fcb25bdbc672b
Author:   David Steele <david@pgmasters.net>
Date:     Thu Dec 31 15:08:58 2020 +0000

    Limit pg option validity and make it command-line only.
    
    The pg option only has one current usage, to let the backup local know which pg index it should copy files from.
    
    There are other possible uses for this option, but they need thought, tests, and documentation.


build/lib/pgBackRestBuild/Config/Data.pm | 26 ------------------------- doc/xml/reference.xml | 13 ------------- src/config/parse.auto.c | 33 +------------------------------- src/protocol/helper.c | 4 ---- test/src/module/command/localTest.c | 1 - test/src/module/config/parseTest.c | 14 +++++--------- test/src/module/protocol/protocolTest.c | 7 +++---- 7 files changed, 9 insertions(+), 89 deletions(-) diff --git a/build/lib/pgBackRestBuild/Config/Data.pm b/build/lib/pgBackRestBuild/Config/Data.pm index 340cf2696..354f09824 100644 --- a/build/lib/pgBackRestBuild/Config/Data.pm +++ b/build/lib/pgBackRestBuild/Config/Data.pm @@ -2906,43 +2906,17 @@ my %hConfigDefine = #------------------------------------------------------------------------------------------------------------------------------- &CFGOPT_PG => { - &CFGDEF_SECTION => CFGDEF_SECTION_STANZA, &CFGDEF_TYPE => CFGDEF_TYPE_INTEGER, &CFGDEF_INTERNAL => true, &CFGDEF_REQUIRED => false, &CFGDEF_ALLOW_RANGE => [1, CFGDEF_INDEX_PG], &CFGDEF_COMMAND => { - &CFGCMD_ARCHIVE_GET => {}, - &CFGCMD_ARCHIVE_PUSH => {}, &CFGCMD_BACKUP => { &CFGDEF_COMMAND_ROLE => { &CFGCMD_ROLE_LOCAL => {}, - &CFGCMD_ROLE_REMOTE => {}, - }, - }, - &CFGCMD_CHECK => - { - &CFGDEF_COMMAND_ROLE => - { - &CFGCMD_ROLE_REMOTE => {}, - }, - }, - &CFGCMD_RESTORE => {}, - &CFGCMD_STANZA_CREATE => - { - &CFGDEF_COMMAND_ROLE => - { - &CFGCMD_ROLE_REMOTE => {}, - }, - }, - &CFGCMD_STANZA_UPGRADE => - { - &CFGDEF_COMMAND_ROLE => - { - &CFGCMD_ROLE_REMOTE => {}, }, }, }, diff --git a/doc/xml/reference.xml b/doc/xml/reference.xml index 8c48ce8db..32ada0e25 100644 --- a/doc/xml/reference.xml +++ b/doc/xml/reference.xml @@ -1036,19 +1036,6 @@ <example>db_owner</example> </config-key> - <!-- ======================================================================================================= --> - <config-key id="pg" name="Set PostgreSQL Cluster"> - <summary>Set PostgreSQL cluster.</summary> - - <text>Set the <postgres/> cluster for a command to operate on. - - For example, this option may be used to perform a restore to a specific <postgres/> cluster, rather than using the first configured cluster. - - Note that some commands, e.g. <cmd>backup</cmd>, are intended to operate on multiple <postgres/> clusters and will ignore this option.</text> - - <example>1</example> - </config-key> - <!-- ======================================================================================================= --> <config-key id="pg-database" name="PostgreSQL Database"> <summary><postgres/> database.</summary> diff --git a/src/config/parse.auto.c b/src/config/parse.auto.c index ec0e772c8..ce54ddee5 100644 --- a/src/config/parse.auto.c +++ b/src/config/parse.auto.c @@ -2077,38 +2077,11 @@ static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] = PARSE_RULE_OPTION_NAME("pg"), PARSE_RULE_OPTION_TYPE(cfgOptTypeInteger), PARSE_RULE_OPTION_REQUIRED(false), - PARSE_RULE_OPTION_SECTION(cfgSectionStanza), - - PARSE_RULE_OPTION_COMMAND_ROLE_DEFAULT_VALID_LIST - ( - PARSE_RULE_OPTION_COMMAND(cfgCmdArchiveGet) - PARSE_RULE_OPTION_COMMAND(cfgCmdArchivePush) - PARSE_RULE_OPTION_COMMAND(cfgCmdRestore) - ), - - PARSE_RULE_OPTION_COMMAND_ROLE_ASYNC_VALID_LIST - ( - PARSE_RULE_OPTION_COMMAND(cfgCmdArchiveGet) - PARSE_RULE_OPTION_COMMAND(cfgCmdArchivePush) - ), + PARSE_RULE_OPTION_SECTION(cfgSectionCommandLine), PARSE_RULE_OPTION_COMMAND_ROLE_LOCAL_VALID_LIST ( - PARSE_RULE_OPTION_COMMAND(cfgCmdArchiveGet) - PARSE_RULE_OPTION_COMMAND(cfgCmdArchivePush) PARSE_RULE_OPTION_COMMAND(cfgCmdBackup) - PARSE_RULE_OPTION_COMMAND(cfgCmdRestore) - ), - - PARSE_RULE_OPTION_COMMAND_ROLE_REMOTE_VALID_LIST - ( - PARSE_RULE_OPTION_COMMAND(cfgCmdArchiveGet) - PARSE_RULE_OPTION_COMMAND(cfgCmdArchivePush) - PARSE_RULE_OPTION_COMMAND(cfgCmdBackup) - PARSE_RULE_OPTION_COMMAND(cfgCmdCheck) - PARSE_RULE_OPTION_COMMAND(cfgCmdRestore) - PARSE_RULE_OPTION_COMMAND(cfgCmdStanzaCreate) - PARSE_RULE_OPTION_COMMAND(cfgCmdStanzaUpgrade) ), PARSE_RULE_OPTION_OPTIONAL_LIST @@ -7015,10 +6988,6 @@ static const struct option optionList[] = .has_arg = required_argument, .val = PARSE_OPTION_FLAG | cfgOptPg, }, - { - .name = "reset-pg", - .val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPg, - }, // pg-database option // ----------------------------------------------------------------------------------------------------------------------------- diff --git a/src/protocol/helper.c b/src/protocol/helper.c index abae67c82..8c08d276e 100644 --- a/src/protocol/helper.c +++ b/src/protocol/helper.c @@ -389,10 +389,6 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int hostId } } - // Set default to make it explicit which host will be used on the remote - if (protocolStorageType == protocolStorageTypePg) - kvPut(optionReplace, VARSTRDEF(CFGOPT_PG), VARUINT(1)); - // Add the process id if not set. This means that the remote is being started from the main process and should always get a // process id of 0. if (!cfgOptionTest(cfgOptProcess)) diff --git a/test/src/module/command/localTest.c b/test/src/module/command/localTest.c index b9cb2a068..770b0cfb6 100644 --- a/test/src/module/command/localTest.c +++ b/test/src/module/command/localTest.c @@ -35,7 +35,6 @@ testRun(void) hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg"); strLstAddZ(argList, "--process=1"); strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO); - hrnCfgArgRawZ(argList, cfgOptPg, "1"); harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList); cmdLocal(HARNESS_FORK_CHILD_READ(), HARNESS_FORK_CHILD_WRITE()); diff --git a/test/src/module/config/parseTest.c b/test/src/module/config/parseTest.c index 7f5ffc26b..980b8c63c 100644 --- a/test/src/module/config/parseTest.c +++ b/test/src/module/config/parseTest.c @@ -761,8 +761,9 @@ testRun(void) // ------------------------------------------------------------------------------------------------------------------------- argList = strLstNew(); strLstAdd(argList, strNew("pgbackrest")); - hrnCfgArgRawZ(argList, cfgOptPg, "1"); - hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to"); + hrnCfgArgRawZ(argList, cfgOptPg, "2"); + hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, "/path/to/1"); + hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 2, "/path/to/2"); strLstAdd(argList, strNew("--process=1")); strLstAdd(argList, strNew("--stanza=db")); strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO); @@ -772,6 +773,7 @@ testRun(void) logLevelStdOut = logLevelError; logLevelStdErr = logLevelError; TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "load local config"); + TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/2", "default pg-path"); TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleLocal, " command role is local"); TEST_RESULT_BOOL(cfgLockRequired(), false, " backup:local command does not require lock"); TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup:local", " command/role name is backup:local"); @@ -1469,15 +1471,11 @@ testRun(void) setenv("PGBACKREST_STANZA", "db", true); setenv("PGBACKREST_PG1_PATH", "/path/to/db", true); - hrnCfgEnvKeyRawZ(cfgOptPgPath, 2, "/path/to/db2"); - hrnCfgEnvRawZ(cfgOptPg, "2"); setenv("PGBACKREST_RECOVERY_OPTION", "f=g:hijk=l", true); setenv("PGBACKREST_DB_INCLUDE", "77", true); TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command"); - TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/db2", "default pg-path"); - TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options"); TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("f")))), "g", "check recovery option"); TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("hijk")))), "l", "check recovery option"); @@ -1486,8 +1484,6 @@ testRun(void) unsetenv("PGBACKREST_STANZA"); unsetenv("PGBACKREST_PG1_PATH"); - hrnCfgEnvKeyRemoveRaw(cfgOptPgPath, 2); - hrnCfgEnvRemoveRaw(cfgOptPg); unsetenv("PGBACKREST_RECOVERY_OPTION"); unsetenv("PGBACKREST_DB_INCLUDE"); @@ -1573,7 +1569,7 @@ testRun(void) hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 8, "/pg8"); hrnCfgArgRawZ(argList, cfgOptPg, "4"); TEST_ERROR( - harnessCfgLoadRole(cfgCmdCheck, cfgCmdRoleRemote, argList), OptionInvalidValueError, + harnessCfgLoadRole(cfgCmdBackup, cfgCmdRoleLocal, argList), OptionInvalidValueError, "key '4' is not valid for 'pg' option"); } diff --git a/test/src/module/protocol/protocolTest.c b/test/src/module/protocol/protocolTest.c index cef7121a3..277bc6ec7 100644 --- a/test/src/module/protocol/protocolTest.c +++ b/test/src/module/protocol/protocolTest.c @@ -328,7 +328,7 @@ testRun(void) TEST_RESULT_STR_Z( strLstJoin(protocolRemoteParam(protocolStorageTypePg, 0), "|"), "-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg1-host" - "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg=1" + "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error" " --pg1-path=/path/to/1 --process=0 --remote-type=pg --stanza=test1 backup:remote", "remote protocol params for db backup"); @@ -350,7 +350,7 @@ testRun(void) TEST_RESULT_STR_Z( strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1), "|"), "-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg2-host" - "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg=1" + "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error" " --pg1-path=/path/to/2 --process=4 --remote-type=pg --stanza=test1 backup:remote", "remote protocol params for db local"); @@ -372,7 +372,7 @@ testRun(void) TEST_RESULT_STR_Z( strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1), "|"), "-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg3-host" - "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg=1" + "|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error" " --pg1-path=/path/to/3 --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --remote-type=pg --stanza=test1" " backup:remote", "remote protocol params for db local"); @@ -974,7 +974,6 @@ testRun(void) strLstAdd(argList, strNewFmt("--repo1-host-user=%s", testUser())); strLstAdd(argList, strNewFmt("--repo1-path=%s", testPath())); strLstAddZ(argList, "--process=999"); - hrnCfgArgRawZ(argList, cfgOptPg, "1"); strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG); harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList); [parent: 951cfa9e900a]