Fixing failed test
[csql.git] / test / cache / Recovery / test004.ksh
blob393a41c626e302e62612408743420c001801d35a
1 #!/bin/sh
3 # 4. Create table t1(f1 int, f2 int, primary key (f1)); in mysql
4 # insert into t1 values(1, 11);
5 # Cache the table in CSQL.
6 # Insert the same tuple in csql.
7 # It should fail with unique key violation.
9 #Run this test only under csql/test or on this directory.
10 #Otherwise, it may fail
11 CSQL_CONF=${PWD}/cache/Recovery/csql.conf
12 input=${PWD}/cache/Recovery/createt1.sql
13 REL_PATH=.
14 if [ -s "$input" -a -s "$CSQL_CONF" ]
15 then
16 REL_PATH=${PWD}/cache/Recovery
18 export CSQL_CONFIG_FILE=$REL_PATH/csql.conf
19 cp $CSQL_CONFIG_FILE /tmp
20 echo DSN=$DSN >> $CSQL_CONFIG_FILE
21 isql $DSN < $REL_PATH/createt1.sql > /dev/null 2>&1
23 if [ $? -ne 0 ]
24 then
25 mv /tmp/csql.conf $CSQL_CONFIG_FILE
26 exit 1;
29 # edit /tmp/csql/csqltable.conf
30 rm -f /tmp/csql/csqltable.conf /tmp/csql/csql.db
31 touch /tmp/csql/csqltable.conf /tmp/csql/csql.db
32 for (( a=1; a<2; a++ ))
34 echo "1:t$a NULL NULL NULL"
35 done >> /tmp/csql/csqltable.conf
37 $CSQL_INSTALL_ROOT/bin/csqlserver -c >/dev/null 2>&1 &
38 pid=$!
39 sleep 5
41 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/insert.sql >/dev/null 2>&1
43 rm -f /tmp/csql/csqltable.conf /tmp/csql/csql.db
44 touch /tmp/csql/csqltable.conf /tmp/csql/csql.db
46 $CSQL_INSTALL_ROOT/bin/csqldump
48 if [ $? -ne 0 ]
49 then
50 mv /tmp/csql.conf $CSQL_CONFIG_FILE
51 exit 5;
54 kill $pid > /dev/null 2>&1
56 isql $DSN < $REL_PATH/drop.sql > /dev/null 2>&1
57 ipcrm -M 1199
58 ipcrm -M 2277
59 mv /tmp/csql.conf $CSQL_CONFIG_FILE
60 rm -f /tmp/csql/csqltable.conf /tmp/csql/csql.db
61 touch /tmp/csql/csqltable.conf /tmp/csql/csql.db
62 exit 0;