1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Add --c option to request a C remote.

The rules for when a C remote is required are getting complicated and will get worse when restoreFile() is migrated.

Instead, set the --c option when a C remote is required.  This option will be removed when the remote is entirely implemented in C.
This commit is contained in:
David Steele 2019-05-09 08:55:48 -04:00
parent c99c7c458b
commit 15531151d7
12 changed files with 74 additions and 12 deletions

View File

@ -146,8 +146,10 @@ use constant CFGOPT_TYPE => 'type';
use constant CFGOPT_OUTPUT => 'output';
push @EXPORT, qw(CFGOPT_OUTPUT);
# Command-line only local/remote optiosn
# Command-line only local/remote options
#-----------------------------------------------------------------------------------------------------------------------------------
use constant CFGOPT_C => 'c';
push @EXPORT, qw(CFGOPT_C);
use constant CFGOPT_COMMAND => 'command';
push @EXPORT, qw(CFGOPT_COMMAND);
use constant CFGOPT_PROCESS => 'process';
@ -999,6 +1001,17 @@ my %hConfigDefine =
# Command-line only local/remote options
#-------------------------------------------------------------------------------------------------------------------------------
&CFGOPT_C =>
{
&CFGDEF_TYPE => CFGDEF_TYPE_BOOLEAN,
&CFGDEF_INTERNAL => true,
&CFGDEF_DEFAULT => false,
&CFGDEF_COMMAND =>
{
&CFGCMD_REMOTE => {},
}
},
&CFGOPT_COMMAND =>
{
&CFGDEF_TYPE => CFGDEF_TYPE_STRING,

View File

@ -67,6 +67,10 @@
<p>Improve type safety of interfaces and drivers.</p>
</release-item>
<release-item>
<p>Add <br-option>--c</br-option> option to request a C remote.</p>
</release-item>
<release-item>
<p>Add <file>common/macro.h</file> for general-purpose macros.</p>
</release-item>

View File

@ -130,6 +130,7 @@ sub libcAutoExportTag
'CFGOPT_ARCHIVE_TIMEOUT',
'CFGOPT_BACKUP_STANDBY',
'CFGOPT_BUFFER_SIZE',
'CFGOPT_C',
'CFGOPT_CHECKSUM_PAGE',
'CFGOPT_CMD_SSH',
'CFGOPT_COMMAND',

View File

@ -277,6 +277,7 @@ STRING_EXTERN(CFGOPT_ARCHIVE_PUSH_QUEUE_MAX_STR, CFGOPT_ARCHI
STRING_EXTERN(CFGOPT_ARCHIVE_TIMEOUT_STR, CFGOPT_ARCHIVE_TIMEOUT);
STRING_EXTERN(CFGOPT_BACKUP_STANDBY_STR, CFGOPT_BACKUP_STANDBY);
STRING_EXTERN(CFGOPT_BUFFER_SIZE_STR, CFGOPT_BUFFER_SIZE);
STRING_EXTERN(CFGOPT_C_STR, CFGOPT_C);
STRING_EXTERN(CFGOPT_CHECKSUM_PAGE_STR, CFGOPT_CHECKSUM_PAGE);
STRING_EXTERN(CFGOPT_CMD_SSH_STR, CFGOPT_CMD_SSH);
STRING_EXTERN(CFGOPT_COMMAND_STR, CFGOPT_COMMAND);
@ -502,6 +503,14 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST
CONFIG_OPTION_DEFINE_ID(cfgDefOptBufferSize)
)
//------------------------------------------------------------------------------------------------------------------------------
CONFIG_OPTION
(
CONFIG_OPTION_NAME(CFGOPT_C)
CONFIG_OPTION_INDEX(0)
CONFIG_OPTION_DEFINE_ID(cfgDefOptC)
)
//------------------------------------------------------------------------------------------------------------------------------
CONFIG_OPTION
(

View File

@ -67,6 +67,8 @@ Option constants
STRING_DECLARE(CFGOPT_BACKUP_STANDBY_STR);
#define CFGOPT_BUFFER_SIZE "buffer-size"
STRING_DECLARE(CFGOPT_BUFFER_SIZE_STR);
#define CFGOPT_C "c"
STRING_DECLARE(CFGOPT_C_STR);
#define CFGOPT_CHECKSUM_PAGE "checksum-page"
STRING_DECLARE(CFGOPT_CHECKSUM_PAGE_STR);
#define CFGOPT_CMD_SSH "cmd-ssh"
@ -378,7 +380,7 @@ Option constants
#define CFGOPT_TYPE "type"
STRING_DECLARE(CFGOPT_TYPE_STR);
#define CFG_OPTION_TOTAL 163
#define CFG_OPTION_TOTAL 164
/***********************************************************************************************************************************
Command enum
@ -419,6 +421,7 @@ typedef enum
cfgOptArchiveTimeout,
cfgOptBackupStandby,
cfgOptBufferSize,
cfgOptC,
cfgOptChecksumPage,
cfgOptCmdSsh,
cfgOptCommand,

View File

@ -570,6 +570,29 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
)
)
// -----------------------------------------------------------------------------------------------------------------------------
CFGDEFDATA_OPTION
(
CFGDEFDATA_OPTION_NAME("c")
CFGDEFDATA_OPTION_REQUIRED(true)
CFGDEFDATA_OPTION_SECTION(cfgDefSectionCommandLine)
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeBoolean)
CFGDEFDATA_OPTION_INTERNAL(true)
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
CFGDEFDATA_OPTION_SECURE(false)
CFGDEFDATA_OPTION_COMMAND_LIST
(
CFGDEFDATA_OPTION_COMMAND(cfgDefCmdRemote)
)
CFGDEFDATA_OPTION_OPTIONAL_LIST
(
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("0")
)
)
// -----------------------------------------------------------------------------------------------------------------------------
CFGDEFDATA_OPTION
(

View File

@ -59,6 +59,7 @@ typedef enum
cfgDefOptArchiveTimeout,
cfgDefOptBackupStandby,
cfgDefOptBufferSize,
cfgDefOptC,
cfgDefOptChecksumPage,
cfgDefOptCmdSsh,
cfgDefOptCommand,

View File

@ -126,6 +126,13 @@ static const struct option optionList[] =
.val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptBufferSize,
},
// c option
// -----------------------------------------------------------------------------------------------------------------------------
{
.name = CFGOPT_C,
.val = PARSE_OPTION_FLAG | cfgOptC,
},
// checksum-page option
// -----------------------------------------------------------------------------------------------------------------------------
{
@ -2238,6 +2245,7 @@ static const ConfigOption optionResolveOrder[] =
cfgOptArchiveTimeout,
cfgOptBackupStandby,
cfgOptBufferSize,
cfgOptC,
cfgOptChecksumPage,
cfgOptCmdSsh,
cfgOptCommand,

View File

@ -169,11 +169,7 @@ main(int argListSize, const char *argList[])
// -----------------------------------------------------------------------------------------------------------------
case cfgCmdRemote:
{
if (strEq(cfgOptionStr(cfgOptCommand), CFGCMD_ARCHIVE_GET_STR) ||
strEq(cfgOptionStr(cfgOptCommand), CFGCMD_ARCHIVE_GET_ASYNC_STR) ||
strEq(cfgOptionStr(cfgOptCommand), CFGCMD_ARCHIVE_PUSH_STR) ||
strEq(cfgOptionStr(cfgOptCommand), CFGCMD_ARCHIVE_PUSH_ASYNC_STR) ||
strEq(cfgOptionStr(cfgOptCommand), CFGCMD_INFO_STR))
if (cfgOptionBool(cfgOptC))
{
cmdRemote(STDIN_FILENO, STDOUT_FILENO);
}

View File

@ -9438,6 +9438,7 @@ static const EmbeddedModule embeddedModule[] =
"'CFGOPT_ARCHIVE_TIMEOUT',\n"
"'CFGOPT_BACKUP_STANDBY',\n"
"'CFGOPT_BUFFER_SIZE',\n"
"'CFGOPT_C',\n"
"'CFGOPT_CHECKSUM_PAGE',\n"
"'CFGOPT_CMD_SSH',\n"
"'CFGOPT_COMMAND',\n"

View File

@ -214,6 +214,9 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int protoc
if (cfgOptionSource(cfgOptRepoHostConfigPath) != cfgSourceDefault)
kvPut(optionReplace, VARSTR(CFGOPT_CONFIG_PATH_STR), cfgOption(cfgOptRepoHostConfigPath));
// Use a C remote
kvPut(optionReplace, VARSTR(CFGOPT_C_STR), VARBOOL(true));
// Add the command option (or use the current command option if it is valid)
if (!cfgOptionTest(cfgOptCommand))
kvPut(optionReplace, VARSTR(CFGOPT_COMMAND_STR), VARSTRZ(cfgCommandName(cfgCommand())));

View File

@ -137,8 +137,8 @@ testRun(void)
strPtr(
strNew(
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|repo-host-user@repo-host"
"|pgbackrest --command=archive-get --log-level-file=off --log-level-stderr=error --process=0 --stanza=test1"
" --type=backup remote")),
"|pgbackrest --c --command=archive-get --log-level-file=off --log-level-stderr=error --process=0"
" --stanza=test1 --type=backup remote")),
"remote protocol params");
// -------------------------------------------------------------------------------------------------------------------------
@ -160,7 +160,7 @@ testRun(void)
strPtr(
strNew(
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|-p|444|repo-host-user@repo-host"
"|pgbackrest --command=archive-get --config=/path/pgbackrest.conf --config-include-path=/path/include"
"|pgbackrest --c --command=archive-get --config=/path/pgbackrest.conf --config-include-path=/path/include"
" --config-path=/path/config --log-level-file=info --log-level-stderr=error --log-subprocess --process=1"
" --stanza=test1 --type=backup remote")),
"remote protocol params with replacements");
@ -182,8 +182,8 @@ testRun(void)
strPtr(
strNew(
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|pgbackrest@repo-host"
"|pgbackrest --command=archive-get --log-level-file=off --log-level-stderr=error --process=3 --stanza=test1"
" --type=backup remote")),
"|pgbackrest --c --command=archive-get --log-level-file=off --log-level-stderr=error --process=3"
" --stanza=test1 --type=backup remote")),
"remote protocol params for local");
}