[MDEV-11062] Different result for time type with optimizer_use_condition_selectivity=4 Created: 2016-10-14  Updated: 2018-07-10  Resolved: 2018-07-10

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.1.18, 10.1, 10.2
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Nirbhay Choubey (Inactive) Assignee: Vicențiu Ciorbaru
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-15321 different results when using value of... Closed
Relates
relates to MDEV-7635 update defaults and simplify mysqld c... Closed
Sprint: 10.2.4-1, 10.1.22

 Description   

Test case

--disable_warnings
drop table if exists t1;
--enable_warnings
 
SET timestamp=DEFAULT;
 
SET @@old_mode=zero_date_time_cast;
--echo # TIMESTAMP literal, old mode
CREATE TABLE t1 (a TIME);
INSERT INTO t1 VALUES ('0000-00-00 10:20:30'),('0000-00-00 10:20:31');
INSERT INTO t1 VALUES ('0000-00-01 10:20:30'),('0000-00-01 10:20:31');
INSERT INTO t1 VALUES ('31 10:20:30'),('32 10:20:30'),('33 10:20:30'),('34 10:20:30');
SELECT * FROM t1;
 
--echo # Old mode, TIMESTAMP-alike literal, zon-zero YYYYMMDD, no propagation
SELECT * FROM t1 WHERE a='0000-00-01 10:20:30';
SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8;
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8;
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=30+RAND();
 
DROP TABLE t1;

With : @@optimizer_use_condition_selectivity=1

SELECT * FROM t1 WHERE a='0000-00-01 10:20:30';
a
34:20:30
SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8;
a
34:20:30

With : @@optimizer_use_condition_selectivity=4

SELECT * FROM t1 WHERE a='0000-00-01 10:20:30';
a
SELECT * FROM t1 WHERE a='0000-00-01 10:20:30' AND LENGTH(a)=8;
a



 Comments   
Comment by Elena Stepanova [ 2016-10-16 ]

Looks similar to MDEV-9628 – not sure it's the same though (probably not, since this one seems to affect only 10.1+, while MDEV-9628 also affects 10.0).

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