diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-09-04 17:52:04 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-09-04 17:52:04 +0300 |
commit | 537f8594a60a1e09d6da0933b55764e0f8abbf5c (patch) | |
tree | 628c68bccb01538df826045ba6f3aaa45c29b93a /mysql-test/main | |
parent | 647d5b243020b799fd7112a801965f5780b86349 (diff) | |
parent | f605ce08b5c0e6ed6907d0639bcc5b5630e9b40a (diff) | |
download | mariadb-git-537f8594a60a1e09d6da0933b55764e0f8abbf5c.tar.gz |
Merge 10.2 into 10.3
Diffstat (limited to 'mysql-test/main')
-rw-r--r-- | mysql-test/main/default.result | 20 | ||||
-rw-r--r-- | mysql-test/main/default.test | 15 | ||||
-rw-r--r-- | mysql-test/main/function_defaults.result | 52 | ||||
-rw-r--r-- | mysql-test/main/function_defaults.test | 48 | ||||
-rw-r--r-- | mysql-test/main/invisible_field.result | 2 |
5 files changed, 125 insertions, 12 deletions
diff --git a/mysql-test/main/default.result b/mysql-test/main/default.result index c214e529d72..cf0788b2fb2 100644 --- a/mysql-test/main/default.result +++ b/mysql-test/main/default.result @@ -3357,18 +3357,26 @@ a b drop table t1; set sql_mode=default; create table t1 (a int default b, b int default 4, t text); -insert into t1 (b, t) values (5, '1 column is omitted'); -insert into t1 values (default, 5, '2 column gets DEFAULT, keyword'); -insert into t1 values (default(a), 5, '3 column gets DEFAULT(a), expression'); -insert into t1 values (default(a)+0, 5, '4 also expression DEFAULT(0)+0'); -insert into t1 values (b, 5, '5 the value of the DEFAULT(a), that is b'); +insert t1 (b, t) values (5, '1 column is omitted'); +insert t1 values (default, 5, '2 column gets DEFAULT, keyword'); +insert t1 values (default(a), 5, '3 column gets DEFAULT(a), expression'); +insert t1 values (default(a)+0, 5, '4 also expression DEFAULT(0)+0'); +insert t1 values (b, 5, '5 the value of the DEFAULT(a), that is b'); +insert t1 (t,b,a) values ('6 reversed, column gets DEFAULT, keyword', 5, default); +insert t1 (t,b,a) values ('7 reversed, column gets DEFAULT(a), expression', 5, default(a)); +insert t1 (t,b,a) values ('8 reversed, also expression DEFAULT(0)+0', 5, default(a)+0); +insert t1 (t,b,a) values ('9 reversed, the value of the DEFAULT(a), that is b', 5, b); select * from t1 order by t; a b t 5 5 1 column is omitted -5 5 2 column gets DEFAULT, keyword +4 5 2 column gets DEFAULT, keyword 4 5 3 column gets DEFAULT(a), expression 4 5 4 also expression DEFAULT(0)+0 4 5 5 the value of the DEFAULT(a), that is b +5 5 6 reversed, column gets DEFAULT, keyword +5 5 7 reversed, column gets DEFAULT(a), expression +5 5 8 reversed, also expression DEFAULT(0)+0 +5 5 9 reversed, the value of the DEFAULT(a), that is b drop table t1; create table t1 (col1 int default(-(default(col1)))); ERROR 01000: Expression for field `col1` is referring to uninitialized field `col1` diff --git a/mysql-test/main/default.test b/mysql-test/main/default.test index 44778bc568a..27e38eeeb49 100644 --- a/mysql-test/main/default.test +++ b/mysql-test/main/default.test @@ -2073,11 +2073,16 @@ set sql_mode=default; # MDEV-10201 Bad results for CREATE TABLE t1 (a INT DEFAULT b, b INT DEFAULT 4) # create table t1 (a int default b, b int default 4, t text); -insert into t1 (b, t) values (5, '1 column is omitted'); -insert into t1 values (default, 5, '2 column gets DEFAULT, keyword'); -insert into t1 values (default(a), 5, '3 column gets DEFAULT(a), expression'); -insert into t1 values (default(a)+0, 5, '4 also expression DEFAULT(0)+0'); -insert into t1 values (b, 5, '5 the value of the DEFAULT(a), that is b'); +insert t1 (b, t) values (5, '1 column is omitted'); +insert t1 values (default, 5, '2 column gets DEFAULT, keyword'); +insert t1 values (default(a), 5, '3 column gets DEFAULT(a), expression'); +insert t1 values (default(a)+0, 5, '4 also expression DEFAULT(0)+0'); +insert t1 values (b, 5, '5 the value of the DEFAULT(a), that is b'); +# and the same in a different order +insert t1 (t,b,a) values ('6 reversed, column gets DEFAULT, keyword', 5, default); +insert t1 (t,b,a) values ('7 reversed, column gets DEFAULT(a), expression', 5, default(a)); +insert t1 (t,b,a) values ('8 reversed, also expression DEFAULT(0)+0', 5, default(a)+0); +insert t1 (t,b,a) values ('9 reversed, the value of the DEFAULT(a), that is b', 5, b); select * from t1 order by t; drop table t1; diff --git a/mysql-test/main/function_defaults.result b/mysql-test/main/function_defaults.result index 62422752e17..4a8f64df352 100644 --- a/mysql-test/main/function_defaults.result +++ b/mysql-test/main/function_defaults.result @@ -3093,3 +3093,55 @@ a b 1999-12-01 11:22:33.000000 1999-12-01 11:22:33.000000 2001-09-09 04:46:40.000000 2001-09-09 04:46:40.000000 DROP TABLE t1; +create table t1 (t timestamp, i int, v timestamp as (t) virtual, key(v)); +insert t1 (t,i) values ('2006-03-01 23:59:59',1); +update t1 set i = 2; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1 (t timestamp, i int); +create trigger tr1 before update on t1 for each row set @new:=new.t; +insert t1 (t,i) values ('2006-03-01 23:59:59', 1); +update t1 set i = 2; +select if(@new = t, 'correct', 'wrong') from t1; +if(@new = t, 'correct', 'wrong') +correct +drop table t1; +create table t1 (i int, j int as (i)); +create trigger tr1 before update on t1 for each row set @new:=new.j; +insert t1 (i) values (1); +update t1, t1 as t2 set t1.i = 2; +select if(@new = j, 'correct', 'wrong') from t1; +if(@new = j, 'correct', 'wrong') +correct +drop table t1; +create table t1 (a int, b varchar(20) default 'foo'); +insert t1 values (1,'bla'),(2, 'bar'); +select * from t1; +a b +1 bla +2 bar +update t1 set b=default where a=1; +select * from t1; +a b +1 foo +2 bar +drop table t1; +create table t1 ( +a int, +b timestamp default '2010-10-10 10:10:10' on update now(), +c varchar(100) default 'x'); +insert t1 (a) values (1),(2); +select * from t1; +a b c +1 2010-10-10 10:10:10 x +2 2010-10-10 10:10:10 x +set timestamp=unix_timestamp('2011-11-11 11-11-11'); +update t1 set b=default, c=default(b) where a=1; +select * from t1; +a b c +1 2010-10-10 10:10:10 2010-10-10 10:10:10 +2 2010-10-10 10:10:10 x +drop table t1; +set timestamp=default; diff --git a/mysql-test/main/function_defaults.test b/mysql-test/main/function_defaults.test index f8b23d0eda8..dd3ba109b2a 100644 --- a/mysql-test/main/function_defaults.test +++ b/mysql-test/main/function_defaults.test @@ -19,3 +19,51 @@ let $now=NOW(6); let $timestamp=TIMESTAMP(6); let $datetime=DATETIME(6); source 'include/function_defaults.inc'; + +# +# MDEV-20403 Assertion `0' or Assertion `btr_validate_index(index, 0)' failed in row_upd_sec_index_entry or error code 126: Index is corrupted upon UPDATE with TIMESTAMP..ON UPDATE +# + +# ON UPDATE NOW and indexed virtual columns +create table t1 (t timestamp, i int, v timestamp as (t) virtual, key(v)); +insert t1 (t,i) values ('2006-03-01 23:59:59',1); +update t1 set i = 2; +check table t1; +drop table t1; + +# ON UPDATE NOW and triggers +create table t1 (t timestamp, i int); +create trigger tr1 before update on t1 for each row set @new:=new.t; +insert t1 (t,i) values ('2006-03-01 23:59:59', 1); +update t1 set i = 2; +select if(@new = t, 'correct', 'wrong') from t1; +drop table t1; + +# triggers, virtual columns, multi-update +create table t1 (i int, j int as (i)); +create trigger tr1 before update on t1 for each row set @new:=new.j; +insert t1 (i) values (1); +update t1, t1 as t2 set t1.i = 2; +select if(@new = j, 'correct', 'wrong') from t1; +drop table t1; + +# SET xxx=DEFAULT +create table t1 (a int, b varchar(20) default 'foo'); +insert t1 values (1,'bla'),(2, 'bar'); +select * from t1; +update t1 set b=default where a=1; +select * from t1; +drop table t1; + +# ON UPDATE NOW and SET xxx=DEFAULT +create table t1 ( + a int, + b timestamp default '2010-10-10 10:10:10' on update now(), + c varchar(100) default 'x'); +insert t1 (a) values (1),(2); +select * from t1; +set timestamp=unix_timestamp('2011-11-11 11-11-11'); +update t1 set b=default, c=default(b) where a=1; +select * from t1; +drop table t1; +set timestamp=default; diff --git a/mysql-test/main/invisible_field.result b/mysql-test/main/invisible_field.result index 43a8b9d726b..9cdc54f2e43 100644 --- a/mysql-test/main/invisible_field.result +++ b/mysql-test/main/invisible_field.result @@ -538,7 +538,7 @@ a b insert into t2 values(1); select a,b from t2; a b -12 1 +NULL 1 drop table t1,t2; create table t1 (a int invisible, b int, c int); create table t2 (a int, b int, d int); |