Bug #3836 concat() does not concatenate
Submitted: 20 May 2004 11:01 Modified: 20 May 2004 15:51
Reporter: Vilius :) Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.18-8 OS:Linux (Debian GNU/Linux 2.6.6)
Assigned to: CPU Architecture:Any

[20 May 2004 11:01] Vilius :)
Description:
When concatinating two or more strings CONCACT() returns empty or NULL string. F.e.

mysql> SELECT CONCAT("a","b");
+-----------------+
| CONCAT("a","b") |
+-----------------+
| NULL            |
+-----------------+
1 row in set (0.00 sec)

How to repeat:
1.
mysql> SELECT CONCAT("a","b");
+-----------------+
| CONCAT("a","b") |
+-----------------+
| NULL            |
+-----------------+
1 row in set (0.00 sec)

2.
mysql> SELECT dir, fn, CONCAT(dir, fn) FROM ata_h;
+-------------------------------+------------------+-----------------+
| dir                           | fn               | CONCAT(dir, fn) |
+-------------------------------+------------------+-----------------+
| /a/Alytaus_RAAD_Alytaus_m_raj | 10224-143953.da1 |                 |
| /a/Alytaus_RAAD_Druskininkai  | 10225-150125.da1 |                 |
+-------------------------------+------------------+-----------------+
2 rows in set (0.10 sec)

mysql> DESCRIBE ata_h;
+------------------------------+--------------+------+-----+---------+-------+
| Field                        | Type         | Null | Key | Default | Extra |
+------------------------------+--------------+------+-----+---------+-------+
| dir                          | varchar(255) |      | PRI |         |       |
| fn                           | varchar(16)  |      | PRI |         |       |
| line                         | int(11)      |      | PRI | 0       |       |
| uid                          | varchar(12)  |      | PRI |         |       |
| ata_nr                       | tinyint(4)   |      | PRI | 0       |       |
+------------------------------+--------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

Suggested fix:
As Fry said in FUTURAMA: Fix It! Fix It! Fix It!...Mm.. Fix It! Fix It! Fix It! :)
[20 May 2004 15:51] MySQL Verification Team
I tested this with 4.0.18 on Windows and with 4.0.20
on Suse 9.0 without to repeat the behavior reported:

miguel@hegel:~> /usr/local/mysql/bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.20-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

<cut>

mysql> select dir, fn,
    -> concat(dir,fn) from ata_h\G
*************************** 1. row ***************************
           dir: /a/Alytaus_RAAAD_Alytaus_m_raj
            fn: 10224-143953.dal
concat(dir,fn): /a/Alytaus_RAAAD_Alytaus_m_raj10224-143953.dal
1 row in set (0.01 sec)

mysql> select concat("a","b");
+-----------------+
| concat("a","b") |
+-----------------+
| ab              |
+-----------------+
1 row in set (0.00 sec)

mysql>