Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n5HZ4-00063H-KQ for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Jan 2022 01:27:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n5HZ3-0008Vb-FW for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Jan 2022 01:27:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n5HZ3-0008VS-7P for pgsql-bugs@lists.postgresql.org; Thu, 06 Jan 2022 01:27:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n5HZ1-00068v-75 for pgsql-bugs@lists.postgresql.org; Thu, 06 Jan 2022 01:27:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2061RXf31000506; Wed, 5 Jan 2022 20:27:33 -0500 From: Tom Lane To: Alexi Theodore cc: pgsql-bugs@lists.postgresql.org Subject: Re: Bug report: variable_conflict + ON CONFLICT In-reply-to: <2A512572-5AE4-4072-9C04-C746C9E67F56@gmail.com> References: <2A512572-5AE4-4072-9C04-C746C9E67F56@gmail.com> Comments: In-reply-to Alexi Theodore message dated "Wed, 05 Jan 2022 16:40:58 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1000504.1641432453.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 05 Jan 2022 20:27:33 -0500 Message-ID: <1000505.1641432453@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alexi Theodore writes: > I'd like to report what I think is a bug. I've put together a script whi= ch highlights things pretty clearly. The short synopsis is that when using= "#variable_conflict use_variable" in a function or procedure, the correct= choice of variable vs column name is done everywhere (that I know of) exc= ept in the ON CONFLICT () part of an INSERT statement. That o= ne part only seems to not follow the conflict resolution pattern. = The names in ON CONFLICT are not values, and it would not make sense to substitute plpgsql variable values for them. A related example is that if you write INSERT INTO t (a,b) VALUES (1,2), none of t, a, or b are candidates to be replaced by plpgsql variables. regards, tom lane