summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-09-04 14:02:01 +0200
committerSergei Golubchik <serg@mariadb.org>2019-09-04 15:37:23 +0200
commit8dca4cf53ff9d738d39730014d79205d6fd014fd (patch)
tree9781e3e4fc2e8c859bafe25a791ee2c456779752 /mysql-test
parent53ec9047c91c66644799ad058e998a7cfe1afef0 (diff)
downloadmariadb-git-8dca4cf53ff9d738d39730014d79205d6fd014fd.tar.gz
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
remove a special treatment of a bare DEFAULT keyword that made it behave inconsistently and differently from DEFAULT(column). Now all forms of the explicit assignment of a default column value behave identically, and all count as an explicitly assigned value (for the purpose of ON UPDATE NOW). followup for c7c481f4d91
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/default.result2
-rw-r--r--mysql-test/r/function_defaults.result29
-rw-r--r--mysql-test/t/function_defaults.test25
3 files changed, 53 insertions, 3 deletions
diff --git a/mysql-test/r/default.result b/mysql-test/r/default.result
index c2de5a578f1..f4ef9fcc8c8 100644
--- a/mysql-test/r/default.result
+++ b/mysql-test/r/default.result
@@ -3372,7 +3372,7 @@ insert into t1 values (b, 5, '5 the value of the DEFAULT(a), that is 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
diff --git a/mysql-test/r/function_defaults.result b/mysql-test/r/function_defaults.result
index 1c63ae17a5d..4a8f64df352 100644
--- a/mysql-test/r/function_defaults.result
+++ b/mysql-test/r/function_defaults.result
@@ -3116,3 +3116,32 @@ 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/t/function_defaults.test b/mysql-test/t/function_defaults.test
index 1e3e86599e3..dd3ba109b2a 100644
--- a/mysql-test/t/function_defaults.test
+++ b/mysql-test/t/function_defaults.test
@@ -24,14 +24,14 @@ 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 DEFAULT NOW and indexed virtual columns
+# 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 DEFAULT NOW and triggers
+# 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);
@@ -46,3 +46,24 @@ 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;