From: | Amit Langote <amitlangote09(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
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-19 03:12:57 |
Message-ID: | CA+HiwqHM1mf6becAnGBuaMMPk7jC3bthZ2ywnF3=XEYwivtTRQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Sat, Oct 19, 2024 at 2:22 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Amit Langote <amitlangote09(at)gmail(dot)com> writes:
> > Another version which expands the comment of JsonValueExpr a little further.
Thanks for the review.
> 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.
Ah, I hadn't considered that. Good point.
> 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;
I decided to use makeJsonValueExpr() here.
> 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.
Good point.
Updated patch attached.
--
Thanks, Amit Langote
Attachment | Content-Type | Size |
---|---|---|
v8-0001-SQL-JSON-Fix-some-oversights-in-commit-b6e1157e7.patch | application/octet-stream | 9.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Lakhin | 2024-10-19 09:00:00 | Re: BUG #18658: Assert in SerialAdd() due to race condition |
Previous Message | Heikki Linnakangas | 2024-10-18 20:15:08 | Re: BUG #18658: Assert in SerialAdd() due to race condition |