Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIdG4-0006Fv-Oj for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Nov 2018 17:29:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gIdG2-0004v9-AA for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Nov 2018 17:29:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIdG1-0004v2-Vu for pgsql-hackers@lists.postgresql.org; Fri, 02 Nov 2018 17:29:18 +0000 Received: from xvm-110-146.dc2.ghst.net ([46.226.110.146] helo=fetter.org) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gIdFz-0002E2-5e for pgsql-hackers@lists.postgresql.org; Fri, 02 Nov 2018 17:29:16 +0000 Received: by fetter.org (Postfix, from userid 1001) id 192C841D22; Fri, 2 Nov 2018 18:29:13 +0100 (CET) Date: Fri, 2 Nov 2018 18:29:12 +0100 From: David Fetter To: Daniel Verite Cc: Pavel Stehule , "corey.huinker" , nasbyj@amazon.com, Surafel Temsgen , Christoph Moench-Tegeder , PostgreSQL Hackers Subject: Re: COPY FROM WHEN condition Message-ID: <20181102172912.GK12677@fetter.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Nov 02, 2018 at 12:58:12PM +0100, Daniel Verite wrote: > Pavel Stehule wrote: > > > > SELECT x.a, sum(x.b) > > > FROM ( COPY INLINE '/path/to/foo.txt' FORMAT CSV ) as x( a integer, b > > > numeric, c text, d date, e json) ) > > > WHERE x.d >= '2018-11-01' > > > > > > > > Without some special feature this example is not extra useful. It is based > > on copy on server that can use only super user with full rights. > > And if superuser, one might use the file data wrapper [1] to get > the same results without the need for the explicit COPY in the query. > > BTW, this brings into question whether the [WHEN condition] clause > should be included in the options of file_fdw, as it supports pretty > much all COPY options. > > Also, psql's \copy should gain the option too? tl;dr: \copy support is a very large can of worms. psql's \copy is something which should probably be handled separately from COPY, as it's both a way to access the filesystem without superuser permission and an interface to the COPY part of the protocol. It seems like poor design to add grammar to support a single client, so we'd need to think about this in terms of what we want to support on the client side independent of specific clients. It also seems like a violation of separation of concerns to couple FEBE to grammar, so there'd need to be some way to do those things separately, too. Best, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate