mirror of
https://github.com/MariaDB/server.git
synced 2026-04-20 07:15:33 +02:00
Fixed LP bug #904345.
The MIN/MAX optimizer code from the function opt_sum_query erroneously did not take into account conjunctive conditions that did not depend on any table, yet were not identified as constant items. These could be items containing rand() or PS/SP parameters. These items are supposed to be evaluated at the execution phase. That's why if such conditions can be extracted from the WHERE condition the MIN/MAX optimization is not applied as currently it is always done at the optimization phase. (In 5.3 expensive subqueries are also evaluated only at the execution phase. So, if a constant condition with such subquery can be extracted from the WHERE clause the MIN/MAX optimization should not be applied in 5.3.) IF an IN/ALL/SOME predicate with a constant left part is transformed into an EXISTS subquery the resulting subquery should not be considered uncacheable if the right part of the predicate is not uncacheable. Backported the function dbug_print_item() from 5.3. The function is used only for debugging.
This commit is contained in:
parent
a22ab047e5
commit
c9259f166b
12 changed files with 123 additions and 35 deletions
|
|
@ -2778,10 +2778,10 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
1 SIMPLE t1 index key1 key1 5 NULL 4 Using where; Using index
|
||||
explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
1 SIMPLE t1 range key1 key1 5 NULL 3 Using where; Using index
|
||||
select max(key1) from t1 where key1 <= 0.6158;
|
||||
max(key1)
|
||||
0.615800023078918
|
||||
|
|
@ -2800,10 +2800,10 @@ max(key1) min(key2)
|
|||
0.615800023078918 1.37619996070862
|
||||
select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
|
||||
max(key1)
|
||||
0.615800023078918
|
||||
0.384499996900558
|
||||
select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
|
||||
min(key1)
|
||||
0.376199990510941
|
||||
0.384499996900558
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
|
||||
INSERT INTO t1 VALUES (10);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue