adding test scripts
[csql.git] / test / cache / Gateway / test013.ksh
blobbba2ef4545d090d092a9d775a165b105cf8a0cfd
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 export CSQL_CONFIG_FILE=/tmp/csql.conf
18 echo DSN=$DSN >>$CSQL_CONFIG_FILE
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;
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
37 for a in 1 2 3 4 5
39 echo "insert into t1 values($a,'INDIA$a');"
40 echo "insert into t1 values($a+10 , NULL);"
41 done>>${REL_PATH}/t1create.sql
42 echo "t1create.sql file created"
43 echo "select * from t1;">${REL_PATH}/sel.sql
44 echo "select file created"
45 isql $DS < ${REL_PATH}/t1create.sql >/dev/null 2>&1
46 if [ $? -ne 0 ]
47 then
48 rm -f ${REL_PATH}/sel.sql
49 rm -f ${REL_PATH}/t1create.sql
50 exit 1;
53 rm -f /tmp/csql/csqltable.conf
54 touch /tmp/csql/csqltable.conf
55 echo "drop table t1;">${REL_PATH}/dp.sql
57 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
58 pid=$!
59 sleep 5
61 echo "Select * from t1 in CSQL"
62 $CSQL_INSTALL_ROOT/bin/csql -g -s ${REL_PATH}/sel.sql
63 if [ $? -ne 0 ]
64 then
65 rm -f ${REL_PATH}/sel.sql
66 rm -f ${REL_PATH}/t1create.sql
67 isql $DS < ${REL_PATH}/dp.sql >/dev/null 2>&1
68 exit 3;
71 echo "Checking for table created or not"
72 $CSQL_INSTALL_ROOT/bin/catalog -u root -p manager -l
73 if [ $? -ne 0 ]
74 then
75 rm -f ${REL_PATH}/sel.sql
76 rm -f ${REL_PATH}/t1create.sql
77 isql $DS < ${REL_PATH}/dp.sql >/dev/null 2>&1
78 exit 4;
81 rm -f /tmp/csql/csqltable.conf
82 touch /tmp/csql/csqltable.conf
83 isql $DS < ${REL_PATH}/dp.sql >/dev/null 2>&1
85 rm -f ${REL_PATH}/dp.sql
86 rm -f ${REL_PATH}/sel.sql
87 rm -f ${REL_PATH}/t1create.sql
88 kill -9 $pid
89 ipcrm -M 1199 -M 2277
90 exit 0;