MySQL Forums
Forum List  »  Router & Proxy

Re: Filtering - Injection - Redirection
Posted by: Jan Kneschke
Date: July 09, 2007 04:34PM

The lua code for this looks like this:

----

local is_in_transaction = 0

function read_query( packet )
if packet:byte() == proxy.COM_QUIT then
proxy.response = {
type = proxy.MYSQLD_PACKET_ERR,
errmsg = "ignored the COM_QUIT"
}

return proxy.PROXY_SEND_RESULT
end

proxy.queries:append(1, packet)

if is_in_transaction == 0 and
packet:byte() == proxy.COM_QUERY and
packet:sub(2, 7) == "SELECT" then
-- send to slave
print("sending to slave");
else
-- send to master
print("sending to master");
end

return proxy.PROXY_SEND_QUERY
end

function read_query_result( inj )
local res = assert(inj.resultset)
local flags = res.flags

is_in_transaction = flags.in_trans
end

----

Now I only have to add the host-selector :)

Jan

Options: ReplyQuote


Subject
Views
Written By
Posted
4719
July 09, 2007 12:18PM
Re: Filtering - Injection - Redirection
3027
July 09, 2007 04:34PM


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.