From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Cc: | Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tender Wang <tndrwang(at)gmail(dot)com> |
Subject: | Re: not null constraints, again |
Date: | 2024-11-08 06:44:40 |
Message-ID: | CACJufxHpi2vL_S+S0Pw8v0W=J7R9Wvz5v7OW7YdJnd9ZHJgr+w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>
> Here's v11, which I intended to commit today, but didn't get around to.
> CI is happy with it, so I'll probably do it tomorrow first thing.
>
CREATE TABLE notnull_tbl2 (a INTEGER CONSTRAINT blah NOT NULL, b
INTEGER CONSTRAINT blah NOT NULL);
RelationGetNotNullConstraints, StoreRelNotNull
will first create the constraint "blah", then iterate through the
second "blah" error out,
which is not great for error out cleaning, i believe.
so i change AddRelationNotNullConstraints
first loop "for (int outerpos = 0; outerpos <
list_length(constraints); outerpos++)"
we can first validate it through the loop, collect information
then do a loop to StoreRelNotNull.
while debugging, in RelationGetNotNullConstraints
if (cooked)
{
CookedConstraint *cooked;
cooked = (CookedConstraint *) palloc(sizeof(CookedConstraint));
cooked->contype = CONSTR_NOTNULL;
cooked->name = pstrdup(NameStr(conForm->conname));
cooked->attnum = colnum;
.....
}
We missed the assignment of cooked->conoid?
MergeConstraintsIntoExisting
/*
* If the CHECK child constraint is "no inherit" then cannot
* merge.
*/
if (child_con->connoinherit)
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("constraint \"%s\" conflicts with
non-inherited constraint on child table \"%s\"",
NameStr(child_con->conname),
RelationGetRelationName(child_rel))));
the above comment can also be hit by not-null constraint, so the
comment is wrong?
Attachment | Content-Type | Size |
---|---|---|
v11-0001-refactor-AddRelationNotNullConstraints.no-cfbot | application/octet-stream | 5.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Jacobson | 2024-11-08 07:42:43 | Re: New "single" COPY format |
Previous Message | David G. Johnston | 2024-11-08 06:14:02 | Re: New "single" COPY format |