Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oLOJb-0004p6-39 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Aug 2022 12:26:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oLOJZ-000216-VO for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Aug 2022 12:26:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oLOJZ-00020x-IU for pgsql-hackers@lists.postgresql.org; Tue, 09 Aug 2022 12:26:29 +0000 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oLOJU-0003VA-NN for pgsql-hackers@lists.postgresql.org; Tue, 09 Aug 2022 12:26:28 +0000 Received: by mail-il1-x133.google.com with SMTP id p10so6400246ile.5 for ; Tue, 09 Aug 2022 05:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc; bh=L8JD54I5Je5tchkSg987U+uofpIVXsrxGrvWv8GOTLU=; b=WKL6SEd3z7uA26xclFePNLyeFXyzJ1NHMvFtiLpDplhtuYkIp5elJCCHw43HVIIh7s FItpfEPW6Ow8myzv9HMRMnFV+/OwDRMwT88p4uS4nmAp2mDNEo2ogAJj0l2y1sOii4Nt EcLm3almm1r2dRLSEoTvvhZzJx0S8f10rSpJSd2ZqrrUvYgp0g1Iw4NfgsslFZq8pqWR Yb8D5/tRANMA5VR5GZYwrsqz/JlGK3u3wNtMEYq0rPOlU0KsIcN4NU8yJi8BCWw3cnW8 8UOYS+h1qsPqE1ZU5gE4E2n/yM/vN+scpRLoZAKSCAHrUCNJobumqWKs7JrbnyY3pkwQ HG8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc; bh=L8JD54I5Je5tchkSg987U+uofpIVXsrxGrvWv8GOTLU=; b=oFaxn0RhNaQkoIu+cJzqRKIblc6gi+CNSgpJbDzTkaywftaMwSEs3bqqZPEQpBHpjf xBbxPBXG/VIICoteeb9cDf9D01OTEOhCZ68dJIeRjPsBdKsxgA3Q623wCZ8AiuVRAGMV pda7x9uVrlNbxpCO5z2/U8zBkQgWcyIcRPhe8SSDjrG8THGhCpEPIaUaOVuuqPl+DpKP LF8yJ5abK29JrB3CUQNNaDI7imNwsAKkPbZVu8lJG0bZ0oK8qbSt69UPYhTFd/XslojE ca48AM8OzlMdbRd+y0FxcQlt99RrcIrwWmqLlBNuDSCr4KvIeoIJQcNqReYZ9xLBP8O7 Ja8Q== X-Gm-Message-State: ACgBeo1bs6oZ3ouJk+axhs/ombqtfkrHV/6Ve2TR7wHnyZlfuyg5s89y l0B93LdeNI+Nz/Du8HTcJKKD3Q== X-Google-Smtp-Source: AA6agR5n5+mD0vcsLAFj0PXOQCbLkUVroKdTBrxrik/xebD5B/r69M4J8siiHxY4NJhv88NAONkVfA== X-Received: by 2002:a05:6e02:14c7:b0:2e1:efe:c83b with SMTP id o7-20020a056e0214c700b002e10efec83bmr3875760ilk.172.1660047983716; Tue, 09 Aug 2022 05:26:23 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id f10-20020a056638112a00b003431db7ef37sm1577142jar.165.2022.08.09.05.26.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Aug 2022 05:26:23 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 291F0800990; Tue, 9 Aug 2022 07:26:22 -0500 (CDT) Date: Tue, 9 Aug 2022 07:26:22 -0500 From: Justin Pryzby To: =?iso-8859-1?Q?=C1lvaro?= Herrera Cc: Peter Eisentraut , Amit Langote , Japin Li , Zhihong Yu , Simon Riggs , pgsql-hackers@lists.postgresql.org, Tomas Vondra , Daniel Westermann , Erik Rijkers , Jaime Casanova , Andres Freund Subject: Re: support for MERGE Message-ID: <20220809122621.GC19644@telsasoft.com> References: <20220801153030.q7wn6phsagjohawm@alvherre.pgsql> <20220809094823.xby5o2ww33euubwi@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220809094823.xby5o2ww33euubwi@alvherre.pgsql> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Aug 09, 2022 at 11:48:23AM +0200, Álvaro Herrera wrote: > On 2022-Aug-01, Álvaro Herrera wrote: > > > > > If MERGE attempts an INSERT > > > > and a unique index is present and a duplicate row is concurrently > > > > + inserted, then a uniqueness violation error is raised; > > > > + MERGE does not attempt to avoid such > > > > + errors by evaluating MATCHED 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 UPDATE." to "...by evaluating > > > MATCHED 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 MERGE attempts an INSERT > and a unique index is present and a duplicate row is concurrently > inserted, then a uniqueness violation error is raised; > MERGE does not attempt to avoid such > errors by restarting evaluation of MATCHED > 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