As discussed on -hackers, this patch allows the construction of an
empty array if an explicit cast to an array type is given (as in,
postgres=# select array::int;
postgres=# select array;
ERROR: no target type for empty array
HINT: Empty arrays must be explictly cast to the desired array type,
A few notes on the implementation:
* The syntax now allows an ARRAY constructor with an empty expression
list (array_expr_list may be empty).
* I've added a new parsenode for arrays, A_ArrayExpr (previously the
parser would create ArrayExpr primnodes).
* transformArrayExpr() now takes two extra arguments, a type oid and
a typmod. When transforming a typecast which casts an A_ArrayExpr to
an array type, transformExpr passes these type details down to
transformArrayExpr, and skips the typecast.
* transformArrayExpr() behaves slightly differently when passed type
information. The overall type of the array is set to the given type,
and all elements are explictly coerced to the equivalent element type.
If it was not passed a type, then the behaviour is as previous; the
function looks for a common type among the elements, and coerces them
to that type. The overall type of the array is derived from the
common element type.
The patch is very invasive (at least compared to any of my previous
patches), but so far I haven't managed to find any broken behaviour.
All regression tests pass, and the regression tests for arrays seem to
be quite comprehensive. I did add a couple of new tests for the empty
array behaviours, but the rest I've left alone.
I look forward to your comments -- although given the length of the
8.4 patch review queue, that will probably be an exercise in extreme
Major thanks go out to Tom for all his guidance on -hackers while I
developed the patch.
In response to
pgsql-hackers by date
|Next:||From: Simon Riggs||Date: 2007-11-30 09:17:21|
|Subject: Re: Release Note Changes|
|Previous:||From: NikhilS||Date: 2007-11-30 07:44:53|
|Subject: Re: BUG #3774: create table like including index doesn't update pg_constraints with primary key|
pgsql-patches by date
|Next:||From: Simon Riggs||Date: 2007-11-30 09:54:19|
|Subject: Re: [PATCHES] Partition: use triggers instead of rules|
|Previous:||From: Jorgen Austvik - Sun Norway||Date: 2007-11-30 08:43:30|
|Subject: Re: pg_regress: paths in largeobject test|
pgsql-general by date
|Next:||From: Usama Dar||Date: 2007-11-30 09:26:57|
|Subject: Re: can't createdb with my new user|
|Previous:||From: Martijn van Oosterhout||Date: 2007-11-30 08:50:18|
|Subject: Re: Record variable not behaving as expected (bug?)|