diff options
-rw-r--r-- | mysql-test/r/func_misc.result | 33 | ||||
-rw-r--r-- | mysql-test/t/func_misc.test | 19 | ||||
-rw-r--r-- | sql/item_func.h | 4 |
3 files changed, 54 insertions, 2 deletions
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 514994ed27c..55b0f9d3c57 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -305,6 +305,39 @@ SELECT 1 from t1 HAVING NAME_CONST('', a); ERROR HY000: Incorrect arguments to NAME_CONST DROP TABLE t1; # +# Test or correct maybe_null of last_value +# +CREATE TABLE t1 (a char(2) not null ); +INSERT INTO t1 VALUES (4),(7),(1); +set @optimizer_switch_save= @@optimizer_switch; +set optimizer_switch='materialization=off'; +CREATE TABLE tv (e char(2) not null ) engine=mysql; +Warnings: +Warning 1286 Unknown storage engine 'mysql' +Warning 1266 Using storage engine MyISAM for table 'tv' +INSERT INTO tv VALUES (1); +CREATE ALGORITHM=MERGE VIEW v_merge AS SELECT * FROM tv; +CREATE ALGORITHM=MERGE VIEW vm AS SELECT * FROM tv; +explain extended +select a from t1 left join v_merge on (a=e) where last_value(NULL,e) not in (select last_value(NULL,e) from vm); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 +1 PRIMARY tv ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY tv system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`tv`) on((`test`.`tv`.`e` = `test`.`t1`.`a`)) where (not(<expr_cache><last_value(NULL,`test`.`tv`.`e`)>(<in_optimizer>(last_value(NULL,`test`.`tv`.`e`),<exists>(select last_value(NULL,'1') from dual where trigcond((<cache>(last_value(NULL,`test`.`tv`.`e`)) = last_value(NULL,'1')))))))) +explain extended +select a from t1 left join v_merge on (a=e) where e not in (select last_value(NULL,e) from vm); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 +1 PRIMARY tv ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY tv system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`tv`) on((`test`.`tv`.`e` = `test`.`t1`.`a`)) where (not(<expr_cache><`test`.`tv`.`e`>(<in_optimizer>(`test`.`tv`.`e`,<exists>(select last_value(NULL,'1') from dual where trigcond((<cache>(`test`.`tv`.`e`) = last_value(NULL,'1')))))))) +set optimizer_switch=@optimizer_switch_save; +drop view v_merge, vm; +drop table t1,tv; +# # End of 5.5 tests # # diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 1f221ce9878..292db69a6e3 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -348,6 +348,25 @@ SELECT 1 from t1 HAVING NAME_CONST('', a); DROP TABLE t1; +--echo # +--echo # Test or correct maybe_null of last_value +--echo # +CREATE TABLE t1 (a char(2) not null ); +INSERT INTO t1 VALUES (4),(7),(1); +set @optimizer_switch_save= @@optimizer_switch; +set optimizer_switch='materialization=off'; +CREATE TABLE tv (e char(2) not null ) engine=mysql; +INSERT INTO tv VALUES (1); +CREATE ALGORITHM=MERGE VIEW v_merge AS SELECT * FROM tv; +CREATE ALGORITHM=MERGE VIEW vm AS SELECT * FROM tv; +explain extended +select a from t1 left join v_merge on (a=e) where last_value(NULL,e) not in (select last_value(NULL,e) from vm); +explain extended +select a from t1 left join v_merge on (a=e) where e not in (select last_value(NULL,e) from vm); +set optimizer_switch=@optimizer_switch_save; +drop view v_merge, vm; +drop table t1,tv; + --echo # --echo # End of 5.5 tests diff --git a/sql/item_func.h b/sql/item_func.h index 516cdd548d0..4306c6ea47a 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -2053,9 +2053,9 @@ public: enum_field_types field_type() const { return last_value->field_type(); } bool const_item() const { return 0; } void evaluate_sideeffects(); - void update_uesd_tables() + void update_used_tables() { - Item_func_last_value::update_used_tables(); + Item_func::update_used_tables(); maybe_null= last_value->maybe_null; } }; |