Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4b76778

Browse files
committed
Fix REASSIGN OWNED for text search objects
Trying to reassign objects owned by a user that had text searchdictionaries or configurations used to fail with:ERROR: unexpected classid 3600orERROR: unexpected classid 3602Fix by adding cases for those object types in a switch in pg_shdepend.c.Both REASSIGN OWNED and text search objects go back all the way to 8.1,so backpatch to all supported branches. In 9.3 the alter-owner code wasmade generic, so the required change in recent branches is prettysimple; however, for 9.2 and older ones we need some additionalreshuffling to enable specifying objects by OID rather than name.Text search templates and parsers are not owned objects, so there's nochange required for them.Per bug #9749 reported by Michal Novotný
1 parentbae0b5c commit4b76778

File tree

3 files changed

+82
-22
lines changed

3 files changed

+82
-22
lines changed

‎src/backend/catalog/pg_shdepend.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include"catalog/pg_proc.h"
3232
#include"catalog/pg_shdepend.h"
3333
#include"catalog/pg_tablespace.h"
34+
#include"catalog/pg_ts_config.h"
35+
#include"catalog/pg_ts_dict.h"
3436
#include"catalog/pg_type.h"
3537
#include"commands/conversioncmds.h"
3638
#include"commands/defrem.h"
@@ -1381,6 +1383,14 @@ shdepReassignOwned(List *roleids, Oid newrole)
13811383
AlterOpFamilyOwner_oid(sdepForm->objid,newrole);
13821384
break;
13831385

1386+
caseTSConfigRelationId:
1387+
AlterTSConfigurationOwner_oid(sdepForm->objid,newrole);
1388+
break;
1389+
1390+
caseTSDictionaryRelationId:
1391+
AlterTSDictionaryOwner_oid(sdepForm->objid,newrole);
1392+
break;
1393+
13841394
default:
13851395
elog(ERROR,"unexpected classid %d",sdepForm->classid);
13861396
break;

‎src/backend/commands/tsearchcmds.c‎

Lines changed: 70 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -843,22 +843,16 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
843843
}
844844

845845
/*
846-
*ALTER TEXT SEARCH DICTIONARY OWNER
846+
*Internal routine for changing the owner of a text search dictionary
847847
*/
848-
void
849-
AlterTSDictionaryOwner(List*name,OidnewOwnerId)
848+
staticvoid
849+
AlterTSDictionaryOwner_internal(Relationrel,OiddictId,OidnewOwnerId)
850850
{
851851
HeapTupletup;
852-
Relationrel;
853-
OiddictId;
854852
OidnamespaceOid;
855853
AclResultaclresult;
856854
Form_pg_ts_dictform;
857855

858-
rel=heap_open(TSDictionaryRelationId,RowExclusiveLock);
859-
860-
dictId=TSDictionaryGetDictid(name, false);
861-
862856
tup=SearchSysCacheCopy(TSDICTOID,
863857
ObjectIdGetDatum(dictId),
864858
0,0,0);
@@ -878,7 +872,7 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
878872
/* must be owner */
879873
if (!pg_ts_dict_ownercheck(dictId,GetUserId()))
880874
aclcheck_error(ACLCHECK_NOT_OWNER,ACL_KIND_TSDICTIONARY,
881-
NameListToString(name));
875+
NameStr(form->dictname));
882876

883877
/* Must be able to become new owner */
884878
check_is_member_of_role(GetUserId(),newOwnerId);
@@ -900,10 +894,41 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
900894
newOwnerId);
901895
}
902896

903-
heap_close(rel,NoLock);
904897
heap_freetuple(tup);
905898
}
906899

