1
function read_query(packet)
2
if packet:byte() == proxy.COM_QUERY then
3
local q = packet:sub(2)
5
if q == "SELECT 1" then
8
-- HINT: lua uses \ddd (3 decimal digits) instead of octals
9
proxy.response.type = proxy.MYSQLD_PACKET_RAW
10
proxy.response.packets = {
12
"\003def" .. -- catalog
19
"\008\0" .. -- charset
20
" \0\0\0" .. -- length
26
"\254\0\0\002\0", -- EOF
28
"\254\0\0\002\0" -- no data EOF
31
return proxy.PROXY_SEND_RESULT
32
elseif q == "SELECT invalid type" then
33
-- should be ERR|OK or nil (aka unset)
35
proxy.response.type = 25
37
return proxy.PROXY_SEND_RESULT
38
elseif q == "SELECT errmsg" then
41
proxy.response.type = proxy.MYSQLD_PACKET_ERR
42
proxy.response.errmsg = "I'm a error"
43
proxy.response.errno = 1000
45
return proxy.PROXY_SEND_RESULT
46
elseif q == "SELECT errmsg empty" then
49
proxy.response.type = proxy.MYSQLD_PACKET_ERR
51
return proxy.PROXY_SEND_RESULT