Re: casting strings to multidimensional arrays yields strange - Mailing list pgsql-bugs

From Kris Jurka
Subject Re: casting strings to multidimensional arrays yields strange
Date
Msg-id Pine.BSO.4.56.0407271050200.78@leary.csoft.net
Whole thread Raw
In response to casting strings to multidimensional arrays yields strange results  (Kris Jurka <books@ejurka.com>)
Responses Re: casting strings to multidimensional arrays yields strange results
List pgsql-bugs
On Tue, 27 Jul 2004, Tom Lane wrote:

> Right now I think the sanest behavior would be to throw an error on
> non-rectangular input.  Once we have support for null elements in
> arrays, however, it would arguably be reasonable to pad with NULLs
> where needed,
>

I'm just forwarding a report mentioned on irc so I have no real personal
interest.  The user was really just trying to figure out how it was
supposed to work, rather than requesting a particular behavior.

Are you considering NULL padding arrays constructed with the
ARRAY[] syntax?  If not then this should definitely throw an error to
match that.  If we plan on moving to consistent NULL padding, perhaps now
we should consistently pad with 0 instead of sometimes padding and sometimes
truncating.  This is a change along the direction we're going even if it
is an intermediate behavior.

Doing some testing along these lines for different data types makes me
think this might not be the best idea, 0 and '' seem like reasonable
defaults for numeric/text data, but for some reason 2000-01-01 is the
default for a date, and I'm sure other data types have similar problems.

jurka=# select
'{{2001-01-01},{2001-02-02,2003-03-03},{2004-02-02,2004-04-04}}'::date[][];
                                   date
---------------------------------------------------------------------------
 {{2001-01-01,2000-01-01},{2001-02-02,2003-03-03},{2004-02-02,2004-04-04}}


Kris Jurka

pgsql-bugs by date:

Previous
From: Kris Jurka
Date:
Subject: Re: BUG #1201: void functions called through jdbc driver
Next
From: Tom Lane
Date:
Subject: Re: casting strings to multidimensional arrays yields strange results