900+
/*
901+
* ALTER TEXT SEARCH DICTIONARY OWNER
902+
*/
903+
void
904+
AlterTSDictionaryOwner(List*name,OidnewOwnerId)
905+
{
906+
Relationrel;
907+
OiddictId;
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(OiddictId,OidnewOwnerId)
922+
{
923+
Relationrel;
924+
925+
rel=heap_open(TSDictionaryRelationId,RowExclusiveLock);
926+
927+
AlterTSDictionaryOwner_internal(rel,dictId,newOwnerId);
928+
929+
heap_close(rel,NoLock);
930+
}
931+
907932
/* ---------------------- TS Template commands -----------------------*/
908933

909934
/*
@@ -1644,22 +1669,16 @@ RemoveTSConfigurationById(Oid cfgId)
16441669
}
16451670

16461671
/*
1647-
*ALTER TEXT SEARCH CONFIGURATION OWNER
1672+
*Internal routine for changing the owner of a text search configuration
16481673
*/
1649-
void
1650-
AlterTSConfigurationOwner(List*name,OidnewOwnerId)
1674+
staticvoid
1675+
AlterTSConfigurationOwner_internal(Relationrel,OidcfgId,OidnewOwnerId)
16511676
{
16521677
HeapTupletup;
1653-
Relationrel;
1654-
OidcfgId;
16551678
AclResultaclresult;
16561679
OidnamespaceOid;
16571680
Form_pg_ts_configform;
16581681

1659-
rel=heap_open(TSConfigRelationId,RowExclusiveLock);
1660-
1661-
cfgId=TSConfigGetCfgid(name, false);
1662-
16631682
tup=SearchSysCacheCopy(TSCONFIGOID,
16641683
ObjectIdGetDatum(cfgId),
16651684
0,0,0);
@@ -1679,7 +1698,7 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
16791698
/* must be owner */
16801699
if (!pg_ts_config_ownercheck(cfgId,GetUserId()))
16811700
aclcheck_error(ACLCHECK_NOT_OWNER,ACL_KIND_TSCONFIGURATION,
1682-
NameListToString(name));
1701+
NameStr(form->cfgname));
16831702

16841703
/* Must be able to become new owner */
16851704
check_is_member_of_role(GetUserId(),newOwnerId);
@@ -1701,10 +1720,39 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
17011720
newOwnerId);
17021721
}
17031722

1704-
heap_close(rel,NoLock);
17051723
heap_freetuple(tup);
17061724
}
17071725

1726+
/*
1727+
* ALTER TEXT SEARCH CONFIGURATION OWNER
1728+
*/
1729+
void
1730+
AlterTSConfigurationOwner(List*name,OidnewOwnerId)
1731+
{
1732+
Relationrel;
1733+
OidcfgId;
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(OidcfgId,OidnewOwnerId)
1745+
{
1746+
Relationrel;
1747+
1748+
rel=heap_open(TSConfigRelationId,RowExclusiveLock);
1749+
1750+
AlterTSConfigurationOwner_internal(rel,cfgId,newOwnerId);
1751+
1752+
heap_close(rel,NoLock);
1753+
}
1754+
1755+
17081756
/*
17091757
* ALTER TEXT SEARCH CONFIGURATION - main entry point
17101758
*/

‎src/include/commands/defrem.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ extern void RemoveTSDictionaries(DropStmt *drop);
104104
externvoidRemoveTSDictionaryById(OiddictId);
105105
externvoidAlterTSDictionary(AlterTSDictionaryStmt*stmt);
106106
externvoidAlterTSDictionaryOwner(List*name,OidnewOwnerId);
107+
externvoidAlterTSDictionaryOwner_oid(OiddictId,OidnewOwnerId);
107108

108109
externvoidDefineTSTemplate(List*names,List*parameters);
109110
externvoidRenameTSTemplate(List*oldname,constchar*newname);
@@ -116,6 +117,7 @@ extern void RemoveTSConfigurations(DropStmt *stmt);
116117
externvoidRemoveTSConfigurationById(OidcfgId);
117118
externvoidAlterTSConfiguration(AlterTSConfigurationStmt*stmt);
118119
externvoidAlterTSConfigurationOwner(List*name,OidnewOwnerId);
120+
externvoidAlterTSConfigurationOwner_oid(OidcfgId,OidnewOwnerId);
119121

120122
externtext*serialize_deflist(List*deflist);
121123
externList*deserialize_deflist(Datumtxt);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp