- Notifications
You must be signed in to change notification settings - Fork 2.3k
Support for connection attributes#350
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
dveeden commented Jun 21, 2015
@julienschmidt I tried to fix everything you suggested in #343 |
julienschmidt commented Jun 21, 2015
ProTip™: You can update existing pull-requests by adding commits to the respective branch in your fork |
dgryski commented Feb 25, 2016
@julienschmidt What work remains before this can be merged? |
dgryski commented Feb 26, 2016
I am planning on rebasing this against master and to fix the merge conflicts and then will squash all the commits. |
packets.go Outdated
| } | ||
| pktLen:=4+4+1+23+len(mc.cfg.user) +1+1+len(scrambleBuff) +21+1 | ||
| pktLen+=attrlen+1// one byte to store the total length of attrs |
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.
Skip all this when clientConnectAttrs is missing in server capabilities
arnehormann commented Feb 26, 2016
@julienschmidt any blockers? |
510077a to c8528afComparedveeden commented Mar 15, 2016
cc @sjmudd |
dveeden commented Mar 15, 2016
Pushed a new version to get rid of the merge conflict in AUTHORS |
This sets attribute _client_name with the value "Go MySQL Driver" Also sets _os, _platform, _pid and program_name by default. This also decodes the uppper two bytes of the capability flags. The dsn_test.go only tests for one attribute because there is no guaranteed sort order for a map and Printf %+v as used by TestDSNParser().
dveeden commented Mar 29, 2016
Is there anything preventing this from getting merged? |
methane commented Mar 29, 2016
Are default attrs same to libmysqclient? |
arnehormann commented Mar 29, 2016
LGTM, sorry for the long wait |
| varpidstring | ||
| varos_userstring | ||
| varos_user_fullstring |
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.
Wrong naming convention
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.
Filed #442 for this lint issue.
julienschmidt commented Mar 29, 2016
Tests are also missing (parser tests are not sufficient). I'm tempted to revert this merge |
| MultiStatementsbool// Allow multiple statements in one query | ||
| ParseTimebool// Parse time values to time.Time | ||
| Strictbool// Return warnings as errors | ||
| ConnAttrsmap[string]string// Connection Attributes |
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.
A map[string]string is rather heavy. This could be pre-packed into 1 string
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.
forget what I said, this should stay user-friendly. The Config struct is now exported
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.
If we move this to a string than we would have to parse it every time we make a connection. So there is a trade-off.
arnehormann commented Mar 29, 2016
OK. Let's summerize: to get this remerged or fixed we need
|
julienschmidt commented Mar 29, 2016
Reverted for now. I think 99% of the users don't care about connections attributes. Should they maybe only be sent when a DSN param is set? |
arnehormann commented Mar 29, 2016
I can see their value, but requiring a DSN arg is fine by me. Do you have a preference for a
|
dveeden commented Mar 29, 2016
Instead of |
arnehormann commented Mar 29, 2016
|
julienschmidt commented Mar 29, 2016
Is it? RFC study time 😄 |
| data[pos] =byte(attrlen) | ||
| pos++ | ||
| forattrname, attrvalue:=rangeattrs{ |
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.
@dveeden That is what I meant. You could directly pack this into one byte sequence / string when the params are parsed.
But forget that, the Config is exported for a reason now.
dveeden commented Mar 29, 2016
What would you want in addition to the parser tests I added? |
julienschmidt commented Mar 29, 2016
A functional test |
julienschmidt commented Mar 29, 2016
And is this backwards-compatible? |
arnehormann commented Mar 29, 2016
@julienschmidt I leave this in your opinionated and very capable hands. RE RFC: I can't find docs saying we have to adhere to an RFC (though we are inspired by one). The unescaped pwd, and RE backwards compatibility: comparison with server flags https://github.com/go-sql-driver/mysql/pull/350/files#diff-2357b8494bbd2f27c09e61fc8ef5f092R260 |
julienschmidt commented Mar 29, 2016
I think it's clear that our DSNs are no URLs (unfortunately, that is one historic mistake. Should we CC the letsencrypt guys again?). |
arnehormann commented Mar 30, 2016
RE DSN format - here's what Google does for webfonts: |
This supersedes #343.
This is to support connection attributes. A number of connection attributes like _pid, _client_name are sent by default and it is possible to send custom attributes.
I noticed that user.Current() doesn't work on Fedora 22 with golang, but it does work with gccgo. If this doesn't work then it won't send this attribute to the server.
Edit (js): List of required fixes: #350 (comment)