pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Anton A. Melnikov <a.melnikov@postgrespro.ru>
To: Amit Langote <amitlangote09@gmail.com>
Cc: jian he <jian.universality@gmail.com>
Cc: Nikita Malakhov <hukutoc@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Erik Rijkers <er@xs4all.nl>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: remaining sql/json patches
Date: Tue, 17 Oct 2023 10:11:12 +0300
Message-ID: <1156d735-5a1b-4c5e-8e13-44b15ec1ee21@postgrespro.ru> (raw )
In-Reply-To: <CA+HiwqFcrOVYXzV9pRME+p-B6cTQM5XDBfws+_0rqjYg9k4kLA@mail.gmail.com >
References: <CA+HiwqFJQdBQzTbSt6=S_3mmYf_pb2YoRNrhL1R0zzFz5Yja=w@mail.gmail.com >
<202309281104.kmkr4v34ny2t@alvherre.pgsql >
<CA+HiwqETtgH0ESDEEGDwTmazmtNeR7UsJS=BOoa=ghdYMo+Ufg@mail.gmail.com >
<20231006214856.yie5dedhzrcb3qxx@alap3.anarazel.de >
<CA+HiwqGdrSTsjyBcw66WE=vDke4B5fJj2zXBbXpv-npgzm4+rg@mail.gmail.com >
<CA+HiwqEHWkGwiy3mKzjf0MaPU84LZh9PjtL3TDZuvF=0QLVz=w@mail.gmail.com >
<CAN-LCVNNjsruFkAGHeF-9W0yTQKuELKAXsyYs3WDTe_SX+9ppg@mail.gmail.com >
<CAN-LCVP=5QSmbndz4q+mNxddLa2y4XVOw+z7Dx=iUkegNM8Sjg@mail.gmail.com >
<CA+HiwqGNmJ67n6BKAROEBHqv0faGA3GxU+vH1wO8x-m9i=hRoQ@mail.gmail.com >
<CACJufxHLYQPw-7Wg=EYqnQPjhaB_dJGH+USsT0vP5FL3sxLX5Q@mail.gmail.com >
<c04ff761-930b-4345-ae23-f78b8ee7ce32@postgrespro.ru >
<CA+HiwqFcrOVYXzV9pRME+p-B6cTQM5XDBfws+_0rqjYg9k4kLA@mail.gmail.com >
On 17.10.2023 07:02, Amit Langote wrote:
> One thing jian he missed during the debugging is that
> ExecEvalJsonExprCoersion() receives the EMPTY ARRAY value via
> *op->resvalue/resnull, set by ExecEvalJsonExprBehavior(), because
> that's the ON EMPTY behavior specified in the constraint. The bug was
> that the code in ExecEvalJsonExprCoercion() failed to set val_string
> to that value ("[]") before passing to InputFunctionCallSafe(), so the
> latter would assume the input is NULL.
>
Thank a lot for this remark!
I tried to dig to the transformJsonOutput() to fix it earlier at the analyze stage,
but it looks like a rather hard way.
Maybe simple in accordance with you note remove the second condition from this line:
if (jb && JB_ROOT_IS_SCALAR(jb)) ?
There is a simplified reproduction before such a fix:
postgres=# select JSON_QUERY(jsonb '[]', '$' RETURNING char(5) OMIT QUOTES EMPTY ON EMPTY);
server closed the connection unexpectedly
This probably means the server terminated abnormally
after:
postgres=# select JSON_QUERY(jsonb '[]', '$' RETURNING char(5) OMIT QUOTES EMPTY ON EMPTY);
json_query
------------
[]
(1 row)
And at the moment i havn't found any side effects of that fix.
Please point me if i'm missing something.
With the best wishes!
--
Anton A. Melnikov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
view thread (300+ messages) latest in thread
Message-ID: <1156d735-5a1b-4c5e-8e13-44b15ec1ee21@postgrespro.ru>
Permalink: ../1156d735-5a1b-4c5e-8e13-44b15ec1ee21@postgrespro.ru/
Also on: postgresql.org/message-id/1156d735-5a1b-4c5e-8e13-44b15ec1ee21@postgrespro.ru
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: a.melnikov@postgrespro.ru, amitlangote09@gmail.com, jian.universality@gmail.com, hukutoc@gmail.com, andres@anarazel.de, alvherre@alvh.no-ip.org, andrew@dunslane.net, er@xs4all.nl
Subject: Re: remaining sql/json patches
In-Reply-To: <1156d735-5a1b-4c5e-8e13-44b15ec1ee21@postgrespro.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox