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.96) (envelope-from ) id 1voFBi-00HE10-0T for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Feb 2026 06:19:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1voFBf-002Dfy-2N for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Feb 2026 06:19:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1voFBf-002Dfq-14 for pgsql-hackers@lists.postgresql.org; Fri, 06 Feb 2026 06:19:27 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1voFBc-00000001JZ0-2ry1 for pgsql-hackers@postgresql.org; Fri, 06 Feb 2026 06:19:26 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-65815ec51d3so473346a12.2 for ; Thu, 05 Feb 2026 22:19:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770358763; cv=none; d=google.com; s=arc-20240605; b=GUkPYIMX21dnHcJLNjH2gTkGcBMNdjx6sHYFvUHDR1lw3F0qwoYNegrV7aSFBFlNiV Wt6ado1gabqLw12RpnQvmKx350t/5Xwz8akBWWEFFeDkiGNgXLZ7SCBAxGL6eUwEyJrt b1pf9ORP5idWDyODA4ECP6WY3H+IuI6NhAaHr5JP8SdOFCbLyza6NZruJINPaXs7bX0E 5TGX8F0QjtmQzBnzhwaL4fA+h2mVXCw2B9+jjEqXluDToKoqwox7SDtPhdx3nXgHnf/D 4W+eEFUsW9glfz8KECxZG76HeeWfvwnwT4VjdbiyqxQ4vS4b7iLdJWg/FGndm3mfbw8N SAYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=fkKtxaZDHNC9e82MGd8D1V14s96izbYVKH8snNr9XSM=; fh=1xzLOHrwFOC/BlzG48y7VIbGLm41n+EEboorzkEXE/Y=; b=EM/OjZ3yQZNE/LqVM5nZvq8WWG+eo60Gnb2onfSDneiBLstaYdDCKu/rDlgUlt3ilM FO7nj8EGbFhninbW1KQIWX2WuEXXBdlDPCjv72xzc9dVS9PPVG760Pr9IOPCeMMdG/o/ lPBMvxieRCxMPpWq0/ELl2OmXZfO1ZNHWvt3c6NOhhojGCdlpQkT6sRwDmb7fPdrCNDM Sfd4IaHj8sKnCCsccJYKObFXVA44Bdh3rztTl395wNci66vUq5Ks4oqCKDixRvk2y3mc lgX7R6onaONlp2H8GUp0C25mf1GZkcpQjuudubCkCtmKKqAGqgfc+KgZ5Akv5+ZFaIMc qhRw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770358763; x=1770963563; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fkKtxaZDHNC9e82MGd8D1V14s96izbYVKH8snNr9XSM=; b=SwP2ggxq+7yINUZQ2rp6juNKPGX1yJGA9KFIyUsdvURe3FqOKLZSUkE/HeLRP2zREi HQ1gZlP5D7mxXigQ5HkveJZSPECLzlvq++I2VAXmNYStW+W+6JYhZTEh5CLG4Sjyl9Bg iieqnb2okhjlX9Z12o5GfJXvbgfUsYT2yGyOLLPqnENRFdVSGOU9690dbPIV84zQgC1G aiRaeEt2xdnpcZI1FICu+eDD0KAC+0LYxAINNHPDU8mGxiU0Ac6MrwjavPlCOYL9v1GY YcUxLfTWeU6x5vFpxaeMmNfWtBn8+P7yaz3QeDoi682Tk4U/uTLyjcU386izjbgaKIyT oqzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770358763; x=1770963563; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fkKtxaZDHNC9e82MGd8D1V14s96izbYVKH8snNr9XSM=; b=nbmsPJxGFG8DfO3osl2Kei+obF8I0GzMu/98bmBGnCgC+XPd4X9haWypElHsu9LTsX ikncDW2Jn6kzWSHg7NPWPWLz++1+4jIwfZNLrQ7U/xcZ+1/f2Kw3kgWp/EZu5OWYIoRa lIzwI86e8zoNfYFy7dN9tXrwrYt7i1Hw5GBY4cXP8ehgakWcdBBTwjX801S4PU0CaI2J XbZmsr/K6Ph5fCAv+v1Os9CWa97w3wKyAwSB70K8LgijQ+alzCC5kO4iDRTo14+5Y1eW ewlL/zjsUhI8KYGbQfw7Pb2YkSCS49bNNQxS0Tklgt6pAfdFBJPIirFY34Yf7jbzCIWA Xnrw== X-Forwarded-Encrypted: i=1; AJvYcCWblNxG0tcTDb88RcySTuWLRRs7g2MPuGf0KXamSRTIhfQnAu/prhIrF3IdSbtgV1RNWsFH2KLGOmUB9n8B@postgresql.org X-Gm-Message-State: AOJu0YyfQ1O8VZHMt3eTOiI6Fq2efwOw+/fEJrn5Kbq6i7EP0rsrxnUV 5IHpNPv4BCwBWBAxnqVthxa/NeDJs5wUPlcTzuhCfu1oZYSFAIFYAJ1rPzX5G95z+tYfrEpvKDG fcomxjv/9f8X/+kZ5n6hryXs8AWs58iY= X-Gm-Gg: AZuq6aLlobRahFtbPT4z2VAzT73//9yoEVI4CEf/9x3FsTwSNgKHHmB6Ou6wlA2u9V0 J1JGT4FY6RVu2db9KKdVM53E5/Um9+ArYZMeA/ZV5n9XYCaB0BiP4hZ+ILrtfIidtBu/p6kpS3M p10Vthrjv8aKI/oBedQZwVv9wjTiIMqhd51kbF3H3YrWiu+OvKd5hMdpdb9RXEyMAWzmM96AkpV V3MbFjT0pVOOECqCVv4TBXQeXODVORctKZKlUTXtyy0AlIow0/RJI2AVlOp86M6PxSJhJHs1Lt/ lgDlG1AkAYacmU7mqJrvl7u/vrlJiyj+Y6Qpxac5RPWW+jw3CKnk1WHWnVw= X-Received: by 2002:a05:6402:4314:b0:658:b8de:179a with SMTP id 4fb4d7f45d1cf-6598412508fmr672871a12.11.1770358763063; Thu, 05 Feb 2026 22:19:23 -0800 (PST) MIME-Version: 1.0 References: <8620df11-96e4-4ca3-8f3c-33a479260961@joeconway.com> <4162f7f7-6fd6-4720-98e2-89f80e3de2ed@joeconway.com> <153b71b8-b6fb-4930-aaff-a7334cb3f6d6@joeconway.com> <8ef5f5d6-38db-4624-8eef-2d96c9eba9d4@joeconway.com> In-Reply-To: From: Junwang Zhao Date: Fri, 6 Feb 2026 14:19:11 +0800 X-Gm-Features: AZwV_Qg4XKh6s6EIzqyOMya4L68o8bDIYncJVE6ITljdo1fvF6nvF8RORPSb5NQ Message-ID: Subject: Re: Emitting JSON to file using COPY TO To: jian he Cc: Florents Tselai , Joe Conway , "Andrey M. Borodin" , Dean Rasheed , Daniel Verite , Andrew Dunstan , Davin Shearer , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Feb 6, 2026 at 11:26=E2=80=AFAM jian he wrote: > > On Wed, Feb 4, 2026 at 12:41=E2=80=AFAM Florents Tselai > wrote: > > > > I (and others I assume) would really like to see this in 19; > > glancing at the thread above and in the test cases I see this is in goo= d shape for comitter review. > > No? > > > > If I were to add something it would be an example in copy.sgml > > > > When the FORCE_ARRAY option is enabled, > > the entire output is wrapped in a JSON array and individual rows are= separated by commas: > > > > COPY (SELECT id, name FROM users) TO STDOUT (FORMAT JSON, FORCE_ARRAY); > > > > > > [ > > {"id": 1, "name": "Alice"} > > ,{"id": 2, "name": "Bob"} > > ,{"id": 3, "name": "Charlie"} > > ] > > > > > > > > v23-0003-Add-option-force_array-for-COPY-JSON-FORMAT.patch > I've added: > > + > + When the FORCE_ARRAY option is enabled, > + the entire output is wrapped in a single JSON array with rows > separated by commas: > + > +COPY (SELECT * FROM (VALUES(1),(2)) val(id)) TO STDOUT (FORMAT JSON, > FORCE_ARRAY); > + > +The output is as follows: > + > +[ > + {"id":1} > +,{"id":2} > +] > + > + > + > + > > > Also, apologies if that has been discussed already, > > is there a good reason why didn't we just go with a simple "WRAP_ARRAY"= ? > > > > I don=E2=80=99t have a particular preference. > If the consensus is that WRAP_ARRAY is better than FORCE_ARRAY, we can > change it accordingly. +0.5 for WRAP_ARRAY > > > -- > jian > https://www.enterprisedb.com/ --=20 Regards Junwang Zhao