summaryrefslogtreecommitdiff
path: root/mysql-test/suite
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-01-14 14:56:01 +0100
committerSergei Golubchik <serg@mariadb.org>2017-01-15 00:11:02 +0100
commit67e2028161d1f653a852f1a4679ff5e523296218 (patch)
tree6b0695fc4760a792df49e74a8e608b6461e59a7a /mysql-test/suite
parent20ca1bcf4bd81ed43683676276b5f27dc8da8e91 (diff)
downloadmariadb-git-67e2028161d1f653a852f1a4679ff5e523296218.tar.gz
MDEV-9690 concurrent queries with virtual columns crash in temporal code
Item_func_le included Arg_comparator. Arg_comparator remembered the current_thd during fix_fields and used that value during execution to allocate Item_cache in get_datetime_value(). But for vcols fix_fields and val_int can happen in different threads. Same bug for Item_func_in using in_datetime or cmp_item_datetime, both also remembered current_thd at fix_fields() to use it later for get_datetime_value(). As a fix, these objects no longer remember the current_thd, and get_datetime_value() uses current_thd at run time. This should not increase the number of current_thd calls much, as Item_cache is created only once anyway.
Diffstat (limited to 'mysql-test/suite')
-rw-r--r--mysql-test/suite/vcol/r/wrong_arena.result39
-rw-r--r--mysql-test/suite/vcol/t/wrong_arena.test22
2 files changed, 61 insertions, 0 deletions
diff --git a/mysql-test/suite/vcol/r/wrong_arena.result b/mysql-test/suite/vcol/r/wrong_arena.result
new file mode 100644
index 00000000000..d542c82458e
--- /dev/null
+++ b/mysql-test/suite/vcol/r/wrong_arena.result
@@ -0,0 +1,39 @@
+create table t1 (a datetime,
+# get_datetime_value
+b int as (a > 1), # Arg_comparator
+c int as (a in (1,2,3)), # in_datetime
+d int as ((a,a) in ((1,1),(2,1),(NULL,1))) # cmp_item_datetime
+);
+Warnings:
+Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Incorrect datetime value: '2'
+Warning 1292 Incorrect datetime value: '3'
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` datetime DEFAULT NULL,
+ `b` int(11) AS (a > 1) VIRTUAL,
+ `c` int(11) AS (a in (1,2,3)) VIRTUAL,
+ `d` int(11) AS ((a,a) in ((1,1),(2,1),(NULL,1))) VIRTUAL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+Warnings:
+Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Incorrect datetime value: '2'
+Warning 1292 Incorrect datetime value: '3'
+insert t1 (a) values ('2010-10-10 10:10:10');
+select * from t1;
+a b c d
+2010-10-10 10:10:10 1 0 0
+Warnings:
+Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Incorrect datetime value: '2'
+Warning 1292 Incorrect datetime value: '1'
+select * from t1;
+a b c d
+2010-10-10 10:10:10 1 0 0
+Warnings:
+Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Incorrect datetime value: '2'
+Warning 1292 Incorrect datetime value: '1'
+drop table t1;
diff --git a/mysql-test/suite/vcol/t/wrong_arena.test b/mysql-test/suite/vcol/t/wrong_arena.test
new file mode 100644
index 00000000000..8bf06bdb9bd
--- /dev/null
+++ b/mysql-test/suite/vcol/t/wrong_arena.test
@@ -0,0 +1,22 @@
+#
+# This tests various issues when vcol items allocate memory (e.g. more items)
+# not in the TABLE::expr_arena.
+#
+
+#
+# MDEV-9690 concurrent queries with virtual columns crash in temporal code
+#
+create table t1 (a datetime,
+ # get_datetime_value
+ b int as (a > 1), # Arg_comparator
+ c int as (a in (1,2,3)), # in_datetime
+ d int as ((a,a) in ((1,1),(2,1),(NULL,1))) # cmp_item_datetime
+);
+show create table t1;
+connect con1, localhost, root;
+insert t1 (a) values ('2010-10-10 10:10:10');
+select * from t1;
+disconnect con1;
+connection default;
+select * from t1;
+drop table t1;