~roger-booth/mysql-proxy/laminator

« back to all changes in this revision

Viewing changes to lib/proxy/parser.lua

  • Committer: Roger Booth
  • Date: 2010-01-11 02:46:16 UTC
  • Revision ID: roger.booth@gmail.com-20100111024616-s84ujm9uejyftgdq
Fix for Proxy parser.lua MySQL Bug #36151

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
        local next_is_tblname = false
39
39
        local in_braces = 0
40
40
        local db_name = nil
 
41
        local ddl_type = nil
41
42
 
42
43
        local tables = {}
43
44
 
129
130
                        elseif ddl_type == "TABLE" then
130
131
                                if in_tablelist and 
131
132
                                   token["token_name"] == "TK_LITERAL" then
132
 
                                        tables[tablename_expand(token.text)] = (sql_stmt == "SELECT" and "read" or "write")
 
133
                                   if not db_name and tokens[i + 1] and tokens[i + 1].token_name == "TK_DOT" then
 
134
                                        db_name = token.text
 
135
                                        else
 
136
                                                tables[tablename_expand(token.text, db_name)] = (sql_stmt == "SELECT" and "read" or "write")
 
137
                                                db_name = nil
 
138
                                        end
133
139
                                else
134
140
                                        in_tablelist = false
135
 
 
136
141
                                        break
137
142
                                end
138
143
                        end
140
145
                        -- INSERT INTO ...
141
146
                        if in_tablelist then
142
147
                                if token["token_name"] == "TK_LITERAL" then
143
 
                                        tables[tablename_expand(token.text)] = (sql_stmt == "SELECT" and "read" or "write")
 
148
                                        if not db_name and tokens[i + 1] and tokens[i + 1].token_name == "TK_DOT" then
 
149
                                                db_name = token.text
 
150
                                        else
 
151
                                                tables[tablename_expand(token.text, db_name)] = (sql_stmt == "SELECT" and "read" or "write")
 
152
                                                db_name = nil
 
153
                                        end
144
154
                                elseif token["token_name"] == "TK_SQL_INTO" then
 
155
                                elseif token["token_name"] == "TK_DOT" then
145
156
                                else
146
157
                                        in_tablelist = false
147
158
                                end
150
161
                        -- UPDATE <tbl> SET ..
151
162
                        if in_tablelist then
152
163
                                if token["token_name"] == "TK_LITERAL" then
153
 
                                        tables[tablename_expand(token.text)] = (sql_stmt == "SELECT" and "read" or "write")
 
164
                                        if not db_name and tokens[i + 1] and tokens[i + 1].token_name == "TK_DOT" then
 
165
                                                db_name = token.text
 
166
                                        else
 
167
                                                tables[tablename_expand(token.text, db_name)] = (sql_stmt == "SELECT" and "read" or "write")
 
168
                                                db_name = nil
 
169
                                        end
154
170
                                elseif token["token_name"] == "TK_SQL_SET" then
155
171
                                        in_tablelist = false
156
 
 
157
172
                                        break
158
173
                                end
159
174
                        end