node-mysql2
node-mysql2 copied to clipboard
writeString and readString default encoding
There is a bug in connection.createBinlogStream() as there is a missing encoding. we should set the default encoding, once the encoding is empty.
I'd probably prefer to treat encoding as required parameter for read/writeString. Can you reproduce issue again ant trace who called them without setting encoding? It's better to fix caller
https://github.com/sidorares/node-mysql2/blob/5f0fb8f1f5035e2c0207490aa2f0b838dc82fdc2/lib/packets/binlog_dump.js#L26
https://github.com/sidorares/node-mysql2/blob/5f0fb8f1f5035e2c0207490aa2f0b838dc82fdc2/lib/commands/binlog_dump.js#L55
https://github.com/sidorares/node-mysql2/blob/5f0fb8f1f5035e2c0207490aa2f0b838dc82fdc2/lib/commands/binlog_dump.js#L59
https://github.com/sidorares/node-mysql2/blob/5f0fb8f1f5035e2c0207490aa2f0b838dc82fdc2/lib/commands/binlog_dump.js#L32
https://github.com/sidorares/node-mysql2/blob/5f0fb8f1f5035e2c0207490aa2f0b838dc82fdc2/lib/commands/binlog_dump.js#L38
I have tried to fix the caller, but due to some readString() is reading the whole length. It's hard to pass the length to the first argument in order to setting the encoding at the second argument. Any ideas?
you can do .readString(undefined, encoding). And encoding is probably sent somewhere at the beginning - there is no way it can be undefined or assumed utf8 by default due to mysql history ( binlog protocol is older than utf )