On Thu, Jul 24, 2025 at 11:54:10AM +0200, Álvaro Herrera wrote:
> Yeah, thanks for taking a look. That duplication is just me being dumb.
> Here's a version without that. The only thing that needed to change was
> changing "CLUSTER opt_verbose" to "CLUSTER VERBOSE" so that the
> unadorned CLUSTER is handled by "CLUSTER opt_utility_option_list"
> instead.
I think we can do something similar for ANALYZE. But AFAICT you're right
that we can't use it for VACUUM and EXPLAIN, at least not easily.
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index fc9a8d64c08..7d341a319e7 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -11987,24 +11987,21 @@ VacuumStmt: VACUUM opt_full opt_freeze opt_verbose opt_analyze opt_vacuum_relati
}
;
-AnalyzeStmt: analyze_keyword opt_verbose opt_vacuum_relation_list
+AnalyzeStmt: analyze_keyword opt_utility_option_list opt_vacuum_relation_list
{
VacuumStmt *n = makeNode(VacuumStmt);
- n->options = NIL;
- if ($2)
- n->options = lappend(n->options,
- makeDefElem("verbose", NULL, @2));
+ n->options = $2;
n->rels = $3;
n->is_vacuumcmd = false;
$$ = (Node *) n;
}
- | analyze_keyword '(' utility_option_list ')' opt_vacuum_relation_list
+ | analyze_keyword VERBOSE opt_vacuum_relation_list
{
VacuumStmt *n = makeNode(VacuumStmt);
- n->options = $3;
- n->rels = $5;
+ n->options = list_make1(makeDefElem("verbose", NULL, @2));
+ n->rels = $3;
n->is_vacuumcmd = false;
$$ = (Node *) n;
}
--
nathan