@@ -3087,24 +3087,29 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
3087
3087
errmsg ("constraint \"%s\" of domain \"%s\" is not a check constraint" ,
3088
3088
constrName , TypeNameToString (typename ))));
3089
3089
3090
- val = SysCacheGetAttrNotNull (CONSTROID , tuple , Anum_pg_constraint_conbin );
3091
- conbin = TextDatumGetCString (val );
3090
+ if (!con -> convalidated )
3091
+ {
3092
+ val = SysCacheGetAttrNotNull (CONSTROID , tuple , Anum_pg_constraint_conbin );
3093
+ conbin = TextDatumGetCString (val );
3092
3094
3093
- validateDomainCheckConstraint (domainoid , conbin );
3095
+ validateDomainCheckConstraint (domainoid , conbin );
3094
3096
3095
- /*
3096
- * Now update the catalog, while we have the door open.
3097
- */
3098
- copyTuple = heap_copytuple (tuple );
3099
- copy_con = (Form_pg_constraint ) GETSTRUCT (copyTuple );
3100
- copy_con -> convalidated = true;
3101
- CatalogTupleUpdate (conrel , & copyTuple -> t_self , copyTuple );
3097
+ /*
3098
+ * Now update the catalog, while we have the door open.
3099
+ */
3100
+ copyTuple = heap_copytuple (tuple );
3101
+ copy_con = (Form_pg_constraint ) GETSTRUCT (copyTuple );
3102
+ copy_con -> convalidated = true;
3103
+ CatalogTupleUpdate (conrel , & copyTuple -> t_self , copyTuple );
3102
3104
3103
- InvokeObjectPostAlterHook (ConstraintRelationId , con -> oid , 0 );
3105
+ InvokeObjectPostAlterHook (ConstraintRelationId , con -> oid , 0 );
3104
3106
3105
- ObjectAddressSet (address , TypeRelationId , domainoid );
3107
+ ObjectAddressSet (address , TypeRelationId , domainoid );
3106
3108
3107
- heap_freetuple (copyTuple );
3109
+ heap_freetuple (copyTuple );
3110
+ }
3111
+ else
3112
+ address = InvalidObjectAddress ; /* already validated */
3108
3113
3109
3114
systable_endscan (scan );
3110
3115
0 commit comments