aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-02-20 21:32:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-02-20 21:32:16 +0000
commit57b30e8e226014c8d06bae0158e0c7fc679f700b (patch)
tree172a3052e6c88922d63726bacd092afac6bf053c /src/include
parentbd8e071482e3c33876295aae5523fe57ce35025b (diff)
downloadpostgresql-57b30e8e226014c8d06bae0158e0c7fc679f700b.tar.gz
postgresql-57b30e8e226014c8d06bae0158e0c7fc679f700b.zip
Create a new expression node type RelabelType, which exists solely to
represent the result of a binary-compatible type coercion. At runtime it just evaluates its argument --- but during type resolution, exprType will pick up the output type of the RelabelType node instead of the type of the argument. This solves some longstanding problems with dropped type coercions, an example being 'select now()::abstime::int4' which used to produce date-formatted output, not an integer, because the coercion to int4 was dropped on the floor.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/nodes.h3
-rw-r--r--src/include/nodes/primnodes.h26
2 files changed, 27 insertions, 2 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 8dd893e3f13..f42f615c7a6 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: nodes.h,v 1.65 2000/02/18 09:29:43 inoue Exp $
+ * $Id: nodes.h,v 1.66 2000/02/20 21:32:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -67,6 +67,7 @@ typedef enum NodeTag
T_Array,
T_ArrayRef,
T_Iter,
+ T_RelabelType,
/*---------------------
* TAGS FOR PLANNER NODES (relation.h)
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index bdeff737b63..7c3e0c6c4b8 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: primnodes.h,v 1.39 2000/01/26 05:58:16 momjian Exp $
+ * $Id: primnodes.h,v 1.40 2000/02/20 21:32:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -467,4 +467,28 @@ typedef struct ArrayRef
Node *refassgnexpr;
} ArrayRef;
+/* ----------------
+ * RelabelType
+ * arg - input expression
+ * resulttype - output type of coercion expression
+ * resulttypmod - output typmod (usually -1)
+ *
+ * RelabelType represents a "dummy" type coercion between two binary-
+ * compatible datatypes, such as reinterpreting the result of an OID
+ * expression as an int4. It is a no-op at runtime; we only need it
+ * to provide a place to store the correct type to be attributed to
+ * the expression result during type resolution. (We can't get away
+ * with just overwriting the type field of the input expression node,
+ * so we need a separate node to show the coercion's result type.)
+ * ----------------
+ */
+
+typedef struct RelabelType
+{
+ NodeTag type;
+ Node *arg;
+ Oid resulttype;
+ int32 resulttypmod;
+} RelabelType;
+
#endif /* PRIMNODES_H */