[MDEV-5204] Wrong result (missing row) with use_stat_tables, stale statistics, STRAIGHT_JOIN Created: 2013-10-29  Updated: 2013-11-28  Resolved: 2013-11-28

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.4
Fix Version/s: 10.0.7

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-3806 Engine independent statistics Closed

 Description   

In the following test case the first query produces an empty result set, and the second query returns a row. 1 row is the correct result.

SET use_stat_tables = 'PREFERABLY';
 
CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
ANALYZE TABLE t1;
 
CREATE TABLE t2 (name CHAR(3)) ENGINE=MyISAM;
ANALYZE TABLE t2;
INSERT INTO t2 VALUES ('USA'),('AUS');
 
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
 
ANALYZE TABLE t2;
 
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;

Results:

INSERT INTO t2 VALUES ('USA'),('AUS');
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
id	name
ANALYZE TABLE t2;
Table	Op	Msg_type	Msg_text
test.t2	analyze	status	OK
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE name IN ( 'AUS','YEM' ) AND id = 1;
id	name
1	AUS

revision-id: sergii@pisem.net-20131028064617-ferc2dktspd2rylj
revno: 3907
branch-nick: 10.0-base

First EXPLAIN:

id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
Warnings:
Note	1003	select 1 AS `id`,'USA' AS `name` from `test`.`t1` straight_join `test`.`t2` where (('USA' in ('AUS','YEM')))

Second EXPLAIN:

id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	const	PRIMARY	PRIMARY	4	const	1	100.00	Using index
1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
Warnings:
Note	1003	select 1 AS `id`,`test`.`t2`.`name` AS `name` from `test`.`t1` straight_join `test`.`t2` where ((`test`.`t2`.`name` in ('AUS','YEM')))



 Comments   
Comment by Igor Babaev [ 2013-11-28 ]

The fix for this bug was pushed into 10.0-base.

Generated at Thu Feb 08 07:02:29 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.