summaryrefslogtreecommitdiff
path: root/mysql-test/main/statistics_upgrade_not_done.result
blob: 902bf25c242d0457c7a842aedc91e1498a930c35 (plain)
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
# Create the old-version of the table
call mtr.add_suppression(".*Incorrect definition of table mysql.column_stats:.*");
alter table mysql.column_stats rename test.t1;
CREATE TABLE mysql.column_stats (
`db_name` varchar(64) COLLATE utf8mb3_bin NOT NULL,
`table_name` varchar(64) COLLATE utf8mb3_bin NOT NULL,
`column_name` varchar(64) COLLATE utf8mb3_bin NOT NULL,
`min_value` varbinary(255) DEFAULT NULL,
`max_value` varbinary(255) DEFAULT NULL,
`nulls_ratio` decimal(12,4) DEFAULT NULL,
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
`hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') COLLATE utf8mb3_bin DEFAULT NULL,
`histogram` varbinary(255) DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns';
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
INSERT INTO mysql.column_stats VALUES
('test','t0','a','0','9',0.0000,4.0000,1.0000,5,'DOUBLE_PREC_HB', x'5555AAAA00');
flush tables;
analyze select * from t0 where a<3;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	r_rows	filtered	r_filtered	Extra
1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	10.00	100.00	30.00	Using where
# restart
select hex(histogram) from mysql.column_stats where table_name='t0' and db_name='test';
hex(histogram)
5555AAAA00
analyze select * from t0 where a<3;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	r_rows	filtered	r_filtered	Extra
1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	10.00	100.00	30.00	Using where
create table t2 (a int);
# This currently just pretends that the histogram was collected. 
analyze table t2 persistent for all;
Table	Op	Msg_type	Msg_text
test.t2	analyze	status	Engine-independent statistics collected
test.t2	analyze	status	Table is already up to date
select * from mysql.column_stats where table_name='t2' and db_name='test';
db_name	table_name	column_name	min_value	max_value	nulls_ratio	avg_length	avg_frequency	hist_size	hist_type	histogram
analyze select * from t0 where a<3;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	r_rows	filtered	r_filtered	Extra
1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	10.00	33.33	30.00	Using where
drop table t0, t1, t2;