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

Commitd785841

Browse files
committed
Change order of operations in ALTER TABLE SET TABLESPACE so that we
don't hold an open file reference to the original table at the end.This is a good thing in any case, particularly so on Windows whichcannot drop the table file otherwise.
1 parentae44912 commitd785841

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 7 additions & 8 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.124 2004/08/04 20:53:53 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.125 2004/08/13 04:50:28 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -5379,21 +5379,20 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace)
53795379
dstrel=smgropen(newrnode);
53805380
smgrcreate(dstrel,rel->rd_istemp, false);
53815381

5382+
/* copy relation data to the new physical file */
5383+
copy_relation_data(rel,dstrel);
5384+
53825385
/* schedule unlinking old physical file */
53835386
if (rel->rd_smgr==NULL)
53845387
rel->rd_smgr=smgropen(rel->rd_node);
53855388
smgrscheduleunlink(rel->rd_smgr,rel->rd_istemp);
5386-
5387-
/* copy relation data to the new physical file */
5388-
copy_relation_data(rel,dstrel);
5389+
rel->rd_smgr=NULL;
53895390

53905391
/*
5391-
* Now drop smgr references. We need not smgrclose() the old file,
5392-
* since it will be dropped anyway at commit by the pending unlink.
5393-
* We do need to get rid of relcache's reference to it, however.
5392+
* Now drop smgr references. The source was already dropped by
5393+
* smgrscheduleunlink.
53945394
*/
53955395
smgrclose(dstrel);
5396-
rel->rd_smgr=NULL;
53975396

53985397
/* update the pg_class row */
53995398
rd_rel->reltablespace= (newTableSpace==MyDatabaseTableSpace) ?InvalidOid :newTableSpace;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp