Bug #26077 'reap' command fetches first command issued by send, not the most recent
Submitted: 5 Feb 2007 9:13 Modified: 30 Jun 2009 20:34
Reporter: Giuseppe Maxia Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1.15 OS:Linux (Linux,Mac OSX)
Assigned to: Paul DuBois CPU Architecture:Any
Tags: Docs, server, Tests

[5 Feb 2007 9:13] Giuseppe Maxia
Description:
The description for "reap" says that it receives "the result of the statement most recently sent with the send command."

http://dev.mysql.com/doc/mysqltest/en/mysqltest-commands.html

However, reap fetches the result of the *first* statement sent to the server via the 'send' command, not the latest. 

The documentation suggests that you could send several statements and then retrieve the most recent one. However, attempting a push/pop approach will cause an error:

send ....
send ...
reap;
reap;

mysqltest: At line 23: query 'reap' failed: 2013: Lost connection to MySQL server during query

This bug could be related to bug#20304

On a side note, the docs should also mention that "reap" fetches the recent result *within the current session*.

How to repeat:
connect (conn1,localhost,root,,);
connect (conn2,localhost,root,,);

--echo # connection conn1
connection conn1;
--echo # send conn1
send select "conn1 first " as msg;
send select "conn1 second" as msg;
--echo # connection conn2
connection conn2;
--echo # send conn2
send select "conn2 first" as msg;
send select "conn2 second" as msg;
--echo # connection conn1
connection conn1;
--echo # reap conn1
reap;
--echo # connection conn2
connection conn2;
--echo # reap conn2
reap;
# uncommenting the following line causes an error
# reap

Sample run:
mysqltest --user=root --password= --socket=var/tmp/master.sock test < /send_reap.test

# connection conn1
# send conn1
select "conn1 first " as msg;
select "conn1 second" as msg;
# connection conn2
# send conn2
select "conn2 first" as msg;
select "conn2 second" as msg;
# connection conn1
# reap conn1
msg
conn1 first
# connection conn2
# reap conn2
msg
conn2 first
ok

According to the docs, I should have received "conn1 second" and "conn2 second".

Suggested fix:
fix the documentation.
[15 May 2009 20:41] Jim Winstead
It has been suggested (in a private comment) that the proper fix for this is to prevent, in the C API, a query from being sent before the results of the previous query have been handled, which is why the bug is in the C API category and triaged as it is.
[16 Jun 2009 16:52] Jim Winstead
And we're not going to make that change. This is purely a documentation problem, as noted in the original report.
[30 Jun 2009 20:34] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

I will avoid "first" and "most recent" altogether and emphasize that there should be only one send at a time:

Receive the result of the statement sent with the send command within
the current session. You should not use reap unless a statement has
been sent with send, and you should not use send again if there is an
outstanding send that has not been processed with reap.