~roger-booth/mysql-proxy/laminator

« back to all changes in this revision

Viewing changes to trunk/tests/suite/base/t/raw_packets.lua

  • Committer: Kay Roepke
  • Author(s): jkneschke
  • Date: 2007-08-23 21:39:05 UTC
  • Revision ID: kay@mysql.com-20070823213905-z5cv1nk93jiwgnlw
added support for test-suites

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" then
 
6
                        -- return a empty row
 
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
                                  "\0" ..    -- db 
 
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
                                "\0011",
 
28
                                "\254\0\0\002\0"  -- no data EOF
 
29
                        }
 
30
                        
 
31
                        return proxy.PROXY_SEND_RESULT
 
32
                elseif q == "SELECT invalid type" then
 
33
                        -- should be ERR|OK or nil (aka unset)
 
34
                        
 
35
                        proxy.response.type = 25
 
36
                        
 
37
                        return proxy.PROXY_SEND_RESULT
 
38
                elseif q == "SELECT errmsg" then
 
39
                        -- don't set a errmsg
 
40
                        
 
41
                        proxy.response.type = proxy.MYSQLD_PACKET_ERR
 
42
                        proxy.response.errmsg = "I'm a error"
 
43
                        proxy.response.errno  = 1000
 
44
                        
 
45
                        return proxy.PROXY_SEND_RESULT
 
46
                elseif q == "SELECT errmsg empty" then
 
47
                        -- don't set a errmsg
 
48
                        
 
49
                        proxy.response.type = proxy.MYSQLD_PACKET_ERR
 
50
                        
 
51
                        return proxy.PROXY_SEND_RESULT
 
52
                end
 
53
        end
 
54
end