Hi all,
I'm working on a deployment of mysql-proxy, and I'd like to add support for prepared statements to rw-splitting.lua.
First, I'd say that rw-splitting.lua needs to be refurbished to work smoothly with mysql-proxy 0.7, which I did. I've seen that a patch almost identical to mine has made it on launchpad thanks to Diego [1].
Then, what is not clear to me is how can I intercept a prepared statement. From what I understand of the documentation, to obtain debug data on incoming prepared statements it should suffice have:
function read_query( packet )
local is_debug = proxy.global.config.rwsplit.is_debug
local cmd = commands.parse(packet)
local c = proxy.connection.client
-- addition JO
if is_debug and
(cmd.type == proxy.COM_QUERY or
cmd.type == proxy.COM_STMNT_PREPARE)
then
print("["..os.date("%c", os.time()).."]" .. " query = " .. cmd.query .. "\n")
elseif cmd.type == proxy.COM_STMNT_EXECUTE then
print("["..os.date("%c", os.time()).."]" .. " statement_id = ".. cmd.stmt_handler_id .. "\n")
end
-- end JO
[rest of read_query is untouched - almost]
But if I use simple prepared statements from within php, nothing is printed to screen and the prepared statement fails to execute (which was expected BTW).
My question is: what should I change in my code?
How come that cmd.type == proxy.COM_STMNT_PREPARE and cmd.type == proxy.COM_STMNT_EXECUTE do not work?
Is it just something having to do with an error in the scripts, or it has to do with some inner defect of mysql-proxy?
Thanks in advance,
Joe
[1] see
http://bazaar.launchpad.net/~diego-fmpwizard/mysql-proxy/bug-43424/revision/634