Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TdP2b-0002hD-FE for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Nov 2012 17:33:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TdP2a-0002eU-GU for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Nov 2012 17:33:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TdP2Z-0002eP-Vg for pgsql-bugs@postgresql.org; Tue, 27 Nov 2012 17:33:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TdP2Y-0005XP-0F for pgsql-bugs@postgresql.org; Tue, 27 Nov 2012 17:33:47 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id qARHXiZO024680; Tue, 27 Nov 2012 12:33:44 -0500 (EST) From: Tom Lane To: tgarnett@panjiva.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #7709: psql \copy csv terminates with \. in quoted region In-reply-to: References: Comments: In-reply-to tgarnett@panjiva.com message dated "Tue, 27 Nov 2012 15:55:28 +0000" Date: Tue, 27 Nov 2012 12:33:44 -0500 Message-ID: <24679.1354037624@sss.pgh.pa.us> X-Pg-Spam-Score: -2.3 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org tgarnett@panjiva.com writes: > psql \copy terminates at \. by itself in a line even if the format is csv > and the \. is inside a quoted region. This means that some values can't be > round-tripped by psql \copy. Tested and the native postgresql COPY handles > this case correctly. Ugh. This seems like a rather fundamental oversight in the CSV feature. The problem is that psql has no idea whether the copy is being done in CSV mode or not --- and even if it did, it doesn't parse the data fully enough to realize whether a \. line is inside quotes or not. In the case of out-of-line data files, it might be reasonable to just dispense with the check for \. altogether and always ship the whole file to the backend; I think there's a \. check on the backend side. (Not sure this is safe in V2 protocol, but I doubt anyone cares anymore about that.) In the case of in-line data in a script file, CSV mode seems a bit broken in any case; there's no concept of a terminator in CSV, AFAIK. So maybe we don't have to worry about that. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs