diff options
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 7d8a75d23c2..1b8e6d57294 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -14375,10 +14375,14 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode) } /* - * Relfilenumbers are not unique in databases across tablespaces, so we - * need to allocate a new one in the new tablespace. - */ - newrelfilenumber = GetNewRelFileNumber(newTableSpace, NULL, + * Generate a new relfilenumber. We cannot reuse the old relfilenumber + * because of the possibility that that relation will be moved back to the + * original tablespace before the next checkpoint. At that point, the + * first segment of the main fork won't have been unlinked yet, and an + * attempt to create new relation storage with that same relfilenumber + * will fail. + */ + newrelfilenumber = GetNewRelFileNumber(newTableSpace, rel->rd_rel->relpersistence); /* Open old and new relation */ |