diff options
| author | Magnus Hagander | 2011-01-14 15:30:33 +0000 |
|---|---|---|
| committer | Magnus Hagander | 2011-01-14 15:30:33 +0000 |
| commit | fcd810c69adf11b6ec1cff35359be0dd27662eff (patch) | |
| tree | b4edb043afe37dc221b765572aa90dafafefcfc7 /src/include/replication | |
| parent | 688423d004f4092aed73c73a3281c281d476436d (diff) | |
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.
Diffstat (limited to 'src/include/replication')
| -rw-r--r-- | src/include/replication/basebackup.h | 2 | ||||
| -rw-r--r-- | src/include/replication/replnodes.h | 63 | ||||
| -rw-r--r-- | src/include/replication/walsender.h | 13 |
3 files changed, 77 insertions, 1 deletions
diff --git a/src/include/replication/basebackup.h b/src/include/replication/basebackup.h index 61e531543c..eb2e160176 100644 --- a/src/include/replication/basebackup.h +++ b/src/include/replication/basebackup.h @@ -12,6 +12,6 @@ #ifndef _BASEBACKUP_H #define _BASEBACKUP_H -extern void SendBaseBackup(const char *options); +extern void SendBaseBackup(const char *backup_label, bool progress); #endif /* _BASEBACKUP_H */ diff --git a/src/include/replication/replnodes.h b/src/include/replication/replnodes.h new file mode 100644 index 0000000000..4f4a1a3bac --- /dev/null +++ b/src/include/replication/replnodes.h @@ -0,0 +1,63 @@ +/*------------------------------------------------------------------------- + * + * replnodes.h + * definitions for replication grammar parse nodes + * + * + * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/replication/replnodes.h + * + *------------------------------------------------------------------------- + */ +#ifndef REPLNODES_H +#define REPLNODES_H + +#include "access/xlogdefs.h" +#include "nodes/primnodes.h" +#include "nodes/value.h" + +/* + * NodeTags for replication parser + */ +typedef enum ReplNodeTag +{ + T_IdentifySystemCmd = 10, + T_BaseBackupCmd, + T_StartReplicationCmd +} ReplNodeTag; + +/* ---------------------- + * IDENTIFY_SYSTEM command + * ---------------------- + */ +typedef struct IdentifySystemCmd +{ + NodeTag type; +} IdentifySystemCmd; + + +/* ---------------------- + * BASE_BACKUP command + * ---------------------- + */ +typedef struct BaseBackupCmd +{ + NodeTag type; + char *label; + bool progress; +} BaseBackupCmd; + + +/* ---------------------- + * START_REPLICATION command + * ---------------------- + */ +typedef struct StartReplicationCmd +{ + NodeTag type; + XLogRecPtr startpoint; +} StartReplicationCmd; + +#endif /* REPLNODES_H */ diff --git a/src/include/replication/walsender.h b/src/include/replication/walsender.h index 9039b240c4..bd9e19320f 100644 --- a/src/include/replication/walsender.h +++ b/src/include/replication/walsender.h @@ -13,6 +13,7 @@ #define _WALSENDER_H #include "access/xlog.h" +#include "nodes/nodes.h" #include "storage/latch.h" #include "storage/spin.h" @@ -69,4 +70,16 @@ extern void WalSndSetState(WalSndState state); extern Datum pg_stat_get_wal_senders(PG_FUNCTION_ARGS); +/* + * Internal functions for parsing the replication grammar, in repl_gram.y and + * repl_scanner.l + */ +extern int replication_yyparse(void); +extern int replication_yylex(void); +extern void replication_yyerror(const char *str); +extern void replication_scanner_init(const char *query_string); +extern void replication_scanner_finish(void); + +extern Node *replication_parse_result; + #endif /* _WALSENDER_H */ |
