Commit 0e14dfe0 authored by Bruce Momjian's avatar Bruce Momjian

Intercept temp table lookups further up to map temp names.

parent cb36c0f6
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.93 1999/07/17 20:16:48 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.94 1999/09/04 22:00:29 momjian Exp $
*
*
* INTERFACE ROUTINES
......@@ -237,8 +237,7 @@ heap_create(char *relname,
if (istemp)
{
/* replace relname of caller */
snprintf(relname, NAMEDATALEN, "pg_temp.%d.%u",
MyProcPid, uniqueId++);
snprintf(relname, NAMEDATALEN, "pg_temp.%d.%u", MyProcPid, uniqueId++);
}
/* ----------------
......@@ -789,15 +788,6 @@ heap_create_with_catalog(char *relname,
(istemp && get_temp_rel_by_name(relname) != NULL))
elog(ERROR, "Relation '%s' already exists", relname);
/* invalidate cache so non-temp table is masked by temp */
if (istemp)
{
Oid relid = RelnameFindRelid(relname);
if (relid != InvalidOid)
RelationForgetRelation(relid);
}
/* save user relation name because heap_create changes it */
if (istemp)
{
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.87 1999/07/20 17:14:05 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.88 1999/09/04 22:00:29 momjian Exp $
*
*
* INTERFACE ROUTINES
......@@ -975,15 +975,6 @@ index_create(char *heapRelationName,
numatts,
attNums);
/* invalidate cache so possible non-temp index is masked by temp */
if (istemp)
{
Oid relid = RelnameFindRelid(indexRelationName);
if (relid != InvalidOid)
RelationForgetRelation(relid);
}
/* save user relation name because heap_create changes it */
if (istemp)
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.43 1999/09/04 19:55:49 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.44 1999/09/04 22:00:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -24,7 +24,6 @@
#include "catalog/pg_index.h"
#include "miscadmin.h"
#include "utils/syscache.h"
#include "utils/temprel.h"
/*
* Names of indices on the following system catalogs:
......@@ -449,14 +448,6 @@ ClassNameIndexScan(Relation heapRelation, char *relName)
Relation idesc;
ScanKeyData skey[1];
HeapTuple tuple;
char *hold_rel;
/*
* we have to do this before looking in system tables because temp
* table namespace takes precedence
*/
if ((hold_rel = get_temp_rel_by_name(relName)) != NULL)
relName = hold_rel;
ScanKeyEntryInitialize(&skey[0],
(bits16) 0x0,
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.34 1999/08/09 03:13:30 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.35 1999/09/04 22:00:30 momjian Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
......@@ -35,6 +35,7 @@
#include "catalog/pg_shadow.h"
#include "catalog/pg_type.h"
#include "utils/catcache.h"
#include "utils/temprel.h"
extern bool AMI_OVERRIDE; /* XXX style */
......@@ -487,6 +488,16 @@ SearchSysCacheTuple(int cacheId,/* cache selection code */
cacheId);
}
/* temp table name remapping */
if (cacheId == RELNAME)
{
char *nontemp_relname;
if ((nontemp_relname =
get_temp_rel_by_name(DatumGetPointer(key1))) != NULL)
key1 = PointerGetDatum(nontemp_relname);
}
tp = SearchSysCache(SysCache[cacheId], key1, key2, key3, key4);
if (!HeapTupleIsValid(tp))
{
......
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.12 1999/09/04 21:45:48 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.13 1999/09/04 22:00:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -118,6 +118,8 @@ remove_temp_relation(Oid relid)
List *l,
*prev;
elog(NOTICE,"oid = %d", relid);
oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
prev = NIL;
......@@ -126,8 +128,11 @@ remove_temp_relation(Oid relid)
{
TempTable *temp_rel = lfirst(l);
elog(NOTICE,"check oid = %d", temp_rel->relid);
if (temp_rel->relid == relid)
{
elog(NOTICE,"removed");
pfree(temp_rel->user_relname);
pfree(temp_rel->relname);
pfree(temp_rel);
......@@ -212,7 +217,10 @@ get_temp_rel_by_name(char *user_relname)
TempTable *temp_rel = lfirst(l);
if (strcmp(temp_rel->user_relname, user_relname) == 0)
{
elog(NOTICE,"found");
return temp_rel->relname;
}
}
return NULL;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment