node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

writeString and readString default encoding

Open shtse8 opened this issue 8 years ago • 4 comments

There is a bug in connection.createBinlogStream() as there is a missing encoding. we should set the default encoding, once the encoding is empty.

shtse8 avatar Nov 20 '17 14:11 shtse8

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

sidorares avatar Nov 20 '17 22:11 sidorares

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

shtse8 avatar Nov 21 '17 10:11 shtse8

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?

shtse8 avatar Nov 21 '17 11:11 shtse8

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 )

sidorares avatar Nov 21 '17 12:11 sidorares