diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-02-20 21:32:16 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-02-20 21:32:16 +0000 |
commit | 57b30e8e226014c8d06bae0158e0c7fc679f700b (patch) | |
tree | 172a3052e6c88922d63726bacd092afac6bf053c /src/backend/nodes/readfuncs.c | |
parent | bd8e071482e3c33876295aae5523fe57ce35025b (diff) |
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/backend/nodes/readfuncs.c')
-rw-r--r-- | src/backend/nodes/readfuncs.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 7d1e0b4cccf..dfbdbef9884 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.84 2000/02/15 20:49:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.85 2000/02/20 21:32:05 tgl Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -1191,6 +1191,35 @@ _readSubLink() return local_node; } +/* ---------------- + * _readRelabelType + * + * RelabelType is a subclass of Node + * ---------------- + */ +static RelabelType * +_readRelabelType() +{ + RelabelType *local_node; + char *token; + int length; + + local_node = makeNode(RelabelType); + + token = lsptok(NULL, &length); /* eat :arg */ + local_node->arg = nodeRead(true); /* now read it */ + + token = lsptok(NULL, &length); /* eat :resulttype */ + token = lsptok(NULL, &length); /* get resulttype */ + local_node->resulttype = (Oid) atol(token); + + token = lsptok(NULL, &length); /* eat :resulttypmod */ + token = lsptok(NULL, &length); /* get resulttypmod */ + local_node->resulttypmod = atoi(token); + + return local_node; +} + /* * Stuff from execnodes.h */ @@ -1820,6 +1849,8 @@ parsePlanString(void) return_value = _readAggref(); else if (length == 7 && strncmp(token, "SUBLINK", length) == 0) return_value = _readSubLink(); + else if (length == 11 && strncmp(token, "RELABELTYPE", length) == 0) + return_value = _readRelabelType(); else if (length == 3 && strncmp(token, "AGG", length) == 0) return_value = _readAgg(); else if (length == 4 && strncmp(token, "HASH", length) == 0) |