Re: BUG #15960: ON CONFLICT Trying accessing to variables

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: anton(dot)dutov(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #15960: ON CONFLICT Trying accessing to variables
Date: 2019-08-15 16:17:36
Message-ID: CAH2-Wzm7KDqfuekQ4NGH_YimW-Jw7wYg82mJyNM_zi=7oXEiSA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Aug 15, 2019 at 6:28 AM PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> 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

This is not a bug. You must resolve the ambiguity by using a plpgsql
variable whose name isn't exactly the same as a column name.

In principle you can have an index on a simple constant, which is
occasionally useful (e.g. using a unique index to enforce that you can
either have zero or one rows in some particular table).

--
Peter Geoghegan

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2019-08-15 17:05:48 Re: BUG #15960: ON CONFLICT Trying accessing to variables
Previous Message PG Bug reporting form 2019-08-15 13:27:24 BUG #15960: ON CONFLICT Trying accessing to variables