mirror of
https://github.com/postgres/postgres.git
synced 2025-10-28 11:55:03 +03:00
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
This commit is contained in:
@@ -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 ')'
|
||||
| VACUUM '(' vacuum_option_list ')' opt_vacuum_relation_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
|
||||
{
|
||||
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; }
|
||||
;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user