adding test scripts
[csql.git] / test / cache / CacheTable / test047.ksh
blob320842b38beadbeb9de50db71f82ca02a48f16eb
1 #!/bin/ksh
2 # Test Case
3 # create table 't1' with 5 fields in Target DB with records.
4 # Load the table 't1' in field mode in csql without condition.
5 # Example : select f1,f2,f3 from t1 ;
6 # Select query executes the selected records from csql.
9 #Author : Jitendra Lenka
10 input=${PWD}/cache/CacheTable/csql.conf
11 REL_PATH=.
12 if [ -s "$input" ]
13 then
14 REL_PATH=${PWD}/cache/CacheTable
16 rm -f /tmp/csql.conf
17 cp $REL_PATH/csql.conf /tmp
18 export CSQL_CONFIG_FILE=/tmp/csql.conf
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 isql $DS < ${REL_PATH}/createtable.sql >/dev/null 2>&1
30 if [ $? -ne 0 ]
31 then
32 exit 2;
35 echo Table t1,t2,t3,t4,t5 created with 2 records in target DB.
37 rm -f /tmp/csql/csqltable.conf /tmp/csql/csqlds.db
38 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.db
40 # cache from target to csql with -f option.
41 echo "cachetable -t t1 "
42 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
43 pid=$!
44 sleep 5
46 $CSQL_INSTALL_ROOT/bin/cachetable -t t1
47 if [ $? -ne 0 ]
48 then
49 rm -f /tmp/csql/csqltable.conf
50 touch /tmp/csql/csqltable.conf
51 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropall.sql > /dev/null 2>&1
52 isql $DS < ${REL_PATH}/dropall.sql >/dev/null 2>&1
53 kill -9 $pid
54 ipcrm -M 4000 -M 4500
55 exit 3;
58 echo "select * from t1;"
60 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectt1.sql
62 #setting for "psql dsn"
63 DSNAME="psql"
65 if [ $DSN != $DSNAME ]
66 then
67 echo "$DSNAME $POSTGRES_USER $POSTGRES_PASSWORD postgres" >>/tmp/csql/csqlds.conf # entries for csqlds.conf file.
68 isql $DSNAME $POSTGRES_USER $POSTGRES_PASSWORD < ${REL_PATH}/createtable.sql >/dev/null 2>&1
69 if [ $? -ne 0 ]
70 then
71 rm -f /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
72 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
73 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropall.sql > /dev/null 2>&1
74 isql $DS < ${REL_PATH}/dropall.sql >/dev/null 2>&1
75 kill -9 $pid
76 ipcrm -M 4000 -M 4500
77 exit 4;
79 else
80 DSNAME="myodbc3"
81 echo "$DSNAME NULL NULL postgres" >>/tmp/csql/csqlds.conf # entries for csqlds.conf file.
82 isql $DSNAME < ${REL_PATH}/createtable.sql >/dev/null 2>&1
83 if [ $? -ne 0 ]
84 then
85 rm -f /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
86 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
87 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropall.sql > /dev/null 2>&1
88 isql $DS < ${REL_PATH}/dropall.sql >/dev/null 2>&1
89 kill -9 $pid
90 ipcrm -M 4000 -M 4500
91 exit 5;
97 # cahetable with -d optiopn
98 # 'cachetable -t <tabName> -d <dsnName>
100 echo Table t1,t2,t3,t4,t5 created with 2 records in target DB.
101 echo "cachetable -t t2 -d psql"
103 $CSQL_INSTALL_ROOT/bin/cachetable -t t2 -d $DSNAME
104 if [ $? -ne 0 ]
105 then
106 rm -f /tmp/csql/csqlds.conf
107 touch /tmp/csql/csqlds.conf
108 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropall.sql > /dev/null 2>&1
109 isql $DS < ${REL_PATH}/dropall.sql >/dev/null 2>&1
110 isql $DSNAME < ${REL_PATH}/dropall.sql >/dev/null 2>&1
111 kill -9 $pid
112 ipcrm -M 4000 -M 4500
113 exit 6;
116 echo "select * from t2;"
117 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectt2.sql
121 rm -f /tmp/csql/csqltable.conf /tmp/csql/csqlds. conf
122 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
124 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropall.sql > /dev/null 2>&1
125 isql $DS < ${REL_PATH}/dropall.sql >/dev/null 2>&1
126 isql $DSNAME ${REL_PATH}/dropall.sql >/dev/null 2>&1
127 kill -9 $pid
128 ipcrm -M 4000 -M 4500
130 exit 0;