summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <ram@gw.mysql.r18.ru>2004-08-26 17:52:07 +0500
committerunknown <ram@gw.mysql.r18.ru>2004-08-26 17:52:07 +0500
commitfccc404a10beba353e9bc9ff4004318e16b01912 (patch)
tree2c90c0ecbc79f4d9255a5033c67b01fc36d4cdc5
parentad3e480c0f904d661876e35e9cbe02c6bcd787aa (diff)
parent11612dd3b428b24b5a47a257ae5f01b03e688e59 (diff)
downloadmariadb-git-fccc404a10beba353e9bc9ff4004318e16b01912.tar.gz
Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.1
into gw.mysql.r18.ru:/usr/home/ram/work/4.1.b5219
-rw-r--r--mysql-test/r/gis.result19
-rw-r--r--mysql-test/t/gis.test18
-rw-r--r--sql/opt_range.cc18
3 files changed, 50 insertions, 5 deletions
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index c2fd7855c85..9f5dd286cf9 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -466,3 +466,22 @@ insert IGNORE into t1 values ('Garbage');
ERROR HY000: Unknown error
alter table t1 add spatial index(a);
drop table t1;
+create table t1(a geometry not null, spatial index(a));
+insert into t1 values
+(GeomFromText('POINT(1 1)')), (GeomFromText('POINT(3 3)')),
+(GeomFromText('POINT(4 4)')), (GeomFromText('POINT(6 6)'));
+select AsText(a) from t1 where
+MBRContains(GeomFromText('Polygon((0 0, 0 2, 2 2, 2 0, 0 0))'), a)
+or
+MBRContains(GeomFromText('Polygon((2 2, 2 5, 5 5, 5 2, 2 2))'), a);
+AsText(a)
+POINT(1 1)
+POINT(3 3)
+POINT(4 4)
+select AsText(a) from t1 where
+MBRContains(GeomFromText('Polygon((0 0, 0 2, 2 2, 2 0, 0 0))'), a)
+and
+MBRContains(GeomFromText('Polygon((0 0, 0 7, 7 7, 7 0, 0 0))'), a);
+AsText(a)
+POINT(1 1)
+drop table t1;
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index 590007caba1..e35b9996a44 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -172,3 +172,21 @@ insert IGNORE into t1 values ('Garbage');
alter table t1 add spatial index(a);
drop table t1;
+
+#
+# Bug #5219: problem with range optimizer
+#
+
+create table t1(a geometry not null, spatial index(a));
+insert into t1 values
+(GeomFromText('POINT(1 1)')), (GeomFromText('POINT(3 3)')),
+(GeomFromText('POINT(4 4)')), (GeomFromText('POINT(6 6)'));
+select AsText(a) from t1 where
+ MBRContains(GeomFromText('Polygon((0 0, 0 2, 2 2, 2 0, 0 0))'), a)
+ or
+ MBRContains(GeomFromText('Polygon((2 2, 2 5, 5 5, 5 2, 2 2))'), a);
+select AsText(a) from t1 where
+ MBRContains(GeomFromText('Polygon((0 0, 0 2, 2 2, 2 0, 0 0))'), a)
+ and
+ MBRContains(GeomFromText('Polygon((0 0, 0 7, 7 7, 7 0, 0 0))'), a);
+drop table t1;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 40e3ffebe56..f11ed31950a 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1302,14 +1302,14 @@ tree_and(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2)
if (*key2 && !(*key2)->simple_key())
flag|=CLONE_KEY2_MAYBE;
*key1=key_and(*key1,*key2,flag);
- if ((*key1)->type == SEL_ARG::IMPOSSIBLE)
+ if (*key1 && (*key1)->type == SEL_ARG::IMPOSSIBLE)
{
tree1->type= SEL_TREE::IMPOSSIBLE;
- break;
- }
#ifdef EXTRA_DEBUG
- (*key1)->test_use_count(*key1);
+ (*key1)->test_use_count(*key1);
#endif
+ break;
+ }
}
}
DBUG_RETURN(tree1);
@@ -1456,6 +1456,13 @@ key_and(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag)
return key1;
}
+ if ((key1->min_flag | key2->min_flag) & GEOM_FLAG)
+ {
+ key1->free_tree();
+ key2->free_tree();
+ return 0; // Can't optimize this
+ }
+
key1->use_count--;
key2->use_count--;
SEL_ARG *e1=key1->first(), *e2=key2->first(), *new_tree=0;
@@ -1538,7 +1545,8 @@ key_or(SEL_ARG *key1,SEL_ARG *key2)
key1->use_count--;
key2->use_count--;
- if (key1->part != key2->part)
+ if (key1->part != key2->part ||
+ (key1->min_flag | key2->min_flag) & GEOM_FLAG)
{
key1->free_tree();
key2->free_tree();