Commit 41894be0 authored by MySQL Build Team's avatar MySQL Build Team

Backport into build-201002030816-5.0.87sp1

> ------------------------------------------------------------
> revno: 2818.1.4
> revision-id: ramil@mysql.com-20091021090408-208mvwwrcroi2j8c
> parent: azundris@mysql.com-20091021033856-ydodp4q42o58e7ka
> committer: Ramil Kalimullin <ramil@mysql.com>
> branch nick: b47019-5.0-bugteam
> timestamp: Wed 2009-10-21 14:04:08 +0500
> message:
>   Fix for bug#47019: Assertion failed: 0, file .\rt_mbr.c, 
>   line 138 when forcing a spatial index
>   
>   Problem: "Spatial indexes can be involved in the search 
>   for queries that use a function such as MBRContains() 
>   or MBRWithin() in the WHERE clause".
>   Using spatial indexes for JOINs with =, <=> etc.
>   predicates is incorrect.
>   
>   Fix: disable spatial indexes for such queries.
parent 65c50b05
...@@ -4401,4 +4401,33 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -4401,4 +4401,33 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings: Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2 Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2
DROP TABLE t1; DROP TABLE t1;
#
# Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when
# forcing a spatial index
#
CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a));
INSERT INTO t1 VALUES
(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')),
(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'));
EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 ALL a NULL NULL NULL 2
SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
1
1
1
1
1
EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 ALL a NULL NULL NULL 2
SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);
1
1
1
1
1
DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
...@@ -3750,5 +3750,21 @@ EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2; ...@@ -3750,5 +3750,21 @@ EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2;
EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2; EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug#47019: Assertion failed: 0, file .\rt_mbr.c, line 138 when
--echo # forcing a spatial index
--echo #
CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a));
INSERT INTO t1 VALUES
(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')),
(GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'));
EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2;
EXPLAIN SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);
SELECT 1 FROM t1 NATURAL LEFT JOIN t1 AS t2 FORCE INDEX(a);
DROP TABLE t1;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -3447,7 +3447,7 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field) ...@@ -3447,7 +3447,7 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field)
{ {
if (!(form->keys_in_use_for_query.is_set(key))) if (!(form->keys_in_use_for_query.is_set(key)))
continue; continue;
if (form->key_info[key].flags & HA_FULLTEXT) if (form->key_info[key].flags & (HA_FULLTEXT | HA_SPATIAL))
continue; // ToDo: ft-keys in non-ft queries. SerG continue; // ToDo: ft-keys in non-ft queries. SerG
uint key_parts= (uint) form->key_info[key].key_parts; uint key_parts= (uint) form->key_info[key].key_parts;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment