Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cU0IS-00011s-3O for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jan 2017 00:09:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cU0IR-00030O-Ms for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jan 2017 00:09:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cU0H2-00014d-79 for pgsql-hackers@postgresql.org; Thu, 19 Jan 2017 00:08:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cU0Gu-0004UX-Jk for pgsql-hackers@postgresql.org; Thu, 19 Jan 2017 00:08:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v0J0844j017807; Wed, 18 Jan 2017 19:08:04 -0500 From: Tom Lane To: Robert Haas cc: Andres Freund , "pgsql-hackers@postgresql.org" Subject: Re: Implement targetlist SRFs using ROWS FROM() (was Changed SRF in targetlist handling) In-reply-to: References: <12780.1484747004@sss.pgh.pa.us> <20170118191924.25lfp6rd6y3kw5sa@alap3.anarazel.de> <13690.1484767452@sss.pgh.pa.us> <20170118193420.znochutmnzusd636@alap3.anarazel.de> <15814.1484769612@sss.pgh.pa.us> <460325A6-EF35-4A29-A1A0-EEDC3EDCF750@anarazel.de> <22709.1484771072@sss.pgh.pa.us> <20170118214702.54b2mdbxce5piwv5@alap3.anarazel.de> <1080.1484776606@sss.pgh.pa.us> <15818.1484781266@sss.pgh.pa.us> <20170118231945.27ivk7cjaq23y6r3@alap3.anarazel.de> Comments: In-reply-to Robert Haas message dated "Wed, 18 Jan 2017 18:59:00 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17805.1484784484.1@sss.pgh.pa.us> Date: Wed, 18 Jan 2017 19:08:04 -0500 Message-ID: <17806.1484784484@sss.pgh.pa.us> X-Pg-Spam-Score: -5.1 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Robert Haas writes: > So, one of the big reasons I use CASE is to avoid evaluating > expressions in cases where they might throw an ERROR. Like, you know: > CASE WHEN d != 0 THEN n / d ELSE NULL END > I guess it's not the end of the world if that only works for > non-set-returning functions, but it's something to think about. Well, refusing CASE-containing-SRF at all isn't going to make your life any better in that regard :-( It's possibly worth noting that this is also true for aggregates and window functions: wrapping those in a CASE doesn't stop them from being evaluated, either. People seem to be generally used to that, although I think I've seen one or two complaints about it from folks who seemed unclear on the concept of aggregates. In the end I think this is mostly about backwards compatibility: are we sufficiently worried about that that we'd rather throw an error than have a silent change of behavior? TBH I'm not sure. We've certainly got two other silent changes of behavior in this same patch. The argument for treating this one differently, I think, is that it's changing from a less surprising behavior to a more surprising one whereas the other changes are the reverse, or at worst neutral. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers