Re: BUG #11207: empty path will segfault jsonb #>

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
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 23:30:16
Message-ID: 25391.1408577416@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> I think returning NULL is the right thing here, really. Aside from being
> arguably more convenient for indexing, we will get less push-back if we
> make some operators go from throwing errors to returning null than if
> we make some other operators go the other way.

Attached is a proposed patch (against HEAD and 9.4 git tip) that has
these effects:

1. #> now returns the input object if the RHS array is empty;

2. Error cases in -> and #> are all removed in favor of returning NULL.

The regression test changes show that we were really pretty inconsistent
about whether to throw error or return NULL for cases where the JSON
tree structure didn't match the extraction request. I think having a
uniform rule is a definite improvement.

regards, tom lane

Attachment Content-Type Size
rationalize-json-extraction-ops.patch text/x-diff 58.4 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2014-08-20 23:39:16 Re: BUG #11207: empty path will segfault jsonb #>
Previous Message Tom Lane 2014-08-20 20:57:01 Re: BUG #11207: empty path will segfault jsonb #>