diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index 45ae7472ab5..2c2587ffc14 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -3087,24 +3087,29 @@ AlterDomainValidateConstraint(List *names, const char *constrName) errmsg("constraint \"%s\" of domain \"%s\" is not a check constraint", constrName, TypeNameToString(typename)))); - val = SysCacheGetAttrNotNull(CONSTROID, tuple, Anum_pg_constraint_conbin); - conbin = TextDatumGetCString(val); + if (!con->convalidated) + { + val = SysCacheGetAttrNotNull(CONSTROID, tuple, Anum_pg_constraint_conbin); + conbin = TextDatumGetCString(val); - validateDomainCheckConstraint(domainoid, conbin); + validateDomainCheckConstraint(domainoid, conbin); - /* - * Now update the catalog, while we have the door open. - */ - copyTuple = heap_copytuple(tuple); - copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple); - copy_con->convalidated = true; - CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple); + /* + * Now update the catalog, while we have the door open. + */ + copyTuple = heap_copytuple(tuple); + copy_con = (Form_pg_constraint) GETSTRUCT(copyTuple); + copy_con->convalidated = true; + CatalogTupleUpdate(conrel, ©Tuple->t_self, copyTuple); - InvokeObjectPostAlterHook(ConstraintRelationId, con->oid, 0); + InvokeObjectPostAlterHook(ConstraintRelationId, con->oid, 0); - ObjectAddressSet(address, TypeRelationId, domainoid); + ObjectAddressSet(address, TypeRelationId, domainoid); - heap_freetuple(copyTuple); + heap_freetuple(copyTuple); + } + else + address = InvalidObjectAddress; /* already validated */ systable_endscan(scan);