Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
60985e53
Commit
60985e53
authored
Aug 13, 2015
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-8610 "WHERE CONTAINS(indexed_geometry_column,1)" causes full table scan
parent
9d884fd3
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
729 additions
and
664 deletions
+729
-664
mysql-test/r/gis-rtree.result
mysql-test/r/gis-rtree.result
+24
-0
mysql-test/t/gis-rtree.test
mysql-test/t/gis-rtree.test
+14
-0
sql/item_geofunc.cc
sql/item_geofunc.cc
+73
-0
sql/item_geofunc.h
sql/item_geofunc.h
+3
-0
sql/opt_range.cc
sql/opt_range.cc
+5
-663
sql/opt_range.h
sql/opt_range.h
+610
-1
No files found.
mysql-test/r/gis-rtree.result
View file @
60985e53
...
...
@@ -1618,5 +1618,29 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 34 NULL 1 Using where
DROP TABLE t1;
#
# MDEV-8610 "WHERE CONTAINS(indexed_geometry_column,1)" causes full table scan
#
CREATE TABLE t1 (a GEOMETRY NOT NULL, SPATIAL KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES (Point(1,1)),(Point(2,2)),(Point(3,3));
EXPLAIN SELECT * FROM t1 WHERE CONTAINS(a,1);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE CONTAINS(a,1.0);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE CONTAINS(a,1e0);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE CONTAINS(a,TIME'00:00:00');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE CONTAINS(a,DATE'2001-01-01');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
EXPLAIN SELECT * FROM t1 WHERE CONTAINS(a,TIMESTAMP'2001-01-01 00:00:00');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
DROP TABLE t1;
#
# End of 10.1 tests
#
mysql-test/t/gis-rtree.test
View file @
60985e53
...
...
@@ -993,6 +993,20 @@ EXPLAIN SELECT * FROM t1 WHERE MBRINTERSECTS(Point(1,2),a);
EXPLAIN
SELECT
*
FROM
t1
WHERE
ST_INTERSECTS
(
Point
(
1
,
2
),
a
);
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-8610 "WHERE CONTAINS(indexed_geometry_column,1)" causes full table scan
--
echo
#
CREATE
TABLE
t1
(
a
GEOMETRY
NOT
NULL
,
SPATIAL
KEY
(
a
))
ENGINE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
Point
(
1
,
1
)),(
Point
(
2
,
2
)),(
Point
(
3
,
3
));
EXPLAIN
SELECT
*
FROM
t1
WHERE
CONTAINS
(
a
,
1
);
EXPLAIN
SELECT
*
FROM
t1
WHERE
CONTAINS
(
a
,
1.0
);
EXPLAIN
SELECT
*
FROM
t1
WHERE
CONTAINS
(
a
,
1
e0
);
EXPLAIN
SELECT
*
FROM
t1
WHERE
CONTAINS
(
a
,
TIME
'00:00:00'
);
EXPLAIN
SELECT
*
FROM
t1
WHERE
CONTAINS
(
a
,
DATE
'2001-01-01'
);
EXPLAIN
SELECT
*
FROM
t1
WHERE
CONTAINS
(
a
,
TIMESTAMP
'2001-01-01 00:00:00'
);
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of 10.1 tests
--
echo
#
sql/item_geofunc.cc
View file @
60985e53
...
...
@@ -38,6 +38,7 @@
#include "set_var.h"
#ifdef HAVE_SPATIAL
#include <m_ctype.h>
#include "opt_range.h"
Field
*
Item_geometry_func
::
tmp_table_field
(
TABLE
*
t_arg
)
...
...
@@ -929,6 +930,78 @@ err:
Functions for spatial relations
*/
static
SEL_ARG
sel_arg_impossible
(
SEL_ARG
::
IMPOSSIBLE
);
SEL_ARG
*
Item_func_spatial_rel
::
get_mm_leaf
(
RANGE_OPT_PARAM
*
param
,
Field
*
field
,
KEY_PART
*
key_part
,
Item_func
::
Functype
type
,
Item
*
value
)
{
DBUG_ENTER
(
"Item_func_spatial_rel::get_mm_leaf"
);
if
(
key_part
->
image_type
!=
Field
::
itMBR
)
DBUG_RETURN
(
0
);
if
(
value
->
cmp_type
()
!=
STRING_RESULT
)
DBUG_RETURN
(
&
sel_arg_impossible
);
if
(
param
->
using_real_indexes
&&
!
field
->
optimize_range
(
param
->
real_keynr
[
key_part
->
key
],
key_part
->
part
))
DBUG_RETURN
(
0
);
if
(
value
->
save_in_field_no_warnings
(
field
,
1
))
DBUG_RETURN
(
&
sel_arg_impossible
);
// Bad GEOMETRY value
DBUG_ASSERT
(
!
field
->
real_maybe_null
());
// SPATIAL keys do not support NULL
uchar
*
str
=
(
uchar
*
)
alloc_root
(
param
->
mem_root
,
key_part
->
store_length
+
1
);
if
(
!
str
)
DBUG_RETURN
(
0
);
// out of memory
field
->
get_key_image
(
str
,
key_part
->
length
,
key_part
->
image_type
);
SEL_ARG
*
tree
;
if
(
!
(
tree
=
new
(
param
->
mem_root
)
SEL_ARG
(
field
,
str
,
str
)))
DBUG_RETURN
(
0
);
// out of memory
switch
(
type
)
{
case
SP_EQUALS_FUNC
:
tree
->
min_flag
=
GEOM_FLAG
|
HA_READ_MBR_EQUAL
;
// NEAR_MIN;//512;
tree
->
max_flag
=
NO_MAX_RANGE
;
break
;
case
SP_DISJOINT_FUNC
:
tree
->
min_flag
=
GEOM_FLAG
|
HA_READ_MBR_DISJOINT
;
// NEAR_MIN;//512;
tree
->
max_flag
=
NO_MAX_RANGE
;
break
;
case
SP_INTERSECTS_FUNC
:
tree
->
min_flag
=
GEOM_FLAG
|
HA_READ_MBR_INTERSECT
;
// NEAR_MIN;//512;
tree
->
max_flag
=
NO_MAX_RANGE
;
break
;
case
SP_TOUCHES_FUNC
:
tree
->
min_flag
=
GEOM_FLAG
|
HA_READ_MBR_INTERSECT
;
// NEAR_MIN;//512;
tree
->
max_flag
=
NO_MAX_RANGE
;
break
;
case
SP_CROSSES_FUNC
:
tree
->
min_flag
=
GEOM_FLAG
|
HA_READ_MBR_INTERSECT
;
// NEAR_MIN;//512;
tree
->
max_flag
=
NO_MAX_RANGE
;
break
;
case
SP_WITHIN_FUNC
:
tree
->
min_flag
=
GEOM_FLAG
|
HA_READ_MBR_WITHIN
;
// NEAR_MIN;//512;
tree
->
max_flag
=
NO_MAX_RANGE
;
break
;
case
SP_CONTAINS_FUNC
:
tree
->
min_flag
=
GEOM_FLAG
|
HA_READ_MBR_CONTAIN
;
// NEAR_MIN;//512;
tree
->
max_flag
=
NO_MAX_RANGE
;
break
;
case
SP_OVERLAPS_FUNC
:
tree
->
min_flag
=
GEOM_FLAG
|
HA_READ_MBR_INTERSECT
;
// NEAR_MIN;//512;
tree
->
max_flag
=
NO_MAX_RANGE
;
break
;
default:
DBUG_ASSERT
(
0
);
break
;
}
DBUG_RETURN
(
tree
);
}
const
char
*
Item_func_spatial_mbr_rel
::
func_name
()
const
{
switch
(
spatial_rel
)
{
...
...
sql/item_geofunc.h
View file @
60985e53
...
...
@@ -277,6 +277,9 @@ class Item_func_spatial_rel: public Item_bool_func2
protected:
enum
Functype
spatial_rel
;
String
tmp_value1
,
tmp_value2
;
SEL_ARG
*
get_mm_leaf
(
RANGE_OPT_PARAM
*
param
,
Field
*
field
,
KEY_PART
*
key_part
,
Item_func
::
Functype
type
,
Item
*
value
);
public:
Item_func_spatial_rel
(
Item
*
a
,
Item
*
b
,
enum
Functype
sp_rel
)
:
Item_bool_func2
(
a
,
b
),
spatial_rel
(
sp_rel
)
...
...
sql/opt_range.cc
View file @
60985e53
This diff is collapsed.
Click to expand it.
sql/opt_range.h
View file @
60985e53
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment