#!/bin/bash

if [ "$1" != "" ] ; then 
    loop=$1
else 
    loop=99999
fi

i=0
while [ $i -lt $loop ] ; do
  i=$(($i + 1))

  mysql -B test <<EOF

drop table if exists ft2;
create table ft2 like ft1;
insert into ft2 select * from ft1;

lock table ft1 write, ft2 read;
delete from ft1;
insert into ft1 select * from ft2;
unlock tables;

select count(*) from ft1;

EOF

done

