-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -211,8 +211,15 @@ func (c *Conn) writeAuthHandshake() error { | |
| capability := mysql.CLIENT_PROTOCOL_41 | mysql.CLIENT_SECURE_CONNECTION | | ||
| mysql.CLIENT_LONG_PASSWORD | mysql.CLIENT_TRANSACTIONS | mysql.CLIENT_PLUGIN_AUTH | ||
| // Adjust client capability flags based on server support | ||
| capability |= c.capability & mysql.CLIENT_LONG_FLAG | ||
| capability |= c.capability & mysql.CLIENT_QUERY_ATTRIBUTES | ||
| // ---- Inherit capabilities that the server has and the user has NOT explicitly denied ---- | ||
| inherit := c.capability & ^c.dcaps // Server-side capabilities minus explicit denies | ||
|
||
| capability |= inherit & mysql.CLIENT_LONG_FLAG // Existing | ||
| // ---- Handling of CLIENT_QUERY_ATTRIBUTES ---- | ||
| if c.ccaps&mysql.CLIENT_QUERY_ATTRIBUTES != 0 { // Explicitly ON | ||
| capability |= mysql.CLIENT_QUERY_ATTRIBUTES | ||
| } else if inherit&mysql.CLIENT_QUERY_ATTRIBUTES != 0 { // Server has it and no denial | ||
| capability |= mysql.CLIENT_QUERY_ATTRIBUTES | ||
| } | ||
| // Adjust client capability flags on specific client requests | ||
| // Only flags that would make any sense setting and aren't handled elsewhere | ||
| // in the library are supported here | ||
|
|
@@ -361,5 +368,7 @@ func (c *Conn) writeAuthHandshake() error { | |
| data[pos] = 0x03 | ||
| } | ||
|
|
||
| c.capability = capability // update capability to the one we sent | ||
|
|
||
| return c.WritePacket(data) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ type Conn struct { | |
| capability uint32 | ||
| // client-set capabilities only | ||
| ccaps uint32 | ||
| dcaps uint32 // disabled capabilities | ||
|
||
|
|
||
| attributes map[string]string | ||
|
|
||
|
|
@@ -236,12 +237,14 @@ func (c *Conn) Ping() error { | |
|
|
||
| // SetCapability enables the use of a specific capability | ||
| func (c *Conn) SetCapability(cap uint32) { | ||
| c.dcaps &^= cap | ||
| c.ccaps |= cap | ||
| } | ||
|
|
||
| // UnsetCapability disables the use of a specific capability | ||
| func (c *Conn) UnsetCapability(cap uint32) { | ||
| c.ccaps &= ^cap | ||
| c.ccaps &^= cap | ||
| c.dcaps |= cap | ||
| } | ||
|
|
||
| // HasCapability returns true if the connection has the specific capability | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to specially process CLIENT_QUERY_ATTRIBUTES. There are 3 states of capability:
SetCapability, which means theccapsbit is 1 and thedcapsbit is 0UnsetCapability, which meansccapsbit is 0 and thedcapsbit is 1So here we turn on the bits by
ccapsat around line 219, and have another round to turn off bits bydcaps. I suggest