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

« back to all changes in this revision

Viewing changes to tags/mysql-proxy-0.6.0/tests/suite/bugs/t/bug_29494.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
function read_query(packet) 
 
2
        if packet:byte() == proxy.COM_QUERY then
 
3
                local q = packet:sub(2) 
 
4
 
 
5
                if q == "SELECT 1 /* BUG #29494 */" then
 
6
                        -- create a packet which is will break the client
 
7
                        --
 
8
                        -- HINT: lua uses \ddd (3 decimal digits) instead of octals
 
9
                        proxy.response.type = proxy.MYSQLD_PACKET_RAW
 
10
                        proxy.response.packets = {
 
11
                                "\001",  -- one field
 
12
                                "\003def" ..   -- catalog
 
13
                                  "\251" ..  -- db, NULL (crashes client)
 
14
                                  "\0" ..    -- table
 
15
                                  "\0" ..    -- orig-table
 
16
                                  "\0011" .. -- name
 
17
                                  "\0" ..    -- orig-name
 
18
                                  "\f" ..    -- filler
 
19
                                  "\008\0" .. -- charset
 
20
                                  " \0\0\0" .. -- length
 
21
                                  "\003" ..    -- type
 
22
                                  "\002\0" ..  -- flags 
 
23
                                  "\0" ..    -- decimals
 
24
                                  "\0\0",    -- filler
 
25
 
 
26
                                "\254\0\0\002\0", -- EOF
 
27
                                "\254\0\0\002\0"  -- no data EOF
 
28
                        }
 
29
                        
 
30
                        return proxy.PROXY_SEND_RESULT
 
31
                elseif q == "SELECT 1" then
 
32
                        -- return a empty row
 
33
                        --
 
34
                        -- HINT: lua uses \ddd (3 decimal digits) instead of octals
 
35
                        proxy.response.type = proxy.MYSQLD_PACKET_RAW
 
36
                        proxy.response.packets = {
 
37
                                "\001",  -- one field
 
38
                                "\003def" ..   -- catalog
 
39
                                  "\0" ..    -- db 
 
40
                                  "\0" ..    -- table
 
41
                                  "\0" ..    -- orig-table
 
42
                                  "\0011" .. -- name
 
43
                                  "\0" ..    -- orig-name
 
44
                                  "\f" ..    -- filler
 
45
                                  "\008\0" .. -- charset
 
46
                                  " \0\0\0" .. -- length
 
47
                                  "\003" ..    -- type
 
48
                                  "\002\0" ..  -- flags 
 
49
                                  "\0" ..    -- decimals
 
50
                                  "\0\0",    -- filler
 
51
 
 
52
                                "\254\0\0\002\0", -- EOF
 
53
                                "\0011",
 
54
                                "\254\0\0\002\0"  -- no data EOF
 
55
                        }
 
56
                        
 
57
                        return proxy.PROXY_SEND_RESULT
 
58
                end
 
59
        end
 
60
end