From e27e56078388c2005b46073b5b295edcba79f359 Mon Sep 17 00:00:00 2001 From: Evgeny Potemkin Date: Mon, 27 Oct 2008 12:26:32 +0300 Subject: Bug#37870: Usage of uninitialized value caused failed assertion. The convert_constant_item function converts a constant to integer using field for condition like 'field = a_constant'. When the convert_constant_item is called for a subquery the outer select is already being executed, so convert_constant_item saves field's value to prevent its corruption. For EXPLAIN field's value isn't initialized thus when convert_constant_item tries to restore saved value it fails assertion. Now the convert_constant_item doesn't save/restore field's value for EXPLAIN. mysql-test/r/explain.result: Added a test case for the bug#37870. mysql-test/t/explain.test: Added a test case for the bug#37870. sql/item_cmpfunc.cc: Bug#37870: Usage of uninitialized value caused failed assertion. Now the convert_constant_item doesn't save/restore field's value for EXPLAIN. --- mysql-test/r/explain.result | 15 +++++++++++++++ mysql-test/t/explain.test | 12 ++++++++++++ 2 files changed, 27 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index 2ce8b8c384f..f3822fe370d 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -107,3 +107,18 @@ X X X X X X X X X X X X X X X X X X Range checked for each record (index map: 0xFFFFFFFFFF) DROP TABLE t2; DROP TABLE t1; +# +# Bug#37870: Usage of uninitialized value caused failed assertion. +# +create table t1 (dt datetime not null); +create table t2 (dt datetime not null); +insert into t1 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1'); +insert into t2 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1'); +flush tables; +EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY OUTR ALL NULL NULL NULL NULL 2 Using where +2 DEPENDENT SUBQUERY INNR ALL NULL NULL NULL NULL 2 Using where +SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); +dt +drop tables t1, t2; diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index c9ae8aceaf6..09a8245b27b 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -94,4 +94,16 @@ EXPLAIN SELECT 1 FROM DROP TABLE t2; DROP TABLE t1; +--echo # +--echo # Bug#37870: Usage of uninitialized value caused failed assertion. +--echo # +create table t1 (dt datetime not null); +create table t2 (dt datetime not null); +insert into t1 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1'); +insert into t2 values ('2001-01-01 1:1:1'), ('2001-01-01 1:1:1'); +flush tables; +EXPLAIN SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); +SELECT OUTR.dt FROM t1 AS OUTR WHERE OUTR.dt IN (SELECT INNR.dt FROM t2 AS INNR WHERE OUTR.dt IS NULL ); +drop tables t1, t2; + # End of 5.0 tests. -- cgit v1.2.1