ALTER TABLE ... SET TABLESPACE pg_default

Lists: pgsql-hackers
From: Stephen Frost <sfrost(at)snowman(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: ALTER TABLE ... SET TABLESPACE pg_default
Date: 2014-01-16 21:28:52
Message-ID: 20140116212852.GG2686@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Greetings,

Harking back to 10 years ago when tablespaces were added, it looks
like we originally figured that users didn't need permissions to
create tables in the database default, per 2467394e. That strikes me
as perfectly fair. Unfortunately, the later addition of
ALTER TABLE ... SET TABLESPACE (af4de814) didn't get the memo about
the default tablespace being special in this regard and refuses to let
a user move their tables into the default tablespace, even though they
can do so via 'CREATE TABLE ... AS SELECT * FROM ...'.

Barring objections, I'll add the same conditional around the AclCheck
in ATPrepSetTableSpace() as exists in DefineRelation() to allow users
to ALTER TABLE ... SET TABLESPACE into the database's default
tablespace and backpatch accordingly.

Thanks,

Stephen


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ALTER TABLE ... SET TABLESPACE pg_default
Date: 2014-01-20 02:33:14
Message-ID: 52DC8AEA.7090507@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/17/2014 05:28 AM, Stephen Frost wrote:
> Greetings,
>
> Harking back to 10 years ago when tablespaces were added, it looks
> like we originally figured that users didn't need permissions to
> create tables in the database default, per 2467394e. That strikes
> me as perfectly fair. Unfortunately, the later addition of ALTER
> TABLE ... SET TABLESPACE (af4de814) didn't get the memo about the
> default tablespace being special in this regard and refuses to let
> a user move their tables into the default tablespace, even though
> they can do so via 'CREATE TABLE ... AS SELECT * FROM ...'.
>
> Barring objections, I'll add the same conditional around the
> AclCheck in ATPrepSetTableSpace() as exists in DefineRelation() to
> allow users to ALTER TABLE ... SET TABLESPACE into the database's
> default tablespace and backpatch accordingly.

Sounds sensible. I just stumbled across a report of this bug, too:

http://stackoverflow.com/questions/21193127/avoid-users-to-create-tables-on-default-tablespace

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services