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

« back to all changes in this revision

Viewing changes to tests/suite/base/t/bug_46141-test.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) 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
 
local proto = require("mysql.proto")
21
 
 
22
 
---
23
 
--
24
 
--
25
 
--
26
 
function read_query(packet)
27
 
        -- pass on everything that is not on the initial connection
28
 
 
29
 
        if packet:byte() ~= proxy.COM_QUERY then
30
 
                proxy.response = {
31
 
                        type = proxy.MYSQLD_PACKET_OK
32
 
                }
33
 
                return proxy.PROXY_SEND_RESULT
34
 
        end
35
 
 
36
 
        if packet:sub(2) == "SELECT 1" then
37
 
                proxy.queries:prepend(1, packet, { resultset_is_needed = true })
38
 
 
39
 
                return proxy.PROXY_SEND_QUERY
40
 
        else
41
 
                proxy.response = {
42
 
                        type = proxy.MYSQLD_PACKET_ERR,
43
 
                        errmsg = "(bug_41991-test) >" .. packet:sub(2) .. "<"
44
 
                }
45
 
                return proxy.PROXY_SEND_RESULT
46
 
        end
47
 
end
48
 
 
49
 
function read_query_result(inj)
50
 
        if inj.id == 1 then
51
 
                proxy.response = {
52
 
                        type = proxy.MYSQLD_PACKET_OK,
53
 
                        resultset = {
54
 
                                fields = {
55
 
                                        { name = "1", type = proxy.MYSQL_TYPE_STRING },
56
 
                                },
57
 
                                rows = {
58
 
                                        { "2" }
59
 
                                }
60
 
                        }
61
 
                }
62
 
                return proxy.PROXY_SEND_RESULT
63
 
        end
64
 
end