temp-table-related failure in regression tests

Поиск
Список
Период
Сортировка
Искать

temp-table-related failure in regression tests

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Is anyone else seeing this with current CVS, or is it my own breakage?

*** ./expected/alter_table.out	Wed May 30 12:38:38 2001
--- ./results/alter_table.out	Tue Jun 19 00:45:22 2001
***************
*** 340,347 **** ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1); NOTICE:  ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s) DROP TABLE pktable;
! NOTICE:  DROP TABLE implicitly drops referential integrity trigger from table "fktable"
! NOTICE:  DROP TABLE implicitly drops referential integrity trigger from table "fktable" DROP TABLE fktable; CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 text,                            PRIMARY KEY(ptest1, ptest2));
--- 340,347 ---- ALTER TABLE FKTABLE ADD FOREIGN KEY(ftest1) references pktable(ptest1); NOTICE:  ALTER TABLE ... ADD CONSTRAINT will create implicit trigger(s) for FOREIGN KEY check(s) DROP TABLE pktable;
! NOTICE:  DROP TABLE implicitly drops referential integrity trigger from table "pg_temp_15818_3"
! NOTICE:  DROP TABLE implicitly drops referential integrity trigger from table "pg_temp_15818_3" DROP TABLE fktable; CREATE TEMP TABLE PKTABLE (ptest1 int, ptest2 text,                            PRIMARY KEY(ptest1, ptest2));

======================================================================

		regards, tom lane

Re: temp-table-related failure in regression tests

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
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.

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?
		regards, tom lane

Re: Re: temp-table-related failure in regression tests

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
> 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, Pennsylvania 19026
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(Oid relid);
--- 16,21 ----

Re: Re: temp-table-related failure in regression tests

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian  writes:
> 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.

Yeah, I didn't see any other way either.  With luck this whole issue
will go away when we do schemas... in the meantime at least the ugliness
is pretty localized.
		regards, tom lane

FAQ