Skip to content

Commit d942f1b

Browse files
authored
client: make CLIENT_QUERY_ATTRIBUTES opt-out to restore proxy compatibility (#1041)
* feat: Update client capability flags Adjust client capability flags based on server support, and account for explicitly disabled capabilities. - client/auth.go: Update client capability flags - client/conn.go: Add field to manage disabled capabilities * feat: Update client capability flags Adjust client capability flags based on server support. Add a new field to manage explicitly disabled flags. - client/auth.go: Improve logic for adjusting client capability flags - client/conn.go: Add field to manage explicitly disabled flags * fix comment
1 parent 0468109 commit d942f1b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

client/auth.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ func (c *Conn) writeAuthHandshake() error {
222222
c.ccaps&mysql.CLIENT_COMPRESS | c.ccaps&mysql.CLIENT_ZSTD_COMPRESSION_ALGORITHM |
223223
c.ccaps&mysql.CLIENT_LOCAL_FILES
224224

225+
capability &^= c.clientExplicitOffCaps
226+
225227
// To enable TLS / SSL
226228
if c.tlsConfig != nil {
227229
capability |= mysql.CLIENT_SSL

client/conn.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ type Conn struct {
4545
capability uint32
4646
// client-set capabilities only
4747
ccaps uint32
48+
// Capability flags explicitly disabled by the client via UnsetCapability()
49+
// These flags are removed from the final advertised capability set during handshake.
50+
clientExplicitOffCaps uint32
4851

4952
attributes map[string]string
5053

@@ -234,14 +237,17 @@ func (c *Conn) Ping() error {
234237
return nil
235238
}
236239

237-
// SetCapability enables the use of a specific capability
240+
// SetCapability marks the specified flag as explicitly enabled by the client.
238241
func (c *Conn) SetCapability(cap uint32) {
239242
c.ccaps |= cap
243+
c.clientExplicitOffCaps &^= cap
240244
}
241245

242-
// UnsetCapability disables the use of a specific capability
246+
// UnsetCapability marks the specified flag as explicitly disabled by the client.
247+
// This disables the flag even if the server supports it.
243248
func (c *Conn) UnsetCapability(cap uint32) {
244-
c.ccaps &= ^cap
249+
c.ccaps &^= cap
250+
c.clientExplicitOffCaps |= cap
245251
}
246252

247253
// HasCapability returns true if the connection has the specific capability

0 commit comments

Comments
 (0)