*** empty log message ***
[csql.git] / test / cache / MultiDsn / Connection / test001.ksh
blob147e4cf5b3942c8f538818d979ed882dae46862b
1 #!/bin/ksh
2 #Test Case
4 # 1.csqlds.conf file has the entries for MySQL and Postgres
5 #
6 # Create table t1 in MyQL and t10 in Postgres.
7 # Select t1 and t10 from their respecrtive TDB.
8 # CACHE_TABLE=true in csql.conf file.
9 # cache t1 and t10 from respective TDB.
10 # select t1 and t10 from CSQL.
12 # Author : Jitendra Lenka
15 input=${PWD}/cache/MultiDsn/Connection/mysqltable.sql
16 REL_PATH=.
17 if [ -s "$input" ]
18 then
19 REL_PATH=${PWD}/cache/MultiDsn/Connection
22 rm -f /tmp/csql.conf
23 cp $REL_PATH/csql.conf /tmp
24 export CSQL_CONFIG_FILE=/tmp/csql.conf
27 echo DSN=$MYSQL_DSN >>$CSQL_CONFIG_FILE
29 rm -f /tmp/csql/csqlds.conf
30 touch /tmp/csql/csqlds.conf
33 $CSQL_INSTALL_ROOT/bin/csqlds -U $MYSQL_USER -P $MYSQL_PASSWORD -D $MYSQL_DSN -N $MYSQL_TDB -a
34 if [ $? -ne 0 ]
35 then
36 exit 1;
38 echo "Entries made for $MYSQL_DSN in csqlds.conf file."
41 $CSQL_INSTALL_ROOT/bin/csqlds -U $POSTGRES_USER -P $POSTGRES_PASSWORD -D $POSTGRES_DSN -N $POSTGRES_TDB -a
42 if [ $? -ne 0 ]
43 then
44 exit 2;
46 echo "Entries made for $POSTGRES_DSN in csqlds.conf file."
49 #Dropping the table if table is present
50 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
51 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
54 isql $DS1 < ${REL_PATH}/mysqltable.sql >/dev/null 2>&1
55 if [ $? -ne 0 ]
56 then
57 exit 3;
59 echo "Table 't1' is created in $MYSQL_DSN"
61 isql $DS1 < ${REL_PATH}/selectt1.sql
62 if [ $? -ne 0 ]
63 then
64 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
65 exit 4;
68 isql $DS2 < ${REL_PATH}/psqltable.sql >/dev/null 2>&1
69 if [ $? -ne 0 ]
70 then
71 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
72 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
73 exit 5;
75 echo "Table 't10' is created in $POSTGRES_DSN"
77 isql $DS2 < ${REL_PATH}/selectt10.sql
78 if [ $? -ne 0 ]
79 then
80 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
81 exit 6;
85 rm -f /tmp/csql/csqltable.conf
86 touch /tmp/csql/csqltable.conf
88 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
89 pid=$!
90 sleep 5
92 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 >/dev/null 2>&1
93 if [ $? -ne 0 ]
94 then
95 kill -9 $pid
96 ipcrm -M 1199 -M 2277
97 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
98 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
99 exit 7;
101 echo "Table t1 is cached from $MYSQL_DSN."
103 echo "select * from t1"
104 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectt1.sql
105 if [ $? -ne 0 ]
106 then
107 kill -9 $pid
108 ipcrm -M 1199 -M 2277
109 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
110 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
111 exit 8;
115 $CSQL_INSTALL_ROOT/bin/cachetable -t t10 -d $POSTGRES_DSN > /dev/null 2>&1
116 if [ $? -ne 0 ]
117 then
118 kill -9 $pid
119 ipcrm -M 1199 -M 2277
120 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
121 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
122 exit 9;
124 echo "Table 't10' is cached from $POSTGRES_DSN."
126 echo "select * from t10."
127 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectt10.sql
128 if [ $? -ne 0 ]
129 then
130 kill -9 $pid
131 ipcrm -M 1199 -M 2277
132 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
133 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
134 exit 10;
138 rm -f /tmp/csql/csqltable.conf
139 touch /tmp/csql/csqltable.conf
141 isql $DS1 < ${REL_PATH}/drop.sql >/dev/null 2>&1
142 isql $DS2 < ${REL_PATH}/drop.sql >/dev/null 2>&1
145 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/drop.sql > /dev/null 2>&1
146 kill -9 $pid
147 ipcrm -M 1199 -M 2277
148 exit 0;