Re: patch: Add a separate TRUNCATE permission

Lists: pgsql-hackers
From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: "PG Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: patch: Add a separate TRUNCATE permission
Date: 2008-07-26 21:44:11
Message-ID: 603c8f070807261444s133fb281sf34d069ab5b4c0b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Here's a patch implementing the TODO item "Add a separate TRUNCATE
permission". Hopefully I found all the bits that needed to be
modified to make this work.

Any feedback appreciated.

Thanks,

...Robert

Attachment Content-Type Size
truncate.patch text/x-diff 23.2 KB

From: Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: Add a separate TRUNCATE permission
Date: 2008-07-28 08:17:08
Message-ID: 488D8084.7010902@sun.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas napsal(a):
> Here's a patch implementing the TODO item "Add a separate TRUNCATE
> permission". Hopefully I found all the bits that needed to be
> modified to make this work.
>
> Any feedback appreciated.
>

Added to the next commit fest patch list.
http://wiki.postgresql.org/wiki/CommitFest:2008-09

Zdenek


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: "Robert Haas" <robertmhaas(at)gmail(dot)com>
Subject: Re: patch: Add a separate TRUNCATE permission
Date: 2008-07-29 08:03:38
Message-ID: 200807291103.38950.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Am Sunday, 27. July 2008 schrieb Robert Haas:
> Here's a patch implementing the TODO item "Add a separate TRUNCATE
> permission". Hopefully I found all the bits that needed to be
> modified to make this work.

Looks very good to me.


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: patch: Add a separate TRUNCATE permission
Date: 2008-07-29 11:08:44
Message-ID: 20080729110844.GL16005@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Peter Eisentraut (peter_e(at)gmx(dot)net) wrote:
> Am Sunday, 27. July 2008 schrieb Robert Haas:
> > Here's a patch implementing the TODO item "Add a separate TRUNCATE
> > permission". Hopefully I found all the bits that needed to be
> > modified to make this work.
>
> Looks very good to me.

We've been through this before, I believe.. The concern is that it
chews up another bit in the acl structure, leaving not a huge number
left. My suggested approach to fixing this was to split the "grantable"
bits up from the regular usage bits. That's, unfortunately, a
non-trivial amount of work, however.

Perhaps just having a plan for how we would increase the number of
available bits would be enough to go ahead and add this option though?
I'd certainly like to see a truncate permission, I wrote a patch for it
myself back in January of 2006. That thread starts here:

http://archives.postgresql.org/pgsql-patches/2006-01/msg00028.php

I think someone else submitted a patch for it last year too, actually.

Thanks,

Stephen


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: patch: Add a separate TRUNCATE permission
Date: 2008-07-29 12:25:20
Message-ID: 200807291525.21721.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Am Tuesday, 29. July 2008 schrieb Stephen Frost:
> I'd certainly like to see a truncate permission, I wrote a patch for it
> myself back in January of 2006.  That thread starts here:
>
> http://archives.postgresql.org/pgsql-patches/2006-01/msg00028.php
>
> I think someone else submitted a patch for it last year too, actually.

Well, that certainly indicates some demand.

I think we should worry about adding more bits when we need them. It's
certainly possible to add more bits, so it is not like we need to save the
ones we have forever.


From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "PG Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: Add a separate TRUNCATE permission
Date: 2008-07-29 12:31:30
Message-ID: 603c8f070807290531v1eb0dc9fsad32f843f7dbb0f5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> We've been through this before, I believe.. The concern is that it
> chews up another bit in the acl structure, leaving not a huge number
> left. My suggested approach to fixing this was to split the "grantable"
> bits up from the regular usage bits. That's, unfortunately, a
> non-trivial amount of work, however.

Writing this patch was more of a "learn the PostgreSQL source" project
for me than a feature that I, personally, have a need for, so I have
no dog in this race other than that, if the feature was actually not
wanted, then it shouldn't be on the TODO list, possibly causing people
to waste time implementing it. :-)

The question of using up all the bits seems purely speculative to me
at this point. I agree that we don't want to fritter them away, but
this is the only TODO item proposes using any of those bits. Tom's
complaint about your patch seems to have been that it uses three of
the five remaining ACL bits; this patch uses only one, and arguably
TRUNCATE is more like a DML command than a utility command (which, as
Tom pointed out, there are certainly too many of to ever allocate a
bit for each one).

I would argue that if we're ever going to start adding permissions for
things like those types of utility command then we ought to create
some separate mechanism for storing permissions that are not likely to
need to be checked very frequently. Then things like INSERT and
UPDATE that happen often can benefit from a 16-bit field, and things
like ANALYZE and ADD COLUMN that are only executed occasionally can
use a separate, more heavy-weight mechanism.

In any event, however we ultimately decide to implement it, we don't
need to solve this problem now.

> I think someone else submitted a patch for it last year too, actually.

I talked about submitting one last year but didn't actually do it
since it seemed to be the wrong point in the development cycle.

