List:Internals« Previous MessageNext Message »
From:ramil Date:July 25 2005 11:36am
Subject:bk commit into 5.0 tree (ramil:1.1890) BUG#11964
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1890 05/07/25 14:36:07 ramil@stripped +3 -0
  fix (bug #11964: ALTER TABLE gives wrong error message with sql-mode TRADITIONAL
(timestamp)).

  sql/field.cc
    1.278 05/07/25 14:35:59 ramil@stripped +4 -1
    fix (bug #11964: ALTER TABLE gives wrong error message with sql-mode TRADITIONAL
(timestamp)).
    set def only if timestamp fields have explicit default value.

  mysql-test/t/strict.test
    1.16 05/07/25 14:35:59 ramil@stripped +14 -0
    fix (bug #11964: ALTER TABLE gives wrong error message with sql-mode TRADITIONAL
(timestamp)).

  mysql-test/r/strict.result
    1.22 05/07/25 14:35:59 ramil@stripped +21 -0
    fix (bug #11964: ALTER TABLE gives wrong error message with sql-mode TRADITIONAL
(timestamp)).

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	ramil
# Host:	gw.mysql.r18.ru
# Root:	/usr/home/ram/work/mysql-5.0

--- 1.277/sql/field.cc	2005-07-20 22:16:40 +05:00
+++ 1.278/sql/field.cc	2005-07-25 14:35:59 +05:00
@@ -8462,7 +8462,10 @@
   def=0;
   if (!(flags & (NO_DEFAULT_VALUE_FLAG | BLOB_FLAG)) &&
       !old_field->is_real_null() &&
-      old_field->ptr && orig_field)
+      old_field->ptr && orig_field &&
+      (sql_type != FIELD_TYPE_TIMESTAMP ||                /* set def only if */
+       old_field->table->timestamp_field != old_field ||  /* timestamp field */ 
+       unireg_check == Field::TIMESTAMP_UN_FIELD))        /* has default val */
   {
     char buff[MAX_FIELD_WIDTH],*pos;
     String tmp(buff,sizeof(buff), charset), *res;

--- 1.21/mysql-test/r/strict.result	2005-07-20 05:57:56 +05:00
+++ 1.22/mysql-test/r/strict.result	2005-07-25 14:35:59 +05:00
@@ -1258,3 +1258,24 @@
 d
 2000-10-01
 drop table t1;
+set @@sql_mode='traditional';
+create table t1(a int, b timestamp);
+alter table t1 add primary key(a);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL default '0',
+  `b` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  PRIMARY KEY  (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a int, b timestamp default 20050102030405);
+alter table t1 add primary key(a);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` int(11) NOT NULL default '0',
+  `b` timestamp NOT NULL default '2005-01-02 03:04:05',
+  PRIMARY KEY  (`a`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;

--- 1.15/mysql-test/t/strict.test	2005-07-20 04:36:42 +05:00
+++ 1.16/mysql-test/t/strict.test	2005-07-25 14:35:59 +05:00
@@ -1118,3 +1118,17 @@
 update t1 set d = 1100;
 select * from t1;
 drop table t1;
+
+#
+# Bug #11964: alter table with timestamp field
+#
+
+set @@sql_mode='traditional';
+create table t1(a int, b timestamp);
+alter table t1 add primary key(a);
+show create table t1;
+drop table t1;
+create table t1(a int, b timestamp default 20050102030405);
+alter table t1 add primary key(a);
+show create table t1;
+drop table t1;
Thread
bk commit into 5.0 tree (ramil:1.1890) BUG#11964ramil25 Jul