[MDEV-2650] LP:904345 - Wrong empty result instead of NULL for MAX/MIN with derived_merge=ON or with a view Created: 2011-12-14 Updated: 2015-02-02 Resolved: 2012-10-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
The following query SELECT MAX(a) returns an empty set if it is executed with derived_merge=ON (current default), and NULL otherwise. bzr version-info Also reproducible on revno 3250. EXPLAIN with derived_merge=ON (wrong result): 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Select tables optimized away select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` where <in_optimizer>((1,2),<exists>(select 3,4 having (((1 = 3) or isnull(3)) and ((2 = 4) or isnull(4)) and <is_not_null_test>(3) and <is_not_null_test>(4)))) EXPLAIN with derived_merge=OFF (correct result): 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00 select max(`alias`.`a`) AS `MAX(a)` from (select `test`.`t1`.`a` AS `a` from `test`.`t1`) `alias` where <expr_cache><1,2>(<in_optimizer>((1,2),<exists>(select 3,4 having (((1 = 3) or isnull(3)) and ((2 = 4) or isnull(4)) and <is_not_null_test>(3) and <is_not_null_test>(4))))) Minimal optimizer_switch: derived_merge=ON (by default) Full optimizer_switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on Test case: SET optimizer_switch='derived_merge=on'; CREATE TABLE t1 ( a int(11) NOT NULL, KEY(a) ); SELECT MAX(a) |
| Comments |
| Comment by Elena Stepanova [ 2011-12-14 ] |
|
Re: Wrong empty result instead of NULL for MAX/MIN with derived_merge=ON CREATE TABLE t1 ( a int(11) NOT NULL, KEY(a) ); SELECT MAX(a) FROM v WHERE (1,2) IN ( SELECT 3,4 ); Reproducible on 5.2.10 and 5.1.60, and on MySQL 5.1.60. |
| Comment by Elena Stepanova [ 2011-12-14 ] |
|
Re: Wrong empty result instead of NULL for MAX/MIN with derived_merge=ON or with a view EXPLAIN EXTENDED SELECT MAX(a) FROM v WHERE (1,2) IN ( SELECT 3,4 ); select max(`test`.`t1`.`a`) AS `MAX(a)` from `test`.`t1` where <in_optimizer>((1,2),<exists>(select 3,4 having (((1 = 3) or isnull(3)) and ((2 = 4) or isnull(4)) and <is_not_null_test>(3) and <is_not_null_test>(4)))) |
| Comment by Oleksandr Byelkin [ 2011-12-15 ] |
|
Re: Wrong empty result instead of NULL for MAX/MIN with derived_merge=ON or with a view CREATE TABLE t1 ( a int(11) NOT NULL, KEY(a) ); SELECT MAX(a) FROM v WHERE rand()*0; drop view v; It returns empty line instead of NULL also. |
| Comment by Oleksandr Byelkin [ 2011-12-15 ] |
|
Re: Wrong empty result instead of NULL for MAX/MIN with derived_merge=ON or with a view CREATE TABLE t1 ( a int(11) NOT NULL, KEY(a) ); SELECT MAX(a) FROM t1 WHERE rand()*0; drop table t1; Produce following: |
| Comment by Oleksandr Byelkin [ 2011-12-15 ] |
|
Re: Wrong empty result instead of NULL for MAX/MIN with derived_merge=ON or with a view |
| Comment by Oleksandr Byelkin [ 2011-12-15 ] |
|
Re: Wrong empty result instead of NULL for MAX/MIN with derived_merge=ON or with a view if (!tables_list && (tables || !select_lex->with_sum_func)) |
| Comment by Oleksandr Byelkin [ 2011-12-15 ] |
|
Re: Wrong empty result instead of NULL for MAX/MIN with derived_merge=ON or with a view |
| Comment by Igor Babaev [ 2011-12-27 ] |
|
Re: Wrong empty result instead of NULL for MAX/MIN with derived_merge=ON or with a view |
| Comment by Rasmus Johansson (Inactive) [ 2012-02-14 ] |
|
Launchpad bug id: 904345 |