#!/bin/bash

# Reset the auto-inc counters (if any) of the tables
./use -A test -e "truncate table tbl_auto_col"
./use -A test -e "truncate table tbl_auto_col_only_on_slave"

# Generate new binary log
./use -A -e "flush logs"
./use -A -e "show master status"

# Insert some data
for ((i=0; i < 5; i++))
do
    ./use -A test -e "INSERT INTO tbl_auto_col_only_on_slave SET col1 = 23211, col2 = 'foo', col3 = 'bar', col4 = 1, col5 = 242122;"
done

# Do the load asynchronously to simulate concurrent connections
./use -A test -e "LOAD DATA LOCAL INFILE '/work/sandboxes/rsandbox_mysql-5_1_69/SQL_LOAD_MB-17a99f5-3' INTO TABLE tbl_auto_col FIELDS TERMINATED BY ',' ENCLOSED BY '\"' (c);" &

#sleep 1

# Do an insert while the load is in progress
for ((i=0; i < 5; i++))
do
    ./use -A test -e "INSERT INTO tbl_auto_col_only_on_slave SET col1 = 23211, col2 = 'foo', col3 = 'bar', col4 = 1, col5 = 242122;"
done

wait
