Re: Quick coding question with acl fixes - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Quick coding question with acl fixes
Date
Msg-id 9931.1090727292@sss.pgh.pa.us
Whole thread Raw
In response to Quick coding question with acl fixes  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Responses Re: Quick coding question with acl fixes
Re: Quick coding question with acl fixes
List pgsql-hackers
Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
> If I have the nspForm variable (which is a Form_pg_namespace) struct 
> pointer, then how do I check if the nspacl field is default (ie. 
> "NULL").  This is so I can avoid running DatumGetAclP on it, which seems 
> to cause alloc error reports.

Best practice is to use SysCacheGetAttr if you are dealing with a row
from cache or heap_getattr if it's from a table scan.  For instance
in aclchk.c there is
       aclDatum = SysCacheGetAttr(NAMESPACENAME, tuple,                                  Anum_pg_namespace_nspacl,
                           &isNull);       if (isNull)           old_acl = acldefault(ACL_OBJECT_NAMESPACE, ownerId);
   else           /* get a detoasted copy of the ACL */           old_acl = DatumGetAclPCopy(aclDatum);
 

> When I run through the acl changing all references from the old owner to 
> the new owner, should I combine the resulting acls if possible?  Because 
> if the new owner already has some acls on that item, they will end up 
> with two acls.

If possible ... how painful would it be to do?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Quick coding question with acl fixes
Next
From: Tom Lane
Date:
Subject: Re: Quick coding question with acl fixes