diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-05 21:31:09 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-05 21:31:09 +0000 |
| commit | 31edbadf4af45dd4eecebcb732702ec6d7ae1819 (patch) | |
| tree | b1b29b079deac806537bc3d5287f4eb325f48efa /src/backend/nodes/outfuncs.c | |
| parent | 1120b99445a90ceba27f49e5cf86293f0628d06a (diff) | |
| download | postgresql-31edbadf4af45dd4eecebcb732702ec6d7ae1819.tar.gz | |
Downgrade implicit casts to text to be assignment-only, except for the ones
from the other string-category types; this eliminates a lot of surprising
interpretations that the parser could formerly make when there was no directly
applicable operator.
Create a general mechanism that supports casts to and from the standard string
types (text,varchar,bpchar) for *every* datatype, by invoking the datatype's
I/O functions. These new casts are assignment-only in the to-string direction,
explicit-only in the other, and therefore should create no surprising behavior.
Remove a bunch of thereby-obsoleted datatype-specific casting functions.
The "general mechanism" is a new expression node type CoerceViaIO that can
actually convert between *any* two datatypes if their external text
representations are compatible. This is more general than needed for the
immediate feature, but might be useful in plpgsql or other places in future.
This commit does nothing about the issue that applying the concatenation
operator || to non-text types will now fail, often with strange error messages
due to misinterpreting the operator as array concatenation. Since it often
(not always) worked before, we should either make it succeed or at least give
a more user-friendly error; but details are still under debate.
Peter Eisentraut and Tom Lane
Diffstat (limited to 'src/backend/nodes/outfuncs.c')
| -rw-r--r-- | src/backend/nodes/outfuncs.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 4bf6764c18..5de540642f 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.308 2007/05/22 23:23:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.309 2007/06/05 21:31:04 tgl Exp $ * * NOTES * Every node type that can appear in stored rules' parsetrees *must* @@ -871,6 +871,16 @@ _outRelabelType(StringInfo str, RelabelType *node) } static void +_outCoerceViaIO(StringInfo str, CoerceViaIO *node) +{ + WRITE_NODE_TYPE("COERCEVIAIO"); + + WRITE_NODE_FIELD(arg); + WRITE_OID_FIELD(resulttype); + WRITE_ENUM_FIELD(coerceformat, CoercionForm); +} + +static void _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node) { WRITE_NODE_TYPE("ARRAYCOERCEEXPR"); @@ -2165,6 +2175,9 @@ _outNode(StringInfo str, void *obj) case T_RelabelType: _outRelabelType(str, obj); break; + case T_CoerceViaIO: + _outCoerceViaIO(str, obj); + break; case T_ArrayCoerceExpr: _outArrayCoerceExpr(str, obj); break; |
