exp changes
[csql.git] / test / tools / copystmt / test001.ksh
blobfc1d1f18d7b96beee7fb7a60fc2cba89e9803c93
1 #!/bin/ksh
2 #create table t1 with f1 int and f2 char(20). insert 10 different record.
3 # a. create a copy of table t1 [ create table ct1 as select * from t1]
4 # b. create a conditional copy of table t1 [create table ct2 as select * from t1 where f1 < conditon]
5 # c. create a copy of table t1 [create table ct3 as select f2 from t1]
6 # d. create a copy of table t1 [create table ct4 as select f2 from t1 where f1 < conditon ]
7 # Drop all tables.
9 QUITFILE=${PWD}/tools/copystmt/quit.sql
10 REL_PATH=.
11 if [ -s "$QUITFILE" ]
12 then
13 REL_PATH=`pwd`/tools/copystmt
16 echo "echo create table t1(f1 int,f2 char(20));" >${REL_PATH}/create_t1.sql
17 echo "create table t1(f1 int,f2 char(20));" >>${REL_PATH}/create_t1.sql
18 i=1
19 while [ $i -le 10 ]
21 echo "insert into t1 values($i,'CSQL$i');" >>${REL_PATH}/create_t1.sql
22 i=`expr $i + 1`
23 done
25 echo "echo create table ct1 as select * from t1;" >${REL_PATH}/create_ct1.sql
26 echo "create table ct1 as select * from t1;" >>${REL_PATH}/create_ct1.sql
28 echo "echo create table ct2 as select * from t1 where f1 < 6;" >${REL_PATH}/create_ct2.sql
29 echo "create table ct2 as select * from t1 where f1 < 6;" >>${REL_PATH}/create_ct2.sql
31 echo "echo create table ct3 as select f2 from t1;" >${REL_PATH}/create_ct3.sql
32 echo "create table ct3 as select f2 from t1;" >>${REL_PATH}/create_ct3.sql
34 echo "echo create table ct4 as select f2 from t1 where f1 >3 and f1 <8;" >${REL_PATH}/create_ct4.sql
35 echo "create table ct4 as select f2 from t1 where f1 >3 and f1 <8;" >>${REL_PATH}/create_ct4.sql
37 echo "Drop table t1;" >${REL_PATH}/drop.sql
38 echo "Drop table ct1;">>${REL_PATH}/drop.sql
39 echo "Drop table ct2;">>${REL_PATH}/drop.sql
40 echo "Drop table ct3;">>${REL_PATH}/drop.sql
41 echo "Drop table ct4;">>${REL_PATH}/drop.sql
43 if [ "$VALGRIND" = "true" ]
44 then
45 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_t1.sql 2> $0.valgr
46 else
47 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_t1.sql
48 if [ $? -ne 0 ]
49 then
50 echo Failed
51 rm -f ${REL_PATH}/create_t1.sql ${REL_PATH}/create_ct1.sql.sql ${REL_PATH}/create_ct2.sql ${REL_PATH}/create_ct3.sql ${REL_PATH}/create_ct4.sql ${REL_PATH}/drop.sql
52 exit 1;
56 if [ "$VALGRIND" = "true" ]
57 then
58 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_ct1.sql 2>> $0.valgr
59 else
60 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_ct1.sql
61 if [ $? -ne 0 ]
62 then
63 echo Failed
64 rm -f ${REL_PATH}/create_t1.sql ${REL_PATH}/create_ct1.sql.sql ${REL_PATH}/create_ct2.sql ${REL_PATH}/create_ct3.sql ${REL_PATH}/create_ct4.sql ${REL_PATH}/drop.sql
65 exit 2;
69 if [ "$VALGRIND" = "true" ]
70 then
71 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_ct2.sql 2>> $0.valgr
72 else
73 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_ct2.sql
74 if [ $? -ne 0 ]
75 then
76 echo Failed
77 rm -f ${REL_PATH}/create_t1.sql ${REL_PATH}/create_ct1.sql.sql ${REL_PATH}/create_ct2.sql ${REL_PATH}/create_ct3.sql ${REL_PATH}/create_ct4.sql ${REL_PATH}/drop.sql
78 exit 3;
82 if [ "$VALGRIND" = "true" ]
83 then
84 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_ct3.sql 2>> $0.valgr
85 else
86 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_ct3.sql
87 if [ $? -ne 0 ]
88 then
89 echo Failed
90 rm -f ${REL_PATH}/create_t1.sql ${REL_PATH}/create_ct1.sql.sql ${REL_PATH}/create_ct2.sql ${REL_PATH}/create_ct3.sql ${REL_PATH}/create_ct4.sql ${REL_PATH}/drop.sql
91 exit 4;
95 if [ "$VALGRIND" = "true" ]
96 then
97 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_ct4.sql 2>> $0.valgr
98 else
99 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/create_ct4.sql
100 if [ $? -ne 0 ]
101 then
102 echo Failed
103 rm -f ${REL_PATH}/create_t1.sql ${REL_PATH}/create_ct1.sql.sql ${REL_PATH}/create_ct2.sql ${REL_PATH}/create_ct3.sql ${REL_PATH}/create_ct4.sql ${REL_PATH}/drop.sql
104 exit 5;
108 if [ "$VALGRIND" = "true" ]
109 then
110 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csqldump 2>> $0.valgr
111 else
112 $CSQL_INSTALL_ROOT/bin/csqldump
113 if [ $? -ne 0 ]
114 then
115 echo Failed
116 rm -f ${REL_PATH}/create_t1.sql ${REL_PATH}/create_ct1.sql.sql ${REL_PATH}/create_ct2.sql ${REL_PATH}/create_ct3.sql ${REL_PATH}/create_ct4.sql ${REL_PATH}/drop.sql
117 exit 6;
121 $CSQL_INSTALL_ROOT/bin/csql -u root -p manager -s ${REL_PATH}/drop.sql
122 rm -f ${REL_PATH}/create_t1.sql ${REL_PATH}/create_ct1.sql.sql ${REL_PATH}/create_ct2.sql ${REL_PATH}/create_ct3.sql ${REL_PATH}/create_ct4.sql ${REL_PATH}/drop.sql
123 echo passed
124 exit 0;