Re: ON ERROR in json_query and the like - Mailing list pgsql-hackers

From Markus Winand
Subject Re: ON ERROR in json_query and the like
Date
Msg-id 2796AD89-523D-4F25-A923-122E2FDF04E3@winand.at
Whole thread Raw
In response to Re: ON ERROR in json_query and the like  (jian he <jian.universality@gmail.com>)
List pgsql-hackers
> On 04.06.2024, at 07:00, jian he <jian.universality@gmail.com> wrote:
>
> On Tue, May 28, 2024 at 5:29 PM Markus Winand <markus.winand@winand.at> wrote:
>
>> 2. EMPTY [ARRAY|OBJECT] ON ERROR implies ERROR ON EMPTY
>>
>>   17beta1=# SELECT JSON_QUERY('[]', '$[*]' EMPTY ARRAY ON ERROR) a;
>>    a
>>   ----
>>    []
>>   (1 row)
>>
>>   As NULL ON EMPTY is implied, it should give the same result as
>>   explicitly adding NULL ON EMPTY:
>>
>
> I vaguely remember, we stumbled on ON ERROR, ON EMPTY several times.
> i don't have a standard,

In my understanding of the standard is that there is no distinction
between an explicit and implicit ON EMPTY clause.

E.g. clause 6.35 (json_query) Syntax Rule 4:

    •  If <JSON query empty behavior> is not specified, then NULL ON EMPTY is implicit.

General Rule 5ai then covers the NULL ON EMPTY case:

           • i)  If the length of SEQ2 is 0 (zero) and ONEMPTY is NULL, then let JV be the null value.

Neither of these make the ON EMPTY handling dependent on the presence of ON ERROR.

-markus


pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: ON ERROR in json_query and the like
Next
From: Bertrand Drouvot
Date:
Subject: Re: relfilenode statistics