#!/bin/bash

mariadb < create.sql

for ((i=0; i < 100; i++)) ; do
    echo Run $i...
    echo
    res=$(cpimport -e 0 patrick crashy bad-data.txt >& /dev/stdout)
    echo $res
    if [ -n "$(echo $res | grep locked)" ] ; then
	echo table lock problem
	exit 1
    fi
    res=$(ps ax | grep StorageManager | grep -v grep)
    if [ -z "$res" ] ; then
        echo caught it
        exit 0
    fi
done

rm -f *.bad *.err
