Re: BUG #18657: Using JSON_OBJECTAGG with volatile function leads to segfault
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Tender Wang <tndrwang@gmail.com>, Michael Paquier <michael@paquier.xyz>,
exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2024-10-17T00:56:52Z
Lists: pgsql-bugs
Amit Langote <amitlangote09@gmail.com> writes: > On Wed, Oct 16, 2024 at 11:26 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: >> Would it be better for parse analysis to explicitly NULL out this >> field once it's done looking at it? Carrying unmaintained pieces >> of an expression tree around seems both inefficient and prone to >> future failures of this same ilk. The further the raw_expr gets >> out of step with current reality, the worse the hazards. > It seems we can't do that in this case, because get_rule_expr() wants > to read it. I think you just increased my level of concern. Aren't you saying that get_rule_expr is likely to deliver utter garbage, because it will be working from an expression that has not tracked transformations made to other parts of the tree? Also, I see that ruleutils is applying get_rule_expr to raw_expr, which AFAICT means it's *not* raw-parser output, else that wouldn't work at all. Which means the field is badly named and incorrectly documented. But in particular it means you cannot just make the tree-walking routines ignore it --- you *must* update it during transformations such as subquery pullup, or you will have garbage that will cause EXPLAIN to crash or at least produce wrong results. In other words, the proposed patch is dangerously wrong. I suspect at this point that the true bug might be the opposite: somebody feeling that they could dispense with updating raw_expr when they shouldn't. In particular, I think "... is not evaluated by eval_const_expressions_mutator()" is already a huge red flag. There are transformations that eval_const_expressions does that are not optional. regards, tom lane
Commits
-
SQL/JSON: Fix some oversights in commit b6e1157e7
- 7148cb3e3067 17.1 landed
- fa4f11854c8b 16.5 landed
- 11c87216d134 18.0 landed
-
Don't include CaseTestExpr in JsonValueExpr.formatted_expr
- b6e1157e7d33 17.0 cited