Skip to content

Commit 7407b2d

Browse files
committed
Remove dead code
As of commit 9895b35, AlterDomainAddConstraint() can only be called with constraints of type CONSTR_CHECK and CONSTR_NOTNULL. So all the code to check for and reject other constraint type values is dead and can be removed. Author: jian he <jian.universality@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/CACJufxHitd5LGLBSSAPShhtDWxT0ViVKTHinkYW-skBX93TcpA@mail.gmail.com
1 parent 7a947ed commit 7407b2d

File tree

1 file changed

+2
-52
lines changed

1 file changed

+2
-52
lines changed

src/backend/commands/typecmds.c

+2-52
Original file line numberDiff line numberDiff line change
@@ -2953,58 +2953,8 @@ AlterDomainAddConstraint(List *names, Node *newConstraint,
29532953

29542954
constr = (Constraint *) newConstraint;
29552955

2956-
switch (constr->contype)
2957-
{
2958-
case CONSTR_CHECK:
2959-
case CONSTR_NOTNULL:
2960-
/* processed below */
2961-
break;
2962-
2963-
case CONSTR_UNIQUE:
2964-
ereport(ERROR,
2965-
(errcode(ERRCODE_SYNTAX_ERROR),
2966-
errmsg("unique constraints not possible for domains")));
2967-
break;
2968-
2969-
case CONSTR_PRIMARY:
2970-
ereport(ERROR,
2971-
(errcode(ERRCODE_SYNTAX_ERROR),
2972-
errmsg("primary key constraints not possible for domains")));
2973-
break;
2974-
2975-
case CONSTR_EXCLUSION:
2976-
ereport(ERROR,
2977-
(errcode(ERRCODE_SYNTAX_ERROR),
2978-
errmsg("exclusion constraints not possible for domains")));
2979-
break;
2980-
2981-
case CONSTR_FOREIGN:
2982-
ereport(ERROR,
2983-
(errcode(ERRCODE_SYNTAX_ERROR),
2984-
errmsg("foreign key constraints not possible for domains")));
2985-
break;
2986-
2987-
case CONSTR_ATTR_DEFERRABLE:
2988-
case CONSTR_ATTR_NOT_DEFERRABLE:
2989-
case CONSTR_ATTR_DEFERRED:
2990-
case CONSTR_ATTR_IMMEDIATE:
2991-
ereport(ERROR,
2992-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2993-
errmsg("specifying constraint deferrability not supported for domains")));
2994-
break;
2995-
2996-
case CONSTR_ATTR_ENFORCED:
2997-
case CONSTR_ATTR_NOT_ENFORCED:
2998-
ereport(ERROR,
2999-
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
3000-
errmsg("specifying constraint enforceability not supported for domains")));
3001-
break;
3002-
3003-
default:
3004-
elog(ERROR, "unrecognized constraint subtype: %d",
3005-
(int) constr->contype);
3006-
break;
3007-
}
2956+
/* enforced by parser */
2957+
Assert(constr->contype == CONSTR_CHECK || constr->contype == CONSTR_NOTNULL);
30082958

30092959
if (constr->contype == CONSTR_CHECK)
30102960
{

0 commit comments

Comments
 (0)