Re: Weird behaviour with ALTER TABLE ... SET TABLESPACE ... statement

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Weird behaviour with ALTER TABLE ... SET TABLESPACE ... statement
Date: 2008-10-06 12:38:02
Message-ID: 48EA06AA.4030302@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Guillaume Lelarge wrote:
> Tom Lane a écrit :
>> Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
>>> The trivial fix is to just force a checkpoint in ALTER TABLE SET
>>> TABLESPACE. Can we do better than that? Perhaps only force a checkpoint
>>> when we find that the file already exists.
>> If ALTER TABLE SET TABLESPACE is assuming that it can always use the
>> same relfilenode number in the new space as in the old, it's just plain
>> broken. We need to fix that assumption.
>
> Do you mean the backend should change the relfilenode number whenever we
> use the ALTER TABLE SET TABLESPACE ? I can't think of a way to get twice
> the same relfilenode.
>
> Perhaps a better question would be : how the next relfilenode is computed?

1. Get the next OID from the counter.
2. Check if a file with that name exists. If it does, goto 1.

Yeah, seems like we need to allocate a new relfilenode in the new
tablespace.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-10-06 12:47:16 Re: Weird behaviour with ALTER TABLE ... SET TABLESPACE ... statement
Previous Message Guillaume Lelarge 2008-10-06 12:29:08 Re: Weird behaviour with ALTER TABLE ... SET TABLESPACE ... statement