If you want to filter a query for further usage, you need first
to identify the query as the one to process, and then you need to
isolate the elements to use for the task.
Both needs can be satisfied using the Lua string.match(string,pattern)
function. Since Lua is an object orieneted language, this
function can also be used as
stringvar:match(pattern).
Let's see an example. We need to do something with with the
UPDATE statements to the employees table.
function read_query( packet )
if packet:byte() ~= proxy.COM_QUERY then
return
end
local query = packet:sub(2)
local cmd, table_name = query:match('^(%w+)%s+(%w+)')
if cmd and cmd:lower() == 'update' then
print( 'updating table ' .. table_name)
if table_name == …[Read more]