diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2019-05-14 14:01:15 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2019-08-28 12:06:52 +0200 |
commit | 9cd6e7ad73554be6d0186a42f983777a90a984f1 (patch) | |
tree | 229bdc0666fd61f7688ef342b553f22a3474bbe0 /mysql-test | |
parent | 7aac83580a5c5a6042b5d03d1031750cb0d5d6ea (diff) | |
download | mariadb-git-9cd6e7ad73554be6d0186a42f983777a90a984f1.tar.gz |
MDEV-16932: ASAN heap-use-after-free in my_charlen_utf8 / my_well_formed_char_length_utf8 on 2nd execution of SP with ALTER trying to add bad CHECK
Make automatic name generation during execution (not prepare).
Check result of memory allocation operation.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/constraints.result | 55 | ||||
-rw-r--r-- | mysql-test/t/constraints.test | 37 |
2 files changed, 92 insertions, 0 deletions
diff --git a/mysql-test/r/constraints.result b/mysql-test/r/constraints.result index df93b69cb9e..97dc19ae022 100644 --- a/mysql-test/r/constraints.result +++ b/mysql-test/r/constraints.result @@ -130,3 +130,58 @@ t CREATE TABLE `t` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP table test.t; SET @@SQL_MODE=@OLD_SQL_MODE; +# +# MDEV-16932 - ASAN heap-use-after-free in my_charlen_utf8 / +# my_well_formed_char_length_utf8 on 2nd execution of SP with +# ALTER trying to add bad CHECK +# +CREATE TABLE t1 (a INT); +CREATE PROCEDURE sp() ALTER TABLE t1 ADD CONSTRAINT CHECK (b > 0); +CALL sp; +ERROR 42S22: Unknown column 'b' in 'CHECK' +CALL sp; +ERROR 42S22: Unknown column 'b' in 'CHECK' +CALL sp; +ERROR 42S22: Unknown column 'b' in 'CHECK' +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 add column b int; +CALL sp; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + CONSTRAINT `CONSTRAINT_1` CHECK (`b` > 0) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CALL sp; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + CONSTRAINT `CONSTRAINT_1` CHECK (`b` > 0), + CONSTRAINT `CONSTRAINT_2` CHECK (`b` > 0) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP PROCEDURE sp; +DROP TABLE t1; +CREATE TABLE t1 (a INT); +CREATE PROCEDURE sp() ALTER TABLE t1 ADD CONSTRAINT CHECK (b > 0); +CALL sp; +ERROR 42S22: Unknown column 'b' in 'CHECK' +alter table t1 add column b int, add constraint check (b < 10); +CALL sp; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` int(11) DEFAULT NULL, + CONSTRAINT `CONSTRAINT_1` CHECK (`b` < 10), + CONSTRAINT `CONSTRAINT_2` CHECK (`b` > 0) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP PROCEDURE sp; +DROP TABLE t1; +# End of 10.2 tests diff --git a/mysql-test/t/constraints.test b/mysql-test/t/constraints.test index 39b2eb52a9f..531e6bd804b 100644 --- a/mysql-test/t/constraints.test +++ b/mysql-test/t/constraints.test @@ -119,3 +119,40 @@ CREATE TABLE test.t (f int foo=bar check(f>0)); SHOW CREATE TABLE t; DROP table test.t; SET @@SQL_MODE=@OLD_SQL_MODE; + +--echo # +--echo # MDEV-16932 - ASAN heap-use-after-free in my_charlen_utf8 / +--echo # my_well_formed_char_length_utf8 on 2nd execution of SP with +--echo # ALTER trying to add bad CHECK +--echo # + +CREATE TABLE t1 (a INT); +CREATE PROCEDURE sp() ALTER TABLE t1 ADD CONSTRAINT CHECK (b > 0); +--error ER_BAD_FIELD_ERROR +CALL sp; +--error ER_BAD_FIELD_ERROR +CALL sp; +--error ER_BAD_FIELD_ERROR +CALL sp; +show create table t1; +alter table t1 add column b int; +CALL sp; +show create table t1; +CALL sp; +show create table t1; +# Cleanup +DROP PROCEDURE sp; +DROP TABLE t1; + +CREATE TABLE t1 (a INT); +CREATE PROCEDURE sp() ALTER TABLE t1 ADD CONSTRAINT CHECK (b > 0); +--error ER_BAD_FIELD_ERROR +CALL sp; +alter table t1 add column b int, add constraint check (b < 10); +CALL sp; +show create table t1; +# Cleanup +DROP PROCEDURE sp; +DROP TABLE t1; + +--echo # End of 10.2 tests |