code reorg
[csql.git] / test / sql / Alter / test004.ksh
blob7ed29d954f2fa36e34698f951d6b02460f1cf710
1 #!/bin/ksh
2 # Renaming an existing column_name to same name.
3 # Create table t1(f1 int,f2 char(10));
4 # Alter table t1 rename column f2 to f2; It should be failed.
6 CREATEFILE=${PWD}/sql/Alter/csql.conf
7 REL_PATH=.
8 if [ -s "$CREATEFILE" ]
9 then
10 REL_PATH=`pwd`/sql/Alter
13 echo "create table t1(f1 int,f2 char(20));" >${REL_PATH}/createtable.sql
14 echo "insert into t1 values(1,'CSQL_LAKSHYA');" >>${REL_PATH}/createtable.sql
15 echo "echo alter table t1 rename column f2 to f2;" >${REL_PATH}/renamecolumn.sql
16 echo "alter table t1 rename column f2 to f2;" >>${REL_PATH}/renamecolumn.sql
17 echo "drop table t1;" >${REL_PATH}/dropt1.sql
19 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropt1.sql >/dev/null 2>&1
21 if [ "$VALGRIND" = "true" ]
22 then
23 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/createtable.sql
24 else
25 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/createtable.sql
26 if [ $? -ne 0 ]
27 then
28 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropt1.sql
29 rm -f ${REL_PATH}/createtable.sql ${REL_PATH}/renamecolumn.sql
30 rm -f ${REL_PATH}/dropt1.sql
31 exit 1;
35 $CSQL_INSTALL_ROOT/bin/catalog -u root -p manager -l >${REL_PATH}/beforealter
37 if [ "$VALGRIND" = "true" ]
38 then
39 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/renamecolumn.sql
40 else
41 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/renamecolumn.sql
42 if [ $? -ne 0 ]
43 then
44 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropt1.sql
45 rm -f ${REL_PATH}/createtable.sql ${REL_PATH}/renamecolumn.sql
46 rm -f ${REL_PATH}/dropt1.sql ${REL_PATH}/beforealter
47 exit 2;
51 $CSQL_INSTALL_ROOT/bin/catalog -u root -p manager -l >${REL_PATH}/afteralter
53 diff ${REL_PATH}/beforealter ${REL_PATH}/afteralter
54 if [ $? -eq 0 ]
55 then
56 echo Test Passed.
57 else
58 echo Test Failed.
61 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropt1.sql
62 if [ $? -ne 0 ]
63 then
64 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropt1.sql
65 rm -f ${REL_PATH}/createtable.sql ${REL_PATH}/renamecolumn.sql
66 rm -f ${REL_PATH}/dropt1.sql ${REL_PATH}/beforealter ${REL_PATH}/afteralter
67 exit 3;
69 rm -f ${REL_PATH}/createtable.sql ${REL_PATH}/renamecolumn.sql
70 rm -f ${REL_PATH}/dropt1.sql ${REL_PATH}/beforealter ${REL_PATH}/afteralter
72 exit 0;