summaryrefslogtreecommitdiff
path: root/mysql-test/t/check_constraint.test
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-05-15 17:02:08 +0300
committerMonty <monty@mariadb.org>2018-05-15 17:10:40 +0300
commit4ab180ad5e9c67427b561035e4b8e193d429fe5a (patch)
treef61abf25921b112e58ec68cbfcf9a6d0ae392d60 /mysql-test/t/check_constraint.test
parent0e296947db503eed2db5b995676f4d9a454c9001 (diff)
downloadmariadb-git-4ab180ad5e9c67427b561035e4b8e193d429fe5a.tar.gz
MDEV-15461 Check Constraints with binary logging makes insert inconsistent
Problem was that verify_constraints() didn't check if there was an error as part of evaluating constraints (can happen in strict mode). In one-row-insert the error was ignored when using binary logging as binary logging clear errors if insert succeeded. In multi-row-insert the error was noticed for the second row. After this fix one will get an error for both one and multi-row inserts if the constraints generates a warning in strict mode.
Diffstat (limited to 'mysql-test/t/check_constraint.test')
-rw-r--r--mysql-test/t/check_constraint.test24
1 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/t/check_constraint.test b/mysql-test/t/check_constraint.test
index 9a77736acd7..02081071bd4 100644
--- a/mysql-test/t/check_constraint.test
+++ b/mysql-test/t/check_constraint.test
@@ -111,3 +111,27 @@ create table t1 (id int auto_increment primary key, datecol datetime, check (dat
insert into t1 (datecol) values (now());
insert into t1 (datecol) values (now());
drop table t1;
+
+#
+# MDEV-15461 Check Constraints with binary logging makes insert inconsistent
+#
+
+CREATE TABLE t1 (
+ EmployeeID SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
+ FirstName VARCHAR(30) NOT NULL CHECK (CHAR_LENGTH(FirstName > 2))
+);
+
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 VALUES (NULL, 'Ken');
+SHOW WARNINGS;
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
+SHOW WARNINGS;
+INSERT IGNORE INTO t1 VALUES (NULL, 'Ken');
+INSERT IGNORE INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
+set sql_mode="";
+INSERT INTO t1 VALUES (NULL, 'Ken');
+INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
+set sql_mode=default;
+select * from t1;
+drop table t1;