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

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: BUG #11207: empty path will segfault jsonb #>
Дата
Msg-id CAKFQuwaHaYa++8ztK57iJvT4xv4YKiDS4WpAezCPV0oafh+vpA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #11207: empty path will segfault jsonb #>  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: BUG #11207: empty path will segfault jsonb #>  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Wed, Aug 20, 2014 at 10:51 PM, Tom Lane-2 [via PostgreSQL] <
ml-node+s1045698n5815665h39@n5.nabble.com> wrote:

> Andrew Dunstan <[hidden email]
> <http://user/SendEmail.jtp?type=3Dnode&node=3D5815665&i=3D0>> 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=3D# select '"foo"'::json #> '{}';
>  ?column?
> ----------
>  "foo"
> (1 row)
>
> regression=3D# 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?
>
>
=E2=80=8BExamples of both json object/array and json=E2=80=8B scalar result=
s from the
different operators may be worth considering.

It is not obvious that your statement:

"dequoting is a function of the -> operator"

is true if one is just looking at the documentation.

Did you maybe intend to say the "->>" operator (which is stated to return
text, not json)?

"Get JSON object field by key" (->)

vs.

"Get JSON object field as text" (->>)

http://www.postgresql.org/docs/9.4/interactive/functions-json.html

The first one should be more precise, maybe: "Get JSON object value, by
key, as json"; and probably add the "by key" to the ->> operator at the
same time for consistency (though to be honest the "by key" part seems
redundant).

The use of "field" here instead of "value" is also confusing (note I
changed it in my alternative).  Do we have the same problem for value/field
as we did for key/name?

David J.




--
View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-1=
1207-empty-path-will-segfault-jsonb-tp5815469p5815667.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #11207: empty path will segfault jsonb #>
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: BUG #11207: empty path will segfault jsonb #>