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-21 03:15:42 |
Message-ID: | 53F5645E.1020000@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On 08/20/2014 10:50 PM, Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> On 08/20/2014 07:30 PM, Tom Lane wrote:
>>> 1. #> now returns the input object if the RHS array is empty;
>> So will
>> val #>> '{}'
>> now return a dequoted bare scalar string? I think that's where the OP
>> actually came into this.
> Hm ... as the patch stands, you get the same thing from either operator:
>
> regression=# select '"foo"'::json #> '{}';
> ?column?
> ----------
> "foo"
> (1 row)
>
> regression=# select '"foo"'::json #>> '{}';
> ?column?
> ----------
> "foo"
> (1 row)
>
> If you think the latter should be dequoted, we can probably make it so.
> I'm not entirely convinced that's right though: you could argue that
> dequoting is a function of the -> operator and we applied zero such
> operators. (I'm not wedded to that argument, just raising it as food
> for thought.) Comments?
>
>
This seems backwards. -> and #> return legal json. ->> and #>> return
text, which is dequoted if the result is a scalar string:
andrew=# select '{"a":"b"}'::json #> '{a}' as j, '{"a":"b"}'::json
#>> '{a}' as t;
j | t
-----+---
"b" | b
(1 row)
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-08-21 03:35:44 | Re: BUG #11207: empty path will segfault jsonb #> |
Previous Message | David G Johnston | 2014-08-21 03:09:40 | Re: BUG #11207: empty path will segfault jsonb #> |