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
a03c0d93
Commit
a03c0d93
authored
Dec 30, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review for CLUSTER ALL patch. Fix bogus locking, incorrect transaction
stop/start nesting, other infelicities.
parent
2e1f2c31
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
286 additions
and
288 deletions
+286
-288
doc/src/sgml/ref/cluster.sgml
doc/src/sgml/ref/cluster.sgml
+13
-11
src/backend/commands/cluster.c
src/backend/commands/cluster.c
+257
-245
src/backend/commands/tablecmds.c
src/backend/commands/tablecmds.c
+6
-11
src/backend/tcop/utility.c
src/backend/tcop/utility.c
+3
-11
src/include/commands/cluster.h
src/include/commands/cluster.h
+6
-9
src/test/regress/expected/cluster.out
src/test/regress/expected/cluster.out
+1
-1
No files found.
doc/src/sgml/ref/cluster.sgml
View file @
a03c0d93
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/cluster.sgml,v 1.2
2 2002/11/18 17:12:06 momjian
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/cluster.sgml,v 1.2
3 2002/12/30 18:42:12 tgl
Exp $
PostgreSQL documentation
-->
...
...
@@ -108,14 +108,16 @@ CLUSTER
<para>
When a table is clustered, <productname>PostgreSQL</productname>
remembers on which index it was clustered.
In calls to
remembers on which index it was clustered.
The form
<command>CLUSTER <replaceable class="parameter">tablename</replaceable></command>,
the table is clustered
on the same index that it was clustered before.
re-clusters the table
on the same index that it was clustered before.
</para>
<para>
A simple <command>CLUSTER</command> clusters all the tables in the database
that the calling user owns and uses the saved cluster information. This
<command>CLUSTER</command> without any parameter re-clusters all the tables
in the
current database that the calling user owns, or all tables if called
by a superuser. (Never-clustered tables are not touched.) This
form of <command>CLUSTER</command> cannot be called from inside a
transaction or function.
</para>
...
...
@@ -165,7 +167,7 @@ CLUSTER
Because <command>CLUSTER</command> remembers the clustering information,
one can cluster the tables one wants clustered manually the first time, and
setup a timed event similar to <command>VACUUM</command> so that the tables
are periodically and automatically
clustered.
are periodically re-
clustered.
</para>
<para>
...
...
src/backend/commands/cluster.c
View file @
a03c0d93
This diff is collapsed.
Click to expand it.
src/backend/commands/tablecmds.c
View file @
a03c0d93
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.6
2 2002/12/16 18:39:22
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.6
3 2002/12/30 18:42:14
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -355,7 +355,7 @@ RemoveRelation(const RangeVar *relation, DropBehavior behavior)
* Removes all the rows from a relation.
*
* Note: This routine only does safety and permissions checks;
* rebuild_rel in cluster.c does the actual work.
* rebuild_rel
ation
in cluster.c does the actual work.
*/
void
TruncateRelation
(
const
RangeVar
*
relation
)
...
...
@@ -366,7 +366,6 @@ TruncateRelation(const RangeVar *relation)
Relation
fkeyRel
;
SysScanDesc
fkeyScan
;
HeapTuple
tuple
;
List
*
indexes
;
/* Grab exclusive lock in preparation for truncate */
rel
=
heap_openrv
(
relation
,
AccessExclusiveLock
);
...
...
@@ -433,17 +432,13 @@ TruncateRelation(const RangeVar *relation)
systable_endscan
(
fkeyScan
);
heap_close
(
fkeyRel
,
AccessShareLock
);
/* Save the information of all indexes on the relation. */
indexes
=
get_indexattr_list
(
rel
,
InvalidOid
);
/* Keep the lock until transaction commit */
heap_close
(
rel
,
NoLock
);
/*
* Do the real work using the same technique as cluster, but
* without the
code copy
portion
* without the
data-copying
portion
*/
rebuild_rel
(
relid
,
InvalidOid
,
indexes
,
false
);
rebuild_relation
(
rel
,
InvalidOid
);
/* NB: rebuild_relation does heap_close() */
}
/*----------
...
...
src/backend/tcop/utility.c
View file @
a03c0d93
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.18
6 2002/12/30 15:31:48 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.18
7 2002/12/30 18:42:16 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -187,7 +187,6 @@ ProcessUtility(Node *parsetree,
CommandDest
dest
,
char
*
completionTag
)
{
if
(
completionTag
)
completionTag
[
0
]
=
'\0'
;
...
...
@@ -195,7 +194,6 @@ ProcessUtility(Node *parsetree,
{
/*
* ******************************** transactions ********************************
*
*/
case
T_TransactionStmt
:
{
...
...
@@ -742,11 +740,7 @@ ProcessUtility(Node *parsetree,
break
;
case
T_ClusterStmt
:
{
ClusterStmt
*
stmt
=
(
ClusterStmt
*
)
parsetree
;
cluster
(
stmt
);
}
cluster
((
ClusterStmt
*
)
parsetree
);
break
;
case
T_VacuumStmt
:
...
...
@@ -874,7 +868,6 @@ ProcessUtility(Node *parsetree,
switch
(
stmt
->
reindexType
)
{
char
*
relname
;
case
INDEX
:
CheckOwnership
(
stmt
->
relation
,
false
);
ReindexIndex
(
stmt
->
relation
,
stmt
->
force
);
...
...
@@ -884,8 +877,7 @@ ProcessUtility(Node *parsetree,
ReindexTable
(
stmt
->
relation
,
stmt
->
force
);
break
;
case
DATABASE
:
relname
=
(
char
*
)
stmt
->
name
;
ReindexDatabase
(
relname
,
stmt
->
force
,
false
);
ReindexDatabase
(
stmt
->
name
,
stmt
->
force
,
false
);
break
;
}
break
;
...
...
src/include/commands/cluster.h
View file @
a03c0d93
...
...
@@ -6,22 +6,19 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* $Id: cluster.h,v 1.1
7 2002/11/23 04:05:52 momjian
Exp $
* $Id: cluster.h,v 1.1
8 2002/12/30 18:42:16 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef CLUSTER_H
#define CLUSTER_H
#include <nodes/parsenodes.h>
/*
* functions
*/
extern
void
cluster
(
ClusterStmt
*
stmt
);
#include "nodes/parsenodes.h"
#include "utils/rel.h"
extern
List
*
get_indexattr_list
(
Relation
OldHeap
,
Oid
OldIndex
);
extern
void
rebuild_rel
(
Oid
tableOid
,
Oid
indexOid
,
List
*
indexes
,
bool
dataCopy
);
extern
void
cluster
(
ClusterStmt
*
stmt
);
extern
void
rebuild_relation
(
Relation
OldHeap
,
Oid
indexOid
);
#endif
/* CLUSTER_H */
src/test/regress/expected/cluster.out
View file @
a03c0d93
...
...
@@ -304,7 +304,7 @@ INSERT INTO clstr_3 VALUES (2);
INSERT INTO clstr_3 VALUES (1);
-- "CLUSTER <tablename>" on a table that hasn't been clustered
CLUSTER clstr_2;
ERROR: CLUSTER: No previously clustered index found on table
clstr_2
ERROR: CLUSTER: No previously clustered index found on table
"clstr_2"
CLUSTER clstr_1_pkey ON clstr_1;
CLUSTER clstr_2_pkey ON clstr_2;
SELECT * FROM clstr_1 UNION ALL
...
...
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