-
Notifications
You must be signed in to change notification settings - Fork 1k
allow setting the collation in auth handshake #860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
5427a8d
10339dd
2f5a812
e6de19d
54ca96f
c7c5b97
541e284
4f41dc3
c471d01
993e339
ef8e800
447ea4f
5f0308a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import ( | |
"crypto/tls" | ||
"encoding/binary" | ||
"fmt" | ||
"github.com/pingcap/tidb/pkg/parser/charset" | ||
|
||
. "github.com/go-mysql-org/go-mysql/mysql" | ||
"github.com/go-mysql-org/go-mysql/packet" | ||
|
@@ -269,7 +270,16 @@ func (c *Conn) writeAuthHandshake() error { | |
|
||
// Charset [1 byte] | ||
// use default collation id 33 here, is utf-8 | ||
data[12] = DEFAULT_COLLATION_ID | ||
collationName := c.collation | ||
if len(collationName) == 0 { | ||
collationName = DEFAULT_COLLATION_NAME | ||
} | ||
collation, err := charset.GetCollationByName(collationName) | ||
if err != nil { | ||
return fmt.Errorf("invalid collation name %s", collationName) | ||
} | ||
|
||
data[12] = byte(collation.ID) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would overflow for some collations.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weirdly enough the protocol says this is 1 byte and that only the low 8-bits are put in this field. Not sure how that's going to work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A MySQL 8.0 Client only allows the user to set the charset, not the collation:
And as all default collations are in the 0-255 range this works with the protocol.
|
||
|
||
// SSL Connection Request Packet | ||
// http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest | ||
|
Uh oh!
There was an error while loading. Please reload this page.