Skip to content

Set library specific connection attributes #788

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

Merged
merged 3 commits into from
May 6, 2023

Conversation

dveeden
Copy link
Collaborator

@dveeden dveeden commented May 5, 2023

Set connection attributes like _platform, _os, _client_name, etc. by default.

Have SetAttributes() update the map instead of overwriting it.

This makes it behave similar to other MySQL clients.

See also: https://dev.mysql.com/doc/refman/8.0/en/performance-schema-connection-attribute-tables.html

Wireshark:
image

Example:

package main

import "github.com/go-mysql-org/go-mysql/client"

func main() {
	conn, _ := client.Connect("127.0.0.1:4000", "root", "", "test", func(c *client.Conn) {
		c.SetAttributes(map[string]string{"app": "myapp"})
	})

	conn.Ping()
	conn.Close()
}

@lance6716 lance6716 merged commit 77430c6 into go-mysql-org:master May 6, 2023
@dveeden dveeden mentioned this pull request May 7, 2023
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 this pull request may close these issues.

2 participants