Commit 31f81d2
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>1 parent 0270a28 commit 31f81d2
2 files changed
Lines changed: 47 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 | + | |
73 | 79 | | |
74 | 80 | | |
75 | 81 | | |
| |||
| 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