From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Gavin Sherry <swm(at)linuxworld(dot)com(dot)au> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Minor DROP TABLESPACE issue |
Date: | 2004-06-19 01:10:09 |
Message-ID: | 5545.1087607409@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Although DROP TABLESPACE can detect tables existing in the target
tablespace, it doesn't have any way to detect schemas that reference
that tablespace as their default tablespace. Thus you can get
implementation-level failures like this one:
$ mkdir /tmp/junk
regression=# create tablespace junk location '/tmp/junk';
CREATE TABLESPACE
regression=# create schema junk tablespace junk;
CREATE SCHEMA
regression=# drop tablespace junk;
DROP TABLESPACE
regression=# create table junk.foo(f1 text);
ERROR: could not create directory "/u/pg_data/pg_tablespaces/292909/155056": No such file or directory
regression=#
The fact that it fails isn't a big problem, but the error message is
pretty unclear if you're unfamiliar with the implementation.
The same problem would exist with respect to a database's default
tablespace, except that a database will always have its system catalogs
stored there and so the file-level check prevents dropping the
tablespace.
I don't think we can directly prevent the DROP TABLESPACE, since we
can't see what's in pg_namespace of other databases. I thought about
creating a placeholder file associated with every schema that has a
nondefault tablespace, thereby allowing the file-level check to detect
the problem. But that looks very ugly, not least because namespaces
don't have relfilenode values. What might be the most appropriate
solution is just to issue a specialized error message in
TablespaceCreateDbspace(): if mkdir fails with ENOENT, we could say
something like
ERROR: tablespace 292909 has been deleted
after making an appropriate stat() test to verify that the symlink is
indeed gone. It's not great that we'd have to use the OID in this
message, but since the pg_tablespace row is (presumably) gone I don't
see any way to get the actual name of the tablespace.
Anyone see other alternatives?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Gavin Sherry | 2004-06-19 01:19:30 | Re: Minor DROP TABLESPACE issue |
Previous Message | Bruce Momjian | 2004-06-19 00:05:41 | Re: Tablespace patch review |