From fcd810c69adf11b6ec1cff35359be0dd27662eff Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Fri, 14 Jan 2011 16:30:33 +0100 Subject: 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. --- src/backend/replication/basebackup.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src/backend/replication/basebackup.c') diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index 7929f855f6d..1ed5e2a6c9e 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -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) { -- cgit v1.2.3