Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
042088f2
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
042088f2
编写于
8月 20, 2021
作者:
D
dapan1121
提交者:
GitHub
8月 20, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7451 from taosdata/hotfix/TD-6180
[td-6180]fix illegal sql issue
上级
97281931
9449c97f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
389 addition
and
1 deletion
+389
-1
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+2
-0
tests/script/api/makefile
tests/script/api/makefile
+4
-1
tests/script/api/stmt_function.c
tests/script/api/stmt_function.c
+383
-0
未找到文件。
src/client/src/tscPrepare.c
浏览文件 @
042088f2
...
@@ -206,6 +206,8 @@ static int normalStmtPrepare(STscStmt* stmt) {
...
@@ -206,6 +206,8 @@ static int normalStmtPrepare(STscStmt* stmt) {
return
code
;
return
code
;
}
}
start
=
i
+
token
.
n
;
start
=
i
+
token
.
n
;
}
else
if
(
token
.
type
==
TK_ILLEGAL
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
&
stmt
->
pSql
->
cmd
),
"invalid sql"
);
}
}
i
+=
token
.
n
;
i
+=
token
.
n
;
...
...
tests/script/api/makefile
浏览文件 @
042088f2
...
@@ -6,7 +6,8 @@ TARGET=exe
...
@@ -6,7 +6,8 @@ TARGET=exe
LFLAGS
=
'-Wl,-rpath,/usr/local/taos/driver/'
-ltaos
-lpthread
-lm
-lrt
LFLAGS
=
'-Wl,-rpath,/usr/local/taos/driver/'
-ltaos
-lpthread
-lm
-lrt
CFLAGS
=
-O0
-g
-Wall
-Wno-deprecated
-fPIC
-Wno-unused-result
-Wconversion
\
CFLAGS
=
-O0
-g
-Wall
-Wno-deprecated
-fPIC
-Wno-unused-result
-Wconversion
\
-Wno-char-subscripts
-D_REENTRANT
-Wno-format
-D_REENTRANT
-DLINUX
\
-Wno-char-subscripts
-D_REENTRANT
-Wno-format
-D_REENTRANT
-DLINUX
\
-Wno-unused-function
-D_M_X64
-I
/usr/local/taos/include
-std
=
gnu99
-Wno-unused-function
-D_M_X64
-I
/usr/local/taos/include
-std
=
gnu99
\
-fsanitize
=
address
all
:
$(TARGET)
all
:
$(TARGET)
...
@@ -14,8 +15,10 @@ exe:
...
@@ -14,8 +15,10 @@ exe:
gcc
$(CFLAGS)
./batchprepare.c
-o
$(ROOT)
batchprepare
$(LFLAGS)
gcc
$(CFLAGS)
./batchprepare.c
-o
$(ROOT)
batchprepare
$(LFLAGS)
gcc
$(CFLAGS)
./stmtBatchTest.c
-o
$(ROOT)
stmtBatchTest
$(LFLAGS)
gcc
$(CFLAGS)
./stmtBatchTest.c
-o
$(ROOT)
stmtBatchTest
$(LFLAGS)
gcc
$(CFLAGS)
./stmtTest.c
-o
$(ROOT)
stmtTest
$(LFLAGS)
gcc
$(CFLAGS)
./stmtTest.c
-o
$(ROOT)
stmtTest
$(LFLAGS)
gcc
$(CFLAGS)
./stmt_function.c
-o
$(ROOT)
stmt_function
$(LFLAGS)
clean
:
clean
:
rm
$(ROOT)
batchprepare
rm
$(ROOT)
batchprepare
rm
$(ROOT)
stmtBatchTest
rm
$(ROOT)
stmtBatchTest
rm
$(ROOT)
stmtTest
rm
$(ROOT)
stmtTest
rm
$(ROOT)
stmt_function
tests/script/api/stmt_function.c
0 → 100644
浏览文件 @
042088f2
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "taos.h"
#include <sys/time.h>
#include <pthread.h>
#include <unistd.h>
#include <assert.h>
void
execute_simple_sql
(
void
*
taos
,
char
*
sql
)
{
TAOS_RES
*
result
=
taos_query
(
taos
,
sql
);
if
(
result
==
NULL
||
taos_errno
(
result
)
!=
0
)
{
printf
(
"failed to %s, Reason: %s
\n
"
,
sql
,
taos_errstr
(
result
));
taos_free_result
(
result
);
exit
(
EXIT_FAILURE
);
}
taos_free_result
(
result
);
}
void
taos_stmt_init_test
()
{
printf
(
"start taos_stmt_init test
\n
"
);
void
*
taos
=
NULL
;
TAOS_STMT
*
stmt
=
NULL
;
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
==
NULL
);
// ASM ERROR
// assert(taos_stmt_close(stmt) != 0);
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"Cannot connect to tdengine server
\n
"
);
exit
(
EXIT_FAILURE
);
}
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
printf
(
"finish taos_stmt_init test
\n
"
);
}
void
taos_stmt_preprare_test
()
{
printf
(
"start taos_stmt_prepare test
\n
"
);
char
*
stmt_sql
=
calloc
(
1
,
1048576
);
TAOS_STMT
*
stmt
=
NULL
;
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
!=
0
);
void
*
taos
=
NULL
;
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"Cannot connect to tdengine server
\n
"
);
exit
(
EXIT_FAILURE
);
}
execute_simple_sql
(
taos
,
"drop database if exists stmt_test"
);
execute_simple_sql
(
taos
,
"create database stmt_test"
);
execute_simple_sql
(
taos
,
"use stmt_test"
);
execute_simple_sql
(
taos
,
"create table super(ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(8), c6 smallint, c7 tinyint, c8 bool, c9 nchar(8), c10 timestamp) tags (t1 int, t2 bigint, t3 float, t4 double, t5 binary(8), t6 smallint, t7 tinyint, t8 bool, t9 nchar(8))"
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
// below will make client dead lock
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
// assert(taos_stmt_close(stmt) == 0);
// stmt = taos_stmt_init(taos);
assert
(
stmt
!=
NULL
);
sprintf
(
stmt_sql
,
"select from ?"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
!=
0
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
sprintf
(
stmt_sql
,
"insert into ? values (?,?,?,?,?,?,?,?,?,?,?)"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
sprintf
(
stmt_sql
,
"insert into super values (?,?,?,?,?,?,?,?,?,?,?)"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
!=
0
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
sprintf
(
stmt_sql
,
"insert into ? values (?,?,?,?,?,?,?,?,1,?,?,?)"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
free
(
stmt_sql
);
printf
(
"finish taos_stmt_prepare test
\n
"
);
}
void
taos_stmt_set_tbname_test
()
{
printf
(
"start taos_stmt_set_tbname test
\n
"
);
TAOS_STMT
*
stmt
=
NULL
;
char
*
name
=
calloc
(
1
,
200
);
// ASM ERROR
// assert(taos_stmt_set_tbname(stmt, name) != 0);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"Cannot connect to tdengine server
\n
"
);
exit
(
EXIT_FAILURE
);
}
execute_simple_sql
(
taos
,
"drop database if exists stmt_test"
);
execute_simple_sql
(
taos
,
"create database stmt_test"
);
execute_simple_sql
(
taos
,
"use stmt_test"
);
execute_simple_sql
(
taos
,
"create table super(ts timestamp, c1 int)"
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
assert
(
taos_stmt_set_tbname
(
stmt
,
name
)
!=
0
);
char
*
stmt_sql
=
calloc
(
1
,
1000
);
sprintf
(
stmt_sql
,
"insert into ? values (?,?)"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
sprintf
(
name
,
"super"
);
assert
(
stmt
!=
NULL
);
assert
(
taos_stmt_set_tbname
(
stmt
,
name
)
==
0
);
free
(
name
);
free
(
stmt_sql
);
taos_stmt_close
(
stmt
);
printf
(
"finish taos_stmt_set_tbname test
\n
"
);
}
void
taos_stmt_set_tbname_tags_test
()
{
printf
(
"start taos_stmt_set_tbname_tags test
\n
"
);
TAOS_STMT
*
stmt
=
NULL
;
char
*
name
=
calloc
(
1
,
20
);
TAOS_BIND
*
tags
=
calloc
(
1
,
sizeof
(
TAOS_BIND
));
// ASM ERROR
// assert(taos_stmt_set_tbname_tags(stmt, name, tags) != 0);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"Cannot connect to tdengine server
\n
"
);
exit
(
EXIT_FAILURE
);
}
execute_simple_sql
(
taos
,
"drop database if exists stmt_test"
);
execute_simple_sql
(
taos
,
"create database stmt_test"
);
execute_simple_sql
(
taos
,
"use stmt_test"
);
execute_simple_sql
(
taos
,
"create stable super(ts timestamp, c1 int) tags (id int)"
);
execute_simple_sql
(
taos
,
"create table tb using super tags (1)"
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
char
*
stmt_sql
=
calloc
(
1
,
1000
);
sprintf
(
stmt_sql
,
"insert into ? using super tags (?) values (?,?)"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
assert
(
taos_stmt_set_tbname_tags
(
stmt
,
name
,
tags
)
!=
0
);
sprintf
(
name
,
"tb"
);
assert
(
taos_stmt_set_tbname_tags
(
stmt
,
name
,
tags
)
!=
0
);
int
t
=
1
;
tags
->
buffer_length
=
TSDB_DATA_TYPE_INT
;
tags
->
buffer_length
=
sizeof
(
uint32_t
);
tags
->
buffer
=
&
t
;
tags
->
length
=
&
tags
->
buffer_length
;
tags
->
is_null
=
NULL
;
assert
(
taos_stmt_set_tbname_tags
(
stmt
,
name
,
tags
)
==
0
);
free
(
stmt_sql
);
free
(
name
);
free
(
tags
);
taos_stmt_close
(
stmt
);
printf
(
"finish taos_stmt_set_tbname_tags test
\n
"
);
}
void
taos_stmt_set_sub_tbname_test
()
{
printf
(
"start taos_stmt_set_sub_tbname test
\n
"
);
TAOS_STMT
*
stmt
=
NULL
;
char
*
name
=
calloc
(
1
,
200
);
// ASM ERROR
// assert(taos_stmt_set_sub_tbname(stmt, name) != 0);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"Cannot connect to tdengine server
\n
"
);
exit
(
EXIT_FAILURE
);
}
execute_simple_sql
(
taos
,
"drop database if exists stmt_test"
);
execute_simple_sql
(
taos
,
"create database stmt_test"
);
execute_simple_sql
(
taos
,
"use stmt_test"
);
execute_simple_sql
(
taos
,
"create stable super(ts timestamp, c1 int) tags (id int)"
);
execute_simple_sql
(
taos
,
"create table tb using super tags (1)"
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
char
*
stmt_sql
=
calloc
(
1
,
1000
);
sprintf
(
stmt_sql
,
"insert into ? values (?,?)"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
assert
(
taos_stmt_set_sub_tbname
(
stmt
,
name
)
!=
0
);
sprintf
(
name
,
"tb"
);
assert
(
taos_stmt_set_sub_tbname
(
stmt
,
name
)
==
0
);
// assert(taos_load_table_info(taos, "super, tb") == 0);
// assert(taos_stmt_set_sub_tbname(stmt, name) == 0);
free
(
name
);
free
(
stmt_sql
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
printf
(
"finish taos_stmt_set_sub_tbname test
\n
"
);
}
void
taos_stmt_bind_param_test
()
{
printf
(
"start taos_stmt_bind_param test
\n
"
);
TAOS_STMT
*
stmt
=
NULL
;
TAOS_BIND
*
binds
=
NULL
;
assert
(
taos_stmt_bind_param
(
stmt
,
binds
)
!=
0
);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"Cannot connect to tdengine server
\n
"
);
exit
(
EXIT_FAILURE
);
}
execute_simple_sql
(
taos
,
"drop database if exists stmt_test"
);
execute_simple_sql
(
taos
,
"create database stmt_test"
);
execute_simple_sql
(
taos
,
"use stmt_test"
);
execute_simple_sql
(
taos
,
"create table super(ts timestamp, c1 int)"
);
stmt
=
taos_stmt_init
(
taos
);
char
*
stmt_sql
=
calloc
(
1
,
1000
);
sprintf
(
stmt_sql
,
"insert into ? values (?,?)"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
binds
)
!=
0
);
free
(
binds
);
TAOS_BIND
*
params
=
calloc
(
2
,
sizeof
(
TAOS_BIND
));
int64_t
ts
=
(
int64_t
)
1591060628000
;
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
0
].
buffer_length
=
sizeof
(
uint64_t
);
params
[
0
].
buffer
=
&
ts
;
params
[
0
].
length
=
&
params
[
0
].
buffer_length
;
params
[
0
].
is_null
=
NULL
;
int32_t
i
=
(
int32_t
)
21474
;
params
[
1
].
buffer_type
=
TSDB_DATA_TYPE_INT
;
params
[
1
].
buffer_length
=
sizeof
(
int32_t
);
params
[
1
].
buffer
=
&
i
;
params
[
1
].
length
=
&
params
[
1
].
buffer_length
;
params
[
1
].
is_null
=
NULL
;
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
!=
0
);
assert
(
taos_stmt_set_tbname
(
stmt
,
"super"
)
==
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
==
0
);
free
(
params
);
free
(
stmt_sql
);
taos_stmt_close
(
stmt
);
printf
(
"finish taos_stmt_bind_param test
\n
"
);
}
void
taos_stmt_bind_single_param_batch_test
()
{
printf
(
"start taos_stmt_bind_single_param_batch test
\n
"
);
TAOS_STMT
*
stmt
=
NULL
;
TAOS_MULTI_BIND
*
bind
=
NULL
;
assert
(
taos_stmt_bind_single_param_batch
(
stmt
,
bind
,
0
)
!=
0
);
printf
(
"finish taos_stmt_bind_single_param_batch test
\n
"
);
}
void
taos_stmt_bind_param_batch_test
()
{
printf
(
"start taos_stmt_bind_param_batch test
\n
"
);
TAOS_STMT
*
stmt
=
NULL
;
TAOS_MULTI_BIND
*
bind
=
NULL
;
assert
(
taos_stmt_bind_param_batch
(
stmt
,
bind
)
!=
0
);
printf
(
"finish taos_stmt_bind_param_batch test
\n
"
);
}
void
taos_stmt_add_batch_test
()
{
printf
(
"start taos_stmt_add_batch test
\n
"
);
TAOS_STMT
*
stmt
=
NULL
;
assert
(
taos_stmt_add_batch
(
stmt
)
!=
0
);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"Cannot connect to tdengine server
\n
"
);
exit
(
EXIT_FAILURE
);
}
execute_simple_sql
(
taos
,
"drop database if exists stmt_test"
);
execute_simple_sql
(
taos
,
"create database stmt_test"
);
execute_simple_sql
(
taos
,
"use stmt_test"
);
execute_simple_sql
(
taos
,
"create table super(ts timestamp, c1 int)"
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
char
*
stmt_sql
=
calloc
(
1
,
1000
);
sprintf
(
stmt_sql
,
"insert into ? values (?,?)"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
assert
(
taos_stmt_add_batch
(
stmt
)
!=
0
);
TAOS_BIND
*
params
=
calloc
(
2
,
sizeof
(
TAOS_BIND
));
int64_t
ts
=
(
int64_t
)
1591060628000
;
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
0
].
buffer_length
=
sizeof
(
uint64_t
);
params
[
0
].
buffer
=
&
ts
;
params
[
0
].
length
=
&
params
[
0
].
buffer_length
;
params
[
0
].
is_null
=
NULL
;
int32_t
i
=
(
int32_t
)
21474
;
params
[
1
].
buffer_type
=
TSDB_DATA_TYPE_INT
;
params
[
1
].
buffer_length
=
sizeof
(
int32_t
);
params
[
1
].
buffer
=
&
i
;
params
[
1
].
length
=
&
params
[
1
].
buffer_length
;
params
[
1
].
is_null
=
NULL
;
assert
(
taos_stmt_set_tbname
(
stmt
,
"super"
)
==
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
==
0
);
assert
(
taos_stmt_add_batch
(
stmt
)
==
0
);
free
(
params
);
free
(
stmt_sql
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
printf
(
"finish taos_stmt_add_batch test
\n
"
);
}
void
taos_stmt_execute_test
()
{
printf
(
"start taos_stmt_execute test
\n
"
);
TAOS_STMT
*
stmt
=
NULL
;
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"Cannot connect to tdengine server
\n
"
);
exit
(
EXIT_FAILURE
);
}
execute_simple_sql
(
taos
,
"drop database if exists stmt_test"
);
execute_simple_sql
(
taos
,
"create database stmt_test"
);
execute_simple_sql
(
taos
,
"use stmt_test"
);
execute_simple_sql
(
taos
,
"create table super(ts timestamp, c1 int)"
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
char
*
stmt_sql
=
calloc
(
1
,
1000
);
sprintf
(
stmt_sql
,
"insert into ? values (?,?)"
);
assert
(
taos_stmt_prepare
(
stmt
,
stmt_sql
,
0
)
==
0
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
TAOS_BIND
*
params
=
calloc
(
2
,
sizeof
(
TAOS_BIND
));
int64_t
ts
=
(
int64_t
)
1591060628000
;
params
[
0
].
buffer_type
=
TSDB_DATA_TYPE_TIMESTAMP
;
params
[
0
].
buffer_length
=
sizeof
(
uint64_t
);
params
[
0
].
buffer
=
&
ts
;
params
[
0
].
length
=
&
params
[
0
].
buffer_length
;
params
[
0
].
is_null
=
NULL
;
int32_t
i
=
(
int32_t
)
21474
;
params
[
1
].
buffer_type
=
TSDB_DATA_TYPE_INT
;
params
[
1
].
buffer_length
=
sizeof
(
int32_t
);
params
[
1
].
buffer
=
&
i
;
params
[
1
].
length
=
&
params
[
1
].
buffer_length
;
params
[
1
].
is_null
=
NULL
;
assert
(
taos_stmt_set_tbname
(
stmt
,
"super"
)
==
0
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
assert
(
taos_stmt_bind_param
(
stmt
,
params
)
==
0
);
assert
(
taos_stmt_execute
(
stmt
)
!=
0
);
assert
(
taos_stmt_add_batch
(
stmt
)
==
0
);
assert
(
taos_stmt_execute
(
stmt
)
==
0
);
free
(
params
);
free
(
stmt_sql
);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
printf
(
"finish taos_stmt_execute test
\n
"
);
}
void
taos_stmt_use_result_test
()
{
printf
(
"start taos_stmt_use_result test
\n
"
);
TAOS_STMT
*
stmt
=
NULL
;
assert
(
taos_stmt_use_result
(
stmt
)
==
NULL
);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"Cannot connect to tdengine server
\n
"
);
exit
(
EXIT_FAILURE
);
}
printf
(
"finish taos_stmt_use_result test
\n
"
);
stmt
=
taos_stmt_init
(
taos
);
assert
(
stmt
!=
NULL
);
TAOS_RES
*
result
=
taos_stmt_use_result
(
stmt
);
int
rows
=
0
;
TAOS_ROW
row
;
while
((
row
=
taos_fetch_row
(
result
)))
{
rows
++
;
}
printf
(
"rows: %d
\n
"
,
rows
);
taos_free_result
(
result
);
// assert(taos_stmt_use_result(stmt) == NULL);
assert
(
taos_stmt_close
(
stmt
)
==
0
);
}
void
taos_stmt_close_test
()
{
printf
(
"start taos_stmt_close test
\n
"
);
// ASM ERROR
// TAOS_STMT *stmt = NULL;
// assert(taos_stmt_close(stmt) != 0);
printf
(
"finish taos_stmt_close test
\n
"
);
}
void
test_api_reliability
()
{
// ASM catch memory leak
taos_stmt_init_test
();
taos_stmt_preprare_test
();
taos_stmt_set_tbname_test
();
taos_stmt_set_tbname_tags_test
();
taos_stmt_set_sub_tbname_test
();
taos_stmt_bind_param_test
();
taos_stmt_bind_single_param_batch_test
();
taos_stmt_bind_param_batch_test
();
taos_stmt_add_batch_test
();
taos_stmt_execute_test
();
taos_stmt_use_result_test
();
taos_stmt_close_test
();
}
int
main
(
int
argc
,
char
*
argv
[])
{
test_api_reliability
();
return
0
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录