From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Peter Geoghegan <pg(at)heroku(dot)com>, justin(dot)vanwinkle(at)gmail(dot)com, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #11207: empty path will segfault jsonb #> |
Date: | 2014-08-20 19:57:08 |
Message-ID: | 53F4FD94.4070201@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On 08/20/2014 03:06 PM, Tom Lane wrote:
> Peter Geoghegan <pg(at)heroku(dot)com> writes:
>> On Wed, Aug 20, 2014 at 11:08 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Is there a reason for these to behave inconsistently, and if not, which
>>> behavior should we standardize on? Considering that you get NULL not an
>>> error for extracting a nonexistent element from an object, I think there
>>> is some case to be made for saying that returning NULL is the more
>>> convenient behavior. Of course one can also argue for wanting this
>>> operator to throw errors if the JSON structure doesn't match the
>>> operation, but it seems like we've chosen to prefer being lax.
>> I discussed this very issue with Andrew during development (I think
>> that this happened to occur in private). My view was that since users
>> will frequently use -> within expression indexes, it's best to have it
>> return NULL for non-objects, rather than make them worry about the
>> case where it'll be rejected, which is rather contrary to the spirit
>> of jsonb (at least as a default behavior).
> Hadn't thought of that angle, but it's a really good point. I'd certainly
> rather be able to put an index on (jsoncol -> 'foo') without worrying
> about what will happen if the column includes things that aren't objects.
>
>> Andrew argued it was
>> preferable to stick to the historic behavior of json operators. IMV,
>> we should have both operators return NULL. They should be consistent,
>> which implies changing the behavior of the existing json variants too,
>> but I don't think that's a big problem.
> None of these operators existed before 9.3, so I don't put a lot of stock
> in the idea that their corner-case behaviors should be considered
> sacrosanct already. But that will become the case pretty soon; if we
> don't get it right in 9.4 it will arguably be too late.
>
>
I'm not terribly dogmatic about it. If the consensus is to change it
then let's do it.
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-08-20 20:57:01 | Re: BUG #11207: empty path will segfault jsonb #> |
Previous Message | Tom Lane | 2014-08-20 19:06:07 | Re: BUG #11207: empty path will segfault jsonb #> |