diff options
author | Igor Babaev <igor@askmonty.org> | 2011-07-04 11:02:35 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2011-07-04 11:02:35 -0700 |
commit | 3984062ba40b72aab421db6e31ba80a42e3ad2ae (patch) | |
tree | 89ddc46bfa527536e1e3fa48ba47925fe4527392 | |
parent | c9e969b62dc81356ebc39e2e3c682ae7772a788a (diff) | |
parent | 3f7d51d0d87478910750fea4019acbc1e573e9ba (diff) | |
download | mariadb-git-3984062ba40b72aab421db6e31ba80a42e3ad2ae.tar.gz |
Merge.
-rw-r--r-- | mysql-test/r/view.result | 31 | ||||
-rw-r--r-- | mysql-test/t/view.test | 21 | ||||
-rw-r--r-- | sql/item.cc | 34 | ||||
-rw-r--r-- | sql/item.h | 7 |
4 files changed, 54 insertions, 39 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 12b8c88730c..559ce4e1935 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -4246,3 +4246,34 @@ a MIN(b) 7 78 DROP VIEW v1; DROP TABLE t1,t2; +# +# LP bug #804686: query over a derived table using a view +# with a degenerated where condition +# +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (0,0), (1,0), (0,0), (1,1), (1,0); +CREATE VIEW v1 AS SELECT a,b FROM t1; +CREATE VIEW v2 AS SELECT a, MAX(b) AS b FROM t1 GROUP BY a; +SELECT * FROM (SELECT b FROM v1 WHERE b = 0) t WHERE b<>0; +b +SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b<>0; +b +SELECT * FROM (SELECT b FROM v1 WHERE b = 0) t WHERE b; +b +SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b; +b +EXPLAIN EXTENDED +SELECT * FROM (SELECT b FROM v1 WHERE b = 0) t WHERE b; +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 +Warnings: +Note 1003 select `test`.`t1`.`b` AS `b` from `test`.`t1` where 0 +EXPLAIN EXTENDED +SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b; +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 +3 DERIVED t1 ALL NULL NULL NULL NULL 5 100.00 Using temporary; Using filesort +Warnings: +Note 1003 select `v2`.`b` AS `b` from `test`.`v2` where 0 +DROP VIEW v1,v2; +DROP TABLE t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 5d148facb9e..bef2e2a2402 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -4192,3 +4192,24 @@ SELECT a, MIN(b) FROM v1 GROUP BY a; DROP VIEW v1; DROP TABLE t1,t2; +--echo # +--echo # LP bug #804686: query over a derived table using a view +--echo # with a degenerated where condition +--echo # + +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (0,0), (1,0), (0,0), (1,1), (1,0); +CREATE VIEW v1 AS SELECT a,b FROM t1; +CREATE VIEW v2 AS SELECT a, MAX(b) AS b FROM t1 GROUP BY a; + +SELECT * FROM (SELECT b FROM v1 WHERE b = 0) t WHERE b<>0; +SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b<>0; +SELECT * FROM (SELECT b FROM v1 WHERE b = 0) t WHERE b; +SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b; +EXPLAIN EXTENDED +SELECT * FROM (SELECT b FROM v1 WHERE b = 0) t WHERE b; +EXPLAIN EXTENDED +SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b; + +DROP VIEW v1,v2; +DROP TABLE t1; diff --git a/sql/item.cc b/sql/item.cc index cad3e60e5fc..0f549b914eb 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6883,40 +6883,6 @@ bool Item_direct_ref::get_date(MYSQL_TIME *ltime,uint fuzzydate) } -Item* Item_direct_ref_to_ident::transform(Item_transformer transformer, - uchar *argument) -{ - DBUG_ASSERT(!current_thd->is_stmt_prepare()); - - Item *new_item= ident->transform(transformer, argument); - if (!new_item) - return 0; - DBUG_ASSERT(new_item->type() == FIELD_ITEM || new_item->type() == REF_ITEM); - - if (ident != new_item) - current_thd->change_item_tree((Item**)&ident, new_item); - return (this->*transformer)(argument); -} - - -Item* Item_direct_ref_to_ident::compile(Item_analyzer analyzer, uchar **arg_p, - Item_transformer transformer, - uchar *arg_t) -{ - if (!(this->*analyzer)(arg_p)) - return 0; - - uchar *arg_v= *arg_p; - Item *new_item= ident->compile(analyzer, &arg_v, transformer, arg_t); - if (new_item && ident != new_item) - { - DBUG_ASSERT(new_item->type() == FIELD_ITEM || new_item->type() == REF_ITEM); - current_thd->change_item_tree((Item**)&ident, new_item); - } - return (this->*transformer)(arg_t); -} - - Item_cache_wrapper::~Item_cache_wrapper() { DBUG_ASSERT(expr_cache == 0); diff --git a/sql/item.h b/sql/item.h index 1829f45d00b..de819dae8ee 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2570,8 +2570,8 @@ public: Field *get_tmp_table_field() { return result_field ? result_field : (*ref)->get_tmp_table_field(); } Item *get_tmp_table_item(THD *thd); - inline table_map used_tables() const; - inline void update_used_tables(); + table_map used_tables() const; + void update_used_tables(); bool const_item() const { return (*ref)->const_item(); @@ -2713,9 +2713,6 @@ public: virtual void print(String *str, enum_query_type query_type) { ident->print(str, query_type); } - virtual Item* transform(Item_transformer transformer, uchar *arg); - virtual Item* compile(Item_analyzer analyzer, uchar **arg_p, - Item_transformer transformer, uchar *arg_t); }; |