Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAx7D-008rUB-6C for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Dec 2023 18:59:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rAx7B-00C5ie-RQ for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Dec 2023 18:59:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAx7B-00C5iW-Gh for pgsql-hackers@lists.postgresql.org; Wed, 06 Dec 2023 18:59:21 +0000 Received: from mail.verite.pro ([185.16.44.216]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAx78-0097oK-Mc for pgsql-hackers@postgresql.org; Wed, 06 Dec 2023 18:59:20 +0000 Received: by mail.verite.pro (Postfix, from userid 1000) id 9573D8C01DE; Wed, 6 Dec 2023 19:59:15 +0100 (CET) Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "Daniel Verite" Subject: Re: Emitting JSON to file using COPY TO To: "Andrew Dunstan" Cc: Joe Conway , Davin Shearer , PostgreSQL-development In-Reply-To: <315b81d4-4b67-7828-0355-3808cd14acd1@dunslane.net> Date: Wed, 06 Dec 2023 19:59:11 +0100 Message-Id: X-Mailer: Manitou v1.7.3 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrew Dunstan wrote: > IMNSHO, we should produce either a single JSON=20 > document (the ARRAY case) or a series of JSON documents, one per row=20 > (the LINES case). "COPY Operations" in the doc says: " The backend sends a CopyOutResponse message to the frontend, followed by zero or more CopyData messages (always one per row), followed by CopyDone". In the ARRAY case, the first messages with the copyjsontest regression test look like this (tshark output): PostgreSQL Type: CopyOut response Length: 13 Format: Text (0) Columns: 3 Format: Text (0) PostgreSQL Type: Copy data Length: 6 Copy data: 5b0a PostgreSQL Type: Copy data Length: 76 Copy data: 207b226964223a312c226631223a226c696e652077697468205c2220696e2069743a2031=E2= =80=A6 The first Copy data message with contents "5b0a" does not qualify as a row of data with 3 columns as advertised in the CopyOut message. Isn't that a problem? At least the json non-ARRAY case ("json lines") doesn't have this issue, since every CopyData message corresponds effectively to a row in the table. [1] https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-COPY Best regards, --=20 Daniel V=C3=A9rit=C3=A9 https://postgresql.verite.pro/ Twitter: @DanielVerite