mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-16630: Ambiguous error message when check constraint matches table name
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);``` and ```insert into t values (10);``` same error `ER_CONSTRAINT_FAILED` is obtained and it is not clear which constraint is violated. This patch solve this error so that in case if field constraint is violated the first parameter in the error message is `table.field_name` and if table constraint is violated the first parameter in error message is `constraint_name`.
This commit is contained in:
committed by
Vicențiu-Marian Ciorbaru
parent
b71c9ae030
commit
8639e28808
@ -135,3 +135,31 @@ INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
|
||||
set sql_mode=default;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-16630: Ambiguous error message when check constraint
|
||||
--echo # matches table name
|
||||
--echo #
|
||||
|
||||
use test;
|
||||
--disable_warnings
|
||||
drop table if exists t;
|
||||
--enable_warnings
|
||||
|
||||
create table t(a int, b int check(b>0),
|
||||
constraint b check(a<b), constraint a check(a>0),
|
||||
constraint x check (a>10));
|
||||
|
||||
show create table t;
|
||||
|
||||
# Generate error when field constraint 'b' is violated
|
||||
--echo # Field constraint 'b' will fail
|
||||
--error ER_CONSTRAINT_FAILED
|
||||
insert into t values (-1, 0);
|
||||
|
||||
# Generate error when table constraint 'b' is violated.
|
||||
--echo # Table constraint 'b' will fail
|
||||
--error ER_CONSTRAINT_FAILED
|
||||
insert into t values (1,1);
|
||||
|
||||
drop table t;
|
||||
|
Reference in New Issue
Block a user