>
> 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: v11-0001-refactor-AddRelationNotNullConstraints.no-cfbot
Description: Binary data

Reply via email to