Commit 556110f4 authored by Tom Lane's avatar Tom Lane

copy_relation_data was mistakenly assuming that the source relation

would always be already open at the smgr level.  Per bug report from
Fabien Coelho.
parent b4456e6d
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.129 2004/08/29 05:06:41 momjian Exp $ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.130 2004/08/31 15:56:39 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -5434,7 +5434,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace) ...@@ -5434,7 +5434,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace)
static void static void
copy_relation_data(Relation rel, SMgrRelation dst) copy_relation_data(Relation rel, SMgrRelation dst)
{ {
SMgrRelation src = rel->rd_smgr; SMgrRelation src;
bool use_wal; bool use_wal;
BlockNumber nblocks; BlockNumber nblocks;
BlockNumber blkno; BlockNumber blkno;
...@@ -5457,6 +5457,9 @@ copy_relation_data(Relation rel, SMgrRelation dst) ...@@ -5457,6 +5457,9 @@ copy_relation_data(Relation rel, SMgrRelation dst)
use_wal = XLogArchivingActive() && !rel->rd_istemp; use_wal = XLogArchivingActive() && !rel->rd_istemp;
nblocks = RelationGetNumberOfBlocks(rel); nblocks = RelationGetNumberOfBlocks(rel);
/* RelationGetNumberOfBlocks will certainly have opened rd_smgr */
src = rel->rd_smgr;
for (blkno = 0; blkno < nblocks; blkno++) for (blkno = 0; blkno < nblocks; blkno++)
{ {
smgrread(src, blkno, buf); smgrread(src, blkno, buf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment