adding test scripts
[csql.git] / test / cache / Gateway / test013n.ksh
blob5b84d41f03871abf4be3d1b635b8488324cb6f7f
1 #!/bin/ksh
3 # Create 't1' table with f1 int, f2 char(10) ,primarykey(f1) in target database
4 # Insert some records with null values
5 # Select from CSQL with -g .It should give actual data as in target database
6 # it should be unloaded by -u option
8 input=${PWD}/cache/Gateway/complex.sql
9 REL_PATH=.
10 if [ -s "$input" ]
11 then
12 REL_PATH=${PWD}/cache/Gateway
15 cp $REL_PATH/csql.conf /tmp/csql.conf
16 echo CSQL_SQL_SERVER=true >>/tmp/csql.conf
17 echo PORT=6026 >>/tmp/csql.conf
18 export CSQL_CONFIG_FILE=/tmp/csql.conf
19 DS="$DSN $DBUSER $PASSWORD"
20 rm -f /tmp/csql/csqlds.conf
21 touch /tmp/csql/csqlds.conf
22 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
23 if [ $? -ne 0 ]
24 then
25 exit 1;
27 echo DSN=$DSN >>$CSQL_CONFIG_FILE
28 if [ $DSN = "sybase" ]
29 then
30 echo "create table t1 (f1 int ,f2 char(10) NULL,primary key(f1));" >${REL_PATH}/t1create.sql
31 elif [ $DSN = "db2" ]
32 then
33 echo "create table t1 (f1 int NOT NULL ,f2 char(10) ,primary key(f1));" >${REL_PATH}/t1create.sql
34 else
35 echo "create table t1 (f1 int,f2 char(10),primary key(f1));" >${REL_PATH}/t1create.sql
38 for a in 1 2 3 4 5
40 echo "insert into t1 values($a,'INDIA$a');"
41 echo "insert into t1 values($a+10 , NULL);"
42 done>>${REL_PATH}/t1create.sql
43 echo "t1create.sql file created"
44 echo "select * from t1;">${REL_PATH}/sel.sql
45 echo "select file created"
46 isql $DS < ${REL_PATH}/t1create.sql >/dev/null 2>&1
47 if [ $? -ne 0 ]
48 then
49 rm -f ${REL_PATH}/sel.sql
50 rm -f ${REL_PATH}/t1create.sql
51 exit 1;
54 rm -f /tmp/csql/csqltable.conf
55 touch /tmp/csql/csqltable.conf
56 echo "drop table t1;">${REL_PATH}/dp.sql
58 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
59 pid=$!
60 sleep 5
62 echo "Select * from t1 in CSQL"
63 $CSQL_INSTALL_ROOT/bin/csql -H localhost -P 6026 -g -s ${REL_PATH}/sel.sql
64 if [ $? -ne 0 ]
65 then
66 rm -f ${REL_PATH}/sel.sql
67 rm -f ${REL_PATH}/t1create.sql
68 isql $DS < ${REL_PATH}/dp.sql >/dev/null 2>&1
69 exit 3;
72 echo "Checking for table created or not"
73 $CSQL_INSTALL_ROOT/bin/catalog -u root -p manager -l
74 if [ $? -ne 0 ]
75 then
76 rm -f ${REL_PATH}/sel.sql
77 rm -f ${REL_PATH}/t1create.sql
78 isql $DS < ${REL_PATH}/dp.sql >/dev/null 2>&1
79 exit 4;
82 rm -f /tmp/csql/csqltable.conf
83 touch /tmp/csql/csqltable.conf
84 isql $DS < ${REL_PATH}/dp.sql >/dev/null 2>&1
86 rm -f ${REL_PATH}/dp.sql
87 rm -f ${REL_PATH}/sel.sql
88 rm -f ${REL_PATH}/t1create.sql
89 kill -9 $pid
90 ipcrm -M 1199 -M 2277
91 kill `ps -el | grep csqlsqlserver | gawk -F" " '{ print $4 }'`
92 exit 0;