Bug #64760 Divide in select does not work
Submitted: 26 Mar 2012 5:20 Modified: 26 Mar 2012 23:43
Reporter: David Bailey Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:5.5.21 OS:Windows (xp)
Assigned to: CPU Architecture:Any

[26 Mar 2012 5:20] David Bailey
Description:
Using Borland's TQuery, the statement "select 2/5" returns a blank column. 
This statement works when using MySQL 4.1 (currently upgrading to latest version).
Please not that statement works using the MySQL work bench.

How to repeat:
Start MySQL 5.5.21.
Open up favorite query tool implementing Borland BDE.
Type in "select 2/5".
Examine result (blank column or missing column when select has multiple fields).

Repeat using MySQL 4.1
(Result set OK).

Suggested fix:
None.
[26 Mar 2012 5:36] Valeriy Kravchuk
Sorry, but this still works in mysql command line client:

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -uroot -proot -P3312 test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.21-log MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select 2/5;
+--------+
| 2/5    |
+--------+
| 0.4000 |
+--------+
1 row in set (0.00 sec)

So, probably you should check how BDE connects to MySQL (via ODBC driver probably?) and then make sure that it connects with "something" that works with MySQL 5.5.x properly.
[26 Mar 2012 6:11] David Bailey
I imagine that you are right in that it will still work using the command line. But Borland Developer Studio does not use the command line. So something has changed between MySQL 4.1 and MySQL 5.5. If this is not considered a bug, then we will have to revert back to MySQL 4.1.

Have also discovered that "select 3.1" returns the same result, so there is something about the data type returned (we suspect) that is incompatible with Borland created code and therefore our programs.
[26 Mar 2012 6:39] Valeriy Kravchuk
Can you, please, check if BDE works with MySQL directly (using some kind of "native" interface) or via ODBC. In later case we may be able to solve the problem with other/newer version of ODBC driver. Otherwise I'd say the problem is in the way BDE works with MySQL.

Can you enable general query log for MySQL server, try to execute your statement from BDE client and send me the content of general query log? See http://dev.mysql.com/doc/refman/5.5/en/query-log.html for reference.
[26 Mar 2012 6:40] Valeriy Kravchuk
Check http://dev.mysql.com/doc/refman/5.5/en/connector-odbc-usagenotes-apptips.html#connector-od... also for any hints that may help.
[26 Mar 2012 23:09] David Bailey
Hi Valeriy,

Is this what you are after...

(mysql.log contents)

C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld, Version: 5.5.21-log (MySQL Community Server (GPL)). started with:
TCP Port: 3306, Named Pipe: (null)
Time                 Id Command    Argument
120327  9:32:04	    1 Connect	gap@localhost on 
		    2 Connect	gap@localhost on blueprint_TrottPark
		    1 Init DB	blueprint_trottpark
120327  9:32:08	    1 Query	explain select 2/5 AS a, 1.5 AS b
		    2 Query	select 2/5 AS a, 1.5 AS b
[26 Mar 2012 23:43] David Bailey
Apparently we were using the MySQL ODBC 3.51 driver. Updating to the 5.1 driver has fixed the problem. 

Thanking you for your help,

David Bailey.