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 1n5Gxf-0004c2-Pa for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Jan 2022 00:48:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n5Gxe-00036T-7i for pgsql-bugs@arkaria.postgresql.org; Thu, 06 Jan 2022 00:48:58 +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 1n5Gq4-0008WQ-Is for pgsql-bugs@lists.postgresql.org; Thu, 06 Jan 2022 00:41:08 +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 1n5Gpy-0005oX-6Z for pgsql-bugs@lists.postgresql.org; Thu, 06 Jan 2022 00:41:07 +0000 Received: by mail-pf1-x435.google.com with SMTP id u20so1027209pfi.12 for ; Wed, 05 Jan 2022 16:41:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:mime-version:subject:message-id:date:to; bh=U3a4J/9b0hIg8wkMbtbaEOfxmzc/78LOsy5qb7pgxlE=; b=JNRsbBxbXwEiN+x51cu8d70NiYfemsGWcUVfADvDst7eN61eXEXHd21Ak23ooL5A3P Y5sFE+0+Nea5DO1UgEVadOshi9UnKqKacpr4CMqVDvpJLEJNG1y7sB8OH9D4kFjti0wH FeDROSwhHoCRM5Afk60HtM/bSNHMY1OHSN/u63fKNN5F/afh0YLfFfykO53r+Xq9o01q qBPOF1HvW7LbOq+SDQzpusrEUQIJbuI1kJq0slqVx7CqgujH45mki8mP64LyWpIoYyVb s2tnyylx5ez9qaFZfkXyTqpIBfIJ3cXBWf4pblEL1UTm4+ZJv9vziJ5PrclKYGJ28LcK Dq6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:subject:message-id:date:to; bh=U3a4J/9b0hIg8wkMbtbaEOfxmzc/78LOsy5qb7pgxlE=; b=QtzCzGBl0IyJVqEx3jSU+01r8UuHD27ssWVRXGw2AFlpFLcVg255UKVpXpzcO7Yn+W iGzmE2N5J9r3x994oc8l9OmMXQC//+eQEfRhCBOcOT9jdVYwosrKhK9j7RuejsxVhR0f EcE6CxLGJWdLYpooho5raMvpJnnmNNCrBpurlgpVTI0YwFYpyRGgeD1pmHT68Y3OOq8e JEJhC1NfBEdz+XqycXcaKzCbSL3NM45k1660Tmh22tiWwUtFjk4RCby8X0FsKjOX+Gwn CjzbBPFpG1UMaCoFu05ZiTrC7RO1SAY+8cYiQdchUDqEX1VBJ8l2DJfwd4gPgOCAP5Mh 87kw== X-Gm-Message-State: AOAM533+NDstuWPr73eLNqNZrOV1lQM/M3yo89QR1VgHXQL7B7++91zL k/G2GOpxHRLd/YJXuxwDhchULvQVdxx4XA== X-Google-Smtp-Source: ABdhPJwdd9265Vyc+yoPK55reJqDS8ggFM8sZ8q1ZB4IdHVuW5uqZSPXIO8eX1c1YqwP+6YkAGoFoQ== X-Received: by 2002:a63:b10d:: with SMTP id r13mr11069393pgf.257.1641429660288; Wed, 05 Jan 2022 16:41:00 -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 z23sm233520pfr.189.2022.01.05.16.40.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jan 2022 16:40:59 -0800 (PST) From: Alexi Theodore Content-Type: multipart/mixed; boundary="Apple-Mail=_9EA6B530-3137-44E8-865E-0462681A5EF9" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Bug report: variable_conflict + ON CONFLICT Message-Id: <2A512572-5AE4-4072-9C04-C746C9E67F56@gmail.com> Date: Wed, 5 Jan 2022 16:40:58 -0800 To: pgsql-bugs@lists.postgresql.org 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 --Apple-Mail=_9EA6B530-3137-44E8-865E-0462681A5EF9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, 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 Thanks, Alex --Apple-Mail=_9EA6B530-3137-44E8-865E-0462681A5EF9 Content-Disposition: attachment; filename="bug report - ON CONFLICT and variable_conflict.txt" Content-Type: text/plain; x-unix-mode=0644; name="bug report - ON CONFLICT and variable_conflict.txt" Content-Transfer-Encoding: quoted-printable ROLLBACK; BEGIN; CREATE TABLE example_table ( test_column TEXT unique ) ; INSERT INTO example_table VALUES ('abc') ON CONFLICT (test_column) DO NOTHING ; CREATE PROCEDURE example_works ( test_column_in TEXT ) AS $$ #variable_conflict use_variable BEGIN INSERT INTO example_table (test_column) VALUES (test_column_in) ON CONFLICT (test_column) DO NOTHING ; END $$ LANGUAGE plpgsql ; CALL example_works('xyz'); SELECT * FROM example_table ; CREATE PROCEDURE example_breaks ( test_column TEXT -- ^ note: the new declaration name is the same as the column name ) AS $$ #variable_conflict use_variable BEGIN -- ^ normally, name conflicts would be resolved successully this way... INSERT INTO example_table (test_column) -- `variable_conflict` is = working here =E2=88=9A VALUES (test_column) -- `variable_conflict` is working here =E2=88=9A ON CONFLICT (test_column) DO NOTHING -- `variable_conflict` is NOT = working here X @ `(test_column)` ; END $$ LANGUAGE plpgsql ; CALL example_breaks('qwe'); /* [42P10] ERROR: there is no unique or exclusion constraint matching the = ON CONFLICT specification PL/pgSQL function example_breaks(text) line 6 at SQL statement */ ROLLBACK;= --Apple-Mail=_9EA6B530-3137-44E8-865E-0462681A5EF9--