Re: Using default tablespace for database?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Guy Rouillier" <guyr(at)masergy(dot)com>
Cc: "PostgreSQL General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using default tablespace for database?
Date: 2004-12-01 05:59:44
Message-ID: 2412.1101880784@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Guy Rouillier" <guyr(at)masergy(dot)com> writes:
> ... This does seem
> logically inconsistent, though. That I can create a table in the
> database's default tablespace if I don't specify it demonstrates that I
> have permission to do; this permission has been implicitly granted to
> all users of the database. That implicit permission doesn't disappear
> because I mention the same tablespace explicitly.

I'm not convinced. I think that
CREATE TABLE foo (...);
means "create my table in whatever tablespace my database likes", while
CREATE TABLE foo (...) TABLESPACE bar;
means "create my table in tablespace bar". It might happen that bar is
the same tablespace as foo's default, but that doesn't make the cases
equivalent; in the latter case I'm asserting that I have the right to
control the tablespace selection, whereas in the former I'm not. So in
the latter case I should need the permissions to make that assertion,
in the former case not.

There isn't a whole lot of practical difference right at the moment, but
let's suppose that in a release or two someone writes an ALTER DATABASE
SET TABLESPACE command. My expectation would be that a table declared
the first way would move to the new database-default tablespace, but a
table declared the second way would stay right in tablespace bar.
That's why you need some explicit permissions to say the latter.

> Any idea why the tablespace name does not appear to be associated with
> the table in the system catalog?

Right at the moment we don't have a way to distinguish "this table is in
the database's default tablespace" from "this table is in tablespace foo
that just happens to be the same as the database's default tablespace".
But IMHO there is a semantic difference there; it's only an implementation
glitch that we can't enforce the difference yet.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas F.O'Connell 2004-12-01 06:11:35 Poor Performance with Distinct Subqueries with EXISTS and EXCEPT
Previous Message Russell Smith 2004-12-01 05:46:47 Re: change natural column order