MySQL Forums
Forum List  »  Router & Proxy

Sending specific SQL after connection
Posted by: Koichi Inoue
Date: March 14, 2010 06:27PM

I am now trying rw-splitting.lua with Rails 2.3.2 (or newer) and MySQL 5.1.43.

I found that ActiveRecord's MySQL connector does the following after new connection is established:
1. Send SET NAMES if any encoding is specified in database.yml
2. Send "SET SQL_AUTO_IS_NULL = 0" to avoid "where id is null" matches last_insert_id.

These statements changes the connection's state, so not compatible with rw-splitting.

I know 1. is solved by server-side settings like the following article:
http://forums.mysql.com/read.php?146,198892,209048#msg-209048

But I can not find the solution for 2. sql_auto_is_null is session-specific system variable and we can not set in my.cnf nor SET GLOBAL.. I tried using init-connect in [mysqld] section but it seems not working.
MySQL Proxy doesn't allow lua to identify specific connection in the pool.

I think these are not so rare case, but potential problem in using connection pool separated from applications.
So I request adding some LUA function call point like after_connect() which is
- You can send any queries by setting proxy.queries queue.
- Garranteed to be called immediately after read_auth_result()
- The queries are sent to the connection which is created just now.

If forging new query without any client-initiated query is not acceptable, "a function which is called before the first query is sent to a connection" may be enough. We can edit proxy.queries by append/prepend functions.

Sorry for no patches...

Best regards.

Options: ReplyQuote


Subject
Views
Written By
Posted
Sending specific SQL after connection
3600
March 14, 2010 06:27PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.