diff options
author | unknown <dlenev@mysql.com> | 2004-10-07 13:51:32 +0400 |
---|---|---|
committer | unknown <dlenev@mysql.com> | 2004-10-07 13:51:32 +0400 |
commit | 0129f32bfcec1e0e283699d4dee7429d33906a79 (patch) | |
tree | b8016f96ab99747f4023e506afd46eb4657a1b29 /mysql-test | |
parent | 5b3444d2faf45786e5f6078e442e0514c8b2814e (diff) | |
parent | 34789efd3191d5a140c65dd17b459024c741c085 (diff) | |
download | mariadb-git-0129f32bfcec1e0e283699d4dee7429d33906a79.tar.gz |
Manual merge of tree containing fix for bug #5915 "ALTER TABLE behaves
differently when converting column to auto_increment in 4.1" with
current tree.
mysql-test/t/type_timestamp.test:
Auto merged
mysql-test/r/type_timestamp.result:
Manual merge.
sql/sql_table.cc:
Manual merge.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/auto_increment.result | 52 | ||||
-rw-r--r-- | mysql-test/r/type_timestamp.result | 17 | ||||
-rw-r--r-- | mysql-test/t/auto_increment.test | 38 | ||||
-rw-r--r-- | mysql-test/t/type_timestamp.test | 12 |
4 files changed, 103 insertions, 16 deletions
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index f5ec5f1f852..428b2769fdb 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -289,3 +289,55 @@ a b 0 13 500 14 drop table t1; +create table t1 (a bigint); +insert into t1 values (1), (2), (3), (NULL), (NULL); +alter table t1 modify a bigint not null auto_increment primary key; +select * from t1; +a +1 +2 +3 +4 +5 +drop table t1; +create table t1 (a bigint); +insert into t1 values (1), (2), (3), (0), (0); +alter table t1 modify a bigint not null auto_increment primary key; +select * from t1; +a +1 +2 +3 +4 +5 +drop table t1; +create table t1 (a bigint); +insert into t1 values (0), (1), (2), (3); +set sql_mode=NO_AUTO_VALUE_ON_ZERO; +alter table t1 modify a bigint not null auto_increment primary key; +set sql_mode= ''; +select * from t1; +a +0 +1 +2 +3 +drop table t1; +create table t1 (a int auto_increment primary key , b int null); +set sql_mode=NO_AUTO_VALUE_ON_ZERO; +insert into t1 values (0,1),(1,2),(2,3); +select * from t1; +a b +0 1 +1 2 +2 3 +set sql_mode= ''; +alter table t1 modify b varchar(255); +insert into t1 values (0,4); +select * from t1; +a b +0 1 +1 2 +2 3 +3 4 +drop table t1; diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index 4dd94b26a73..42fdc7e50c6 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -405,17 +405,14 @@ a b NULL NULL NULL 2003-01-01 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 NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -set TIMESTAMP=1000000000; -insert into t1 values (); +create table t1 (a bigint, b bigint); +insert into t1 values (NULL, NULL), (20030101000000, 20030102000000); +set timestamp=1000000019; +alter table t1 modify a timestamp, modify b timestamp; select * from t1; -ts -2001-09-09 04:46:40 +a b +2001-09-09 04:46:59 2001-09-09 04:46:59 +2003-01-01 00:00:00 2003-01-02 00:00:00 drop table t1; create table t1 (a char(2), t timestamp); insert into t1 values ('a', '2004-01-01 00:00:00'), ('a', '2004-01-01 01:00:00'), diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index e5986e6755d..8e11a3d68a5 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -168,3 +168,41 @@ update t1 set a=NULL where b=13; update t1 set a=500 where b=14; select * from t1 order by b; drop table t1; + +# +# Test of behavior of ALTER TABLE when coulmn containing NULL or zeroes is +# converted to AUTO_INCREMENT column +# +create table t1 (a bigint); +insert into t1 values (1), (2), (3), (NULL), (NULL); +alter table t1 modify a bigint not null auto_increment primary key; +select * from t1; +drop table t1; + +create table t1 (a bigint); +insert into t1 values (1), (2), (3), (0), (0); +alter table t1 modify a bigint not null auto_increment primary key; +select * from t1; +drop table t1; + +# We still should be able to preserve zero in NO_AUTO_VALUE_ON_ZERO mode +create table t1 (a bigint); +insert into t1 values (0), (1), (2), (3); +set sql_mode=NO_AUTO_VALUE_ON_ZERO; +alter table t1 modify a bigint not null auto_increment primary key; +set sql_mode= ''; +select * from t1; +drop table t1; + +# It also sensible to preserve zeroes if we are converting auto_increment +# column to auto_increment column (or not touching it at all, which is more +# common case probably) +create table t1 (a int auto_increment primary key , b int null); +set sql_mode=NO_AUTO_VALUE_ON_ZERO; +insert into t1 values (0,1),(1,2),(2,3); +select * from t1; +set sql_mode= ''; +alter table t1 modify b varchar(255); +insert into t1 values (0,4); +select * from t1; +drop table t1; diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index 5978c24ddc4..a8a0cf8703c 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -267,13 +267,13 @@ select * from t1; drop table t1; # -# Test for bug #4491, TIMESTAMP(19) should be possible to create and not -# only read in 4.0 +# Let us test behavior of ALTER TABLE when it converts columns +# containing NULL to TIMESTAMP columns. # -create table t1 (ts timestamp(19)); -show create table t1; -set TIMESTAMP=1000000000; -insert into t1 values (); +create table t1 (a bigint, b bigint); +insert into t1 values (NULL, NULL), (20030101000000, 20030102000000); +set timestamp=1000000019; +alter table t1 modify a timestamp, modify b timestamp; select * from t1; drop table t1; |