Re: Using default tablespace for database? - Mailing list pgsql-general

From Tom Lane
Subject Re: Using default tablespace for database?
Date
Msg-id 2412.1101880784@sss.pgh.pa.us
Whole thread Raw
In response to Re: Using default tablespace for database?  ("Guy Rouillier" <guyr@masergy.com>)
List pgsql-general
"Guy Rouillier" <guyr@masergy.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

pgsql-general by date:

Previous
From: Russell Smith
Date:
Subject: Re: change natural column order
Next
From: Tino Wildenhain
Date:
Subject: Re: change natural column order