PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID15960
PG Version11.3
OSLinux
Opened2019-08-15 13:27:24+00
Reported byAnton Dutov
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      15960
Logged by:          Anton Dutov
Email address:      (redacted)
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');

Messages

DateAuthorSubject
2019-08-15 13:27:24+00PG Bug reporting formBUG #15960: ON CONFLICT Trying accessing to variables
2019-08-15 16:17:36+00Peter GeogheganRe: BUG #15960: ON CONFLICT Trying accessing to variables
2019-08-15 17:05:48+00Andres FreundRe: BUG #15960: ON CONFLICT Trying accessing to variables
2019-08-15 17:09:14+00Peter GeogheganRe: BUG #15960: ON CONFLICT Trying accessing to variables
2019-08-15 19:42:13+00Andres FreundRe: BUG #15960: ON CONFLICT Trying accessing to variables
2019-08-15 22:06:25+00Tom LaneRe: BUG #15960: ON CONFLICT Trying accessing to variables
2019-08-15 22:15:44+00Andres FreundRe: BUG #15960: ON CONFLICT Trying accessing to variables