summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorAnel Husakovic <anelhusakovic88@gmail.com>2018-04-20 07:06:25 +0000
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2018-05-18 11:47:14 +0300
commitadf9f8d99528d5cc965cc63c498c27eb0dfd1ed1 (patch)
treed92c87bcab11939dd0d728993ffb5d3837319935 /sql/table.cc
parent395c8ca708c15e7f4b8dca5c3f5246d03eb557af (diff)
downloadmariadb-git-bb-anel-check_constraing.tar.gz
Add error message in case of the `field` `check` constraintsbb-anel-check_constraing
One can create table with the same name for `field` and `table` `check` constraint. For example: create table t(a int check(a>0), constraint a check(a>10)); But when inserting new rows same error is always raised. For example with insert into t values (-1); insert into t values (10); same error `ER_CONSTRAINT_FAILED` is returned for both queries. By the assumption that the previous error should be raised only in case of `table` constraints, this patch will distinguish between `field` and `table` error message by adding newly created `ER_FIELD_CONSTRAINT_FAILED` error which occurs only when `field` constraint is violated.
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/sql/table.cc b/sql/table.cc
index ced8f8c0ae8..8b33ccd8675 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -5243,7 +5243,11 @@ int TABLE::verify_constraints(bool ignore_failure)
if (((*chk)->expr->val_int() == 0 && !(*chk)->expr->null_value) ||
in_use->is_error())
{
- my_error(ER_CONSTRAINT_FAILED,
+ enum_vcol_info_type vcol_type= (*chk)->get_vcol_type();
+ DBUG_ASSERT(vcol_type == VCOL_CHECK_TABLE ||
+ vcol_type == VCOL_CHECK_FIELD);
+ my_error(vcol_type == VCOL_CHECK_TABLE ? ER_CONSTRAINT_FAILED :
+ ER_FIELD_CONSTRAINT_FAILED,
MYF(ignore_failure ? ME_JUST_WARNING : 0), (*chk)->name.str,
s->db.str, s->table_name.str);
return ignore_failure ? VIEW_CHECK_SKIP : VIEW_CHECK_ERROR;