Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAczb-0002cV-JM for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Oct 2018 15:35:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gAczZ-0002QR-8K for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Oct 2018 15:35:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAczY-0002QA-Mb for pgsql-hackers@lists.postgresql.org; Thu, 11 Oct 2018 15:35:12 +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 1gAczV-0007FG-0l for pgsql-hackers@lists.postgresql.org; Thu, 11 Oct 2018 15:35:10 +0000 Received: by fetter.org (Postfix, from userid 1001) id 4FD9741C1E; Thu, 11 Oct 2018 17:35:06 +0200 (CEST) Date: Thu, 11 Oct 2018 17:35:05 +0200 From: David Fetter To: Corey Huinker Cc: surafel3000@gmail.com, cmt@burggraben.net, pgsql-hackers@lists.postgresql.org Subject: Re: COPY FROM WHEN condition Message-ID: <20181011153505.GL6157@fetter.org> References: <20181011085925.5zopu7jvxzs5c4xq@squirrel.exwg.net> 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 Thu, Oct 11, 2018 at 05:12:48AM -0400, Corey Huinker wrote: > On Thu, Oct 11, 2018 at 5:04 AM Surafel Temesgen > wrote: > > > > > > > On Thu, Oct 11, 2018 at 12:00 PM Christoph Moench-Tegeder < > > cmt@burggraben.net> wrote: > > > >> You can: > >> COPY ( query ) TO 'filename'; > >> > > it is for COPY FROM > > > > regards > > Surafel > > > > It didn't get far, but you may want to take a look at a rejected patch for > copy_srf() (set returning function) > https://www.postgresql.org/message-id/CADkLM%3DdoeiWQX4AGtDNG4PsWfSXz3ai7kY%3DPZm3sUhsUeev9Bg%40mail.gmail.com > https://commitfest.postgresql.org/12/869/ > > Having a set returning function gives you the full expressiveness of SQL, > at the cost of an extra materialization step. I wonder whether something JIT-like could elide this. A very interesting subset of such WHEN clauses could be pretty straight-forward to implement in a pretty efficient way. 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