Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2016 05/06/28 07:27:00 igor@stripped +3 -0
range.result, range.test:
Added a test case for bug #10031.
opt_range.cc:
Fixed bug #10031: range condition was not used with
views. Range analyzer did not take into account that
view columns were always referred through Item_ref.
mysql-test/r/range.result
1.38 05/06/28 07:24:19 igor@stripped +24 -0
Added a test case for bug #10031.
mysql-test/t/range.test
1.30 05/06/28 07:23:43 igor@stripped +23 -0
Added a test case for bug #10031.
sql/opt_range.cc
1.176 05/06/28 07:18:36 igor@stripped +6 -5
Fixed bug #10031: range condition was not used with
views. Range analyzer did not take into account that
view columns were always referred through Item_ref.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: igor
# Host: rurik.mysql.com
# Root: /home/igor/dev/mysql-5.0-0
--- 1.175/sql/opt_range.cc Thu Jun 23 07:23:41 2005
+++ 1.176/sql/opt_range.cc Tue Jun 28 07:18:36 2005
@@ -3581,15 +3581,16 @@
DBUG_RETURN(ftree);
}
default:
- if (cond_func->arguments()[0]->type() == Item::FIELD_ITEM)
+ if (cond_func->arguments()[0]->real_item()->type() == Item::FIELD_ITEM)
{
- field_item= (Item_field*) (cond_func->arguments()[0]);
+ field_item= (Item_field*) (cond_func->arguments()[0]->real_item());
value= cond_func->arg_count > 1 ? cond_func->arguments()[1] : 0;
}
else if (cond_func->have_rev_func() &&
- cond_func->arguments()[1]->type() == Item::FIELD_ITEM)
+ cond_func->arguments()[1]->real_item()->type() ==
+ Item::FIELD_ITEM)
{
- field_item= (Item_field*) (cond_func->arguments()[1]);
+ field_item= (Item_field*) (cond_func->arguments()[1]->real_item());
value= cond_func->arguments()[0];
}
else
@@ -3610,7 +3611,7 @@
for (uint i= 0; i < cond_func->arg_count; i++)
{
- Item *arg= cond_func->arguments()[i];
+ Item *arg= cond_func->arguments()[i]->real_item();
if (arg != field_item)
ref_tables|= arg->used_tables();
}
--- 1.37/mysql-test/r/range.result Thu Jun 23 23:56:51 2005
+++ 1.38/mysql-test/r/range.result Tue Jun 28 07:24:19 2005
@@ -720,3 +720,27 @@
59 C
60 C
DROP TABLE t1;
+CREATE TABLE t1 (a int, b int, primary key(a,b));
+INSERT INTO t1 VALUES
+(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3);
+CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3;
+EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+EXPLAIN SELECT a,b FROM t1 WHERE a < 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+EXPLAIN SELECT a,b FROM v1 WHERE a < 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+SELECT a,b FROM t1 WHERE a < 2 and b=3;
+a b
+1 3
+SELECT a,b FROM v1 WHERE a < 2 and b=3;
+a b
+1 3
+DROP VIEW v1;
+DROP TABLE t1;
--- 1.29/mysql-test/t/range.test Thu Jun 23 02:08:50 2005
+++ 1.30/mysql-test/t/range.test Tue Jun 28 07:23:43 2005
@@ -530,3 +530,26 @@
SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
DROP TABLE t1;
+
+#
+# Test for bug #10031: range to be used over a view
+#
+
+CREATE TABLE t1 (a int, b int, primary key(a,b));
+
+INSERT INTO t1 VALUES
+ (1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3);
+
+CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3;
+
+EXPLAIN SELECT a,b FROM t1 WHERE a < 2 and b=3;
+EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3;
+
+EXPLAIN SELECT a,b FROM t1 WHERE a < 2;
+EXPLAIN SELECT a,b FROM v1 WHERE a < 2;
+
+SELECT a,b FROM t1 WHERE a < 2 and b=3;
+SELECT a,b FROM v1 WHERE a < 2 and b=3;
+
+DROP VIEW v1;
+DROP TABLE t1;
| Thread |
|---|
| • bk commit into 5.0 tree (igor:1.2016) BUG#10031 | igor | 28 Jun |