|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * 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 $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -5379,21 +5379,20 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace)
|
5379 | 5379 | dstrel = smgropen(newrnode);
|
5380 | 5380 | smgrcreate(dstrel, rel->rd_istemp, false);
|
5381 | 5381 |
|
| 5382 | + /* copy relation data to the new physical file */ |
| 5383 | + copy_relation_data(rel, dstrel); |
| 5384 | + |
5382 | 5385 | /* schedule unlinking old physical file */
|
5383 | 5386 | if (rel->rd_smgr == NULL)
|
5384 | 5387 | rel->rd_smgr = smgropen(rel->rd_node);
|
5385 | 5388 | 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; |
5389 | 5390 |
|
5390 | 5391 | /*
|
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. |
5394 | 5394 | */
|
5395 | 5395 | smgrclose(dstrel);
|
5396 |
| - rel->rd_smgr = NULL; |
5397 | 5396 |
|
5398 | 5397 | /* update the pg_class row */
|
5399 | 5398 | rd_rel->reltablespace = (newTableSpace == MyDatabaseTableSpace) ? InvalidOid : newTableSpace;
|
|
0 commit comments