aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1996-09-16 05:33:20 +0000
committerMarc G. Fournier <scrappy@hub.org>1996-09-16 05:33:20 +0000
commit475493130de825caf884d537d193d6b3ff8d0279 (patch)
tree1e23f4b09f62ee7d24723603a0e37491af8c3899 /src/backend/executor
parentc5dd292007c3948a44e085c26205c1242e7ec350 (diff)
downloadpostgresql-475493130de825caf884d537d193d6b3ff8d0279.tar.gz
postgresql-475493130de825caf884d537d193d6b3ff8d0279.zip
|Subject: Postgres patch: Assert attribute type match
| |Here's a patch for Version 2 only. It just adds an Assert to catch some |inconsistencies in the catalog classes. | |-- |Bryan Henderson Phone 408-227-6803 |San Jose, California |
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execQual.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index 104c1f2f506..fe2744d1e20 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.1.1.1 1996/07/09 06:21:25 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.2 1996/09/16 05:33:20 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -172,8 +172,24 @@ ExecEvalAggreg(Aggreg *agg, ExprContext *econtext, bool *isNull)
*
* Returns a Datum whose value is the value of a range
* variable with respect to given expression context.
- * ----------------------------------------------------------------
- */
+ *
+ *
+ * As an entry condition, we expect that the the datatype the
+ * plan expects to get (as told by our "variable" argument) is in
+ * fact the datatype of the attribute the plan says to fetch (as
+ * seen in the current context, identified by our "econtext"
+ * argument).
+ *
+ * If we fetch a Type A attribute and Caller treats it as if it
+ * were Type B, there will be undefined results (e.g. crash).
+ * One way these might mismatch now is that we're accessing a
+ * catalog class and the type information in the pg_attribute
+ * class does not match the hardcoded pg_attribute information
+ * (in pg_attribute.h) for the class in question.
+ *
+ * We have an Assert to make sure this entry condition is met.
+ *
+ * ---------------------------------------------------------------- */
Datum
ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
{
@@ -211,8 +227,12 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
heapTuple = slot->val;
tuple_type = slot->ttc_tupleDescriptor;
buffer = slot->ttc_buffer;
-
+
attnum = variable->varattno;
+
+ /* (See prolog for explanation of this Assert) */
+ Assert(attnum < 0 ||
+ variable->vartype == tuple_type->attrs[attnum-1]->atttypid)
/*
* If the attribute number is invalid, then we are supposed to