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 1rAttJ-008eJO-TC for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Dec 2023 15:32:49 +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 1rAttI-00AX37-Jp for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Dec 2023 15:32:48 +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 1rAttI-00AX2z-4m for pgsql-hackers@lists.postgresql.org; Wed, 06 Dec 2023 15:32:48 +0000 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rAttE-0096I4-UD for pgsql-hackers@postgresql.org; Wed, 06 Dec 2023 15:32:46 +0000 Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-423e77aa09cso6372651cf.1 for ; Wed, 06 Dec 2023 07:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1701876763; x=1702481563; 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=dhb5nsu4vxB4trHNjl25pxdv1SADnsNazU/Kmt0l/GA=; b=Ai2pNzeLC4XxuQoWmM5heNvHJkqk/f2h8ddDBf0b8M0bVueImp9oc18uy4lb+LNlkT IKC+hSbYPjEGmI0kOzDC/+aP0Ajxe3ZsVGQOcg1wlqehVJhzOD6w2E6AIPqZJF+TW6ic Ca28j51hnt7CWtH21F8+DWCaFCbvovnVUne+/iQU2TjvpK1Zjb3L0OMrZrKoM4Kcd5jm ULR1t0+N2dPJaflk/zxSddSk+o1wbUbHsHH0x861NXT5DSZA5lVhEaBx+0HhWK81eHlZ YRlwCk/9NwZP4Cm4Uy6Jd1X38nezvyWSo7uijSLh7DAsuDjOZIl8SIznfdSkY7PfmSiM NQXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701876763; x=1702481563; 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=dhb5nsu4vxB4trHNjl25pxdv1SADnsNazU/Kmt0l/GA=; b=LoOjAVpKIwJEOxlSLRA8+6sBLrrnHVfkfsYqdAsONNxix4LY5cNjrcUmUWw49PlKt8 WJ24iKLeCjT4J38QcO/GvvSQzLMruEgNLPT25SK6H6aZzRxhVinGBUdLXBq16QiGPAet MUX8P4o3ZK5kOi1laH1MWsUhjnuUONjIR2EcnDb60z4dFJFpHnMCZsRzmRRX93s0cwuD jYqs/ZAC4EMIz5PxSq2BZYpBsSXZbSPm42zUU74IIC8mKNF49f2rt5NH+JW8e62YzN9o T1RXhGt0ZlZIEcCmntP5uE8zVoQnPGc7auzQif1mmknmqMWu1ARaINW7YzR/m6bZFi5m xu0g== X-Gm-Message-State: AOJu0YxBWEUN24lsljAzP1tJzEjeAoAujNXYw7Y0JHRw5ML71rkvQp1P c2HhaqqdaiPw9WApWm/QNfR/SQ== X-Google-Smtp-Source: AGHT+IH2RBhn1X6vUkRtbVRPcNRLyzQhKfg32VsBhnk1zBprlNF5D4ckA1Bu4KMjW/W+7Dbf9QDlHw== X-Received: by 2002:ac8:7d88:0:b0:41e:1b18:f4a2 with SMTP id c8-20020ac87d88000000b0041e1b18f4a2mr1176008qtd.36.1701876763483; Wed, 06 Dec 2023 07:32:43 -0800 (PST) Received: from ?IPV6:2605:a601:91bc:f600::2bb? ([2605:a601:91bc:f600::2bb]) by smtp.googlemail.com with ESMTPSA id g7-20020ac84807000000b004258264d166sm28991qtq.60.2023.12.06.07.32.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Dec 2023 07:32:43 -0800 (PST) Message-ID: Date: Wed, 6 Dec 2023 10:32:41 -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: <5c84b70b-ba18-c45d-dbbe-612fa229b2ce@dunslane.net> <398c22f6-4299-4b17-80bf-2f14f4afd592@joeconway.com> <46cc4507-a0d9-4044-b2ce-5a8bca8015c0@joeconway.com> <2554e520-e103-8978-dcb5-807dfeb77402@dunslane.net> <926ff917-8371-40ec-b5e6-ab7b0e09bdc5@joeconway.com> <315b81d4-4b67-7828-0355-3808cd14acd1@dunslane.net> <7a60faf6-e7f1-419d-aee6-10a78ea2fe81@joeconway.com> <2e7ff718-895d-83fc-46f7-be25e23b23b4@dunslane.net> 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: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-12-06 We 08:49, Joe Conway wrote: > On 12/6/23 07:36, Andrew Dunstan wrote: >> >> On 2023-12-05 Tu 16:46, Joe Conway wrote: >>> On 12/5/23 16:20, Andrew Dunstan wrote: >>>> On 2023-12-05 Tu 16:09, Joe Conway wrote: >>>>> On 12/5/23 16:02, Joe Conway wrote: >>>>>> On 12/5/23 15:55, Andrew Dunstan wrote: >>>>>>> and in any other case (e.g. LINES) I can't see why you >>>>>>> would have them. >>>>> >>>>> Oh I didn't address this -- I saw examples in the interwebs of >>>>> MSSQL server I think [1] which had the non-array with commas >>>>> import and export style. It was not that tough to support and the >>>>> code as written already does it, so why not? >>>> >>>> That seems quite absurd, TBH. I know we've catered for some >>>> absurdity in >>>> the CSV code (much of it down to me), so maybe we need to be >>>> liberal in >>>> what we accept here too. IMNSHO, we should produce either a single >>>> JSON >>>> document (the ARRAY case) or a series of JSON documents, one per row >>>> (the LINES case). >>> >>> So your preference would be to not allow the non-array-with-commas >>> case but if/when we implement COPY FROM we would accept that format? >>> As in Postel'a law ("be conservative in what you do, be liberal in >>> what you accept from others")? >> >> >> Yes, I think so. > > Awesome. The attached does it that way. I also ran pgindent. > > I believe this is ready to commit unless there are further comments or > objections. Sorry to bikeshed a little more, I'm a bit late looking at this. I suspect that most users will actually want the table as a single JSON document, so it should probably be the default. In any case FORCE_ARRAY as an option has a slightly wrong feel to it. I'm having trouble coming up with a good name for the reverse of that, off the top of my head. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com