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 1s5weE-0099CQ-DJ for pgsql-hackers@arkaria.postgresql.org; Sun, 12 May 2024 00:01:02 +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 1s5weC-007pzs-0p for pgsql-hackers@arkaria.postgresql.org; Sun, 12 May 2024 00:01:00 +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 1s5weB-007pzk-Nf for pgsql-hackers@lists.postgresql.org; Sun, 12 May 2024 00:01:00 +0000 Received: from mail-vk1-xa33.google.com ([2607:f8b0:4864:20::a33]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s5we8-000YVI-R8 for pgsql-hackers@lists.postgresql.org; Sun, 12 May 2024 00:00:58 +0000 Received: by mail-vk1-xa33.google.com with SMTP id 71dfb90a1353d-4df3da90b6cso1227040e0c.2 for ; Sat, 11 May 2024 17:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715472055; x=1716076855; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VMjXb8Yx7liRpoPoBhALbShb52Eioojk1JZyKz191V8=; b=aJSnX0vWHg5JFrS60cLIdx3lg5384SImS4QMp4eRd1LUA9wpwbFqvyuPsm2LU82Js1 uM6FvRaKPhs8DprBwZK+K5vJkaTs/xRRGR6192X5zBCFOKYkqz/nby2Wg4hHYBeKwUI3 v/eD/kD5F69L2LDW+LgDIuxdrP0gG020LMJecK+9lLui6hMUt0oRtoZKNQDX4ZjpTyCU MuYYQTAwm2paGw1eOHqxOlIL8d3rZRqqy1ZdN697O1VAnGczNjXe71ygu+lz1vbmty7n LgCfPYSLaDbPTER2ojhZHivZPvg7l6VK+FAr/WVOh6GF/qajHbiqj0h+lt8wNFZ9AA7Q a1ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715472055; x=1716076855; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VMjXb8Yx7liRpoPoBhALbShb52Eioojk1JZyKz191V8=; b=hFk2khYFQ2AE1mAb2JxmZPsxUonGvL6uNyXPevmSshs/pqKkgPKA/D0I+CCA7Omrh3 kURYV8kwqaHwziV/84ayzIdQr2mvKzIz4OJfdcTsEhhJ84sgPGQmSRJCjxH+2ycE18tt 5SsHqTeHnhX6pe9VqsQprdhJWOldI4TuQUZfF7uYB96Bu3c/cdbICPwONNy62bpViNRn AVrP48wSGmUJEWm/mzZLTED+pBGVk7PGsVRsXBNfKtw33hPv/Nt7OJgR9HIYaJ0XTVTm dpSYcepO9CewUUZuDO19hy926GqizqYfLORajejgnQI/WXg718ODtx7+kBevVr9xX58I w4xg== X-Forwarded-Encrypted: i=1; AJvYcCWfulhF8SBV5dukTYnwpInuyayiW1rakD+DB5lL1shAxTMRZ/qB4XFY4Raj5ARDH+v+156kyrpshPCe5dj5xmKzxmwjcMC5hs5Hw76ALwtOBiov X-Gm-Message-State: AOJu0YyhPjmnraU6HUJ7XSHEL82PivaYTZCqZUyEnHeDo5wkhf9EGl7n 58aDXs+5+NbrkUnq3Ws2xxat7hP6RgKf334e1PHKKd9x+nshzVffTyByI8yFnPiy1pacGbyZotF CJgvxsKp1sLOEYAHii6UjhJT+nCA= X-Google-Smtp-Source: AGHT+IHcXniwVQYXP2Bvjc6zwwzXjNJCqHkuGcD4E3axl2TyUbGClOev/b12P+fcLtf8uS52b4cMRWtwcSdccm6uyzc= X-Received: by 2002:a05:6102:32d1:b0:47c:29e0:c12f with SMTP id ada2fe7eead31-48077e5e295mr6983174137.23.1715472053909; Sat, 11 May 2024 17:00:53 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: jian he Date: Sun, 12 May 2024 08:00:00 +0800 Message-ID: Subject: Re: SQL:2011 application time To: Paul Jungwirth Cc: Robert Haas , Peter Eisentraut , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, May 6, 2024 at 11:01=E2=80=AFAM jian he wrote: > > On Wed, May 1, 2024 at 12:39=E2=80=AFAM Paul Jungwirth > wrote: > > > > On 4/30/24 09:24, Robert Haas wrote: > > > Peter, could you have a look at > > > http://postgr.es/m/47550967-260b-4180-9791-b224859fe63e@illuminatedco= mputing.com > > > and express an opinion about whether each of those proposals are (a) > > > good or bad ideas and (b) whether they need to be fixed for the > > > current release? > > > > Here are the same patches but rebased. I've added a fourth which is my = progress on adding the CHECK > > constraint. I don't really consider it finished though, because it has = these problems: > > > > - The CHECK constraint should be marked as an internal dependency of th= e PK, so that you can't drop > > it, and it gets dropped when you drop the PK. I don't see a good way to= tie the two together though, > > so I'd appreciate any advice there. They are separate AlterTableCmds, s= o how do I get the > > ObjectAddress of both constraints at the same time? I wanted to store t= he PK's ObjectAddress on the > > Constraint node, but since ObjectAddress isn't a Node it doesn't work. > > > > hi. > I hope I understand the problem correctly. > my understanding is that we are trying to solve a corner case: > create table t(a int4range, b int4range, primary key(a, b WITHOUT OVERLAP= S)); > insert into t values ('[1,2]','empty'), ('[1,2]','empty'); > but we still not yet address for cases like: create table t10(a int4range, b int4range, unique (a, b WITHOUT OVERLAPS)); insert into t10 values ('[1,2]','empty'), ('[1,2]','empty'); one table can have more than one temporal unique constraint, for each temporal unique constraint adding a check isempty constraint seems not easy. for example: CREATE TABLE t ( id int4range, valid_at daterange, parent_id int4range, CONSTRAINT t1 unique (id, valid_at WITHOUT OVERLAPS), CONSTRAINT t2 unique (parent_id, valid_at WITHOUT OVERLAPS), CONSTRAINT t3 unique (valid_at, id WITHOUT OVERLAPS), CONSTRAINT t4 unique (parent_id, id WITHOUT OVERLAPS), CONSTRAINT t5 unique (id, parent_id WITHOUT OVERLAPS), CONSTRAINT t6 unique (valid_at, parent_id WITHOUT OVERLAPS) ); add 6 check isempty constraints for table "t" is challenging. so far, I see the challenging part: * alter table alter column data type does not drop previous check isempty constraint, and will also add a check isempty constraint, so overall it will add more check constraints. * adding more check constraints needs a way to resolve naming collisions. Maybe we can just mention that the special 'empty' range value makes temporal unique constraints not "unique". also we can make sure that FOREIGN KEY can only reference primary keys, not unique temporal constraint= s. so the unique temporal constraints not "unique" implication is limited. I played around with it, we can error out these cases in the function transformFkeyCheckAttrs.