From: Nathan Bossart Date: Mon, 15 May 2023 12:02:09 -0700 Subject: [PATCH v4 1/3] Rearrange CLUSTER rules in gram.y. This change moves the unparenthesized syntaxes for CLUSTER to the end of the ClusterStmt rules in preparation for a follow-up commit that will move these syntaxes to the "Compatibility" section of the CLUSTER documentation. The documentation for the unparenthesized 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 | 3 +-- src/backend/parser/gram.y | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/doc/src/sgml/ref/cluster.sgml b/doc/src/sgml/ref/cluster.sgml index 29f0f1fd90..35b8deaec1 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 [VERBOSE] [ replaceable class="parameter">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 d6426f3b8e..a0b741ea72 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -11574,33 +11574,32 @@ 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 = $3; - n->indexname = $4; - n->params = NIL; - if ($2) - n->params = lappend(n->params, makeDefElem("verbose", NULL, @2)); + n->relation = $5; + n->indexname = $6; + n->params = $3; $$ = (Node *) n; } - - | CLUSTER '(' utility_option_list ')' qualified_name cluster_index_specification + /* unparenthesized VERBOSE kept for pre-14 compatibility */ + | CLUSTER opt_verbose qualified_name cluster_index_specification { ClusterStmt *n = makeNode(ClusterStmt); - n->relation = $5; - n->indexname = $6; - n->params = $3; + n->relation = $3; + n->indexname = $4; + n->params = NIL; + if ($2) + n->params = lappend(n->params, makeDefElem("verbose", NULL, @2)); $$ = (Node *) n; } | CLUSTER opt_verbose -- 2.25.1 --/9DWx/yDrRhgMJTb Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0002-Support-parenthesized-syntax-for-CLUSTER-without-.patch"