[MXS-257] filters not always intercept 'USE db' calls Created: 2015-07-10 Updated: 2017-12-01 Resolved: 2015-07-12 |
|
| Status: | Closed |
| Project: | MariaDB MaxScale |
| Component/s: | Plugin |
| Affects Version/s: | None |
| Fix Version/s: | 1.3.0 |
| Type: | New Feature | Priority: | Minor |
| Reporter: | Yuval Hager | Assignee: | markus makela |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Description |
|
In my filter, I would like to know when users connect to which DB. Currently, Maxscale allows clients to specify DB to connect to in the handshake reply, and the filter is not being called. This leads to inconsistent behavior of the filter: if the user specifies a database in the connection string, the filter does not know about it, but if database is not specified, and USE db is issued later, that goes through the filter. A quick solution to this is to remove the GW_MYSQL_CAPABILITIES_CONNECT_WITH_DB bit from the capabilities. This will force the clients to call USE db explicitly after connecting, regardless of the connection string supplied by the user. An alternative would be to let the filter know somehow that a database has been selected. I'm using this patch for the first alternative:
|
| Comments |
| Comment by markus makela [ 2015-07-10 ] |
|
The connection default database is stored in the initial authentication. The contents are stored at the protocol level which can be accessed through the client session. |
| Comment by markus makela [ 2015-07-12 ] |
|
Closing as this is already implemented. |
| Comment by Yuval Hager [ 2015-07-13 ] |
|
Thanks, that's helpful. Do you mean that the db name can be found in the MySQLProtocol struct? Looking at mysql_client_server_protocol.h, it's not obvious to me where. |
| Comment by markus makela [ 2015-07-14 ] |
|
yhagerMy apologies, the database name is in the MySQL_session structure. This is the session->data pointer and for MySQLClient protocol, it is a pointer to a MySQL_session struct. This struct has the database, username and sha1 of the password. |
| Comment by Yuval Hager [ 2015-07-14 ] |
|
Oh, thanks. Actually I do have that in my code, but I got an empty db in there on the newSession callback. However, I was using a rather outdated version of the develop branch - I have since updated to release-1.2. If it's still missing from there, I'll open a bug report specifically about this. It's not going to be this week, so let's leave this one closed. |