On 1/8/09, Jay Pipes <[email protected]> wrote:
>
> All:
>
> mysql> SELECT FROM_UNIXTIME("2008-01-08 03:14:07");
> +--------------------------------------+
> | FROM_UNIXTIME("2008-01-08 03:14:07") |
> +--------------------------------------+
> | 1969-12-31 19:33:28 |
> +--------------------------------------+
> 1 row in set, 1 warning (0.00 sec)
>
> mysql> show warnings;
>
> +---------+------+----------------------------------------------------------+
> | Level | Code | Message |
>
> +---------+------+----------------------------------------------------------+
> | Warning | 1292 | Truncated incorrect INTEGER value: '2008-01-08 03:14:07'
> |
>
> +---------+------+----------------------------------------------------------+
> 1 row in set (0.00 sec)
>
> I was actually surprised to find this was the behaviour in MySQL and
> Drizzle.
>
> Would anyone have a problem if I converted the above to an error?
> FROM_UNIXTIME() only takes unsigned integers in the range of 0 to INT32_MAX.
> It doesn't take strings, or strings that "look like numbers", or anything
> of the sort.
>
> IMHO, the above behaviour is dangerous, as it:
>
> * Implicitly tries to convert a string to an integer (based on the warning)
> * Produces an invalid TIMESTAMP value
> * Doesn't error, therefore giving the unassuming user the impression that
> FROM_UNIXTIME() indeed takes string parameters.
>
> Anyone object to me making the above an error?
No. Please make this an error. If you can find the code that does the
implicit conversions of things like this and kill it, throwing an error
instead, that'd be great. Because MySQL says "aha, I can make this into a
number, let's see, the first character is a digit, I can use that! Same
with the second, third and fourth -- AWESOME! The 5th character...oops, not
a digit, no worry, I have a number, I'll just use that instead!"
Note that indeed, Drizzle (and MySQL) convert Jay's original date to the
number "2008":
> select unix_timestamp('1969-12-31 19:33:28');
+---------------------------------------+
| unix_timestamp('1969-12-31 19:33:28') |
+---------------------------------------+
| 2008 |
+---------------------------------------+
1 row in set (0.00 sec)
There is indeed absolutely NO good reason for this behavior. Lazy
end-programmers != good reason.
-Sheeri
Cheers,
>
> Jay
>
> _______________________________________________
> Mailing list:
> https://launchpad.net/~drizzle-discuss<https://launchpad.net/%7Edrizzle-discuss>
> Post to : [email protected]
> Unsubscribe :
> https://launchpad.net/~drizzle-discuss<https://launchpad.net/%7Edrizzle-discuss>
> More help : https://help.launchpad.net/ListHelp
>
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp