Skip to content

client: make CLIENT_QUERY_ATTRIBUTES opt-out to restore proxy compatibility #1041

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ func (c *Conn) writeAuthHandshake() error {
c.ccaps&mysql.CLIENT_COMPRESS | c.ccaps&mysql.CLIENT_ZSTD_COMPRESSION_ALGORITHM |
c.ccaps&mysql.CLIENT_LOCAL_FILES

capability &^= c.clientExplicitOffCaps

// To enable TLS / SSL
if c.tlsConfig != nil {
capability |= mysql.CLIENT_SSL
Expand Down
12 changes: 9 additions & 3 deletions client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ type Conn struct {
capability uint32
// client-set capabilities only
ccaps uint32
// Capability flags explicitly disabled by the client via UnsetCapability()
// These flags are removed from the final advertised capability set during handshake.
clientExplicitOffCaps uint32

attributes map[string]string

Expand Down Expand Up @@ -234,14 +237,17 @@ func (c *Conn) Ping() error {
return nil
}

// SetCapability enables the use of a specific capability
// SetCapability marks the specified flag as explicitly enabled by the client.
func (c *Conn) SetCapability(cap uint32) {
c.ccaps |= cap
c.clientExplicitOffCaps &^= cap
}

// UnsetCapability disables the use of a specific capability
// UnsetCapability marks the specified flag as explicitly disabled by the client.
// This disables the flag even if the server supports it.
func (c *Conn) UnsetCapability(cap uint32) {
c.ccaps &= ^cap
c.ccaps &^= cap
c.clientExplicitOffCaps |= cap
}

// HasCapability returns true if the connection has the specific capability
Expand Down
Loading