mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Added relation name in error messages for constraint checks.
This gives more information to the user about the error and it makes such messages consistent with the other similar messages in the code. Reported-by: Simon Riggs Author: Mahendra Singh and Simon Riggs Reviewed-by: Beena Emerson and Amit Kapila Discussion: https://postgr.es/m/CANP8+j+7YUvQvGxTrCiw77R23enMJ7DFmyA3buR+fa2pKs4XhA@mail.gmail.com
This commit is contained in:
@ -5288,8 +5288,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_NOT_NULL_VIOLATION),
|
||||
errmsg("column \"%s\" contains null values",
|
||||
NameStr(attr->attname)),
|
||||
errmsg("column \"%s\" of relation \"%s\" contains null values",
|
||||
NameStr(attr->attname),
|
||||
RelationGetRelationName(oldrel)),
|
||||
errtablecol(oldrel, attn + 1)));
|
||||
}
|
||||
}
|
||||
@ -5304,8 +5305,9 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
|
||||
if (!ExecCheck(con->qualstate, econtext))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CHECK_VIOLATION),
|
||||
errmsg("check constraint \"%s\" is violated by some row",
|
||||
con->name),
|
||||
errmsg("check constraint \"%s\" of relation \"%s\" is violated by some row",
|
||||
con->name,
|
||||
RelationGetRelationName(oldrel)),
|
||||
errtableconstraint(oldrel, con->name)));
|
||||
break;
|
||||
case CONSTR_FOREIGN:
|
||||
@ -5322,11 +5324,13 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
|
||||
if (tab->validate_default)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CHECK_VIOLATION),
|
||||
errmsg("updated partition constraint for default partition would be violated by some row")));
|
||||
errmsg("updated partition constraint for default partition \"%s\" would be violated by some row",
|
||||
RelationGetRelationName(oldrel))));
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CHECK_VIOLATION),
|
||||
errmsg("partition constraint is violated by some row")));
|
||||
errmsg("partition constraint of relation \"%s\" is violated by some row",
|
||||
RelationGetRelationName(oldrel))));
|
||||
}
|
||||
|
||||
/* Write the tuple out to the new relation */
|
||||
@ -10160,8 +10164,9 @@ validateCheckConstraint(Relation rel, HeapTuple constrtup)
|
||||
if (!ExecCheck(exprstate, econtext))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_CHECK_VIOLATION),
|
||||
errmsg("check constraint \"%s\" is violated by some row",
|
||||
NameStr(constrForm->conname)),
|
||||
errmsg("check constraint \"%s\" of relation \"%s\" is violated by some row",
|
||||
NameStr(constrForm->conname),
|
||||
RelationGetRelationName(rel)),
|
||||
errtableconstraint(rel, NameStr(constrForm->conname))));
|
||||
|
||||
ResetExprContext(econtext);
|
||||
|
Reference in New Issue
Block a user