adding test scripts
[csql.git] / test / cache / DDL / test003.ksh
blob9551c3008f256456edc59982ac0e57a882577487
1 #!/bin/ksh
3 # Cache table t1 from target database and drop the table. It should give an error.
5 # Run this test only under csql/test or on this directory.
6 # Otherwise, it may fail
7 CSQL_CONF=${PWD}/cache/DDL/csql.conf
8 input=${PWD}/cache/DDL/csqlinputtest1.sql
9 REL_PATH=.
10 if [ -s "$input" ]
11 then
12 REL_PATH=${PWD}/cache/DDL
15 rm -f /tmp/csql.conf
16 cp $REL_PATH/csql.conf /tmp
17 export CSQL_CONFIG_FILE=/tmp/csql.conf
19 echo DSN=$DSN >>$CSQL_CONFIG_FILE
20 DS="$DSN $DBUSER $PASSWORD"
21 rm -f /tmp/csql/csqlds.conf
22 touch /tmp/csql/csqlds.conf
23 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
24 if [ $? -ne 0 ]
25 then
26 exit 1;
29 if [ $DSN = "oracle" ]
30 then
31 isql $DS < $REL_PATH/oratest1.oracle >/dev/null
32 elif [ "$DSN" = "sybase" ]
33 then
34 isql $DS < $REL_PATH/sybaseinputtest1.sql > /dev/null 2>&1
35 elif [ "$DSN" = "db2" ]
36 then
37 isql $DS < $REL_PATH/db2inputtest1.sql > /dev/null 2>&1
38 else
39 isql $DS < $REL_PATH/mysqlinputtest2.sql >/dev/null
43 if [ $? -ne 0 ]
44 then
45 echo "unable to create in target db"
46 exit 1
49 rm /tmp/csql/csqltable.conf
50 touch /tmp/csql/csqltable.conf
51 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
52 pid=$!
53 sleep 5
54 if [ "$VALGRIND" = "true" ]
55 then
56 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/cachetable -t t1 2> $0.valgr
57 else
58 $CSQL_INSTALL_ROOT/bin/cachetable -t t1
59 if [ $? -ne 0 ]
60 then
61 echo "unable to cache table from target db"
62 rm /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
63 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
64 isql $DS < $REL_PATH/dropall.sql >/dev/null 2>&1
65 exit 2
69 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/dropall.sql
71 if [ "$VALGRIND" = "true" ]
72 then
73 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u 2>> $0.valgr
74 else
75 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u
76 if [ $? -ne 0 ]
77 then
78 echo "unable to Unload the table"
79 rm /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
80 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
81 isql $DS < $REL_PATH/dropall.sql >/dev/null 2>&1
82 exit 3
85 isql $DS < $REL_PATH/dropall.sql >/dev/null 2>&1
86 kill -9 $pid
87 ipcrm -M 1199 -M 2277 -M 1947
88 rm /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
89 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
90 exit 0