Bug #37188 can't query a view when use decode() function
Submitted: 4 Jun 2008 10:28 Modified: 5 Jun 2008 3:05
Reporter: long ware Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: Views Severity:S3 (Non-critical)
Version:5.0.24a-community-nt OS:Windows (xp sp3)
Assigned to: Susanne Ebrecht CPU Architecture:Any
Tags: view decode

[4 Jun 2008 10:28] long ware
Description:
can't query a view when use decode() function

How to repeat:
i want to know this is a bug or not,see blow

select version()
--5.0.24a-community-nt
create table zzzz(id int,remark varbinary(255))
insert into zzzz values (1,encode('你好','key'))
insert into zzzz values (2,encode('再见','key'))
select id,remark from zzzz
select id,decode(remark,'key') from zzzz
--get all data
CREATE view tmp_view as (
	select id,DECODE(remark,'key') AS str from zzzz
)
--ok
select * from tmp_view
--Error Code : 1064
--You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AS `str` from `test`.`zzzz`)' at line 1
--(0 ms taken)

Suggested fix:
fix it ??
[4 Jun 2008 15:08] Susanne Ebrecht
Many thanks for writing a bug report.

I can't reproduce your problem by using a newer version.

MySQL 5.0.24 is very old. Please try our newest version MySQL 5.0.51b.

Please feel free to reopen this bug report again, when you still have problems with newer version.

Here my test:

mysql> CREATE view tmp_view as (
    -> select id,DECODE(remark,'key') AS str from zzzz
    -> )
    -> ;
Query OK, 0 rows affected (0.03 sec)

mysql> select * from tmp_view
    -> ;
+------+--------+
| id   | str    |
+------+--------+
|    1 | 你好 | 
|    2 | 再见 | 
+------+--------+
[5 Jun 2008 3:05] long ware
yes,new version fixed this problem

thank you