Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Brendan Jurd <direvus(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Florian Pflug <fgp(at)phlo(dot)org>, Josh Berkus <josh(at)agliodbs(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)
Date: 2013-04-06 14:43:10
Message-ID: 1365259390.7407.YahooMailNeo@web162904.mail.bf1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Brendan Jurd <direvus(at)gmail(dot)com> wrote:
> On 6 April 2013 01:59, Kevin Grittner <kgrittn(at)ymail(dot)com> wrote:
>> Brendan Jurd <direvus(at)gmail(dot)com> wrote:
>>
>>> The language specifically allows for zero elements, and does not
>>> contemplate multiple dimensions.
>>
>> I don't remember anything in the spec which would prohibit the data
>> type of an array element from itself being an array, however.
>
> Indeed it does not prohibit nesting arrays inside other arrays, but
> the multidim arrays that Postgres allows you to create are not the
> same thing as nested arrays.
>
> I believe that a purely to-spec implementation would allow you to make
> an array-of-int-arrays, but since each element is its own separate
> collection there would be no requirement that they have the same
> cardinality as each other.
>
> For example, ARRAY[[1], [2,3], [4,5,6]] is a valid collection per the
> spec, but Postgres won't let you create this, because Postgres is
> trying to create a 2-D matrix of integers, rather than a collection of
> collections of integers.
>
> The inability to extend multidim arrays in Postgres is another
> manifestation of this matrix-oriented design.  Extending nested
> collections is a no-brainer.  Extending matrices while ensuring they
> remain perfectly regular ... not so much.

Your interpretation matches mine all around.  It is unfortunate
that we have hijacked the standard's syntax for arrays to add a
matrix feature.  It seems to leave us without any way forward on
these issues that I like very much.

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-04-06 14:44:03 Re: corrupt pages detected by enabling checksums
Previous Message Matthias Nagel 2013-04-06 09:46:23 Fwd: Range types (DATERANGE, TSTZRANGE) in a foreign key with "inclusion" logic