mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
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
This commit is contained in:
18
src/backend/utils/cache/syscache.c
vendored
18
src/backend/utils/cache/syscache.c
vendored
@ -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);
|
||||
|
Reference in New Issue
Block a user