File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -211,8 +211,15 @@ func (c *Conn) writeAuthHandshake() error {
211
211
capability := mysql .CLIENT_PROTOCOL_41 | mysql .CLIENT_SECURE_CONNECTION |
212
212
mysql .CLIENT_LONG_PASSWORD | mysql .CLIENT_TRANSACTIONS | mysql .CLIENT_PLUGIN_AUTH
213
213
// Adjust client capability flags based on server support
214
- capability |= c .capability & mysql .CLIENT_LONG_FLAG
215
- capability |= c .capability & mysql .CLIENT_QUERY_ATTRIBUTES
214
+ // ---- Inherit capabilities that the server has and the user has NOT explicitly denied ----
215
+ inherit := c .capability & ^ c .dcaps // Server-side capabilities minus explicit denies
216
+ capability |= inherit & mysql .CLIENT_LONG_FLAG // Existing
217
+ // ---- Handling of CLIENT_QUERY_ATTRIBUTES ----
218
+ if c .ccaps & mysql .CLIENT_QUERY_ATTRIBUTES != 0 { // Explicitly ON
219
+ capability |= mysql .CLIENT_QUERY_ATTRIBUTES
220
+ } else if inherit & mysql .CLIENT_QUERY_ATTRIBUTES != 0 { // Server has it and no denial
221
+ capability |= mysql .CLIENT_QUERY_ATTRIBUTES
222
+ }
216
223
// Adjust client capability flags on specific client requests
217
224
// Only flags that would make any sense setting and aren't handled elsewhere
218
225
// in the library are supported here
@@ -361,5 +368,7 @@ func (c *Conn) writeAuthHandshake() error {
361
368
data [pos ] = 0x03
362
369
}
363
370
371
+ c .capability = capability // update capability to the one we sent
372
+
364
373
return c .WritePacket (data )
365
374
}
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ type Conn struct {
45
45
capability uint32
46
46
// client-set capabilities only
47
47
ccaps uint32
48
+ dcaps uint32 // disabled capabilities
48
49
49
50
attributes map [string ]string
50
51
@@ -236,12 +237,14 @@ func (c *Conn) Ping() error {
236
237
237
238
// SetCapability enables the use of a specific capability
238
239
func (c * Conn ) SetCapability (cap uint32 ) {
240
+ c .dcaps &^= cap
239
241
c .ccaps |= cap
240
242
}
241
243
242
244
// UnsetCapability disables the use of a specific capability
243
245
func (c * Conn ) UnsetCapability (cap uint32 ) {
244
- c .ccaps &= ^ cap
246
+ c .ccaps &^= cap
247
+ c .dcaps |= cap
245
248
}
246
249
247
250
// HasCapability returns true if the connection has the specific capability
You can’t perform that action at this time.
0 commit comments