1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#
# Tests for r_engine_stats in ANALYZE FORMAT=JSON output
#
--source include/analyze-format.inc
--source include/have_sequence.inc
--source include/have_innodb.inc
create table t1 (
pk int not null,
a varchar(64),
b varchar(64),
c varchar(64)
) engine=innodb;
insert into t1 select
seq, seq, seq, seq
from
seq_1_to_10000;
analyze table t1 persistent for all;
--echo # Note the r_engine_stats below. Only non-zero members are printed
let $out=`
ANALYZE FORMAT=json
select * from t1 where pk < 120000;
`;
# Don't use "source include/analyze-format.inc" as it replaces r_engine_stats
# Replace the "pages_accessed" value, too, as it is different for some
# platforms...
--replace_regex /("(r_[a-z_]*_time(_in_progress)?_ms|r_buffer_size|pages_accessed)": )[^, \n]*/\1"REPLACED"/
evalp select '$out' as X;
evalp set @js='$out';
set @out=(select json_extract(@js,'$**.r_engine_stats.pages_accessed'));
select cast(json_extract(@out,'$[0]') as DOUBLE) > 0 as PAGES_ACCESSED_MORE_THAN_ZERO;
--echo #
--echo # Try an UPDATE
--echo #
let $out=`analyze format=json update t1 set b = b-1 where pk < 120000`;
--replace_regex /("(r_[a-z_]*_time_ms|pages_accessed|pages_updated)": )[^, \n]*/\1"REPLACED"/
evalp select '$out' as X;
evalp set @js='$out';
set @out=(select json_extract(@js,'$**.r_engine_stats.pages_updated'));
select cast(json_extract(@out,'$[0]') as DOUBLE) > 0 as PAGES_UPDATED_MORE_THAN_ZERO;
--echo #
--echo # Try a DELETE
--echo #
let $out=`analyze format=json delete from t1 where mod(pk,2)=1`;
--replace_regex /("(r_[a-z_]*_time_ms|pages_accessed|pages_updated)": )[^, \n]*/\1"REPLACED"/
evalp select '$out' as X;
evalp set @js='$out';
set @out=(select json_extract(@js,'$**.r_engine_stats.pages_updated'));
select cast(json_extract(@out,'$[0]') as DOUBLE) > 0 as PAGES_UPDATED_MORE_THAN_ZERO;
drop table t1;
--echo #
--echo # MDEV-31764: ASAN use-after-poison in trace_engine_stats upon ANALYZE FORMAT=JSON
--echo #
--disable_result_log
ANALYZE FORMAT=JSON SELECT count(*) FROM information_schema.GLOBAL_STATUS;
--enable_result_log
--echo # Another testcase without I_S:
CREATE TABLE t1 (a INT);
INSERT INTO t1 SELECT seq FROM seq_1_to_100;
CREATE TABLE t2 (s INT);
INSERT INTO t2 SELECT seq FROM seq_1_to_10;
--echo # Must use SJ-Materialization to hit the issue with temp.table:
--source include/analyze-format.inc
ANALYZE FORMAT=JSON SELECT * FROM t1 WHERE a IN (SELECT s FROM t2);
DROP TABLE t1, t2;
|