...Robert


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: patch: Add a separate TRUNCATE permission
Date: 2008-07-29 13:03:47
Message-ID: 20080729130347.GM16005@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Peter Eisentraut (peter_e(at)gmx(dot)net) wrote:
> Am Tuesday, 29. July 2008 schrieb Stephen Frost:
> > I'd certainly like to see a truncate permission, I wrote a patch for it
> > myself back in January of 2006.  That thread starts here:
> >
> > http://archives.postgresql.org/pgsql-patches/2006-01/msg00028.php
> >
> > I think someone else submitted a patch for it last year too, actually.
>
> Well, that certainly indicates some demand.
>
> I think we should worry about adding more bits when we need them. It's
> certainly possible to add more bits, so it is not like we need to save the
> ones we have forever.

I would agree with this. Others?

Stephen


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: Add a separate TRUNCATE permission
Date: 2008-07-29 13:11:24
Message-ID: 20080729131124.GN16005@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Robert Haas (robertmhaas(at)gmail(dot)com) wrote:
> > We've been through this before, I believe.. The concern is that it
> > chews up another bit in the acl structure, leaving not a huge number
> > left. My suggested approach to fixing this was to split the "grantable"
> > bits up from the regular usage bits. That's, unfortunately, a
> > non-trivial amount of work, however.
>
> Writing this patch was more of a "learn the PostgreSQL source" project
> for me than a feature that I, personally, have a need for, so I have
> no dog in this race other than that, if the feature was actually not
> wanted, then it shouldn't be on the TODO list, possibly causing people
> to waste time implementing it. :-)

Oh, it's wanted, I've been asking after it for 3 years. The problem is
just in getting people to agree to address it in this way, or if not to
accept some other way to address it (in which case the TODO should be
updated to reflect that).

> The question of using up all the bits seems purely speculative to me
> at this point. I agree that we don't want to fritter them away, but
> this is the only TODO item proposes using any of those bits. Tom's
> complaint about your patch seems to have been that it uses three of
> the five remaining ACL bits; this patch uses only one, and arguably
> TRUNCATE is more like a DML command than a utility command (which, as
> Tom pointed out, there are certainly too many of to ever allocate a
> bit for each one).

With the advent of autovacuum, my additional permissions for vacuum and
analyze are much less necessary. I'm fine with just adding a permission
for truncate.

> I would argue that if we're ever going to start adding permissions for
> things like those types of utility command then we ought to create
> some separate mechanism for storing permissions that are not likely to
> need to be checked very frequently. Then things like INSERT and
> UPDATE that happen often can benefit from a 16-bit field, and things
> like ANALYZE and ADD COLUMN that are only executed occasionally can
> use a separate, more heavy-weight mechanism.

That's along the same lines as I was proposing, except I would put all
of the "grantable" options in the "not often needed" column, which would
give us a full 32-bit field for "common" permissions.

> In any event, however we ultimately decide to implement it, we don't
> need to solve this problem now.

Agreed.

> > I think someone else submitted a patch for it last year too, actually.
>
> I talked about submitting one last year but didn't actually do it
> since it seemed to be the wrong point in the development cycle.

That might have been it, not sure.

Thanks!

Stephen


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "PG Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: Add a separate TRUNCATE permission
Date: 2008-07-29 15:08:13
Message-ID: 10976.1217344093@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Robert Haas" <robertmhaas(at)gmail(dot)com> writes:
> The question of using up all the bits seems purely speculative to me
> at this point. I agree that we don't want to fritter them away, but
> this is the only TODO item proposes using any of those bits. Tom's
> complaint about your patch seems to have been that it uses three of
> the five remaining ACL bits;

Yeah, exactly, and it also started us down the path of wanting a
separate permission bit for every DDL command. I don't have a
problem with the idea of just eating one bit for TRUNCATE. That
would leave us with four free out of sixteen, which hardly seems
like the usage level at which to start sounding alarm bells.

I believe it would be easy and cheap to adjust the representation
of ACLs to support 32 permissions instead of 16; so I won't cry
if we someday push past 16. Beyond that, though, things get very
much more expensive and complicated (as per the speculations in
this thread). So what I was really resisting was the notion of
"permission per DDL command" --- I don't want to go that way.

regards, tom lane


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: patch: Add a separate TRUNCATE permission
Date: 2008-08-03 20:41:18
Message-ID: 1217796078.3934.255.camel@ebony.t-mobile.de.
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Tue, 2008-07-29 at 09:03 -0400, Stephen Frost wrote:
> * Peter Eisentraut (peter_e(at)gmx(dot)net) wrote:
> > Am Tuesday, 29. July 2008 schrieb Stephen Frost:
> > > I'd certainly like to see a truncate permission, I wrote a patch for it
> > > myself back in January of 2006. That thread starts here:
> > >
> > > http://archives.postgresql.org/pgsql-patches/2006-01/msg00028.php
> > >
> > > I think someone else submitted a patch for it last year too, actually.

It was raised in January and rejected again then. Glad to see it raised
again here. I believe Tom's previous concerns about allowing truncate
permissions were related to the potentially increased number of truncate
commands this would cause and the need to tune invalidation messages.
That's done now.

> > Well, that certainly indicates some demand.
> >
> > I think we should worry about adding more bits when we need them. It's
> > certainly possible to add more bits, so it is not like we need to save the
> > ones we have forever.
>
> I would agree with this. Others?

I've no problem with running out of bits. At this rate, we have enough
some for some years yet. But I don't see too many additional permissions
coming along anyhow.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support