Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBjvr-0006DY-Ne for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Nov 2016 15:02:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cBjvr-0002xn-AV for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Nov 2016 15:02:55 +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.84_2) (envelope-from ) id 1cBjvp-0002tV-2C for pgsql-hackers@postgresql.org; Tue, 29 Nov 2016 15:02:53 +0000 Received: from verite.pro ([195.154.189.246] helo=genius-map.net) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBjvk-0005GK-I8 for pgsql-hackers@postgresql.org; Tue, 29 Nov 2016 15:02:52 +0000 Received: by genius-map.net (Postfix, from userid 1001) id 7001838A05DD; Tue, 29 Nov 2016 16:02:46 +0100 (CET) Content-Type: text/plain; charset="iso-8859-15" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: pg_dump / copy bugs with "big lines" ? From: "Daniel Verite" To: "Alvaro Herrera" Cc: "Tomas Vondra" ,"Craig Ringer" ,"Tom Lane" ,"Robert Haas" ,"Jim Nasby" ,"Ronan Dunklau" ,"pgsql-hackers" In-Reply-To: <20161128170029.npsjil5emwf4uojc@alvherre.pgsql> Date: Tue, 29 Nov 2016 16:02:45 +0100 Message-Id: <9cfb98ae-e4a4-4654-bf1a-d37e7d27c075@manitou-mail.org> X-Mailer: Manitou v1.6.0 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Alvaro Herrera wrote: > But I realized that doing it this way is simple enough; > and furthermore, in any platforms where int is 8 bytes (ILP64), this > would automatically allow for 63-bit-sized stringinfos On such platforms there's the next problem that we can't send COPY rows through the wire protocol when they're larger than 2GB. Based on the tests with previous iterations of the patch that used int64 for the StringInfo length, the COPY backend code does not gracefully fail in that case. What happened when trying (linux x86_64) with a 2GB-4GB row is that the size seems to overflow and is sent as a 32-bit integer with the MSB set, which is confusing for the client side (at least libpq cannot deal with it). If we consider what would happen with the latest patch on a platform with sizeof(int)=3D8 and a \copy invocation like this: \copy (select big,big,big,big,big,big,big,big,...... FROM (select lpad('', 1024*1024*200) as big) s) TO /dev/null if we put enough copies of "big" in the select-list to grow over 2GB, and then over 4GB. On a platform with sizeof(int)=3D4 this should normally fail over 2GB with "Cannot enlarge string buffer containing $X bytes by $Y more bytes" I don't have an ILP64 environment myself to test, but I suspect it would malfunction instead of cleanly erroring out on such platforms. One advantage of hardcoding the StringInfo limit to 2GB independantly of sizeof(int) is to basically avoid the problem. Also, without this limit, we can "COPY FROM/TO file" really huge rows, 4GB and beyond, like I tried successfully during the tests mentioned upthread (again with len as int64 on x86_64). So such COPYs would succeed or fail depending on whether they deal with a file or a network connection. Do we want this difference in behavior? (keeping in mind that they will both fail anyway if any individual field in the row is larger than 1GB) Best regards, --=20 Daniel V=E9rit=E9 PostgreSQL-powered mailer: http://www.manitou-mail.org Twitter: @DanielVerite --=20 Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers