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.96) (envelope-from ) id 1vztms-001QJ8-0L for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Mar 2026 09:54:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vztmo-002QxY-2G for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Mar 2026 09:53:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vztmo-002QxQ-0y for pgsql-hackers@lists.postgresql.org; Tue, 10 Mar 2026 09:53:58 +0000 Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vztmm-00000001wqV-01Hk for pgsql-hackers@lists.postgresql.org; Tue, 10 Mar 2026 09:53:58 +0000 Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-899ee87355dso120610906d6.1 for ; Tue, 10 Mar 2026 02:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773136433; cv=none; d=google.com; s=arc-20240605; b=Icc/0Td/4J3XzyaGsdIIaY4u6znQ2T7lQDOrlwR7OGUOdSAXMjigT8JsIE8y+XD3DX /vmJ8VAoXwhCagMQ8op/EIeQ6GX6arIlerrZ171FAm82E8QnJ5YxICoizzwwH85GYe1M t449NN0h0Jf/KolFcmblE3sdzZXqDhBE0FbCBQrL09eX45LsM9wZEVjefdueOiIHbEbe GS1zKKVfgkO/2avP1Tmy2pOc9k//rlLNwH7wrZdJJWpOnAq+lVQ56/z4UI9oVpCqKQx6 Gg85m2P5dKhCebcF14sEQ2St3+BH0DQgE/TWOZcnzUBriE0Y6aTDi0f7mJGiILLKpD/W lPrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1LuGk8Z56JnEZRFcwGkAhOoh0ENrh3+FXLaXfIVXKMU=; fh=AlGGFS3EAyWeVa3NVwHFRUQLdNm7bFU+cMhuPQGVHOk=; b=C3Hq2VbOSLAsFCW7s81lgrogKmmoMGzetXOA60c/y8MF8gEUpsMEk2onTSMhqZnTsz QRUdIRfCceKXJNiBD7AFBA3CL6btx57cfl4IH8P4vDs92wpneOeP7Bp0zh4+mApj2m2O igV7VtukNlRhZSxv+mIFqoE62vq9VxdEuYfDbGr+5aDeOSw0aiqRisM/HZQ3gVTKwtYm 3cma3rEW2je+B6eS4AoC5/Dwh11Zhcn7j/ZFbY555otVOcWo7bVuzGQUqNK8be9HNPZn ugXV15cXfU/JgBwh3TfdqzxktYt3/qm0ekESRSCLg3IO18qhKs9aWuj3QlggeGlfVA0j sTlw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773136433; x=1773741233; 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=1LuGk8Z56JnEZRFcwGkAhOoh0ENrh3+FXLaXfIVXKMU=; b=LPWWROESyfhPE5SAD2tRX73tRARo9Psq93ZTFwLuulohVgEw8jMcqmUQ6e28T4OLjS qX990dOS7j7QSdaRpt0/oGa82zn5eAAIrOUTUW2kNuTxcJ4CbiFWAKxT8V+ysEOFvyay CjxImKz5XW+J40P8hwU7AfkVdu1j1HoHUXbotggWicZTWMz8M7eXYEiGSL15nK1a9uCd FrV4tlD1jRVAYrUADpv279M0mD90/f2BGmupOBHX0hOR67xxWDz67eh0qR40SadRxrz3 X2L0PhzLlsH5vZ9d/fo66e6+UYFfWZLQN9lxTxlbmVEq8MV7w5F1IzXTnujSE+kCSq9O LKPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773136433; x=1773741233; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=1LuGk8Z56JnEZRFcwGkAhOoh0ENrh3+FXLaXfIVXKMU=; b=TI3BlhqNiXaMl3GPIVNLe7DUXbexN5igpjjsozr3oBwBs1M5Au/T6shqIWyLFdvNJn /HHl+YD1EHO/FU0yI3n7raK/dx0pbNdw0s3i7jOohwCflRz0xz69+GyPVy0ZlrwYFbB/ gqYmk1/KkgPGpGMOR9dRMfKqyYiaaA1Tvb3CLU1jVtDtUFkw+QhNz1AegKA7dYwpcMU2 6IIjn1yxQOEtoAQm34NJIs11q3zhorcEgVMD0BudAVPSvaJKEHNBjKsTB2OI4VsEKz/s vM+MiqmIPWmM7hRqLzzrCBMhC2e1o62DHrgFRxS/rBQK0KN0SekLpr8WDAw+Ues/XQ29 FAgg== X-Forwarded-Encrypted: i=1; AJvYcCVgnalc8s2Nab4RVtuRAiqVWuvylaIBnMwIbNmEbNQnp2ntEOU+auhpcGhegxD311Qh0IeLivertA993PS6@lists.postgresql.org X-Gm-Message-State: AOJu0Yw9XhISe/fIGGEyfnZGDUwShkiQmwHkcd1b0WeRfeeFzhpQm33t QXMtznrLfFVIrGwDPDAMnUftMPuGCLMjFJEwzJd61Z1MoYTFuAc8bCDsPr2/uSyUTDH8YKTk1as ggWU4iVvnl4ezanfUZ3EX4n99y0tsIbQ= X-Gm-Gg: ATEYQzwAj6zxHltFzfzm78qcCJTIUDrWZNlZq94wcZvDV5Tfm6kODpmopK9yLHpoqEa y6vio2rbNgf6s56csq7Qtt4AyHx/7g3CmPiKSv4o8XynkwhVMGYL30O0qvcJTzcdtySNbP2t5nb BVytrNld99RfutoHV0lA4NjEz1AnZGHk3rCd7fV4l6juoSvDcy4xsd2v7mtthArE2Cpa65NtoVX ETXqpQ2KJwO5FzpaPWyGyQ2W70q6ti2yIrK5DsuJcgOMtp6Wo9iJcJvWXOCg0hphdyaBOn/Ft3C 0I1f0/kwjafuA1yIoQX6e+ikuEyAZgqOiRE1aIWzfwLWMkAU3SoyLEEuaIWMZS/3X4FeOOuEOaN bjXyRUQ== X-Received: by 2002:a05:6214:262c:b0:89a:1221:c671 with SMTP id 6a1803df08f44-89a30b06471mr218993716d6.62.1773136433323; Tue, 10 Mar 2026 02:53:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Kirill Reshke Date: Tue, 10 Mar 2026 14:53:41 +0500 X-Gm-Features: AaiRm522hCOSp_uhbE8keQUCm_IqbxxONmfJPDcAfKEY7jkRIszd7WIoGOlrwyo Message-ID: Subject: Re: domain for WITHOUT OVERLAPS To: Paul A Jungwirth Cc: jian he , 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 Wed, 11 Feb 2026 at 23:51, Paul A Jungwirth wrote: > > On Sun, Dec 28, 2025 at 11:18=E2=80=AFPM jian he wrote: > > > > > Is there any performance concern about adding this lookup? > > > From what I can tell we don't use TYPECACHE_DOMAIN_BASE_INFO very > > > often, so it is probably okay. > > > We can get here in the executor from ExecEvalWholeRowVar, but that > > > seems acceptable to me. > > > > > > > > hi. > > > > To make WITHOUT OVERLAPS work with domains, ExecWithoutOverlapsNotEmpty= requires > > the base type=E2=80=99s typtype. I do not see a viable alternative appr= oach. > > > > We can cache the base type's typtype in TypeCacheEntry->domainBaseTypty= pe. > > Okay. > > > > > > > Also testing a range over a domain (in WITHOUT OVERLAPS position) wou= ld be good. > > > > > I do not think we need extensive foreign key=E2=80=93related tests, bec= ause > > check_exclusion_or_unique_constraint is only invoked for data changes o= n the > > primary key side. So, I kept only a single foreign key=E2=80=93related = test. > > The foreign key code also uses the column type, so there are still > interesting feature combinations here that should be tested rather > than just assuming they work. > > > The attached patch should address all of your comments. > > I think you will like attached regress tests. > > A lot of the issues I mentioned before don't look addressed to me. > What do you think of the v4 patch attached here? It includes a few > more FK tests. Some other details I changed: > > +-- > +-- tests for range over domain, multirange over a domain, custom > range type over > +-- domain, custom multi range type over domain. > +-- > +CREATE DOMAIN int4_d as integer check (value <> 10); > +CREATE TYPE int4_d_range as range (subtype =3D int4_d); > +CREATE DOMAIN int4multirange_d as int4multirange check (value <> '{[10,1= 1)}'); > +CREATE DOMAIN int4range_d AS int4range CHECK (VALUE <> '[10,11)'); > +CREATE DOMAIN textrange2_d AS textrange2 CHECK (VALUE <> '[c,d)'); > +CREATE DOMAIN textrange2_dd AS textrange2_d; > +CREATE DOMAIN textmultirange2_d AS textmultirange2 CHECK (VALUE <> '{[c,= d)}'); > > This comment still doesn't match the types created below it. In my v4 > patch I've added a comment before each CREATE TYPE/DOMAIN line. > > Also let's define these in the same order that we test them below. > > +-- It is a range type rather than a domain type; however, the range type= =E2=80=99s > +-- subtype is a domain type. > +CREATE TABLE temporal_rng4 ( > + id int4range_d, > + valid_at int4_d_range, > + CONSTRAINT temporal_rng4_pk PRIMARY KEY(id, valid_at WITHOUT OVERLAPS) > +); > +INSERT INTO temporal_rng4 VALUES ('[1,2)', '[10,11)'); --error > +INSERT INTO temporal_rng4 VALUES ('[10,11)', '[1,2)'); --error > +INSERT INTO temporal_rng4 VALUES ('[1,11)', '[9,10)'); --error > +INSERT INTO temporal_rng4 VALUES ('[1,2)', '[1,13)'), ('[1,2)', > '[2,5)'); --error > +DROP TABLE temporal_rng4; > > We need to test a case that succeeds, not just cases that fail. Also > the last case doesn't violate the domain; it just conflicts with a > prior row. That's a good test too, but let's clarify. > > The point is to test WITHOUT OVERLAPS, but several of these lines are > testing the id column, not the valid_at column. I made the id columns > be just regular int4range. > > Likewise with the scenarios below. > > Yours, > > -- > Paul ~{:-) > pj@illuminatedcomputing.com Hi! I v4, test comments says we check for unique violation, while test output says its exclusion constraint: +INSERT INTO temporal_mltrng4 VALUES ('[1,2)', '{[1,13)}'), ('[1,2)', '{[2,13)}'); -- not unique +ERROR: conflicting key value violates exclusion constraint "temporal_mltrng4_pk" Maybe we can update wording to be more precise? Like `-- overlaps with other tuple`. Other that this nit, patch looks good. --=20 Best regards, Kirill Reshke