jrgemignani commented on PR #2448: URL: https://github.com/apache/age/pull/2448#issuecomment-4861653410
> @jrgemignani **GPT 5.5 xhigh review**: > > I found one semantic issue with the capture rewrite. > > `reduce_capture_mutator()` captures the largest agtype-typed outer-reference subtree and passes it through the `extras` aggregate argument. That means the captured expression is evaluated unconditionally as an aggregate argument, before the fold body runs. This changes short-circuit behavior for `CASE`, `AND`, `OR`, etc. > > Repro: > > ```sql > WITH 0 AS z > RETURN reduce(s = 0, x IN [1] | > CASE WHEN false THEN s + 1 / z ELSE s END) > ``` > > This currently raises division by zero, even though the branch should not be evaluated. The same expression without an outer capture returns 0. > > I think the capture needs to preserve evaluation order, likely by capturing only outer leaf values and leaving operators/function calls inside the serialized fold expression. > > Also, `git diff --check apache/master...pr-2448` reports trailing whitespace in the newly added regress/expected/age_reduce.out lines. Resolved. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
