diff options
author | unknown <pem@mysql.comhem.se> | 2005-02-16 16:06:41 +0100 |
---|---|---|
committer | unknown <pem@mysql.comhem.se> | 2005-02-16 16:06:41 +0100 |
commit | 0f466d046cae40468492dbe41ccb1c54a5509418 (patch) | |
tree | fd89d8647d4a4e16cd4a1f46efe25487244fcb09 | |
parent | ec075331b0b8f9ce710bb2bffe7fd1ca1db8f90f (diff) | |
download | mariadb-git-0f466d046cae40468492dbe41ccb1c54a5509418.tar.gz |
Fixed BUG#8540: Local variable overrides an alias.
mysql-test/r/sp.result:
New test case for BUG#8540.
mysql-test/t/sp.test:
New test case for BUG#8540.
sql/item.h:
Use the existing name (if any) for a SP local variable (to get the correct
field name in a select in the case of an alias).
-rw-r--r-- | mysql-test/r/sp.result | 10 | ||||
-rw-r--r-- | mysql-test/t/sp.test | 16 | ||||
-rw-r--r-- | sql/item.h | 5 |
3 files changed, 30 insertions, 1 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 0af6b821ce0..05803e57ba0 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2059,6 +2059,16 @@ call bug6029()| 1136 drop procedure bug6029| drop table t3| +drop procedure if exists bug8540| +create procedure bug8540() +begin +declare x int default 1; +select x as y, x+0 as z; +end| +call bug8540()| +y z +1 1 +drop procedure bug8540| drop table if exists fac| create table fac (n int unsigned not null primary key, f bigint unsigned)| drop procedure if exists ifac| diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index bdc5ec0dc22..8b59af6e494 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -2520,6 +2520,22 @@ call bug6029()| drop procedure bug6029| drop table t3| +# +# BUG#8540: Local variable overrides an alias +# +--disable_warnings +drop procedure if exists bug8540| +--enable_warnings + +create procedure bug8540() +begin + declare x int default 1; + select x as y, x+0 as z; +end| + +call bug8540()| +drop procedure bug8540| + # # Some "real" examples diff --git a/sql/item.h b/sql/item.h index 299bc6c081b..7d9526b53a8 100644 --- a/sql/item.h +++ b/sql/item.h @@ -460,7 +460,10 @@ public: { Item *it= this_item(); - it->set_name(m_name.str, m_name.length, system_charset_info); + if (name) + it->set_name(name, strlen(name), system_charset_info); + else + it->set_name(m_name.str, m_name.length, system_charset_info); it->make_field(field); } |