@@ -942,22 +942,16 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
942
942
}
943
943
944
944
/*
945
- * ALTER TEXT SEARCH DICTIONARY OWNER
945
+ * Internal routine for changing the owner of a text search dictionary
946
946
*/
947
- void
948
- AlterTSDictionaryOwner ( List * name , Oid newOwnerId )
947
+ static void
948
+ AlterTSDictionaryOwner_internal ( Relation rel , Oid dictId , Oid newOwnerId )
949
949
{
950
950
HeapTuple tup ;
951
- Relation rel ;
952
- Oid dictId ;
953
951
Oid namespaceOid ;
954
952
AclResult aclresult ;
955
953
Form_pg_ts_dict form ;
956
954
957
- rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
958
-
959
- dictId = get_ts_dict_oid (name , false);
960
-
961
955
tup = SearchSysCacheCopy1 (TSDICTOID , ObjectIdGetDatum (dictId ));
962
956
963
957
if (!HeapTupleIsValid (tup )) /* should not happen */
@@ -975,7 +969,7 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
975
969
/* must be owner */
976
970
if (!pg_ts_dict_ownercheck (dictId , GetUserId ()))
977
971
aclcheck_error (ACLCHECK_NOT_OWNER , ACL_KIND_TSDICTIONARY ,
978
- NameListToString ( name ));
972
+ NameStr ( form -> dictname ));
979
973
980
974
/* Must be able to become new owner */
981
975
check_is_member_of_role (GetUserId (), newOwnerId );
@@ -997,10 +991,41 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
997
991
newOwnerId );
998
992
}
999
993
1000
- heap_close (rel , NoLock );
1001
994
heap_freetuple (tup );
1002
995
}
1003
996
997
+ /*
998
+ * ALTER TEXT SEARCH DICTIONARY OWNER
999
+ */
1000
+ void
1001
+ AlterTSDictionaryOwner (List * name , Oid newOwnerId )
1002
+ {
1003
+ Relation rel ;
1004
+ Oid dictId ;
1005
+
1006
+ rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
1007
+ dictId = get_ts_dict_oid (name , false);
1008
+
1009
+ AlterTSDictionaryOwner_internal (rel , dictId , newOwnerId );
1010
+
1011
+ heap_close (rel , NoLock );
1012
+ }
1013
+
1014
+ /*
1015
+ * Change text search dictionary owner, by OID
1016
+ */
1017
+ void
1018
+ AlterTSDictionaryOwner_oid (Oid dictId , Oid newOwnerId )
1019
+ {
1020
+ Relation rel ;
1021
+
1022
+ rel = heap_open (TSDictionaryRelationId , RowExclusiveLock );
1023
+
1024
+ AlterTSDictionaryOwner_internal (rel , dictId , newOwnerId );
1025
+
1026
+ heap_close (rel , NoLock );
1027
+ }
1028
+
1004
1029
/* ---------------------- TS Template commands -----------------------*/
1005
1030
1006
1031
/*
@@ -1833,22 +1858,16 @@ RemoveTSConfigurationById(Oid cfgId)
1833
1858
}
1834
1859
1835
1860
/*
1836
- * ALTER TEXT SEARCH CONFIGURATION OWNER
1861
+ * Internal routine for changing the owner of a text search configuration
1837
1862
*/
1838
- void
1839
- AlterTSConfigurationOwner ( List * name , Oid newOwnerId )
1863
+ static void
1864
+ AlterTSConfigurationOwner_internal ( Relation rel , Oid cfgId , Oid newOwnerId )
1840
1865
{
1841
1866
HeapTuple tup ;
1842
- Relation rel ;
1843
- Oid cfgId ;
1844
1867
AclResult aclresult ;
1845
1868
Oid namespaceOid ;
1846
1869
Form_pg_ts_config form ;
1847
1870
1848
- rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1849
-
1850
- cfgId = get_ts_config_oid (name , false);
1851
-
1852
1871
tup = SearchSysCacheCopy1 (TSCONFIGOID , ObjectIdGetDatum (cfgId ));
1853
1872
1854
1873
if (!HeapTupleIsValid (tup )) /* should not happen */
@@ -1866,7 +1885,7 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
1866
1885
/* must be owner */
1867
1886
if (!pg_ts_config_ownercheck (cfgId , GetUserId ()))
1868
1887
aclcheck_error (ACLCHECK_NOT_OWNER , ACL_KIND_TSCONFIGURATION ,
1869
- NameListToString ( name ));
1888
+ NameStr ( form -> cfgname ));
1870
1889
1871
1890
/* Must be able to become new owner */
1872
1891
check_is_member_of_role (GetUserId (), newOwnerId );
@@ -1888,10 +1907,39 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
1888
1907
newOwnerId );
1889
1908
}
1890
1909
1891
- heap_close (rel , NoLock );
1892
1910
heap_freetuple (tup );
1893
1911
}
1894
1912
1913
+ /*
1914
+ * ALTER TEXT SEARCH CONFIGURATION OWNER
1915
+ */
1916
+ void
1917
+ AlterTSConfigurationOwner (List * name , Oid newOwnerId )
1918
+ {
1919
+ Relation rel ;
1920
+ Oid cfgId ;
1921
+
1922
+ rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1923
+ cfgId = get_ts_config_oid (name , false);
1924
+
1925
+ AlterTSConfigurationOwner_internal (rel , cfgId , newOwnerId );
1926
+
1927
+ heap_close (rel , NoLock );
1928
+ }
1929
+
1930
+ void
1931
+ AlterTSConfigurationOwner_oid (Oid cfgId , Oid newOwnerId )
1932
+ {
1933
+ Relation rel ;
1934
+
1935
+ rel = heap_open (TSConfigRelationId , RowExclusiveLock );
1936
+
1937
+ AlterTSConfigurationOwner_internal (rel , cfgId , newOwnerId );
1938
+
1939
+ heap_close (rel , NoLock );
1940
+ }
1941
+
1942
+
1895
1943
/*
1896
1944
* ALTER TEXT SEARCH CONFIGURATION - main entry point
1897
1945
*/
0 commit comments