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 1r4yEF-00BACh-Qt for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Nov 2023 06:57:55 +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 1r4yEE-0068C4-6K for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Nov 2023 06:57:54 +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.94.2) (envelope-from ) id 1r4yED-0068Bv-Sw for pgsql-hackers@lists.postgresql.org; Mon, 20 Nov 2023 06:57:53 +0000 Received: from mail-vk1-xa29.google.com ([2607:f8b0:4864:20::a29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r4yEA-007NKZ-TB for pgsql-hackers@lists.postgresql.org; Mon, 20 Nov 2023 06:57:52 +0000 Received: by mail-vk1-xa29.google.com with SMTP id 71dfb90a1353d-4ac3083ca04so1289957e0c.1 for ; Sun, 19 Nov 2023 22:57:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700463469; x=1701068269; 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=HDPiloJeP8mGyGHcVixsSgUcV74OIBcc9V+764j5/vs=; b=lWE8tP0A7St0U20G6rpEJ6+DSbrcgkmXUWezAE6JjMIz+Da0w5uUmTyLaNu6wO51oa yKaZY+/9/zmlqOkEOiLScuPM6pyno98TovhlzSkiunt4mly2sueWGAb2CayknE173ZlH GbQKfLpSmxEaYx/I346wbwb5m3IC61YCuqwucHamA3ZKsqud+jSIS1FYrOWaVSc7JXmq hBEHvy8VNJqAjwaMEnAMCunRguv9SZOxsODm245KH9A3yKig7YQIEXRl4Nt6rj4UOunp Ncl8rUu8oxtBxxMDODwTFx5/XRQ8WVX0ixy0nCrtGq4i7Z0Q+wYUIWUsmpeSdmGVmEYl KseA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700463469; x=1701068269; 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=HDPiloJeP8mGyGHcVixsSgUcV74OIBcc9V+764j5/vs=; b=nDwxjI6Qim9HKqoAhDp1qupaF5875vBRbw53upAZgvF+1XVkeair3tFX5t4V33p88M keNtBhbdVNFJYSxcbgiyHAF+wGK/b1a/SU4JHzkwxYf41OaXeuwVoWCPUwZwLi/GpUPL YFgHH/DyG/kYpt9gXhtfZ81Qo7ZI+iAaP4TN+3gO1PcTCfHhJo5GoIJe8dUAS24v1gNL +PwknG/vgO3WxrqYvPhhx0S9XBwKKsyYz/9J49+5PmyiwhT4rtCIq1/w483B7Gkg6Ohr k9areH8rwGc3UEfyn6HP9Q9FNKk0Lqt5yaQgSc04UhRuEkxgoAwsI40bJiyMrmpTkJd0 TpVQ== X-Gm-Message-State: AOJu0YwQOlf+n8apshEmAr6YtZIlJ/WEADkNiOVff4pcOiq85Nowg5W3 h/sECx2j+KtgMmjwVT6gFo+DQUBMOhlZuuYg27SmbFEYluFxfxui X-Google-Smtp-Source: AGHT+IHMAHTsWq701yufErCBrT3jUmDSj5FQgVdNQlw3O/xcQN1+IB4HPgF5x1Udaq7fQTi4Rf5Gv4OPdW2ivsF8T7Q= X-Received: by 2002:a1f:ec44:0:b0:496:3906:33e3 with SMTP id k65-20020a1fec44000000b00496390633e3mr4647812vkh.15.1700463468684; Sun, 19 Nov 2023 22:57:48 -0800 (PST) MIME-Version: 1.0 References: <831f17ba-ff36-1380-a475-a7cd2c65a89c@enterprisedb.com> <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> In-Reply-To: From: jian he Date: Mon, 20 Nov 2023 14:57:37 +0800 Message-ID: Subject: Re: SQL:2011 application time To: Paul A Jungwirth Cc: 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 Sun, Nov 19, 2023 at 1:24=E2=80=AFPM Paul A Jungwirth wrote: > > Thank you for continuing to review this submission! My changes are in > the v18 patch I sent a few days ago. Details below. > > On Sun, Oct 29, 2023 at 5:01=E2=80=AFPM jian he wrote: > > * The attached patch makes foreign keys with PERIOD fail if any of the > > foreign key columns is "generated columns". > > I don't see anything like that included in your attachment. I do see > the restriction on `ON DELETE SET NULL/DEFAULT (columnlist)`, which I > included. But you are referring to something else I take it? Why do > you think FKs should fail if the referred column is GENERATED? Is that > a restriction you think should apply to all FKs or only temporal ones? > I believe the following part should fail. Similar tests on src/test/regress/sql/generated.sql. line begin 347. drop table if exists gtest23a,gtest23x cascade; CREATE TABLE gtest23a (x int4range, y int4range, CONSTRAINT gtest23a_pk PRIMARY KEY (x, y WITHOUT OVERLAPS)); CREATE TABLE gtest23x (a int4range, b int4range GENERATED ALWAYS AS ('empty') STORED, FOREIGN KEY (a, PERIOD b ) REFERENCES gtest23a(x, PERIOD y) ON UPDATE CASCADE); -- should be error? ------- > > > * you did if (numfks !=3D numpks) before if (is_temporal) {numfks +=3D > > 1;}, So I changed the code order to make the error report more > > consistent. > > Since we do numfks +=3D1 and numpks +=3D1, I don't see any inconsistency > here. Also you are making things now happen before a permissions > check, which may be important (I'm not sure). Can you explain what > improvement is intended here? Your changes don't seem to cause any > changes in the tests, so what is the goal? Perhaps I'm > misunderstanding what you mean by "more consistent." > begin; drop table if exists fk, pk cascade; CREATE TABLE pk (id int4range, valid_at int4range, CONSTRAINT pk_pk PRIMARY KEY (id, valid_at WITHOUT OVERLAPS) ); CREATE TABLE fk ( id int4range,valid_at tsrange, parent_id int4range, CONSTRAINT fk FOREIGN KEY (parent_id, valid_at) REFERENCES pk ); rollback; -- the above query will return an error: number of referencing and referenced columns for foreign key disagree. but if you look at it closely, primary key and foreign key columns both are= two! The error should be saying valid_at should be specified with "PERIOD". begin; drop table if exists fk, pk cascade; CREATE TABLE pk (id int4range, valid_at int4range, CONSTRAINT pk_pk PRIMARY KEY (id, valid_at WITHOUT OVERLAPS) ); CREATE TABLE fk ( id int4range,valid_at int4range, parent_id int4range, CONSTRAINT fk FOREIGN KEY (parent_id, period valid_at) REFERENCES pk ); select conname,array_length(conkey,1),array_length(confkey,1) from pg_constraint where conname =3D 'fk'; rollback; ------------ I found out other issues in v18. I first do `git apply` then `git diff --check`, there is a white space error in v18-0005. You also need to change update.sgml and delete.sgml Outputs = part. Since at most, it can return 'UPDATE 3' or 'DELETE 3'. --the following query should work? drop table pk; CREATE table pk(a numrange PRIMARY key,b text); insert into pk values('[1,10]'); create or replace function demo1() returns void as $$ declare lb numeric default 1; up numeric default 3; begin update pk for portion of a from lb to up set b =3D 'lb_to_up'; return; end $$ language plpgsql; select * from demo1();