Re: Re: temp-table-related failure in regression tests - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Re: temp-table-related failure in regression tests
Date
Msg-id 200106191203.f5JC3P708115@candle.pha.pa.us
Whole thread Raw
In response to Re: temp-table-related failure in regression tests  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Re: temp-table-related failure in regression tests  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> I wrote:
> > Is anyone else seeing this with current CVS, or is it my own breakage?
> 
> Ah, the problem is RelationGetRelationName didn't know about the
> new temprel naming convention.

Sorry, yes, I missed changing that.  I thought I had all the pg_temp
mapped to defines but I missed that one and hence didn't change to
underscore names.

> 
> I quick-hacked rel.h to fix this, but we need a better solution.
> I don't much like having rel.h include temprel.h --- seems like the
> include should go the other way.  Should is_temp_relname get moved
> to rel.h?

You will see near the top of rel.h:
/* added to prevent circular dependency.  bjm 1999/11/15 */extern char *get_temp_rel_by_physicalname(const char
*relname);

so it seems there is an interdependency between rel.h and temprel.h. 
Trying to include temprel.h in rel.h causes a compile problem.  Going
the other way I assume would cause the same problem.

We can move the is_temp_relname define if you wish but with one hack
already in rel.h for get_temp_rel_by_physicalname(), I am not excited
about adding another to rel.h.  In fact, is_temp_relname needs
PG_TEMP_REL_PREFIX so we would have to move it too.  However, I don't
see any other solution so I moved both to from temprel.h to rel.h.

I am attaching a fix that I have committed to CVS.  If you don't like
it, feel free to reverse it out and try something else.  Seems to
compile fine.

I will be speaking at Red Hat HQ today so will not be available to
reverse it out myself.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026 
Index: src/include/utils/rel.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/utils/rel.h,v
retrieving revision 1.47
diff -c -r1.47 rel.h
*** src/include/utils/rel.h    2001/06/19 05:11:50    1.47
--- src/include/utils/rel.h    2001/06/19 12:00:59
***************
*** 188,230 **** #define RelationGetFile(relation) ((relation)->rd_fd)  /*
-  * RelationGetRelationName
-  *
-  *      Returns the relation's logical name (as seen by the user).
-  *
-  * If the rel is a temp rel, the temp name will be returned.  Therefore,
-  * this name is not unique.  But it is the name to use in heap_openr(),
-  * for example.
-  */
- #define RelationGetRelationName(relation) \
- (\
-     (strncmp(RelationGetPhysicalRelationName(relation), \
-              "pg_temp", 7) != 0) \
-     ? \
-         RelationGetPhysicalRelationName(relation) \
-     : \
-         get_temp_rel_by_physicalname( \
-             RelationGetPhysicalRelationName(relation)) \
- )
- 
- 
- /*
-  * RelationGetPhysicalRelationName
-  *
-  *      Returns the rel's physical name, ie, the name appearing in pg_class.
-  *
-  * While this name is unique across all rels in the database, it is not
-  * necessarily useful for accessing the rel, since a temp table of the
-  * same name might mask the rel.  It is useful mainly for determining if
-  * the rel is a shared system rel or not.
-  *
-  * The macro is rather unfortunately named, since the pg_class name no longer
-  * has anything to do with the file name used for physical storage of the rel.
-  */
- #define RelationGetPhysicalRelationName(relation) \
-     (NameStr((relation)->rd_rel->relname))
- 
- /*  * RelationGetNumberOfAttributes  *  *      Returns the number of attributes.
--- 188,193 ----
***************
*** 253,257 ****
--- 216,264 ---- extern void RelationSetIndexSupport(Relation relation,                         IndexStrategy strategy,
                       RegProcedure *support);
 
+ 
+ /*
+  * Handle temp relations
+  */
+ #define PG_TEMP_REL_PREFIX "pg_temp"
+ 
+ #define is_temp_relname(relname) \
+         (strncmp(relname, PG_TEMP_REL_PREFIX, strlen(PG_TEMP_REL_PREFIX)) == 0)
+ 
+ /*
+  * RelationGetPhysicalRelationName
+  *
+  *      Returns the rel's physical name, ie, the name appearing in pg_class.
+  *
+  * While this name is unique across all rels in the database, it is not
+  * necessarily useful for accessing the rel, since a temp table of the
+  * same name might mask the rel.  It is useful mainly for determining if
+  * the rel is a shared system rel or not.
+  *
+  * The macro is rather unfortunately named, since the pg_class name no longer
+  * has anything to do with the file name used for physical storage of the rel.
+  */
+ #define RelationGetPhysicalRelationName(relation) \
+     (NameStr((relation)->rd_rel->relname))
+ 
+ /*
+  * RelationGetRelationName
+  *
+  *      Returns the relation's logical name (as seen by the user).
+  *
+  * If the rel is a temp rel, the temp name will be returned.  Therefore,
+  * this name is not unique.  But it is the name to use in heap_openr(),
+  * for example.
+  */
+ #define RelationGetRelationName(relation) \
+ (\
+     !is_temp_relname(relation) \
+     ? \
+         RelationGetPhysicalRelationName(relation) \
+     : \
+         get_temp_rel_by_physicalname( \
+             RelationGetPhysicalRelationName(relation)) \
+ )
+   #endif     /* REL_H */
Index: src/include/utils/temprel.h
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/utils/temprel.h,v
retrieving revision 1.16
diff -c -r1.16 temprel.h
*** src/include/utils/temprel.h    2001/06/18 16:13:21    1.16
--- src/include/utils/temprel.h    2001/06/19 12:00:59
***************
*** 16,26 ****  #include "access/htup.h" 
- #define PG_TEMP_REL_PREFIX "pg_temp"
- 
- #define is_temp_relname(relname) \
-         (strncmp(relname, PG_TEMP_REL_PREFIX, strlen(PG_TEMP_REL_PREFIX)) == 0)
-  extern void create_temp_relation(const char *relname,                      HeapTuple pg_class_tuple); extern void
remove_temp_rel_by_relid(Oidrelid);
 
--- 16,21 ----

pgsql-hackers by date:

Previous
From: Zeugswetter Andreas SB
Date:
Subject: AW: AW: Re: [SQL] behavior of ' = NULL' vs. MySQL vs. S tand ards
Next
From: Bruce Momjian
Date:
Subject: PlPerl compile failure