Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_44632607
TDengine
提交
04884256
T
TDengine
项目概览
weixin_44632607
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
04884256
编写于
11月 06, 2020
作者:
P
plum-lihui
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'release/s105' of
https://github.com/taosdata/TDengine
into release/s105
上级
a805e289
387345d2
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
160 addition
and
56 deletion
+160
-56
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+15
-1
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+3
-0
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+1
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+2
-2
src/query/inc/tsqlfunction.h
src/query/inc/tsqlfunction.h
+1
-1
src/query/src/qAst.c
src/query/src/qAst.c
+0
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+2
-1
src/query/src/qFill.c
src/query/src/qFill.c
+1
-1
src/query/src/qHistogram.c
src/query/src/qHistogram.c
+2
-2
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+1
-1
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+52
-25
tests/examples/c/asyncdemo.c
tests/examples/c/asyncdemo.c
+33
-8
tests/examples/c/demo.c
tests/examples/c/demo.c
+47
-12
未找到文件。
src/client/src/tscAsync.c
浏览文件 @
04884256
...
...
@@ -428,6 +428,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
}
else
{
assert
(
code
==
TSDB_CODE_SUCCESS
);
}
// param already freed by other routine and pSql in tscCache when ctrl + c
if
(
atomic_load_ptr
(
&
pSql
->
param
)
==
NULL
)
{
return
;
...
...
@@ -441,6 +442,20 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
assert
(
pParObj
->
signature
==
pParObj
&&
trs
->
subqueryIndex
==
pTableMetaInfo
->
vgroupIndex
&&
pTableMetaInfo
->
vgroupIndex
>=
0
&&
pTableMetaInfo
->
vgroupList
!=
NULL
);
// tscProcessSql can add error into async res
tscProcessSql
(
pSql
);
return
;
}
else
if
(
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_TAG_FILTER_QUERY
))
{
tscDebug
(
"%p update table meta in local cache, continue to process sql and send corresponding tid_tag query"
,
pSql
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
code
=
tscGetTableMeta
(
pSql
,
pTableMetaInfo
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
return
;
}
else
{
assert
(
code
==
TSDB_CODE_SUCCESS
);
}
assert
((
tscGetNumOfTags
(
pTableMetaInfo
->
pTableMeta
)
!=
0
));
// tscProcessSql can add error into async res
tscProcessSql
(
pSql
);
return
;
...
...
@@ -465,7 +480,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
tscResetSqlCmdObj
(
pCmd
,
false
);
code
=
tsParseSql
(
pSql
,
true
);
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
return
;
}
else
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
04884256
...
...
@@ -97,6 +97,9 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc
pCtx
->
param
[
2
].
i64Key
=
pQueryInfo
->
order
.
order
;
pCtx
->
param
[
2
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
pCtx
->
param
[
1
].
i64Key
=
pQueryInfo
->
order
.
orderColId
;
}
else
if
(
functionId
==
TSDB_FUNC_APERCT
)
{
pCtx
->
param
[
0
].
i64Key
=
pExpr
->
param
[
0
].
i64Key
;
pCtx
->
param
[
0
].
nType
=
pExpr
->
param
[
0
].
nType
;
}
pCtx
->
interBufBytes
=
pExpr
->
interBytes
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
04884256
...
...
@@ -1309,7 +1309,7 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
if
((
!
pCmd
->
parseFinished
)
&&
(
!
initial
))
{
tscDebug
(
"%p resume to parse sql: %s"
,
pSql
,
pCmd
->
curSql
);
}
ret
=
tscAllocPayload
(
&
pSql
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
);
if
(
TSDB_CODE_SUCCESS
!=
ret
)
{
return
ret
;
...
...
src/client/src/tscSubquery.c
浏览文件 @
04884256
...
...
@@ -523,7 +523,7 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) {
assert
(
pSqlObj
->
subState
.
numOfRemain
>
0
);
if
(
atomic_sub_fetch_32
(
&
pSqlObj
->
subState
.
numOfRemain
,
1
)
<=
0
)
{
tscError
(
"%p all subquery return and query failed, global code:%
d"
,
pSqlObj
,
pSqlObj
->
res
.
code
);
tscError
(
"%p all subquery return and query failed, global code:%
s"
,
pSqlObj
,
tstrerror
(
pSqlObj
->
res
.
code
)
);
freeJoinSubqueryObj
(
pSqlObj
);
}
}
...
...
@@ -565,7 +565,7 @@ int32_t tagValCompar(const void* p1, const void* p2) {
return
(
tag1
->
len
>
tag2
->
len
)
?
1
:
-
1
;
}
return
strn
cmp
(
tag1
->
data
,
tag2
->
data
,
tag1
->
len
);
return
mem
cmp
(
tag1
->
data
,
tag2
->
data
,
tag1
->
len
);
}
void
tscBuildVgroupTableInfo
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
,
SArray
*
tables
)
{
...
...
src/query/inc/tsqlfunction.h
浏览文件 @
04884256
...
...
@@ -149,7 +149,7 @@ typedef struct SResultRowCellInfo {
int8_t
hasResult
;
// result generated, not NULL value
bool
initialized
;
// output buffer has been initialized
bool
complete
;
// query has completed
uint
16
_t
numOfRes
;
// num of output result in current buffer
uint
32
_t
numOfRes
;
// num of output result in current buffer
}
SResultRowCellInfo
;
#define GET_ROWCELL_INTERBUF(_c) ((void*) ((char*)(_c) + sizeof(SResultRowCellInfo)))
...
...
src/query/src/qAst.c
浏览文件 @
04884256
...
...
@@ -32,7 +32,6 @@
#include "tstoken.h"
#include "ttokendef.h"
#include "tulog.h"
#include "tutil.h"
/*
*
...
...
src/query/src/qExecutor.c
浏览文件 @
04884256
...
...
@@ -1609,7 +1609,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
pRuntimeEnv
->
pCtx
=
(
SQLFunctionCtx
*
)
calloc
(
pQuery
->
numOfOutput
,
sizeof
(
SQLFunctionCtx
));
pRuntimeEnv
->
rowCellInfoOffset
=
calloc
(
pQuery
->
numOfOutput
,
sizeof
(
int32_t
));
pRuntimeEnv
->
pResultRow
=
getNewResultRow
(
pRuntimeEnv
->
pool
);
//calloc(1, sizeof(SResultRow));
pRuntimeEnv
->
pResultRow
=
getNewResultRow
(
pRuntimeEnv
->
pool
);
if
(
pRuntimeEnv
->
pResultRow
==
NULL
||
pRuntimeEnv
->
pCtx
==
NULL
||
pRuntimeEnv
->
rowCellInfoOffset
==
NULL
)
{
goto
_clean
;
...
...
@@ -1745,6 +1745,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
pRuntimeEnv
->
pTSBuf
=
tsBufDestroy
(
pRuntimeEnv
->
pTSBuf
);
taosTFree
(
pRuntimeEnv
->
keyBuf
);
taosTFree
(
pRuntimeEnv
->
rowCellInfoOffset
);
taosHashCleanup
(
pRuntimeEnv
->
pResultRowHashTable
);
pRuntimeEnv
->
pResultRowHashTable
=
NULL
;
...
...
src/query/src/qFill.c
浏览文件 @
04884256
...
...
@@ -170,7 +170,7 @@ int64_t getFilledNumOfRes(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows
int32_t
numOfRows
=
taosNumOfRemainRows
(
pFillInfo
);
TSKEY
ekey1
=
ekey
;
if
(
pFillInfo
->
order
!=
TSDB_ORDER_ASC
)
{
if
(
!
FILL_IS_ASC_FILL
(
pFillInfo
)
)
{
pFillInfo
->
endKey
=
taosTimeTruncate
(
ekey
,
&
pFillInfo
->
interval
,
pFillInfo
->
precision
);
}
...
...
src/query/src/qHistogram.c
浏览文件 @
04884256
...
...
@@ -168,7 +168,7 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
(
*
pHisto
)
->
numOfEntries
+=
1
;
}
}
else
{
/* insert a new slot */
if
((
*
pHisto
)
->
numOfElems
>
1
&&
idx
<
(
*
pHisto
)
->
numOfEntries
)
{
if
((
*
pHisto
)
->
numOfElems
>
=
1
&&
idx
<
(
*
pHisto
)
->
numOfEntries
)
{
if
(
idx
>
0
)
{
assert
((
*
pHisto
)
->
elems
[
idx
-
1
].
val
<=
val
);
}
...
...
@@ -661,4 +661,4 @@ SHistogramInfo* tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2
free
(
pHistoBins
);
return
pResHistogram
;
}
\ No newline at end of file
}
src/vnode/src/vnodeRead.c
浏览文件 @
04884256
...
...
@@ -298,7 +298,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
v
Debug
(
"vgId:%d, invalid handle in retrieving result, code:0x%08x, QInfo:%p"
,
pVnode
->
vgId
,
code
,
(
void
*
)
pRetrieve
->
qhandle
);
v
Error
(
"vgId:%d, invalid handle in retrieving result, code:0x%08x, QInfo:%p"
,
pVnode
->
vgId
,
code
,
(
void
*
)
pRetrieve
->
qhandle
);
vnodeBuildNoResultQueryRsp
(
pRet
);
return
code
;
}
...
...
tests/examples/c/apitest.c
浏览文件 @
04884256
...
...
@@ -9,26 +9,40 @@
static
void
prepare_data
(
TAOS
*
taos
)
{
taos_query
(
taos
,
"drop database if exists test;"
);
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
taos_free_result
(
result
);
usleep
(
100000
);
taos_query
(
taos
,
"create database test;"
);
result
=
taos_query
(
taos
,
"create database test;"
);
taos_free_result
(
result
);
usleep
(
100000
);
taos_select_db
(
taos
,
"test"
);
taos_query
(
taos
,
"create table meters(ts timestamp, a int) tags(area int);"
);
result
=
taos_query
(
taos
,
"create table meters(ts timestamp, a int) tags(area int);"
);
taos_free_result
(
result
);
taos_query
(
taos
,
"create table t0 using meters tags(0);"
);
taos_query
(
taos
,
"create table t1 using meters tags(1);"
);
taos_query
(
taos
,
"create table t2 using meters tags(2);"
);
taos_query
(
taos
,
"create table t3 using meters tags(3);"
);
taos_query
(
taos
,
"create table t4 using meters tags(4);"
);
taos_query
(
taos
,
"create table t5 using meters tags(5);"
);
taos_query
(
taos
,
"create table t6 using meters tags(6);"
);
taos_query
(
taos
,
"create table t7 using meters tags(7);"
);
taos_query
(
taos
,
"create table t8 using meters tags(8);"
);
taos_query
(
taos
,
"create table t9 using meters tags(9);"
);
result
=
taos_query
(
taos
,
"create table t0 using meters tags(0);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t1 using meters tags(1);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t2 using meters tags(2);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t3 using meters tags(3);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t4 using meters tags(4);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t5 using meters tags(5);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t6 using meters tags(6);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t7 using meters tags(7);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t8 using meters tags(8);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"create table t9 using meters tags(9);"
);
taos_free_result
(
result
);
TAOS_RES
*
res
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:00:00.000', 0)"
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:00:00.000', 0)"
" ('2020-01-01 00:01:00.000', 0)"
" ('2020-01-01 00:02:00.000', 0)"
" t1 values('2020-01-01 00:00:00.000', 0)"
...
...
@@ -46,10 +60,11 @@ static void prepare_data(TAOS* taos) {
" t7 values('2020-01-01 00:01:02.000', 0)"
" t8 values('2020-01-01 00:01:02.000', 0)"
" t9 values('2020-01-01 00:01:02.000', 0)"
);
int
affected
=
taos_affected_rows
(
res
);
int
affected
=
taos_affected_rows
(
res
ult
);
if
(
affected
!=
18
)
{
printf
(
"
\033
[31m%d rows affected by last insert statement, but it should be 18
\033
[0m
\n
"
,
affected
);
}
taos_free_result
(
result
);
// super tables subscription
usleep
(
1000000
);
}
...
...
@@ -135,6 +150,7 @@ static void verify_query(TAOS* taos) {
res
=
taos_query
(
taos
,
"select * from meters"
);
taos_stop_query
(
res
);
taos_free_result
(
res
);
}
...
...
@@ -153,23 +169,30 @@ static void verify_subscribe(TAOS* taos) {
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
0
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:02:00.001', 0);"
);
taos_query
(
taos
,
"insert into t8 values('2020-01-01 00:01:03.000', 0);"
);
TAOS_RES
*
result
;
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:02:00.001', 0);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"insert into t8 values('2020-01-01 00:01:03.000', 0);"
);
taos_free_result
(
result
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
2
);
taos_query
(
taos
,
"insert into t2 values('2020-01-01 00:01:02.001', 0);"
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.001', 0);"
);
result
=
taos_query
(
taos
,
"insert into t2 values('2020-01-01 00:01:02.001', 0);"
);
taos_free_result
(
result
);
result
=
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.001', 0);"
);
taos_free_result
(
result
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
2
);
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.002', 0);"
);
result
=
taos_query
(
taos
,
"insert into t1 values('2020-01-01 00:03:00.002', 0);"
);
taos_free_result
(
result
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
1
);
// keep progress information and restart subscription
taos_unsubscribe
(
tsub
,
1
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.000', 0);"
);
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.000', 0);"
);
taos_free_result
(
result
);
tsub
=
taos_subscribe
(
taos
,
1
,
"test"
,
"select * from meters;"
,
NULL
,
NULL
,
0
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
24
);
...
...
@@ -196,7 +219,8 @@ static void verify_subscribe(TAOS* taos) {
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
0
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.001', 0);"
);
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:04:00.001', 0);"
);
taos_free_result
(
result
);
res
=
taos_consume
(
tsub
);
check_row_count
(
__LINE__
,
res
,
1
);
...
...
@@ -205,7 +229,8 @@ static void verify_subscribe(TAOS* taos) {
int
blockFetch
=
0
;
tsub
=
taos_subscribe
(
taos
,
1
,
"test"
,
"select * from meters;"
,
subscribe_callback
,
&
blockFetch
,
1000
);
usleep
(
2000000
);
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:05:00.001', 0);"
);
result
=
taos_query
(
taos
,
"insert into t0 values('2020-01-01 00:05:00.001', 0);"
);
taos_free_result
(
result
);
usleep
(
2000000
);
taos_unsubscribe
(
tsub
,
0
);
}
...
...
@@ -213,8 +238,9 @@ static void verify_subscribe(TAOS* taos) {
void
verify_prepare
(
TAOS
*
taos
)
{
TAOS_RES
*
result
=
taos_query
(
taos
,
"drop database if exists test;"
);
taos_free_result
(
result
);
usleep
(
100000
);
taos_query
(
taos
,
"create database test;"
);
result
=
taos_query
(
taos
,
"create database test;"
);
int
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
...
...
@@ -429,7 +455,8 @@ void verify_stream(TAOS* taos) {
NULL
);
printf
(
"waiting for stream data
\n
"
);
usleep
(
100000
);
taos_query
(
taos
,
"insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);"
);
TAOS_RES
*
result
=
taos_query
(
taos
,
"insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);"
);
taos_free_result
(
result
);
usleep
(
200000000
);
taos_close_stream
(
strm
);
}
...
...
tests/examples/c/asyncdemo.c
浏览文件 @
04884256
...
...
@@ -46,6 +46,34 @@ void taos_insert_call_back(void *param, TAOS_RES *tres, int code);
void
taos_select_call_back
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
);
void
taos_error
(
TAOS
*
taos
);
static
void
queryDB
(
TAOS
*
taos
,
char
*
command
)
{
int
i
;
TAOS_RES
*
pSql
=
NULL
;
int32_t
code
=
-
1
;
for
(
i
=
0
;
i
<
5
;
i
++
)
{
if
(
NULL
!=
pSql
)
{
taos_free_result
(
pSql
);
pSql
=
NULL
;
}
pSql
=
taos_query
(
taos
,
command
);
code
=
taos_errno
(
pSql
);
if
(
0
==
code
)
{
break
;
}
}
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"Failed to run %s, reason: %s
\n
"
,
command
,
taos_errstr
(
pSql
));
taos_free_result
(
pSql
);
taos_close
(
taos
);
exit
(
EXIT_FAILURE
);
}
taos_free_result
(
pSql
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
TAOS
*
taos
;
...
...
@@ -78,16 +106,14 @@ int main(int argc, char *argv[])
printf
(
"success to connect to server
\n
"
);
sprintf
(
sql
,
"drop database %s"
,
db
);
taos_query
(
taos
,
sql
);
sprintf
(
sql
,
"drop database
if exists
%s"
,
db
);
queryDB
(
taos
,
sql
);
sprintf
(
sql
,
"create database %s"
,
db
);
if
(
taos_query
(
taos
,
sql
)
!=
0
)
taos_error
(
taos
);
queryDB
(
taos
,
sql
);
sprintf
(
sql
,
"use %s"
,
db
);
if
(
taos_query
(
taos
,
sql
)
!=
0
)
taos_error
(
taos
);
queryDB
(
taos
,
sql
);
strcpy
(
prefix
,
"asytbl_"
);
for
(
i
=
0
;
i
<
numOfTables
;
++
i
)
{
...
...
@@ -95,8 +121,7 @@ int main(int argc, char *argv[])
tableList
[
i
].
taos
=
taos
;
sprintf
(
tableList
[
i
].
name
,
"%s%d"
,
prefix
,
i
);
sprintf
(
sql
,
"create table %s%d (ts timestamp, volume bigint)"
,
prefix
,
i
);
if
(
taos_query
(
taos
,
sql
)
!=
0
)
taos_error
(
taos
);
queryDB
(
taos
,
sql
);
}
gettimeofday
(
&
systemTime
,
NULL
);
...
...
tests/examples/c/demo.c
浏览文件 @
04884256
...
...
@@ -22,6 +22,34 @@
#include <inttypes.h>
#include <taos.h> // TAOS header file
static
void
queryDB
(
TAOS
*
taos
,
char
*
command
)
{
int
i
;
TAOS_RES
*
pSql
=
NULL
;
int32_t
code
=
-
1
;
for
(
i
=
0
;
i
<
5
;
i
++
)
{
if
(
NULL
!=
pSql
)
{
taos_free_result
(
pSql
);
pSql
=
NULL
;
}
pSql
=
taos_query
(
taos
,
command
);
code
=
taos_errno
(
pSql
);
if
(
0
==
code
)
{
break
;
}
}
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"Failed to run %s, reason: %s
\n
"
,
command
,
taos_errstr
(
pSql
));
taos_free_result
(
pSql
);
taos_close
(
taos
);
exit
(
EXIT_FAILURE
);
}
taos_free_result
(
pSql
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
TAOS
*
taos
;
char
qstr
[
1024
];
...
...
@@ -44,22 +72,26 @@ int main(int argc, char *argv[]) {
printf
(
"success to connect to server
\n
"
);
taos_query
(
taos
,
"drop database demo"
);
//taos_query(taos, "drop database demo");
queryDB
(
taos
,
"drop database if exists demo"
);
result
=
taos_query
(
taos
,
"create database demo"
);
if
(
result
==
NULL
)
{
printf
(
"failed to create database, reason:%s
\n
"
,
"null result"
/*taos_errstr(taos)*/
);
exit
(
1
);
}
//result = taos_query(taos, "create database demo");
//if (result == NULL) {
// printf("failed to create database, reason:%s\n", "null result"/*taos_errstr(taos)*/);
// exit(1);
//}
queryDB
(
taos
,
"create database demo"
);
printf
(
"success to create database
\n
"
);
taos_query
(
taos
,
"use demo"
);
//taos_query(taos, "use demo");
queryDB
(
taos
,
"use demo"
);
// create table
if
(
taos_query
(
taos
,
"create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))"
)
==
0
)
{
printf
(
"failed to create table, reason:%s
\n
"
,
taos_errstr
(
result
));
exit
(
1
);
}
//if (taos_query(taos, "create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))") == 0) {
// printf("failed to create table, reason:%s\n", taos_errstr(result));
// exit(1);
//}
queryDB
(
taos
,
"create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))"
);
printf
(
"success to create table
\n
"
);
// sleep for one second to make sure table is created on data node
...
...
@@ -80,8 +112,10 @@ int main(int argc, char *argv[]) {
printf
(
"insert row: %i
\n
"
,
i
);
}
else
{
printf
(
"failed to insert row: %i, reason:%s
\n
"
,
i
,
"null result"
/*taos_errstr(result)*/
);
taos_free_result
(
result
);
exit
(
1
);
}
taos_free_result
(
result
);
//sleep(1);
}
...
...
@@ -91,7 +125,8 @@ int main(int argc, char *argv[]) {
sprintf
(
qstr
,
"SELECT * FROM m1"
);
result
=
taos_query
(
taos
,
qstr
);
if
(
result
==
NULL
||
taos_errno
(
result
)
!=
0
)
{
printf
(
"failed to select, reason:%s
\n
"
,
taos_errstr
(
result
));
printf
(
"failed to select, reason:%s
\n
"
,
taos_errstr
(
result
));
taos_free_result
(
result
);
exit
(
1
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录