1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-27 23:21:58 +03:00

Use a lexer and grammar for parsing walsender commands

Makes it easier to parse mainly the BASE_BACKUP command
with it's options, and avoids having to manually deal
with quoted identifiers in the label (previously broken),
and makes it easier to add new commands and options in
the future.

In passing, refactor the case statement in the walsender
to put each command in it's own function.
This commit is contained in:
Magnus Hagander
2011-01-14 16:30:33 +01:00
parent 688423d004
commit fcd810c69a
12 changed files with 603 additions and 128 deletions

View File

@ -98,12 +98,10 @@ perform_base_backup(const char *backup_label, List *tablespaces)
* pg_stop_backup() for the user.
*/
void
SendBaseBackup(const char *options)
SendBaseBackup(const char *backup_label, bool progress)
{
DIR *dir;
struct dirent *de;
char *backup_label = strchr(options, ';');
bool progress = false;
List *tablespaces = NIL;
tablespaceinfo *ti;
MemoryContext backup_context;
@ -119,18 +117,7 @@ SendBaseBackup(const char *options)
WalSndSetState(WALSNDSTATE_BACKUP);
if (backup_label == NULL)
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("invalid base backup options: %s", options)));
backup_label++; /* Walk past the semicolon */
/* Currently the only option string supported is PROGRESS */
if (strncmp(options, "PROGRESS", 8) == 0)
progress = true;
else if (options[0] != ';')
ereport(FATAL,
(errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("invalid base backup options: %s", options)));
backup_label = "base backup";
if (update_process_title)
{