model-writtenrun 3893 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Maxim Boguk reported that COPY foreign-key checks appeared as top-level queries when utility tracking was disabled, despite pg_stat_statements.track being set to top #1.
- Julien Rouhaud reproduced the bug, identified the same problem in DO blocks, and proposed incrementing execution nesting depth even when utility statements were not tracked #2.
- Sergei Kornilov supplied DO-block regression tests and the utility nesting fix #3; Tomas Vondra reviewed it as correct, requested clearer comments, and initially proposed committing and backpatching it #4.
- After the patch remained uncommitted, Tom Lane revised its comments and condition checks, questioned whether PREPARE should share EXECUTE's nesting exemption, and argued against backpatching a potentially surprising behavioral change #6.
- Tom established that PREPARE must retain its exemption because parse analysis depends on top-level status, replaced the shared utility macro with explicit checks, and added fixes and tests for statements executed during planning #7.
- Sergei tested the revised series across tracking settings and both simple and extended query protocols, reported no unexpected top-level classifications, and accepted development-branch-only application #8.
- Tom committed both patches from #7 as 76db9cb636, consolidating the separate nesting counters while preserving the posted tests, and confirmed the push in the final message #9; the full series landed without backpatching.