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 1tiZBl-00HRkn-A3 for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2025 13:23:33 +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 1tiZBj-007MDt-DH for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2025 13:23:32 +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 1tiZBi-007MDb-AD for pgsql-hackers@lists.postgresql.org; Thu, 13 Feb 2025 13:23:31 +0000 Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tiZBg-000aGK-2o for pgsql-hackers@lists.postgresql.org; Thu, 13 Feb 2025 13:23:30 +0000 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 3BC371380989; Thu, 13 Feb 2025 08:23:28 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Thu, 13 Feb 2025 08:23:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc: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=1739453008; x= 1739539408; bh=rRog73FeO5WMjal0vC7PSnjPkOLwISEQyHHiAeKO2tU=; b=A 2BJ2aLe5DxlCaeueQ/1T5ZPDfD5f5ou+V3gxnVAbVx8J16Zk09amuCHtwOapuEMG 62ypncbDs8jY7C0acTIUtmolWTgQZlBmWWbeLVjfaQ5GxWSL7geGmkou/NMQJtrN jGQJBH8YxiNPKitaBBcy3Qa+WvdwCzyG+aJTidhObfCasXU+yMXuA4pZrG5WL6bZ +VF6cItBVt9dFskSq6GM+z5j8Cc3ukdgvwByI6QNcQWosUgBNQBNGVNo4QfkjEXd 8DgDiOefJMYyhzRfPKbVSKlaySr8GAO7rgji5nAqU4QHvqmyYTuEsu0Rbwe2l770 /mHE3+TbYWbbEAiiBftuQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=fm3; t= 1739453008; x=1739539408; bh=rRog73FeO5WMjal0vC7PSnjPkOLwISEQyHH iAeKO2tU=; b=yzcSMPwdj2lQe+Mvs0+BJvxj3jxz2sftFBpMB3PbCknWSatVO40 Dzy19o1o215pmXVpv95dPnqn8KiGWlHPLPUmrXqovesw/+gDQ89DB9+kXcrh7piX 6XeciUDn+q4wDFGlE6HkPYiDDkPReIgZtcSo9W4ZCAQlH1pD1cCq6tT30EwZkDgp 2hCB3YcMyPzCKXYaN5N0XjklvSHai5/9NLghzzXqLc/VG+/UP69f6i0336lYu6SN n8oPMuTjsldql78IXn3L6+nRoj06HrP1gdhO/J+/bNrJ28kXujI8bkSRmBgfpdhf Jcfs9wCXB4UOALYnzbjsM+vLayd5dnGqGmA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdegieekkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpegtkfffgggfuffhvfevfhgjsehmtderredtvdej necuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghuthcuoehpvghtvghrsegvihhsvg hnthhrrghuthdrohhrgheqnecuggftrfgrthhtvghrnhepledtheekleffieevfedtkeel veevfeekkeevheehvdejfefgveethfetiedtuedvnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhesvghishgvnhhtrhgruhhtrdho rhhgpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhope hpjhesihhllhhumhhinhgrthgvuggtohhmphhuthhinhhgrdgtohhmpdhrtghpthhtohep jhhirghnrdhunhhivhgvrhhsrghlihhthiesghhmrghilhdrtghomhdprhgtphhtthhope hpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrghdp rhgtphhtthhopehvihhgnhgvshhhvddusehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Feb 2025 08:23:27 -0500 (EST) Content-Type: multipart/mixed; boundary="------------yb78c8EgP02btOrF14ZNzl7V" Message-ID: <3e061027-781d-42c1-b6e8-bafbf3b51033@eisentraut.org> Date: Thu, 13 Feb 2025 14:23:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: SQL:2011 application time From: Peter Eisentraut To: Paul Jungwirth Cc: jian he , PostgreSQL Hackers , vignesh C References: <95c6d49b-7d60-4ad0-820c-e00ae1b2a3d4@illuminatedcomputing.com> <57ea0668-5205-426e-b934-efc89f2186c2@illuminatedcomputing.com> <6dc196d4-8853-49d7-8dd3-e391058451c1@eisentraut.org> <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> Content-Language: en-US In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------yb78c8EgP02btOrF14ZNzl7V Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 23.01.25 16:40, Peter Eisentraut wrote: > I think my interpretation of what RESTRICT should do is different. > > The clause "Execution of referential actions" in the SQL standard only > talks about referenced and referencing columns, not periods.  So this > would mean you can change the period columns all you want (as long as > they maintain referential integrity).  So it would be like the NO ACTION > case.  But you can't change any of the non-period columns on the primary > key if they are referenced by any referencing columns, even if the > respective periods are disjoint. > > Maybe this makes sense, or maybe this is a mistake (neglected to update > this part when periods were introduced?).  But in any case, I can't get > from this to what the patch does.  When I apply the tests in the patch > without the code changes, what I would intuitively like are more errors > than the starting state, but your patch results in fewer errors. After staring at this a bit more, I think my interpretation above was not correct. This seems better: The clause "Execution of referential actions" in the SQL standard only talks about referenced and referencing columns, not periods. The RESTRICT error is raised when a "matching row" exists in the referencing table. The "matching row" is determined purely by looking at the "normal" columns of the key, not the period columns. So in our implementation in ri_restrict(), ISTM, we just need to ignore the period/range columns when doing the RESTRICT check. Attached is a quick patch that demonstrates how this could work. I think the semantics of this are right and make sense. --------------yb78c8EgP02btOrF14ZNzl7V Content-Type: text/plain; charset=UTF-8; name="0001-WIP-Fix-RESTRICT-behavior-for-temporal-foreign-keys.patch.nocfbot" Content-Disposition: attachment; filename*0="0001-WIP-Fix-RESTRICT-behavior-for-temporal-foreign-keys.pat"; filename*1="ch.nocfbot" Content-Transfer-Encoding: base64 RnJvbSA3ZDJhZTIyNmRhNjc4Mzg4MjUxMjBmNzU5YTkxMjM2MmNmOTFlMDY1IE1vbiBTZX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