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 1r9Ce5-00F7DT-Qa for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2023 23:10:05 +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 1r9Ce4-009oEN-GN for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Dec 2023 23:10:04 +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 1r9Ce3-009oBr-VI for pgsql-hackers@lists.postgresql.org; Fri, 01 Dec 2023 23:10:03 +0000 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r9Ce1-008LPJ-D9 for pgsql-hackers@postgresql.org; Fri, 01 Dec 2023 23:10:02 +0000 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-7b37dbf896eso91346239f.1 for ; Fri, 01 Dec 2023 15:10:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701472200; x=1702077000; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=GHeIFpVLV64ZFGrgRYkXPtEiV5fxq82uCqNsTUPxEhk=; b=T7CUJHjttVLHJ1W0ZcShw9+AkDhXXX30pKhMwCqJQXShYUSCfgSJz7/EAvbFzhNyTI 8V03zMnkC8Gfhb5IWr2aUnt0QQVQ7vbRReWwK+av7X9XVUOtxK2HOXZN//D3jaReejiP +4ohSKj5KQRcRvyeDFfdKsOOIMs6wRNw/07oKYScPDBZqDjtxoUqHazxgJyF5COKuiID Vl5YMozV66ds2pz5+O42JLqGQgaGZJnakLBlw+Pg7DM4tbm50CikOIIJJyxavibdUjSH 46GEp9l3SQP76RQItM1x8MSEXR16lhb0mVScSfVgTT7M0caNlZckO8+ev4qiMoOWlc64 0deQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701472200; x=1702077000; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GHeIFpVLV64ZFGrgRYkXPtEiV5fxq82uCqNsTUPxEhk=; b=dxkRyRTFRA19+5Y8OE44KaU9ZYgbuoQcu401Xl24Eq3gASg6foe9+owKOPeN44lafe ppB5SHI1OsK8Vir9lEaUTm1xJBcT32l3d9wM+t2c6Dq6w9r2imeP/3WOrkn2rTmWkk8z Va2H1F2tE2joQX+csSAUsX6+xUxlOvQD52F5SsjELlyvchd/Hh/EkHVLQgFyBj1k6HSz jDzEEf19b0iPbS88dqaluGNOK8ULkoJTlW/9EnmV+g4/uvmhMWtbJK8hIXxE+vOKzk9c m1j6WTMURskHbK6XPeEXjRyk/DKe6pC/2yvYytGvNGifGDyno/tVew5wm9ElMWzOrCVj vLdQ== X-Gm-Message-State: AOJu0Yw5ff3fkWqEjIJf6prRavyrKcoDfoL3ugStHdTpXfOx+MhBme9p RsLjA5tGyq1Rk0DlddTsvwY= X-Google-Smtp-Source: AGHT+IEm6LmfyjU5tCadrrSiM3wBZOCZiv5wT4+Nq061OMLbjgORf8r2HXrbqCzvrEimdCgrxDTfUA== X-Received: by 2002:a5e:a709:0:b0:7b4:28f8:521 with SMTP id b9-20020a5ea709000000b007b428f80521mr302958iod.33.1701472200609; Fri, 01 Dec 2023 15:10:00 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id l3-20020a02a883000000b00466bd8ccac1sm1117072jam.143.2023.12.01.15.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 15:10:00 -0800 (PST) Date: Fri, 1 Dec 2023 17:09:58 -0600 From: Nathan Bossart To: Joe Conway Cc: Davin Shearer , PostgreSQL-development Subject: Re: Emitting JSON to file using COPY TO Message-ID: <20231201230958.GA1786735@nathanxps13> References: <3853387.1701096982@sss.pgh.pa.us> <3a98decf-3fe3-4b49-9b68-fda01338872c@sedlakovi.org> <24e3ee88-ec1e-421b-89ae-8a47ee0d2df1@joeconway.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24e3ee88-ec1e-421b-89ae-8a47ee0d2df1@joeconway.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Dec 01, 2023 at 02:28:55PM -0500, Joe Conway wrote: > I did a quick PoC patch (attached) -- if there interest and no hard > objections I would like to get it up to speed for the January commitfest. Cool. I would expect there to be interest, given all the other JSON support that has been added thus far. I noticed that, with the PoC patch, "json" is the only format that must be quoted. Without quotes, I see a syntax error. I'm assuming there's a conflict with another json-related rule somewhere in gram.y, but I haven't tracked down exactly which one is causing it. > 1. Is supporting JSON array format sufficient, or does it need to support > some other options? How flexible does the support scheme need to be? I don't presently have a strong opinion on this one. My instinct would be start with something simple, though. I don't think we offer any special options for log_destination... > 2. This only supports COPY TO and we would undoubtedly want to support COPY > FROM for JSON as well, but is that required from the start? I would vote for including COPY FROM support from the start. > ! if (!cstate->opts.json_mode) I think it's unfortunate that this further complicates the branching in CopyOneRowTo(), but after some quick glances at the code, I'm not sure it's worth refactoring a bunch of stuff to make this nicer. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com