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
c5eabafb
Commit
c5eabafb
authored
Oct 14, 2008
by
Alvaro Herrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that CLUSTER leaves the toast table and index with consistent names,
by renaming the new copies after the catalog games.
parent
a303e4dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
src/backend/commands/cluster.c
src/backend/commands/cluster.c
+32
-1
No files found.
src/backend/commands/cluster.c
View file @
c5eabafb
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.17
7 2008/06/19 00:46:04
alvherre Exp $
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.17
8 2008/10/14 17:19:50
alvherre Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -29,6 +29,7 @@
#include "catalog/index.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_namespace.h"
#include "catalog/toasting.h"
#include "commands/cluster.h"
#include "commands/tablecmds.h"
...
...
@@ -568,6 +569,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid)
char
NewHeapName
[
NAMEDATALEN
];
TransactionId
frozenXid
;
ObjectAddress
object
;
Relation
newrel
;
/* Mark the correct index as clustered */
mark_index_clustered
(
OldHeap
,
indexOid
);
...
...
@@ -622,6 +624,35 @@ rebuild_relation(Relation OldHeap, Oid indexOid)
* because reindex_relation does it.
*/
reindex_relation
(
tableOid
,
false
);
/*
* At this point, everything is kosher except that the toast table's name
* corresponds to the temporary table. The name is irrelevant to
* the backend because it's referenced by OID, but users looking at the
* catalogs could be confused. Rename it to prevent this problem.
*
* Note no lock required on the relation, because we already hold an
* exclusive lock on it.
*/
newrel
=
heap_open
(
tableOid
,
NoLock
);
if
(
OidIsValid
(
newrel
->
rd_rel
->
reltoastrelid
))
{
char
NewToastName
[
NAMEDATALEN
];
Relation
toastrel
;
/* rename the toast table ... */
snprintf
(
NewToastName
,
NAMEDATALEN
,
"pg_toast_%u"
,
tableOid
);
RenameRelationInternal
(
newrel
->
rd_rel
->
reltoastrelid
,
NewToastName
,
PG_TOAST_NAMESPACE
);
/* ... and its index too */
toastrel
=
relation_open
(
newrel
->
rd_rel
->
reltoastrelid
,
AccessShareLock
);
snprintf
(
NewToastName
,
NAMEDATALEN
,
"pg_toast_%u_index"
,
tableOid
);
RenameRelationInternal
(
toastrel
->
rd_rel
->
reltoastidxid
,
NewToastName
,
PG_TOAST_NAMESPACE
);
relation_close
(
toastrel
,
AccessShareLock
);
}
relation_close
(
newrel
,
NoLock
);
}
/*
...
...
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