@@ -810,22 +810,16 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
810
810
}
811
811
812
812
/*
813
- * ALTER TEXT SEARCH DICTIONARY OWNER
813
+ * Internal routine for changing the owner of a text search dictionary
814
814
*/
815
- void
816
- AlterTSDictionaryOwner ( List * name , Oid newOwnerId )
815
+ static void
816
+ AlterTSDictionaryOwner_internal ( Relation rel , Oid dictId , Oid newOwnerId )
817
817
{
818
818
HeapTuple tup ;
819
- Relation rel ;
820
- Oid dictId ;
821
819
Oid namespaceOid ;
822
820
AclResult aclresult ;
823
821
Form_pg_ts_dict form ;
824
822
825
- rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
826
-
827
- dictId = get_ts_dict_oid (name , false);
828
-
829
823
tup = SearchSysCacheCopy1 (TSDICTOID , ObjectIdGetDatum (dictId ));
830
824
831
825
if (!HeapTupleIsValid (tup )) /* should not happen */
@@ -843,7 +837,7 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
843
837
/* must be owner */
844
838
if (!pg_ts_dict_ownercheck (dictId , GetUserId ()))
845
839
aclcheck_error (ACLCHECK_NOT_OWNER , ACL_KIND_TSDICTIONARY ,
846
- NameListToString ( name ));
840
+ NameStr ( form -> dictname ));
847
841
848
842
/* Must be able to become new owner */
849
843
check_is_member_of_role (GetUserId (), newOwnerId );
@@ -865,10 +859,41 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
865
859
newOwnerId );
866
860
}
867
861
868
- heap_close (rel , NoLock );
869
862
heap_freetuple (tup );
870
863
}
871
864
865
+ /*
866
+ * ALTER TEXT SEARCH DICTIONARY OWNER
867
+ */
868
+ void
869
+ AlterTSDictionaryOwner (List * name , Oid newOwnerId )
870
+ {
871
+ Relation rel ;
872
+ Oid dictId ;
873
+
874
+ rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
875
+ dictId = get_ts_dict_oid (name , false);
876
+
877
+ AlterTSDictionaryOwner_internal (rel , dictId , newOwnerId );
878
+
879
+ heap_close (rel , NoLock );
880
+ }
881
+
882
+ /*
883
+ * Change text search dictionary owner, by OID
884
+ */
885
+ void
886
+ AlterTSDictionaryOwner_oid (Oid dictId , Oid newOwnerId )
887
+ {
888
+ Relation rel ;
889
+
890
+ rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
891
+
892
+ AlterTSDictionaryOwner_internal (rel , dictId , newOwnerId );
893
+
894
+ heap_close (rel , NoLock );
895
+ }
896
+
872
897
/* ---------------------- TS Template commands -----------------------*/
873
898
874
899
/*
@@ -1578,22 +1603,16 @@ RemoveTSConfigurationById(Oid cfgId)
1578
1603
}
1579
1604
1580
1605
/*
1581
- * ALTER TEXT SEARCH CONFIGURATION OWNER
1606
+ * Internal routine for changing the owner of a text search configuration
1582
1607
*/
1583
- void
1584
- AlterTSConfigurationOwner ( List * name , Oid newOwnerId )
1608
+ static void
1609
+ AlterTSConfigurationOwner_internal ( Relation rel , Oid cfgId , Oid newOwnerId )
1585
1610
{
1586
1611
HeapTuple tup ;
1587
- Relation rel ;
1588
- Oid cfgId ;
1589
1612
AclResult aclresult ;
1590
1613
Oid namespaceOid ;
1591
1614
Form_pg_ts_config form ;
1592
1615
1593
- rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1594
-
1595
- cfgId = get_ts_config_oid (name , false);
1596
-
1597
1616
tup = SearchSysCacheCopy1 (TSCONFIGOID , ObjectIdGetDatum (cfgId ));
1598
1617
1599
1618
if (!HeapTupleIsValid (tup )) /* should not happen */
@@ -1611,7 +1630,7 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
1611
1630
/* must be owner */
1612
1631
if (!pg_ts_config_ownercheck (cfgId , GetUserId ()))
1613
1632
aclcheck_error (ACLCHECK_NOT_OWNER , ACL_KIND_TSCONFIGURATION ,
1614
- NameListToString ( name ));
1633
+ NameStr ( form -> cfgname ));
1615
1634
1616
1635
/* Must be able to become new owner */
1617
1636
check_is_member_of_role (GetUserId (), newOwnerId );
@@ -1633,10 +1652,39 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
1633
1652
newOwnerId );
1634
1653
}
1635
1654
1636
- heap_close (rel , NoLock );
1637
1655
heap_freetuple (tup );
1638
1656
}
1639
1657
1658
+ /*
1659
+ * ALTER TEXT SEARCH CONFIGURATION OWNER
1660
+ */
1661
+ void
1662
+ AlterTSConfigurationOwner (List * name , Oid newOwnerId )
1663
+ {
1664
+ Relation rel ;
1665
+ Oid cfgId ;
1666
+
1667
+ rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1668
+ cfgId = get_ts_config_oid (name , false);
1669
+
1670
+ AlterTSConfigurationOwner_internal (rel , cfgId , newOwnerId );
1671
+
1672
+ heap_close (rel , NoLock );
1673
+ }
1674
+
1675
+ void
1676
+ AlterTSConfigurationOwner_oid (Oid cfgId , Oid newOwnerId )
1677
+ {
1678
+ Relation rel ;
1679
+
1680
+ rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1681
+
1682
+ AlterTSConfigurationOwner_internal (rel , cfgId , newOwnerId );
1683
+
1684
+ heap_close (rel , NoLock );
1685
+ }
1686
+
1687
+
1640
1688
/*
1641
1689
* ALTER TEXT SEARCH CONFIGURATION - main entry point
1642
1690
*/
0 commit comments