summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordlenev@brandersnatch.localdomain <>2005-01-11 14:26:40 +0300
committerdlenev@brandersnatch.localdomain <>2005-01-11 14:26:40 +0300
commit2f321150924de852439a26d2b26e544f4a5949b7 (patch)
tree69b409bd5ca1149ad22e13b6a497d45ca7bad03a
parent28f5a019c1b85267988d4542a924f451506a1540 (diff)
downloadmariadb-git-2f321150924de852439a26d2b26e544f4a5949b7.tar.gz
Fix for bug #7418 "TIMESTAMP not always converted to DATETIME in MAXDB
mode". Changed grammar rule for "type" token. Now we have one branch with optional length specification for TIMESTAMP type instead of two separate branches.
-rw-r--r--mysql-test/r/type_timestamp.result10
-rw-r--r--mysql-test/t/type_timestamp.test12
-rw-r--r--sql/sql_yacc.yy9
3 files changed, 23 insertions, 8 deletions
diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result
index 42fdc7e50c6..6c46d308e7e 100644
--- a/mysql-test/r/type_timestamp.result
+++ b/mysql-test/r/type_timestamp.result
@@ -422,3 +422,13 @@ max(t)
2004-01-01 01:00:00
2004-02-01 00:00:00
drop table t1;
+set sql_mode='maxdb';
+create table t1 (a timestamp, b timestamp(19));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE "t1" (
+ "a" datetime default NULL,
+ "b" datetime default NULL
+)
+set sql_mode='';
+drop table t1;
diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test
index a8a0cf8703c..783e310f02d 100644
--- a/mysql-test/t/type_timestamp.test
+++ b/mysql-test/t/type_timestamp.test
@@ -286,3 +286,15 @@ insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00')
('b', '2004-02-01 00:00:00');
select max(t) from t1 group by a;
drop table t1;
+
+#
+# Test for bug #7418 "TIMESTAMP not always converted to DATETIME in MAXDB
+# mode". TIMESTAMP columns should be converted DATETIME columns in MAXDB
+# mode regardless of whether a display width is given.
+#
+set sql_mode='maxdb';
+create table t1 (a timestamp, b timestamp(19));
+show create table t1;
+# restore default mode
+set sql_mode='';
+drop table t1;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index a09694ee1e6..66f7882c4e7 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1415,7 +1415,7 @@ type:
| YEAR_SYM opt_len field_options { $$=FIELD_TYPE_YEAR; }
| DATE_SYM { $$=FIELD_TYPE_DATE; }
| TIME_SYM { $$=FIELD_TYPE_TIME; }
- | TIMESTAMP
+ | TIMESTAMP opt_len
{
if (YYTHD->variables.sql_mode & MODE_MAXDB)
$$=FIELD_TYPE_DATETIME;
@@ -1428,13 +1428,6 @@ type:
$$=FIELD_TYPE_TIMESTAMP;
}
}
- | TIMESTAMP '(' NUM ')'
- {
- LEX *lex= Lex;
- lex->length= $3.str;
- lex->type|= NOT_NULL_FLAG;
- $$= FIELD_TYPE_TIMESTAMP;
- }
| DATETIME { $$=FIELD_TYPE_DATETIME; }
| TINYBLOB { Lex->charset=&my_charset_bin;
$$=FIELD_TYPE_TINY_BLOB; }