summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BitKeeper/etc/logging_ok1
-rw-r--r--mysql-test/r/type_timestamp.result12
-rw-r--r--mysql-test/t/type_timestamp.test11
-rw-r--r--sql/sql_parse.cc6
4 files changed, 29 insertions, 1 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok
index 7a3063c3884..3ffbead8d68 100644
--- a/BitKeeper/etc/logging_ok
+++ b/BitKeeper/etc/logging_ok
@@ -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
diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result
index cd45bcf911d..752a5045eb0 100644
--- a/mysql-test/r/type_timestamp.result
+++ b/mysql-test/r/type_timestamp.result
@@ -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;
diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test
index 3483227376e..92bd20e846e 100644
--- a/mysql-test/t/type_timestamp.test
+++ b/mysql-test/t/type_timestamp.test
@@ -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;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 1f0af05a460..39c1a78b081 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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 */
}