Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions mysql-test/include/get_rec_idx_ranges_from_opt_ctx.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ set @opt_context=
context,
'(?<=set @opt_context=\')([\n\r].*)*(?=\'\;#opt_context_ends)')
from information_schema.optimizer_context);
set @records=
(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.file_stat_records')));
select *from json_table(@records,
'$[*]' columns(file_stat_records text path '$')) as jt;
set @file_stat_records=
(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.file_stat_records')));
select *from json_table(@file_stat_records,
'$[*]' columns(file_stat_records text path '$')) as jt;
set @indexes=
(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.indexes')));

set @table_contexts= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.list_contexts[*]')));
select *from json_table(
@indexes, '$[*][*]' columns(index_name text path '$.index_name',
rec_per_key json path '$.rec_per_key')) as jt;
@table_contexts,
'$[*]' columns(table_name text path '$.name',
file_stat_records text path '$.file_stat_records',
index_name text path '$**.indexes[*].index_name',
rec_per_key json path '$**.indexes[*].rec_per_key'
)) as jt;

set @list_ranges=
(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.list_ranges')));
select *from json_table(
Expand All @@ -24,4 +21,5 @@ select *from json_table(
ranges json path '$.ranges',
num_rows int path '$.num_rows',
max_index_blocks int path '$.max_index_blocks',
max_row_blocks int path '$.max_row_blocks')) as jt;
max_row_blocks int path '$.max_row_blocks'
)) as jt;
75 changes: 12 additions & 63 deletions mysql-test/main/opt_context_load_stats_basic.result
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,16 @@ set @opt_context=
context,
'(?<=set @opt_context=\')([\n\r].*)*(?=\'\;#opt_context_ends)')
from information_schema.optimizer_context);
set @records=
(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.file_stat_records')));
select *from json_table(@records,
'$[*]' columns(file_stat_records text path '$')) as jt;
file_stat_records
20
set @file_stat_records=
(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.file_stat_records')));
select *from json_table(@file_stat_records,
'$[*]' columns(file_stat_records text path '$')) as jt;
file_stat_records
20
set @indexes=
(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.indexes')));
set @table_contexts= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.list_contexts[*]')));
select *from json_table(
@indexes, '$[*][*]' columns(index_name text path '$.index_name',
rec_per_key json path '$.rec_per_key')) as jt;
index_name rec_per_key
t1_idx_a ["4"]
t1_idx_b ["3"]
t1_idx_ab [
"4",
"1"
]
@table_contexts,
'$[*]' columns(table_name text path '$.name',
file_stat_records text path '$.file_stat_records',
index_name text path '$**.indexes[*].index_name',
rec_per_key json path '$**.indexes[*].rec_per_key'
)) as jt;
table_name file_stat_records index_name rec_per_key
db1.t1 20 NULL NULL
set @list_ranges=
(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.list_ranges')));
select *from json_table(
Expand All @@ -63,14 +49,14 @@ select *from json_table(
ranges json path '$.ranges',
num_rows int path '$.num_rows',
max_index_blocks int path '$.max_index_blocks',
max_row_blocks int path '$.max_row_blocks')) as jt;
max_row_blocks int path '$.max_row_blocks'
)) as jt;
index_name ranges num_rows max_index_blocks max_row_blocks
t1_idx_a ["(NULL) < (a) < (3)"] 12 1 1
t1_idx_b ["(6) < (b)"] 2 1 1
t1_idx_ab ["(NULL) < (a) < (3)"] 12 1 1
set @saved_opt_context_1=@opt_context;
set @saved_records_1=@records;
set @saved_indexes_1=@indexes;
set @saved_table_contexts= @table_contexts;
set @saved_list_ranges_1=@list_ranges;
#
# load stats in JSON format into variable optimizer_replay_context
Expand Down Expand Up @@ -129,21 +115,8 @@ from information_schema.optimizer_context);
select JSON_EQUALS(@saved_opt_context_1, @opt_context);
JSON_EQUALS(@saved_opt_context_1, @opt_context)
0
set @records= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.file_stat_records')));
set @indexes=(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.indexes')));
set @list_ranges= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.list_ranges')));
set @saved_records_2 = @records;
set @saved_indexes_2 = @indexes;
set @saved_list_ranges_2 = @list_ranges;
select JSON_EQUALS(@saved_records_2, @saved_records_1);
JSON_EQUALS(@saved_records_2, @saved_records_1)
0
select * from json_table(@records, '$[*]' columns(file_stat_records text path '$')) as jt;
file_stat_records
40
select JSON_EQUALS(@saved_indexes_2, @saved_indexes_1);
JSON_EQUALS(@saved_indexes_2, @saved_indexes_1)
1
select JSON_EQUALS(@saved_list_ranges_2, @saved_list_ranges_1);
JSON_EQUALS(@saved_list_ranges_2, @saved_list_ranges_1)
0
Expand Down Expand Up @@ -240,15 +213,7 @@ from information_schema.optimizer_context);
select JSON_EQUALS(@saved_opt_context_1, @opt_context);
JSON_EQUALS(@saved_opt_context_1, @opt_context)
0
set @records= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.file_stat_records')));
set @indexes=(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.indexes')));
set @list_ranges= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.list_ranges')));
select JSON_EQUALS(@saved_records_2, @records);
JSON_EQUALS(@saved_records_2, @records)
1
select JSON_EQUALS(@saved_indexes_2, @indexes);
JSON_EQUALS(@saved_indexes_2, @indexes)
1
select JSON_EQUALS(@saved_list_ranges_2, @list_ranges);
JSON_EQUALS(@saved_list_ranges_2, @list_ranges)
1
Expand All @@ -273,23 +238,7 @@ set @opt_context=
context,
'(?<=set @opt_context=\')([\n\r].*)*(?=\'\;#opt_context_ends)')
from information_schema.optimizer_context);
set @records= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.file_stat_records')));
set @indexes=(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.indexes')));
set @list_ranges= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.list_ranges')));
select JSON_EQUALS(@saved_records_2, @records);
JSON_EQUALS(@saved_records_2, @records)
1
select JSON_EQUALS(@saved_indexes_2, @indexes);
JSON_EQUALS(@saved_indexes_2, @indexes)
0
select * from json_table(@indexes, '$[*][*]' columns(index_name text path '$.index_name', rec_per_key json path '$.rec_per_key')) as jt;
index_name rec_per_key
t1_idx_a ["8"]
t1_idx_b ["5"]
t1_idx_ab [
"8",
"2"
]
select JSON_EQUALS(@saved_list_ranges_2, @list_ranges);
JSON_EQUALS(@saved_list_ranges_2, @list_ranges)
1
Expand Down
19 changes: 1 addition & 18 deletions mysql-test/main/opt_context_load_stats_basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ select * from t1 where a < 3 and b > 6;
--source include/get_rec_idx_ranges_from_opt_ctx.inc

set @saved_opt_context_1=@opt_context;
set @saved_records_1=@records;
set @saved_indexes_1=@indexes;
set @saved_table_contexts= @table_contexts;
set @saved_list_ranges_1=@list_ranges;

--echo #
Expand Down Expand Up @@ -79,17 +78,10 @@ select * from t1 where a < 3 and b > 6;

select JSON_EQUALS(@saved_opt_context_1, @opt_context);

set @records= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.file_stat_records')));
set @indexes=(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.indexes')));
set @list_ranges= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.list_ranges')));

set @saved_records_2 = @records;
set @saved_indexes_2 = @indexes;
set @saved_list_ranges_2 = @list_ranges;

select JSON_EQUALS(@saved_records_2, @saved_records_1);
select * from json_table(@records, '$[*]' columns(file_stat_records text path '$')) as jt;
select JSON_EQUALS(@saved_indexes_2, @saved_indexes_1);
select JSON_EQUALS(@saved_list_ranges_2, @saved_list_ranges_1);
select * from json_table(
@list_ranges,
Expand Down Expand Up @@ -153,12 +145,8 @@ select * from t1 where a < 3 and b > 6;

select JSON_EQUALS(@saved_opt_context_1, @opt_context);

set @records= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.file_stat_records')));
set @indexes=(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.indexes')));
set @list_ranges= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.list_ranges')));

select JSON_EQUALS(@saved_records_2, @records);
select JSON_EQUALS(@saved_indexes_2, @indexes);
select JSON_EQUALS(@saved_list_ranges_2, @list_ranges);

--echo #
Expand All @@ -174,13 +162,8 @@ select * from t1 where a < 3 and b > 6;

--source include/get_opt_context.inc

set @records= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.file_stat_records')));
set @indexes=(select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.indexes')));
set @list_ranges= (select JSON_DETAILED(JSON_EXTRACT(@opt_context, '$**.list_ranges')));

select JSON_EQUALS(@saved_records_2, @records);
select JSON_EQUALS(@saved_indexes_2, @indexes);
select * from json_table(@indexes, '$[*][*]' columns(index_name text path '$.index_name', rec_per_key json path '$.rec_per_key')) as jt;
select JSON_EQUALS(@saved_list_ranges_2, @list_ranges);

set @saved_opt_context_2 = @opt_context;
Expand Down
Loading
Loading