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 1gDurn-0003V8-Pk for pgsql-jdbc@arkaria.postgresql.org; Sat, 20 Oct 2018 17:16:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gDurk-0004HQ-6c for pgsql-jdbc@arkaria.postgresql.org; Sat, 20 Oct 2018 17:16:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gDurj-0004HJ-TS for pgsql-jdbc@lists.postgresql.org; Sat, 20 Oct 2018 17:16:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gDurg-0002MP-OG for pgsql-jdbc@postgresql.org; Sat, 20 Oct 2018 17:16:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w9KHGWRC013327; Sat, 20 Oct 2018 13:16:32 -0400 From: Tom Lane To: "David G. Johnston" cc: Dave Cramer , "Gerson.Stadlmann@ifco.com" , List Subject: Re: Bug in JDBC.driver CopyManager method when copying json output In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Sat, 20 Oct 2018 07:44:05 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <13325.1540055792.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 20 Oct 2018 13:16:32 -0400 Message-ID: <13326.1540055792@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "David G. Johnston" writes: > The backend is respecting the documented meanings and usage of the QUOTE > and ESCAPE options of COPY. Yeah, I don't see any bug here. You've got one layer of backslash-quoting that is required by JSON string syntax, and then a second layer that is imposed by COPY's text format. > Not sure what a JSON mode would look like though I=E2=80=99m thinking it= =E2=80=99s not what > was described here... I can't see how that would do anything except move the pain somewhere else. Multiple quoting layers always result in "ugly" output (but if the receipient is correctly coded and reverses the operations in the right sequence, the same underlying data will emerge). The OP might want to consider using COPY BINARY, which uses a length prefix instead of character-escaping to keep fields separate. Still, though, this is fundamentally just cosmetic. If you don't apply the correct reverse conversion steps in the correct order, you won't get the right results. regards, tom lane