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

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Florian Pflug <fgp(at)phlo(dot)org>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Brendan Jurd <direvus(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)
Date: 2013-04-03 13:30:34
Message-ID: 515C2EFA.2090403@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 04/02/2013 02:46 PM, Florian Pflug wrote:
> On Apr1, 2013, at 13:43 , Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> I don't think the current behavior is broken. I found it
>> counterintuitive at first, but then I got used to it. It's reasonably
>> self-consistent: arrays can't have empty dimensions, therefore the
>> empty array is unique and dimensionless. Is that the behavior I would
>> have picked if I had designed the type? No, it isn't. I wouldn't
>> have tried to support one-dimensional arrays and multi-dimensional
>> arrays in the same data type either, nor would I have supported
>> non-default lower bounds. But all of those ships have sailed, and the
>> time to change them is not after people have spent 10 years building
>> applications that work with the current behavior. If we want to
>> introduce a new type with different, perhaps better, behavior, well, I
>> think that might be a fine idea. But I *don't* think imposing a hard
>> compatibility break on users of arrays is a good idea.
> +1.
>
> Especially since having infinitely many variants of "empty" is IMHO
> hardly an improvement over the existing situation.
>
> If we're going to break compatibility, we should IMHO get rid of
> non-zero lower bounds all together. My guess is that the number of
> affected users wouldn't be much higher than for the proposed patch,
> and it'd allow lossless mapping to most language's native array types…

That would actually break a HUGE number of users, since the default
lower bound is 1. I have seen any number of pieces if code that rely on
that.

Doesn't the standard have something to say about all this?

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2013-04-03 13:32:53 Re: Typo in documentation for function to_json
Previous Message Dimitri Fontaine 2013-04-03 13:29:32 Re: in-catalog Extension Scripts and Control parameters (templates?)