Re: json_query conditional wrapper bug

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: json_query conditional wrapper bug
Date: 2024-09-12 02:24:52
Message-ID: CA+HiwqFoSbbBDxGDOanv+h1_fvLRim7p0vy0Ft3MfQrh0pZs9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 11, 2024 at 8:56 PM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> On 11.09.24 13:25, Amit Langote wrote:
> > On Wed, Sep 11, 2024 at 6:57 PM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> >> On 11.09.24 09:51, Amit Langote wrote:
> >>>>> I've updated your patch to include updated test outputs and a nearby
> >>>>> code comment expanded. Do you intend to commit it or do you prefer
> >>>>> that I do?
> >>>>
> >>>> This change looks unrelated:
> >>>>
> >>>> -ERROR: new row for relation "test_jsonb_constraints" violates check
> >>>> constraint "test_jsonb_constraint4"
> >>>> +ERROR: new row for relation "test_jsonb_constraints" violates check
> >>>> constraint "test_jsonb_constraint5"
> >>>>
> >>>> Is this some randomness in the way these constraints are evaluated?
> >>>
> >>> The result of JSON_QUERY() in the CHECK constraint changes, so the
> >>> constraint that previously failed now succeeds after this change,
> >>> because the comparison looked like this before and after:
> >>>
> >>> -- before
> >>> postgres=# select jsonb '[10]' < jsonb '[10]';
> >>> ?column?
> >>> ----------
> >>> f
> >>> (1 row)
> >>>
> >>> -- after
> >>> postgres=# select jsonb '10' < jsonb '[10]';
> >>> ?column?
> >>> ----------
> >>> t
> >>> (1 row)
> >>>
> >>> That causes the next constraint to be evaluated and its failure
> >>> reported instead.
> >>>
> >>> In the attached, I've adjusted the constraint for the test case to be
> >>> a bit more relevant and removed a nearby somewhat redundant test,
> >>> mainly because its output changes after the adjustment.
> >>
> >> Ok, that looks good. Good that we could clear that up a bit.
> >
> > Thanks for checking. Would you like me to commit it?
>
> Please do.

Done. Thanks for the report and the patch.

--
Thanks, Amit Langote

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2024-09-12 02:25:38 Re: Remove shadowed declaration warnings
Previous Message Michael Paquier 2024-09-12 02:19:00 Re: Pgstattuple on Sequences: Seeking Community Feedback on Potential Patch