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

Commitfa3938f

Browse files
committed
When a relation is moved to another tablespace, we can't assume that we can
use the old relfilenode in the new tablespace. There might be another relationin the new tablespace with the same relfilenode, so we must generate a freshrelfilenode in the new tablespace.The 8.3 patch to let deleted relation files linger as zero-length files untilthe next checkpoint made this more obvious: moving a relation from one tablespace another, and then back again, caused a collision with the lingeringfile.Back-patch to 8.1. The issue is present in 8.0 as well, but it doesn't seemworth fixing there, because we didn't have protection from OID collisionsafter OID wraparound before 8.1.Report by Guillaume Lelarge.
1 parent078aaf7 commitfa3938f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 12 additions & 1 deletion
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.266 2008/09/08 00:47:40 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.267 2008/10/07 11:15:41 heikki Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -6488,6 +6488,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace)
64886488
OidoldTableSpace;
64896489
Oidreltoastrelid;
64906490
Oidreltoastidxid;
6491+
Oidnewrelfilenode;
64916492
RelFileNodenewrnode;
64926493
SMgrRelationdstrel;
64936494
Relationpg_class;
@@ -6557,8 +6558,17 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace)
65576558
*/
65586559
FlushRelationBuffers(rel);
65596560

6561+
/*
6562+
* Relfilenodes are not unique across tablespaces, so we need to allocate
6563+
* a new one in the new tablespace.
6564+
*/
6565+
newrelfilenode=GetNewRelFileNode(newTableSpace,
6566+
rel->rd_rel->relisshared,
6567+
NULL);
6568+
65606569
/* Open old and new relation */
65616570
newrnode=rel->rd_node;
6571+
newrnode.relNode=newrelfilenode;
65626572
newrnode.spcNode=newTableSpace;
65636573
dstrel=smgropen(newrnode);
65646574

@@ -6588,6 +6598,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace)
65886598

65896599
/* update the pg_class row */
65906600
rd_rel->reltablespace= (newTableSpace==MyDatabaseTableSpace) ?InvalidOid :newTableSpace;
6601+
rd_rel->relfilenode=newrelfilenode;
65916602
simple_heap_update(pg_class,&tuple->t_self,tuple);
65926603
CatalogUpdateIndexes(pg_class,tuple);
65936604

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp