Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Fresh open+closed searches covered UPDATE unicode_ci "ON UPDATE", UPDATE collation "CURRENT_TIMESTAMP" unchanged, makeUpdateChangedRowsPredicate, UPDATE "<=>" collation, "ON UPDATE CURRENT_TIMESTAMP" "unicode_ci", and "automatic ON UPDATE" collation. The only search hit was #33394, which concerns an ENUM/YEAR type-mismatch panic in joined UPDATE; it does not cover native-Unicode persisted timestamps or the physical-vs-collation changed-record decision.
Branch Name
main
Commit ID
Other Environment Information
- Isolated single-node MatrixOne runtime;
git_version()='98b20975'. - Differential reference: MySQL
8.0.46. - The complete matrix ran serially on both engines in two fresh-database rounds. All 204 fixed-oracle assertions passed, with zero semantic round drift.
- The oracle is the committed payload and timestamp, not the affected-row count.
Actual Behavior
For a utf8mb4_unicode_ci text column, ordinary UPDATE can persist new bytes while retaining the old automatic ON UPDATE CURRENT_TIMESTAMP value.
For example, after changing 'a' to 'A', MatrixOne stores v='A' but keeps ts='2000-01-01 00:00:00.000000'. MySQL stores the same new payload and refreshes ts.
MatrixOne builds its changed-row predicate using collation-aware null-safe SQL equality. Under utf8mb4_unicode_ci, 'a' <=> 'A' is true, so the predicate incorrectly classifies the assignment as unchanged and selects the old automatic timestamp. The explicitly assigned payload still comes from the new row image.
Expected Behavior
Automatic ON UPDATE should follow physical changed-record semantics, as MySQL does. Collation-equal but byte-different text is a real record change and must refresh an unassigned automatic timestamp.
Exact no-ops must continue to preserve the timestamp. Explicit timestamp assignments, NULL transitions, rollback, statement atomicity, and ODKU behavior must not be changed inadvertently.
Steps to Reproduce
DROP DATABASE IF EXISTS repro_onupdate_collation;
CREATE DATABASE repro_onupdate_collation;
USE repro_onupdate_collation;
CREATE TABLE t(
id INT PRIMARY KEY,
v VARCHAR(32) COLLATE utf8mb4_unicode_ci NULL,
n INT NOT NULL DEFAULT 0,
ts TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6)
ON UPDATE CURRENT_TIMESTAMP(6)
);
INSERT INTO t(id,v,n,ts)
VALUES(1,'a',0,'2000-01-01 00:00:00.000000');
UPDATE t SET v='A' WHERE id=1;
SELECT id,v,HEX(v) AS v_bytes,n,ts,
ts='2000-01-01 00:00:00.000000' AS stayed_fixed,
ts>'2000-01-01 00:00:00.000000' AS refreshed
FROM t WHERE id=1;Observed MatrixOne result:
id=1, v='A', v_bytes='41', n=0,
ts='2000-01-01 00:00:00', stayed_fixed=1, refreshed=0
MySQL 8.0.46 returns the same new payload and non-NULL n, but a current timestamp with stayed_fixed=0, refreshed=1.
The same root reproduces for:
- Accent- and expansion-equivalent changes:
'e'→'é'and'ss'→'ß'. - Trailing-space and empty/PAD-SPACE changes.
VARCHAR,CHAR, andTEXTpayload columns.- SQL
PREPARE/EXECUTE. - Committed state read through a fresh connection.
Matching controls validated on both engines include:
- Exact no-op, empty no-op, NULL no-op, and explicit
ts=ts: timestamp stays fixed. - Real text change,
utf8mb4_bin, NULL/value transitions, another genuinely changed column, and explicitts=CURRENT_TIMESTAMP(6): timestamp refreshes. - ODKU byte change refreshes on both engines; ODKU exact no-op stays fixed on both. This report is not an ODKU defect.
- Rollback restores the original row; a late second-row
NOT NULLerror leaves the complete row set unchanged.
Additional information
At this commit:
bind_update.go:877-900callsmakeUpdateChangedRowsPredicatefor an unassigned automaticON UPDATEcolumn.bind_update.go:126-190constructs per-column null-safe<=>comparisons and negates their conjunction.func_compare.go:706-722routes text comparison through collation semantics;collation_semantics.go:127-143compares native-Unicode collation keys rather than original bytes.bind_update.go:917-959rewrites the automatic expression toIF(changed,on_update_expr,old_value).bind_update.go:2336-2363independently selects the new explicit payload, producing the new-text/stale-timestamp combination.
MySQL 8.0 uses physical record comparison before automatic update functions: compare_records and set_function_defaults. Field_varstring::cmp_binary compares lengths and payload bytes, not collation equality.
A fix should preserve exact no-op handling and explicit timestamp assignments while making the automatic changed-record decision compatible with physical old/new images. The ODKU comparator is a useful control, but this report does not assume it is a drop-in ordinary-UPDATE fix.
Activity