mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Fixed bug mdev-5635.
After constant row substitution some field items become constant items. The range analyzer should take into account this fact when looking for ranges.
This commit is contained in:
@@ -1538,3 +1538,14 @@ a
|
|||||||
3
|
3
|
||||||
4
|
4
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
|
#
|
||||||
|
# MDEV-5635: join of a const table with non-const tables
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a varchar(3) NOT NULL) ENGINE=MyISAM;
|
||||||
|
INSERT INTO t1 VALUES ('foo');
|
||||||
|
CREATE TABLE t2 (b varchar(3), c varchar(3), INDEX(b)) ENGINE=MyISAM;
|
||||||
|
INSERT INTO t2 VALUES ('bar', 'bar'),( 'qux', 'qux');
|
||||||
|
SELECT STRAIGHT_JOIN * FROM t1, t2 AS t2_1, t2 AS t2_2
|
||||||
|
WHERE t2_2.c = t2_1.c AND t2_2.b = t2_1.b AND ( a IS NULL OR t2_1.c = a );
|
||||||
|
a b c b c
|
||||||
|
DROP TABLE t1,t2;
|
||||||
|
@@ -1185,3 +1185,18 @@ SELECT t1.a FROM t1 NATURAL STRAIGHT_JOIN t2 ORDER BY t1.a;
|
|||||||
SELECT t1.a FROM t1 NATURAL STRAIGHT_JOIN t2 ORDER BY t1.a;
|
SELECT t1.a FROM t1 NATURAL STRAIGHT_JOIN t2 ORDER BY t1.a;
|
||||||
|
|
||||||
DROP TABLE t1,t2;
|
DROP TABLE t1,t2;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-5635: join of a const table with non-const tables
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a varchar(3) NOT NULL) ENGINE=MyISAM;
|
||||||
|
INSERT INTO t1 VALUES ('foo');
|
||||||
|
|
||||||
|
CREATE TABLE t2 (b varchar(3), c varchar(3), INDEX(b)) ENGINE=MyISAM;
|
||||||
|
INSERT INTO t2 VALUES ('bar', 'bar'),( 'qux', 'qux');
|
||||||
|
|
||||||
|
SELECT STRAIGHT_JOIN * FROM t1, t2 AS t2_1, t2 AS t2_2
|
||||||
|
WHERE t2_2.c = t2_1.c AND t2_2.b = t2_1.b AND ( a IS NULL OR t2_1.c = a );
|
||||||
|
|
||||||
|
DROP TABLE t1,t2;
|
||||||
|
@@ -7941,6 +7941,7 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param,COND *cond)
|
|||||||
value= cond_func->arg_count > 1 ? cond_func->arguments()[1] : NULL;
|
value= cond_func->arg_count > 1 ? cond_func->arguments()[1] : NULL;
|
||||||
if (value && value->is_expensive())
|
if (value && value->is_expensive())
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
if (!cond_func->arguments()[0]->real_item()->const_item())
|
||||||
ftree= get_full_func_mm_tree(param, cond_func, field_item, value, inv);
|
ftree= get_full_func_mm_tree(param, cond_func, field_item, value, inv);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -7966,6 +7967,7 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param,COND *cond)
|
|||||||
value= cond_func->arguments()[0];
|
value= cond_func->arguments()[0];
|
||||||
if (value && value->is_expensive())
|
if (value && value->is_expensive())
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
|
if (!cond_func->arguments()[1]->real_item()->const_item())
|
||||||
ftree= get_full_func_mm_tree(param, cond_func, field_item, value, inv);
|
ftree= get_full_func_mm_tree(param, cond_func, field_item, value, inv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user