Re: sql/json miscellaneous issue

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: sql/json miscellaneous issue
Date: 2024-06-24 11:46:36
Message-ID: CA+HiwqF3Zq3iJoXCyS3uwb8ydELYuyT1WHOw=2TepYKnBp5NBg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Jun 24, 2024 at 7:04 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> hi.
> the following two queries should return the same result?
>
> SELECT * FROM JSON_query (jsonb 'null', '$' returning jsonb);
> SELECT * FROM JSON_value (jsonb 'null', '$' returning jsonb);

I get this with HEAD:

SELECT * FROM JSON_query (jsonb 'null', '$' returning jsonb);
json_query
------------
null
(1 row)

Time: 734.587 ms
SELECT * FROM JSON_value (jsonb 'null', '$' returning jsonb);
json_value
------------

(1 row)

Much like:

SELECT JSON_QUERY('{"key": null}', '$.key');
json_query
------------
null
(1 row)

Time: 2.975 ms
SELECT JSON_VALUE('{"key": null}', '$.key');
json_value
------------

(1 row)

Which makes sense to me, because JSON_QUERY() is supposed to return a
JSON null in both cases and JSON_VALUE() is supposed to return a SQL
NULL for a JSON null.

--
Thanks, Amit Langote

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2024-06-24 11:50:21 Re: speed up a logical replica setup
Previous Message shveta malik 2024-06-24 11:43:25 Re: Conflict detection and logging in logical replication