model-writtenrun 7442 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Greg Nancarrow reported that rewriting a query could lose hasModifyingCTE and permit unsafe parallel execution, supplying a patch that updates both the nested and enclosing query flags; he credited Hou Zhijie with reproducing the SELECT failure and minimizing the patch, and Amit Langote with reviewing it #1.
- Tom Lane questioned the enclosing-query update, then revised the fix to propagate hasRecursive as well as hasModifyingCTE into sub_action and integrated the reproducer into regression tests #2 #3; that revision landed unchanged as ed29089633.
- Greg demonstrated that INSERT…SELECT rule actions still leave the enclosing INSERT flag unset #4, prompting Tom to recognize that rewriting can place a data-modifying CTE below the top query level, which ordinary parsing forbids #5.
- With the release deadline approaching, Tom reverted the first fix in d1d2979852 and proposed rejecting the unsupported case #5; he also considered moving CTEs to the enclosing query but warned that this would require adjusting ctelevelsup references #6.
- The separate parallel INSERT work that exposed the bug landed as 05c8482f7f from thread #42973, rather than from this thread’s rewriter patches.
- Discussion resumed in May with Takayuki Tsunakawa questioning the scope of the proposed restriction #7, while Zhijie Hou supported rejecting data-modifying CTEs when rule_action differs from sub_action and suggested error wording #8.
- Takayuki then supplied a revision moving the CTE list and flags to rule_action, replacing boolean unions with assignments, and reporting passing regression tests and successful flag inspection #9; Tom requested evidence that the existing placement was wrong, and Takayuki acknowledged uncertainty about the two placements #10 #11.
- In September, Tom showed that the assignments could discard existing flags and that moving CTEs without adjusting ctelevelsup fails when an aggregate prevents subquery pull-up, producing a missing-CTE error; he recommended rejecting the case instead of adding substantial tree-adjustment code #12.
- Greg redirected the discussion to his newer patch in thread #44738, which restores the reverted fix and adds the error condition #13; Tom closed this thread’s CommitFest item as Returned With Feedback and moved to that replacement #14, which subsequently landed with light edits as 362e2dcc46.