Re: BUG #18657: Using JSON_OBJECTAGG with volatile function leads to segfault
От | Tom Lane |
---|---|
Тема | Re: BUG #18657: Using JSON_OBJECTAGG with volatile function leads to segfault |
Дата | |
Msg-id | 907538.1729272125@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | BUG #18657: Using JSON_OBJECTAGG with volatile function leads to segfault (PG Bug reporting form <noreply@postgresql.org>) |
Список | pgsql-bugs |
Amit Langote <amitlangote09@gmail.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
В списке pgsql-bugs по дате отправления: