Intercept temp table lookups further up to map temp names.
authorBruce Momjian
Sat, 4 Sep 1999 22:00:30 +0000 (22:00 +0000)
committerBruce Momjian
Sat, 4 Sep 1999 22:00:30 +0000 (22:00 +0000)
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/indexing.c
src/backend/utils/cache/syscache.c
src/backend/utils/cache/temprel.c

index 1592be2687b31e27dfd677c202999b7b44820b5b..b571cf3f817931af2d01b637ccc5a9e4614f0919 100644 (file)
@@ -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)
    {
index 5c44746cb2c0181234643b7634ef34f58f76c0e5..d52731bac237e13c032135720ac5e35ce8c4edad 100644 (file)
@@ -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)
    {
index f8a115582a5c1d760a3febf370b15e2b01f625d9..9007258f2e81792cc2f2ed1dc1fdf3d6fc1c8404 100644 (file)
@@ -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,15 +448,7 @@ 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,
                           (AttrNumber) 1,
index 470780676c29487ac142b9a50a7e8bef1e5e7952..c9c7770f8ccbb7a5e531967c51be16906d2cf093 100644 (file)
@@ -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))
    {
index 75cfe14fbca3f1d9334513c19e1cf471d54fb10d..ece1c9519f616366940df20350c373cc87253a6a 100644 (file)
@@ -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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -117,6 +117,8 @@ remove_temp_relation(Oid relid)
    MemoryContext oldcxt;
    List       *l,
               *prev;
+              
+elog(NOTICE,"oid = %d", relid);
 
    oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt);
 
@@ -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;
 }