提交 48444692 编写于 作者: D dapan1121

add test case

上级 8d789e51
......@@ -10,9 +10,10 @@ sql connect
print ======================== dnode1 start
sql create function add_one as '/tmp/add_one.so' outputtype int;
sql create function add_one_64232 as '/tmp/add_one_64232.so' outputtype int;
sql create aggregate function sum_double as '/tmp/sum_double.so' outputtype int;
sql show functions;
if $rows != 2 then
if $rows != 3 then
return -1
endi
......@@ -1212,6 +1213,32 @@ endi
sql_error select add_one(f1),sub_one(f1) from tb1;
sql create table taaa (ts timestamp, f1 bigint);
sql insert into taaa values (now, 1);
sql insert into taaa values (now, 10);
sql insert into taaa values (now, 1000);
sql insert into taaa values (now, 100);
sql select add_one_64232(f1) from taaa;
if $rows != 4 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data10 != 11 then
return -1
endi
if $data20 != 1001 then
return -1
endi
if $data30 != 101 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
......
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct SUdfInit{
int maybe_null; /* 1 if function can return NULL */
int decimals; /* for real functions */
long long length; /* For string functions */
char *ptr; /* free pointer for function data */
int const_item; /* 0 if result is independent of arguments */
} SUdfInit;
void add_one_64232(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBUf, char* tsOutput,
int* numOfOutput, short otype, short obytes, SUdfInit* buf) {
int i;
int r = 0;
printf("add_one_64232 input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf);
if (itype == 5) {
for(i=0;i<numOfRows;++i) {
printf("input %d - %d", i, *((long *)data + i));
*((int *)dataOutput+i)=(int)*((long *)data + i) + 1;
printf(", output %d\n", *((int *)dataOutput+i));
if (tsOutput) {
*(long long*)tsOutput=1000000;
}
}
*numOfOutput=numOfRows;
printf("add_one_64232 out, numOfOutput:%d\n", *numOfOutput);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册