Re: [PATCH] Fix jsonb comparison for raw scalar pseudo arrays

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: jian he <jian(dot)universality(at)gmail(dot)com>, Yan Chengpeng <chengpeng_yan(at)outlook(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Fix jsonb comparison for raw scalar pseudo arrays
Date: 2025-01-03 15:44:15
Message-ID: 5ead8eb7-4d97-460e-8c0c-b04a6b1e9cf5@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2024-12-09 Mo 11:16 AM, jian he wrote:
> On Mon, Dec 9, 2024 at 9:27 PM Yan Chengpeng <chengpeng_yan(at)outlook(dot)com> wrote:
>> Sorry, I uploaded the wrong file. I uploaded a new patch with the modified document. Please take a review. Thanks!
>>
>>
> sorry. maybe i didn't mention it explicitly.
> i mean something like:
>
> diff --git a/doc/src/sgml/json.sgml b/doc/src/sgml/json.sgml
> index 54648c459c..d9b24e413e 100644
> --- a/doc/src/sgml/json.sgml
> +++ b/doc/src/sgml/json.sgml
> @@ -584,12 +584,13 @@ SELECT jdoc->'guid', jdoc->'name' FROM api WHERE
> jdoc @@ '$.tags[*] == "qui"';
> The <literal>btree</literal> ordering for <type>jsonb</type>
> datums is seldom
> of great interest, but for completeness it is:
> <synopsis>
> -<replaceable>Object</replaceable> > <replaceable>Array</replaceable>
>> <replaceable>Boolean</replaceable> >
> <replaceable>Number</replaceable> > <replaceable>String</replaceable>
>> <replaceable>Null</replaceable>
> +<replaceable>Object</replaceable> > <replaceable>Array</replaceable>
>> <replaceable>Boolean</replaceable> >
> <replaceable>Number</replaceable> > <replaceable>String</replaceable>
>> <replaceable>null</replaceable>
> <replaceable>Object with n pairs</replaceable> > <replaceable>object
> with n - 1 pairs</replaceable>
>
> <replaceable>Array with n elements</replaceable> > <replaceable>array
> with n - 1 elements</replaceable>
> </synopsis>
> + with the exception that (for historical reasons) an empty array
> sorts less than <replaceable>null</replaceable>.
> Objects with equal numbers of pairs are compared in the order:
> <synopsis>
> <replaceable>key-1</replaceable>, <replaceable>value-1</replaceable>,
> <replaceable>key-2</replaceable> ...

Pushed something along these lines. In master I also added a code
comment so nobody might be tempted to "fix" the anomaly.

cheers

andrew

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2025-01-03 15:58:48 Re: Modern SHA2- based password hashes for pgcrypto
Previous Message Fabrízio de Royes Mello 2025-01-03 15:42:01 Re: Remove unused rel parameter in lookup_var_attr_stats