*** pgsql/src/backend/utils/adt/acl.c 2009/01/01 17:23:48 1.145 --- pgsql/src/backend/utils/adt/acl.c 2009/01/22 20:16:06 1.146 *************** *** 8,14 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.144 2008/12/19 16:25:17 petere Exp $ * *------------------------------------------------------------------------- */ --- 8,14 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.145 2009/01/01 17:23:48 momjian Exp $ * *------------------------------------------------------------------------- */ *************** allocacl(int n) *** 367,372 **** --- 367,413 ---- } /* + * Copy an ACL + */ + Acl * + aclcopy(const Acl *orig_acl) + { + Acl *result_acl; + + result_acl = allocacl(ACL_NUM(orig_acl)); + + memcpy(ACL_DAT(result_acl), + ACL_DAT(orig_acl), + ACL_NUM(orig_acl) * sizeof(AclItem)); + + return result_acl; + } + + /* + * Concatenate two ACLs + * + * This is a bit cheesy, since we may produce an ACL with redundant entries. + * Be careful what the result is used for! + */ + Acl * + aclconcat(const Acl *left_acl, const Acl *right_acl) + { + Acl *result_acl; + + result_acl = allocacl(ACL_NUM(left_acl) + ACL_NUM(right_acl)); + + memcpy(ACL_DAT(result_acl), + ACL_DAT(left_acl), + ACL_NUM(left_acl) * sizeof(AclItem)); + + memcpy(ACL_DAT(result_acl) + ACL_NUM(left_acl), + ACL_DAT(right_acl), + ACL_NUM(right_acl) * sizeof(AclItem)); + + return result_acl; + } + + /* * Verify that an ACL array is acceptable (one-dimensional and has no nulls) */ static void *************** acldefault(GrantObjectType objtype, Oid *** 542,552 **** --- 583,599 ---- { AclMode world_default; AclMode owner_default; + int nacl; Acl *acl; AclItem *aip; switch (objtype) { + case ACL_OBJECT_COLUMN: + /* by default, columns have no extra privileges */ + world_default = ACL_NO_RIGHTS; + owner_default = ACL_NO_RIGHTS; + break; case ACL_OBJECT_RELATION: world_default = ACL_NO_RIGHTS; owner_default = ACL_ALL_RIGHTS_RELATION; *************** acldefault(GrantObjectType objtype, Oid *** 593,599 **** break; } ! acl = allocacl((world_default != ACL_NO_RIGHTS) ? 2 : 1); aip = ACL_DAT(acl); if (world_default != ACL_NO_RIGHTS) --- 640,652 ---- break; } ! nacl = 0; ! if (world_default != ACL_NO_RIGHTS) ! nacl++; ! if (owner_default != ACL_NO_RIGHTS) ! nacl++; ! ! acl = allocacl(nacl); aip = ACL_DAT(acl); if (world_default != ACL_NO_RIGHTS) *************** acldefault(GrantObjectType objtype, Oid *** 614,622 **** * "_SYSTEM"-like ACL entry, by internally special-casing the owner * whereever we are testing grant options. */ ! aip->ai_grantee = ownerId; ! aip->ai_grantor = ownerId; ! ACLITEM_SET_PRIVS_GOPTIONS(*aip, owner_default, ACL_NO_RIGHTS); return acl; } --- 667,678 ---- * "_SYSTEM"-like ACL entry, by internally special-casing the owner * whereever we are testing grant options. */ ! if (owner_default != ACL_NO_RIGHTS) ! { ! aip->ai_grantee = ownerId; ! aip->ai_grantor = ownerId; ! ACLITEM_SET_PRIVS_GOPTIONS(*aip, owner_default, ACL_NO_RIGHTS); ! } return acl; }