Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
1cdc5872
Commit
1cdc5872
authored
Jun 02, 2004
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OK, here's the final version of ALTER TABLE ... SET WITHOUT CLUSTER.
Has docs + regression test. Christopher Kings-Lynne
parent
6f1aa94f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
6 deletions
+65
-6
doc/src/sgml/ref/alter_table.sgml
doc/src/sgml/ref/alter_table.sgml
+15
-2
src/backend/commands/tablecmds.c
src/backend/commands/tablecmds.c
+20
-2
src/backend/parser/gram.y
src/backend/parser/gram.y
+9
-1
src/include/nodes/parsenodes.h
src/include/nodes/parsenodes.h
+2
-1
src/test/regress/expected/cluster.out
src/test/regress/expected/cluster.out
+11
-0
src/test/regress/sql/cluster.sql
src/test/regress/sql/cluster.sql
+8
-0
No files found.
doc/src/sgml/ref/alter_table.sgml
View file @
1cdc5872
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.7
0 2004/05/27 03:30:11 tgl
Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.7
1 2004/06/02 21:01:08 momjian
Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -42,6 +42,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
...
@@ -42,6 +42,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
SET WITHOUT OIDS
SET WITHOUT OIDS
OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
CLUSTER ON <replaceable class="PARAMETER">index_name</replaceable>
CLUSTER ON <replaceable class="PARAMETER">index_name</replaceable>
SET WITHOUT CLUSTER
</synopsis>
</synopsis>
</refsynopsisdiv>
</refsynopsisdiv>
...
@@ -213,12 +214,24 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
...
@@ -213,12 +214,24 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
<term><literal>CLUSTER</literal></term>
<term><literal>CLUSTER</literal></term>
<listitem>
<listitem>
<para>
<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.
operations.
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</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>
<varlistentry>
<term><literal>RENAME</literal></term>
<term><literal>RENAME</literal></term>
<listitem>
<listitem>
...
...
src/backend/commands/tablecmds.c
View file @
1cdc5872
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.10
8 2004/05/26 04:41:12 neilc
Exp $
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.10
9 2004/06/02 21:01:08 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -233,6 +233,7 @@ static void ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab);
...
@@ -233,6 +233,7 @@ static void ATPostAlterTypeCleanup(List **wqueue, AlteredTableInfo *tab);
static
void
ATPostAlterTypeParse
(
char
*
cmd
,
List
**
wqueue
);
static
void
ATPostAlterTypeParse
(
char
*
cmd
,
List
**
wqueue
);
static
void
ATExecChangeOwner
(
Oid
relationOid
,
int32
newOwnerSysId
);
static
void
ATExecChangeOwner
(
Oid
relationOid
,
int32
newOwnerSysId
);
static
void
ATExecClusterOn
(
Relation
rel
,
const
char
*
indexName
);
static
void
ATExecClusterOn
(
Relation
rel
,
const
char
*
indexName
);
static
void
ATExecDropCluster
(
Relation
rel
);
static
int
ri_trigger_type
(
Oid
tgfoid
);
static
int
ri_trigger_type
(
Oid
tgfoid
);
static
void
update_ri_trigger_args
(
Oid
relid
,
static
void
update_ri_trigger_args
(
Oid
relid
,
const
char
*
oldname
,
const
char
*
oldname
,
...
@@ -1922,8 +1923,9 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
...
@@ -1922,8 +1923,9 @@ ATPrepCmd(List **wqueue, Relation rel, AlterTableCmd *cmd,
pass
=
AT_PASS_MISC
;
pass
=
AT_PASS_MISC
;
break
;
break
;
case
AT_ClusterOn
:
/* CLUSTER ON */
case
AT_ClusterOn
:
/* CLUSTER ON */
case
AT_DropCluster
:
/* SET WITHOUT CLUSTER */
ATSimplePermissions
(
rel
,
false
);
ATSimplePermissions
(
rel
,
false
);
/* Th
is command never recurses
*/
/* Th
ese commands never recurse
*/
/* No command-specific prep needed */
/* No command-specific prep needed */
pass
=
AT_PASS_MISC
;
pass
=
AT_PASS_MISC
;
break
;
break
;
...
@@ -2083,6 +2085,9 @@ ATExecCmd(AlteredTableInfo *tab, Relation rel, AlterTableCmd *cmd)
...
@@ -2083,6 +2085,9 @@ ATExecCmd(AlteredTableInfo *tab, Relation rel, AlterTableCmd *cmd)
case
AT_ClusterOn
:
/* CLUSTER ON */
case
AT_ClusterOn
:
/* CLUSTER ON */
ATExecClusterOn
(
rel
,
cmd
->
name
);
ATExecClusterOn
(
rel
,
cmd
->
name
);
break
;
break
;
case
AT_DropCluster
:
/* SET WITHOUT CLUSTER */
ATExecDropCluster
(
rel
);
break
;
case
AT_DropOids
:
/* SET WITHOUT OIDS */
case
AT_DropOids
:
/* SET WITHOUT OIDS */
/*
/*
* Nothing to do here; we'll have generated a DropColumn subcommand
* Nothing to do here; we'll have generated a DropColumn subcommand
...
@@ -5044,6 +5049,19 @@ ATExecClusterOn(Relation rel, const char *indexName)
...
@@ -5044,6 +5049,19 @@ ATExecClusterOn(Relation rel, const char *indexName)
mark_index_clustered
(
rel
,
indexOid
);
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
* ALTER TABLE CREATE TOAST TABLE
*
*
...
...
src/backend/parser/gram.y
View file @
1cdc5872
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.4
59 2004/06/01 03:28:48 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.4
60 2004/06/02 21:01:09 momjian
Exp $
*
*
* HISTORY
* HISTORY
* AUTHOR DATE MAJOR EVENT
* AUTHOR DATE MAJOR EVENT
...
@@ -1277,6 +1277,14 @@ alter_table_cmd:
...
@@ -1277,6 +1277,14 @@ alter_table_cmd:
n->name = $3;
n->name = $3;
$$ = (Node *)n;
$$ = (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:
alter_column_default:
...
...
src/include/nodes/parsenodes.h
View file @
1cdc5872
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.25
6 2004/05/26 13:57:02
momjian Exp $
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.25
7 2004/06/02 21:01:09
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -793,6 +793,7 @@ typedef enum AlterTableType
...
@@ -793,6 +793,7 @@ typedef enum AlterTableType
AT_ToastTable
,
/* create toast table */
AT_ToastTable
,
/* create toast table */
AT_ChangeOwner
,
/* change owner */
AT_ChangeOwner
,
/* change owner */
AT_ClusterOn
,
/* CLUSTER ON */
AT_ClusterOn
,
/* CLUSTER ON */
AT_DropCluster
,
/* SET WITHOUT CLUSTER */
AT_DropOids
/* SET WITHOUT OIDS */
AT_DropOids
/* SET WITHOUT OIDS */
}
AlterTableType
;
}
AlterTableType
;
...
...
src/test/regress/expected/cluster.out
View file @
1cdc5872
...
@@ -297,6 +297,17 @@ WHERE pg_class.oid=indexrelid
...
@@ -297,6 +297,17 @@ WHERE pg_class.oid=indexrelid
clstr_tst_b_c
clstr_tst_b_c
(1 row)
(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
-- Verify that clustering all tables does in fact cluster the right ones
CREATE USER clstr_user;
CREATE USER clstr_user;
CREATE TABLE clstr_1 (a INT PRIMARY KEY);
CREATE TABLE clstr_1 (a INT PRIMARY KEY);
...
...
src/test/regress/sql/cluster.sql
View file @
1cdc5872
...
@@ -95,6 +95,14 @@ WHERE pg_class.oid=indexrelid
...
@@ -95,6 +95,14 @@ WHERE pg_class.oid=indexrelid
AND
pg_class_2
.
relname
=
'clstr_tst'
AND
pg_class_2
.
relname
=
'clstr_tst'
AND
indisclustered
;
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
-- Verify that clustering all tables does in fact cluster the right ones
CREATE
USER
clstr_user
;
CREATE
USER
clstr_user
;
CREATE
TABLE
clstr_1
(
a
INT
PRIMARY
KEY
);
CREATE
TABLE
clstr_1
(
a
INT
PRIMARY
KEY
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment