%{ /*------------------------------------------------------------------------- * * repl_gram.y - Parser for the replication commands * * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * src/backend/replication/repl_gram.y * *------------------------------------------------------------------------- */ #include "postgres.h" #include "access/xlogdefs.h" #include "nodes/makefuncs.h" #include "nodes/replnodes.h" #include "replication/walsender.h" #include "replication/walsender_private.h" /* Result of the parsing is returned here */ Node *replication_parse_result; static SQLCmd *make_sqlcmd(void); /* * Bison doesn't allocate anything that needs to live across parser calls, * so we can easily have it use palloc instead of malloc. This prevents * memory leaks if we error out during parsing. Note this only works with * bison >= 2.0. However, in bison 1.875 the default is to use alloca() * if possible, so there's not really much problem anyhow, at least if * you're building with gcc. */ #define YYMALLOC palloc #define YYFREE pfree %} %expect 0 %name-prefix="replication_yy" %union { char *str; bool boolval; uint32 uintval; XLogRecPtr recptr; Node *node; List *list; DefElem *defelt; } /* Non-keyword tokens */ %token SCONST IDENT %token UCONST %token RECPTR %token T_WORD /* Keyword tokens. */ %token K_BASE_BACKUP %token K_IDENTIFY_SYSTEM %token K_SHOW %token K_START_REPLICATION %token K_CREATE_REPLICATION_SLOT %token K_DROP_REPLICATION_SLOT %token K_TIMELINE_HISTORY %token K_LABEL %token K_PROGRESS %token K_FAST %token K_WAIT %token K_NOWAIT %token K_MAX_RATE %token K_WAL %token K_TABLESPACE_MAP %token K_NOVERIFY_CHECKSUMS %token K_TIMELINE %token K_PHYSICAL %token K_LOGICAL %token K_SLOT %token K_RESERVE_WAL %token K_TEMPORARY %token K_EXPORT_SNAPSHOT %token K_NOEXPORT_SNAPSHOT %token K_USE_SNAPSHOT %token K_MANIFEST %token K_MANIFEST_CHECKSUMS %type command %type base_backup start_replication start_logical_replication create_replication_slot drop_replication_slot identify_system timeline_history show sql_cmd %type base_backup_opt_list %type base_backup_opt %type opt_timeline %type plugin_options plugin_opt_list %type plugin_opt_elem %type plugin_opt_arg %type opt_slot var_name %type opt_temporary %type create_slot_opt_list %type create_slot_opt %% firstcmd: command opt_semicolon { replication_parse_result = $1; } ; opt_semicolon: ';' | /* EMPTY */ ; command: identify_system | base_backup | start_replication | start_logical_replication | create_replication_slot | drop_replication_slot | timeline_history | show | sql_cmd ; /* * IDENTIFY_SYSTEM */ identify_system: K_IDENTIFY_SYSTEM { $$ = (Node *) makeNode(IdentifySystemCmd); } ; /* * SHOW setting */ show: K_SHOW var_name { VariableShowStmt *n = makeNode(VariableShowStmt); n->name = $2; $$ = (Node *) n; } var_name: IDENT { $$ = $1; } | var_name '.' IDENT { $$ = psprintf("%s.%s", $1, $3); } ; /* * BASE_BACKUP [LABEL '