I have come across a very strange occurrence while working on a client's
system. I get different behavior between the two servers (one Windows, one
Linux) when it comes to a column defined as double(5,4). The Windows system
truncates new values (existing data in the table is not truncated) whereas
the Linux system does not.

On the Windows machine I have been unable to replicate the data that already
exists in the table! -- e.g., a value of 179.0000 exists in the table but I
cannot insert that value back into the same column -- so that is why my
statements below illustrate the issue by selecting from the table.

Anyone witnessed this bizarre behavior or know if I should report this
elsewhere?

Kevin

First, tech specs:
Desktop: WinXP, MySQL 4.1.3b-beta-nt-max
Server: Slackware Linux 9.0, MySQL 4.1.1-alpha

Here are the statements I executed on both machines:

SHOW COLUMNS FROM scene LIKE 'max_lon';
SELECT max(max_lon) FROM scene;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( a double(5, 4) );
INSERT INTO t1 SELECT max(max_lon) FROM scene;
SELECT a FROM t1;

And here is the output:

---------------------------------------------------
WINDOWS
---------------------------------------------------
mysql> SHOW COLUMNS FROM scene LIKE 'max_lon';
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| max_lon | double(5,4) | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
1 row in set (0.00 sec)

mysql> SELECT max(max_lon) FROM scene;
+--------------+
| max(max_lon) |
+--------------+
|     179.0000 |
+--------------+
1 row in set (0.02 sec)

mysql> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t1 ( a double(5, 4) );
Query OK, 0 rows affected (0.09 sec)

mysql> INSERT INTO t1 SELECT max(max_lon) FROM scene;
Query OK, 1 row affected, 1 warning (0.03 sec)
Records: 1  Duplicates: 0  Warnings: 1

mysql> SHOW WARNINGS;
+---------+------+----------------------------------------------------------
+
| Level   | Code | Message
|
+---------+------+----------------------------------------------------------
+
| Warning | 1264 | Data truncated; out of range for column 'a' at row 14437
|
+---------+------+----------------------------------------------------------
+
1 row in set (0.00 sec)

mysql> SELECT a FROM t1;
+--------+
| a      |
+--------+
| 9.9999 |
+--------+
1 row in set (0.00 sec)


---------------------------------------------------
LINUX
---------------------------------------------------
mysql> SHOW COLUMNS FROM scene LIKE 'max_lon';
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| max_lon | double(5,4) | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
1 row in set (0.00 sec)

mysql> SELECT max(max_lon) FROM scene;
+--------------+
| max(max_lon) |
+--------------+
|     179.0000 |
+--------------+
1 row in set (0.00 sec)

mysql> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t1 ( a double(5, 4) );
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO t1 SELECT max(max_lon) FROM scene;
Query OK, 1 row affected (0.01 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> SHOW WARNINGS;
Empty set (0.00 sec)

mysql> SELECT a FROM t1;
+----------+
| a        |
+----------+
| 179.0000 |
+----------+
1 row in set (0.00 sec)


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to