[Bug]: ON DUPLICATE KEY UPDATE rejects direct ENUM/SET string assignments
メンテナーはふだん 1 日以内に返信
評価
この issue はまだ評価されていません。
説明
Description
Reproduced in 2/2 fresh runs on MatrixOne main commit c0cef5c9cce2164fedd201c188bfffe4d2d09a96 (git_version() = c0cef5c) and compared with MySQL 8.0.46.
INSERT ... ON DUPLICATE KEY UPDATE rejects a valid string literal assigned directly to an ENUM or SET column with internal Error 20203. The same value works through ODKU VALUES(v) and through an ordinary UPDATE; MySQL accepts all of these forms. Thus the failure is specific to the ODKU assignment-conversion path, not an invalid ENUM/SET value.
Minimal reproduction
DROP DATABASE IF EXISTS repro_odku_enum_set;
CREATE DATABASE repro_odku_enum_set;
USE repro_odku_enum_set;
CREATE TABLE e(
id INT PRIMARY KEY,
v ENUM('a','b','c') NOT NULL
);
CREATE TABLE s(
id INT PRIMARY KEY,
v SET('a','b','c') NOT NULL
);
INSERT INTO e VALUES(1,'c');
INSERT INTO s VALUES(1,'a');
-- ENUM: direct string assignment fails on MatrixOne.
INSERT INTO e(id,v) VALUES(1,'a')
ON DUPLICATE KEY UPDATE v='a';
-- MatrixOne:
-- ERROR 20203: invalid argument operator cast, bad value [VARCHAR ENUM]
-- MySQL 8.0.46: succeeds and changes v to 'a'.
SELECT id,v,v+0 FROM e;
-- MatrixOne after the failed statement: (1,'c',3), so the old row is unchanged.
-- Positive ODKU controls on the same table.
INSERT INTO e(id,v) VALUES(1,'a')
ON DUPLICATE KEY UPDATE v=VALUES(v);
SELECT id,v,v+0 FROM e;
-- both: (1,'a',1)
INSERT INTO e(id,v) VALUES(1,3)
ON DUPLICATE KEY UPDATE v=3;
SELECT id,v,v+0 FROM e;
-- both: (1,'c',3)
UPDATE e SET v='a' WHERE id=1;
SELECT id,v,v+0 FROM e;
-- both: (1,'a',1)
-- SET: direct string assignment fails on MatrixOne.
INSERT INTO s(id,v) VALUES(1,'b,c')
ON DUPLICATE KEY UPDATE v='b,c';
-- MatrixOne:
-- ERROR 20203: invalid argument cast to uint64, bad value b,c
-- MySQL 8.0.46: succeeds and changes v to 'b,c'.
SELECT id,v,v+0 FROM s;
-- MatrixOne after the failed statement: (1,'a',1), so the old row is unchanged.
INSERT INTO s(id,v) VALUES(1,'b,c')
ON DUPLICATE KEY UPDATE v=VALUES(v);
SELECT id,v,v+0 FROM s;
-- both: (1,'b,c',6)
UPDATE s SET v='a' WHERE id=1;
SELECT id,v,v+0 FROM s;
-- both: (1,'a',1)
Expected behavior
The two direct-string ODKU statements must perform the duplicate-key update, just as they do in MySQL 8.0.46 and in the VALUES(v)/ordinary-UPDATE controls. They must not expose an internal cast error for a value accepted by the column type.
Additional scope and code analysis
The same ODKU path also rejects CONCAT(...) and CAST(... AS CHAR) string expressions. A prepared ENUM ODKU with placeholders can fail during PREPARE with the analogous [TEXT ENUM] cast error, so this is not limited to hard-coded literals. A type-matrix control over numeric, string/binary, temporal, BIT, YEAR, UUID, JSON, and GEOMETRY columns found the direct-assignment discrepancy confined to ENUM/SET.
At the tested commit, pkg/sql/plan/ondup_update_binder.go uses the generic MakePlan2CastExpr for the update assignment instead of the ENUM/SET-aware assignment conversion used by ordinary INSERT/UPDATE paths.
Duplicate check
Searched open and closed issues for ODKU ENUM/SET string assignment and both error strings. #31958 is an ENUM UNIQUE-key ODKU planning panic; #33226 concerns ordinary UPDATE ... SET v=DEFAULT writing the wrong value; #33229 concerns persisted CHECK/generated-column ordinal semantics; #14970 is CTAS VARCHAR-to-ENUM conversion. None covers this direct ODKU assignment failure.
- 主要言語
- Go
- スター
- 1.9k
- フォーク
- 312
- 平均マージ
- 22時間 59分
- マージ済み PR(30日)
- 736
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
matrixorigin/matrixone のほかの issue
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
matrixorigin/matrixone#33363 ·
メンテナーはふだん 1 日以内に返信
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
matrixorigin/matrixone#33362 ·
メンテナーはふだん 1 日以内に返信
-
SLEEP rejects NULL and negative durations that MySQL accepts対応中かも @XuPeng-SH が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
matrixorigin/matrixone#32653 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: TestChangeWatchProxy loses its first tenant connection during PingContext in Ubuntu CI対応中かも @XuPeng-SH が今日担当しました。 オープンkind/bug needs-triage
matrixorigin/matrixone#33371 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: TestDaemonClaimSQLRoundTrip exhausts its shared deadline during the stale claim update in Ubuntu CI対応中かも @XuPeng-SH が今日担当しました。 オープンkind/bug needs-triage
matrixorigin/matrixone#33370 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
matrixorigin/matrixone の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
pg-sharding/spqr#3314 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
slavakurilyak/awesome-ai-agents#1051 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
google-gemini/gemini-api-cli#247 ·
メンテナーはふだん 1 日以内に返信