aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2020-01-28 07:48:10 +0530
committerAmit Kapila <akapila@postgresql.org>2020-01-28 07:48:10 +0530
commit05f18c6b6b6e4b44302ee20a042cedc664532aa2 (patch)
tree312f27295ec5e9623b517bb61550b76a4df093e0 /src/backend/commands/tablecmds.c
parentff8ca5fadd819155c82bd16fcc6b7231af649cf8 (diff)
downloadpostgresql-05f18c6b6b6e4b44302ee20a042cedc664532aa2.tar.gz
postgresql-05f18c6b6b6e4b44302ee20a042cedc664532aa2.zip
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
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 7c23968f2d3..70589dd1dc3 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -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);