Re: BUG #19046: Incorrect result when using json_array() with column reference in subquery combined with RIGHT JOIN - Mailing list pgsql-bugs

From Tender Wang
Subject Re: BUG #19046: Incorrect result when using json_array() with column reference in subquery combined with RIGHT JOIN
Date
Msg-id CAHewXNnXQwvyp84LzguotwwEJXKkPAbOY2hPNN0Tk9LiVtmxWw@mail.gmail.com
Whole thread Raw
In response to Re: BUG #19046: Incorrect result when using json_array() with column reference in subquery combined with RIGHT JOIN  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs


Tom Lane <tgl@sss.pgh.pa.us> 于2025年9月11日周四 11:16写道:
Richard Guo <guofenglinux@gmail.com> writes:
> I tested JsonExpr, which is the representation of json_value,
> json_query and json_exists.  It seems that they could not produce
> non-NULL output with a NULL input.  So we are good on that front.

Seems like we ought to actually look at the relevant code, not
try to test our way to an understanding of it.

              

I read the  ExecInitJsonExpr() code, it has:

/*
* Evaluate formatted_expr storing the result into
* jsestate->formatted_expr.
*/
ExecInitExprRec((Expr *) jsexpr->formatted_expr, state,
&jsestate->formatted_expr.value,
&jsestate->formatted_expr.isnull);

/* JUMP to return NULL if formatted_expr evaluates to NULL */
jumps_return_null = lappend_int(jumps_return_null, state->steps_len);
scratch->opcode = EEOP_JUMP_IF_NULL;
scratch->resnull = &jsestate->formatted_expr.isnull;
scratch->d.jump.jumpdone = -1; /* set below */
ExprEvalPushStep(state, scratch);

The above codes say that it will directly return null if formatted_expr evaluates to NULL.

--
Thanks,
Tender Wang

pgsql-bugs by date:

Previous
From: Todd Lang
Date:
Subject: RE: BUG #19045: Applying custom collation rules appears to erase existing rules
Next
From: Peter Geoghegan
Date:
Subject: Re: BUG #19049: Assert failure when using skip arrays on an index key with DESC order