code reorg for Transactionw!
[csql.git] / test / sql / Datatype / test002.ksh
blob2785a3d069dfae896fdbf7e9d56928a79bd23dd3
1 #!/bin/ksh
2 # NOT NULL Constraint test on varchar
3 # Create table t1( f1 int, f2 varchar(15) NOT NULL);
4 # Insert 5 records into t1 having null values in f1 for some of the records.
5 # Null value should not be inserted into varchar field.
6 # Update Records set NULL value to varchar field. It should not be allowed
7 # Retrieve records based on varchar field.
9 CREATEFILE=${PWD}/sql/Datatype/csql.conf
10 REL_PATH=.
11 if [ -s "$CREATEFILE" ]
12 then
13 REL_PATH=`pwd`/sql/Datatype
16 echo "echo Create table t1( f1 int, f2 varchar(15) NOT NULL);" >${REL_PATH}/varchar_NOTNULL.sql
17 echo "Create table t1( f1 int, f2 varchar(15) NOT NULL);" >>${REL_PATH}/varchar_NOTNULL.sql
18 echo "insert into t1 values(1,'Lakshya1');" >>${REL_PATH}/varchar_NOTNULL.sql
19 echo "insert into t1 values(2,NULL);" >>${REL_PATH}/varchar_NOTNULL.sql
20 echo "insert into t1 values(3,'Lakshya3');" >>${REL_PATH}/varchar_NOTNULL.sql
21 echo "insert into t1 values(4,NULL);" >>${REL_PATH}/varchar_NOTNULL.sql
22 echo "insert into t1 values(5,'Lakshya5');" >>${REL_PATH}/varchar_NOTNULL.sql
23 echo "echo select * from t1;" >>${REL_PATH}/varchar_NOTNULL.sql
24 echo "select * from t1;" >>${REL_PATH}/varchar_NOTNULL.sql
25 echo "echo update t1 set f2=NULL where f1<=3;" >>${REL_PATH}/varchar_NOTNULL.sql
26 echo "update t1 set f2=NULL where f1<=3;" >>${REL_PATH}/varchar_NOTNULL.sql
27 echo "echo select * from t1;" >>${REL_PATH}/varchar_NOTNULL.sql
28 echo "select * from t1;" >>${REL_PATH}/varchar_NOTNULL.sql
30 echo "drop table t1;" >${REL_PATH}/dropt1.sql
32 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropt1.sql >/dev/null 2>&1
34 if [ "$VALGRIND" = "true" ]
35 then
36 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/varchar_NOTNULL.sql
37 else
38 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/varchar_NOTNULL.sql
39 if [ $? -ne 0 ]
40 then
41 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropt1.sql
42 rm -f ${REL_PATH}/varchar_NOTNULL.sql ${REL_PATH}/dropt1.sql
43 exit 1;
47 if [ "$VALGRIND" = "true" ]
48 then
49 valgrind --tool=memcheck --leak-check=full $CSQL_INSTALL_ROOT/bin/catalog -u root -p manager -l
50 else
51 $CSQL_INSTALL_ROOT/bin/catalog -u root -p manager -l
54 $CSQL_INSTALL_ROOT/bin/csql -s ${REL_PATH}/dropt1.sql
55 if [ $? -ne 0 ]
56 then
57 exit 2;
60 rm -f ${REL_PATH}/varchar_NOTNULL.sql ${REL_PATH}/dropt1.sql
61 exit 0;