Commit 491ef6af authored by unknown's avatar unknown
Browse files

Merge bk-internal.mysql.com:/home/bk/mysql-5.1

into  mockturtle.local:/home/dlenev/src/mysql-5.1-merge


mysql-test/t/disabled.def:
  Auto merged
mysql-test/t/ps.test:
  Auto merged
sql/sql_view.cc:
  Auto merged
parents e57ef96a 07b6b2f8
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
# include/wait_condition.inc
#
# SUMMARY
#
#    Waits until the passed statement returns true, or the operation
#    times out.
#
# USAGE
#
#    let $wait_condition=
#      SELECT c = 3 FROM t;
#    --source include/wait_condition.inc
#
# EXAMPLE
#    events_bugs.test
#

--disable_query_log

let $wait_counter= 300;
while ($wait_counter)
{
    let $success= `$wait_condition`;
    if ($success)
    {
        let $wait_counter= 0;
    }
    if (!$success)
    {
        real_sleep 0.1;
        dec $wait_counter;
    }
}
if (!$success)
{
  echo Timeout in wait_condition.inc for $wait_condition;
}

--enable_query_log
+51 −0
Original line number Diff line number Diff line
# include/wait_show_pattern.inc
#
# SUMMARY
#
#   Waits until output produced by SHOW statement which particular type is
#   specified as parameter matches certain pattern or maximum time reached.
#
# NOTES
#
#   Only the first row produced by the parameter statement is checked.
#
# USAGE
#
#   let $show_type= <Tail of SHOW statement>;
#   let $show_pattern= 'Pattern to be used for LIKE matching';
#   --source wait_show_pattern.inc
#
# EXAMPLES
# 
#   alter_table-big.test, wait_slave_status.inc
#
# SEE ALSO
#
#   wait_slave_status.inc, wait_condition.inc (>=5.1)
#
###############################################################################

--disable_query_log

# We accept to wait maximum 30 seconds (0.2 sec/loop).
let $wait_counter= 150;
while ($wait_counter)
{
  let $result= `SHOW $show_type`;
  let $success= `SELECT '$result' LIKE $show_pattern`;
  if ($success)
  {
    let $wait_counter= 0;
  }
  if (!$success)
  {
    real_sleep 0.2;
    dec $wait_counter;
  }
}
if (!$success)
{
  echo Timeout in wait_show_pattern.inc \$show_type= $show_type \$show_pattern= $show_pattern (\$result= '$result');
}

--enable_query_log
+7 −36
Original line number Diff line number Diff line
@@ -104,50 +104,21 @@
eval SELECT "let \$result_pattern= $result_pattern ;" AS "";
SELECT '--source include/wait_slave_status.inc' AS "";

# We accept to wait maximum 30 seconds (0.2 sec/loop).
let $max_wait= 150;
while ($max_wait)
{
    let $my_val= `SHOW SLAVE STATUS`;
    # Now we have the first record of the SHOW result set as one fat string
    # within the variable  $my_val.

    eval SET @my_val = '$my_val';
    # DEBUG eval SELECT @my_val AS "response to SHOW SLAVE STATUS";
let $show_type= SLAVE STATUS;
let $show_pattern= $result_pattern;
--enable_query_log

    eval SELECT @my_val LIKE $result_pattern INTO @success;
    # @success is     '1' if we have a match
    #                 '0' if we have no match
    # DEBUG SELECT @success;
--source include/wait_show_pattern.inc

    let $success= `SELECT @success`;
    let $no_success= `SELECT @success = 0`;
    if ($success)
    {
       # We reached the expected result and want to jump out of the loop
       # without unneeded sleeps.
       # Attention: Do not set $max_wait to 0, because "while" with negative value
       #            does not work.
       let $max_wait= 1;
    }
    if ($no_success)
    {
       # We did not reach the expected result and will have to sleep again
       # or jump out of the loop, when max_wait is exhausted.
       real_sleep 0.2;
    }
    dec $max_wait;
}
--enable_query_log
if ($no_success)
if (!$success)
{
let $message= ! Attention: Timeout in wait_slave_status.inc.
              |       Possible reasons with decreasing probability:
              |       - The LIKE pattern ($result_pattern) is wrong, because the
              |       - The LIKE pattern is wrong, because the
              |         testcase was altered or the layout of the
              |         SHOW SLAVE STATUS result set changed.
              |       - There is a new bug within the replication.
              |       - We met an extreme testing environment and $max_wait is
              |       - We met an extreme testing environment and timeout is
              |         too small.;
--source include/show_msg80.inc
--echo DEBUG INFO START (wait_slave_status.inc):
+9 −41
Original line number Diff line number Diff line
# include/wait_until_rows_count.inc
# inspired by wait_for_slave_status by Matthias Leich
#
# SUMMARY
#
#    Waits until SELECT count(*)-$count from $table returns zero
#    Waits until SELECT count(*) = $count from $table returns true, or
#    the operation times out.
#
# USAGE
#
#    Set vars like
#      let $count=11;
#    let $count= 5;
#    let $table= t1;
#      # invoke the macro
#      --include wait_until_rows_count.inc
#    --source include/wait_until_rows_count.inc
#
# EXAMPLE
#    extra/binlog/binlog_insert_delayed.test
#
#
# TODO: generalize up to wait_[until|while] with arbitrary select or even query and
#       a condition to wait or get awakened
#       It's impossible to implement such a "most" general macro without
#       extending mysqltest. Just no way to pass a query as an argument and
#       evaluate it here, like eval "$quuery". One is bound
#       to specify it inside of the macro

--disable_query_log

let $wait_counter= 300;     # max wait in 0.1 seconds
while ($wait_counter)
{
    eval select count(*)-$count from $table into @rez;
    let $rez=`select @rez`;
    let $success=`SELECT @rez = 0`;
    let $no_success=1;
    if ($success)
    {
        let $wait_counter= 1; # droppping counter to leave loop
        let $no_success=0;
    }
    if ($no_success)
    {
       --sleep 0.1
    }
    dec $wait_counter;
}

--enable_query_log
if ($no_success)
{
	--die Timeout in wait_until_rows_count.inc, required table never had a prescribed number of rows.
}
let $wait_condition=
  select count(*) = $count from $table;
--source include/wait_condition.inc
+18 −0
Original line number Diff line number Diff line
drop table if exists t1, t2;
create table t1 (n1 int, n2 int, n3 int,
key (n1, n2, n3),
key (n2, n3, n1),
key (n3, n1, n2));
create table t2 (i int);
alter table t1 disable keys;
reset master;
alter table t1 enable keys;;
insert into t2 values (1);
insert into t1 values (1, 1, 1);
show binlog events in 'master-bin.000001' from 102;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	1	#	use `test`; insert into t2 values (1)
master-bin.000001	#	Query	1	#	use `test`; alter table t1 enable keys
master-bin.000001	#	Query	1	#	use `test`; insert into t1 values (1, 1, 1)
drop tables t1, t2;
End of 5.0 tests
Loading