Skip to content

[Bug]: JOIN UPDATE on ENUM or YEAR panics in null-safe comparison #33394

Todo

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Searched open and closed issues for joined/multi-table UPDATE with ENUM or YEAR, nullSafeEqualFn, SMALLINT UNSIGNED vector to []types.Enum, and BIGINT vector to []types.MoYear. Closed #31901 concerns an ENUM/SMALLINT UNSIGNED comparison panic in ordinary SELECT. The baseline tested here includes its fix PR #32358 (merge commit fbcca458c3f8543236594841f22914cec78c0e3f), but the JOIN UPDATE changed-row predicate still produces the related ENUM mismatch and a separate YEAR mismatch. The original SELECT report does not cover either UPDATE reproduction.

Branch Name

main

Commit ID

c0cef5c

Other Environment Information

  • Hardware parameters: single-CN local deployment
  • OS type: macOS
  • Others: MySQL 8.0.46 used as a differential control; both engines ran the same reproducer twice

Actual Behavior

A JOIN UPDATE that assigns a valid string literal to an ENUM or YEAR target fails with Error 20101 and an internal vector type panic:

-- ENUM
internal error: panic type mismatch: casting SMALLINT UNSIGNED vector to []types.Enum

-- YEAR
internal error: panic type mismatch: casting BIGINT vector to []types.MoYear

The stack goes through nullSafeEqualFn. Assigning the ENUM's existing value also panics, so this is not limited to values that actually change. Each failed statement leaves the original value unchanged.

Single-table UPDATE succeeds for both types. A JOIN UPDATE to a SET column also succeeds, as does the broader joined-update control matrix for ordinary scalar types.

MySQL 8.0.46 successfully executes both joined updates in both rounds and stores ENUM a and YEAR 2026.

Expected Behavior

Valid joined updates should execute without an internal panic and store the assigned values. The changed-row/null-safe comparison must use type metadata consistent with the physical vectors produced by the UPDATE plan.

Steps to Reproduce

DROP DATABASE IF EXISTS repro_join_update_enum_year;
CREATE DATABASE repro_join_update_enum_year;
USE repro_join_update_enum_year;

CREATE TABLE e(id INT PRIMARY KEY, v ENUM('a','b','c') NOT NULL);
CREATE TABLE y(id INT PRIMARY KEY, v YEAR NOT NULL);
CREATE TABLE x(id INT PRIMARY KEY);

INSERT INTO e VALUES(1,'b');
INSERT INTO y VALUES(1,'2020');
INSERT INTO x VALUES(1);

UPDATE e JOIN x ON e.id=x.id SET e.v='a';
-- MatrixOne Error 20101:
-- casting SMALLINT UNSIGNED vector to []types.Enum
SELECT id,v,v+0 FROM e; -- still (1,'b',2)

UPDATE y JOIN x ON y.id=x.id SET y.v='2026';
-- MatrixOne Error 20101:
-- casting BIGINT vector to []types.MoYear
SELECT id,v FROM y;       -- still (1,2020)

-- Positive controls: both succeed.
UPDATE e SET v='a' WHERE id=1;
UPDATE y SET v='2026' WHERE id=1;

Additional Information

In pkg/sql/plan/bind_update.go, makeUpdateChangedRowsPredicate constructs the new-side expression with Typ: oldTyp and binds oldExpr <=> newExpr. For these joined assignments, the actual new-value projections are SMALLINT UNSIGNED for ENUM and BIGINT for YEAR. nullSafeEqualFn then reads the vectors as types.Enum or types.MoYear, causing the checked vector conversion to panic. The defect is therefore in the joined UPDATE changed-row predicate's type contract, not in the validity of the input literals.

Activity

  1. added this to the MO-202611 milestone on Nov 27, 2026
  2. added
    kind/bug
    on Nov 27, 2026
  3. added theissue type on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions