From 8da89bdbdc83c7bd12d0a64661f755445d4690b3 Mon Sep 17 00:00:00 2001 From: Juan Jose Santamaria Flecha Date: Thu, 9 Mar 2023 17:59:05 -0500 Subject: [PATCH] fix chechSeek for WIN32 Fix checkSeek() detection of unseekable devices on Windows --- src/bin/pg_dump/pg_backup_archiver.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 61ebb8f..a9958df 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -3808,6 +3808,7 @@ ReadHead(ArchiveHandle *AH) bool checkSeek(FILE *fp) { +#ifndef WIN32 pgoff_t tpos; /* Check that ftello works on this file */ @@ -3822,6 +3823,15 @@ checkSeek(FILE *fp) */ if (fseeko(fp, tpos, SEEK_SET) != 0) return false; +#else + /* + * Calling lseek() on a handle to a non-seeking device such as a pipe or + * a communications device is not supported, even though the lseek() may + * not return an error. + */ + if (GetFileType(_get_osfhandle(fileno(fp))) != FILE_TYPE_DISK) + return false; +#endif return true; } -- 2.11.0