[MDEV-2806] LP:611379 - Equivalent queries with Impossible where return different results Created: 2010-07-29 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: | Philip Stoev (Inactive) | Assignee: | Oleksandr Byelkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
The following two equivalent queries return different results in maria 5.2 and 5.3 (and identical results in mysql 5.5.5) : SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` ; SELECT * FROM ( SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` ); MariaDB returns 0 on the second query and NULL on the first, whereas MySQL returns NULL on both. In MariaDB, both EXPLAIN plans agree that "Impossible WHERE noticed after reading const tables" |
| Comments |
| Comment by Philip Stoev (Inactive) [ 2010-07-29 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Equivalent queries with Impossible where return different results CREATE TABLE `CC` ( SELECT SUM( DISTINCT table1 .`pk` ) FROM B table1 STRAIGHT_JOIN ( BB table2 JOIN CC ON table2 .`col_varchar_key` ) ON table2 .`pk` ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2010-08-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Equivalent queries with Impossible where return different results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2010-08-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Equivalent queries with Impossible where return different results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2010-08-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Equivalent queries with Impossible where return different results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2010-08-11 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Equivalent queries with Impossible where return different results | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2010-08-12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Equivalent queries with Impossible where return different results MariaDB [test]> create table t1 (a int not null); MariaDB [test]> insert into t1 values (1); MariaDB [test]> create table t2 (a int not null primary key); MariaDB [test]> insert into t2 values (10); MariaDB [test]> explain select sum(distinct t1.a) from t1,t2 where t1.a=t2.a;
---
--- MariaDB [test]> explain select * from (select sum(distinct t1.a) from t1,t2 where t1.a=t2.a) as t;
---
--- MariaDB [test]> select sum(distinct t1.a) from t1,t2 where t1.a=t2.a;
--------------------
-------------------- MariaDB [test]> select * from (select sum(distinct t1.a) from t1,t2 where t1.a=t2.a) as t;
--------------------
-------------------- Both queries must return
--------------------
-------------------- I've checked that absolutely the same problem we have with mysql-5.1.49 and with the current mysql-5.1 development tree. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Stewart Smith [ 2010-08-12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Equivalent queries with Impossible where return different results main.bug_lp611379 [ fail ] drizzletest: At line 9: query 'explain select * from (select sum(distinct t1.a) from t1,t2 where t1.a=t2.a) as t' failed: 1048: Column 'sum(distinct t1.a)' cannot be null but the fix gets us the correct query results, although with slightly different execution plans. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2010-08-12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Equivalent queries with Impossible where return different results MariaDB [test]> create table t3 (a int not null); MariaDB [test]> insert into t3 values (3), (1), (2); MariaDB [test]> select sum(distinct a) from t3 where a < 0;
-----------------
----------------- MariaDB [test]> select * from (select sum(distinct a) from t3 where a < 0) as t;
-----------------
----------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Rasmus Johansson (Inactive) [ 2010-09-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Launchpad bug id: 611379 |