# Execute the command sequence belonging to test number
# @sess2_test_number of session 2
#
# @sess2_test_number must be set outside of this script and contain
# a valid number. That means
#       SELECT command, command_number, 1
#       FROM t99_actions
#       WHERE test_number = @sess2_test_number
# must not give an empty result set.

let $last_number= 0;
let $run= 1;
while ($run)
{
  # Attention: @current_command, @command_number, @command_found
  #            hold their old values, when the next SELECT gets
  #            ROW NOT FOUND
  --disable_query_log
  SET @command_found = 0;
  --disable_warnings
  eval SELECT command, command_number, 1
         INTO @current_command, @command_number, @command_found
       FROM t99_actions
       WHERE test_number = @sess2_test_number
         AND command_number >= $last_number
       ORDER BY test_number, command_number
       LIMIT 1;
  --enable_warnings
  --enable_query_log

  let $run= `SELECT @command_found`;
  if ($run)
  {
    # DEBUG SELECT @current_command, @command_number, @command_found;
    let $current_command= `SELECT @current_command`;
    eval $current_command;
    let $last_number= `SELECT @command_number + 1`;
  }
}
