1
function read_query(packet)
2
if packet:byte() == proxy.COM_QUERY then
3
local q = packet:sub(2)
5
if q == "SELECT 1 /* BUG #29494 */" then
6
-- create a packet which is will break the client
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
13
"\251" .. -- db, NULL (crashes client)
19
"\008\0" .. -- charset
20
" \0\0\0" .. -- length
26
"\254\0\0\002\0", -- EOF
27
"\254\0\0\002\0" -- no data EOF
30
return proxy.PROXY_SEND_RESULT
31
elseif q == "SELECT 1" then
34
-- HINT: lua uses \ddd (3 decimal digits) instead of octals
35
proxy.response.type = proxy.MYSQLD_PACKET_RAW
36
proxy.response.packets = {
38
"\003def" .. -- catalog
45
"\008\0" .. -- charset
46
" \0\0\0" .. -- length
52
"\254\0\0\002\0", -- EOF
54
"\254\0\0\002\0" -- no data EOF
57
return proxy.PROXY_SEND_RESULT