From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Paul Jungwirth <pj(at)illuminatedcomputing(dot)com> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: SQL:2011 application time |
Date: | 2024-05-12 00:00:00 |
Message-ID: | CACJufxHMbSiKX9BTg4P_vHj3BUf4uGyfprNYPgz_jrQw6RTsxg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, May 6, 2024 at 11:01 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> On Wed, May 1, 2024 at 12:39 AM Paul Jungwirth
> <pj(at)illuminatedcomputing(dot)com> 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@illuminatedcomputing.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 the 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, so how do I get the
> > ObjectAddress of both constraints at the same time? I wanted to store the 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 OVERLAPS));
> 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 constraints.
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Geoghegan | 2024-05-12 00:08:03 | Re: Inefficient nbtree behavior with row-comparison quals |
Previous Message | Thomas Munro | 2024-05-11 23:31:09 | Re: Why is citext/regress failing on hamerkop? |