Re: BUG #17845: insert into on conflict bug .

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "digoal(at)126(dot)com" <digoal(at)126(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17845: insert into on conflict bug .
Date: 2023-03-16 13:10:26
Message-ID: 3759407.1678972226@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Thursday, March 16, 2023, PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message jian he 2023-03-16 14:28:27 Re: BUG #17845: insert into on conflict bug .
Previous Message David G. Johnston 2023-03-16 12:22:23 Re: BUG #17845: insert into on conflict bug .