1#
2# This tests various issues when vcol items allocate memory (e.g. more items)
3# not in the TABLE::expr_arena.
4#
5
6#
7# MDEV-9690 concurrent queries with virtual columns crash in temporal code
8#
9create table t1 (a datetime,
10  # get_datetime_value
11  b int as (a > 1),                             # Arg_comparator
12  c int as (a in (1,2,3)),                      # in_datetime
13  d int as ((a,a) in ((1,1),(2,1),(NULL,1))),   # cmp_item_datetime
14  # other issues
15  e int as ((a,1) in ((1,1),(2,1),(NULL,1)))    # cmp_item_row::alloc_comparators()
16);
17enable_prepare_warnings;
18show create table t1;
19disable_prepare_warnings;
20connect con1, localhost, root;
21disable_warnings;
22insert t1 (a) values ('2010-10-10 10:10:10');
23enable_warnings;
24select * from t1;
25disconnect con1;
26connection default;
27disable_warnings;
28select * from t1;
29enable_warnings;
30drop table t1;
31
32connect con1, localhost, root;
33create table t1 (a datetime,
34  b datetime as (least(a,1))                    # Item_func_min_max::get_date
35);
36insert t1 (a) values ('2010-10-10 10:10:10');
37select * from t1;
38disconnect con1;
39connection default;
40select * from t1;
41drop table t1;
42
43#
44# MDEV-13435 Crash when selecting virtual columns generated using JSON functions
45#
46create table t1 (
47  id int  not null ,
48  js varchar(1000) not null,
49  t time AS (cast(json_value(json_extract(js,concat('$.singleDay."', dayname(curdate()),'"')),'$.start') as time)) virtual);
50insert  into t1(id,js) values (0, '{"default" : {"start": "00:00:00", "end":"23:59:50"}}');
51select * from t1;
52drop table t1;
53