Bug #30506 Proxy handles multi-statements queries in its core, but not in scripts
Submitted: 20 Aug 2007 10:11
Reporter: Giuseppe Maxia Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Proxy: Scripts Severity:S2 (Serious)
Version:0.6.0 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: multi-statement query, proxy, script

[20 Aug 2007 10:11] Giuseppe Maxia
Description:
Proxy handles multi-statement queries internally. Both server and client receive what they expect, but the multiple result sets are not passed to the Lua environment, and thus they can't be handled properly.

For example, when calling a procedure containing two result sets, I see the following:
call p1();
+-----+
| one |
+-----+
|   1 | 
+-----+
1 row in set (0.00 sec)

+-----+-----+-------+
| one | two | three |
+-----+-----+-------+
|   1 |   2 | three | 
+-----+-----+-------+
1 row in set (0.00 sec)

However, in the proxy I only see one result set:

.---  mysql query
| query.len = 10
| query.packet = 03 63 61 6c 6c 20 70 31 28 29
| .--- query
| | command = COM_QUERY
| | query = "call p1()"
| '---
|
| result.len = 1
| result.packet = 01
| result.flags = { in_trans = 0, auto_commit = 1, no_good_index_used = 0, no_index_used = 0 }
| result.warning_count = 0
| result.affected_rows = 0
| result.insert_id = 0
| result.query_status = 0
| query_time = 1186us
| response_time = 1272us
| .--- result-set
| | command = COM_QUERY
| | num-cols = 1
| | field[0] = { type = 8, name = one }
| | row[0] = { 1 }
| '---
'---

How to repeat:
1) 
connect through the proxy, using tutorial-packet.lua
/usr/local/sbin/mysql-proxy --proxy-lua-script=tutorial-packets.lua

2) Using a MySQL client through the proxy, enter the following

drop procedure if exists p1;
delimiter //
create procedure p1() 
deterministic 
begin 
  select 1 as one; 
  select 1 as one, 2 as two, 'three' as three; 
end // 
delimiter ;
call p1();

Suggested fix:
pass the handling of multiple statements to the Lua environment