@@ -5288,8 +5288,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
5288
5288
5289
5289
ereport(ERROR,
5290
5290
(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)),
5293
5294
errtablecol(oldrel, attn + 1)));
5294
5295
}
5295
5296
}
@@ -5304,8 +5305,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
5304
5305
if (!ExecCheck(con->qualstate, econtext))
5305
5306
ereport(ERROR,
5306
5307
(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)),
5309
5311
errtableconstraint(oldrel, con->name)));
5310
5312
break;
5311
5313
case CONSTR_FOREIGN:
@@ -5322,11 +5324,13 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
5322
5324
if (tab->validate_default)
5323
5325
ereport(ERROR,
5324
5326
(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))));
5326
5329
else
5327
5330
ereport(ERROR,
5328
5331
(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))));
5330
5334
}
5331
5335
5332
5336
/* Write the tuple out to the new relation */
@@ -10160,8 +10164,9 @@ validateCheckConstraint(Relation rel, HeapTuple constrtup)
10160
10164
if (!ExecCheck(exprstate, econtext))
10161
10165
ereport(ERROR,
10162
10166
(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)),
10165
10170
errtableconstraint(rel, NameStr(constrForm->conname))));
10166
10171
10167
10172
ResetExprContext(econtext);
0 commit comments