@@ -5288,8 +5288,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
52885288
52895289ereport(ERROR,
52905290(errcode(ERRCODE_NOT_NULL_VIOLATION),
5291- errmsg("column \"%s\" contains null values",
5292- NameStr(attr->attname)),
5291+ errmsg("column \"%s\" of relation \"%s\" contains null values",
5292+ NameStr(attr->attname),
5293+ RelationGetRelationName(oldrel)),
52935294 errtablecol(oldrel, attn + 1)));
52945295}
52955296}
@@ -5304,8 +5305,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
53045305if (!ExecCheck(con->qualstate, econtext))
53055306ereport(ERROR,
53065307(errcode(ERRCODE_CHECK_VIOLATION),
5307- errmsg("check constraint \"%s\" is violated by some row",
5308- con->name),
5308+ errmsg("check constraint \"%s\" of relation \"%s\" is violated by some row",
5309+ con->name,
5310+ RelationGetRelationName(oldrel)),
53095311 errtableconstraint(oldrel, con->name)));
53105312break;
53115313case CONSTR_FOREIGN:
@@ -5322,11 +5324,13 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
53225324if (tab->validate_default)
53235325ereport(ERROR,
53245326(errcode(ERRCODE_CHECK_VIOLATION),
5325- errmsg("updated partition constraint for default partition would be violated by some row")));
5327+ errmsg("updated partition constraint for default partition \"%s\" would be violated by some row",
5328+ RelationGetRelationName(oldrel))));
53265329else
53275330ereport(ERROR,
53285331(errcode(ERRCODE_CHECK_VIOLATION),
5329- errmsg("partition constraint is violated by some row")));
5332+ errmsg("partition constraint of relation \"%s\" is violated by some row",
5333+ RelationGetRelationName(oldrel))));
53305334}
53315335
53325336/* Write the tuple out to the new relation */
@@ -10160,8 +10164,9 @@ validateCheckConstraint(Relation rel, HeapTuple constrtup)
1016010164if (!ExecCheck(exprstate, econtext))
1016110165ereport(ERROR,
1016210166(errcode(ERRCODE_CHECK_VIOLATION),
10163- errmsg("check constraint \"%s\" is violated by some row",
10164- NameStr(constrForm->conname)),
10167+ errmsg("check constraint \"%s\" of relation \"%s\" is violated by some row",
10168+ NameStr(constrForm->conname),
10169+ RelationGetRelationName(rel)),
1016510170 errtableconstraint(rel, NameStr(constrForm->conname))));
1016610171
1016710172ResetExprContext(econtext);