@@ -843,22 +843,16 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
843
843
}
844
844
845
845
/*
846
- * ALTER TEXT SEARCH DICTIONARY OWNER
846
+ * Internal routine for changing the owner of a text search dictionary
847
847
*/
848
- void
849
- AlterTSDictionaryOwner ( List * name , Oid newOwnerId )
848
+ static void
849
+ AlterTSDictionaryOwner_internal ( Relation rel , Oid dictId , Oid newOwnerId )
850
850
{
851
851
HeapTuple tup ;
852
- Relation rel ;
853
- Oid dictId ;
854
852
Oid namespaceOid ;
855
853
AclResult aclresult ;
856
854
Form_pg_ts_dict form ;
857
855
858
- rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
859
-
860
- dictId = TSDictionaryGetDictid (name , false);
861
-
862
856
tup = SearchSysCacheCopy (TSDICTOID ,
863
857
ObjectIdGetDatum (dictId ),
864
858
0 , 0 , 0 );
@@ -878,7 +872,7 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
878
872
/* must be owner */
879
873
if (!pg_ts_dict_ownercheck (dictId , GetUserId ()))
880
874
aclcheck_error (ACLCHECK_NOT_OWNER , ACL_KIND_TSDICTIONARY ,
881
- NameListToString ( name ));
875
+ NameStr ( form -> dictname ));
882
876
883
877
/* Must be able to become new owner */
884
878
check_is_member_of_role (GetUserId (), newOwnerId );
@@ -900,10 +894,41 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
900
894
newOwnerId );
901
895
}
902
896
903
- heap_close (rel , NoLock );
904
897
heap_freetuple (tup );
905
898
}
906
899
900
+ /*
901
+ * ALTER TEXT SEARCH DICTIONARY OWNER
902
+ */
903
+ void
904
+ AlterTSDictionaryOwner (List * name , Oid newOwnerId )
905
+ {
906
+ Relation rel ;
907
+ Oid dictId ;
908
+
909
+ rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
910
+ dictId = TSDictionaryGetDictid (name , false);
911
+
912
+ AlterTSDictionaryOwner_internal (rel , dictId , newOwnerId );
913
+
914
+ heap_close (rel , NoLock );
915
+ }
916
+
917
+ /*
918
+ * Change text search dictionary owner, by OID
919
+ */
920
+ void
921
+ AlterTSDictionaryOwner_oid (Oid dictId , Oid newOwnerId )
922
+ {
923
+ Relation rel ;
924
+
925
+ rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
926
+
927
+ AlterTSDictionaryOwner_internal (rel , dictId , newOwnerId );
928
+
929
+ heap_close (rel , NoLock );
930
+ }
931
+
907
932
/* ---------------------- TS Template commands -----------------------*/
908
933
909
934
/*
@@ -1644,22 +1669,16 @@ RemoveTSConfigurationById(Oid cfgId)
1644
1669
}
1645
1670
1646
1671
/*
1647
- * ALTER TEXT SEARCH CONFIGURATION OWNER
1672
+ * Internal routine for changing the owner of a text search configuration
1648
1673
*/
1649
- void
1650
- AlterTSConfigurationOwner ( List * name , Oid newOwnerId )
1674
+ static void
1675
+ AlterTSConfigurationOwner_internal ( Relation rel , Oid cfgId , Oid newOwnerId )
1651
1676
{
1652
1677
HeapTuple tup ;
1653
- Relation rel ;
1654
- Oid cfgId ;
1655
1678
AclResult aclresult ;
1656
1679
Oid namespaceOid ;
1657
1680
Form_pg_ts_config form ;
1658
1681
1659
- rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1660
-
1661
- cfgId = TSConfigGetCfgid (name , false);
1662
-
1663
1682
tup = SearchSysCacheCopy (TSCONFIGOID ,
1664
1683
ObjectIdGetDatum (cfgId ),
1665
1684
0 , 0 , 0 );
@@ -1679,7 +1698,7 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
1679
1698
/* must be owner */
1680
1699
if (!pg_ts_config_ownercheck (cfgId , GetUserId ()))
1681
1700
aclcheck_error (ACLCHECK_NOT_OWNER , ACL_KIND_TSCONFIGURATION ,
1682
- NameListToString ( name ));
1701
+ NameStr ( form -> cfgname ));
1683
1702
1684
1703
/* Must be able to become new owner */
1685
1704
check_is_member_of_role (GetUserId (), newOwnerId );
@@ -1701,10 +1720,39 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
1701
1720
newOwnerId );
1702
1721
}
1703
1722
1704
- heap_close (rel , NoLock );
1705
1723
heap_freetuple (tup );
1706
1724
}
1707
1725
1726
+ /*
1727
+ * ALTER TEXT SEARCH CONFIGURATION OWNER
1728
+ */
1729
+ void
1730
+ AlterTSConfigurationOwner (List * name , Oid newOwnerId )
1731
+ {
1732
+ Relation rel ;
1733
+ Oid cfgId ;
1734
+
1735
+ rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1736
+ cfgId = TSConfigGetCfgid (name , false);
1737
+
1738
+ AlterTSConfigurationOwner_internal (rel , cfgId , newOwnerId );
1739
+
1740
+ heap_close (rel , NoLock );
1741
+ }
1742
+
1743
+ void
1744
+ AlterTSConfigurationOwner_oid (Oid cfgId , Oid newOwnerId )
1745
+ {
1746
+ Relation rel ;
1747
+
1748
+ rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1749
+
1750
+ AlterTSConfigurationOwner_internal (rel , cfgId , newOwnerId );
1751
+
1752
+ heap_close (rel , NoLock );
1753
+ }
1754
+
1755
+
1708
1756
/*
1709
1757
* ALTER TEXT SEARCH CONFIGURATION - main entry point
1710
1758
*/
<
AC01
/tr>
0 commit comments