On Tue, Aug 09, 2022 at 11:48:23AM +0200, Álvaro Herrera wrote: > On 2022-Aug-01, Álvaro Herrera wrote: > > > > > If <command>MERGE</command> attempts an <command>INSERT</command> > > > > and a unique index is present and a duplicate row is concurrently > > > > + inserted, then a uniqueness violation error is raised; > > > > + <command>MERGE</command> does not attempt to avoid such > > > > + errors by evaluating <literal>MATCHED</literal> conditions. > > > > > > This was a portion of a chang that was committed as ffffeebf2. > > > > > > But I don't understand why this changed from "does not attempt to avoid > > > the > > > error by executing an <command>UPDATE</command>." to "...by evaluating > > > <literal>MATCHED</literal> conditions." > > > > > > Maybe it means to say "..by re-starting evaluation of match conditions". > > > > Yeah, my thought there is that it may also be possible that the action > > that would run if the conditions are re-run is a DELETE or a WHEN > > MATCHED THEN DO NOTHING; so saying "by executing an UPDATE" it leaves > > out those possibilities. IOW if we're evaluating NOT MATCHED INSERT and > > we find a duplicate, we do not go back to MATCHED. > > So I propose to leave it as > > If <command>MERGE</command> attempts an <command>INSERT</command> > and a unique index is present and a duplicate row is concurrently > inserted, then a uniqueness violation error is raised; > <command>MERGE</command> does not attempt to avoid such > errors by restarting evaluation of <literal>MATCHED</literal> > conditions.
I think by "leave it as" you mean "change it to". (Meaning, without referencing UPDATE). > (Is "re-starting" better than "restarting"?) "re-starting" doesn't currently existing in the docs, so I guess not. You could also say "starting from scratch the evaluation of MATCHED conditions". Note that I proposed two other changes in the other thread ("MERGE and parsing with prepared statements"). - remove the sentence with "automatic type conversion will be attempted"; - make examples more similar to emphasize their differences; -- Justin