Re: SQL/JSON path issues/questions

From: Liudmila Mantrova <l(dot)mantrova(at)postgrespro(dot)ru>
To: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: Thom Brown <thom(at)linux(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SQL/JSON path issues/questions
Date: 2019-06-17 10:07:15
Message-ID: 4ccb78e6-dae5-b982-87ad-b44959bbdcf3@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 6/17/19 11:36 AM, Alexander Korotkov wrote:
> I'm going to push attached 3 patches if no objections.
>
> Regarding 0003-Separate-two-distinctive-json-errors.patch, I think it
> requires more thoughts.
>
> RETURN_ERROR(ereport(ERROR,
> (errcode(ERRCODE_SINGLETON_JSON_ITEM_REQUIRED),
> errmsg("left operand of jsonpath
> operator %s is not a single numeric value",
> - jspOperationName(jsp->type)))));
> + jspOperationName(jsp->type)),
> + (llen != 1 ?
> + errdetail("It was an array with %d
> elements.", llen):
> + errdetail("The only element was not a
> numeric.")))));
>
> When we have more than 1 value, it's no exactly array. Jsonpath can
> extract values from various parts of json document, which never
> constitute and array. Should we say something like "There are %d
> values"? Also, probably we should display the type of single element
> if it's not numeric. jsonb_path_match() also throws
> ERRCODE_SINGLETON_JSON_ITEM_REQUIRED, should we add similar
> errdetail() there?
>
> ------
> Alexander Korotkov
> Postgres Professional: http://www.postgrespro.com
> The Russian Postgres Company

Hi Alexander,

While I have no objections to the proposed fixes, I think we can further
improve patch 0003 and the text it refers to.
In attempt to clarify jsonpath docs and address the concern that ? is
hard to trace in the current text, I'd also like to propose patch 0004.
Please see both of them attached.

--
Liudmila Mantrova
Technical writer at Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachment Content-Type Size
0003-fix-jsonpath-varname-description-3.patch text/x-patch 3.8 KB
0004-clarify-jsonpath-docs-1.patch text/x-patch 4.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2019-06-17 11:28:42 Re: Obsolete comments about semaphores in proc.c
Previous Message Amit Kapila 2019-06-17 10:03:23 Re: POC: Cleaning up orphaned files using undo logs