Skip to content

Commit fbd6532

Browse files
committed
[FLINK-40087] Fix MySqlDefaultValueConverter fails to parse charset-introducer default values wrapped in double quotes and/or containing padding spaces (e.g. _UTF8MB4" 0 ")
1 parent b056f71 commit fbd6532

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/table/MySqlConnectorITCase.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,29 +1749,29 @@ void testAlterWithCharsetIntroducerDefaultValue() throws Exception {
17491749
}
17501750

17511751
/**
1752-
* Integration test for the <b>snapshot</b> code path when a table is created with columns
1753-
* whose {@code DEFAULT} clause carries a character-set introducer plus padding spaces inside
1754-
* the quotes (both single-quoted {@code _utf8mb4' 0 '} and double-quoted {@code _UTF8MB4" 0 "}
1752+
* Integration test for the <b>snapshot</b> code path when a table is created with columns whose
1753+
* {@code DEFAULT} clause carries a character-set introducer plus padding spaces inside the
1754+
* quotes (both single-quoted {@code _utf8mb4' 0 '} and double-quoted {@code _UTF8MB4" 0 "}
17551755
* forms).
17561756
*
17571757
* <p>Default values are parsed in two different code paths inside the connector: during the
17581758
* snapshot phase the schema is discovered by {@code SHOW CREATE TABLE} whose output is
17591759
* re-parsed by the Debezium Antlr parser, and during the incremental phase the {@code ALTER
1760-
* TABLE} statements coming from the binlog are parsed on the fly. Both eventually flow
1761-
* through {@link io.debezium.connector.mysql.MySqlDefaultValueConverter#convert}.
1760+
* TABLE} statements coming from the binlog are parsed on the fly. Both eventually flow through
1761+
* {@link io.debezium.connector.mysql.MySqlDefaultValueConverter#convert}.
17621762
*
17631763
* <p>Empirically the MySQL server <b>normalizes</b> such default value expressions on the
17641764
* server side before persisting them, so {@code SHOW CREATE TABLE} returns the fully
17651765
* canonicalized form (e.g. {@code DEFAULT '0'}) regardless of what the user originally wrote.
17661766
* That means the snapshot path never actually observes the introducer / padding shape and
1767-
* cannot serve as a reverse reproduction for this bug (the reverse reproduction is
1768-
* exclusively covered by {@link #testAlterWithCharsetIntroducerDefaultValue()} which feeds
1769-
* the raw DDL to Debezium via the binlog). This case therefore acts as a <b>positive
1770-
* verification</b> that the current fix does not introduce any side effect on the snapshot
1771-
* schema discovery path: the source must reach RUNNING, the snapshot must yield the initial
1772-
* rows, and a subsequent binlog INSERT relying on server-side defaults must also flow
1773-
* through, wiring both parsing paths end to end. Combined with the no-restart strategy, any
1774-
* regression on the snapshot side would fail the case via {@code fetchRows} timing out.
1767+
* cannot serve as a reverse reproduction for this bug (the reverse reproduction is exclusively
1768+
* covered by {@link #testAlterWithCharsetIntroducerDefaultValue()} which feeds the raw DDL to
1769+
* Debezium via the binlog). This case therefore acts as a <b>positive verification</b> that the
1770+
* current fix does not introduce any side effect on the snapshot schema discovery path: the
1771+
* source must reach RUNNING, the snapshot must yield the initial rows, and a subsequent binlog
1772+
* INSERT relying on server-side defaults must also flow through, wiring both parsing paths end
1773+
* to end. Combined with the no-restart strategy, any regression on the snapshot side would fail
1774+
* the case via {@code fetchRows} timing out.
17751775
*/
17761776
@Test
17771777
void testSnapshotWithCharsetIntroducerDefaultValue() throws Exception {
@@ -1874,8 +1874,7 @@ void testSnapshotWithCharsetIntroducerDefaultValue() throws Exception {
18741874
statement.execute("INSERT INTO snapshot_cs_default_test (id) VALUES (3);");
18751875
}
18761876

1877-
String[] expected =
1878-
new String[] {"+I[1, 0, 0]", "+I[2, 0, 0]", "+I[3, 0, 0]"};
1877+
String[] expected = new String[] {"+I[1, 0, 0]", "+I[2, 0, 0]", "+I[3, 0, 0]"};
18791878
actualRows.addAll(fetchRows(iterator, expected.length - 2));
18801879
assertEqualsInAnyOrder(Arrays.asList(expected), actualRows);
18811880
jobClient.cancel().get();

0 commit comments

Comments
 (0)