From 996659f2556843490827eb5027b53bac4b10783d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 20 Jun 2000 01:41:22 +0000 Subject: Fix handling of type tuple associated with a temp relation. We have to apply the tempname->realname mapping to type name lookup as well as relation name lookup, else the type tuple will not be found when wanted. This fixes bugs like this one: create temp table foo (f1 int); select foo.f2 from foo; ERROR: Unable to locate type name 'foo' in catalog --- src/backend/utils/cache/syscache.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/backend/utils/cache/syscache.c') diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index ba9452b80e4..e8f602c2ec2 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.54 2000/06/17 04:56:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.55 2000/06/20 01:41:22 tgl Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -482,14 +482,20 @@ SearchSysCacheTuple(int cacheId,/* cache selection code */ cacheId); } - /* temp table name remapping */ - if (cacheId == RELNAME) + /* + * If someone tries to look up a relname, translate temp relation + * names to real names. Less obviously, apply the same translation + * to type names, so that the type tuple of a temp table will be found + * when sought. This is a kluge ... temp table substitution should be + * happening at a higher level ... + */ + if (cacheId == RELNAME || cacheId == TYPENAME) { char *nontemp_relname; - if ((nontemp_relname = - get_temp_rel_by_username(DatumGetPointer(key1))) != NULL) - key1 = PointerGetDatum(nontemp_relname); + nontemp_relname = get_temp_rel_by_username(DatumGetCString(key1)); + if (nontemp_relname != NULL) + key1 = CStringGetDatum(nontemp_relname); } tp = SearchSysCache(SysCache[cacheId], key1, key2, key3, key4); -- cgit v1.2.3