2 #Testing TIMESTAMP_SUB function by adding second value
3 # Create table t1(f1 timestamp, f2 timestamp);
4 # insert into t1 values('2001-01-01 01:01:01', '2001-05-05 05:05:01');
5 # insert into t1 values('2002-01-01 01:01:01', '2002-03-05 05:05:01');
6 # insert into t1 values('2003-01-01 01:01:01', '2003-03-05 05:05:01');
7 # insert into t1 values('2004-01-01 01:01:01', '2004-03-05 05:05:01');
8 # insert into t1 values('2005-01-01 01:01:01', '2005-01-05 05:05:01');
10 # select * from t1 where timestamp_sub(f2 interval 14640 second) ='2003-03-05 01:01:01';
11 # select * from t1 where timestamp_sub(f2 interval 14640 second)<='2003-03-05 01:01:01';
12 # select * from t1 where timestamp_sub(f2 interval 14640 second) >'2003-03-05 01:01:01';
13 # select * from t1 where timestamp_sub(f2 interval 864000 second) ='2003-02-23 05:05:01';
14 # select * from t1 where timestamp_sub(f2 interval 864000 second)>='2003-02-23 05:05:01';
15 # select * from t1 where timestamp_sub(f2 interval 31622400 second) ='2004-01-05 05:05:01';
16 # select * from t1 where timestamp_sub(f2 interval 31622400 second)!='2004-01-05 05:05:01';
18 CREATEFILE
=${PWD}/sql
/ScalarFunction
/csql.conf
20 if [ -s "$CREATEFILE" ]
22 REL_PATH
=`pwd`/sql
/ScalarFunction
25 echo "drop table t1;" >${REL_PATH}/dropt1.sql
27 $CSQL_INSTALL_ROOT/bin
/csql
-s ${REL_PATH}/dropt1.sql
>/dev
/null
2>&1
29 if [ "$VALGRIND" = "true" ]
31 valgrind
--tool=memcheck
--leak-check=full
$CSQL_INSTALL_ROOT/bin
/csql
-s ${REL_PATH}/timestamp_sub_second.sql
33 $CSQL_INSTALL_ROOT/bin
/csql
-s ${REL_PATH}/timestamp_sub_second.sql
36 $CSQL_INSTALL_ROOT/bin
/csql
-s ${REL_PATH}/dropt1.sql
37 rm -f ${REL_PATH}/dropt1.sql
42 $CSQL_INSTALL_ROOT/bin
/csql
-s ${REL_PATH}/dropt1.sql
48 rm -f ${REL_PATH}/dropt1.sql