I hit a snag with multiple inheritance -- if you apply this patch, you'll see failures in the pg_dump and pg_upgrade tests. I don't have any ideas to fix this right now, but I'll keep thinking about it.
i looked into this, the reason for these failures was when the given name for a constraint for a parent table propagates to the child table because of inheritance the name conflicts and throws "mismatching constraint name" error we added, let me show an example,
postgres=# alter table test1 add constraint nn not null col1 not valid; ERROR: mismatching constraint name "nn" DETAIL: A not-null constraint named "test2_col1_not_null" already exists for this column.
I think we can fix this by throwing an error only if this constraint was added directly to the table and not through inheritance/propagation from the parent, we can do this using the "is_local" flag, i have checked and all tests passed.
/* * Throw an error if the proposed constraint name doesn't match the * existing one. */ + if (is_local && name && strcmp(name, NameStr(conform->conname)) != 0) ereport(ERROR, errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg("mismatching constraint name \"%s\"", name), errdetail("A not-null constraint named \"%s\" already exists for this column.", NameStr(conform->conname)));
also checking how other constraints handle this case like CHECK and found it just appends to existing constraint