pg.ddx.io  pgsql-patches@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jaime Casanova <systemguards@gmail.com>
To: pgsql-patches <pgsql-patches@postgresql.org>
Subject: Extending grant insert on tables to sequences
Date: Thu, 22 May 2008 13:18:24 -0500
Message-ID: <c2d9e70e0805221118x1411e00crd7d4aae7e6e4ea3d@mail.gmail.com> (raw)

Hi,

The idea of this patch is to avoid the need to make explicit grants on
sequences owned by tables.

This patch make:
- GRANT INSERT ON TABLE  extend to GRANT USAGE ON SEQUENCE    (currval, nextval)
- GRANT UPDATE ON TABLE extend to GRANT UPDATE ON SEQUENCE (nextval, setval)
- GRANT SELECT ON TABLE extend to GRANT SELECT ON SEQUENCE  (currval)

comments?

-- 
regards,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Guayaquil - Ecuador
Cel. (593) 087171157

Attachments:

grant_seq.patch (text/plain, 1.6K) download ? config.log ? config.status Index: src/backend/catalog/aclchk.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/catalog/aclchk.c,v retrieving revision 1.146 diff -c -r1.146 aclchk.c *** src/backend/catalog/aclchk.c 12 May 2008 00:00:46 -0000 1.146 --- src/backend/catalog/aclchk.c 22 May 2008 18:13:18 -0000 *************** *** 360,365 **** --- 360,402 ---- } ExecGrantStmt_oids(&istmt); + + /* + * If the objtype is a relation and the privileges includes INSERT, UPDATE + * or SELECT then extends the GRANT/REVOKE to the sequences owned by the + * relation + */ + if (istmt.objtype == ACL_OBJECT_RELATION) && + (istmt.privileges & (ACL_INSERT | ACL_UPDATE | ACL_SELECT)) + { + AclMode priv; + foreach(cell, istmt.objects) + { + InternalGrant istmt_seq; + + istmt_seq.is_grant = istmt.is_grant; + istmt_seq.objtype = ACL_OBJECT_SEQUENCE; + istmt_seq.grantees = istmt.grantees; + istmt_seq.grant_option = istmt.grant_option; + istmt_seq.behavior = istmt.behavior; + + istmt_seq.all_privs = false; + istmt_seq.privileges = ACL_NO_RIGHTS; + + istmt_seq.objects = getOwnedSequences(lfirst_oid(cell)); + if (istmt_seq.objects != NIL) + { + if (istmt.privileges & (ACL_INSERT)) + istmt_seq.privileges |= ACL_USAGE; + else if (istmt.privileges & (ACL_UPDATE)) + istmt_seq.privileges |= ACL_UPDATE; + else if (istmt.privileges & (ACL_SELECT)) + istmt_seq.privileges |= ACL_SELECT; + + ExecGrantStmt_oids(&istmt_seq); + } + } + } } /*

view thread (26+ messages)  latest in thread

Message-ID: <c2d9e70e0805221118x1411e00crd7d4aae7e6e4ea3d@mail.gmail.com>
Permalink:  ../c2d9e70e0805221118x1411e00crd7d4aae7e6e4ea3d@mail.gmail.com/
Also on:    postgresql.org/message-id/c2d9e70e0805221118x1411e00crd7d4aae7e6e4ea3d@mail.gmail.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-patches@postgresql.org
  Cc: systemguards@gmail.com
  Subject: Re: Extending grant insert on tables to sequences
  In-Reply-To: <c2d9e70e0805221118x1411e00crd7d4aae7e6e4ea3d@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox