adding test scripts
[csql.git] / test / cache / CacheTable / test030.ksh
blob5859a46858680e9fb0d38a0ec5f2a4e284223238
1 #!/bin/ksh
2 #Test Case
3 # Create table t5 and t6 in target DB
4 # Load t5 and t6 table with condition option and direct option
5 # Insert some record in CSQL tool with csql -g option
6 # It should insert into target database not in CSQL database
9 input=${PWD}/cache/CacheTable/inputtest4.sql
10 REL_PATH=.
11 if [ -s "$input" ]
12 then
13 REL_PATH=${PWD}/cache/CacheTable
15 rm -f /tmp/csql.conf
16 cp $CSQL_CONFIG_FILE /tmp
17 export CSQL_CONFIG_FILE=/tmp/csql.conf
18 echo CACHE_TABLE=true >>$CSQL_CONFIG_FILE
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 # create table t5,t6 in target DB.
31 if [ $DSN = "db2" ]
32 then
33 isql $DS < ${REL_PATH}/createt5db2.sql >/dev/null 2>&1
34 else
35 isql $DS < ${REL_PATH}/createt5.sql >/dev/null 2>&1
37 if [ $? -ne 0 ]
38 then
39 exit 2;
41 echo Table t5 and t6 created in target DB.
43 rm -f /tmp/csql/csqltable.conf
44 touch /tmp/csql/csqltable.conf
46 for a in 5 6 7 8 9 10 11 12 13 14 15
48 echo "insert into t5 values($a,$a+1);"
49 echo "insert into t6 values($a,$a+1);"
50 done>>${REL_PATH}/inserttarget.sql
51 isql $DS < ${REL_PATH}/inserttarget.sql >/dev/null 2>&1
53 echo "cachetable -t t5 -D -c \"f1>=10\""
54 echo "cachetable -t t6 -D -c \"f1>=10\" "
56 $CSQL_INSTALL_ROOT/bin/cachetable -t t5 -D -c "f1>=10"
57 if [ $? -ne 0 ]
58 then
59 isql $DS < ${REL_PATH}/drop5.sql >/dev/null 2>&1
60 rm -f /tmp/csql/csqltable.conf
61 touch /tmp/csql/csqltable.conf
62 exit 3;
65 $CSQL_INSTALL_ROOT/bin/cachetable -t t6 -D -c "f1>=10"
66 if [ $? -ne 0 ]
67 then
68 rm -f /tmp/csql/csqltable.conf
69 touch /tmp/csql/csqltable.conf
70 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop5.sql >/dev/null 2>&1
71 isql $DS < ${REL_PATH}/drop5.sql >/dev/null 2>&1
72 rm -f ${REL_PATH}/inserttarget.sql
73 exit 4;
76 for a in 5 6
78 echo "insert into t$a values(16,20);"
79 echo "insert into t$a values(15,21);"
80 done>>${REL_PATH}/insertt5t6.sql
82 echo "select query on t1 and t2 table"
83 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/insertt5t6.sql
84 if [ $? -ne 0 ]
85 then
86 rm -f /tmp/csql/csqltable.conf
87 touch /tmp/csql/csqltable.conf
88 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop5.sql >/dev/null 2>&1
89 isql $DS < ${REL_PATH}/drop5.sql >/dev/null 2>&1
90 rm -f $REL_PATH/insertt5t6.sql
91 rm -f ${REL_PATH}/inserttarget.sql
92 exit 5;
94 for a in 5 6
96 echo "select * from t$a;"
97 done>>${REL_PATH}/selectt5t6.sql
99 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/selectt5t6.sql
100 if [ $? -ne 0 ]
101 then
102 rm -f /tmp/csql/csqltable.conf
103 touch /tmp/csql/csqltable.conf
104 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop5.sql >/dev/null 2>&1
105 isql $DS < ${REL_PATH}/drop5.sql >/dev/null 2>&1
106 rm -f $REL_PATH/insertt5t6.sql
107 rm -f $REL_PATH/selectt5t6.sql
108 rm -f ${REL_PATH}/inserttarget.sql
109 exit 6;
111 isql $DS < ${REL_PATH}/selectt5t6.sql
112 $CSQL_INSTALL_ROOT/bin/cachetable -t t6 -u
113 if [ $? -ne 0 ]
114 then
115 rm -f /tmp/csql/csqltable.conf
116 touch /tmp/csql/csqltable.conf
117 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop5.sql >/dev/null 2>&1
118 isql $DS < ${REL_PATH}/drop5.sql >/dev/null 2>&1
119 rm -f $REL_PATH/insertt5t6.sql
120 rm -f $REL_PATH/selectt5t6.sql
121 rm -f ${REL_PATH}/inserttarget.sql
122 exit 7;
124 $CSQL_INSTALL_ROOT/bin/cachetable -t t5 -u
125 if [ $? -ne 0 ]
126 then
127 rm -f /tmp/csql/csqltable.conf
128 touch /tmp/csql/csqltable.conf
129 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop5.sql >/dev/null 2>&1
130 isql $DS < ${REL_PATH}/drop5.sql >/dev/null 2>&1
131 rm -f $REL_PATH/insertt5t6.sql
132 rm -f $REL_PATH/selectt5t6.sql
133 rm -f ${REL_PATH}/inserttarget.sql
134 exit 8;
137 #rm -f /tmp/csql/csqltable.conf
138 #touch /tmp/csql/csqltable.conf
140 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/drop5.sql > /dev/null 2>&1
141 isql $DS <${REL_PATH}/drop5.sql >/dev/null 2>&1
142 rm -f $REL_PATH/insertt5t6.sql
143 rm -f $REL_PATH/selectt5t6.sql
144 rm -f ${REL_PATH}/inserttarget.sql
145 exit 0;