BUG #17845: insert into on conflict bug .

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: digoal(at)126(dot)com
Subject: BUG #17845: insert into on conflict bug .
Date: 2023-03-16 10:16:36
Message-ID: 17845-fee889ae7e226a76@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17845
Logged by: Zhou Digoal
Email address: digoal(at)126(dot)com
PostgreSQL version: 15.2
Operating system: macos
Description:

insert into on conflict bug .
In the following insert statement, the row has not been updated multiple
times, why is it still showing an error?

```
create table a (id int primary key, info text, ts date);

insert into a
select * from (values (1,'a',date '2022-01-01'),(1,'b',date
'2022-01-02'),(1,'c',date '2022-01-03')) as t (id,info,ts) order by ts
desc
on conflict (id)
do update set info=excluded.info, ts=excluded.ts where a.ts < excluded.ts ;

QUERY PLAN
--------------------------------------------------------------------------
Insert on a (cost=0.06..0.10 rows=0 width=0)
Conflict Resolution: UPDATE
Conflict Arbiter Indexes: a_pkey
Conflict Filter: (a.ts < excluded.ts)
-> Sort (cost=0.06..0.07 rows=3 width=40)
Sort Key: "*VALUES*".column3 DESC
-> Values Scan on "*VALUES*" (cost=0.00..0.04 rows=3 width=40)
(7 rows)

ERROR: 21000: ON CONFLICT DO UPDATE command cannot affect row a second
time
HINT: Ensure that no rows proposed for insertion within the same command
have duplicate constrained values.
LOCATION: ExecOnConflictUpdate, nodeModifyTable.c:2054
```

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2023-03-16 11:01:42 BUG #17846: pg_dump doesn't properly dump with paused WAL replay
Previous Message Sébastien 2023-03-16 07:40:08 Re: BUG #17840: Failing to execute auto_explain for logging leads to transaction rollback.