The internal implementation of _pgstat64() is used in quite a few
places, so we'd better update this part first, IMO, and then focus on the pg_dump part. Anyway, it looks like you are right here: there is nothing for FILE_TYPE_PIPE or FILE_TYPE_CHAR in this WIN32 implementation of fstat().
I am amazed to hear that both ftello64() and fseek64() actually succeed if you use a pipe: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fseek.html Could it be something we should try to make more portable by ourselves with a wrapper for these on WIN32? That would not be the first one to accomodate our code with POSIX, and who knows what code could be broken because of that, like external extensions that use fseek64() without knowing it.
The error is reproducible in versions previous to win32stat.c, so that might work as bug fix.
I've broken the patch in two:
1. fixes the detection of unseekable files in checkSeek(), using logic that hopefully is backpatchable,
2. the improvements on file type detection for stat() proposed by the OP.