~jan-kneschke/mysql-proxy/packet-tracking-assertions

« back to all changes in this revision

Viewing changes to trunk/examples/tutorial-warnings.lua

  • Committer: Kay Roepke
  • Author(s): Jan Kneschke
  • Date: 2008-01-23 22:00:28 UTC
  • Revision ID: kay@mysql.com-20080123220028-hq2xqb69apa75fnx
first round on mysql-shell based on the proxy code

this is mostly a verification if the proxy-code is flexible enough to handle 
all three scenarios of: client, server and forwarding (proxy)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--[[ $%BEGINLICENSE%$
2
 
 Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
3
 
 
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
7
 
 License.
8
 
 
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.
13
 
 
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
17
 
 02110-1301  USA
18
 
 
19
 
 $%ENDLICENSE%$ --]]
20
1
--[[
21
2
 
22
 
   
 
3
   Copyright (C) 2007 MySQL AB
 
4
 
 
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.
 
8
 
 
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.
 
13
 
 
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
23
17
 
24
18
--]]
25
19
 
38
32
--
39
33
function read_query( packet )
40
34
        if string.byte(packet) == proxy.COM_QUERY then
41
 
                proxy.queries:append(1, packet, { resultset_is_needed = true } )
 
35
                proxy.queries:append(1, packet )
42
36
 
43
37
                return proxy.PROXY_SEND_QUERY
44
38
        end
64
58
 
65
59
                if res.warning_count > 0 then
66
60
                        print("Query had warnings: " .. inj.query:sub(2))
67
 
                        proxy.queries:append(2, string.char(proxy.COM_QUERY) .. "SHOW WARNINGS", { resultset_is_needed = true } )
 
61
                        proxy.queries:append(2, string.char(proxy.COM_QUERY) .. "SHOW WARNINGS" )
68
62
                end
69
63
        elseif (inj.id == 2) then
70
64
                for row in inj.resultset.rows do
71
 
                        print(string.format("warning: [%d] %s", row[2], row[1]))
 
65
                        print(string.format("warning: [%d] %s", row[1], row[2]))
72
66
                end
73
67
 
74
68
                return proxy.PROXY_IGNORE_RESULT