On 11/4/13 9:51 PM, Alistair Cunningham wrote:
On 04/11/13 17:25, Daniel-Constantin Mierla wrote:
Do you know if mysql accepts to set a timestamp column with a datetime value? I will look over the code to see if there are potential side effects and eventually some workarounds.
Correct me if I'm wrong, but the SQL format of a datetime value is the same as a timestamp value. Both are YYYY-MM-DD HH:MM:SS. Therefore in the following it doesn't matter whether the '2013-11-04 12:34:56' is a datetime or a timestamp:
mysql> create table test ( a datetime, b timestamp ); Query OK, 0 rows affected (0.01 sec)
mysql> insert into test values ( '2013-11-04 12:34:56', '2013-11-04 12:34:56' ); Query OK, 1 row affected (0.00 sec)
mysql> select * from test; +---------------------+---------------------+ | a | b | +---------------------+---------------------+ | 2013-11-04 12:34:56 | 2013-11-04 12:34:56 | +---------------------+---------------------+ 1 row in set (0.00 sec)
I thought timestamp storing the unix time stamp as seconds. I see that in mysql module, MYSQL_TYPE_TIMESTAMP is considered as integer value (so expects the seconds) and MYSQL_TYPE_DATETIME is stored over a time_t by converting from date-time string.
I would do some basic tests to see if it works - on 32b looks like being ok. On 64b, the time_t is long int, iirc, so the sizes are different -- speaking of these, this mapping has to be reviewed anyhow, I will look closer at it when I get a chance.
Daniel