~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/base/t/tokens1.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
local tk = require('proxy.tokenizer')
 
2
 
 
3
function read_query( packet )
 
4
    if packet:byte() ~= proxy.COM_QUERY then
 
5
        return
 
6
    end
 
7
    local query = packet:sub(2)
 
8
    local tokens = tk.tokenize(query)
 
9
    local stripped_tokens = tk.tokens_without_comments(tokens, true )
 
10
    local simple_tokens = tk.bare_tokens(stripped_tokens, true )
 
11
    proxy.response.type = proxy.MYSQLD_PACKET_OK
 
12
    proxy.response.resultset = {
 
13
        fields = {
 
14
            { type = proxy.MYSQL_TYPE_STRING, name = "item", },
 
15
            { type = proxy.MYSQL_TYPE_STRING, name = "value", },
 
16
        },
 
17
        rows = {
 
18
            { 'original', query },
 
19
            { 'rebuilt' , tk.tokens_to_query(tokens) }
 
20
        }
 
21
    }
 
22
    return proxy.PROXY_SEND_RESULT
 
23
end