code reorg for Transactionw!
[csql.git] / test / cache / DDL / test004.ksh
blobd36147819c6fc9ce15ecf16c56a5480d27e7c1e1
1 #!/bin/ksh
3 # Load table t1 from MySQL using csql -g enter the following command
4 # create index idx on t1 (f1),Index should be created only in csql and not in mysql
6 # Run this test only under csql/test or on this directory.
7 # Otherwise, it may fail
8 CSQL_CONF=${PWD}/cache/DDL/csql.conf
9 input=${PWD}/cache/DDL/csqlinputtest1.sql
10 REL_PATH=.
11 if [ -s "$input" ]
12 then
13 REL_PATH=${PWD}/cache/DDL
16 rm -f /tmp/csql.conf
17 cp $REL_PATH/csql.conf /tmp
18 export CSQL_CONFIG_FILE=/tmp/csql.conf
20 echo DSN=$DSN >>$CSQL_CONFIG_FILE
21 DS="$DSN $DBUSER $PASSWORD"
22 rm -f /tmp/csql/csqlds.conf
23 touch /tmp/csql/csqlds.conf
24 $CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a
25 if [ $? -ne 0 ]
26 then
27 exit 1;
31 echo "create table t1(f1 int,f2 int,f3 char(10));">$REL_PATH/t1.sql
32 isql $DS < $REL_PATH/t1.sql >/dev/null
33 if [ $? -ne 0 ]
34 then
35 rm -f /tmp/csql/csqlds.conf
36 touch /tmp/csql/csqlds.conf
37 echo "unable to create in target db"
38 cp /tmp/csql.conf $CSQL_CONFIG_FILE
39 rm -f $REL_PATH/t1.sql
40 exit 1
43 rm /tmp/csql/csqltable.conf
44 touch /tmp/csql/csqltable.conf
45 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
46 pid=$!
47 sleep 5
48 $CSQL_INSTALL_ROOT/bin/cachetable -t t1
49 if [ $? -ne 0 ]
50 then
51 echo "unable to cache table from target db"
52 rm -f /tmp/csql/csqlds.conf
53 touch /tmp/csql/csqlds.conf
54 isql $DS < $REL_PATH/dropall.sql >/dev/null 2>&1
55 rm -f $REL_PATH/t1.sql
56 exit 2
58 echo "create index ind1 on t1(f2);">$REL_PATH/cre.sql
59 $CSQL_INSTALL_ROOT/bin/csql -g -s $REL_PATH/cre.sql
60 $CSQL_INSTALL_ROOT/bin/catalog -u root -p manager -l
61 if [ $? -ne 0 ]
62 then
63 echo "unable to Unload the table"
64 rm -f /tmp/csql/csqlds.conf
65 touch /tmp/csql/csqlds.conf
66 isql $DS < $REL_PATH/dropall.sql >/dev/null 2>&1
67 rm -f $REL_PATH/t1.sql
68 rm -f $REL_PATH/cre.sql
69 kill -9 $pid
70 ipcrm -M 1199 -M 2277 -M 1947
71 exit 3
73 echo "desc t1;">$REL_PATH/a.sql
74 $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u
75 if [ $? -ne 0 ]
76 then
77 echo "unable to Unload the table"
78 isql $DS < $REL_PATH/dropall.sql >/dev/null 2>&1
79 rm -f /tmp/csql/csqlds.conf
80 touch /tmp/csql/csqlds.conf
81 rm -f $REL_PATH/t1.sql
82 rm -f $REL_PATH/cre.sql
83 rm -f $REL_PATH/a.sql
84 kill -9 $pid
85 ipcrm -M 1199 -M 2277 -M 1947
86 exit 4
88 isql $DS < $REL_PATH/dropall.sql >/dev/null 2>&1
89 kill -9 $pid
90 ipcrm -M 1199 -M 2277 -M 1947
91 rm /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
92 touch /tmp/csql/csqltable.conf /tmp/csql/csqlds.conf
93 rm -f $REL_PATH/t1.sql
94 rm -f $REL_PATH/cre.sql
95 rm -f $REL_PATH/a.sql
96 exit 0