diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-06-20 01:41:22 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-06-20 01:41:22 +0000 |
commit | 996659f2556843490827eb5027b53bac4b10783d (patch) | |
tree | 54fc74b0573dd91922b7401e975013d92eb9f254 /src/backend/utils/cache/syscache.c | |
parent | a1dfaef6c6e2da34dbc808f205665a6c96362149 (diff) | |
download | postgresql-996659f2556843490827eb5027b53bac4b10783d.tar.gz postgresql-996659f2556843490827eb5027b53bac4b10783d.zip |
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
Diffstat (limited to 'src/backend/utils/cache/syscache.c')
-rw-r--r-- | src/backend/utils/cache/syscache.c | 18 |
1 files changed, 12 insertions, 6 deletions
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); |