Bug #890 MySQL 4.1: COALESCE(4/0,"Test",4) returns 0.
Submitted: 22 Jul 2003 12:19 Modified: 11 Aug 2003 3:28
Reporter: Jay G Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1-alpha OS:Linux (RH 8/FreeBSD)
Assigned to: Bugs System CPU Architecture:Any

[22 Jul 2003 12:19] Jay G
Description:
COALESCE() does not return string results in 4.1, if encounters string first it returns 0.

This appears to only happen if you use a null formula like (4/0).

Log:
mysql  Ver 13.5 Distrib 4.1.0-alpha, for pc-linux (i686)

mysql> SELECT COALESCE(4/0,NULL,"MySQL",4,NULL);
+-----------------------------------+
| COALESCE(4/0,NULL,"MySQL",4,NULL) |
+-----------------------------------+
|                                 0 |
+-----------------------------------+
1 row in set (0.00 sec)

mysql> SELECT COALESCE(4/0,NULL,4,"MySQL",NULL);
+-----------------------------------+
| COALESCE(4/0,NULL,4,"MySQL",NULL) |
+-----------------------------------+
|                                 4 |
+-----------------------------------+
1 row in set (0.00 sec)

mysql> SELECT COALESCE("MySQL");
+-------------------+
| COALESCE("MySQL") |
+-------------------+
| MySQL             |
+-------------------+
1 row in set (0.00 sec)

mysql> SELECT COALESCE(NULL,"MySQL");
+------------------------+
| COALESCE(NULL,"MySQL") |
+------------------------+
| MySQL                  |
+------------------------+
1 row in set (0.00 sec)

mysql> SELECT COALESCE(4/0,NULL,"MySQL");
+----------------------------+
| COALESCE(4/0,NULL,"MySQL") |
+----------------------------+
|                          0 |
+----------------------------+
1 row in set (0.00 sec)

mysql> SELECT COALESCE((4/0),NULL,"MySQL");
+------------------------------+
| COALESCE((4/0),NULL,"MySQL") |
+------------------------------+
|                            0 |
+------------------------------+
1 row in set (0.00 sec)

How to repeat:
Repeat any of the queries, in 4.1, as listed in Description above.
[11 Aug 2003 1:00] Victor Vagin
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.mysql.com/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

This is my trace:

---------------------------------------
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.1-alpha-debug-log

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

mysql> use test
Database changed
mysql> SELECT COALESCE(4/0,NULL,"MySQL",4,NULL);
+-----------------------------------+
| COALESCE(4/0,NULL,"MySQL",4,NULL) |
+-----------------------------------+
| MySQL                             |
+-----------------------------------+
1 row in set (0.01 sec)

mysql>
---------------------------------------

Please, try newer version..
[11 Aug 2003 3:28] Victor Vagin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html