[MDEV-3113] LP:777691 - Wrong result with subqery in select list and subquery cache=off in maria-5.3 Created: 2011-05-05 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: | Timour Katchaounov (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
Not repeatable in maria-5.2 Repeatable in maria-5.3, maria-5.3-mwl89. The SUM part of following query: SELECT t1.f1, ( SELECT SUM( f10 ) FROM t3 WHERE f10 > t1.f10 ) FROM t1 JOIN t2 ON t2.f2 > 0; returns 2 different results for 2 rows where t1.f1 is the same, hence the SUM should also be the same. Subquery cache appears to mask the bug by caching the first value and returning it twice. Test case: DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t2; DROP TABLE IF EXISTS t3; SET SESSION optimizer_switch='subquery_cache=off'; In maria-5.2: f10 ( SELECT SUM( f10 ) FROM t3 WHERE f10 > t1.f10 ) in maria-5.3: f10 ( SELECT SUM( f10 ) FROM t3 WHERE f10 > t1.f10 ) Explain in maria-5.3: id select_type table type possible_keys key key_len ref rows Extra |
| Comments |
| Comment by Philip Stoev (Inactive) [ 2011-06-05 ] |
|
Re: Wrong result with subqery in select list and subquery cache=off in maria-5.3 SET @@optimizer_switch='materialization=off,subquery_cache=off,semijoin=off'; CREATE TABLE t1 ( f11 varchar(32)) ; CREATE TABLE t2 ( f2 int, f10 varchar(32)) ; SELECT ( SELECT MAX( f2 ) FROM t2 WHERE t2.f10 <> t1.f11 ) FROM t1; |
| Comment by Philip Stoev (Inactive) [ 2011-07-08 ] |
|
Re: Wrong result with subqery in select list and subquery cache=off in maria-5.3 DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t3; SELECT ( |
| Comment by Timour Katchaounov (Inactive) [ 2011-07-11 ] |
|
Re: Wrong result with subqery in select list and subquery cache=off in maria-5.3 SET @@optimizer_switch='materialization=off,subquery_cache=off'; CREATE TABLE t1 ( f11 varchar(32)) ; CREATE TABLE t2 ( f2 int, f10 varchar(32)) ; SELECT t1.f11, ( SELECT MAX( f2 ) FROM t2 WHERE t2.f10 = t1.f11 ) FROM t1; |
| Comment by Timour Katchaounov (Inactive) [ 2011-07-11 ] |
|
Re: Wrong result with subqery in select list and subquery cache=off in maria-5.3 The cause of the wrong result is that after the subquery execution The problem lines above were added by the fix for bug lp:613029. |
| Comment by Timour Katchaounov (Inactive) [ 2011-07-12 ] |
|
Re: Wrong result with subqery in select list and subquery cache=off in maria-5.3 CREATE TABLE t1 ( f1 varchar(32)) ; CREATE TABLE t2 ( f2 int, f3 varchar(32)) ; SET @@optimizer_switch='materialization=off,in_to_exists=on,subquery_cache=off'; EXPLAIN SELECT t1.f1, ( SELECT MAX( f2 ) FROM t2 WHERE t2.f3 = t1.f1 ) as max_f2 FROM t1; INSERT INTO t2 VALUES (2,'y'); drop table t1, t2; |
| Comment by Rasmus Johansson (Inactive) [ 2011-12-13 ] |
|
Launchpad bug id: 777691 |