Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3552116

Browse files
committed
Fix search for mchar/mvarchar tuypes via search_path to make these types dumpable even with cleaned up searchpath
1 parent 178a3d1 commit 3552116

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

src/backend/optimizer/path/indxpath.c

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3258,6 +3258,38 @@ static Oid mmGTOid = InvalidOid;
32583258
static Oid mcharOid = InvalidOid;
32593259
static Oid mvarcharOid = InvalidOid;
32603260

3261+
static Oid
3262+
findTypeOid(char *typname)
3263+
{
3264+
CatCList *catlist;
3265+
HeapTuple tup;
3266+
int n_members;
3267+
Oid typoid;
3268+
3269+
catlist = SearchSysCacheList(TYPENAMENSP, 1,
3270+
CStringGetDatum(typname),
3271+
0, 0, 0);
3272+
3273+
n_members = catlist->n_members;
3274+
3275+
if (n_members != 1)
3276+
{
3277+
ReleaseSysCacheList(catlist);
3278+
if (n_members > 1)
3279+
elog(ERROR,"There are %d candidates for '%s' type",
3280+
n_members, typname);
3281+
return InvalidOid;
3282+
}
3283+
3284+
tup = &catlist->members[0]->tuple;
3285+
3286+
typoid = HeapTupleGetOid(tup);
3287+
3288+
ReleaseSysCacheList(catlist);
3289+
3290+
return typoid;
3291+
}
3292+
32613293
static bool
32623294
fillMCharOIDS() {
32633295
CatCList *catlist;
@@ -3280,27 +3312,13 @@ fillMCharOIDS() {
32803312
tup = &catlist->members[0]->tuple;
32813313

32823314
if ( HeapTupleGetOid(tup) != mmPFPOid ) {
3283-
TypeName *typename;
3284-
Type typtup;
32853315
char *quals_funcname = "mchar_greaterstring";
32863316
Oid tmp_mmPFPOid = HeapTupleGetOid(tup);
32873317

32883318
ReleaseSysCacheList(catlist);
32893319

3290-
typename = makeTypeName("mchar");
3291-
typtup = LookupTypeName(NULL, typename, NULL, true);
3292-
if ( typtup ) {
3293-
mcharOid = typeTypeId(typtup);
3294-
ReleaseSysCache(typtup);
3295-
}
3296-
3297-
typename = makeTypeName("mvarchar");
3298-
typtup = LookupTypeName(NULL, typename, NULL, true);
3299-
if ( typtup ) {
3300-
mvarcharOid = typeTypeId(typtup);
3301-
ReleaseSysCache(typtup);
3302-
}
3303-
3320+
mcharOid = findTypeOid("mchar");
3321+
mvarcharOid = findTypeOid("mvarchar");
33043322

33053323
if ( mcharOid == InvalidOid || mvarcharOid == InvalidOid ) {
33063324
elog(LOG,"Can't find mchar/mvarvarchar types: mchar=%d mvarchar=%d",

0 commit comments

Comments
 (0)