Bug #35669 MySQL Proxy does not report Lua syntax errors
Submitted: 29 Mar 2008 11:34 Modified: 3 Jun 2009 15:02
Reporter: Giuseppe Maxia Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Proxy: Core Severity:S1 (Critical)
Version:0.7.0 OS:MacOS
Assigned to: Kay Roepke CPU Architecture:Any
Tags: mysql-proxy, parsing, scripts, syntax

[29 Mar 2008 11:34] Giuseppe Maxia
Description:
MySQL Proxy 0.7.0 does not report syntax errors in the Lua script.
The previous version (0.6.1) correctly complains about the error.

for example, when executing the snippet below, version 0.7.0 does not report anything, while 0.6.1 reports the error.

function faulty (x)
    if x = 0 then                     -- this is wrong!!!
        print('should not come here')
    end
end

function read_query (packet)
    faulty(1)
end

output from 0.6.1:

luaL_loadfile(test_syntax.lua) failed
lua_load_file(test_syntax.lua) failed: test_syntax.lua:3: 'then' expected near '='

output from 0.7.0:
(none)

How to repeat:
-- save the following as test_syntax.lua
function faulty (x)
    if x = 0 then                     -- this is wrong!!!
        print('should not come here')
    end
end

function read_query (packet)
    faulty(1)
end

-- launch the 0.7.0 Proxy 
-- execute any query
[29 Mar 2008 12:43] Kay Roepke
The syntax error is reported, but only on log level `warning`.
The default behavior of the log function seems to have changed in that the default log level is now `error`, thus the warning does not get displayed.

Additionally some error checking is missing, leading to a crash of the proxy.

I propose to change the log level of syntax errors to `error` and of course the crash must be fixed, too.

As a workaround to see the warning, start the proxy with --log-level=warning. However, the proxy will still crash in this version.
[25 Feb 2009 14:54] Kay Roepke
a preliminary fix proposal is available at:
https://code.launchpad.net/~kay-roepke/mysql-proxy/fix-bug-35669
[25 Feb 2009 15:24] Kay Roepke
see https://code.launchpad.net/~kay-roepke/mysql-proxy/fix-bug-35669/+merge/3936
[25 Feb 2009 16:26] Kay Roepke
pushed to lp:mysql-proxy as rev 630, please test
[3 Jun 2009 15:02] Kay Roepke
fixed in 0.7.1 and trunk