BUG #17873: Empty JSONB array is ordered before all other JSONB values

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: marcus(at)cockroachlabs(dot)com
Subject: BUG #17873: Empty JSONB array is ordered before all other JSONB values
Date: 2023-03-27 19:17:07
Message-ID: 17873-826fdc8bbcace4f1@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17873
Logged by: Marcus Gartner
Email address: marcus(at)cockroachlabs(dot)com
PostgreSQL version: 14.6
Operating system: macOS 13.2.1
Description:

The JSONB Indexing documentation (here:
https://www.postgresql.org/docs/14/datatype-json.html#JSON-INDEXING) states
that:

"The btree ordering for jsonb datums is seldom of great interest, but for
completeness it is:
Object > Array > Boolean > Number > String > Null"

However, the empty JSONB array value does comply with this ordering as it is
less than all other JSONB values, as far as I
can tell.

SELECT '[]'::JSONB < j::JSONB
FROM (VALUES
('null'),
('"a"'),
('1'),
('[1]'),
('{}')
) v(j);
?column?
----------
t
t
t
t
t
(5 rows)

Is this a bug in the B-tree ordering of JSONB values? I could not find any
notes in the source code or test cases that explain this
special case for empty JSONB arrays.

Thanks,
Marcus

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2023-03-27 21:28:30 Re: BUG #17871: JIT during postgresql_fdw remote_estimates EXPLAIN have very negatively effect on planning time
Previous Message Tom Lane 2023-03-27 19:06:21 Re: BUG #17872: Dropping an attribute of a composite type breaks indexes over the type silently