From 6b0706ac33ab5da815980c642a9cde9a4cd86b6b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 20 Mar 2008 21:42:48 +0000 Subject: 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. --- src/include/nodes/nodes.h | 3 ++- src/include/nodes/parsenodes.h | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/include') diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 5a6745a214..79d679b5be 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.205 2008/01/01 19:45:58 momjian Exp $ + * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.206 2008/03/20 21:42:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -324,6 +324,7 @@ typedef enum NodeTag T_FuncCall, T_A_Indices, T_A_Indirection, + T_A_ArrayExpr, T_ResTarget, T_TypeCast, T_SortBy, diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index c973eea729..ff01438331 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.359 2008/02/07 17:09:51 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.360 2008/03/20 21:42:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -242,9 +242,9 @@ typedef struct A_Const * TypeCast - a CAST expression * * NOTE: for mostly historical reasons, A_Const parsenodes contain - * room for a TypeName; we only generate a separate TypeCast node if the - * argument to be casted is not a constant. In theory either representation - * would work, but the combined representation saves a bit of code in many + * room for a TypeName, allowing a constant to be marked as being of a given + * type without a separate TypeCast node. Either representation will work, + * but the combined representation saves a bit of code in many * productions in gram.y. */ typedef struct TypeCast @@ -304,6 +304,15 @@ typedef struct A_Indirection List *indirection; /* subscripts and/or field names */ } A_Indirection; +/* + * A_ArrayExpr - an ARRAY[] construct + */ +typedef struct A_ArrayExpr +{ + NodeTag type; + List *elements; /* array element expressions */ +} A_ArrayExpr; + /* * ResTarget - * result target (used in target list of pre-transformed parse trees) -- cgit v1.2.3