Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIiC9-0005U8-6k for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Jun 2017 21:08:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dIiC8-0004ni-Gn for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Jun 2017 21:08:48 +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 1dIiAZ-0008B0-Ab for pgsql-hackers@postgresql.org; Wed, 07 Jun 2017 21:07:11 +0000 Received: from mail-qt0-x22b.google.com ([2607:f8b0:400d:c0d::22b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dIiAV-0004gg-OG for pgsql-hackers@postgresql.org; Wed, 07 Jun 2017 21:07:10 +0000 Received: by mail-qt0-x22b.google.com with SMTP id c10so20981082qtd.1 for ; Wed, 07 Jun 2017 14:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pcorp-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-transfer-encoding:thread-index :content-language; bh=+8hVFdeOlitIwlFN1xaRZX6E88eRjxY7ZFTfjMI3FLo=; b=AZPQjpEi98uLRXtSiMFuOjiafHMQuQKB+mELBHAzIx92YVy7agkJ2ihsJI5HN//BKZ p5jnA8tkK4QRCpJ/43LFCwVfPBF04pXukssW3U/p3WVO1WsPznt9+I7bMgmNiMa+DeIF Yn8WOU56z6J2evxsNcp7YzUgbYsAsCChAJe3A8yKSNUF/v1eJ4q2Tw2dNgjGWmc2YSDW hUzR4X2AWQaCQt8SF2OzPSgDMF/pA/ZpVlUjJKb3Sic+VnDh1/8RBLMRPf80g0CQTlJN zfc6oz43K2gYIe4VR6KViHDdztuGTxHzAernoZVcwYYuKo0w5CyU/nEqbFNZKU421itd rTRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:references:in-reply-to:subject:date :message-id:mime-version:content-transfer-encoding:thread-index :content-language; bh=+8hVFdeOlitIwlFN1xaRZX6E88eRjxY7ZFTfjMI3FLo=; b=iVleuir1w8HalDWVqKy7J08/4OL7+7LjPleBnQhtgAvBF7ZJpUef3L5zFC9JZnTmr0 3kmZqlmlyjEYBwKtu3iHZFWWYbbwvPqpwjOlYSdlWxSuhg8VEcXe6XbcjRnCmauzhnMB 2+boSO0TIKyogwfS2rRTIF7o/FBy+2b599ny4cynJrsZffcXxI3R4OWPMf9w8Vw0HU34 ZaeWBcbp8yT2NAki4BEmtP0LNZqRCRDZ7sBbN+vgYPMmn0/otbbFqPUgvg0qHC4R4WSS e37TD3QaW/ROH6v6NtT8uKqziEZaoMz9eTQSxE8PvdLjbu8eNrIHIPgl0jgApLGsW0It S1VA== X-Gm-Message-State: AODbwcCKyiW192fGtlAAT/F3rZcQKLcjTnuLB5PTgNrHabSbLVZ1H1RN lSzfn1Lvfy8TUWHT X-Received: by 10.200.38.204 with SMTP id 12mr2491282qtp.236.1496869625614; Wed, 07 Jun 2017 14:07:05 -0700 (PDT) Received: from R (50-78-240-110-static.hfc.comcastbusiness.net. [50.78.240.110]) by smtp.gmail.com with ESMTPSA id l184sm1761329qkc.33.2017.06.07.14.07.04 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 14:07:04 -0700 (PDT) From: "Regina Obe" To: "'Tom Lane'" , "'Mark Dilger'" Cc: "'Andres Freund'" , "'PostgreSQL-development'" References: <000001d2d5de$d8d66170$8a832450$@pcorp.us> <29994.1495809534@sss.pgh.pa.us> <000c01d2d654$518f2be0$f4ad83a0$@pcorp.us> <21809.1495994606@sss.pgh.pa.us> <20170603024503.yv6gxvkyx6mtc63m@alap3.anarazel.de> <7181.1496458380@sss.pgh.pa.us> <20170603031127.fqg7zjhfgbcbcank@alap3.anarazel.de> <4125B63A-886A-442D-9932-34F0D4F76D41@gmail.com> <20170604193521.ha6d5kpkdswmissm@alap3.anarazel.de> <63850C96-9570-4969-8074-7033DA4C334F@gmail.com> <20170604211942.aiavcbagsho5owcz@alap3.anarazel.de> <13450.1496861842@sss.pgh.pa.us> In-Reply-To: <13450.1496861842@sss.pgh.pa.us> Subject: Re: PostgreSQL 10 changes in exclusion constraints - did something change? CASE WHEN behavior oddity Date: Wed, 7 Jun 2017 17:07:10 -0400 Message-ID: <000201d2dfd2$07fad150$17f073f0$@pcorp.us> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQGSyGid0WOb7K33IPoK2k+QsEQaEAKr4LhqAj7/u9sCYz3ehQI8CMhgAnAUar8CAekolwFXzi3+Apc1MG8B7cswggJEIFHfAhiT9OsBmaJDn6HLlrTg Content-Language: en-us X-Pg-Spam-Score: -1.9 (-) 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 > After chewing on this for awhile, I'm starting to come to the conclusion that we'd be best off to throw an error for SRF-inside-CASE (or COALESCE). Mark is correct that the simplest case of > SELECT x, CASE WHEN y THEN generate_series(1,z) ELSE 5 END > FROM table_with_columns_x_and_y_and_z; > behaves just intuitively enough that people might be using it. The new implementation method cannot reasonably duplicate the old semantics for that, which means that if we let it stand as-is we will be > silently breaking queries, even if we fix up some of the weirder corner cases like what happens when the CASE can be const-simplified. So I think we'd be better off to make this throw an error, and force any > affected users to rewrite in a way that will work in both v10 and older releases. > As to *how* to throw an error, I think it should be possible to teach parse analysis to detect such cases, with something like the ParseExprKind mechanism that could be checked to see if we're inside a > subexpression that restricts what's allowed. There are some other checks like no-nested-aggregates that perhaps could be folded in as well. Checking at parse analysis ought to be sufficient because > rule rewriting could not introduce such a case where it wasn't before, and planner subquery flattening won't introduce one either because we don't flatten subqueries with SRFs in their tlists. > If people are on board with throwing an error, I'll go see about writing a patch. > regards, tom lane +1 I'm not a fan of either solution, but I think what Tom proposes of throwing an error sounds like least invasive and confusing. I'd much prefer an error thrown than silent behavior change. Given that we ran into this in 3 places in PostGIS code, I'm not convinced the issue is all that rare. Make sure to point out the breaking change in the release notes though and syntax to remedy it. Thanks, Regina -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers