diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-11-13 13:40:11 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-11-13 13:40:11 +0100 |
commit | 6a2c1701412d3951b7bae2f683e646b75b916cd2 (patch) | |
tree | 9f18977d2aa844f5f7baeccf747d506222af650f /mysql-test | |
parent | 815667086cfa4ee28eb1bdc88d5ae86755c71b72 (diff) | |
download | mariadb-git-6a2c1701412d3951b7bae2f683e646b75b916cd2.tar.gz |
MDEV-6849 ON UPDATE CURRENT_TIMESTAMP doesn't always work
reset default fields not for every modified row, but only once,
at the beginning, as the set of modified fields doesn't change.
exception: INSERT ... ON DUPLICATE KEY UPDATE - the set of fields
does change per row and in that case we reset default fields per row.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/include/function_defaults.inc | 17 | ||||
-rw-r--r-- | mysql-test/r/function_defaults.result | 42 |
2 files changed, 49 insertions, 10 deletions
diff --git a/mysql-test/include/function_defaults.inc b/mysql-test/include/function_defaults.inc index e588c82df1b..ae058eddff6 100644 --- a/mysql-test/include/function_defaults.inc +++ b/mysql-test/include/function_defaults.inc @@ -408,15 +408,28 @@ UPDATE t1 SET c = 2; SELECT * FROM t1; --echo # +--echo # Test that ON UPDATE CURRENT_TIMESTAMP works after non-changing UPDATE. +--echo # + +--echo # 2011-04-20 09:54:13 UTC +SET TIMESTAMP = 1303293253.794613; + +UPDATE t1 SET c = 2, b = '2011-04-20 09:53:41.794613'; +SELECT * FROM t1; + +UPDATE t1 SET c = 3; +SELECT * FROM t1; + +--echo # --echo # Test of multiple-table UPDATE for ON UPDATE CURRENT_TIMESTAMP --echo # --echo # 2011-04-20 15:06:13 UTC SET TIMESTAMP = 1303311973.534231; -UPDATE t1 t11, t1 t12 SET t11.c = 2; +UPDATE t1 t11, t1 t12 SET t11.c = 3; SELECT * FROM t1; -UPDATE t1 t11, t1 t12 SET t11.c = 3; +UPDATE t1 t11, t1 t12 SET t11.c = 2; SELECT * FROM t1; DROP TABLE t1; diff --git a/mysql-test/r/function_defaults.result b/mysql-test/r/function_defaults.result index 27b9ee0a323..105e899ea08 100644 --- a/mysql-test/r/function_defaults.result +++ b/mysql-test/r/function_defaults.result @@ -435,18 +435,31 @@ SELECT * FROM t1; a b c 2011-04-20 09:53:41 2011-04-20 09:53:41 2 # +# Test that ON UPDATE CURRENT_TIMESTAMP works after non-changing UPDATE. +# +# 2011-04-20 09:54:13 UTC +SET TIMESTAMP = 1303293253.794613; +UPDATE t1 SET c = 2, b = '2011-04-20 09:53:41.794613'; +SELECT * FROM t1; +a b c +2011-04-20 09:53:41 2011-04-20 09:53:41 2 +UPDATE t1 SET c = 3; +SELECT * FROM t1; +a b c +2011-04-20 09:54:13 2011-04-20 09:54:13 3 +# # Test of multiple-table UPDATE for ON UPDATE CURRENT_TIMESTAMP # # 2011-04-20 15:06:13 UTC SET TIMESTAMP = 1303311973.534231; -UPDATE t1 t11, t1 t12 SET t11.c = 2; +UPDATE t1 t11, t1 t12 SET t11.c = 3; SELECT * FROM t1; a b c -2011-04-20 09:53:41 2011-04-20 09:53:41 2 -UPDATE t1 t11, t1 t12 SET t11.c = 3; +2011-04-20 09:54:13 2011-04-20 09:54:13 3 +UPDATE t1 t11, t1 t12 SET t11.c = 2; SELECT * FROM t1; a b c -2011-04-20 15:06:13 2011-04-20 15:06:13 3 +2011-04-20 15:06:13 2011-04-20 15:06:13 2 DROP TABLE t1; # # Test of a multiple-table update where only one table is updated and @@ -1967,18 +1980,31 @@ SELECT * FROM t1; a b c 2011-04-20 09:53:41.794613 2011-04-20 09:53:41.794613 2 # +# Test that ON UPDATE CURRENT_TIMESTAMP works after non-changing UPDATE. +# +# 2011-04-20 09:54:13 UTC +SET TIMESTAMP = 1303293253.794613; +UPDATE t1 SET c = 2, b = '2011-04-20 09:53:41.794613'; +SELECT * FROM t1; +a b c +2011-04-20 09:53:41.794613 2011-04-20 09:53:41.794613 2 +UPDATE t1 SET c = 3; +SELECT * FROM t1; +a b c +2011-04-20 09:54:13.794613 2011-04-20 09:54:13.794613 3 +# # Test of multiple-table UPDATE for ON UPDATE CURRENT_TIMESTAMP # # 2011-04-20 15:06:13 UTC SET TIMESTAMP = 1303311973.534231; -UPDATE t1 t11, t1 t12 SET t11.c = 2; +UPDATE t1 t11, t1 t12 SET t11.c = 3; SELECT * FROM t1; a b c -2011-04-20 09:53:41.794613 2011-04-20 09:53:41.794613 2 -UPDATE t1 t11, t1 t12 SET t11.c = 3; +2011-04-20 09:54:13.794613 2011-04-20 09:54:13.794613 3 +UPDATE t1 t11, t1 t12 SET t11.c = 2; SELECT * FROM t1; a b c -2011-04-20 15:06:13.534231 2011-04-20 15:06:13.534231 3 +2011-04-20 15:06:13.534231 2011-04-20 15:06:13.534231 2 DROP TABLE t1; # # Test of a multiple-table update where only one table is updated and |