2
Copyright (c) 2007, 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
3
Copyright (C) 2007 MySQL AB
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; version 2 of the License.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
20
module("proxy.commands", package.seeall)
75
74
-- nothing to decode
76
75
elseif cmd.type == proxy.COM_STMT_PREPARE then
77
76
cmd.query = packet:sub(2)
78
-- the stmt_handler_id is at the same position for both STMT_EXECUTE and STMT_CLOSE
79
elseif cmd.type == proxy.COM_STMT_EXECUTE or cmd.type == proxy.COM_STMT_CLOSE then
80
cmd.stmt_handler_id = string.byte(packet, 2) + (string.byte(packet, 3) * 256) + (string.byte(packet, 4) * 256 * 256) + (string.byte(packet, 5) * 256 * 256 * 256)
81
77
elseif cmd.type == proxy.COM_FIELD_LIST then
82
78
cmd.table = packet:sub(2)
83
79
elseif cmd.type == proxy.COM_INIT_DB or
84
80
cmd.type == proxy.COM_CREATE_DB or
85
81
cmd.type == proxy.COM_DROP_DB then
86
82
cmd.schema = packet:sub(2)
87
elseif cmd.type == proxy.COM_SET_OPTION then
88
cmd.option = packet:sub(2)
90
print("[debug] (command) unhandled type name:" .. tostring(cmd.type_name) .. " byte:" .. tostring(cmd.type))
84
print("[debug] (command) unhandled type " .. cmd.type_name)
106
100
elseif cmd.type == proxy.COM_FIELD_LIST then
107
101
-- should have a table-name
108
102
return ("[%s]"):format(cmd.type_name)
109
elseif cmd.type == proxy.COM_STMT_EXECUTE then
110
return ("[%s] %s"):format(cmd.type_name, cmd.stmt_handler_id)
111
elseif cmd.type == proxy.COM_STMT_EXECUTE then
112
return ("[%s] %s"):format(cmd.type_name, cmd.stmt_handler_id)
115
105
return ("[%s] ... no idea"):format(cmd.type_name)