2
Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; version 2 of the
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
local tokenizer = require("proxy.tokenizer")
21
local proto = require("mysql.proto")
23
function connect_server()
26
type = proxy.MYSQLD_PACKET_RAW,
28
proto.to_challenge_packet({})
31
return proxy.PROXY_SEND_RESULT
38
function read_query( packet )
39
if packet:byte() ~= proxy.COM_QUERY then
40
proxy.response = { type = proxy.MYSQLD_PACKET_OK }
41
return proxy.PROXY_SEND_RESULT
43
local query = packet:sub(2)
45
-- Uncomment the following two lines if using with MySQL command line.
46
-- Keep them commented if using inside the test suite
47
-- counter = counter + 1
48
-- if counter < 3 then return end
49
local tokens = tokenizer.tokenize(query)
50
proxy.response.type = proxy.MYSQLD_PACKET_OK
51
proxy.response.resultset = {
53
{ type = proxy.MYSQL_TYPE_STRING, name = "text", },
55
rows = { { '<'..tokenizer.normalize(tokens)..'>' } }
57
return proxy.PROXY_SEND_RESULT