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 1tp2g0-00HNVr-Fj for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Mar 2025 10:05:32 +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 1tp2fy-003YMt-RJ for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Mar 2025 10:05:30 +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 1tp2fx-003YGj-Tk for pgsql-hackers@lists.postgresql.org; Mon, 03 Mar 2025 10:05:30 +0000 Received: from fout-b5-smtp.messagingengine.com ([202.12.124.148]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tp2fv-000gwN-13 for pgsql-hackers@lists.postgresql.org; Mon, 03 Mar 2025 10:05:28 +0000 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id F34751140197; Mon, 3 Mar 2025 05:05:25 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Mon, 03 Mar 2025 05:05:26 -0500 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=fm3; t=1740996325; x=1741082725; bh=Z7yD2Z+LsrroqOGB8JGwBEJbPux3D7NV t+JywRQN4wc=; b=RlqoYWRfKtC+0NYFvGlfQGZBpNznrQiyNg8+Mv2v6DyW3Lv+ LFJ/i14lVEPWI+zRi2pM+gft3LK6oFjALrs4PIP5CMgulMvEJ1iqeVis5Sy8XyI0 DWQQmc1FuvmeBfTt+ZABElHk9/YBqutehoDxqCXoIF4kH5ilwDhD39MU5X+/G/3B ZL8Z/mfKY0B3ukmdMKLWm9P1cVXzMC7LX2wa/0kwTKEIikauZrhcoj7eAY09UNap qZ60nghaN/csYE7RuvnTuUuvZ268XjQn7TSsWBdL5gtPrcl6v4u9XbUUn7rN39am 1jvOXpAtMhstXgB+f1ScDATwyclytWQZvm6eRQ== 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-sender:x-me-sender:x-sasl-enc; s=fm1; t=1740996325; x= 1741082725; bh=Z7yD2Z+LsrroqOGB8JGwBEJbPux3D7NVt+JywRQN4wc=; b=M IITiqwMA7NMl6xcO8X9zPKWhjJ0K+aSUsM0ZxWIqWGzaHzBYnWBjT5Mkrbl2jrtc RsA9DW712TIcrwY80vQMmC4VnDoG5WXkS+TH7N18QZ5ZDWltkcphjIcAlLg7hBuL w+mPD/W1v01YJm0erBH8CsEoXu5LMDRKZsWZ/V59KGTfZlwNyMJySS57TVbPS1SY FiZvNTPdsf76JFhVPtHPXqykbQywtLUlj4WkNeUKEDgbzeSggLj2QKltZikSCSl2 TFKuSwlsNhfCpjXEH7Ux5Sq0GjmfxdN/n3ecKAgX7xNy0zgZYVJY/MCpRJ+bL6LR qBrt/iep9t7fXDVDqARUg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdelkeekgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddv jeenucfhrhhomheprfgvthgvrhcugfhishgvnhhtrhgruhhtuceophgvthgvrhesvghish gvnhhtrhgruhhtrdhorhhgqeenucggtffrrghtthgvrhhnpefgjedthfekfedtuefgieel heetleejgefhueeltdfhueetvdffudekfeejhfegheenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrsegvihhsvghnthhrrghuthdr ohhrghdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh epphhjsehilhhluhhmihhnrghtvggutghomhhpuhhtihhnghdrtghomhdprhgtphhtthho pehjihgrnhdruhhnihhvvghrshgrlhhithihsehgmhgrihhlrdgtohhmpdhrtghpthhtoh epphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg pdhrtghpthhtohepvhhighhnvghshhdvudesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Mar 2025 05:05:24 -0500 (EST) Message-ID: <22c4dd72-66fa-4f76-95f2-757d754e2aad@eisentraut.org> Date: Mon, 3 Mar 2025 11:05:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: SQL:2011 application time To: Paul Jungwirth Cc: jian he , PostgreSQL Hackers , vignesh C References: <66e47fc0-77b7-4763-9b70-5c0b7ff15f21@eisentraut.org> <333d3886-b737-45c3-93f4-594c96bb405d@eisentraut.org> <6a2247d9-461d-4b0a-b692-f0f3c0fab27f@eisentraut.org> <8f995a4c-64e3-40cd-bfed-06b54a280d36@illuminatedcomputing.com> <0832f18d-523f-4c15-acb0-338a785150c5@illuminatedcomputing.com> <5f0c25de-2c13-4fb5-a4df-a1e03c43cd14@illuminatedcomputing.com> <1b45f81d-4e99-4813-a2c6-72bf5fd80980@eisentraut.org> <3e061027-781d-42c1-b6e8-bafbf3b51033@eisentraut.org> <3b33690e-0d67-47a5-8424-93ac1fed4c26@eisentraut.org> <1085d8a3-17a7-4639-afd2-bd6dfa09713d@illuminatedcomputing.com> Content-Language: en-US From: Peter Eisentraut In-Reply-To: <1085d8a3-17a7-4639-afd2-bd6dfa09713d@illuminatedcomputing.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 26.02.25 06:15, Paul Jungwirth wrote: > I agree with that last principle: it shouldn't matter how the primary > keys are split up. But it seems to me that "matches" in the standard > should include the period. It does for NO ACTION, so why not RESTRICT? > That's why your example of expanding the referenced range succeeds. None > of the referenced moments were changed, so there are no referencing > moments to match. > > > I'm not sure what other behavior of RESTRICT there might be that is > internally consistent and is > > meaningfully different from NO ACTION. > > The difference between RESTRICT and NO ACTION for temporal foreign keys > is the same as the difference for ordinary foreign keys: we perform the > check prior to applying any "action" or allowing any other commands to > provide substitutes for the lost references. There are tests in sql/ > without_overlaps.sql showing how their behavior differs. > > Also you haven't yet explained why anyone would *want* to use RESTRICT > as you've described it, since the temporal part of the key is just > ignored, and they could just define a non-temporal foreign key instead. > Or to be precise, it fails *more* than a non-temporal foreign key, > because changing the period can violate the constraint, even though we > ignore the period when looking for matches. This is not what I'm aiming for. (Maybe my patches were wrong about that.) In the theory of the SQL standard, executing referential actions and checking the foreign-key constraint are two separate steps. So it kind of goes like this: 1. run command 2. run any referential actions 3. check that foreign key is still satisfied This is why the default referential action is called "NO ACTION": It just skips the step 2. But it still does step 3. This means that under RESTRICT and with my interpretation, the check for a RESTRICT violation in step 2 can "ignore" the period part, but the step 3 still has to observe the period part. In the implementation, these steps are mostly combined into one trigger function, so it might be a bit tricky to untangle them. > But since we don't agree on the behavior, it seems best to me to wait to > implement RESTRICT. Not much is lost, since NO ACTION is so similar. We > can wait for the SQL committee to clarify things, or see what another > RDBMS vendor does. I'm fine with that.