4 messages in com.mysql.lists.bugsLOAD DATA does not handle xEy numbers...
FromSent OnAttachments
BICHOT Guilhem 17261330 Jan 2002 02:10 
Sinisa Milivojevic30 Jan 2002 05:02 
Michael Widenius31 Jan 2002 09:18 
Michael Widenius14 Feb 2002 01:13 
Subject:LOAD DATA does not handle xEy numbers properly when inserting in a DECIMAL column
From:Michael Widenius (mon@mysql.com)
Date:02/14/2002 01:13:43 AM
List:com.mysql.lists.bugs

Hi!

How-To-Repeat: (To avoid spam filter)

"BICHOT" == BICHOT Guilhem <172613 <guil@ipsn.fr>> writes:

BICHOT> Description:

BICHOT> It is said that MySQL can automatically convert strings to numbers, BICHOT> but here is an exception with a DECIMAL or INT column, in INSERT BICHOT> and LOAD DATA. If the string is written in the xEy manner BICHOT> (meaning x * 10^y), BICHOT> then only the part before the "E" is kept by MySQL, leading BICHOT> to bad values.

<cut>

Apparently we need to precise the rules a bit:

- If you try to use a string in a 'integer' context, the string will be read as an integer. (basicly with the 'atoi()' C function) This means that if you insert the string '1e2' into an integer column only 1 will be inserted.

- If you try to use a string in a floating point context, the string will be read as a floating point value. (basicly with the 'atof()' C function)

The reason for the above rules are:

- Speed - Predictability (in a sense..) - You will not get problems with integers that is outside of the floating point precision. - Its not easy to code a fast function that can read a longlong or unsigned longlong value and also accept an exponent.

Regards, Monty