Re: [Patch Review] TRUNCATE Permission - Mailing list pgsql-hackers

From Ryan Bradetich
Subject Re: [Patch Review] TRUNCATE Permission
Date
Msg-id e739902b0809011232q55d0bd00q72b8d8019104feb7@mail.gmail.com
Whole thread Raw
In response to [Patch Review] TRUNCATE Permission  ("Ryan Bradetich" <rbradetich@gmail.com>)
Responses Re: [Patch Review] TRUNCATE Permission  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hello all,

On Sun, Aug 31, 2008 at 11:55 PM, Ryan Bradetich <rbradetich@gmail.com> wrote:

I do not believe this is a huge issue since truncate is prohibited on the system catalogs
by the truncate_check_rel().

template1=# truncate pg_authid;
ERROR:  permission denied: "pg_authid" is a system catalog

I thought about this some more.  I believe my suggestion was incorrect.
Since truncate_check_rel() prevents the use of the truncate command on
system catalogs, the TRUNCATE permission should always be stripped
from the system catalogs.

Here is the inconsistency I observed:

template1=# \z pg_catalog.pg_authid

                  Access privileges
   Schema   |   Name    | Type  |  Access privileges 
------------+-----------+-------+---------------------
 pg_catalog | pg_authid | table | rbrad=arwdDxt/rbrad
(1 row)

  template1=# select rolname, rolcatupdate from pg_authid;
   rolname | rolcatupdate
  ---------+--------------
   rbrad   | t
  (1 row)

  template1=# select has_table_privilege('pg_authid', 'truncate');
   has_table_privilege
  ---------------------
   t
  (1 row)

  template1=# truncate pg_authid;
  ERROR:  permission denied: "pg_authid" is a system catalog

The TRUNCATE fails even though \z and has_table_privilege() said I had permissions.
Compare with the DELETE privilege:

  template1=# select has_table_privilege('pg_authid', 'delete');
   has_table_privilege
  ---------------------
   t
  (1 row)

template1=# delete from pg_authid;
DELETE 1

Thanks,

- Ryan

pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Window functions patch v04 for the September commit fest
Next
From: Tom Lane
Date:
Subject: Re: [Patch Review] TRUNCATE Permission