Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1cdc587

Browse files
committed
OK, here's the final version of ALTER TABLE ... SET WITHOUT CLUSTER.
Has docs + regression test.Christopher Kings-Lynne
1 parent6f1aa94 commit1cdc587

File tree

6 files changed

+65
-6
lines changed

6 files changed

+65
-6
lines changed

‎doc/src/sgml/ref/alter_table.sgml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.70 2004/05/27 03:30:11 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.71 2004/06/02 21:01:08 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -42,6 +42,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
4242
SET WITHOUT OIDS
4343
OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
4444
CLUSTER ON <replaceable class="PARAMETER">index_name</replaceable>
45+
SET WITHOUT CLUSTER
4546
</synopsis>
4647
</refsynopsisdiv>
4748

@@ -213,12 +214,24 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
213214
<term><literal>CLUSTER</literal></term>
214215
<listitem>
215216
<para>
216-
This form selects the default controlling index for future <xref linkend="SQL-CLUSTER" endterm="sql-cluster-title">
217+
This form selects the default index for future
218+
<xref linkend="SQL-CLUSTER" endterm="sql-cluster-title">
217219
operations.
218220
</para>
219221
</listitem>
220222
</varlistentry>
221223

224+
<varlistentry>
225+
<term><literal>SET WITHOUT CLUSTER</literal></term>
226+
<listitem>
227+
<para>
228+
This form removes the most recently used
229+
<xref linkend="SQL-CLUSTER" endterm="sql-cluster-title">
230+
index specification from the table.
231+
</para>
232+
</listitem>
233+
</varlistentry>
234+
222235
<varlistentry>
223236
<term><literal>RENAME</literal></term>
224237
<listitem>

‎src/backend/commands/tablecmds.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.108 2004/05/26 04:41:12 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.109 2004/06/02 21:01:08 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -233,6 +233,7 @@ static void ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab);
233233
staticvoidATPostAlterTypeParse(char*cmd,List**wqueue);
234234
staticvoidATExecChangeOwner(OidrelationOid,int32newOwnerSysId);
235235
staticvoidATExecClusterOn(Relationrel,constchar*indexName);
236+
staticvoidATExecDropCluster(Relationrel);
236237
staticintri_trigger_type(Oidtgfoid);
237238
staticvoidupdate_ri_trigger_args(Oidrelid,
238239
constchar*oldname,
@@ -1922,8 +1923,9 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
19221923
pass=AT_PASS_MISC;
19231924
break;
19241925
caseAT_ClusterOn:/* CLUSTER ON */
1926+
caseAT_DropCluster:/* SET WITHOUT CLUSTER */
19251927
ATSimplePermissions(rel, false);
1926-
/*This command neverrecurses */
1928+
/*These commands neverrecurse */
19271929
/* No command-specific prep needed */
19281930
pass=AT_PASS_MISC;
19291931
break;
@@ -2083,6 +2085,9 @@ ATExecCmd(AlteredTableInfo *tab, Relation rel, AlterTableCmd *cmd)
20832085
caseAT_ClusterOn:/* CLUSTER ON */
20842086
ATExecClusterOn(rel,cmd->name);
20852087
break;
2088+
caseAT_DropCluster:/* SET WITHOUT CLUSTER */
2089+
ATExecDropCluster(rel);
2090+
break;
20862091
caseAT_DropOids:/* SET WITHOUT OIDS */
20872092
/*
20882093
* Nothing to do here; we'll have generated a DropColumn subcommand
@@ -5044,6 +5049,19 @@ ATExecClusterOn(Relation rel, const char *indexName)
50445049
mark_index_clustered(rel,indexOid);
50455050
}
50465051

5052+
/*
5053+
* ALTER TABLE SET WITHOUT CLUSTER
5054+
*
5055+
* We have to find any indexes on the table that have indisclustered bit
5056+
* set and turn it off.
5057+
*/
5058+
staticvoid
5059+
ATExecDropCluster(Relationrel)
5060+
{
5061+
mark_index_clustered(rel,InvalidOid);
5062+
}
5063+
5064+
50475065
/*
50485066
* ALTER TABLE CREATE TOAST TABLE
50495067
*

‎src/backend/parser/gram.y

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.459 2004/06/01 03:28:48 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.460 2004/06/02 21:01:09 momjian Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -1277,6 +1277,14 @@ alter_table_cmd:
12771277
n->name =$3;
12781278
$$ = (Node *)n;
12791279
}
1280+
/* ALTER TABLE <name> SET WITHOUT CLUSTER*/
1281+
|SETWITHOUTCLUSTER
1282+
{
1283+
AlterTableCmd *n = makeNode(AlterTableCmd);
1284+
n->subtype = AT_DropCluster;
1285+
n->name =NULL;
1286+
$$ = (Node *)n;
1287+
}
12801288
;
12811289

12821290
alter_column_default:

‎src/include/nodes/parsenodes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.256 2004/05/26 13:57:02 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.257 2004/06/02 21:01:09 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -793,6 +793,7 @@ typedef enum AlterTableType
793793
AT_ToastTable,/* create toast table */
794794
AT_ChangeOwner,/* change owner */
795795
AT_ClusterOn,/* CLUSTER ON */
796+
AT_DropCluster,/* SET WITHOUT CLUSTER */
796797
AT_DropOids/* SET WITHOUT OIDS */
797798
}AlterTableType;
798799

‎src/test/regress/expected/cluster.out

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,17 @@ WHERE pg_class.oid=indexrelid
297297
clstr_tst_b_c
298298
(1 row)
299299

300+
-- Try turning off all clustering
301+
ALTER TABLE clstr_tst SET WITHOUT CLUSTER;
302+
SELECT pg_class.relname FROM pg_index, pg_class, pg_class AS pg_class_2
303+
WHERE pg_class.oid=indexrelid
304+
AND indrelid=pg_class_2.oid
305+
AND pg_class_2.relname = 'clstr_tst'
306+
AND indisclustered;
307+
relname
308+
---------
309+
(0 rows)
310+
300311
-- Verify that clustering all tables does in fact cluster the right ones
301312
CREATE USER clstr_user;
302313
CREATE TABLE clstr_1 (a INT PRIMARY KEY);

‎src/test/regress/sql/cluster.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ WHERE pg_class.oid=indexrelid
9595
ANDpg_class_2.relname='clstr_tst'
9696
AND indisclustered;
9797

98+
-- Try turning off all clustering
99+
ALTERTABLE clstr_tstSET WITHOUT CLUSTER;
100+
SELECTpg_class.relnameFROM pg_index, pg_class, pg_classAS pg_class_2
101+
WHEREpg_class.oid=indexrelid
102+
AND indrelid=pg_class_2.oid
103+
ANDpg_class_2.relname='clstr_tst'
104+
AND indisclustered;
105+
98106
-- Verify that clustering all tables does in fact cluster the right ones
99107
CREATEUSERclstr_user;
100108
CREATETABLEclstr_1 (aINTPRIMARY KEY);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp