1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-26 01:22:12 +03:00

Create a new parsetree node type, TypeCast, so that transformation of

SQL cast constructs can be performed during expression transformation
instead of during parsing.  This allows constructs like x::numeric(9,2)
and x::int2::float8 to behave as one would expect.
This commit is contained in:
Tom Lane
2000-01-17 00:14:49 +00:00
parent e0bd60171a
commit 49528361f5
10 changed files with 242 additions and 132 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.99 2000/01/09 00:26:22 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.100 2000/01/17 00:14:46 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1385,6 +1385,17 @@ _copyTypeName(TypeName *from)
return newnode;
}
static TypeCast *
_copyTypeCast(TypeCast *from)
{
TypeCast *newnode = makeNode(TypeCast);
Node_Copy(from, newnode, arg);
Node_Copy(from, newnode, typename);
return newnode;
}
static Query *
_copyQuery(Query *from)
{
@ -1658,6 +1669,9 @@ copyObject(void *from)
case T_TypeName:
retval = _copyTypeName(from);
break;
case T_TypeCast:
retval = _copyTypeCast(from);
break;
/*
* VALUE NODES

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.30 2000/01/09 00:26:23 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.31 2000/01/17 00:14:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1046,6 +1046,15 @@ _freeTypeName(TypeName *node)
pfree(node);
}
static void
_freeTypeCast(TypeCast *node)
{
freeObject(node->arg);
freeObject(node->typename);
pfree(node);
}
static void
_freeQuery(Query *node)
{
@ -1294,6 +1303,9 @@ freeObject(void *node)
case T_TypeName:
_freeTypeName(node);
break;
case T_TypeCast:
_freeTypeCast(node);
break;
/*
* VALUE NODES

View File

@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.102 2000/01/14 00:53:21 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.103 2000/01/17 00:14:47 tgl Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
@ -190,6 +190,15 @@ _outTypeName(StringInfo str, TypeName *node)
_outNode(str, node->arrayBounds);
}
static void
_outTypeCast(StringInfo str, TypeCast *node)
{
appendStringInfo(str, " TYPECAST :arg ");
_outNode(str, node->arg);
appendStringInfo(str, " :typename ");
_outNode(str, node->typename);
}
static void
_outIndexElem(StringInfo str, IndexElem *node)
{
@ -1292,6 +1301,8 @@ _outAConst(StringInfo str, A_Const *node)
{
appendStringInfo(str, "CONST ");
_outValue(str, &(node->val));
appendStringInfo(str, " :typename ");
_outNode(str, node->typename);
}
static void
@ -1400,6 +1411,9 @@ _outNode(StringInfo str, void *obj)
case T_TypeName:
_outTypeName(str, obj);
break;
case T_TypeCast:
_outTypeCast(str, obj);
break;
case T_IndexElem:
_outIndexElem(str, obj);
break;