Re: SQL/JSON: FOR ORDINALITY bug

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Erik Rijkers <er(at)xs4all(dot)nl>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: SQL/JSON: FOR ORDINALITY bug
Date: 2022-05-09 20:37:33
Message-ID: 5695ca50-abc1-5734-2223-870c0f000ddb@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2022-05-04 We 16:09, Erik Rijkers wrote:
> Op 04-05-2022 om 21:12 schreef Andrew Dunstan:
>>
>>>>>
>>>>> I don't see how rowseq can be anything but 1.  Each invocation of
>>>
>>>
>>> After some further experimentation, I now think you must be right,
>>> David.
>>>
>>> Also, looking at the DB2 docs:
>>>    https://www.ibm.com/docs/en/i/7.2?topic=data-using-json-table
>>>      (see especially under 'Handling nested information')
>>>
>>> There, I gathered some example data + statements where one is the case
>>> at hand.  I also made them runnable under postgres (attached).
>>>
>>> I thought that was an instructive example, with those
>>> 'outer_ordinality' and 'inner_ordinality' columns.
>>>
>>>
>>
>> Yeah, I just reviewed the latest version of that page (7.5) and the
>> example seems fairly plain that we are doing the right thing, or if not
>> we're in pretty good company, so I guess this is probably a false alarm.
>> Looks like ordinality is for the number of the element produced by the
>> path expression. So a path of 'lax $' should just produce ordinality of
>> 1 in each case, while a path of 'lax $[*]' will produce increasing
>> ordinality for each element of the root array.
>
> Agreed.
>
> You've probably noticed then that on that same page under 'Sibling
> Nesting' is a statement that gives a 13-row resultset on DB2 whereas
> in 15devel that statement yields just 10 rows.  I don't know which is
> correct.

Oracle also gives 10 rows for that query according to my testing, so I
suspect either DB2 and/or its docs are wrong.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-05-10 01:01:55 Re: [PATCH] Add native windows on arm64 support
Previous Message Euler Taveira 2022-05-09 18:44:45 Re: Privileges on PUBLICATION