WIP : change tablespace for a database

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: WIP : change tablespace for a database
Date: 2008-10-15 17:51:40
Message-ID: 48F62DAC.2080308@lelarge.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I'm currently working on a patch for the TODO item :

Allow databases to be moved to different tablespaces

I already changed the syntax, added some code to move the relations of
the specific database to the target tablespace. It works. But I have
three issues I would like to discuss.

To get the list of relations to move, the user needs to be connected to
the database. It seems awkward to launch an ALTER DATABASE statement on
the currently open database. I mean, this is what I do know:

guillaume(at)laptop$ psql db1
psql (8.4devel)
Type "help" for help.

db1=# ALTER DATABASE db1 TABLESPACE ts1;

I don't think we can do another way, do you?

One other thing, a much worse one. It seems I can't move sys objects.
There's this comment in ATExecSetTableSpace function:

/*
* We can never allow moving of shared or nailed-in-cache relations,
* because we can't support changing their reltablespace values.
*/

I do understand we forbid moving a system relation when using the ALTER
TABLE SET TABLESPACE statement. But I wonder if it could be done with an
ALTER DATABASE TABLESPACE statement.

And last issue, when I do my ALTER DATABASE TABLESPACE statement, all
relations are moved on the target tablespace, and the dattablespace
field (in pg_database catalog) is updated with the new value. When this
is done, a few moment after, I get messages telling me PG_VERSION file
is not available in the pg_tblspc/<tablespace oid>/<database oid>
directory. I know about the set_short_version() function in
backend/commands/tablespace.c but I'm not sure I should use this
function. In fact, I wonder why this file is not created at the first
move of a table.

Comments and suggestions welcome!

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Chernow 2008-10-15 18:04:12 Re: 8.3 .4 + Vista + MingW + initdb = ACCESS_DENIED
Previous Message Matthew T. O'Connor 2008-10-15 17:47:15 Re: 8.3 .4 + Vista + MingW + initdb = ACCESS_DENIED