Re: BUG #15960: ON CONFLICT Trying accessing to variables - Mailing list pgsql-bugs

From Peter Geoghegan
Subject Re: BUG #15960: ON CONFLICT Trying accessing to variables
Date
Msg-id CAH2-Wzm7KDqfuekQ4NGH_YimW-Jw7wYg82mJyNM_zi=7oXEiSA@mail.gmail.com
Whole thread Raw
In response to BUG #15960: ON CONFLICT Trying accessing to variables  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #15960: ON CONFLICT Trying accessing to variables  (Andres Freund <andres@anarazel.de>)
List pgsql-bugs
On Thu, Aug 15, 2019 at 6:28 AM PG Bug reporting form
<noreply@postgresql.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



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #15960: ON CONFLICT Trying accessing to variables
Next
From: Andres Freund
Date:
Subject: Re: BUG #15960: ON CONFLICT Trying accessing to variables