diff options
author | Gleb Shchepa <gshchepa@mysql.com> | 2009-05-19 00:51:52 +0500 |
---|---|---|
committer | Gleb Shchepa <gshchepa@mysql.com> | 2009-05-19 00:51:52 +0500 |
commit | 20076dea049e077d7e129d5d4b6b0c05f1e5305e (patch) | |
tree | 197dd2e2bdd4cbd7775f332cb827834ff7737492 | |
parent | ef28e928f05e502f5e86a94e5aac57a879644e41 (diff) | |
parent | 2d55cc51a288c56332789de080b38fbe59b5ef30 (diff) | |
download | mariadb-git-20076dea049e077d7e129d5d4b6b0c05f1e5305e.tar.gz |
manual merge 5.0-bugteam --> 5.1-bugteam (bug 40825)
-rw-r--r-- | mysql-test/r/view.result | 19 | ||||
-rw-r--r-- | mysql-test/t/view.test | 23 | ||||
-rw-r--r-- | sql/item.cc | 3 |
3 files changed, 44 insertions, 1 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 0905fc0109b..a7af6a30f5c 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -3700,6 +3700,25 @@ ERROR 42000: Key 'c2' doesn't exist in table 'v1' DROP VIEW v1; DROP TABLE t1; # ----------------------------------------------------------------- +# -- Bug#40825: Error 1356 while selecting from a view +# -- with a "HAVING" clause though query works +# ----------------------------------------------------------------- + +CREATE TABLE t1 (c INT); + +CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`c` AS `view_column` from `t1` having `view_column` latin1 latin1_swedish_ci +SELECT * FROM v1; +view_column + +DROP VIEW v1; +DROP TABLE t1; + +# -- End of test case for Bug#40825 + +# ----------------------------------------------------------------- # -- End of 5.0 tests. # ----------------------------------------------------------------- DROP DATABASE IF EXISTS `d-1`; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index c9d01266e9e..39db92ee1bc 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -3681,6 +3681,29 @@ DROP VIEW v1; DROP TABLE t1; --echo # ----------------------------------------------------------------- +--echo # -- Bug#40825: Error 1356 while selecting from a view +--echo # -- with a "HAVING" clause though query works +--echo # ----------------------------------------------------------------- +--echo + +CREATE TABLE t1 (c INT); + +--echo + +CREATE VIEW v1 (view_column) AS SELECT c AS alias FROM t1 HAVING alias; +SHOW CREATE VIEW v1; +SELECT * FROM v1; + +--echo + +DROP VIEW v1; +DROP TABLE t1; + +--echo +--echo # -- End of test case for Bug#40825 +--echo + +--echo # ----------------------------------------------------------------- --echo # -- End of 5.0 tests. --echo # ----------------------------------------------------------------- diff --git a/sql/item.cc b/sql/item.cc index 4d9dc50226f..8a8c3610198 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5810,7 +5810,8 @@ void Item_ref::print(String *str, enum_query_type query_type) !table_name && name && alias_name_used) { THD *thd= current_thd; - append_identifier(thd, str, name, (uint) strlen(name)); + append_identifier(thd, str, (*ref)->real_item()->name, + (*ref)->real_item()->name_length); } else (*ref)->print(str, query_type); |