diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-10-03 18:53:44 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-10-03 18:53:44 -0400 |
commit | 11d8d72c27a64ea4e30adce11cf6c4f3dd3e60db (patch) | |
tree | edfc217d80302fb5f5a6a36f8de4312e832b634b /src/backend/parser | |
parent | 45f9d08684d954b0e514b69f270e763d2785dd53 (diff) |
Allow multiple tables to be specified in one VACUUM or ANALYZE command.
Not much to say about this; does what it says on the tin.
However, formerly, if there was a column list then the ANALYZE action was
implied; now it must be specified, or you get an error. This is because
it would otherwise be a bit unclear what the user meant if some tables
have column lists and some don't.
Nathan Bossart, reviewed by Michael Paquier and Masahiko Sawada, with some
editorialization by me
Discussion: https://postgr.es/m/E061A8E3-5E3D-494D-94F0-E8A9B312BBFC@amazon.com
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/gram.y | 71 |
1 files changed, 27 insertions, 44 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index c303818c9b0..4c83a63f7d9 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -365,6 +365,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); %type <list> DefACLOptionList %type <ival> import_qualification_type %type <importqual> import_qualification +%type <node> vacuum_relation %type <list> stmtblock stmtmulti OptTableElementList TableElementList OptInherit definition @@ -396,6 +397,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query); transform_element_list transform_type_list TriggerTransitions TriggerReferencing publication_name_list + vacuum_relation_list opt_vacuum_relation_list %type <list> group_by_list %type <node> group_by_item empty_grouping_set rollup_clause cube_clause @@ -10147,7 +10149,7 @@ cluster_index_specification: * *****************************************************************************/ -VacuumStmt: VACUUM opt_full opt_freeze opt_verbose +VacuumStmt: VACUUM opt_full opt_freeze opt_verbose opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); n->options = VACOPT_VACUUM; @@ -10157,22 +10159,7 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose n->options |= VACOPT_FREEZE; if ($4) n->options |= VACOPT_VERBOSE; - n->relation = NULL; - n->va_cols = NIL; - $$ = (Node *)n; - } - | VACUUM opt_full opt_freeze opt_verbose qualified_name - { - VacuumStmt *n = makeNode(VacuumStmt); - n->options = VACOPT_VACUUM; - if ($2) - n->options |= VACOPT_FULL; - if ($3) - n->options |= VACOPT_FREEZE; - if ($4) - n->options |= VACOPT_VERBOSE; - n->relation = $5; - n->va_cols = NIL; + n->rels = $5; $$ = (Node *)n; } | VACUUM opt_full opt_freeze opt_verbose AnalyzeStmt @@ -10187,22 +10174,11 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose n->options |= VACOPT_VERBOSE; $$ = (Node *)n; } - | VACUUM '(' vacuum_option_list ')' - { - VacuumStmt *n = makeNode(VacuumStmt); - n->options = VACOPT_VACUUM | $3; - n->relation = NULL; - n->va_cols = NIL; - $$ = (Node *) n; - } - | VACUUM '(' vacuum_option_list ')' qualified_name opt_name_list + | VACUUM '(' vacuum_option_list ')' opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); n->options = VACOPT_VACUUM | $3; - n->relation = $5; - n->va_cols = $6; - if (n->va_cols != NIL) /* implies analyze */ - n->options |= VACOPT_ANALYZE; + n->rels = $5; $$ = (Node *) n; } ; @@ -10229,25 +10205,13 @@ vacuum_option_elem: } ; -AnalyzeStmt: - analyze_keyword opt_verbose +AnalyzeStmt: analyze_keyword opt_verbose opt_vacuum_relation_list { VacuumStmt *n = makeNode(VacuumStmt); n->options = VACOPT_ANALYZE; if ($2) n->options |= VACOPT_VERBOSE; - n->relation = NULL; - n->va_cols = NIL; - $$ = (Node *)n; - } - | analyze_keyword opt_verbose qualified_name opt_name_list - { - VacuumStmt *n = makeNode(VacuumStmt); - n->options = VACOPT_ANALYZE; - if ($2) - n->options |= VACOPT_VERBOSE; - n->relation = $3; - n->va_cols = $4; + n->rels = $3; $$ = (Node *)n; } ; @@ -10275,6 +10239,25 @@ opt_name_list: | /*EMPTY*/ { $$ = NIL; } ; +vacuum_relation: + qualified_name opt_name_list + { + $$ = (Node *) makeVacuumRelation($1, InvalidOid, $2); + } + ; + +vacuum_relation_list: + vacuum_relation + { $$ = list_make1($1); } + | vacuum_relation_list ',' vacuum_relation + { $$ = lappend($1, $3); } + ; + +opt_vacuum_relation_list: + vacuum_relation_list { $$ = $1; } + | /*EMPTY*/ { $$ = NIL; } + ; + /***************************************************************************** * |