Skip to content
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

server: set CLIENT_CONNECT_ATTRS #975

Merged
merged 3 commits into from
Jan 25, 2025
Merged

Conversation

dveeden
Copy link
Collaborator

@dveeden dveeden commented Jan 24, 2025

package main

import (
	"net"

	"github.com/go-mysql-org/go-mysql/server"
)

func main() {
	l, _ := net.Listen("tcp", "127.0.0.1:4000")
	c, _ := l.Accept()
	conn, _ := server.NewConn(c, "root", "", server.EmptyHandler{})
	for akey, aval := range conn.Attributes() {
		println(akey, aval)
	}
}
go run main.go
mysql -h 127.0.0.1 -P 4000 -u root 

With this PR there is output, without this PR there is not (unless one would explicitly set CLIENT_CONNECT_ATTRS)

_client_name libmysql
os_user dvaneeden
_client_version 9.2.0
program_name mysql
_pid 470697
_platform x86_64
_os Linux

@dveeden
Copy link
Collaborator Author

dveeden commented Jan 24, 2025

Compatibility testing:

mycli 1.27.2

dvaneeden@dve-carbon:/tmp/attrs$ go run main.go 
_client_name pymysql
_client_version 1.1.1
_pid 472593
program_name mycli

MySQL 5.7.31

dvaneeden@dve-carbon:/tmp/attrs$ go run main.go 
_platform x86_64
program_name mysql
_os linux-glibc2.12
_client_name libmysql
_pid 473779
_client_version 5.7.31

MySQL 5.6.44

dvaneeden@dve-carbon:/tmp/attrs$ go run main.go 
_client_name libmysql
_pid 473985
_client_version 5.6.44
_platform x86_64
program_name mysql
_os linux-glibc2.12

MySQL 5.5.62 (not sending anything)

dvaneeden@dve-carbon:/tmp/attrs$ go run main.go 

@dveeden dveeden added the server label Jan 24, 2025
@lance6716 lance6716 merged commit d00dff7 into go-mysql-org:master Jan 25, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants