Re: casting strings to multidimensional arrays yields strange

From: Kris Jurka <books(at)ejurka(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: casting strings to multidimensional arrays yields strange
Date: 2004-07-27 16:07:22
Message-ID: Pine.BSO.4.56.0407271050200.78@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers pgsql-patches

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-07-27 16:41:04 Re: casting strings to multidimensional arrays yields strange results
Previous Message Tom Lane 2004-07-27 14:08:12 Re: casting strings to multidimensional arrays yields strange results

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-07-27 16:41:04 Re: casting strings to multidimensional arrays yields strange results
Previous Message Tom Lane 2004-07-27 15:19:24 Re: Savepoints inside functions

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-07-27 16:41:04 Re: casting strings to multidimensional arrays yields strange results
Previous Message Tom Lane 2004-07-27 14:08:12 Re: casting strings to multidimensional arrays yields strange results