adding test scripts
[csql.git] / test / cache / CacheTable / test010.ksh
blob006e29b273ef50017346ae4c6ca463f545bded6d
1 #!/bin/ksh
2 # Test Case
4 # Create table t1 and t2 in mysql and insert 10 records each.
5 # Run $ cachetable -R
6 # Both the tables should be cached into csql with all the records intact.
8 #Run this test only under csql/test or on this directory.
9 #Otherwise, it may fail
10 dropAll() {
11 rm -f /tmp/csql/csqltable.conf
12 touch /tmp/csql/csqltable.conf
13 #cp $CSQL_CONFIG_FILE /tmp/csql.conf
14 #echo DSN=$DSN >>$CSQL_CONFIG_FILE
15 isql $DS < ${REL_PATH}/dropall.sql >/dev/null 2>&1
16 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/dropall.sql > /dev/null 2>&1
17 #cp /tmp/csql.conf $CSQL_CONFIG_FILE
21 input=${PWD}/cache/CacheTable/create.sql
22 REL_PATH=.
23 if [ -s "$input" ]
24 then
25 REL_PATH=${PWD}/cache/CacheTable
28 cp $CSQL_CONFIG_FILE /tmp/csql.conf
29 echo CACHE_TABLE=true >>$CSQL_CONFIG_FILE
30 echo DSN=$DSN >>$CSQL_CONFIG_FILE
31 DS="$DSN $DBUSER $PASSWORD"
32 rm -f /tmp/csql/csqlds.conf
33 touch /tmp/csql/csqlds.conf
34 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
35 if [ $? -ne 0 ]
36 then
37 exit 1;
40 isql $DS < ${REL_PATH}/create.sql >/dev/null 2>&1
41 echo table t1 and t2 are created with records in target db
43 rm -f /tmp/csql/csqltable.conf
44 touch /tmp/csql/csqltable.conf
46 # write to the file
47 echo "1 t1 NULL NULL NULL $DSN" > /tmp/csql/csqltable.conf
48 echo "2 t2 NULL t2f1<5 NULL $DSN" >> /tmp/csql/csqltable.conf
50 $CSQL_INSTALL_ROOT/bin/cachetable -R
51 if [ $? -ne 0 ]
52 then
53 dropAll
54 cp /tmp/csql.conf $CSQL_CONFIG_FILE
55 exit 1;
58 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectstar.sql
59 dropAll
60 cp /tmp/csql.conf $CSQL_CONFIG_FILE
61 exit 0;