Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mraW2-0006SC-Ac for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Nov 2021 06:51:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mraW0-0007Fv-RJ for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Nov 2021 06:51:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mraVz-0007Fm-Bk for pgsql-bugs@lists.postgresql.org; Mon, 29 Nov 2021 06:51:52 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mraVv-0000a1-FA for pgsql-bugs@lists.postgresql.org; Mon, 29 Nov 2021 06:51:49 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 7450F5C008F; Mon, 29 Nov 2021 01:51:45 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 29 Nov 2021 01:51:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=5YCsKRvA8N9EAxDsFDnZJ+eeSxL WYqPtttc151ICIB0=; b=tTaHD+CsDPI8GE97FDZolIpnDt+mFhDJZQ/8YEfZSh2 YwXqn6KIYqAN1yNXB+AMOL1PCJGEUiIqHOX8L79fOmCxeK2FKTy4JZBhhsT9Yuqv 9YxM/ZjF1FXfzixRpIjUwN+z9I98u4UpPYb6cDyqhLBoEjFbxFEvpqe8f+U4NVc8 ReisU/21dHl5UsvKN9D0svb+emQ7JiUvizgCpEFdaNWuQZxDkZiZjpJDfALVNFYv J47YntpfBXFRuJOoT4Z8DVRHiZQ9HeJdaX6fnhIL7GYVEWD1gceAYfRsV95ZPIfZ yjanVa5KpegM1wSsu6iGxswIcDCZgzqFfbeK0fxSQUQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=5YCsKR vA8N9EAxDsFDnZJ+eeSxLWYqPtttc151ICIB0=; b=Y20kcKq6nThZnoPbPe9Ujf uXqoigWRnbhMQXOSIAYgm1m/yk3knJsrTuDBbBdWEdAHw5PFS5wx+8aYDkF3R1bZ lCFxGhfM39ZzBCHLm+AP+BbugY7CuDwNYpqACy6DLwBZodDuoCQOfdrZFDeziG9S AQQ97ehDSEgnUcg27CFefwYRqm9vf1P3VW71ugOMXM61L7uKr7iV0NgzGvzXDKCb RbjykMvM/a06irmZum1H0akWbX1fcTPvotnoXpR8+P+6ei5Bv78s1Otxe4nP2odV sZyI5w5nlJTkQKsBuJnEgEMdLXrMButhQFmYRHWQh3VX7P5+7bRzzG5nUIyM4cww == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrheekgdefkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdefhedmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepkeefueffkedtgfeuffeitdffffef teeivdfhvefhvdejteetteegvdejteeuieeunecuffhomhgrihhnpehpohhsthhgrhgvsh hqlhdrohhrghdpphhgshhqlhdrsghuihhlugenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 Nov 2021 01:51:43 -0500 (EST) Date: Mon, 29 Nov 2021 15:51:39 +0900 From: Michael Paquier To: Justin Pryzby Cc: Dmitry Koval , Juan =?iso-8859-1?Q?Jos=E9_Santamar=EDa?= Flecha , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17288: PSQL bug with COPY command (Windows) Message-ID: References: <9caa0612-19e5-f860-4b97-908a1c721233@postgrespro.ru> <20211129050122.GK17618@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5iOpFmj4qamd0NC7" Content-Disposition: inline In-Reply-To: <20211129050122.GK17618@telsasoft.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --5iOpFmj4qamd0NC7 Content-Type: multipart/mixed; boundary="239V1l8xfBB9HhFi" Content-Disposition: inline --239V1l8xfBB9HhFi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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=3Djacana&dt=3D202= 1-11-29%2004%3A00%3A29 >=20 > Nov 28 23:06:41 c:/mingw/msys/1.0/home/pgrunner/bf/root/HEAD/pgsql.build/= =2E./pgsql/src/port/win32stat.c:309:3: warning: implicit declaration of fun= ction 'GetFinalPathNameByHandleA'; did you mean 'GetFullPathNameA'? [-Wimpl= icit-function-declaration] > ... Hmm. Looking at MinGW, mingw-w64-headers/include/fileapi.h includes GetFinalPathNameByHandleA() as long as _WIN32_WINNT >=3D 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 --239V1l8xfBB9HhFi Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="mingw-fstat-fix.patch" Content-Transfer-Encoding: quoted-printable 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 =3D (HANDLE) _get_osfhandle(fileno); - char path[MAX_PATH]; + BY_HANDLE_FILE_INFORMATION fiData; =20 if (hFile =3D=3D INVALID_HANDLE_VALUE || buf =3D=3D NULL) { @@ -306,7 +306,7 @@ _pgfstat64(int fileno, struct stat *buf) if ((fileno =3D=3D _fileno(stdin) || fileno =3D=3D _fileno(stdout) || fileno =3D=3D _fileno(stderr)) && - GetFinalPathNameByHandleA(hFile, path, MAX_PATH, VOLUME_NAME_NT) =3D=3D = 0) + !GetFileInformationByHandle(hFile, &fiData)) { memset(buf, 0, sizeof(*buf)); buf->st_mode =3D _S_IFCHR; --239V1l8xfBB9HhFi-- --5iOpFmj4qamd0NC7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmGkeHsACgkQnvQgOdby QH2fLw//b6P5pLK5L1emRQZoGwmDw8Yc/K3MLpBUdmu5htYdsWJjL6jDTYCW+mRQ uvA4ziqzjxebY6Y8AFbSM38xh5e7+XDI3lqdCQPCqEiweQpE5rCv50Ir4+idZmEK ZmxnAfbcnbQaXnSLmK/GKDJ40SzLiugiEecoHXaLksP1zV5JLSIcWO9qKZbwH9oz x9+mgwHEFZQ1oUnI2NT84sWqTtUi1WPUG4sD4SHPkcf0j644pIvsdvlMi5GjbWov sYVJZpJPuhnzU51X249w4CMLfsAjOy6qryGdeZtHUmtUmb0ePb2/HBxMJhsvozj3 GzDNuUQKR6Em1g+9B4m5hmiHbz6mbA0Hs3rYuMVKBp4LleDKQqlyYep88ryOJxEx auda0NFl3TwSOS5DpWNox/r2Ce8PIZiQu86fkA7J3p6uceBiQIFskulNZZn8AUuT lS5doCv6le+EQA7yFrCqDjbHp9KuXdGcLOAmuv6E9rd1ytBj28/qmdVprX0gijOF elHy3yShelxZjVnwDEHY6G2k+CvM1oins2bw2PD1YLs6Idkr1Mmpzq4ncxsQtx5e 8VQ0S5RNa4hen9iVqB3dYxuwtx94g41ehfYWN+hHgxpwEKrMwZjdA6EbJYbTG5VV rtRnM7d+vYGfOo7sFwAiYIp71xkq8Unq7GNAp3qYLrAcZZReVbo= =TJQ4 -----END PGP SIGNATURE----- --5iOpFmj4qamd0NC7--