Re: Upsert error "column reference is ambiguous" - Mailing list pgsql-general

From Tim Starling
Subject Re: Upsert error "column reference is ambiguous"
Date
Msg-id 80f95342-cc09-4236-a2d7-68538fbfc41b@wikimedia.org
Whole thread Raw
In response to Re: Upsert error "column reference is ambiguous"  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Upsert error "column reference is ambiguous"
Re: Upsert error "column reference is ambiguous"
List pgsql-general
On 28/4/25 20:54, Tom Lane wrote:
> Even if I were on board with arbitrarily adopting one of the two
> possible interpretations, it's far from obvious to me that most people
> would agree that "v" should mean the value from the existing row,
> rather than the new value.  Better to make them say which they want.

OK sure, no way to tell, but if every other DBMS does it the same way 
then that might be a hint.

Also, I'm just saying, the upsert feature is fully useless to me with 
this name resolution policy.

In the single-row case, there's no need for EXCLUDED at all, because 
the client knows everything about the excluded row. Recall my example:

INSERT INTO t VALUES (1,1) ON CONFLICT (k) DO UPDATE SET v=v+1;

If I meant SET v=EXCLUDED.v+1 I would have just written v=2. The 
default policy (in other DBMSes) follows by analogy from the 
single-row case.

-- Tim Starling




pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Wal Files not removing automatically
Next
From: Laurenz Albe
Date:
Subject: Re: Upsert error "column reference is ambiguous"