[MDEV-3075] LP:825051 - Wrong result with date/datetime and subquery with GROUP BY and in_to_exists Created: 2011-08-12  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: Minor
Reporter: Philip Stoev (Inactive) Assignee: Timour Katchaounov (Inactive)
Resolution: Fixed Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug825051.xml    

 Description   

The following query:

SELECT * FROM t1 WHERE a IN ( SELECT a AS field1 FROM t1 GROUP BY field1 );

does not return rows that match the IN predicate (that is, all rows in the table). Same query without GROUP BY returns a correct result.

explain:

id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 4 NULL 2 Using where; Using index
2 DEPENDENT SUBQUERY t1 index NULL a 4 NULL 1 Using index

minimal optimizer switch: materialization=off,in_to_exists=on

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=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,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

bzr version-info
revision-id: <email address hidden>
date: 2011-08-11 22:34:41 -0700
build-date: 2011-08-12 11:29:02 +0300
revno: 3151
branch-nick: maria-5.3

test case:

CREATE TABLE t1 (a date, KEY (a)) ;
INSERT INTO t1 VALUES ('2009-01-01'),('2009-02-02');

SET SESSION optimizer_switch='materialization=off,in_to_exists=on';

SELECT * FROM t1 WHERE a IN ( SELECT a AS field1 FROM t1 GROUP BY field1 );

Reproducible in maria-5.3. Not reproducible in maria-5.2, mysql-5.5 . Not reproducible with integers. Does not involve NULLSs or constant optimizations.



 Comments   
Comment by Rasmus Johansson (Inactive) [ 2011-11-30 ]

Launchpad bug id: 825051

Generated at Thu Feb 08 06:46:09 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.