Commit a3d0115
Fix Warning 1300 for varbinary columns with bytes invalid as utf8mb4 (#1661)
* Fix Warning 1300 for varbinary columns with bytes invalid as utf8mb4
When gh-ost replays a binlog DML event, the go-mysql library returns
varbinary column values as a Go `string` (not `[]byte`). In convertArg,
the existing code only converted string → []byte when the column had a
non-empty Charset (e.g. utf8mb4 for varchar). varbinary columns have no
character set, so Charset is always "", and the string fell through
unconverted.
The Go MySQL driver sends `string` args as MYSQL_TYPE_VAR_STRING with
the connection's utf8mb4 charset metadata attached, causing MySQL to
validate the bytes. If a varbinary value (e.g. a binary UUID) contains
byte sequences that are invalid utf8mb4, MySQL emits Warning 1300. With
gh-ost's panic-on-warnings enabled, this aborts the migration.
Fix: add an else-if branch that detects binary storage types by
MySQLType (binary, varbinary, *blob) and returns []byte, so the driver
sends MYSQL_TYPE_BLOB (binary data) with no charset validation.
MySQLType is used rather than Charset == "" alone because test Column
objects built via NewColumnList leave MySQLType unset, which would have
changed the return type for all no-charset columns in existing tests.
In production, inspect.go always populates MySQLType from
information_schema.data_type.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Address PR review feedback on varbinary Warning 1300 fix
- Use MySQLType "varbinary(16)" in tests instead of bare "varbinary",
matching the real value produced by information_schema COLUMN_TYPE
(which includes length). Guards against future refactors that might
switch from substring matching to exact matching.
- Correct test comment: MySQLType is populated from COLUMN_TYPE, not
data_type.
- Broaden types.go comment to say "the connection's charset/collation
metadata (often utf8mb4)" since gh-ost's connection charset is
configurable via --charset.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* appease linter
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: meiji163 <meiji163@github.com>1 parent 0270a28 commit a3d0115
2 files changed
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
73 | 80 | | |
74 | 81 | | |
75 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
98 | 139 | | |
99 | 140 | | |
100 | 141 | | |
| |||
0 commit comments