Re: Data Truncation of CURRENT_TIMESTAMP
Posted by: Mark Matthews
Date: March 10, 2005 12:39PM

Kevin Lloyd wrote:
> I'm having a problem with 'data truncation' and
> timestamp fields.
> The fields in question have a default value of
> CURRENT_TIMESTAMP. It appears the drivers are
> attempting to insert this value into the database
> when I use the ResultSet.insertRow() method (and
> the field isn't actually updated). When they do,
> I get the (new) data truncation
> warning/exception.
> I've managed to replicate the issue by calling
> updateString("CURRENT_TIMESTAMP") on the field.
> Am I missing some driver or database option here?
> Kevin Lloyd
> MySQL 4.1.10
> MySQL-AB JDBC Driver mysql-connector-java-3.1.7

It seems the issue is that the driver can't distinguish from the information given by the server the difference between CURRENT_TIMESTAMP and 'CURRENT_TIMESTAMP', so it sends 'CURRENT_TIMESTAMP'...We'll have to add a fix to look if the default value is CURRENT_TIMESTAMP and the column is a timestamp type, and if so, not send it as a string:

mysql> create table tsFoo(field1 TIMESTAMP NOT NULL, field2 VARCHAR(32) DEFAULT 'abcd');
Query OK, 0 rows affected (0.01 sec)

mysql> show columns from tsFoo;
| Field | Type | Null | Key | Default | Extra |
| field1 | timestamp | YES | | CURRENT_TIMESTAMP | |
| field2 | varchar(32) | YES | | abcd | |
2 rows in set (0.00 sec)


We'll put a workaround in 3.1.8, but I filed this as a server bug:


Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools

Options: ReplyQuote

Written By
Re: Data Truncation of CURRENT_TIMESTAMP
March 10, 2005 12:39PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.