Bug #46141 prepend does not support { resultset_is_needed = true }
Submitted: 13 Jul 2009 1:41 Modified: 7 Dec 2009 9:12
Reporter: Diego Medina Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Proxy: Core Severity:S1 (Critical)
Version:0.8.0 r757 OS:Any
Assigned to: Jan Kneschke CPU Architecture:Any

[13 Jul 2009 1:41] Diego Medina
Description:
Even after adding

{ resultset_is_needed = true } 

to a prepend command (like this one:

proxy.queries:prepend(2, string.char(proxy.COM_QUERY) .. "SELECT NOW()", { resultset_is_needed = true } )

)

The proxy will give you an error like this one:

(critical) proxy-plugin.c:259: read_query_result() in /tmp/test.lua tries to modify the resultset, but hasn't asked to buffer it in proxy.query:append(..., { resultset_is_needed = true }). We ignore the change to the result-set.

Note: This also affects the rw-splitting.lua script
Related to bug#43424 and bug#42841

How to repeat:
1- Save this Lua script as test.lua

function read_query( packet )
  proxy.queries:prepend(
    2,
    string.char(proxy.COM_QUERY) .. "SELECT NOW()",
    { resultset_is_needed = true }
  )
  return proxy.PROXY_SEND_QUERY
end

function read_query_result( inj )
  if inj.id == 2 then
    return proxy.PROXY_SEND_RESULT
  end
end

2- start the proxy like this:

$./sbin/mysql-proxy --proxy-lua-script=/tmp/test.lua  \
--proxy-backend-addresses=127.0.0.1:22001

3- On another terminal, connect to port 4040
4- Go back to the terminal where you started the proxy, and you will see this error:

(critical) proxy-plugin.c:259: read_query_result() in /tmp/test.lua tries to modify the resultset, but hasn't asked to buffer it in proxy.query:append(..., { resultset_is_needed = true }). We ignore the change to the result-set.
[1 Sep 2009 12:04] Jan Kneschke
revno: 801
committer: jan@mysql.com
branch nick: trunk
timestamp: Tue 2009-09-01 14:02:55 +0200
message:
  moved the _append() and _prepend() code into a comment _add() function (fixes #46141)
------------------------------------------------------------
revno: 800
committer: jan@mysql.com
branch nick: trunk
timestamp: Mon 2009-08-31 17:42:54 +0200
message:
  added failing test for #46141
[1 Sep 2009 15:28] Enterprise Tools JIRA Robot
Diego Medina writes: 
Verified fixed on 0.8.0
[7 Dec 2009 9:12] MC Brown
A note has been added to the 0.8.0 changelog: 

The supplied script <filename>rw-splitting.lua</filename> had not been updated to use the new <literal>resultset_is_needed</literal> flag or updated <literal>proxy.connections</literal> structure.