Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cb36c0f

Browse files
committed
In RelationNameGetRelation(), replace temp table name by
real name before doing lookup. We only want to index temp tables by their real names in the relcache, to ensure there's not more than one relcache entry for them.
1 parent 15dd167 commit cb36c0f

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

src/backend/utils/cache/relcache.c

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.69 1999/09/04 18:42:13 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.70 1999/09/04 21:47:23 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -56,6 +56,7 @@
5656
#include "utils/builtins.h"
5757
#include "utils/catcache.h"
5858
#include "utils/relcache.h"
59+
#include "utils/temprel.h"
5960

6061

6162
static void RelationFlushRelation(Relation *relationPtr,
@@ -1182,6 +1183,7 @@ RelationIdGetRelation(Oid relationId)
11821183
Relation
11831184
RelationNameGetRelation(char *relationName)
11841185
{
1186+
char *temprelname;
11851187
Relation rd;
11861188
RelationBuildDescInfo buildinfo;
11871189

@@ -1192,6 +1194,15 @@ RelationNameGetRelation(char *relationName)
11921194
IncrHeapAccessStat(local_RelationNameGetRelation);
11931195
IncrHeapAccessStat(global_RelationNameGetRelation);
11941196

1197+
/* ----------------
1198+
* if caller is looking for a temp relation, substitute its real name;
1199+
* we only index temp rels by their real names.
1200+
* ----------------
1201+
*/
1202+
temprelname = get_temp_rel_by_name(relationName);
1203+
if (temprelname)
1204+
relationName = temprelname;
1205+
11951206
/* ----------------
11961207
* first try and get a reldesc from the cache
11971208
* ----------------
@@ -1212,26 +1223,6 @@ RelationNameGetRelation(char *relationName)
12121223
return rd;
12131224
}
12141225

1215-
/* ----------------
1216-
* old "getreldesc" interface.
1217-
* ----------------
1218-
*/
1219-
#ifdef NOT_USED
1220-
Relation
1221-
getreldesc(char *relationName)
1222-
{
1223-
/* ----------------
1224-
* increment access statistics
1225-
* ----------------
1226-
*/
1227-
IncrHeapAccessStat(local_getreldesc);
1228-
IncrHeapAccessStat(global_getreldesc);
1229-
1230-
return RelationNameGetRelation(relationName);
1231-
}
1232-
1233-
#endif
1234-
12351226
/* ----------------------------------------------------------------
12361227
* cache invalidation support routines
12371228
* ----------------------------------------------------------------

0 commit comments

Comments
 (0)