diff options
author | Gleb Shchepa <gshchepa@mysql.com> | 2009-05-18 23:43:06 +0500 |
---|---|---|
committer | Gleb Shchepa <gshchepa@mysql.com> | 2009-05-18 23:43:06 +0500 |
commit | 8a39147a6adf83a430d7d9bf951238519157603d (patch) | |
tree | 5e85c79ec8dded8d42753cd6706b2dcc48f95297 /sql/item.cc | |
parent | edc19ca2520bad0e4cff40a9dac2d064882cfa2b (diff) | |
download | mariadb-git-8a39147a6adf83a430d7d9bf951238519157603d.tar.gz |
Bug#40825: Error 1356 while selecting from a view
with a "HAVING" clause though query works
SELECT from views defined like:
CREATE VIEW v1 (view_column)
AS SELECT c AS alias FROM t1 HAVING alias
fails with an error 1356:
View '...' references invalid table(s) or column(s)
or function(s) or definer/invoker of view lack rights
to use them
CREATE VIEW form with a (column list) substitutes
SELECT column names/aliases with names from a
view column list.
However, alias references in HAVING clause was
not substituted.
The Item_ref::print function has been modified
to write correct aliased names of underlying
items into VIEW definition generation/.frm file.
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item.cc b/sql/item.cc index 13f09914ec6..7c4e86d756f 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5648,7 +5648,8 @@ void Item_ref::print(String *str) !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); |