Re: SQL/JSON path issues/questions

From: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
To: 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 08:36:12
Message-ID: CAPpHfds2a6sjV10S5g42uWc4s=udTRYV=rth03-eLR1y60K=cA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
0001-implement-like_regex-flag-q-in-jsonpath-2.patch application/octet-stream 7.7 KB
0002-improve-jsonpath-like_regex-documentation-2.patch application/octet-stream 1.3 KB
0003-fix-jsonpath-varname-description-2.patch application/octet-stream 2.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2019-06-17 09:23:08 Re: "WIP: Data at rest encryption" patch and, PostgreSQL 11-beta3
Previous Message Kyotaro Horiguchi 2019-06-17 08:31:03 Strange error message in xlog.c