From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Amit Langote <amitlangote09(at)gmail(dot)com> |
Cc: | Tender Wang <tndrwang(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18657: Using JSON_OBJECTAGG with volatile function leads to segfault |
Date: | 2024-10-18 17:22:05 |
Message-ID: | 907538.1729272125@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Amit Langote <amitlangote09(at)gmail(dot)com> writes:
> Another version which expands the comment of JsonValueExpr a little further.
I still don't like this approach to eval_const_expressions one bit.
It's undocumented and it pessimizes as many cases as it optimizes.
Sure, in the case where we can fold formatted_expr to a constant,
we avoid processing raw_expr at all --- but if we fail to do that,
we end by recursively simplifying formatted_expr twice (and raw_expr
once). That's not a win.
I think it should look more like
/*
* If we can fold formatted_expr to a constant, we can elide
* the JsonValueExpr altogether. Otherwise we must process
* raw_expr too. But JsonFormat is a flat node and requires
* no simplification, only copying.
*/
formatted = eval_const_expressions_mutator((Node *) jve->formatted_expr,
context);
if (formatted && IsA(formatted, Const))
return formatted;
newnode = makeNode(JsonValueExpr);
newnode->formatted_expr = formatted;
newnode->raw_expr = eval_const_expressions_mutator((Node *) jve->raw_expr,
context);
newnode->format = copyObject(jve->format);
return newnode;
(Untested, probably requires more casts than I wrote.)
Also, in primnodes.h, personally I'd write
+ Expr *raw_expr; /* user-specified expression */
"raw" is a misnomer here, and even if we're not going to rename the
field, we're not helping anyone by using that word in the comment.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2024-10-18 20:15:08 | Re: BUG #18658: Assert in SerialAdd() due to race condition |
Previous Message | PG Bug reporting form | 2024-10-18 14:48:08 | BUG #18663: synchronous_standby_names vs synchronous_commit vs pg_stat_replication |