Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dJodx-0007Xr-CM for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Jun 2017 22:14:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dJodw-0007VB-V7 for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Jun 2017 22:14:04 +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 1dJodv-0007PI-Mr for pgsql-hackers@postgresql.org; Sat, 10 Jun 2017 22:14:03 +0000 Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dJodq-00056f-H1 for pgsql-hackers@postgresql.org; Sat, 10 Jun 2017 22:14:03 +0000 Received: by mail-qk0-x232.google.com with SMTP id r62so16854395qkf.0 for ; Sat, 10 Jun 2017 15:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=TSynjdGywww+0GPKYgdpIKSvhNg8lyXXhoWbjpXKr1s=; b=Qkgfb9sVDbaCaRBw9linI8CqFjKCkryg+OTI1i7K/GzjMcEPLDu2MPfUzqcSHUTNVU 96MmXC/7J0zAUejjqE3fnyB0LbnzhlNsyY1GlQPSE676TWNIGT0/d5YRsZ4YIhWtb/TC wu7LvaPteSfVht0JgpV58vpd8pwN+S5f/PonxgluPBSNxZlsymtK4S6nWBUbyRzogFyS L7P/tDWv2d2ubIiocdS2VHoqG5hY4/Gk+jLO10jDw3/Ob7+98EOPmGylGEJ9G/LHDSiP FJsGQ8US5c6CiPyANQHHdPXI+Ov+qyXn5xJHncE7ZtjNvwnW8XqtMBArhozKxg8y58lf y84Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=TSynjdGywww+0GPKYgdpIKSvhNg8lyXXhoWbjpXKr1s=; b=pNqHDOFVJQolWZgD+hrFgFyKnw9XNJPpdhliS1QWgnhnmTfql7to6iL8Mtvb9DaOZL c5hgYc1RwDD6g8Xt/zaSBczFjGJNJx79ub4I/XYyKgE2xZTU0miErK1nfQDOBoCy7OqO S/ZQ2t8dHg5TJ+f67plTfO3dRTByhLkDu4ftI/aLQqtkPhyF/2JNp16pwR8ImmcY4A/C hB/V0xeIxdYq+SI9jWbzklnhrVDK2NjH6AtGcApGPC9Oo2x+UU9/z0Wdd9Lo1CsATUGM ne8Kz+IzhO6OF+XHuPPBm+PgI4svoGBrStSimqQq8XlrvL72gVJAuqwC/2T/z6krKJvt dLxw== X-Gm-Message-State: AKS2vOwTMxLNld+7hfqOtbV5bBLEK/0m1+Ss7eBHA8IEKQeZgAPPA3MD +lPI5wpjXPRE6QdZ X-Received: by 10.233.220.134 with SMTP id q128mr37766622qkf.199.1497132837040; Sat, 10 Jun 2017 15:13:57 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([186.9.132.162]) by smtp.gmail.com with ESMTPSA id l23sm3564257qtl.24.2017.06.10.15.13.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Jun 2017 15:13:55 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 3C83FC9D; Sat, 10 Jun 2017 15:04:19 -0300 (-03) Date: Sat, 10 Jun 2017 15:04:19 -0300 From: Alvaro Herrera To: Tom Lane Cc: Andres Freund , Mark Dilger , Regina Obe , PostgreSQL-development Subject: Re: PostgreSQL 10 changes in exclusion constraints - did something change? CASE WHEN behavior oddity Message-ID: <20170610180419.2gref4t7oipjcri5@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ujeevgxln6xej4pv" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5259.1497044025@sss.pgh.pa.us> User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) 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 --ujeevgxln6xej4pv Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Tom Lane wrote: > I wrote: > > Yes, we already have guards for those cases, but they return fairly opaque > > error messages to the tune of "set-valued function called in context that > > cannot accept a set", because the executor hasn't enough context to do > > better. I'd like the messages to be more specific, like "set-valued > > function cannot appear within CASE" and so on. > > Here's an expanded version of the "bottom up" patch that adjusts some > parser APIs to allow these additional messages to be thrown. This changes > all occurrences of "set-valued function called in context that cannot > accept a set" in the core regression tests into something more specific. > There are probably some remaining cases that this doesn't cover, but the > existing execution-time checks will still catch those. Interesting stuff. Here's a small recommendation for a couple of those new messages. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --ujeevgxln6xej4pv Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="translatability.patch" *** a/src/backend/parser/parse_expr.c --- b/src/backend/parser/parse_expr.c *************** *** 1068,1074 **** transformAExprNullIf(ParseState *pstate, A_Expr *a) if (result->opretset) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), ! errmsg("NULLIF operator must not return a set"), parser_errposition(pstate, a->location))); /* --- 1068,1075 ---- if (result->opretset) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), ! /* translator: %s is name of a SQL construct, eg NULLIF */ ! errmsg("%s operator must not return a set", "NULLIF"), parser_errposition(pstate, a->location))); /* *************** *** 3041,3047 **** make_distinct_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree, if (((OpExpr *) result)->opretset) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), ! errmsg("IS DISTINCT FROM operator must not return a set"), parser_errposition(pstate, location))); /* --- 3042,3050 ---- if (((OpExpr *) result)->opretset) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), ! /* translator: %s is name of a SQL construct, eg NULLIF */ ! errmsg("%s operator must not return a set", ! "IS DISTINCT FROM"), parser_errposition(pstate, location))); /* --ujeevgxln6xej4pv Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --ujeevgxln6xej4pv--