Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gItqX-0000xO-98 for pgsql-bugs@arkaria.postgresql.org; Sat, 03 Nov 2018 11:12:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gItqU-0002PF-JC for pgsql-bugs@arkaria.postgresql.org; Sat, 03 Nov 2018 11:12:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gItqU-0002P8-CZ for pgsql-bugs@lists.postgresql.org; Sat, 03 Nov 2018 11:12:02 +0000 Received: from mail.verite.pro ([185.16.44.216]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gItqR-0004Iw-RE for pgsql-bugs@lists.postgresql.org; Sat, 03 Nov 2018 11:12:02 +0000 Received: from genius-map.net (verite.pro [195.154.189.246]) by mail.verite.pro (Postfix) with ESMTP id B71B78C01AF; Sat, 3 Nov 2018 12:07:29 +0100 (CET) Received: by genius-map.net (Postfix, from userid 1001) id 889AA38A0610; Sat, 3 Nov 2018 12:11:57 +0100 (CET) Content-Type: text/plain; charset="iso-8859-15" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: Unable to copy large (>2GB) files using PostgreSQL 11 (Windows) From: "Daniel Verite" To: "Michael Paquier" Cc: "Alistair Johnson" ,pgsql-bugs@lists.postgresql.org In-Reply-To: <20181102233512.GD1899@paquier.xyz> Date: Sat, 03 Nov 2018 12:11:53 +0100 Message-Id: X-Mailer: Manitou v1.7.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michael Paquier wrote: > Windows portability problems with stat() makes this problem way harder > than it looks at first glance, because it also uses a "stat" structure > which is not able to store the size of files larger than 2GB FWIW I don't reproduce the problem with a self-compiled PostgreSQL 11.0 with the MSYS2/mingw64 toolchain on a Windows 10 64-bit desktop. But I do get the error when using PG 11.0 packaged by EDB and trying the same test on the same machine (that is, \copy table from file with a file a bit over 2GB). The error seems to be emited at the point of this fstat() call in psql/copy.c: /* make sure the specified file is not a directory */ if ((result =3D fstat(fileno(copystream), &st)) < 0) psql_error("could not stat file \"%s\": %s\n", options->file,=20 Note that it's fstat() rather than stat(). A quick git grep -w seems to show that fstat() doesn't go through the same kind of aliasing that can make stat() a macro actually calling pgwin32_safestat(). Best regards, --=20 Daniel V=E9rit=E9 PostgreSQL-powered mailer: http://www.manitou-mail.org Twitter: @DanielVerite