model-writtenrun 9762 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Daniel Verite proposed \copyfrom and \copyto to support multiline COPY statements and variable interpolation, attaching a prototype that redirected files or programs through the query buffer in #1.
- David G. Johnston questioned the need for new commands and proposed extending \g in #4; Daniel initially feared this required semantic SQL parsing, then discovered that redirection could be selected after receiving the server's result and replaced the prototype with a COPY TO STDOUT fix in #6.
- Fabien COELHO compiled and tested the replacement, identified initialization concerns, and requested documentation and tests in #8; after discussion of portable file testing, Tom Lane decided that TAP coverage should be a separate project and that this bug fix should be back-patched without new tests in #15.
- Tom Lane also required existing copyStream redirection to retain priority and identified a SIGPIPE restoration problem in #15; Daniel incorporated that feedback, added documentation, and refined NULL-stream handling in #16.
- Fabien's manual testing of the revised patch exposed ROW_COUNT behavior and inconsistent ERROR reporting between COPY and SELECT redirection in #17; Daniel explained that the general ROW_COUNT issue was separate and defended reporting client-side failures through ERROR in #18.
- Fabien proposed distinguishing SQL and client failures in #19, while Daniel argued that ERROR must detect failed output and proposed matching ON_ERROR_STOP in #22; Tom settled on reporting any error through ERROR and leaving broader consistency fixes for later in #28.
- Tom identified a remaining risk of closing a stream owned by \copy and proposed explicit need_close tracking in #28, then committed the final submitted patch with that correction and documentation edits as 6d3ede5f1c; his announcement confirmed back-patching through PostgreSQL 9.5 while leaving 9.4 unchanged because its \g implementation differed substantially in #30.
- After landing, Daniel proposed pursuing COPY FROM support in #31, and Tom identified the remaining pstdout capability and suggested \g -, explicit input redirection, and possible program-input syntax in #32.
- The thread ended with COPY TO redirection committed, while COPY FROM support, portable direct-stdout syntax, broader error handling, and additional tests remained future work: Daniel explicitly had no new patch yet in #33, supported \g - in #35, and Corey Huinker added agreement in #36.