pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: anton.dutov@gmail.com
Subject: BUG #15960: ON CONFLICT Trying accessing to variables
Date: Thu, 15 Aug 2019 13:27:24 +0000
Message-ID: <15960-ea463c93a1f572db@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15960
Logged by:          Anton Dutov
Email address:      anton.dutov@gmail.com
PostgreSQL version: 11.3
Operating system:   Linux
Description:        

Using upsert in stored procedure  ON CONFLICT(id, ...)  trows "ERROR: column
reference "id" is ambiguous" where id used as column name and as variable,
but ON CONFLICT can't use variables



Reproduce

CREATE TABLE IF NOT EXISTS test_table (id INT PRIMARY KEY, note TEXT);

CREATE OR REPLACE FUNCTION test_table_add (
  in_id   INT
 ,in_note TEXT
 ,OUT id INT
) RETURNS INT LANGUAGE plpgsql VOLATILE SECURITY DEFINER AS $$
BEGIN
    INSERT INTO test_table (id, note) VALUES (in_id, in_note)
      ON CONFLICT (id) DO UPDATE SET note = in_note;
END;
$$;

SELECT test_table_add (1, 'ONE');



view thread (7+ messages)  latest in thread

Message-ID: <15960-ea463c93a1f572db@postgresql.org>
Permalink:  ../15960-ea463c93a1f572db@postgresql.org/
Also on:    postgresql.org/message-id/15960-ea463c93a1f572db@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, anton.dutov@gmail.com
  Subject: Re: BUG #15960: ON CONFLICT Trying accessing to variables
  In-Reply-To: <15960-ea463c93a1f572db@postgresql.org>
  References: <15960-ea463c93a1f572db@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox