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 1rnh9L-00Ea8f-ME for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Mar 2024 15:49:44 +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 1rnh9J-004nCi-Ux for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Mar 2024 15:49:42 +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 1rnh9I-004nCa-QX for pgsql-hackers@lists.postgresql.org; Fri, 22 Mar 2024 15:49:42 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rnh9A-005sQm-QI for pgsql-hackers@lists.postgresql.org; Fri, 22 Mar 2024 15:49:40 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id D5AAC5C007F; Fri, 22 Mar 2024 11:49:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 22 Mar 2024 11:49:32 -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=fm1; t=1711122572; x=1711208972; bh=aejBSh2I3zupA5OUPUMkuNYUJmIXMOv9 h3rHaQvKY6E=; b=PFGQf5HLNIQehq1w90A1popiceeSnUs07ChnEiarBNTFjIhz CCCSEyVF2lVbtCdqnNSoivZFZ1poT9rtihoXYB7oD4S/Gzl4OKi60hiAsQKVxV7y aVMfJtk9ctK8bPDoXC3POtvwgxCFwiFvj1nRrVXLdmSsnkTfwhS/SSAdtzaZkPEt fbL1RGEHvgyT1PBWYIm+/uqssRn9g3VOJuUTL7HpKxn7LKrnOIMvWzGdsKLi0Fj+ eC1mLz3ZEHJoxT1ZYONXpsTGjwCEPQfgGRupSwn5wlu70rrFhEHUivskW9Sm/lag eYBd9jxLzqxl0DObULlSbBUY6xXk6PI0zN8eww== 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=fm2; t=1711122572; x= 1711208972; bh=aejBSh2I3zupA5OUPUMkuNYUJmIXMOv9h3rHaQvKY6E=; b=m E8iVLW7bjatBUVr7RYr0G7wCuYS+4+or07Jg4B0a11FdosR3yGJLE8PujYSJsvcb yySRCgF8Vj83CMhZxm1u4tAkKf1z+ljdrlk5TMK/c1HhLKv9hf1SWpqc1vJfExV+ iR5u/IsJKKmQkafzIEp6KAv/2aUFYY0bL8ch7Q7Qv3e/+CBZloAexQwGfLvKssrr naPAsAXizmKYRmfvyh/nPkQSLEnFcUTIAjwd0J3hDn096ERLD9nD2B7VHFSB3nv8 U56h/2VDSYMLhRUFBPBtn7ocUbEoX1pvkpvdPq7RtxaU2u+V+flR9+F7jSYboPl8 FxQpDl7vs9KgOvJ16rabQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddtvddgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgh eqnecuggftrfgrthhtvghrnhepjefhveehtdetgfffhffhfeefgffghffflefgieeuueek hedvhedvfeehffdvfeeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepphgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhg X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Mar 2024 11:49:31 -0400 (EDT) Message-ID: <49c07eac-18ec-4aff-929c-e81b87df1092@eisentraut.org> Date: Fri, 22 Mar 2024 16:49:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: SQL:2011 application time Content-Language: en-US To: Paul Jungwirth , jian he Cc: PostgreSQL Hackers References: <7bd1c8f9-a91a-41a3-990e-0f796ba692ec@eisentraut.org> <6c3edb2c-bc45-4f19-babd-8f4edf39b384@illuminatedcomputing.com> <41b57948-f4d3-455f-8880-e0ce7e61ffc1@illuminatedcomputing.com> <0d977c63-f4a6-43ba-aad0-35c06c55df11@eisentraut.org> <85dd3ad0-fa79-46e8-a08b-c426c76825f3@eisentraut.org> From: Peter Eisentraut In-Reply-To: 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 On 22.03.24 01:35, Paul Jungwirth wrote: > > 1. In ri_triggers.c ri_KeysEqual, you swap the order of arguments to > ri_AttributesEqual(): > > > > -           if (!ri_AttributesEqual(riinfo->ff_eq_oprs[i], > RIAttType(rel, attnums[i]), > > -                                   oldvalue, newvalue)) > > +           if (!ri_AttributesEqual(eq_opr, RIAttType(rel, attnums[i]), > > +                                   newvalue, oldvalue)) > > > > But the declared arguments of ri_AttributesEqual() are oldvalue and > newvalue, so passing them > > backwards is really confusing.  And the change does matter in the tests. > > > > Can we organize this better? > > I renamed the params and actually the whole function. All it's doing is > execute `oldvalue op newvalue`, casting if necessary. So I changed it to > ri_CompareWithCast and added some documentation. In an earlier version > of this patch I had a separate function for the PERIOD comparison, but > it's just doing the same thing, so I think the best thing is to give the > function a more accurate name and use it. Ok, I see now, and the new explanation is better. But after reading the comment in the function about collations, I think there could be trouble. As long as we are only comparing for equality (and we don't support nondeterministic global collations), then we can use any collation to compare for equality. But if we are doing contained-by, then the collation does matter, so we would need to get the actual collation somehow. So as written, this might not always work correctly. I think it would be safer for now if we just kept using the equality operation even for temporal foreign keys. If we did that, then in the case that you update a key to a new value that is contained by the old value, this function would say "not equal" and fire all the checks, even though it wouldn't need to. This is kind of similar to the "false negatives" that the comment already talks about. What do you think?