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 1tBdh6-0059HV-Pk for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Nov 2024 17:31:48 +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 1tBdh3-0061ux-VZ for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Nov 2024 17:31:46 +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 1tBdh3-0061um-Co for pgsql-hackers@lists.postgresql.org; Thu, 14 Nov 2024 17:31:45 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tBdh1-001s2j-4t for pgsql-hackers@lists.postgresql.org; Thu, 14 Nov 2024 17:31:44 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-20cceb8d8b4so5823125ad.1 for ; Thu, 14 Nov 2024 09:31:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=illuminatedcomputing-com.20230601.gappssmtp.com; s=20230601; t=1731605502; x=1732210302; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=hpq76D9wDVgg8xsMGJc5hUv4E3P8auffSY7rej9EmB0=; b=vQKDwOJg3DvnzbK8a4hgN1Smq7qaQxalIxoYT7egBI7S6Iv7El7aB56zJT6Jbl2/SY 8chaQxthNuzFaeaxSVZ4ggIm+D497CnV/KHEfrpPb9mcbb1oAz7zmYu7MRYXlmHfBYzx uWZ+MgC/ZkMXe3WKH/6xq7R1zT+uD9BmGShmijajetoupWMrEQO2GnXRzYU1nci/CdI1 M+gyQ87f4g0zfCizksvpD9BMLBUTgxJJbMcSKpzp2v5T3yeWeZcT5MnMfROuNPxglYGh SF/6fYnXUUwlfBXkGBlYQuXTrpEsPrQe18SakbdmGYaZfW41h2HfLARFjnD2TCIm1U1k /CAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731605502; x=1732210302; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hpq76D9wDVgg8xsMGJc5hUv4E3P8auffSY7rej9EmB0=; b=FNd+9A/wSUkOjZXLVNNugCKzVo65pJ4f2qMnKnp1ybSM97r5BlQhI1vWkn4vUxaQsU UA0+P9zPZlYCXkN9UzUzZ8uCIuidJNNiln1sEQ9jU8FHXrNnWXsY3eT96dtruMBS0DzK c6OftsTYw+wZcCGZ0aAhozZk2rrEj/Oh3VmpaAK63HAHSysX0LtbUm8OunlLT5tcPkMh fkNIMVhPTZktrzGQ0rn7pqo0uqryvbGlq00ISGdqi7BG86tYRq6Hono5lfWEISPaYfju C6PDBy6Fp3dechGV37YjI6c/CDYCxO8RzSALJTqBC6c0ilAYp/iI4rUCoq4+mskI+anW 6aIw== X-Forwarded-Encrypted: i=1; AJvYcCWqr3ZRpnPYJEebw89+HkXAFTEWaICvmPqmbCFks60p+yThaHNjplFNbQNo8soz5mLu37bmPTVTlZTaBAnO@lists.postgresql.org X-Gm-Message-State: AOJu0Yy9osEgLXMf5myK+mC0x1y7olWYTtaGPF3xWXB9b+yP7cYodCCj DzGTrLcEfCSmaAAsTkC+0ey122ME+rjtTcdfjREGKtuGppuhstLwhnvoX2GAnLY= X-Google-Smtp-Source: AGHT+IHQJ4yyu1TL+NYsFnEv3x+pXmlhsH2ZnG69iy+WiuwrXsP0LWT3tS9PGEO74aAYftNcr7rELQ== X-Received: by 2002:a17:903:120e:b0:205:7007:84fa with SMTP id d9443c01a7336-211c0fbcda4mr62382095ad.28.1731605502093; Thu, 14 Nov 2024 09:31:42 -0800 (PST) Received: from [192.168.2.139] ([50.39.255.79]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-211c7c522b9sm13282775ad.79.2024.11.14.09.31.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Nov 2024 09:31:41 -0800 (PST) Message-ID: <78b43581-35f6-4478-8d8a-98e66a763e74@illuminatedcomputing.com> Date: Thu, 14 Nov 2024 09:31:40 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: SQL:2011 application time From: Paul Jungwirth To: Sam Gabrielsson Cc: Peter Eisentraut , jian he , Isaac Morland , Robert Haas , Jeff Davis , PostgreSQL Hackers References: <73d09e24-b6b9-4c89-8c0a-8842ca0f81f9@illuminatedcomputing.com> <081aa43c-3a97-4bd5-a498-ba02e0a7570d@illuminatedcomputing.com> <54390149-11d6-4f52-bbe8-f69832ceb3bd@eisentraut.org> <9b7cb814-c78c-489f-85b2-32be4398647f@illuminatedcomputing.com> <95c6d49b-7d60-4ad0-820c-e00ae1b2a3d4@illuminatedcomputing.com> <57ea0668-5205-426e-b934-efc89f2186c2@illuminatedcomputing.com> <3b0e067d-9a78-46f7-8027-99c19e7cde44@illuminatedcomputing.com> Content-Language: en-US In-Reply-To: <3b0e067d-9a78-46f7-8027-99c19e7cde44@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 Just sharing my progress here since it's been a week: On 11/6/24 17:03, Paul Jungwirth wrote: > On 11/4/24 13:16, Sam Gabrielsson wrote: >> Foreign key violation errors are incorrectly raised in a few cases for a temporal foreign key with >> default ON UPDATE NO ACTION. Test is based on the commited v39 patches (used a snapshot version of >> PG18 devel available from PGDG). > > Thank you for the report! I confirmed that this is a problem. In ri_restrict we fail if any fk > records still match the being-changed pk, but for temporal if you're merely shrinking the pk range, > fk references could still wind up being valid (if you're only shrinking it a little). So we need to > do more work. I'm nearly done with a patch for this. I'll try to wrap it up today and get it sent this evening. > IIRC for RESTRICT it is *correct* to reject the change, so we would want to keep the old SQL there, > and only update it for NOACTION. I realized there are problems with the RESTRICT case also. I've got a fix written for that too, but it needs some tidying up. I'll submit both patches together. The RESTRICT case needs to find the *lost* time span(s) (because it might not be the whole thing) and check for references to those. To do that, it calls our without_portion support function. That function was intended to support FOR PORTION OF, but it happens to be exactly what we need here. So I'm reordering the patches a bit and adjusting the documentation there. Yours, -- Paul ~{:-) pj@illuminatedcomputing.com