Fix for bug #4491 "timestamp(19) doesn't work".

We should allow 19 as length of newly created TIMESTAMP fields.
parent 1097805c
......@@ -20,6 +20,7 @@ bell@sanja.is.com.ua
bk@admin.bk
carsten@tsort.bitbybit.dk
davida@isil.mysql.com
dlenev@brandersnatch.localdomain
dlenev@build.mysql.com
dlenev@mysql.com
gerberb@ou800.zenez.com
......
......@@ -167,3 +167,15 @@ ts1 ts2
2001-09-09 04:46:40 0000-00-00 00:00:00
2001-09-09 04:46:40 0000-00-00 00:00:00
drop table t1;
create table t1 (ts timestamp(19));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`ts` timestamp(19) NOT NULL
) TYPE=MyISAM
set TIMESTAMP=1000000000;
insert into t1 values ();
select * from t1;
ts
2001-09-09 04:46:40
drop table t1;
......@@ -105,3 +105,14 @@ insert into t1 values ();
insert into t1 values (DEFAULT, DEFAULT);
select * from t1;
drop table t1;
#
# Test for bug #4491, TIMESTAMP(19) should be possible to create and not
# only read in 4.0
#
create table t1 (ts timestamp(19));
show create table t1;
set TIMESTAMP=1000000000;
insert into t1 values ();
select * from t1;
drop table t1;
......@@ -3231,8 +3231,12 @@ bool add_field_to_list(char *field_name, enum_field_types type,
case FIELD_TYPE_TIMESTAMP:
if (!length)
new_field->length= 14; // Full date YYYYMMDDHHMMSS
else
else if (new_field->length != 19)
{
/*
We support only even TIMESTAMP lengths less or equal than 14
and 19 as length of 4.1 compatible representation.
*/
new_field->length=((new_field->length+1)/2)*2; /* purecov: inspected */
new_field->length= min(new_field->length,14); /* purecov: inspected */
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment