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 1n5O5a-0006QF-Os for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Jan 2022 08:25: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 1n5O5Z-0008ME-AL for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Jan 2022 08:25: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 1n5IpS-0003GK-Jk for pgsql-bugs@lists.postgresql.org; Thu, 06 Jan 2022 02:48:38 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n5IpN-0006qO-9P for pgsql-bugs@lists.postgresql.org; Thu, 06 Jan 2022 02:48:37 +0000 Received: by mail-pf1-x435.google.com with SMTP id t187so1311834pfb.11 for ; Wed, 05 Jan 2022 18:48:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ZJqPyXd9+HNCg1/gFVlba/IRAXJ6GmTilrofbMDP56o=; b=L1Z0/30g3fPcInzWaFuI0Xk9ecc7ThURzr48228a1i9BT5tu76U91L//m3NcjeGrWd P+U8VMQdoeUM//t7ldl8ywUi61iq4zsPNCDs02W1gOEtyfGv5jhPNhfbfpOdSGMYxDtj hmi9zmrSNyPRkSOiFuk9JdPAijLjS/ZiQBQ9e/iC6EcgXQRfH/49i/Jp/BzbXARzviAt GvWPgEuMWUSyfZPIosk9WG9AfjF08EdE+27sfJcCvbwLMufTxgKanD+EP8VaFE9b3QR8 Ne/+lgS4/eD0Napn4q8gu7qSowq4dsNT96m5RjA9CQXgOqeo+0bzgE6lJhy+vPkfDxqb cgnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ZJqPyXd9+HNCg1/gFVlba/IRAXJ6GmTilrofbMDP56o=; b=ER/g88T4zhSwmg2tiYhJh++Ft9gyOekjRVqfiiHwGiWbLjBg5ARgSkuwxu6eobgC3I sQFn3/ex4vmhwTPJSCSUkHTqDqwAMYpBsASTmm6EwVbs+hRjAWSfCFIHap11+qw+bmao xC7dYZA1r73QzxwG7viSWwX3CeNbhANZgTcGRZpeMx6ualVIweIEXq4JdoGBkoFBq7z9 Ucc2WPeDhRKeik09Elmh1VkQOprdPcYlzFsCATbpMg21vyfeaI6on9FVqT7HQxrbaFre AnJ31O634wmg61SePkhxmXN8tu0aCVOXNbOd4lWrKez8/rqzY9ufneuffMkk4VUGvQgc dqow== X-Gm-Message-State: AOAM533ZgS5EL17lEVJplthWwOvRRxOwtwmgyu0HnOQw8VZ6QkJq9voM 4bSCiBkJ5/engtsEpVn9BPo= X-Google-Smtp-Source: ABdhPJxp0viTdUJNR/iOHpuym/jv49pYwoTqwyQB5xVuVDHwlci7WreP3CP2Abwk5k/LUnf47crEhg== X-Received: by 2002:a63:eb06:: with SMTP id t6mr50869706pgh.366.1641437312225; Wed, 05 Jan 2022 18:48:32 -0800 (PST) Received: from smtpclient.apple (c-98-246-25-37.hsd1.or.comcast.net. [98.246.25.37]) by smtp.gmail.com with ESMTPSA id il18sm4100420pjb.37.2022.01.05.18.48.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jan 2022 18:48:31 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: Bug report: variable_conflict + ON CONFLICT From: Alexi Theodore In-Reply-To: <1000505.1641432453@sss.pgh.pa.us> Date: Wed, 5 Jan 2022 18:48:30 -0800 Cc: pgsql-bugs@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <29CD2A90-F445-47B7-8222-AB08088EC676@gmail.com> References: <2A512572-5AE4-4072-9C04-C746C9E67F56@gmail.com> <1000505.1641432453@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.3654.120.0.1.13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I think that is my point though? Since the ON CONFLICT parameters are = not variables, it should never cause a concern... but in this case, = thats exactly what is happening. Its almost being interpreted as though = the variable is being replaced with its value. I.e. ON CONFLICT ('awe') = which of course is not going to work. The way it should work should be = identical to other parts of the query which are the same condition and = don't concern with whether to interpret as variable or column, because = they can only be column. > On Jan 5, 2022, at 5:27 PM, Tom Lane wrote: >=20 > Alexi Theodore writes: >> I'd like to report what I think is a bug. I've put together a script = which 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) except in the ON CONFLICT () part of an INSERT = statement. That one part only seems to not follow the conflict = resolution pattern.=20 >=20 > 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. >=20 > regards, tom lane