2 #Testing TIMESTAMP_DIFF function using minute
3 # Create table t1(f1 timestamp, f2 timestamp);
4 # insert into t1 values('2002-01-01 01:01:01', '2002-01-01 01:01:01');
5 # insert into t1 values('2002-01-01 01:01:01', '2002-01-01 01:10:01');
6 # insert into t1 values('2002-01-01 01:01:01', '2002-01-01 05:10:01');
7 # insert into t1 values('2002-01-01 01:01:01', '2002-02-03 05:05:01');
8 # insert into t1 values('2002-01-01 01:01:01', '2002-03-01 05:05:01');
9 # insert into t1 values('2004-01-01 01:01:01', '2004-02-01 05:05:01');
10 # insert into t1 values('2004-01-01 01:01:01', '2004-03-01 05:05:01');
11 # insert into t1 values('2002-01-01 01:01:01', '2004-03-01 05:05:01');
13 # select * from t1 where timestamp_diff(minute,f1,f2) =0;
14 # select * from t1 where timestamp_diff(minute,f2,f1) =9;
15 # select * from t1 where timestamp_diff(minute,f2,f1)<=249;
16 # select * from t1 where timestamp_diff(minute,f2,f1) =85204;
17 # select * from t1 where timestamp_diff(minute,f2,f1)>=85204;
18 # select * from t1 where timestamp_diff(minute,f2,f1) =44884;
19 # select * from t1 where timestamp_diff(minute,f2,f1) =86644;
20 # select * from t1 where timestamp_diff(minute,f2,f1)!=86644;
21 # select * from t1 where timestamp_diff(minute,f2,f1) =1137844;
22 # select * from t1 where timestamp_diff(minute,f2,f1)!=1137844;
24 CREATEFILE
=${PWD}/sql
/ScalarFunction
/csql.conf
26 if [ -s "$CREATEFILE" ]
28 REL_PATH
=`pwd`/sql
/ScalarFunction
31 echo "drop table t1;" >${REL_PATH}/dropt1.sql
33 $CSQL_INSTALL_ROOT/bin
/csql
-s ${REL_PATH}/dropt1.sql
>/dev
/null
2>&1
35 if [ "$VALGRIND" = "true" ]
37 valgrind
--tool=memcheck
--leak-check=full
$CSQL_INSTALL_ROOT/bin
/csql
-s ${REL_PATH}/timestamp_diff_minute.sql
39 $CSQL_INSTALL_ROOT/bin
/csql
-s ${REL_PATH}/timestamp_diff_minute.sql
42 $CSQL_INSTALL_ROOT/bin
/csql
-s ${REL_PATH}/dropt1.sql
43 rm -f ${REL_PATH}/dropt1.sql
48 $CSQL_INSTALL_ROOT/bin
/csql
-s ${REL_PATH}/dropt1.sql
54 rm -f ${REL_PATH}/dropt1.sql