MERGE docs adjustments
authorAlvaro Herrera <[email protected]>
Fri, 12 Aug 2022 11:16:50 +0000 (13:16 +0200)
committerAlvaro Herrera <[email protected]>
Fri, 12 Aug 2022 11:16:50 +0000 (13:16 +0200)
Per Justin Pryzby

Discussion: https://postgr.es/m/20220801145257[email protected]
Discussion: https://postgr.es/m/20220714162618[email protected]

doc/src/sgml/mvcc.sgml
doc/src/sgml/ref/merge.sgml

index 14b51db55e3d4a3aa6945213c943b434fc48272d..337f6dd42945a2d3c1afd5452a30dcc502a11f29 100644 (file)
     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.
+    errors by restarting evaluation of <literal>MATCHED</literal>
+    conditions.
    </para>
 
    <para>
index 7f73f3d89c5de6a7aa55a651833a386c3bce3c7e..a129a6edd5bbb79848d44701646b8b460803ccec 100644 (file)
@@ -266,10 +266,6 @@ DELETE
       filled with a default value, either its declared default value
       or null if there is none.
      </para>
-     <para>
-      If the expression for any column is not of the correct data type,
-      automatic type conversion will be attempted.
-     </para>
      <para>
       If <replaceable class="parameter">target_table_name</replaceable>
       is a partitioned table, each row is routed to the appropriate partition
@@ -581,12 +577,12 @@ WHEN NOT MATCHED THEN
 <programlisting>
 MERGE INTO CustomerAccount CA
 USING (Select CustomerId, TransactionValue From RecentTransactions) AS T
-ON CA.CustomerId = T.CustomerId
+ON T.CustomerId = CA.CustomerId
+WHEN MATCHED THEN
+  UPDATE SET Balance = Balance + TransactionValue;
 WHEN NOT MATCHED THEN
   INSERT (CustomerId, Balance)
   VALUES (T.CustomerId, T.TransactionValue)
-WHEN MATCHED THEN
-  UPDATE SET Balance = Balance + TransactionValue;
 </programlisting>
   </para>