From 018b61f81b4aa3c85e2d671d056681ff5c765475 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Wed, 19 Jul 2023 15:26:43 -0700 Subject: [PATCH] Rearrange CLUSTER rules in gram.y. This change moves the unparenthesized syntax for CLUSTER to the end of the ClusterStmt rules in preparation for a follow-up commit that will move this syntax to the "Compatibility" section of the CLUSTER documentation. The documentation for the CLUSTER syntaxes has also been consolidated. Suggested-by: Melanie Plageman Discussion https://postgr.es/m/CAAKRu_bc5uHieG1976kGqJKxyWtyQt9yvktjsVX%2Bi7NOigDjOA%40mail.gmail.com --- doc/src/sgml/ref/cluster.sgml | 5 ++--- src/backend/parser/gram.y | 27 +++++++++++++-------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/doc/src/sgml/ref/cluster.sgml b/doc/src/sgml/ref/cluster.sgml index 0ed29a5c6d4..e308e2ce912 100644 --- a/doc/src/sgml/ref/cluster.sgml +++ b/doc/src/sgml/ref/cluster.sgml @@ -21,9 +21,8 @@ PostgreSQL documentation -CLUSTER [VERBOSE] table_name [ USING index_name ] -CLUSTER ( option [, ...] ) table_name [ USING index_name ] -CLUSTER [VERBOSE] +CLUSTER [ ( option [, ...] ) ] table_name [ USING index_name ] +CLUSTER [ VERBOSE ] [ table_name [ USING index_name ] ] where option can be one of: diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index edb6c00ece6..91793cb2eff 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -11553,15 +11553,24 @@ CreateConversionStmt: /***************************************************************************** * * QUERY: - * CLUSTER [VERBOSE] [ USING ] - * CLUSTER [ (options) ] [ USING ] - * CLUSTER [VERBOSE] + * CLUSTER (options) [ USING ] + * CLUSTER [VERBOSE] [ [ USING ] ] * CLUSTER [VERBOSE] ON (for pre-8.3) * *****************************************************************************/ ClusterStmt: - CLUSTER opt_verbose qualified_name cluster_index_specification + CLUSTER '(' utility_option_list ')' qualified_name cluster_index_specification + { + ClusterStmt *n = makeNode(ClusterStmt); + + n->relation = $5; + n->indexname = $6; + n->params = $3; + $$ = (Node *) n; + } + /* unparenthesized VERBOSE kept for pre-14 compatibility */ + | CLUSTER opt_verbose qualified_name cluster_index_specification { ClusterStmt *n = makeNode(ClusterStmt); @@ -11572,16 +11581,6 @@ ClusterStmt: n->params = lappend(n->params, makeDefElem("verbose", NULL, @2)); $$ = (Node *) n; } - - | CLUSTER '(' utility_option_list ')' qualified_name cluster_index_specification - { - ClusterStmt *n = makeNode(ClusterStmt); - - n->relation = $5; - n->indexname = $6; - n->params = $3; - $$ = (Node *) n; - } | CLUSTER opt_verbose { ClusterStmt *n = makeNode(ClusterStmt);