Bug #118152 BEFORE UPDATE trigger does not use correct NEW.val when val is ON UPDATE CURRENT_TIMESTAMP
Submitted: 9 May 8:45 Modified: 9 May 9:45
Reporter: Fei Yang Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:8.0.42,8.4.5,9.2.0 OS:Any
Assigned to: CPU Architecture:Any

[9 May 8:45] Fei Yang
Description:
When updating a partitioned table using a JOIN operation, if the partition key is modified, the referenced NEW.val does not correctly reflect CURRENT_TIMESTAMP as expected.

got

> select * from t1
+---------------------+---+
| a                   | b |
+---------------------+---+
| 2017-04-25 01:01:01 | 2 |
+---------------------+---+
> select @x
+---------------------+
| @x                  |
+---------------------+
| 2017-04-25 11:11:11 |
+---------------------+

explected

> select * from t1
+---------------------+---+
| a                   | b |
+---------------------+---+
| 2017-04-25 01:01:01 | 2 |
+---------------------+---+
> select @x
+---------------------+
| @x                  |
+---------------------+
| 2017-04-25 01:01:01 |
+---------------------+

How to repeat:
drop table if exists t1, t2;
drop trigger if exists trigger_before_update_with_join;
SET TIMESTAMP= UNIX_TIMESTAMP("2017-04-25 11:11:11");
CREATE TABLE t1( a DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, b INT) partition by range (b) (partition p0 values less than(10000), partition p1 values less than maxvalue);
CREATE TABLE t2( d INT);
INSERT INTO t1(b) VALUES(1);
INSERT INTO t2 VALUES(2);
CREATE TRIGGER trigger_before_update_with_join BEFORE UPDATE ON t1 FOR EACH ROW SET @x:= NEW.a;
SET TIMESTAMP= UNIX_TIMESTAMP("2017-04-25 01:01:01");
UPDATE t1, t2 SET t1.b= t2.d;
SELECT * FROM t1;
SELECT @x;
[9 May 9:45] MySQL Verification Team
Hello Fei Yang,

Thank you for the report and test case.
Verified as described.

regards,
Umesh