| Bug #41236 | CONCAT inconsistently accepts string args without separating commas | ||
|---|---|---|---|
| Submitted: | 4 Dec 2008 17:31 | Modified: | 4 Dec 2008 20:15 |
| Reporter: | Peter Brawley (Basic Quality Contributor) | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 6.0.7 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | qc | ||
[4 Dec 2008 19:44]
Valeriy Kravchuk
Sorry, but this is not a bug. According to SQL standard, character string literal can be specified as:
'abc' 'def'
and implicit concatenation happens. So, in the first case CONCAT is applied just to one string literal argument. In the second case argument is string function RPAD(...) and then either ) or comma before the next argument is expected. Instead, we have a string literal. So, syntax is incorrect. In 5.0.x it was explicit:
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot -P3308 test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 5.0.72-enterprise-gpl-nt MySQL Enterprise Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> SELECT CONCAT(RPAD('abc',5,' ') 'def');
ERROR 1064 (42000): 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 ''def'
)' at line 1
5.1 and later tried to provide more clear and precise error message for this case.
[4 Dec 2008 20:15]
Peter Brawley
A SQL anomaly, OK. The 6.0.7 error message is ERROR 1583 (42000): Incorrect parameters in the call to native function 'CONCAT'

Description: CONCAT() accepts literal strings without comma separation: SELECT CONCAT('abc' 'def'); +---------------------+ | CONCAT('abc' 'def') | +---------------------+ | abcdef | +---------------------+ ... but not function args ... SELECT CONCAT(RPAD('abc',5,' ') 'def'); ERROR 1583 (42000): Incorrect parameters in the call to native function 'CONCAT' Non-literals require commas: SELECT CONCAT(RPAD('abc',5,' '), 'def'); +----------------------------------+ | CONCAT(RPAD('abc',5,' '), 'def') | +----------------------------------+ | abc def | +----------------------------------+ I suggest this inconsistency is undesirable at best. How to repeat: As above