aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-04-14 22:34:48 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-04-14 22:34:48 +0000
commit8e14408028e31a3dad872a0735a435ba10017ae6 (patch)
tree99fbb5bd8b2d8487ae0e1b0a5deb6777cd4d3f60
parent0453a997af76a36530200dbf8403e70849ff4c0b (diff)
downloadpostgresql-8e14408028e31a3dad872a0735a435ba10017ae6.tar.gz
postgresql-8e14408028e31a3dad872a0735a435ba10017ae6.zip
Make equalTupleDescs() compare attlen/attbyval/attalign rather than
assuming comparison of atttypid is sufficient. In a dropped column atttypid will be 0, and we'd better check the physical-storage data to make sure the tupdescs are physically compatible. I do not believe there is a real risk before 8.0, since before that we only used this routine to compare successive states of the tupdesc for a particular relation. But 8.0's typcache.c might be comparing arbitrary tupdescs so we'd better play it safer.
-rw-r--r--src/backend/access/common/tupdesc.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index fac8551dfd6..fedc7ec4894 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.110 2005/03/31 22:46:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/common/tupdesc.c,v 1.111 2005/04/14 22:34:48 tgl Exp $
*
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -274,10 +274,15 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
/*
* We do not need to check every single field here: we can
- * disregard attrelid, attnum (it was used to place the row in the
- * attrs array) and everything derived from the column datatype.
- * Also, attcacheoff must NOT be checked since it's possibly not
- * set in both copies.
+ * disregard attrelid and attnum (which were used to place the row
+ * in the attrs array in the first place). It might look like we
+ * could dispense with checking attlen/attbyval/attalign, since these
+ * are derived from atttypid; but in the case of dropped columns
+ * we must check them (since atttypid will be zero for all dropped
+ * columns) and in general it seems safer to check them always.
+ *
+ * attcacheoff must NOT be checked since it's possibly not set
+ * in both copies.
*/
if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0)
return false;
@@ -285,12 +290,18 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
return false;
if (attr1->attstattarget != attr2->attstattarget)
return false;
+ if (attr1->attlen != attr2->attlen)
+ return false;
if (attr1->attndims != attr2->attndims)
return false;
if (attr1->atttypmod != attr2->atttypmod)
return false;
+ if (attr1->attbyval != attr2->attbyval)
+ return false;
if (attr1->attstorage != attr2->attstorage)
return false;
+ if (attr1->attalign != attr2->attalign)
+ return false;
if (attr1->attnotnull != attr2->attnotnull)
return false;
if (attr1->atthasdef != attr2->atthasdef)