@@ -827,22 +827,16 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
827
827
}
828
828
829
829
/*
830
- * ALTER TEXT SEARCH DICTIONARY OWNER
830
+ * Internal routine for changing the owner of a text search dictionary
831
831
*/
832
- void
833
- AlterTSDictionaryOwner ( List * name , Oid newOwnerId )
832
+ static void
833
+ AlterTSDictionaryOwner_internal ( Relation rel , Oid dictId , Oid newOwnerId )
834
834
{
835
835
HeapTuple tup ;
836
- Relation rel ;
837
- Oid dictId ;
838
836
Oid namespaceOid ;
839
837
AclResult aclresult ;
840
838
Form_pg_ts_dict form ;
841
839
842
- rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
843
-
844
- dictId = TSDictionaryGetDictid (name , false);
845
-
846
840
tup = SearchSysCacheCopy1 (TSDICTOID , ObjectIdGetDatum (dictId ));
847
841
848
842
if (!HeapTupleIsValid (tup )) /* should not happen */
@@ -860,7 +854,7 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
860
854
/* must be owner */
861
855
if (!pg_ts_dict_ownercheck (dictId , GetUserId ()))
862
856
aclcheck_error (ACLCHECK_NOT_OWNER , ACL_KIND_TSDICTIONARY ,
863
- NameListToString ( name ));
857
+ NameStr ( form -> dictname ));
864
858
865
859
/* Must be able to become new owner */
866
860
check_is_member_of_role (GetUserId (), newOwnerId );
@@ -882,10 +876,41 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
882
876
newOwnerId );
883
877
}
884
878
885
- heap_close (rel , NoLock );
886
879
heap_freetuple (tup );
887
880
}
888
881
882
+ /*
883
+ * ALTER TEXT SEARCH DICTIONARY OWNER
884
+ */
885
+ void
886
+ AlterTSDictionaryOwner (List * name , Oid newOwnerId )
887
+ {
888
+ Relation rel ;
889
+ Oid dictId ;
890
+
891
+ rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
892
+ dictId = TSDictionaryGetDictid (name , false);
893
+
894
+ AlterTSDictionaryOwner_internal (rel , dictId , newOwnerId );
895
+
896
+ heap_close (rel , NoLock );
897
+ }
898
+
899
+ /*
900
+ * Change text search dictionary owner, by OID
901
+ */
902
+ void
903
+ AlterTSDictionaryOwner_oid (Oid dictId , Oid newOwnerId )
904
+ {
905
+ Relation rel ;
906
+
907
+ rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
908
+
909
+ AlterTSDictionaryOwner_internal (rel , dictId , newOwnerId );
910
+
911
+ heap_close (rel , NoLock );
912
+ }
913
+
889
914
/* ---------------------- TS Template commands -----------------------*/
890
915
891
916
/*
@@ -1612,22 +1637,16 @@ RemoveTSConfigurationById(Oid cfgId)
1612
1637
}
1613
1638
1614
1639
/*
1615
- * ALTER TEXT SEARCH CONFIGURATION OWNER
1640
+ * Internal routine for changing the owner of a text search configuration
1616
1641
*/
1617
- void
1618
- AlterTSConfigurationOwner ( List * name , Oid newOwnerId )
1642
+ static void
1643
+ AlterTSConfigurationOwner_internal ( Relation rel , Oid cfgId , Oid newOwnerId )
1619
1644
{
1620
1645
HeapTuple tup ;
1621
- Relation rel ;
1622
- Oid cfgId ;
1623
1646
AclResult aclresult ;
1624
1647
Oid namespaceOid ;
1625
1648
Form_pg_ts_config form ;
1626
1649
1627
- rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1628
-
1629
- cfgId = TSConfigGetCfgid (name , false);
1630
-
1631
1650
tup = SearchSysCacheCopy1 (TSCONFIGOID , ObjectIdGetDatum (cfgId ));
1632
1651
1633
1652
if (!HeapTupleIsValid (tup )) /* should not happen */
@@ -1645,7 +1664,7 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
1645
1664
/* must be owner */
1646
1665
if (!pg_ts_config_ownercheck (cfgId , GetUserId ()))
1647
1666
aclcheck_error (ACLCHECK_NOT_OWNER , ACL_KIND_TSCONFIGURATION ,
1648
- NameListToString ( name ));
1667
+ NameStr ( form -> cfgname ));
1649
1668
1650
1669
/* Must be able to become new owner */
1651
1670
check_is_member_of_role (GetUserId (), newOwnerId );
@@ -1667,10 +1686,39 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
1667
1686
newOwnerId );
1668
1687
}
1669
1688
1670
- heap_close (rel , NoLock );
1671
1689
heap_freetuple (tup );
1672
1690
}
1673
1691
1692
+ /*
1693
+ * ALTER TEXT SEARCH CONFIGURATION OWNER
1694
+ */
1695
+ void
1696
+ AlterTSConfigurationOwner (List * name , Oid newOwnerId )
1697
+ {
1698
+ Relation rel ;
1699
+ Oid cfgId ;
1700
+
1701
+ rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1702
+ cfgId = TSConfigGetCfgid (name , false);
1703
+
1704
+ AlterTSConfigurationOwner_internal (rel , cfgId , newOwnerId );
1705
+
1706
+ heap_close (rel , NoLock );
1707
+ }
1708
+
1709
+ void
1710
+ AlterTSConfigurationOwner_oid (Oid cfgId , Oid newOwnerId )
1711
+ {
1712
+ Relation rel ;
1713
+
1714
+ rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1715
+
1716
+ AlterTSConfigurationOwner_internal (rel , cfgId , newOwnerId );
1717
+
1718
+ heap_close (rel , NoLock );
1719
+ }
1720
+
1721
+
1674
1722
/*
1675
1723
* ALTER TEXT SEARCH CONFIGURATION - main entry point
1676
1724
*/
0 commit comments