Skip to content

[cdc] Return an empty string for canal/aliyun enum index 0 - #10371

Open
jackylee-ch wants to merge 1 commit into
apache:masterfrom
jackylee-ch:cdc-enum-index-guard
Open

jackylee-ch wants to merge 1 commit into
apache:masterfrom
jackylee-ch:cdc-enum-index-guard

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

Purpose

CanalFieldParser and AliyunFieldParser decode a MySQL enum value by indexing
options[elementIndex - 1]. MySQL stores index 0 for an empty or invalid enum value
(e.g. a value inserted outside the declared members under a non-strict SQL mode), so a row
carrying it made the index -1 and threw ArrayIndexOutOfBoundsException, failing the
whole canal / aliyun-DTS sync job.

This maps a non-positive index to the empty string — MySQL's own representation of that
value — before indexing. Valid 1-based indices are unchanged.

Tests

CanalFieldParserTest / AliyunFieldParserTest assert index 0 yields the empty string
and that valid indices still resolve to their members; both threw
ArrayIndexOutOfBoundsException before the change.

API and Format

No change.

Documentation

No change.

CanalFieldParser and AliyunFieldParser decode a MySQL enum by indexing
options[elementIndex - 1]. MySQL stores index 0 for an empty or invalid
enum value, so a row carrying it made the index -1 and threw
ArrayIndexOutOfBoundsException, failing the sync job. Map a non-positive
index to the empty string, which is MySQL's own representation of that
value; valid 1-based indices are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant