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

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, runyuan(at)berkeley(dot)edu, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19046: Incorrect result when using json_array() with column reference in subquery combined with RIGHT JOIN
Date: 2025-09-12 00:57:27
Message-ID: CAHewXNnXQwvyp84LzguotwwEJXKkPAbOY2hPNN0Tk9LiVtmxWw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 于2025年9月11日周四 11:16写道:

> Richard Guo <guofenglinux(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2025-09-12 01:07:02 Re: BUG #19049: Assert failure when using skip arrays on an index key with DESC order
Previous Message Todd Lang 2025-09-11 18:38:29 RE: BUG #19045: Applying custom collation rules appears to erase existing rules