postgresql/src
Michael Paquier 10260c794b Fix fstat() emulation on Windows with standard streams
The emulation of fstat() in win32stat.c caused two issues with the
existing in-core callers, failing on EINVAL when using a stream as
argument:
- psql's \copy would crash when using a stream.
- pg_recvlogical would fail with -f -.

The tests in copyselect.sql from the main test suite covers the first
case, and there is a TAP test for the second case.  However, in both
cases, as the standard streams are always redirected, automated tests
did not notice those issues, requiring a terminal on Windows to be
reproducible.

This issue has been introduced in bed9075, and the origin of the problem
is that GetFileInformationByHandle() does not work directly on streams,
so this commit adds an extra code path to emulate and return a set of
stats that match best with the reality.  Note that redirected streams
rely on handles that can be queried with GetFileInformationByHandle(),
but we can rely on GetFinalPathNameByHandleA() to detect this case.

Author: Dmitry Koval, Juan José Santamaría Flecha
Discussion: https://postgr.es/m/17288-6b58a91025a8a8a3@postgresql.org
Backpatch-through: 14
2021-11-25 12:16:21 +09:00
..
backend Replace straggling uses of ReadRecPtr/EndRecPtr. 2021-11-24 16:56:14 -08:00
bin Remove useless LZ4 system call on failure when writing file header 2021-11-24 20:12:54 +09:00
common Allow psql's other uses of simple_prompt() to be interrupted by ^C. 2021-11-19 12:11:46 -05:00
fe_utils Replace unicode characters in comments with ascii 2021-11-01 22:42:49 +01:00
include Flush Memoize cache when non-key parameters change, take 2 2021-11-24 23:29:14 +13:00
interfaces Remove check for accept() argument types 2021-11-09 15:35:26 +01:00
makefiles Add NO_INSTALL option to pgxs 2021-05-27 13:58:29 +02:00
pl plpgsql: report proper line number for errors in variable initialization. 2021-10-31 12:43:47 -04:00
port Fix fstat() emulation on Windows with standard streams 2021-11-25 12:16:21 +09:00
template Further tweaking of PG_SYSROOT heuristics for macOS. 2021-01-20 12:07:23 -05:00
test Flush Memoize cache when non-key parameters change, take 2 2021-11-24 23:29:14 +13:00
timezone Update time zone data files to tzdata release 2021e. 2021-10-29 11:38:18 -04:00
tools Add support for Visual Studio 2022 in build scripts 2021-11-24 13:03:23 +09:00
tutorial doc: Prefer explicit JOIN syntax over old implicit syntax in tutorial 2021-04-08 10:51:26 +02:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Add support for LZ4 compression in pg_receivewal 2021-11-05 11:33:25 +09:00
Makefile.shlib AIX: Fix missing libpq symbols by respecting SHLIB_EXPORTS. 2021-09-06 11:27:59 -07:00
nls-global.mk Add errhint_plural() function and make use of it 2021-03-31 09:16:25 +02:00