Bug #17487 | CASE and IF() used in a group function (e.g. SUM ) results in error #1305 | ||
---|---|---|---|
Submitted: | 16 Feb 2006 17:20 | Modified: | 19 Feb 2006 9:25 |
Reporter: | Oswaldt Oldenburg | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S4 (Feature request) |
Version: | MySQL 5.0.18-nt | OS: | Windows (Windows XP Professional with SP2) |
Assigned to: | CPU Architecture: | Any |
[16 Feb 2006 17:20]
Oswaldt Oldenburg
[17 Feb 2006 14:14]
Valeriy Kravchuk
Please, read the manual (http://dev.mysql.com/doc/refman/5.0/en/functions.html): "Note: By default, there must be no whitespace between a function name and the parenthesis following it. This helps the MySQL parser distinguish between function calls and references to tables or columns that happen to have the same name as a function. However, spaces around function arguments are permitted. You can tell the MySQL server to accept spaces after function names by starting it with the --sql-mode=IGNORE_SPACE option. (See Section 5.2.5, “The Server SQL Mode”.) Individual client programs can request this behavior by using the CLIENT_IGNORE_SPACE option for mysql_real_connect(). In either case, all function names become reserved words." Look: mysql> SELECT -> SUM -> ( -> CASE x -> WHEN 1 THEN 2 -> WHEN 2 THEN 4 -> ELSE 8 -> END -> ) -> FROM `dummy` WHERE 1; ERROR 1305 (42000): FUNCTION test.SUM does not exist mysql> SELECT SUM( CASE x WHEN 1 THEN 2 WHEN 2 THEN 4 ELSE 8 END) FROM ` dummy` WHERE 1; +-----------------------------------------------------------+ | SUM( CASE x WHEN 1 THEN 2 WHEN 2 THEN 4 ELSE 8 END) | +-----------------------------------------------------------+ | 10 | +-----------------------------------------------------------+ 1 row in set (0.00 sec) mysql> select sum (x) from `dummy`; ERROR 1305 (42000): FUNCTION test.sum does not exist mysql> select sum(x) from `dummy`; +--------+ | sum(x) | +--------+ | 5 | +--------+ 1 row in set (0.00 sec) I hope, you understand now that this is not a bug.
[19 Feb 2006 9:25]
Oswaldt Oldenburg
The e-mail below demonstrates, it is not a bug. But I think, it's a cosmetical one then - why it works with AVG? A equal behavior of all functions would be desirable. ID: 17487 Updated by: Valeriy Kravchuk Reported by: Oswaldt Oldenburg -Status: Open +Status: Not a Bug Severity: S1 (Critical) Category: Server Operating System: Windows XP Professional with SP2 Version: MySQL 5.0.18-nt [17 Feb 15:14] Valeriy Kravchuk Please, read the manual (http://dev.mysql.com/doc/refman/5.0/en/functions.html): "Note: By default, there must be no whitespace between a function name and the parenthesis following it. This helps the MySQL parser distinguish between function calls and references to tables or columns that happen to have the same name as a function. However, spaces around function arguments are permitted. You can tell the MySQL server to accept spaces after function names by starting it with the --sql-mode=IGNORE_SPACE option. (See Section 5.2.5, “The Server SQL Modeâ€.) Individual client programs can request this behavior by using the CLIENT_IGNORE_SPACE option for mysql_real_connect(). In either case, all function names become reserved words." Look: mysql> SELECT -> SUM -> ( -> CASE x -> WHEN 1 THEN 2 -> WHEN 2 THEN 4 -> ELSE 8 -> END -> ) -> FROM `dummy` WHERE 1; ERROR 1305 (42000): FUNCTION test.SUM does not exist mysql> SELECT SUM( CASE x WHEN 1 THEN 2 WHEN 2 THEN 4 ELSE 8 END) FROM ` dummy` WHERE 1; +-----------------------------------------------------------+ | SUM( CASE x WHEN 1 THEN 2 WHEN 2 THEN 4 ELSE 8 END) | +-----------------------------------------------------------+ | 10 | +-----------------------------------------------------------+ 1 row in set (0.00 sec) mysql> select sum (x) from `dummy`; ERROR 1305 (42000): FUNCTION test.sum does not exist mysql> select sum(x) from `dummy`; +--------+ | sum(x) | +--------+ | 5 | +--------+ 1 row in set (0.00 sec) I hope, you understand now that this is not a bug.