Bug #2574 ODBC 3.51 - A field decimal 18,8 returns only 4 decimal places
Submitted: 29 Jan 2004 22:10 Modified: 25 Jan 2006 12:55
Reporter: Vikram J. Gurjar Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version: OS:Linux (Linux/Windows)
Assigned to: MySQL Verification Team CPU Architecture:Any

[29 Jan 2004 22:10] Vikram J. Gurjar
Description:
MySQL 4.0.17 on RH 9.0 
ODBC 3.51 on Win 98 
 
A field defined as decimal 18,8 returns only 4 decimal places on select. 

How to repeat:
On the server 
In a database <database> on any table <table> in MySQL in Linux RH 9 MySQL 4.0.17 
 
USE <database> 
ALTER TABLE <tablename> ADD COLUMN <fieldname> decimal(18,8) NOT NULL DEFAULT 
0 
 
On a client 
USING VISUAL FOXPRO 6.0 with ODBC 3.51 on a Win 98 system 
In the command window type (or cut and paste) 
 
STORE SQLSTRINGCONNECT('dsn=<mysql>;uid=<user>;pwd=<password>) TO gndbconn 
SQLEXEC(gndbconn,"USE <database>") 
SQLEXEC(gndbconn,"SELECT * FROM <tablename>") 
BROW 
returns only 4 decimal places. 
 

Suggested fix:
 
Float works properly...changing the field to float solved the problem.
[31 Jan 2004 8:04] MySQL Verification Team
Worked fine for me from mysql client:

 ALTER TABLE nazivi ADD COLUMN glupost decimal(18,8) NOT NULL DEFAULT 0;
Query OK, 14 rows affected (0.06 sec)
Records: 14  Duplicates: 0  Warnings: 0

mysql> select * from nazivi;
+------+------------+------------+
| BROJ | naziv      | glupost    |
+------+------------+------------+
|    1 | jedan      | 0.00000000 |
|    2 | dva        | 0.00000000 |
|    3 | tri        | 0.00000000 |
|    4 | xxxxxxxxxx | 0.00000000 |
|    5 | a          | 0.00000000 |
|   10 |            | 0.00000000 |
|    6 | Sinisa     | 0.00000000 |
|    7 | Satkica    | 0.00000000 |
|    8 | yyyyy      | 0.00000000 |
|    9 | yyyyy      | 0.00000000 |
|   11 | aa         | 0.00000000 |
|   15 | NULL       | 0.00000000 |
|   55 |  "kkk"     | 0.00000000 |
|   66 |  ";;;"     | 0.00000000 |
+------+------------+------------+
14 rows in set (0.02 sec)

Please check that it works for you from mysql client.

In that case we will be able to pinpoint this as only MyODBC bug.
[22 Jul 2004 3:58] Timothy Smith
This hasn't been verified using ODBC - it looks like a potential bug, so I'm setting it back to Open so that it will be looked at again.
[26 Jul 2004 4:40] MySQL Verification Team
Explanation because I am marking this bug report as not a bug:

Below I created the table and display the rows using the
mysql client:

c:\mysql\bin>mysql -h192.168.0.77 --port=3340 -umiguel -p test
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.0.21-debug-log

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

mysql> create table bug2574 (x decimal(18,8));
Query OK, 0 rows affected (0.02 sec)

mysql> insert into bug2574 values (14.345), (24.903);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from bug2574;
+-------------+
| x           |
+-------------+
| 14.34500000 |
| 24.90300000 |
+-------------+
2 rows in set (0.00 sec)

Then an actual test for MyODBC is to fetch the data without
the use of one application  with text boxes, grids or their own
way for the manipulate the data set. For that I created an
DSN called bug2574 and fetched and displayed the data set
with the Microsoft's test tool: ODBCTE32.EXE.

Full Connect(Default)

	Env. Attr. SQL_ATTR_ODBC_VERSION set to SQL_OV_ODBC3

	Successfully connected to DSN 'bug2574'.

SQLExecDirect:
In:hstmt = 0x00991910, szSqlStr = "select * from bug2574", cbSqlStr = -3
				Return:	SQL_SUCCESS=0
Get Data All:
"x"
14.34500000
24.90300000
2 rows fetched from 1 column.

How you can see above MyODBC delivered correctly the decimal rows
like the mysql client does.
[25 Jan 2006 12:55] Vikram J. Gurjar
Just put in the full value like 9.12345678 and see what you get on the return.

You will get 9.12340000  instead.

Vikram
[25 Jan 2006 22:06] MySQL Verification Team
Still i was unable to repeat:

mysql> create table bug2574 (x decimal(18,8));
Query OK, 0 rows affected (0.41 sec)

mysql> insert into bug2574 values (9.12345678);
Query OK, 1 row affected (0.20 sec)

mysql> select * from bug2574;
+------------+
| x          |
+------------+
| 9.12345678 |
+------------+
1 row in set (0.16 sec)

Full Connect(Default)

	Env. Attr. SQL_ATTR_ODBC_VERSION set to SQL_OV_ODBC3

	Successfully connected to DSN 'bug2574'.
SQLExecDirect:
	In:	hstmt = 0x003B1B58, szSqlStr = "select * from bug2574", 
		cbSqlStr = -3
	Return:	SQL_SUCCESS=0

Get Data All:
"x"
9.12345678
1 row fetched from 1 column.