adding test scripts
[csql.git] / test / cache / CacheTable / test021.ksh
blobec1416efbc37b3021d5054bf9806715cab433860
1 #!/bin/ksh
2 # Test Case
4 # Create table t4 with f1 int and f2 char,composite primary key (f1,f2) in target database
5 # Cache it with cachetable tool.
6 # Check the catalog table whether primary key is composite
7 # Insert some records which violate composite key
8 # Insertion should fail
9 # Unload the table. It should succeed.
11 input=${PWD}/cache/CacheTable/create.sql
12 REL_PATH=.
13 if [ -s "$input" ]
14 then
15 REL_PATH=${PWD}/cache/CacheTable
17 rm -f /tmp/csql.conf
18 cp $REL_PATH/csql.conf /tmp
19 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;
29 if [ $DSN = "db2" ]
30 then
31 isql $DS < ${REL_PATH}/create1db2.sql >/dev/null 2>&1
32 else
33 isql $DS < ${REL_PATH}/create1.sql >/dev/null 2>&1
35 if [ $? -ne 0 ]
36 then
37 exit 1;
39 echo table t4 is created with records in target db
40 $CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 &
41 pid=$!
42 sleep 5
44 rm -f /tmp/csql/csqltable.conf
45 touch /tmp/csql/csqltable.conf
47 echo "1 t4 NULL NULL NULL $DSN" >> /tmp/csql/csqltable.conf
49 $CSQL_INSTALL_ROOT/bin/cachetable -R
50 if [ $? -ne 0 ]
51 then
52 isql $DS < ${REL_PATH}/drop1.sql >/dev/null 2>&1
53 rm -f /tmp/csql/csqltable.conf
54 touch /tmp/csql/csqltable.conf
55 kill -9 $pid
56 ipcrm -M 4000 -M 4500
57 exit 2
60 $CSQL_INSTALL_ROOT/bin/catalog -u root -p manager -l
61 if [ $? -ne 0 ]
62 then
63 isql $DS < ${REL_PATH}/drop1.sql >/dev/null 2>&1
64 rm -f /tmp/csql/csqltable.conf
65 touch /tmp/csql/csqltable.conf
66 kill -9 $pid
67 ipcrm -M 4000 -M 4500
68 exit 3
71 $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/insert1.sql
73 if [ $? -ne 0 ]
74 then
75 isql $DS < ${REL_PATH}/drop1.sql >/dev/null 2>&1
76 rm -f /tmp/csql/csqltable.conf
77 touch /tmp/csql/csqltable.conf
78 kill -9 $pid
79 ipcrm -M 4000 -M 4500
80 exit 4
83 $CSQL_INSTALL_ROOT/bin/cachetable -U root -P manager -t t4 -u
84 isql $DS < ${REL_PATH}/drop1.sql >/dev/null 2>&1
85 rm -f /tmp/csql/csqltable.conf
86 touch /tmp/csql/csqltable.conf
87 kill -9 $pid
88 ipcrm -M 4000 -M 4500
89 exit 0;