Skip to content
Open
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
210 changes: 210 additions & 0 deletions mysql-test/main/opt_context_store_stats.result
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,214 @@ index_name ranges num_rows max_index_blocks max_row_blocks
a ["(10) <= (a) <= (10)"] 49 1 11
# == End of optimizer context
drop table t1;
#
# MDEV-40533: unprintable gis ranges in trace and context
#
create table t1 (
id int,
g1 geometry not null,
g2 geometry,
key k_prefix (g1(5)),
key k_full (g1(200)),
key k_null (g2(200))
) engine=myisam;
insert into t1 select seq, point(seq, seq), point(seq, seq) from seq_1_to_5;
insert into t1 values (6, point(6,6), NULL);
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
# The index holds the whole value: it is printed in the WKT format
explain
select id from t1 force index (k_full) where g1=point(2,2);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref k_full k_full 202 const 1 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t1 6 NULL NULL
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
k_full ["(POINT(2 2)) <= (g1) <= (POINT(2 2))"] 1 1 1
# == End of optimizer context
# multiple ranges
explain
select id from t1 force index (k_full)
where g1=point(3,3) or g1=linestring(point(1,1), point(2,2));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range k_full k_full 202 NULL 2 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t1 6 NULL NULL
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
k_full [
"(POINT(3 3)) <= (g1) <= (POINT(3 3))",
"(LINESTRING(1 1,2 2)) <= (g1) <= (LINESTRING(1 1,2 2))"
] 2 2 1
# == End of optimizer context
# NULL values and multiple ranges
explain
select id from t1 force index (k_null)
where g2=point(3,3) or g2 is null or g2=linestring(point(1,1), point(2,2));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range k_null k_null 203 NULL 3 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t1 6 NULL NULL
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
k_null [
"(NULL) <= (g2) <= (NULL)",
"(POINT(3 3)) <= (g2) <= (POINT(3 3))",
"(LINESTRING(1 1,2 2)) <= (g2) <= (LINESTRING(1 1,2 2))"
] 3 3 1
# == End of optimizer context
# The index holds only a prefix of the value, so it cannot be converted
# to WKT. It is printed as a binary string, like any other BLOB prefix.
explain
select id from t1 force index (k_prefix) where g1=point(2,2);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref k_prefix k_prefix 7 const 6 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t1 6 NULL NULL
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
k_prefix ["(\\\\x00\\\\x00\\\\x00\\\\x00\\\\x01) <= (g1) <= (\\\\x00\\\\x00\\\\x00\\\\x00\\\\x01)"] 6 1 1
# == End of optimizer context
drop table t1;
#
# A SPATIAL index stores the MBR of the value. It is printed as the
# WKT of the MBR together with the spatial relation the range uses.
#
create table t2 (
id int,
g geometry not null,
spatial key (g)
) engine=myisam;
insert into t2 select seq, point(seq, seq) from seq_1_to_20;
insert into t2 values
(21, geomfromtext('LINESTRING(0 0, 5 8)')),
(22, geomfromtext('POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))'));
analyze table t2;
Table Op Msg_type Msg_text
test.t2 analyze status OK
# mbrcontains(value, column)
explain
select id from t2 where mbrcontains(geomfromtext('POLYGON((0 0,0 3,3 3,3 0,0 0))'), g);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range g g 34 NULL 4 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t2 22 g ["22"]
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
g ["(g) MBRWITHIN (POLYGON((0 0,3 0,3 3,0 3,0 0)))"] 4 1 1
# == End of optimizer context
# mbrwithin(column, value)
explain
select id from t2 where mbrwithin(g, geomfromtext('LINESTRING(1 1, 9 12)'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range g g 34 NULL 9 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t2 22 g ["22"]
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
g ["(g) MBRWITHIN (POLYGON((1 1,9 1,9 12,1 12,1 1)))"] 9 1 1
# == End of optimizer context
# The other spatial relations
explain
select id from t2 where mbrcontains(g, geomfromtext('POINT(2 2)'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range g g 34 NULL 3 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t2 22 g ["22"]
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
g ["(g) MBRCONTAINS (POLYGON((2 2,2 2,2 2,2 2,2 2)))"] 3 1 1
# == End of optimizer context
explain
select id from t2 where mbrequals(g, geomfromtext('POINT(7 7)'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range g g 34 NULL 1 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t2 22 g ["22"]
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
g ["(g) MBREQUALS (POLYGON((7 7,7 7,7 7,7 7,7 7)))"] 1 1 1
# == End of optimizer context
explain
select id from t2 where mbrintersects(g, geomfromtext('POLYGON((0 0,0 2,2 2,2 0,0 0))'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range g g 34 NULL 4 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t2 22 g ["22"]
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
g ["(g) MBRINTERSECTS (POLYGON((0 0,2 0,2 2,0 2,0 0)))"] 4 1 1
# == End of optimizer context
# mbrtouches/mbroverlaps all use the mbrintersects relation
explain
select id from t2 where mbrtouches(g, geomfromtext('POLYGON((0 0,0 2,2 2,2 0,0 0))'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range g g 34 NULL 4 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t2 22 g ["22"]
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
g ["(g) MBRINTERSECTS (POLYGON((0 0,2 0,2 2,0 2,0 0)))"] 4 1 1
# == End of optimizer context
explain
select id from t2 where mbroverlaps(g, geomfromtext('POLYGON((0 0,0 2,2 2,2 0,0 0))'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range g g 34 NULL 4 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t2 22 g ["22"]
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
g ["(g) MBRINTERSECTS (POLYGON((0 0,2 0,2 2,0 2,0 0)))"] 4 1 1
# == End of optimizer context
explain
select id from t2 where mbrdisjoint(g, geomfromtext('POLYGON((0 0,0 2,2 2,2 0,0 0))'));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL g NULL NULL NULL 22 Using where
# == Optimizer Context
# === Tables
# Tables in the context
table_name file_stat_records index_name rec_per_key
test.t2 22 g ["22"]
# === Range accesses
index_name ranges num_rows max_index_blocks max_row_blocks
g ["(g) MBRDISJOINT (POLYGON((0 0,2 0,2 2,0 2,0 0)))"] 2147483647 0 0
Warnings:
Warning 1264 Out of range value for column 'num_rows' at row 1
# == End of optimizer context
drop table t2;
# End of 13.1 tests
96 changes: 96 additions & 0 deletions mysql-test/main/opt_context_store_stats.test
Original file line number Diff line number Diff line change
Expand Up @@ -470,4 +470,100 @@ select * from t1 partition (p1) where a=10;

drop table t1;

--echo #
--echo # MDEV-40533: unprintable gis ranges in trace and context
--echo #
create table t1 (
id int,
g1 geometry not null,
g2 geometry,
key k_prefix (g1(5)),
key k_full (g1(200)),
key k_null (g2(200))
) engine=myisam;

insert into t1 select seq, point(seq, seq), point(seq, seq) from seq_1_to_5;
insert into t1 values (6, point(6,6), NULL);
analyze table t1;

--echo # The index holds the whole value: it is printed in the WKT format
explain
select id from t1 force index (k_full) where g1=point(2,2);
--source include/opt_context_list_tables_and_ranges.inc

--echo # multiple ranges
explain
select id from t1 force index (k_full)
where g1=point(3,3) or g1=linestring(point(1,1), point(2,2));
--source include/opt_context_list_tables_and_ranges.inc

--echo # NULL values and multiple ranges
explain
select id from t1 force index (k_null)
where g2=point(3,3) or g2 is null or g2=linestring(point(1,1), point(2,2));
--source include/opt_context_list_tables_and_ranges.inc

--echo # The index holds only a prefix of the value, so it cannot be converted
--echo # to WKT. It is printed as a binary string, like any other BLOB prefix.
explain
select id from t1 force index (k_prefix) where g1=point(2,2);
--source include/opt_context_list_tables_and_ranges.inc

drop table t1;

--echo #
--echo # A SPATIAL index stores the MBR of the value. It is printed as the
--echo # WKT of the MBR together with the spatial relation the range uses.
--echo #

create table t2 (
id int,
g geometry not null,
spatial key (g)
) engine=myisam;

insert into t2 select seq, point(seq, seq) from seq_1_to_20;
insert into t2 values
(21, geomfromtext('LINESTRING(0 0, 5 8)')),
(22, geomfromtext('POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))'));
analyze table t2;

--echo # mbrcontains(value, column)
explain
select id from t2 where mbrcontains(geomfromtext('POLYGON((0 0,0 3,3 3,3 0,0 0))'), g);
--source include/opt_context_list_tables_and_ranges.inc

--echo # mbrwithin(column, value)
explain
select id from t2 where mbrwithin(g, geomfromtext('LINESTRING(1 1, 9 12)'));
--source include/opt_context_list_tables_and_ranges.inc

--echo # The other spatial relations
explain
select id from t2 where mbrcontains(g, geomfromtext('POINT(2 2)'));
--source include/opt_context_list_tables_and_ranges.inc

explain
select id from t2 where mbrequals(g, geomfromtext('POINT(7 7)'));
--source include/opt_context_list_tables_and_ranges.inc

explain
select id from t2 where mbrintersects(g, geomfromtext('POLYGON((0 0,0 2,2 2,2 0,0 0))'));
--source include/opt_context_list_tables_and_ranges.inc

--echo # mbrtouches/mbroverlaps all use the mbrintersects relation
explain
select id from t2 where mbrtouches(g, geomfromtext('POLYGON((0 0,0 2,2 2,2 0,0 0))'));
--source include/opt_context_list_tables_and_ranges.inc

explain
select id from t2 where mbroverlaps(g, geomfromtext('POLYGON((0 0,0 2,2 2,2 0,0 0))'));
--source include/opt_context_list_tables_and_ranges.inc

explain
select id from t2 where mbrdisjoint(g, geomfromtext('POLYGON((0 0,0 2,2 2,2 0,0 0))'));
--source include/opt_context_list_tables_and_ranges.inc

drop table t2;

--echo # End of 13.1 tests
Loading
Loading