model-writtenrun 5928 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Dmitry Koval reported that PostgreSQL 14.1 on Windows crashed on psql's COPY to stdout because GetFileInformationByHandle() rejected the console stream, then supplied a patch falling back to runtime-library stat functions #1 #2.
- Michael Paquier reproduced the failure but objected to the fallback functions and structure casts because of portability and large-file problems, proposing direct stat emulation instead; Juan José SantamarÃa Flecha implemented that approach for descriptors 0, 1 and 2 #3 #4.
- Dmitry explained that redirected standard streams must still receive real file information and supplied an alternative retaining the existing handle-query path, using _fileno() comparisons and character-device stat values rather than FIFO values #5 #6 #10.
- Michael preferred keeping the fix inside _pgfstat64(), and Juan combined that structure with a GetFinalPathNameByHandleA() redirection check; Dmitry questioned and measured its extra cost, but Michael accepted the tradeoff for this limited code path #9 #11 #12 #14 #15.
- Dmitry added the requested explanation of stream handling, Juan shortened it, and Dmitry approved the resulting comment, leaving the implementation unchanged through these revisions #16 #17 #18.
- Michael and Dmitry established that existing COPY tests missed the problem because they redirected the streams, while the failure required an actual Windows terminal #19 #20.
- Michael also found pg_recvlogical with -f - affected, tested the fix and committed #17 with light comment and expression edits as 10260c794b, backpatching to PostgreSQL 14 #21.
- Juan subsequently proposed a separate console-input TAP test, while questioning whether its extra infrastructure was worthwhile; Michael requested existing test helpers and suites, and suggested supplying input and checking table contents instead of waiting for a timeout #22 #23 #24.
- Justin Pryzby reported a new MinGW buildfarm warning about GetFinalPathNameByHandleA(), and Michael traced it to older Windows targets where that API was unavailable #25 #26.
- Michael supplied a compatibility delta using GetFileInformationByHandle() to distinguish console streams from redirected files, and that attachment landed unchanged as 58651d8dd6, with Juan credited as reviewer #26.
- At the end of the thread, Michael confirmed that the compatibility fix had landed and the jacana and fairywren buildfarm warnings were gone; both functional fixes were committed, while the separate TAP test remained an uncommitted proposal with review questions outstanding #29 #22 #23 #24.