Re: Simplify calls of pg_class_aclcheck when multiple modes are used

Lists: pgsql-hackers
From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Simplify calls of pg_class_aclcheck when multiple modes are used
Date: 2014-08-27 12:02:40
Message-ID: CAB7nPqTX3rRAaFTbe1h=PnUe7VO6+Q12VEZOf3qUNqmFDpL1vA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi all,

In a couple of code paths we do the following to check permissions on an
object:
if (pg_class_aclcheck(relid, userid, ACL_USAGE) != ACLCHECK_OK &&
pg_class_aclcheck(relid, userid, ACL_UPDATE) != ACLCHECK_OK)
ereport(ERROR, blah);

Wouldn't it be better to simplify that with a single call of
pg_class_aclcheck, gathering together the modes that need to be checked? In
the case above, the call to pg_class_aclcheck would become like that:
if (pg_class_aclcheck(relid, userid,
ACL_USAGE | ACL_UPDATE) != ACLCHECK_OK)
ereport(ERROR, blah);

That's not a critical thing, but it would save some cycles. Patch is
attached.
Regards,
--
Michael

Attachment Content-Type Size
20140827_aclcheck_simplify.patch text/x-patch 2.2 KB

From: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Simplify calls of pg_class_aclcheck when multiple modes are used
Date: 2014-10-06 17:58:11
Message-ID: CAFcNs+pqkmmA5FjHUGzB5bdH7Lg-MWVuHwpex0_rvJi-Ro+57w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Aug 27, 2014 at 9:02 AM, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
wrote:
>
> Hi all,
>
> In a couple of code paths we do the following to check permissions on an
object:
> if (pg_class_aclcheck(relid, userid, ACL_USAGE) != ACLCHECK_OK &&
> pg_class_aclcheck(relid, userid, ACL_UPDATE) != ACLCHECK_OK)
> ereport(ERROR, blah);
>
> Wouldn't it be better to simplify that with a single call of
pg_class_aclcheck, gathering together the modes that need to be checked? In
the case above, the call to pg_class_aclcheck would become like that:
> if (pg_class_aclcheck(relid, userid,
> ACL_USAGE | ACL_UPDATE) != ACLCHECK_OK)
> ereport(ERROR, blah);
>
> That's not a critical thing, but it would save some cycles. Patch is
attached.
>

I did a little review:
- applied to master without errors
- no compiler warnings
- no regressions

It's a minor change and as Michael already said would save some cycles.

Marked as "Ready for commiter".

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog: http://fabriziomello.github.io
>> Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello
>> Github: http://github.com/fabriziomello


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Simplify calls of pg_class_aclcheck when multiple modes are used
Date: 2014-10-21 20:03:09
Message-ID: 5446BBFD.80502@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 8/27/14 8:02 AM, Michael Paquier wrote:
> In a couple of code paths we do the following to check permissions on an
> object:
> if (pg_class_aclcheck(relid, userid, ACL_USAGE) != ACLCHECK_OK &&
> pg_class_aclcheck(relid, userid, ACL_UPDATE) != ACLCHECK_OK)
> ereport(ERROR, blah);
>
> Wouldn't it be better to simplify that with a single call of
> pg_class_aclcheck, gathering together the modes that need to be checked?

Yes, it's probably just an oversight.

While looking at this, I wrote a few tests cases for sequence
privileges, because that was not covered at all. That patch is attached.

That led me to discover this issue:
http://www.postgresql.org/message-id/5446B819.1020600@gmx.net

I'll wait for the resolution of that and then commit this.

Attachment Content-Type Size
sequence-privileges-tests.patch text/x-diff 4.9 KB

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Simplify calls of pg_class_aclcheck when multiple modes are used
Date: 2014-10-21 22:19:01
Message-ID: CAB7nPqQN153onE+y-LJvaoTRz3i8K+s=veYjQxxgWVsUGyay+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Oct 22, 2014 at 5:03 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> While looking at this, I wrote a few tests cases for sequence
> privileges, because that was not covered at all. That patch is attached.
>
+1 for those tests.
--
Michael


From: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Simplify calls of pg_class_aclcheck when multiple modes are used
Date: 2014-10-21 22:29:13
Message-ID: CAFcNs+oVAYKC0pp4wYfsLy0GRSbki8V9Bb1dMd1EySpE1fGPQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Em terça-feira, 21 de outubro de 2014, Michael Paquier <
michael(dot)paquier(at)gmail(dot)com> escreveu:

> On Wed, Oct 22, 2014 at 5:03 AM, Peter Eisentraut <peter_e(at)gmx(dot)net
> <javascript:_e(%7B%7D,'cvml','peter_e(at)gmx(dot)net');>> wrote:
>
>> While looking at this, I wrote a few tests cases for sequence
>> privileges, because that was not covered at all. That patch is attached.
>>
> +1 for those tests.
>
>
+1

Fabrízio Mello

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog: http://fabriziomello.github.io
>> Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello
>> Github: http://github.com/fabriziomello


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Simplify calls of pg_class_aclcheck when multiple modes are used
Date: 2014-10-23 01:45:52
Message-ID: 54485DD0.8000805@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 10/21/14 6:19 PM, Michael Paquier wrote:
> On Wed, Oct 22, 2014 at 5:03 AM, Peter Eisentraut <peter_e(at)gmx(dot)net
> <mailto:peter_e(at)gmx(dot)net>> wrote:
>
> While looking at this, I wrote a few tests cases for sequence
> privileges, because that was not covered at all. That patch is
> attached.
>
> +1 for those tests.
> --
> Michael

Committed your patch and tests.


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Simplify calls of pg_class_aclcheck when multiple modes are used
Date: 2014-10-23 14:48:01
Message-ID: CAB7nPqQavROtJYaMMYj=oiHqzwxMkEztz3CuP=CDXkJpBb-o+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Oct 23, 2014 at 10:45 AM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:

> Committed your patch and tests.
>
Thanks!
--
Michael