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 1qkshF-00HIaj-QL for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Sep 2023 21:00:50 +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 1qkshE-004ru6-EW for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Sep 2023 21:00:48 +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 1qkshC-004rts-L1 for pgsql-hackers@lists.postgresql.org; Mon, 25 Sep 2023 21:00:48 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qksh9-006cMr-9u for pgsql-hackers@lists.postgresql.org; Mon, 25 Sep 2023 21:00:45 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 12DBE5C274B; Mon, 25 Sep 2023 17:00:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 25 Sep 2023 17:00:42 -0400 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:sender:subject:subject:to:to; s=fm1; t=1695675642; x=1695762042; bh=OeypIArgEbXjZx0F/468wjoJ6 msN74dLqPqaJkbyoSk=; b=IV7JW7VXA6wPdDkRRHOnQn+AvFPuS5fy2rAdC3hf1 B8cVmwQ1k8PVzqn7MEPZcxJKDxZhh8KIu03rESMT10sucWTCW5mEI9iYyePkudGB BeiOJyeTDUmbvoBMg/SyilXORNxSlAqAhLFUlx+QfWKh2jRLzWO5wtwpQQgx6bXR /Mz8UxpWh/tay81WLu9xvoPKVPdVM9E0bJADylSxaWV+lcsPc64mHUWUaQ6UAars ifdt3USeqp+mPoAbfHYvaich60zNb3ldGXax8XE0ASCM5wVgftQdoOUAyEiZM6ea y/DSchoD0pL0rBx+xPasvtWM/erZe0DXijvzWYbgj71yQ== 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:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1695675642; x=1695762042; bh=OeypIArgEbXjZx0F/468wjoJ6msN74dLqPq aJkbyoSk=; b=DSiZfuJpcakyL38yNYkscPFwwIQN7g98FNo++h56HMVjuaV5h93 hvIWwbSu3rqce4b3bMnlUzzD49B7VD6lj0F4GJs7V+GH6sFsVitGHy4g8UJVy+DV XZtYaYG2CbH56rTu9EM9lvAk7+KYoqUvJOFvwwctM9OC/XS7B1lDM6K56x1AlUkT gS/j1qZ2r5QpvmroZUV4fhewGWoQN6xknzpRHkNqrsv934dmlO7zLa4/HsX0ZV6W L0JHHxarWYsIWeO28hm8/c6TwJh6f+mk21FHXUX+7jFUvpJ3E9HoASUBVuy/wMKb 2Dx7iOu/x53PC75aWtZF4NJOlZpxhQe3ptA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudelgedgudehhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttdefjeenucfhrhhomheprfgv thgvrhcugfhishgvnhhtrhgruhhtuceophgvthgvrhesvghishgvnhhtrhgruhhtrdhorh hgqeenucggtffrrghtthgvrhhnpeelvdfgfedujeejuddvffekkeekvdefieefleeifefg hfeiieevudevieehieefjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 25 Sep 2023 17:00:39 -0400 (EDT) Message-ID: <1106ff18-b607-7ff3-e4ab-a3c6e1d46fc7@eisentraut.org> Date: Mon, 25 Sep 2023 22:00:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: SQL:2011 application time To: Paul Jungwirth , jian he Cc: PostgreSQL Hackers References: <6f010a6e-8e20-658b-dc05-dc9033a694da@eisentraut.org> <7d44dade-ff31-5eef-80ac-78ed838066f6@postgresfriends.org> <88dadcc1-6652-ff7d-264d-73906a53dee9@illuminatedcomputing.com> <5157e85a-6007-27a7-853a-5601d9c3722f@illuminatedcomputing.com> <5a16a59a-d497-7d72-07aa-0afc09d5193a@illuminatedcomputing.com> Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 25.09.23 21:20, Paul Jungwirth wrote: > On 9/24/23 21:52, jian he wrote: >> On Wed, Sep 20, 2023 at 10:50 AM Paul Jungwirth >> wrote: >>> >>> On 9/17/23 20:11, jian he wrote: >>>> small issues so far I found, v14. >>> >>> Thank you again for the review! v15 is attached. >>> >> >> hi. some tiny issues. > > Rebased v16 patches attached. Looking through the tests in v16-0001: +-- PK with no columns just WITHOUT OVERLAPS: +CREATE TABLE temporal_rng ( + valid_at tsrange, + CONSTRAINT temporal_rng_pk PRIMARY KEY (valid_at WITHOUT OVERLAPS) +); +ERROR: syntax error at or near "WITHOUT" +LINE 3: CONSTRAINT temporal_rng_pk PRIMARY KEY (valid_at WITHOUT OV... + ^ I think this error is confusing. The SQL standard requires at least one non-period column in a PK. I don't know why that is or why we should implement it. But if we want to implement it, maybe we should enforce that in parse analysis rather than directly in the parser, to be able to produce a more friendly error message. +-- PK with a range column/PERIOD that isn't there: +CREATE TABLE temporal_rng ( + id INTEGER, + CONSTRAINT temporal_rng_pk PRIMARY KEY (id, valid_at WITHOUT OVERLAPS) +); +ERROR: range or PERIOD "valid_at" in WITHOUT OVERLAPS does not exist I think here we should just produce a "column doesn't exist" error message, the same as if the "id" column was invalid. We don't need to get into the details of what kind of column it should be. That is done in the next test +ERROR: column "valid_at" in WITHOUT OVERLAPS is not a range type Also, in any case it would be nice to have a location pointer here (for both cases). +-- PK with one column plus a range: +CREATE TABLE temporal_rng ( + -- Since we can't depend on having btree_gist here, + -- use an int4range instead of an int. + -- (The rangetypes regression test uses the same trick.) + id int4range, + valid_at tsrange, + CONSTRAINT temporal_rng_pk PRIMARY KEY (id, valid_at WITHOUT OVERLAPS) +); I'm confused why you are using int4range here (and in further tests) for the scalar (non-range) part of the primary key. Wouldn't a plaint int4 serve here? +SELECT pg_get_indexdef(conindid, 0, true) FROM pg_constraint WHERE conname = 'temporal_rng_pk'; + pg_get_indexdef +------------------------------------------------------------------------------- + CREATE UNIQUE INDEX temporal_rng_pk ON temporal_rng USING gist (id, valid_at) Shouldn't this somehow show the operator classes for the columns? We are using different operator classes for the id and valid_at columns, aren't we? +-- PK with USING INDEX (not possible): +CREATE TABLE temporal3 ( + id int4range, + valid_at tsrange +); +CREATE INDEX idx_temporal3_uq ON temporal3 USING gist (id, valid_at); +ALTER TABLE temporal3 + ADD CONSTRAINT temporal3_pk + PRIMARY KEY USING INDEX idx_temporal3_uq; +ERROR: "idx_temporal3_uq" is not a unique index +LINE 2: ADD CONSTRAINT temporal3_pk + ^ +DETAIL: Cannot create a primary key or unique constraint using such an index. Could you also add a test where the index is unique and the whole thing does work? Apart from the tests, how about renaming the column pg_constraint.contemporal to something like to conwithoutoverlaps?