postgresql/src/tools
Michael Paquier 34105eea62 Fix detection of unseekable files for fseek() and ftello() with MSVC
Calling fseek() or ftello() on a handle to a non-seeking device such as
a pipe or a communications device is not supported.  Unfortunately,
MSVC's flavor of these routines, _fseeki64() and _ftelli64(), do not
return an error when given a pipe as handle.  Some of the logic of
pg_dump and restore relies on these routines to check if a handle is
seekable, causing failures when passing the contents of pg_dump to
pg_restore through a pipe, for example.

This commit introduces wrappers for fseeko() and ftello() on MSVC so as
any callers are able to properly detect the cases of non-seekable
handles.  This relies mainly on GetFileType(), sharing a bit of code
with the MSVC port for fstat().  The code in charge of getting a file
type is refactored into a new file called win32common.c, shared by
win32stat.c and the new win32fseek.c.  It includes the MSVC ports for
fseeko() and ftello().

Like 765f5df, this is backpatched down to 14, where the fstat()
implementation for MSVC is able to understand about files larger than
4GB in size.  Using a TAP test for that is proving to be tricky as
IPC::Run handles the pipes by itself, still I have been able to check
the fix manually.

Reported-by: Daniel Watzinger
Author: Juan José Santamaría Flecha, Michael Paquier
Discussion: https://postgr.es/m/CAC+AXB26a4EmxM2suXxPpJaGrqAdxracd7hskLg-zxtPB50h7A@mail.gmail.com
Backpatch-through: 14
2023-04-12 09:09:58 +09:00
..
editors Make Emacs perl-mode indent more like perltidy. 2019-01-13 11:32:31 -08:00
ifaddrs Update copyright for 2021 2021-01-02 13:06:25 -05:00
msvc Fix detection of unseekable files for fseek() and ftello() with MSVC 2023-04-12 09:09:58 +09:00
perlcheck Stop requiring an explicit return from perl subroutines 2020-04-14 16:55:34 -04:00
pginclude Remove extraneous newlines added by perl copyright patch 2021-05-07 11:37:37 -04:00
pgindent Revert "Fix replay of create database records on standby" 2022-03-29 15:36:21 +02:00
PerfectHash.pm Update copyright for 2021 2021-01-02 13:06:25 -05:00
RELEASE_CHANGES Add list of ignorable pgindent commits for git-blame. 2021-06-22 09:06:32 -07:00
ccsym tools/ccsym: update for modern versions of gcc 2015-01-20 13:02:58 -05:00
check_bison_recursion.pl Update copyright for 2021 2021-01-02 13:06:25 -05:00
codelines Fix remaining stray references to CVS. 2010-09-22 19:51:39 -04:00
copyright.pl Update copyright for 2021 2021-01-02 13:06:25 -05:00
find_badmacros Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
find_static Fix omission of -X (--no-psqlrc) in some psql invocations. 2015-12-28 11:46:43 -05:00
find_typedef Refer to OS X as "macOS", except for the port name which is still "darwin". 2016-09-25 15:40:57 -04:00
fix-old-flex-code.pl Update copyright for 2021 2021-01-02 13:06:25 -05:00
gen_keywordlist.pl Update copyright for 2021 2021-01-02 13:06:25 -05:00
git-external-diff Preserve information on use of git-external-diff 2018-05-24 23:45:31 +09:30
git_changelog Remove extraneous newlines added by perl copyright patch 2021-05-07 11:37:37 -04:00
make_ctags Improve missing-program error handling in make_ctags and make_etags. 2019-01-13 13:33:50 -05:00
make_etags Improve missing-program error handling in make_ctags and make_etags. 2019-01-13 13:33:50 -05:00
make_mkid Add another pgdefine path check, and a cvs-git change. 2011-08-26 21:52:35 -04:00
pgtest pgtest: run clean, build, and check stages separately 2018-07-28 15:34:06 -04:00
testint128.c Update copyright for 2021 2021-01-02 13:06:25 -05:00
valgrind.supp Avoid need for valgrind suppressions for pg_atomic_init_u64 on some platforms. 2020-06-08 19:52:19 -07:00
version_stamp.pl Update copyright for 2021 2021-01-02 13:06:25 -05:00
win32tzlist.pl Update copyright for 2021 2021-01-02 13:06:25 -05:00