1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-16 15:02:33 +03:00

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.
This commit is contained in:
Tom Lane
2000-02-20 21:32:16 +00:00
parent bd8e071482
commit 57b30e8e22
13 changed files with 325 additions and 86 deletions

View File

@@ -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 */