*** empty log message ***
[csql.git] / test / cache / CacheTable / test032.ksh
blob83d174e296eb48fe93b2a365026536d88ab57d7c
1 #!/bin/ksh
3 # Create 't1' table with f1 int, f2 char(10) ,primarykey(f1)
4 # Insert some records with null values
5 # Cache t1 from target to csql.
6 # Select from CSQL cache node .It should give actual data as in target database
7 # it should be unloaded by -u option
9 input=${PWD}/cache/CacheTable/inputtest4.sql
10 REL_PATH=.
11 if [ -s "$input" ]
12 then
13 REL_PATH=${PWD}/cache/CacheTable
16 if [ "$DSN" = "sybase" ]
17 then
18 echo "create table t1 (f1 int,f2 char(10) NULL,primary key(f1));" >${REL_PATH}/t1create.sql
19 elif [ "$DSN" = "db2" ]
20 then
21 echo "create table t1 (f1 int NOT NULL,f2 char(10),primary key(f1));" >${REL_PATH}/t1create.sql
22 else
23 echo "create table t1 (f1 int,f2 char(10) ,primary key(f1));" >${REL_PATH}/t1create.sql
27 for a in 1 2 3 4 5
29 echo "insert into t1 values($a,'INDIA$a');"
30 echo "insert into t1 values($a+10 , NULL);"
31 done>>${REL_PATH}/t1create.sql
32 echo "t1create.sql file created"
33 echo "select * from t1;">${REL_PATH}/sel.sql
34 echo "select file created"
35 rm -f /tmp/csql.conf
36 cp $CSQL_CONFIG_FILE /tmp
37 export CSQL_CONFIG_FILE=/tmp/csql.conf
38 echo CACHE_TABLE=true >>$CSQL_CONFIG_FILE
39 echo DSN=$DSN >>$CSQL_CONFIG_FILE
40 DS="$DSN $DBUSER $PASSWORD"
41 rm -f /tmp/csql/csqlds.conf
42 touch /tmp/csql/csqlds.conf
43 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
44 if [ $? -ne 0 ]
45 then
46 exit 1;
49 isql $DS < ${REL_PATH}/t1create.sql >/dev/null 2>&1
50 if [ $? -ne 0 ]
51 then
52 rm -f ${REL_PATH}/sel.sql
53 rm -f ${REL_PATH}/t1create.sql
54 exit 1;
57 rm -f /tmp/csql/csqltable.conf
58 touch /tmp/csql/csqltable.conf
60 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 >/dev/null 2>&1
61 if [ $? -ne 0 ]
62 then
63 rm -f ${REL_PATH}/sel.sql
64 rm -f ${REL_PATH}/t1create.sql
65 exit 2;
67 echo "Select * from t1 in CSQL"
68 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/sel.sql
69 if [ $? -ne 0 ]
70 then
71 rm -f ${REL_PATH}/sel.sql
72 rm -f ${REL_PATH}/t1create.sql
73 exit 3;
76 echo "Checking for table created or not"
77 $CSQL_INSTALL_ROOT/bin/catalog -u root -p manager -l
78 if [ $? -ne 0 ]
79 then
80 rm -f ${REL_PATH}/sel.sql
81 rm -f ${REL_PATH}/t1create.sql
82 exit 4;
85 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u >/dev/null 2>&1
86 if [ $? -ne 0 ]
87 then
88 rm -f ${REL_PATH}/sel.sql
89 rm -f ${REL_PATH}/t1create.sql
90 exit 5;
92 echo "cache table 't1' unloaded by -u option"
93 echo "drop table t1;">${REL_PATH}/dp.sql
94 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dp.sql >/dev/null 2>&1
95 rm -f /tmp/csql/csqltable.conf
96 touch /tmp/csql/csqltable.conf
97 isql $DS < ${REL_PATH}/dp.sql >/dev/null 2>&1
98 rm -f ${REL_PATH}/dp.sql
99 rm -f ${REL_PATH}/sel.sql
100 rm -f ${REL_PATH}/t1create.sql
101 exit 0;