Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyNtK-00015k-Rx for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Aug 2019 22:06:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hyNtI-0001i5-UY for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Aug 2019 22:06:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hyNtI-0001hy-Jz for pgsql-bugs@lists.postgresql.org; Thu, 15 Aug 2019 22:06:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hyNtB-0000wt-1x for pgsql-bugs@lists.postgresql.org; Thu, 15 Aug 2019 22:06:39 +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 x7FM6Pac031083; Thu, 15 Aug 2019 18:06:25 -0400 From: Tom Lane To: Andres Freund cc: Peter Geoghegan , anton.dutov@gmail.com, PostgreSQL mailing lists Subject: Re: BUG #15960: ON CONFLICT Trying accessing to variables In-reply-to: <20190815194213.hskbzb3vcpij5tiy@alap3.anarazel.de> References: <15960-ea463c93a1f572db@postgresql.org> <34AB8A8F-1020-4800-9A06-577E038B3C50@anarazel.de> <20190815194213.hskbzb3vcpij5tiy@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Thu, 15 Aug 2019 12:42:13 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31081.1565906785.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 15 Aug 2019 18:06:25 -0400 Message-ID: <31082.1565906785@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2019-08-15 10:09:14 -0700, Peter Geoghegan wrote: >> On Thu, Aug 15, 2019 at 10:05 AM Andres Freund wro= te: >>> Seems like it's more a question of preventing the hook from resolving = things at that point? >> I don't know. > Seems like we'd just need a new EXPR_KIND_*, maybe > EXPR_KIND_ARBITER_EXPRESSION, which plpgsql's column hook would just > ignore. It's already using EXPR_KIND_INDEX_EXPRESSION, so I doubt you need a new exprkind; it'd be fine not to resolve plpgsql variables in CREATE INDEX too. Possibly the same could happen for some other exprkinds. But I'm not really sure that having the hook discriminate against particular exprkinds is a good idea, on two grounds: 1. It introduces user-visible inconsistency. Despite the OP's opinion, I am not convinced that having "id" behave differently here than it would elsewhere is a good thing. 2. It seems like an inevitable source of future bugs, when somebody changes something in a way that makes it desirable to resolve plpgsql variables in a particular exprkind. Yeah, that most likely means they should have split that exprkind in two, but this is the sort of action at a distance that's very unlikely to get noticed until too late. Maybe it'd be a net positive despite these objections, but I do not think it's a clear-cut win. regards, tom lane