Has docs + regression test.
Christopher Kings-Lynne
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.70 2004/05/27 03:30:11 tgl Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.71 2004/06/02 21:01:08 momjian Exp $
PostgreSQL documentation
-->
SET WITHOUT OIDS
OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
CLUSTER ON <replaceable class="PARAMETER">index_name</replaceable>
+ SET WITHOUT CLUSTER
</synopsis>
</refsynopsisdiv>
<term><literal>CLUSTER</literal></term>
<listitem>
<para>
- This form selects the default controlling index for future <xref linkend="SQL-CLUSTER" endterm="sql-cluster-title">
+ This form selects the default index for future
+ <xref linkend="SQL-CLUSTER" endterm="sql-cluster-title">
operations.
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><literal>SET WITHOUT CLUSTER</literal></term>
+ <listitem>
+ <para>
+ This form removes the most recently used
+ <xref linkend="SQL-CLUSTER" endterm="sql-cluster-title">
+ index specification from the table.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><literal>RENAME</literal></term>
<listitem>
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.108 2004/05/26 04:41:12 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.109 2004/06/02 21:01:08 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static void ATPostAlterTypeParse(char *cmd, List **wqueue);
static void ATExecChangeOwner(Oid relationOid, int32 newOwnerSysId);
static void ATExecClusterOn(Relation rel, const char *indexName);
+static void ATExecDropCluster(Relation rel);
static int ri_trigger_type(Oid tgfoid);
static void update_ri_trigger_args(Oid relid,
const char *oldname,
pass = AT_PASS_MISC;
break;
case AT_ClusterOn: /* CLUSTER ON */
+ case AT_DropCluster: /* SET WITHOUT CLUSTER */
ATSimplePermissions(rel, false);
- /* This command never recurses */
+ /* These commands never recurse */
/* No command-specific prep needed */
pass = AT_PASS_MISC;
break;
case AT_ClusterOn: /* CLUSTER ON */
ATExecClusterOn(rel, cmd->name);
break;
+ case AT_DropCluster: /* SET WITHOUT CLUSTER */
+ ATExecDropCluster(rel);
+ break;
case AT_DropOids: /* SET WITHOUT OIDS */
/*
* Nothing to do here; we'll have generated a DropColumn subcommand
mark_index_clustered(rel, indexOid);
}
+/*
+ * ALTER TABLE SET WITHOUT CLUSTER
+ *
+ * We have to find any indexes on the table that have indisclustered bit
+ * set and turn it off.
+ */
+static void
+ATExecDropCluster(Relation rel)
+{
+ mark_index_clustered(rel, InvalidOid);
+}
+
+
/*
* ALTER TABLE CREATE TOAST TABLE
*
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.459 2004/06/01 03:28:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.460 2004/06/02 21:01:09 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
n->name = $3;
$$ = (Node *)n;
}
+ /* ALTER TABLE <name> SET WITHOUT CLUSTER */
+ | SET WITHOUT CLUSTER
+ {
+ AlterTableCmd *n = makeNode(AlterTableCmd);
+ n->subtype = AT_DropCluster;
+ n->name = NULL;
+ $$ = (Node *)n;
+ }
;
alter_column_default:
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.256 2004/05/26 13:57:02 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.257 2004/06/02 21:01:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
AT_ToastTable, /* create toast table */
AT_ChangeOwner, /* change owner */
AT_ClusterOn, /* CLUSTER ON */
+ AT_DropCluster, /* SET WITHOUT CLUSTER */
AT_DropOids /* SET WITHOUT OIDS */
} AlterTableType;
clstr_tst_b_c
(1 row)
+-- Try turning off all clustering
+ALTER TABLE clstr_tst SET WITHOUT CLUSTER;
+SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2
+WHERE pg_class.oid=indexrelid
+ AND indrelid=pg_class_2.oid
+ AND pg_class_2.relname = 'clstr_tst'
+ AND indisclustered;
+ relname
+ ---------
+ (0 rows)
+
-- Verify that clustering all tables does in fact cluster the right ones
CREATE USER clstr_user;
CREATE TABLE clstr_1 (a INT PRIMARY KEY);
AND pg_class_2.relname = 'clstr_tst'
AND indisclustered;
+-- Try turning off all clustering
+ALTER TABLE clstr_tst SET WITHOUT CLUSTER;
+SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2
+WHERE pg_class.oid=indexrelid
+ AND indrelid=pg_class_2.oid
+ AND pg_class_2.relname = 'clstr_tst'
+ AND indisclustered;
+
-- Verify that clustering all tables does in fact cluster the right ones
CREATE USER clstr_user;
CREATE TABLE clstr_1 (a INT PRIMARY KEY);