Re: ON ERROR in json_query and the like

From: Markus Winand <markus(dot)winand(at)winand(dot)at>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ON ERROR in json_query and the like
Date: 2024-06-12 13:22:15
Message-ID: 2796AD89-523D-4F25-A923-122E2FDF04E3@winand.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> On 04.06.2024, at 07:00, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> On Tue, May 28, 2024 at 5:29 PM Markus Winand <markus(dot)winand(at)winand(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2024-06-12 13:29:54 Re: relfilenode statistics
Previous Message David G. Johnston 2024-06-12 13:13:52 Re: ON ERROR in json_query and the like