windows porting build fix for linux
[csql.git] / test / cache / Gateway / test002n.ksh
blob51a4e579bb5382ba759a72f847fb1364d8a692d1
1 #!/bin/ksh
2 # 2. Create table t1 in MySQL with all supported data types in it. and insert 10 records in it.
3 # Note that in this test case the table is not cached in csql and it is present only in MySQL.
4 # insert 10 more records using csql tool.
5 # select records with WHERE clause containing parameters for all the fields with different data types.
6 # update all fields with WHERE clause on primary key
7 # delete records with WHERE clause on all fields
8 #Run this test only under csql/test or on this directory.
9 #Otherwise, it may fail
10 input=${PWD}/cache/Gateway/mysqlinputtest1.sql
11 REL_PATH=.
12 if [ -s "$input" ]
13 then
14 REL_PATH=${PWD}/cache/Gateway
16 rm -f /tmp/csql.conf
18 cp $REL_PATH/csql.conf /tmp/csql.conf
19 echo CSQL_SQL_SERVER=true >>/tmp/csql.conf
20 echo PORT=6002 >>/tmp/csql.conf
21 export CSQL_CONFIG_FILE=/tmp/csql.conf
23 echo DSN=$DSN >>$CSQL_CONFIG_FILE
24 DS="$DSN $DBUSER $PASSWORD"
25 rm -f /tmp/csql/csqlds.conf
26 touch /tmp/csql/csqlds.conf
27 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
28 if [ $? -ne 0 ]
29 then
30 exit 1;
33 if [ $DSN = "oracle" ]
34 then
35 isql $DS < $REL_PATH/orainputt1.oracle >/dev/null 2>&1
36 elif [ $DSN = "sybase" ]
37 then
38 isql $DS < $REL_PATH/sybaseinputtest1.sql >/dev/null 2>&1
39 elif [ $DSN = "db2" ]
40 then
41 isql $DS < $REL_PATH/db2inputtest1.sql >/dev/null 2>&1
42 else
43 isql $DS < $REL_PATH/mysqlinputtest1.sql >/dev/null 2>&1
46 if [ $? -ne 0 ]
47 then
48 echo "DSN is not set for target db"
49 exit 2
52 # edit /tmp/csql/csqltable.conf
53 rm -f /tmp/csql/csqltable.conf
54 touch /tmp/csql/csqltable.conf
55 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
56 pid=$!
57 sleep 5
58 if [ $DSN = "oracle" ]
59 then
60 for a in 51 52 53 54 55
62 echo "insert into t1 values($a,'KKK');"
63 done >> $REL_PATH/oracsqlinputt1.sql
64 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/oracsqlinputt1.sql >/dev/null 2>&1
65 else
66 if [ $DSN = "db2" ]
67 then
68 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/csqldb2inputtest1.sql >/dev/null 2>&1
69 else
70 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/csqlinputtest1.sql >/dev/null 2>&1
74 if [ $? -ne 0 ]
75 then
76 echo "Server not opened"
77 exit 4;
80 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/selectstar.sql >/dev/null 2>&1
81 isql $DS < $REL_PATH/selectstar.sql
83 if [ $DSN = "oracle" ]
84 then
85 echo "select * from t1 where f1 in(10,30,50,54);" >> $REL_PATH/oraselect.sql
86 echo "select * from t1 where f1 between 20 and 54;" >> $REL_PATH/oraselect.sql
87 echo "update t1 set f2='LLL' where f1=20;" >> $REL_PATH/oraupdate.sql
88 echo "delete from t1 where f2='BBB';" >> $REL_PATH/oradelete.sql
89 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/oraselect.sql >/dev/null 2>&1
90 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/oraupdate.sql >/dev/null 2>&1
91 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/oradelete.sql >/dev/null 2>&1
92 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/selectstar.sql >/dev/null 2>&1
93 else
94 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/select.sql >/dev/null 2>&1
95 if [ $DSN = "db2" ]
96 then
97 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/db2update.sql >/dev/null 2>&1
98 else
99 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/update.sql >/dev/null 2>&1
101 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/delete.sql >/dev/null 2>&1
102 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6002 -g -s $REL_PATH/selectstar.sql >/dev/null 2>&1
105 isql $DS < $REL_PATH/selectstar.sql
106 isql $DS < $REL_PATH/dropt1t2t3.sql > /dev/null 2>&1
107 rm -f /tmp/csql/csqltable.conf
108 rm -f $REL_PATH/ora*.sql
109 touch /tmp/csql/csqltable.conf
110 kill -9 $pid
111 ipcrm -M 1199 -M 2277
112 kill `ps -el | grep csqlsqlserver | gawk -F" " '{ print $4 }'`
113 exit 0;