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 1rA8GV-004xBQ-Bt for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Dec 2023 12:41:35 +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 1rA8GR-00GdC5-3A for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Dec 2023 12:41:31 +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 1rA8GQ-00GdBx-FX for pgsql-hackers@lists.postgresql.org; Mon, 04 Dec 2023 12:41:30 +0000 Received: from mail-qv1-xf2e.google.com ([2607:f8b0:4864:20::f2e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rA8GK-008kL3-VB for pgsql-hackers@postgresql.org; Mon, 04 Dec 2023 12:41:28 +0000 Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-67abaab0bc7so8403346d6.2 for ; Mon, 04 Dec 2023 04:41:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1701693683; x=1702298483; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:subject:from:references:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=L5jwGu7ArI1sW8nKiiw+xV+j6lLm8wYVK7yFiL/asu4=; b=YhtNYhEMcHqQS/Zb1jh6OBT27Dsyx25PAvFX+O6qKUjqxgQxcKKH7Yz0/TRQct2aNM NfZDECJxJxYWBzcrf8b/anPh2ecqTluUiLm0F5eCS6U/WLsiAV0d8JkpZwnJsoqtakOu jlpTmn4RnwaWIift7N01joywNlfvlPaBvu75dGURExIDYNzNoqWxRTtLII24lN96Ua76 XtRpjeCWENBWC/aY96mo0sC5f+ENbkjIpiy5RRgRAF3zysph7uY4SIFA0LDnJzzMPaiJ eqZS1YoIbLcPV/PlYVK/0ePqv/GfNsQJkozhBXDPajdzXIT/dlNnBM9ZKWajTh7NN5Qh wGWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701693683; x=1702298483; h=content-transfer-encoding:in-reply-to:subject:from:references:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=L5jwGu7ArI1sW8nKiiw+xV+j6lLm8wYVK7yFiL/asu4=; b=FeSjnjfUT5VeaHwqR1SLL7w7ZsK8S6RrZ3/pPd6xpAASo16ELKMWOLQazSMxd/zepF 5c1yd09Pim7TNX/bhiLKW5DP2Rea+zsDyAy3FG+zq7RjBWvlDHkFlG7bZ8XvHwkpK+Vm O+i2Kl6N+8Uca+Rx4GD3n+5WsgJLAvvLJcSTazU17LqHtUBau4IfDngI3ry6bsc0N+T1 ZBb7ayeYggOy5ALTCE4OFzqoQOzD1gKZaqTY5hLPskzG4+xuGmCFyFeboE6I9f865Jhv k//wDDJ8TeebYdl4+DcbPvnUSBz5dePzc1FjhK0rgW4BYA7g2L/+Xq+37M+u3WNf4Okz xmZw== X-Gm-Message-State: AOJu0Ywj4iLOE05U4HkULfB47tQQfwV9hzSDZO1XpyktHV0fAcyCyHpv H7gQIyYD8M/YFaMhL789v7rKZg== X-Google-Smtp-Source: AGHT+IHfIAIUjAHocHlDCR1jzOn62Eei+Lw2buBO4NS3dXsT4To/yYXJAdc7qdGSxmkEHpeuIYkZcQ== X-Received: by 2002:a05:6214:1889:b0:67a:5cc9:938b with SMTP id cx9-20020a056214188900b0067a5cc9938bmr4324888qvb.57.1701693683014; Mon, 04 Dec 2023 04:41:23 -0800 (PST) Received: from ?IPV6:2605:a601:91bc:f600::2bb? ([2605:a601:91bc:f600::2bb]) by smtp.googlemail.com with ESMTPSA id z24-20020ac84558000000b004181e5a724csm4238869qtn.88.2023.12.04.04.41.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Dec 2023 04:41:22 -0800 (PST) Message-ID: <9c77b6fa-ee88-b2e6-0fa7-4fc81721da35@dunslane.net> Date: Mon, 4 Dec 2023 07:41:20 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: Joe Conway , Davin Shearer , PostgreSQL-development References: <3853387.1701096982@sss.pgh.pa.us> <3a98decf-3fe3-4b49-9b68-fda01338872c@sedlakovi.org> <24e3ee88-ec1e-421b-89ae-8a47ee0d2df1@joeconway.com> <7117a356-916c-4cf3-bad8-861490e65dcf@joeconway.com> From: Andrew Dunstan Subject: Re: Emitting JSON to file using COPY TO In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-12-03 Su 20:14, Joe Conway wrote: > (please don't top quote on the Postgres lists) > > On 12/3/23 17:38, Davin Shearer wrote: >> " being quoted as \\" breaks the JSON. It needs to be \".  This has >> been my whole problem with COPY TO for JSON. >> >> Please validate that the output is in proper format with correct >> quoting for special characters. I use `jq` on the command line to >> validate and format the output. > > I just hooked existing "row-to-json machinery" up to the "COPY TO" > statement. If the output is wrong (just for for this use case?), that > would be a missing feature (or possibly a bug?). > > Davin -- how did you work around the issue with the way the built in > functions output JSON? > > Andrew -- comments/thoughts? > > I meant to mention this when I was making comments yesterday. The patch should not be using CopyAttributeOutText - it will try to escape characters such as \, which produces the effect complained of here, or else we need to change its setup so we have a way to inhibit that escaping. cheers andrew > > -- Andrew Dunstan EDB: https://www.enterprisedb.com