On 11/16/26 18:30, Kirill Reshke wrote:
> On Mon, 16 Nov 2026 at 18:39, Tomas Vondra <[email protected]> wrote:
>>
>> Hi,
>>
> 
> Hi!
> I quickly looked up, JSON bugs are already reported here
> https://commitfest.postgresql.org/patch/7186/. Did you review this
> thread? Should we continue your fix instead?
> The CoerceToDomain part looks novel - no previous report.
> I didn't check your patchset details closely.
> 

Hmm, I didn't notice that thread before :-( Sorry.

I've tried swapping the v4 fix from that thread for my fix, and
re-running the tests. And it triggered two differences:

1) prevented inlining in two queries:

  Values Scan on "*VALUES*"
-   Output: JSON_VALUE("*VALUES*".column1, '$."a"' PASSING 1 AS p
RETURNING integer DEFAULT 0 ON EMPTY DEFAULT '-1'::integer ON ERROR),
JSON_VALUE('{"a": 1}'::jsonb, "*VALUES*".column2 RETURNING integer
DEFAULT 0 ON EMPTY DEFAULT '-1'::integer ON ERROR)
+   Output: sqljson_strict_context("*VALUES*".column1),
sqljson_strict_path("*VALUES*".column2)
 (2 rows)

2) failed with a couple cases that return a not-NULL domain

+ERROR:  could not coerce ON ERROR expression (NULL) to the RETURNING type
+DETAIL:  domain queryfuncs_int_notnull does not allow null values

I'm not sure either of these is a problem the v4 patch needs to solve. I
like that it's simpler, because if does not need to descend into the
expressions. It a more conservative fix, but maybe that's a good thing.

The (2) happens because it does not check if the domain used in the
RETURNING clause is null-rejecting. But it also interacts with the
on_error behavior, so not sure we can allow that.


regards

-- 
Tomas Vondra



Reply via email to