Updated patch applied. Thanks.
I added a mention of the old syntax at the bottom of the CLUSTER manual
page, and cleaned up the grammar a little. Also did a little comment
cleaning in gram.y.
---------------------------------------------------------------------------
Holger Schurig wrote:
> SGML ref text (swapped parameter list, changed example text)
>
> Also, I noticed that the text of the example spoke about a
> table "employees", but the example used the table "emp". I
> fixed this inconsistency.
>
--
Bruce Momjian <[EMAIL PROTECTED]> http://momjian.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/ref/cluster.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/cluster.sgml,v
retrieving revision 1.40
diff -c -c -r1.40 cluster.sgml
*** doc/src/sgml/ref/cluster.sgml 1 Feb 2007 00:28:18 -0000 1.40
--- doc/src/sgml/ref/cluster.sgml 8 Apr 2007 00:23:30 -0000
***************
*** 20,27 ****
<refsynopsisdiv>
<synopsis>
! CLUSTER <replaceable class="PARAMETER">indexname</replaceable> ON <replaceable class="PARAMETER">tablename</replaceable>
! CLUSTER <replaceable class="PARAMETER">tablename</replaceable>
CLUSTER
</synopsis>
</refsynopsisdiv>
--- 20,26 ----
<refsynopsisdiv>
<synopsis>
! CLUSTER <replaceable class="PARAMETER">tablename</replaceable> [ USING <replaceable class="PARAMETER">indexname</replaceable> ]
CLUSTER
</synopsis>
</refsynopsisdiv>
***************
*** 77,95 ****
<variablelist>
<varlistentry>
! <term><replaceable class="PARAMETER">indexname</replaceable></term>
<listitem>
<para>
! The name of an index.
</para>
</listitem>
</varlistentry>
<varlistentry>
! <term><replaceable class="PARAMETER">tablename</replaceable></term>
<listitem>
<para>
! The name (possibly schema-qualified) of a table.
</para>
</listitem>
</varlistentry>
--- 76,94 ----
<variablelist>
<varlistentry>
! <term><replaceable class="PARAMETER">tablename</replaceable></term>
<listitem>
<para>
! The name (possibly schema-qualified) of a table.
</para>
</listitem>
</varlistentry>
<varlistentry>
! <term><replaceable class="PARAMETER">indexname</replaceable></term>
<listitem>
<para>
! The name of an index.
</para>
</listitem>
</varlistentry>
***************
*** 172,180 ****
<para>
Cluster the table <literal>employees</literal> on the basis of
! its index <literal>emp_ind</literal>:
<programlisting>
! CLUSTER emp_ind ON emp;
</programlisting>
</para>
--- 171,179 ----
<para>
Cluster the table <literal>employees</literal> on the basis of
! its index <literal>employees_ind</literal>:
<programlisting>
! CLUSTER employees USING employees_ind;
</programlisting>
</para>
***************
*** 182,188 ****
Cluster the <literal>employees</literal> table using the same
index that was used before:
<programlisting>
! CLUSTER emp;
</programlisting>
</para>
--- 181,187 ----
Cluster the <literal>employees</literal> table using the same
index that was used before:
<programlisting>
! CLUSTER employees;
</programlisting>
</para>
***************
*** 198,204 ****
<title>Compatibility</title>
<para>
! There is no <command>CLUSTER</command> statement in the SQL standard.
</para>
</refsect1>
--- 197,208 ----
<title>Compatibility</title>
<para>
! The syntax:
! <synopsis>
! CLUSTER <replaceable class="PARAMETER">indexname</replaceable> ON <replaceable class="PARAMETER">tablename</replaceable>
! </synopsis>
! is also supported for compatibility with pre-8.3 <productname>PostgreSQL</> installations.
! There is no <command>CLUSTER</command> statement in the SQL standard.
</para>
</refsect1>
Index: src/backend/parser/gram.y
===================================================================
RCS file: /cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.586
diff -c -c -r2.586 gram.y
*** src/backend/parser/gram.y 2 Apr 2007 22:20:53 -0000 2.586
--- src/backend/parser/gram.y 8 Apr 2007 00:23:32 -0000
***************
*** 209,215 ****
%type <str> relation_name copy_file_name
database_name access_method_clause access_method attr_name
! index_name name file_name
%type <list> func_name handler_name qual_Op qual_all_Op subquery_Op
opt_class opt_validator
--- 209,215 ----
%type <str> relation_name copy_file_name
database_name access_method_clause access_method attr_name
! index_name name file_name cluster_index_specification
%type <list> func_name handler_name qual_Op qual_all_Op subquery_Op
opt_class opt_validator
***************
*** 5084,5090 ****
/*****************************************************************************
*
* QUERY:
! * load "filename"
*
*****************************************************************************/
--- 5084,5090 ----
/*****************************************************************************
*
* QUERY:
! * LOAD "filename"
*
*****************************************************************************/
***************
*** 5346,5370 ****
/*****************************************************************************
*
* QUERY:
! * cluster <index_name> on <qualified_name>
! * cluster <qualified_name>
! * cluster
*
*****************************************************************************/
ClusterStmt:
! CLUSTER index_name ON qualified_name
! {
! ClusterStmt *n = makeNode(ClusterStmt);
! n->relation = $4;
! n->indexname = $2;
! $$ = (Node*)n;
! }
! | CLUSTER qualified_name
{
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $2;
! n->indexname = NULL;
$$ = (Node*)n;
}
| CLUSTER
--- 5346,5363 ----
/*****************************************************************************
*
* QUERY:
! * CLUSTER <qualified_name> [ USING <index_name> ]
! * CLUSTER
! * CLUSTER <index_name> ON <qualified_name> (for pre-8.3)
*
*****************************************************************************/
ClusterStmt:
! CLUSTER qualified_name cluster_index_specification
{
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $2;
! n->indexname = $3;
$$ = (Node*)n;
}
| CLUSTER
***************
*** 5374,5386 ****
n->indexname = NULL;
$$ = (Node*)n;
}
;
/*****************************************************************************
*
* QUERY:
! * vacuum
! * analyze
*
*****************************************************************************/
--- 5367,5393 ----
n->indexname = NULL;
$$ = (Node*)n;
}
+ /* kept for pre-8.3 compatibility */
+ | CLUSTER index_name ON qualified_name
+ {
+ ClusterStmt *n = makeNode(ClusterStmt);
+ n->relation = $4;
+ n->indexname = $2;
+ $$ = (Node*)n;
+ }
+ ;
+
+ cluster_index_specification:
+ USING index_name { $$ = $2; }
+ | /*EMPTY*/ { $$ = NULL; }
;
+
/*****************************************************************************
*
* QUERY:
! * VACUUM
! * ANALYZE
*
*****************************************************************************/
Index: src/bin/psql/tab-complete.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v
retrieving revision 1.160
diff -c -c -r1.160 tab-complete.c
*** src/bin/psql/tab-complete.c 26 Mar 2007 16:58:40 -0000 1.160
--- src/bin/psql/tab-complete.c 8 Apr 2007 00:23:33 -0000
***************
*** 822,832 ****
COMPLETE_WITH_LIST(list_COLUMNALTER);
}
! else if (pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
! pg_strcasecmp(prev_wd, "CLUSTER") == 0)
COMPLETE_WITH_CONST("ON");
else if (pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
- pg_strcasecmp(prev2_wd, "CLUSTER") == 0 &&
pg_strcasecmp(prev_wd, "ON") == 0)
{
completion_info_charp = prev3_wd;
--- 822,830 ----
COMPLETE_WITH_LIST(list_COLUMNALTER);
}
! else if (pg_strcasecmp(prev3_wd, "TABLE") == 0)
COMPLETE_WITH_CONST("ON");
else if (pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
pg_strcasecmp(prev_wd, "ON") == 0)
{
completion_info_charp = prev3_wd;
***************
*** 929,952 ****
/*
* If the previous word is CLUSTER and not without produce list of
! * indexes.
*/
else if (pg_strcasecmp(prev_wd, "CLUSTER") == 0 &&
pg_strcasecmp(prev2_wd, "WITHOUT") != 0)
! COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
! /* If we have CLUSTER <sth>, then add "ON" */
else if (pg_strcasecmp(prev2_wd, "CLUSTER") == 0 &&
! pg_strcasecmp(prev_wd, "ON") != 0)
! COMPLETE_WITH_CONST("ON");
/*
! * If we have CLUSTER <sth> ON, then add the correct tablename as well.
*/
else if (pg_strcasecmp(prev3_wd, "CLUSTER") == 0 &&
! pg_strcasecmp(prev_wd, "ON") == 0)
{
completion_info_charp = prev2_wd;
! COMPLETE_WITH_QUERY(Query_for_table_owning_index);
}
/* COMMENT */
--- 927,951 ----
/*
* If the previous word is CLUSTER and not without produce list of
! * tables
*/
else if (pg_strcasecmp(prev_wd, "CLUSTER") == 0 &&
pg_strcasecmp(prev2_wd, "WITHOUT") != 0)
! COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
! /* If we have CLUSTER <sth>, then add "USING" */
else if (pg_strcasecmp(prev2_wd, "CLUSTER") == 0 &&
! pg_strcasecmp(prev_wd, "ON") != 0) {
! COMPLETE_WITH_CONST("USING");
! }
/*
! * If we have CLUSTER <sth> ORDER BY, then add the index as well.
*/
else if (pg_strcasecmp(prev3_wd, "CLUSTER") == 0 &&
! pg_strcasecmp(prev_wd, "USING") == 0)
{
completion_info_charp = prev2_wd;
! COMPLETE_WITH_QUERY(Query_for_index_of_table);
}
/* COMMENT */
Index: src/test/regress/expected/cluster.out
===================================================================
RCS file: /cvsroot/pgsql/src/test/regress/expected/cluster.out,v
retrieving revision 1.17
diff -c -c -r1.17 cluster.out
*** src/test/regress/expected/cluster.out 7 Jul 2005 20:40:01 -0000 1.17
--- src/test/regress/expected/cluster.out 8 Apr 2007 00:23:36 -0000
***************
*** 329,335 ****
CLUSTER clstr_2;
ERROR: there is no previously clustered index for table "clstr_2"
CLUSTER clstr_1_pkey ON clstr_1;
! CLUSTER clstr_2_pkey ON clstr_2;
SELECT * FROM clstr_1 UNION ALL
SELECT * FROM clstr_2 UNION ALL
SELECT * FROM clstr_3;
--- 329,335 ----
CLUSTER clstr_2;
ERROR: there is no previously clustered index for table "clstr_2"
CLUSTER clstr_1_pkey ON clstr_1;
! CLUSTER clstr_2 USING clstr_2_pkey;
SELECT * FROM clstr_1 UNION ALL
SELECT * FROM clstr_2 UNION ALL
SELECT * FROM clstr_3;
Index: src/test/regress/sql/cluster.sql
===================================================================
RCS file: /cvsroot/pgsql/src/test/regress/sql/cluster.sql,v
retrieving revision 1.9
diff -c -c -r1.9 cluster.sql
*** src/test/regress/sql/cluster.sql 7 Jul 2005 20:40:02 -0000 1.9
--- src/test/regress/sql/cluster.sql 8 Apr 2007 00:23:36 -0000
***************
*** 122,128 ****
CLUSTER clstr_2;
CLUSTER clstr_1_pkey ON clstr_1;
! CLUSTER clstr_2_pkey ON clstr_2;
SELECT * FROM clstr_1 UNION ALL
SELECT * FROM clstr_2 UNION ALL
SELECT * FROM clstr_3;
--- 122,128 ----
CLUSTER clstr_2;
CLUSTER clstr_1_pkey ON clstr_1;
! CLUSTER clstr_2 USING clstr_2_pkey;
SELECT * FROM clstr_1 UNION ALL
SELECT * FROM clstr_2 UNION ALL
SELECT * FROM clstr_3;
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly