Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s5QG2-005Jen-8F for pgsql-hackers@arkaria.postgresql.org; Fri, 10 May 2024 13:25:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s5QG0-00FGE4-HR for pgsql-hackers@arkaria.postgresql.org; Fri, 10 May 2024 13:25:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s5QG0-00FGDv-3R for pgsql-hackers@lists.postgresql.org; Fri, 10 May 2024 13:25:52 +0000 Received: from fhigh4-smtp.messagingengine.com ([103.168.172.155]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s5QFx-000L6l-Rl for pgsql-hackers@lists.postgresql.org; Fri, 10 May 2024 13:25:51 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id DADDD1140113; Fri, 10 May 2024 09:25:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 10 May 2024 09:25:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm2; t=1715347548; x=1715433948; bh=lQeDtRKcwj9ylldJusf+MPTpiYktNzt9 dsivVSu2QsE=; b=4jDRVgLqNLxR32+k30oPQ+n7j/EF7PGS4Ftw8Eg/kgbZWd4F ulk9tkU5ccYBYdwTyz2HkaCMBWJDImUUaIBOx4sJMODO52ZM62VQwwZC5IBP+LFg bC9IhSqaZLcpoZst4z/dKHI/xNSaT+rLuRkn2wKLuBJ2NFuxDrekpqnGalYphRwf XpNYPPOH87KWRXEZof0wezsqME35JzpI0w3T/vxKS5H9O+FI+fV2nu6/rQ14HSWt zAL+ksvOcYEueIiAlAWBs5jv263nB1v4Cyzw1p8d8KGPoQuyP00LxQ9bmmVwh6z0 KA9gIo39gDyTxinNLKjxv9sH74BIYaUfJC1fXw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1715347548; x= 1715433948; bh=lQeDtRKcwj9ylldJusf+MPTpiYktNzt9dsivVSu2QsE=; b=Q kwZ18xT32Cl/v4z+5g+4KQxb8B9MBN2HAEd/khW8t6f99aUm+0MnIE40nOiYlaza qH8NwFhIn9jbiW/9dAY5aeICiEoXmNWeppFS0tBzplex0uqFfv+uWf0AbHnyMl8a nVdNKqjeoVKMbHfwYtXxsXUfPSiJqwfqqqGp/JFDS7YPOCFGbS2WkTwHWKt/6NTE W+fkgF93c5/4QUlU7ggj1uJ7md2o82W+CStVc539CyArmO64IuN2NRPXj2tp2QAr acUjA3wEOWKsj3vAJts5lgTRa7T7UoYo3dT6aj9gjUz4dDNNXbwvBBdJ+gAsZ86v pybAU16USkPzKI/HiclNg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdefkedgieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgh eqnecuggftrfgrthhtvghrnhepjefhveehtdetgfffhffhfeefgffghffflefgieeuueek hedvhedvfeehffdvfeeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepphgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhg X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 10 May 2024 09:25:47 -0400 (EDT) Message-ID: Date: Fri, 10 May 2024 15:25:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: SQL:2011 application time To: Paul Jungwirth , Robert Haas Cc: jian he , PostgreSQL Hackers References: <85dd3ad0-fa79-46e8-a08b-c426c76825f3@eisentraut.org> <49c07eac-18ec-4aff-929c-e81b87df1092@eisentraut.org> <1edb3b79-a4bc-43b1-80aa-2e090472fe32@eisentraut.org> <47550967-260b-4180-9791-b224859fe63e@illuminatedcomputing.com> <1b2ab118-82c1-4e79-a094-04dab382e2c4@illuminatedcomputing.com> <3775839b-3f0f-4c8a-ac03-a253222e6a4b@illuminatedcomputing.com> <731ef81e-d4c3-41c6-ba8f-f6131f4f6407@eisentraut.org> <1426589a-83cb-4a89-bf40-713970c07e63@illuminatedcomputing.com> Content-Language: en-US From: Peter Eisentraut In-Reply-To: <1426589a-83cb-4a89-bf40-713970c07e63@illuminatedcomputing.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I have committed the v2-0001-Fix-ON-CONFLICT-DO-NOTHING-UPDATE-for-temporal-in.patch from this (confusingly, there was also a v2 earlier in this thread), and I'll continue working on the remaining items. On 09.05.24 06:24, Paul Jungwirth wrote: > Here are a couple new patches, rebased to e305f715, addressing Peter's > feedback. I'm still working on integrating jian he's suggestions for the > last patch, so I've omitted that one here. > > On 5/8/24 06:51, Peter Eisentraut wrote: >> About v2-0001-Fix-ON-CONFLICT-DO-NOTHING-UPDATE-for-temporal-in.patch, >> I think the >> ideas are right, but I wonder if we can fine-tune the new conditionals >> a bit. >> >> --- a/src/backend/executor/execIndexing.c >> +++ b/src/backend/executor/execIndexing.c >> @@ -210,7 +210,7 @@ ExecOpenIndices(ResultRelInfo *resultRelInfo, bool >> speculative) >>                   * If the indexes are to be used for speculative >> insertion, add extra >>                   * information required by unique index entries. >>                   */ >> -               if (speculative && ii->ii_Unique) >> +               if (speculative && ii->ii_Unique && >> !ii->ii_HasWithoutOverlaps) >>                          BuildSpeculativeIndexInfo(indexDesc, ii); >> >> Here, I think we could check !indexDesc->rd_index->indisexclusion >> instead.  So we >> wouldn't need ii_HasWithoutOverlaps. > > Okay. > >> Or we could push this into BuildSpeculativeIndexInfo(); it could just >> skip the rest >> if an exclusion constraint is passed, on the theory that all the >> speculative index >> info is already present in that case. > > I like how BuildSpeculativeIndexInfo starts with an Assert that it's > given a unique index, so I've left the check outside the function. This > seems cleaner anyway: the function stays more focused. > >> --- a/src/backend/optimizer/util/plancat.c >> +++ b/src/backend/optimizer/util/plancat.c >> @@ -815,7 +815,7 @@ infer_arbiter_indexes(PlannerInfo *root) >>           */ >>          if (indexOidFromConstraint == idxForm->indexrelid) >>          { >> -           if (!idxForm->indisunique && onconflict->action == >> ONCONFLICT_UPDATE) >> +           if ((!idxForm->indisunique || idxForm->indisexclusion) && >> onconflict->action == ONCONFLICT_UPDATE) >>                  ereport(ERROR, >>                          (errcode(ERRCODE_WRONG_OBJECT_TYPE), >>                           errmsg("ON CONFLICT DO UPDATE not supported >> with exclusion constraints"))); >> >> Shouldn't this use only idxForm->indisexclusion anyway?  Like >> >> +           if (idxForm->indisexclusion && onconflict->action == >> ONCONFLICT_UPDATE) >> >> That matches what the error message is reporting afterwards. > > Agreed. > >>           * constraints), so index under consideration can be immediately >>           * skipped if it's not unique >>           */ >> -       if (!idxForm->indisunique) >> +       if (!idxForm->indisunique || idxForm->indisexclusion) >>              goto next; >> >> Maybe here we need a comment.  Or make that a separate statement, like > > Yes, that is nice. Done. > > Yours, >