From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Brendan Jurd <direvus(at)gmail(dot)com> |
Cc: | "David E(dot) Wheeler" <david(at)justatheory(dot)com>, "pgsql-hackers(at)postgresql(dot)org Hackers" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Should array_length() Return NULL |
Date: | 2013-03-16 19:27:53 |
Message-ID: | 25958.1363462073@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Brendan Jurd <direvus(at)gmail(dot)com> writes:
> On 17 March 2013 05:19, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Perhaps not. I think for most uses, a 1-D zero-length array would be
>> just as good. I guess what I'd want to know is whether we also need
>> to support higher-dimensional zero-size arrays, and if so, what does
>> the I/O syntax for those look like?
> If I'm reading right, in our current implementation of array
> dimensionality, there can be no such thing as a higher-dimensional
> zero-length array anyhow. Postgres doesn't care about how many
> dimensions you define for an array, it uses the "quacks like a duck"
> test for number of dimensions. For example:
> postgres=# SELECT ARRAY[1]::int[][], array_dims(ARRAY[1]::int[][]);
> array | array_dims
> -------+------------
> {1} | [1:1]
Um, this seems to be conflating the issue with a different one, which
is that the type system doesn't care how many dimensions arrays have.
So "int[]" and "int[][]" are the same type. That's slightly annoying
but I'm not sure it's really worth changing.
What I'm concerned about here is whether these expressions shouldn't
be yielding different data values:
regression=# select array[]::int[];
array
-------
{}
(1 row)
regression=# select array[array[]]::int[];
array
-------
{}
(1 row)
regression=# select array[array[],array[]]::int[];
array
-------
{}
(1 row)
Right now, if we did make them produce what they appear to mean, the
array I/O functions would have a problem with representing the results:
regression=# select '{}'::int[];
int4
------
{}
(1 row)
regression=# select '{{}}'::int[];
ERROR: malformed array literal: "{{}}"
LINE 1: select '{{}}'::int[];
^
regression=# select '{{},{}}'::int[];
ERROR: malformed array literal: "{{},{}}"
LINE 1: select '{{},{}}'::int[];
^
So I think we'd need to fix that before we could go very far in this
direction.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2013-03-16 21:02:44 | Re: Enabling Checksums |
Previous Message | Brendan Jurd | 2013-03-16 19:06:43 | Re: Should array_length() Return NULL |