Commit 3a00469e authored by unknown's avatar unknown
Browse files

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

We should allow 19 as length of newly created TIMESTAMP fields.


mysql-test/r/type_timestamp.result:
  Added test of TIMESTAMP(19) support.
mysql-test/t/type_timestamp.test:
  Added test of TIMESTAMP(19) support.
sql/sql_parse.cc:
  add_field_to_list(): TIMESTAMP columns should also support 19 as length since it is
  length of 4.1 compatible representation.
BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parent 06cd2efc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
+12 −0
Original line number Diff line number Diff line
@@ -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;
+11 −0
Original line number Diff line number Diff line
@@ -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;
+5 −1
Original line number Diff line number Diff line
@@ -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 */
    }