Skip to content

Connection collations limit use of custom collation specification #1603

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

Closed
SpencerMalone opened this issue Jul 8, 2024 · 0 comments · Fixed by #1604
Closed

Connection collations limit use of custom collation specification #1603

SpencerMalone opened this issue Jul 8, 2024 · 0 comments · Fixed by #1604

Comments

@SpencerMalone
Copy link

SpencerMalone commented Jul 8, 2024

Issue description

According to: https://github.com/go-sql-driver/mysql?tab=readme-ov-file#unicode-support

When only the charset is specified, the SET NAMES query is sent and the server's default collation is used.
When both the charset and collation are specified, the SET NAMES COLLATE query is sent.
When only the collation is specified, the collation is specified in the protocol handshake and the SET NAMES query is not sent. This can save one roundtrip, but note that the server may ignore the specified collation silently and use the server's default charset/collation instead.

Unfortunately, the limits imposed by https://github.com/go-sql-driver/mysql/blob/master/packets.go#L325-L336 seem to apply regardless of if you are the only collation case or the both charset and collation case, which limits the use of "similar but not the same" newer mysql collations, such as utf8mb4_0900_as_ci (notice this is the as / accent sensitive collation, not ai_ci)

Example code

	db, err := sql.Open("mysql", "user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&collation=utf8mb4_0900_as_ci")
	if err != nil {
		panic(err.Error())
	}
	defer db.Close()

	err = db.Ping()
	if err != nil {
		panic(err.Error())
	}

Error log

*errors.errorString: unknown collation: "utf8mb4_0900_as_ci"

Configuration

*Driver version (or git SHA):*v1.8.1

Go version: go version go1.22.0 darwin/amd64

Server version: Mysql 8.x

methane added a commit that referenced this issue Aug 30, 2024
methane added a commit to methane/mysql that referenced this issue Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant