diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 271ae26cbaf..7b0e66a8940 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -2663,7 +2663,7 @@ alter_table_cmd:
 					n->def = (Node *) c;
 					c->conname = $3;
 					c->alterDeferrability = true;
-					processCASbits($4, @4, "FOREIGN KEY",
+					processCASbits($4, @4, NULL,
 									&c->deferrable,
 									&c->initdeferred,
 									NULL, NULL, NULL, yyscanner);
@@ -19531,9 +19531,11 @@ processCASbits(int cas_bits, int location, const char *constrType,
 		else
 			ereport(ERROR,
 					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-			/* translator: %s is CHECK, UNIQUE, or similar */
+					 constrType ?
+					 /* translator: %s is CHECK, UNIQUE, TRIGGER, or similar */
 					 errmsg("%s constraints cannot be marked DEFERRABLE",
-							constrType),
+							constrType) :
+					 errmsg("constraint cannot be marked DEFERRABLE"),
 					 parser_errposition(location)));
 	}
 
@@ -19544,9 +19546,11 @@ processCASbits(int cas_bits, int location, const char *constrType,
 		else
 			ereport(ERROR,
 					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-			/* translator: %s is CHECK, UNIQUE, or similar */
+					 constrType ?
+					 /* translator: %s is CHECK, UNIQUE, TRIGGER, or similar */
 					 errmsg("%s constraints cannot be marked DEFERRABLE",
-							constrType),
+							constrType) :
+					 errmsg("constraint cannot be marked DEFERRABLE"),
 					 parser_errposition(location)));
 	}
 
@@ -19557,9 +19561,11 @@ processCASbits(int cas_bits, int location, const char *constrType,
 		else
 			ereport(ERROR,
 					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-			/* translator: %s is CHECK, UNIQUE, or similar */
+					 constrType ?
+					 /* translator: %s is CHECK, UNIQUE, TRIGGER, or similar */
 					 errmsg("%s constraints cannot be marked NOT VALID",
-							constrType),
+							constrType) :
+					 errmsg("constraint cannot be marked NOT VALID"),
 					 parser_errposition(location)));
 	}
 
@@ -19570,9 +19576,11 @@ processCASbits(int cas_bits, int location, const char *constrType,
 		else
 			ereport(ERROR,
 					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-			/* translator: %s is CHECK, UNIQUE, or similar */
+					 constrType ?
+					 /* translator: %s is CHECK, UNIQUE, TRIGGER, or similar */
 					 errmsg("%s constraints cannot be marked NO INHERIT",
-							constrType),
+							constrType) :
+					 errmsg("constraint cannot be marked NO INHERIT"),
 					 parser_errposition(location)));
 	}
 
@@ -19583,9 +19591,11 @@ processCASbits(int cas_bits, int location, const char *constrType,
 		else
 			ereport(ERROR,
 					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-					 /* translator: %s is CHECK, UNIQUE, or similar */
+					 constrType ?
+					 /* translator: %s is CHECK, UNIQUE, TRIGGER, or similar */
 					 errmsg("%s constraints cannot be marked NOT ENFORCED",
-							constrType),
+							constrType) :
+					 errmsg("constraint cannot be marked NOT ENFORCED"),
 					 parser_errposition(location)));
 
 		/*
@@ -19605,9 +19615,11 @@ processCASbits(int cas_bits, int location, const char *constrType,
 		else
 			ereport(ERROR,
 					(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-					 /* translator: %s is CHECK, UNIQUE, or similar */
+					 constrType ?
+					 /* translator: %s is CHECK, UNIQUE, TRIGGER, or similar */
 					 errmsg("%s constraints cannot be marked ENFORCED",
-							constrType),
+							constrType) :
+					 errmsg("constraint cannot be marked ENFORCED"),
 					 parser_errposition(location)));
 	}
 }
diff --git a/src/test/regress/expected/constraints.out b/src/test/regress/expected/constraints.out
index 4f39100fcdf..226a1b4c9e6 100644
--- a/src/test/regress/expected/constraints.out
+++ b/src/test/regress/expected/constraints.out
@@ -745,11 +745,11 @@ ERROR:  misplaced NOT ENFORCED clause
 LINE 1: CREATE TABLE UNIQUE_NOTEN_TBL(i int UNIQUE NOT ENFORCED);
                                                    ^
 ALTER TABLE unique_tbl ALTER CONSTRAINT unique_tbl_i_key ENFORCED;
-ERROR:  FOREIGN KEY constraints cannot be marked ENFORCED
+ERROR:  constraint cannot be marked ENFORCED
 LINE 1: ...TABLE unique_tbl ALTER CONSTRAINT unique_tbl_i_key ENFORCED;
                                                               ^
 ALTER TABLE unique_tbl ALTER CONSTRAINT unique_tbl_i_key NOT ENFORCED;
-ERROR:  FOREIGN KEY constraints cannot be marked NOT ENFORCED
+ERROR:  constraint cannot be marked NOT ENFORCED
 LINE 1: ...ABLE unique_tbl ALTER CONSTRAINT unique_tbl_i_key NOT ENFORC...
                                                              ^
 DROP TABLE unique_tbl;
diff --git a/src/test/regress/expected/foreign_key.out b/src/test/regress/expected/foreign_key.out
index 6a3374d5152..776f1059b2d 100644
--- a/src/test/regress/expected/foreign_key.out
+++ b/src/test/regress/expected/foreign_key.out
@@ -1284,11 +1284,11 @@ ERROR:  constraint declared INITIALLY DEFERRED must be DEFERRABLE
 LINE 1: ...e ALTER CONSTRAINT fktable_fk_fkey NOT DEFERRABLE INITIALLY ...
                                                              ^
 ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NO INHERIT;
-ERROR:  FOREIGN KEY constraints cannot be marked NO INHERIT
+ERROR:  constraint cannot be marked NO INHERIT
 LINE 1: ...ER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NO INHERIT...
                                                              ^
 ALTER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT VALID;
-ERROR:  FOREIGN KEY constraints cannot be marked NOT VALID
+ERROR:  constraint cannot be marked NOT VALID
 LINE 1: ...ER TABLE fktable ALTER CONSTRAINT fktable_fk_fkey NOT VALID;
                                                              ^
 -- test order of firing of FK triggers when several RI-induced changes need to
