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