Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c641bb4

Browse files
author
Commitfest Bot
committed
[CF 5769] v1 - make ALTER DOMAIN VALIDATE CONSTRAINT no-op when constraint is validated
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5769 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CACJufxG=-Dv9fPJHqkA9c-wGZ2dDOWOXSp-X-0K_G7r-DgaASw@mail.gmail.com Author(s): Jian He
2 parents 03c53a7 + f0e3675 commit c641bb4

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/backend/commands/typecmds.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3087,24 +3087,29 @@ AlterDomainValidateConstraint(List *names, const char *constrName)
30873087
errmsg("constraint \"%s\" of domain \"%s\" is not a check constraint",
30883088
constrName, TypeNameToString(typename))));
30893089

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);
30923094

3093-
validateDomainCheckConstraint(domainoid, conbin);
3095+
validateDomainCheckConstraint(domainoid, conbin);
30943096

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);
31023104

3103-
InvokeObjectPostAlterHook(ConstraintRelationId, con->oid, 0);
3105+
InvokeObjectPostAlterHook(ConstraintRelationId, con->oid, 0);
31043106

3105-
ObjectAddressSet(address, TypeRelationId, domainoid);
3107+
ObjectAddressSet(address, TypeRelationId, domainoid);
31063108

3107-
heap_freetuple(copyTuple);
3109+
heap_freetuple(copyTuple);
3110+
}
3111+
else
3112+
address = InvalidObjectAddress; /* already validated */
31083113

31093114
systable_endscan(scan);
31103115

0 commit comments

Comments
 (0)