| Bug #36151 | Proxy parser.lua -- get_tables function works unexpectedly on subsequent uses | ||
|---|---|---|---|
| Submitted: | 16 Apr 2008 21:18 | ||
| Reporter: | Lachlan Mulcahy | ||
| Status: | Verified | ||
| Category: | Proxy: Scripts | Severity: | S3 (Non-critical) |
| Version: | 0.6.1, 0.7.1 | OS: | Any |
| Assigned to: | Diego Medina | Target Version: | |
| Triage: | D2 (Serious) / R1 (None/Negligible) / E1 (None/Negligible) | ||
[3 Jun 16:49]
Kay Roepke
This problem seems to persist in version 0.7.1 and trunk, but I'm confused about the output. Even with the patch there seems to be a problem, but I can't quite figure out what I'm missing off-hand. Needs test case.

Description: When using the get_tables function on the parser.lua script bundled with proxy, running the parser more than once gives incorrect/unexpected results. How to repeat: Create bugtest.lua: function read_query ( packet ) local query = "DROP TABLE t" local tk = require('proxy.tokenizer') local pr = require('proxy.parser') local tokens = tk.tokenize(query) local tbls = pr.get_tables(tokens) for k, v in pairs(tbls) do print(k.." => "..v) end tbls = pr.get_tables(tokens) for k, v in pairs(tbls) do print(k.." => "..v) end return proxy.PROXY_SEND_QUERY end shell> mysql-proxy --proxy-lua-script=bugtest.lua Connect to the proxy, issue some query and watch the output. Suggested fix: Initialise the ddl_type variable in the get_tables function to avoid subsequent executions using the old value... Apply this diff to ./lib/proxy/parser.lua: 40a41 > local ddl_type = nil