pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Dmitry Koval <d.koval@postgrespro.ru>
Cc: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17288: PSQL bug with COPY command (Windows)
Date: Mon, 29 Nov 2021 15:51:39 +0900
Message-ID: <YaR4e1Pj6wAt+fPT@paquier.xyz> (raw)
In-Reply-To: <20211129050122.GK17618@telsasoft.com>
References: <9caa0612-19e5-f860-4b97-908a1c721233@postgrespro.ru>
	<CAC+AXB1FTZueNdvT1F4fpr4z9gxpcKkgWa-Awor9XC9PAKLVSA@mail.gmail.com>
	<YZiGIxk5F3TT/OJc@paquier.xyz>
	<ff540eb5-3493-cf02-6c22-20ef6e15fee9@postgrespro.ru>
	<CAC+AXB2GfM3NGjx7vc+=UvbD_bzQheiPqk2BQiFRn7G0oVUDhA@mail.gmail.com>
	<c97531c7-a439-78b5-33e6-6aab5a900949@postgrespro.ru>
	<YZ3Cm7PKGesAitYN@paquier.xyz>
	<b108ffee-53b7-f11d-4110-1c2a72fa63b2@postgrespro.ru>
	<YZ8BvVysOLJcTP16@paquier.xyz>
	<20211129050122.GK17618@telsasoft.com>

On Sun, Nov 28, 2021 at 11:01:22PM -0600, Justin Pryzby wrote:
> Do you know this causes a new warning ?

No, I did not know that.

> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=jacana&dt=2021-11-29%2004%3A00%3A29
> 
> Nov 28 23:06:41 c:/mingw/msys/1.0/home/pgrunner/bf/root/HEAD/pgsql.build/../pgsql/src/port/win32stat.c:309:3: warning: implicit declaration of function 'GetFinalPathNameByHandleA'; did you mean 'GetFullPathNameA'? [-Wimplicit-function-declaration]
> ...

Hmm.  Looking at MinGW, mingw-w64-headers/include/fileapi.h includes
GetFinalPathNameByHandleA() as long as _WIN32_WINNT >= 0x0600, so this
stuff is not going to work when we are under an older _WIN32_WINNT as
it seems to be the case here.  I have missed that.

We know that GetFileInformationByHandle() would be able to work in
the scope of win32stat.c as it is supported down to Windows XP so we
would be covered, so switching to that instead of
GetFinalPathNameByHandleA() would take care of the problem.  Better to
call that only for a standard stream, only for the emulation of
fstat(), in the spirit of the original fix.
--
Michael

Attachments:

mingw-fstat-fix.patch (text/x-diff, 735B) download diff --git a/src/port/win32stat.c b/src/port/win32stat.c index 3956fac060..426e01f0ef 100644 --- a/src/port/win32stat.c +++ b/src/port/win32stat.c @@ -289,7 +289,7 @@ int _pgfstat64(int fileno, struct stat *buf) { HANDLE hFile = (HANDLE) _get_osfhandle(fileno); - char path[MAX_PATH]; + BY_HANDLE_FILE_INFORMATION fiData; if (hFile == INVALID_HANDLE_VALUE || buf == NULL) { @@ -306,7 +306,7 @@ _pgfstat64(int fileno, struct stat *buf) if ((fileno == _fileno(stdin) || fileno == _fileno(stdout) || fileno == _fileno(stderr)) && - GetFinalPathNameByHandleA(hFile, path, MAX_PATH, VOLUME_NAME_NT) == 0) + !GetFileInformationByHandle(hFile, &fiData)) { memset(buf, 0, sizeof(*buf)); buf->st_mode = _S_IFCHR;
signature.asc (application/pgp-signature, 832B) download

view thread (29+ messages)  latest in thread

Message-ID: <YaR4e1Pj6wAt+fPT@paquier.xyz>
Permalink:  ../YaR4e1Pj6wAt+fPT@paquier.xyz/
Also on:    postgresql.org/message-id/YaR4e1Pj6wAt+fPT@paquier.xyz

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: michael@paquier.xyz, pryzby@telsasoft.com, d.koval@postgrespro.ru, juanjo.santamaria@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17288: PSQL bug with COPY command (Windows)
  In-Reply-To: <YaR4e1Pj6wAt+fPT@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox