@@ -165,9 +165,9 @@ static AclMode pg_type_aclmask_ext(Oid type_oid, Oid roleid,
165165 AclMode mask , AclMaskHow how ,
166166 bool * is_missing );
167167static void recordExtensionInitPriv (Oid objoid , Oid classoid , int objsubid ,
168- Oid ownerId , Acl * new_acl );
168+ Acl * new_acl );
169169static void recordExtensionInitPrivWorker (Oid objoid , Oid classoid , int objsubid ,
170- Oid ownerId , Acl * new_acl );
170+ Acl * new_acl );
171171
172172
173173/*
@@ -1802,7 +1802,7 @@ ExecGrant_Attribute(InternalGrant *istmt, Oid relOid, const char *relname,
18021802 CatalogTupleUpdate (attRelation , & newtuple -> t_self , newtuple );
18031803
18041804 /* Update initial privileges for extensions */
1805- recordExtensionInitPriv (relOid , RelationRelationId , attnum , ownerId ,
1805+ recordExtensionInitPriv (relOid , RelationRelationId , attnum ,
18061806 ACL_NUM (new_acl ) > 0 ? new_acl : NULL );
18071807
18081808 /* Update the shared dependency ACL info */
@@ -2062,8 +2062,7 @@ ExecGrant_Relation(InternalGrant *istmt)
20622062 CatalogTupleUpdate (relation , & newtuple -> t_self , newtuple );
20632063
20642064 /* Update initial privileges for extensions */
2065- recordExtensionInitPriv (relOid , RelationRelationId , 0 ,
2066- ownerId , new_acl );
2065+ recordExtensionInitPriv (relOid , RelationRelationId , 0 , new_acl );
20672066
20682067 /* Update the shared dependency ACL info */
20692068 updateAclDependencies (RelationRelationId , relOid , 0 ,
@@ -2264,7 +2263,7 @@ ExecGrant_common(InternalGrant *istmt, Oid classid, AclMode default_privs,
22642263 CatalogTupleUpdate (relation , & newtuple -> t_self , newtuple );
22652264
22662265 /* Update initial privileges for extensions */
2267- recordExtensionInitPriv (objectid , classid , 0 , ownerId , new_acl );
2266+ recordExtensionInitPriv (objectid , classid , 0 , new_acl );
22682267
22692268 /* Update the shared dependency ACL info */
22702269 updateAclDependencies (classid ,
@@ -2416,8 +2415,7 @@ ExecGrant_Largeobject(InternalGrant *istmt)
24162415 CatalogTupleUpdate (relation , & newtuple -> t_self , newtuple );
24172416
24182417 /* Update initial privileges for extensions */
2419- recordExtensionInitPriv (loid , LargeObjectRelationId , 0 ,
2420- ownerId , new_acl );
2418+ recordExtensionInitPriv (loid , LargeObjectRelationId , 0 , new_acl );
24212419
24222420 /* Update the shared dependency ACL info */
24232421 updateAclDependencies (LargeObjectRelationId ,
@@ -2589,7 +2587,7 @@ ExecGrant_Parameter(InternalGrant *istmt)
25892587
25902588 /* Update initial privileges for extensions */
25912589 recordExtensionInitPriv (parameterId , ParameterAclRelationId , 0 ,
2592- ownerId , new_acl );
2590+ new_acl );
25932591
25942592 /* Update the shared dependency ACL info */
25952593 updateAclDependencies (ParameterAclRelationId , parameterId , 0 ,
@@ -4477,7 +4475,6 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
44774475 }
44784476
44794477 recordExtensionInitPrivWorker (objoid , classoid , curr_att ,
4480- pg_class_tuple -> relowner ,
44814478 DatumGetAclP (attaclDatum ));
44824479
44834480 ReleaseSysCache (attTuple );
@@ -4490,7 +4487,6 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
44904487 /* Add the record, if any, for the top-level object */
44914488 if (!isNull )
44924489 recordExtensionInitPrivWorker (objoid , classoid , 0 ,
4493- pg_class_tuple -> relowner ,
44944490 DatumGetAclP (aclDatum ));
44954491
44964492 ReleaseSysCache (tuple );
@@ -4501,7 +4497,6 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
45014497 Datum aclDatum ;
45024498 bool isNull ;
45034499 HeapTuple tuple ;
4504- Form_pg_largeobject_metadata form_lo_meta ;
45054500 ScanKeyData entry [1 ];
45064501 SysScanDesc scan ;
45074502 Relation relation ;
@@ -4526,7 +4521,6 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
45264521 tuple = systable_getnext (scan );
45274522 if (!HeapTupleIsValid (tuple ))
45284523 elog (ERROR , "could not find tuple for large object %u" , objoid );
4529- form_lo_meta = (Form_pg_largeobject_metadata ) GETSTRUCT (tuple );
45304524
45314525 aclDatum = heap_getattr (tuple ,
45324526 Anum_pg_largeobject_metadata_lomacl ,
@@ -4535,7 +4529,6 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
45354529 /* Add the record, if any, for the top-level object */
45364530 if (!isNull )
45374531 recordExtensionInitPrivWorker (objoid , classoid , 0 ,
4538- form_lo_meta -> lomowner ,
45394532 DatumGetAclP (aclDatum ));
45404533
45414534 systable_endscan (scan );
@@ -4544,7 +4537,6 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
45444537 else if (get_object_attnum_acl (classoid ) != InvalidAttrNumber )
45454538 {
45464539 int cacheid ;
4547- Oid ownerId ;
45484540 Datum aclDatum ;
45494541 bool isNull ;
45504542 HeapTuple tuple ;
@@ -4555,17 +4547,14 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
45554547 elog (ERROR , "cache lookup failed for %s %u" ,
45564548 get_object_class_descr (classoid ), objoid );
45574549
4558- ownerId = DatumGetObjectId (SysCacheGetAttrNotNull (cacheid ,
4559- tuple ,
4560- get_object_attnum_owner (classoid )));
45614550 aclDatum = SysCacheGetAttr (cacheid , tuple ,
45624551 get_object_attnum_acl (classoid ),
45634552 & isNull );
45644553
45654554 /* Add the record, if any, for the top-level object */
45664555 if (!isNull )
45674556 recordExtensionInitPrivWorker (objoid , classoid , 0 ,
4568- ownerId , DatumGetAclP (aclDatum ));
4557+ DatumGetAclP (aclDatum ));
45694558
45704559 ReleaseSysCache (tuple );
45714560 }
@@ -4578,8 +4567,6 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
45784567void
45794568removeExtObjInitPriv (Oid objoid , Oid classoid )
45804569{
4581- Oid ownerId ;
4582-
45834570 /*
45844571 * If this is a relation then we need to see if there are any sub-objects
45854572 * (eg: columns) for it and, if so, be sure to call
@@ -4594,7 +4581,6 @@ removeExtObjInitPriv(Oid objoid, Oid classoid)
45944581 if (!HeapTupleIsValid (tuple ))
45954582 elog (ERROR , "cache lookup failed for relation %u" , objoid );
45964583 pg_class_tuple = (Form_pg_class ) GETSTRUCT (tuple );
4597- ownerId = pg_class_tuple -> relowner ;
45984584
45994585 /*
46004586 * Indexes don't have permissions, neither do the pg_class rows for
@@ -4631,44 +4617,17 @@ removeExtObjInitPriv(Oid objoid, Oid classoid)
46314617
46324618 /* when removing, remove all entries, even dropped columns */
46334619
4634- recordExtensionInitPrivWorker (objoid , classoid , curr_att ,
4635- ownerId , NULL );
4620+ recordExtensionInitPrivWorker (objoid , classoid , curr_att , NULL );
46364621
46374622 ReleaseSysCache (attTuple );
46384623 }
46394624 }
46404625
46414626 ReleaseSysCache (tuple );
46424627 }
4643- else
4644- {
4645- /* Must find out the owner's OID the hard way */
4646- AttrNumber ownerattnum ;
4647- int cacheid ;
4648- HeapTuple tuple ;
4649-
4650- /*
4651- * If the object is of a kind that has no owner, it should not have
4652- * any pg_init_privs entry either.
4653- */
4654- ownerattnum = get_object_attnum_owner (classoid );
4655- if (ownerattnum == InvalidAttrNumber )
4656- return ;
4657- cacheid = get_object_catcache_oid (classoid );
4658- tuple = SearchSysCache1 (cacheid , ObjectIdGetDatum (objoid ));
4659- if (!HeapTupleIsValid (tuple ))
4660- elog (ERROR , "cache lookup failed for %s %u" ,
4661- get_object_class_descr (classoid ), objoid );
4662-
4663- ownerId = DatumGetObjectId (SysCacheGetAttrNotNull (cacheid ,
4664- tuple ,
4665- ownerattnum ));
4666-
4667- ReleaseSysCache (tuple );
4668- }
46694628
46704629 /* Remove the record, if any, for the top-level object */
4671- recordExtensionInitPrivWorker (objoid , classoid , 0 , ownerId , NULL );
4630+ recordExtensionInitPrivWorker (objoid , classoid , 0 , NULL );
46724631}
46734632
46744633/*
@@ -4680,8 +4639,7 @@ removeExtObjInitPriv(Oid objoid, Oid classoid)
46804639 * Pass in the object OID, the OID of the class (the OID of the table which
46814640 * the object is defined in) and the 'sub' id of the object (objsubid), if
46824641 * any. If there is no 'sub' id (they are currently only used for columns of
4683- * tables) then pass in '0'. Also pass the OID of the object's owner.
4684- * Finally, pass in the complete ACL to store.
4642+ * tables) then pass in '0'. Finally, pass in the complete ACL to store.
46854643 *
46864644 * If an ACL already exists for this object/sub-object then we will replace
46874645 * it with what is passed in.
@@ -4690,8 +4648,7 @@ removeExtObjInitPriv(Oid objoid, Oid classoid)
46904648 * removed, if one is found.
46914649 */
46924650static void
4693- recordExtensionInitPriv (Oid objoid , Oid classoid , int objsubid ,
4694- Oid ownerId , Acl * new_acl )
4651+ recordExtensionInitPriv (Oid objoid , Oid classoid , int objsubid , Acl * new_acl )
46954652{
46964653 /*
46974654 * Generally, we only record the initial privileges when an extension is
@@ -4704,7 +4661,7 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid,
47044661 if (!creating_extension && !binary_upgrade_record_init_privs )
47054662 return ;
47064663
4707- recordExtensionInitPrivWorker (objoid , classoid , objsubid , ownerId , new_acl );
4664+ recordExtensionInitPrivWorker (objoid , classoid , objsubid , new_acl );
47084665}
47094666
47104667/*
@@ -4721,7 +4678,7 @@ recordExtensionInitPriv(Oid objoid, Oid classoid, int objsubid,
47214678 */
47224679static void
47234680recordExtensionInitPrivWorker (Oid objoid , Oid classoid , int objsubid ,
4724- Oid ownerId , Acl * new_acl )
4681+ Acl * new_acl )
47254682{
47264683 Relation relation ;
47274684 ScanKeyData key [3 ];
0 commit comments