Re: BUG #17845: insert into on conflict bug . - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17845: insert into on conflict bug .
Date
Msg-id 3759407.1678972226@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #17845: insert into on conflict bug .  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thursday, March 16, 2023, PG Bug reporting form <noreply@postgresql.org>
> wrote:
>> In the following insert statement, the row has not been updated multiple
>> times, why is it still showing an error?

>> 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
>> ;

> You have id=1 in there three times which is precisely the definition of
> “multiple times” (I.e., more than 1)

Yeah.  I believe the reason for the restriction is that it would
otherwise be very uncertain what order the input rows get processed in.
(No, the "order by" won't save you, because there's still a join
to be done after that.)

            regards, tom lane



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #17845: insert into on conflict bug .
Next
From: jian he
Date:
Subject: Re: BUG #17845: insert into on conflict bug .