Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Adrian Klaver
On 12/1/21 20:20, Michael Lewis wrote: Perhaps I missed something, but why all this effort to reference the column and not just reference IX_Lockers_Uuid for the on conflict clause? Two reasons: 1) The OP thought that ON CONFLICT could only reference a column. 2) Explaining why the error occu

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Michael Lewis
Perhaps I missed something, but why all this effort to reference the column and not just reference IX_Lockers_Uuid for the on conflict clause?

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Adrian Klaver
On 12/1/21 12:55, Adrian Klaver wrote: On 12/1/21 11:43, Jenda Krynicky wrote: From:   Adrian Klaver On 12/1/21 11:20 AM, Jenda Krynicky wrote: While the ON CONFLICT () very explicitely insists on there being a name of a column of the table being inserted into. Makes nonsense.

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Adrian Klaver
On 12/1/21 11:43, Jenda Krynicky wrote: From: Adrian Klaver On 12/1/21 11:20 AM, Jenda Krynicky wrote: So let's suppose I have a table like this: So pretty please with a cherry on top, how do I explain to postgres 13.4, that yes indeed by "Uuid" I mean the stinking colum

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread David G. Johnston
On Wed, Dec 1, 2021 at 1:04 PM Jenda Krynicky wrote: > I did not create the table and I did not forget the quotes. I removed > them in one of many attempts to appease PostgreSQL. I've already > learned about those braindead rules. > > Nothing is perfect, especially something that started decades

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Tom Lane
"Jenda Krynicky" writes: > From: Tom Lane >> It's also possible to qualify the name in the ON CONFLICT clause, >> although I think you have to parenthesize it to do so: >> ... ON CONFLICT (("Lockers"."Uuid")) > ERROR: invalid reference to FROM-clause entry for table "Lockers" >

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Jenda Krynicky
From: "David G. Johnston" > On Wed, Dec 1, 2021 at 12:44 PM Jenda Krynicky wrote: > > > How's that a variable for gawd's sake? It's a column name too! A > > column name in the definition of the resulting table. > > > > The columns of the returns table are provided to the function as variables >

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Jenda Krynicky
From: Tom Lane > "David G. Johnston" writes: > > On Wed, Dec 1, 2021 at 12:21 PM Jenda Krynicky wrote: > >> THERE IS NO (CENSORED) VARIABLE "Uuid"! > > > Yes, there is. RETURNS TABLE (... "Uuid" text ... ) > > > Changing that to something else should remove the ambiguity. I

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread David G. Johnston
On Wed, Dec 1, 2021 at 12:59 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Wed, Dec 1, 2021 at 12:52 PM Tom Lane wrote: > >> It's also possible to qualify the name in the ON CONFLICT clause, >> although I think you have to parenthesize it to do so: >> >> ... ON CONFLICT (("Locker

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread David G. Johnston
On Wed, Dec 1, 2021 at 12:52 PM Tom Lane wrote: > It's also possible to qualify the name in the ON CONFLICT clause, > although I think you have to parenthesize it to do so: > > ... ON CONFLICT (("Lockers"."Uuid")) > > This really needs to be confirmed and, if so, better documented on the INSERT p

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread David G. Johnston
On Wed, Dec 1, 2021 at 12:44 PM Jenda Krynicky wrote: > How's that a variable for gawd's sake? It's a column name too! A > column name in the definition of the resulting table. > The columns of the returns table are provided to the function as variables so that one can write: output_column1 :=

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Tom Lane
"David G. Johnston" writes: > On Wed, Dec 1, 2021 at 12:21 PM Jenda Krynicky wrote: >> THERE IS NO (CENSORED) VARIABLE "Uuid"! > Yes, there is. RETURNS TABLE (... "Uuid" text ... ) > Changing that to something else should remove the ambiguity. I agree it is > not an ideal solution though. I'

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Jenda Krynicky
From: Adrian Klaver > On 12/1/21 11:20 AM, Jenda Krynicky wrote: > > So let's suppose I have a table like this: > > > > > > > So pretty please with a cherry on top, how do I explain to postgres > > 13.4, that yes indeed by "Uuid" I mean the stinking column "Uuid". > > The bas

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Jenda Krynicky
From: "David G. Johnston" > On Wed, Dec 1, 2021 at 12:21 PM Jenda Krynicky wrote: > > > > > CREATE OR REPLACE FUNCTION public.findorcreatelocker( > > lockeruuid text, > > ipaddress text) > > RETURNS TABLE("Id" integer, "Created" timestamp without time > > zone, "Uuid" text,

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread David G. Johnston
On Wed, Dec 1, 2021 at 12:21 PM Jenda Krynicky wrote: > > CREATE OR REPLACE FUNCTION public.findorcreatelocker( > lockeruuid text, > ipaddress text) > RETURNS TABLE("Id" integer, "Created" timestamp without time > zone, "Uuid" text, "State" integer, "ConnectionStatus" integer,

Re: INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Adrian Klaver
On 12/1/21 11:20 AM, Jenda Krynicky wrote: So let's suppose I have a table like this: So pretty please with a cherry on top, how do I explain to postgres 13.4, that yes indeed by "Uuid" I mean the stinking column "Uuid". The basic issue is described here: https://www.postgresql.org/docs/c

INSERT ... ON CONFLICT doesn't work

2021-12-01 Thread Jenda Krynicky
So let's suppose I have a table like this: CREATE TABLE IF NOT EXISTS public."Lockers" ( "Id" integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), "Uuid" text COLLATE pg_catalog."default", "IpAddress" text COLLATE pg_catalog