1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-08 00:47:37 +03:00

Arrange for an explicit cast applied to an ARRAY[] constructor to be applied

directly to all the member expressions, instead of the previous implementation
where the ARRAY[] constructor would infer a common element type and then we'd
coerce the finished array after the fact.  This has a number of benefits,
one being that we can allow an empty ARRAY[] construct so long as its
element type is specified by such a cast.

Brendan Jurd, minor fixes by me.
This commit is contained in:
Tom Lane
2008-03-20 21:42:48 +00:00
parent 8759b79d0f
commit 6b0706ac33
11 changed files with 312 additions and 100 deletions

View File

@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.388 2008/02/07 20:19:47 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.389 2008/03/20 21:42:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1684,6 +1684,16 @@ _copyA_Indirection(A_Indirection *from)
return newnode;
}
static A_ArrayExpr *
_copyA_ArrayExpr(A_ArrayExpr *from)
{
A_ArrayExpr *newnode = makeNode(A_ArrayExpr);
COPY_NODE_FIELD(elements);
return newnode;
}
static ResTarget *
_copyResTarget(ResTarget *from)
{
@@ -3543,6 +3553,9 @@ copyObject(void *from)
case T_A_Indirection:
retval = _copyA_Indirection(from);
break;
case T_A_ArrayExpr:
retval = _copyA_ArrayExpr(from);
break;
case T_ResTarget:
retval = _copyResTarget(from);
break;

View File

@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.318 2008/02/07 20:19:47 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.319 2008/03/20 21:42:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1729,6 +1729,14 @@ _equalA_Indirection(A_Indirection *a, A_Indirection *b)
return true;
}
static bool
_equalA_ArrayExpr(A_ArrayExpr *a, A_ArrayExpr *b)
{
COMPARE_NODE_FIELD(elements);
return true;
}
static bool
_equalResTarget(ResTarget *a, ResTarget *b)
{
@@ -2469,6 +2477,9 @@ equal(void *a, void *b)
case T_A_Indirection:
retval = _equalA_Indirection(a, b);
break;
case T_A_ArrayExpr:
retval = _equalA_ArrayExpr(a, b);
break;
case T_ResTarget:
retval = _equalResTarget(a, b);
break;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.322 2008/01/09 08:46:44 neilc Exp $
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.323 2008/03/20 21:42:48 tgl Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
@@ -1971,6 +1971,14 @@ _outA_Indirection(StringInfo str, A_Indirection *node)
WRITE_NODE_FIELD(indirection);
}
static void
_outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
{
WRITE_NODE_TYPE("A_ARRAYEXPR");
WRITE_NODE_FIELD(elements);
}
static void
_outResTarget(StringInfo str, ResTarget *node)
{
@@ -2417,6 +2425,9 @@ _outNode(StringInfo str, void *obj)
case T_A_Indirection:
_outA_Indirection(str, obj);
break;
case T_A_ArrayExpr:
_outA_ArrayExpr(str, obj);
break;
case T_ResTarget:
_outResTarget(str, obj);
break;