Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8e0eda6c
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
8e0eda6c
编写于
5月 05, 2022
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of github.com:taosdata/TDengine into feature/udf
上级
a0c92acd
ea2247e2
变更
33
显示空白变更内容
内联
并排
Showing
33 changed file
with
1067 addition
and
2145 deletion
+1067
-2145
cmake/cmake.define
cmake/cmake.define
+7
-1
example/src/tstream.c
example/src/tstream.c
+4
-3
include/common/tdatablock.h
include/common/tdatablock.h
+12
-10
include/common/tdataformat.h
include/common/tdataformat.h
+5
-5
include/common/tmsg.h
include/common/tmsg.h
+3
-1
include/common/trow.h
include/common/trow.h
+18
-20
include/libs/parser/parser.h
include/libs/parser/parser.h
+36
-32
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+3
-1
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+17
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+65
-0
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+46
-1
source/common/src/tglobal.c
source/common/src/tglobal.c
+34
-13
source/common/src/tmsg.c
source/common/src/tmsg.c
+19
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-0
source/dnode/mnode/impl/inc/mndOffset.h
source/dnode/mnode/impl/inc/mndOffset.h
+2
-0
source/dnode/mnode/impl/inc/mndSubscribe.h
source/dnode/mnode/impl/inc/mndSubscribe.h
+2
-0
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+1
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+7
-1
source/dnode/mnode/impl/src/mndOffset.c
source/dnode/mnode/impl/src/mndOffset.c
+33
-0
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+4
-0
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+9
-4
source/dnode/mnode/impl/test/trans/trans2.cpp
source/dnode/mnode/impl/test/trans/trans2.cpp
+239
-34
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+6
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+24
-11
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+1
-1
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+22
-0
source/libs/planner/test/planSTableTest.cpp
source/libs/planner/test/planSTableTest.cpp
+2
-0
source/libs/planner/test/planTestMain.cpp
source/libs/planner/test/planTestMain.cpp
+2
-2
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+78
-21
source/libs/planner/test/planTestUtil.h
source/libs/planner/test/planTestUtil.h
+1
-1
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+21
-1
source/libs/stream/src/tstream.c
source/libs/stream/src/tstream.c
+10
-4
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+333
-1977
未找到文件。
cmake/cmake.define
浏览文件 @
8e0eda6c
...
@@ -67,7 +67,13 @@ ELSE ()
...
@@ -67,7 +67,13 @@ ELSE ()
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
ADD_DEFINITIONS("-D_TD_ARM_")
ADD_DEFINITIONS("-D_TD_ARM_")
ELSE ()
ELSE ()
ADD_DEFINITIONS("-msse4.2 -mfma")
ADD_DEFINITIONS("-msse4.2")
IF("${FMA_SUPPORT}" MATCHES "true")
MESSAGE(STATUS "turn fma function support on")
ADD_DEFINITIONS("-mfma")
ELSE ()
MESSAGE(STATUS "turn fma function support off")
ENDIF()
ENDIF ()
ENDIF ()
ENDIF ()
ENDIF ()
example/src/tstream.c
浏览文件 @
8e0eda6c
...
@@ -81,9 +81,10 @@ int32_t create_stream() {
...
@@ -81,9 +81,10 @@ int32_t create_stream() {
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
pRes
=
taos_query
(
pRes
=
pConn
,
taos_query
(
pConn
,
"create stream stream1 trigger window_close as select min(k), max(k), sum(k) as sum_of_k from tu1 interval(10m)"
);
"create stream stream1 trigger window_close as select _wstartts, min(k), max(k), sum(k) as sum_of_k "
"from tu1 interval(10m)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create stream stream1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to create stream stream1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
return
-
1
;
...
...
include/common/tdatablock.h
浏览文件 @
8e0eda6c
...
@@ -54,6 +54,7 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
...
@@ -54,6 +54,7 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
BMCharPos(bm_, r_) |= (1u << (7u - BitPos(r_))); \
BMCharPos(bm_, r_) |= (1u << (7u - BitPos(r_))); \
} while (0)
} while (0)
<<<<<<<
HEAD
#define colDataSetNotNull_f(bm_, r_) \
#define colDataSetNotNull_f(bm_, r_) \
do { \
do { \
BMCharPos(bm_, r_) &= ~(1u << (7u - BitPos(r_))); \
BMCharPos(bm_, r_) &= ~(1u << (7u - BitPos(r_))); \
...
@@ -69,15 +70,14 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
...
@@ -69,15 +70,14 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
#define colDataGetNumData(p1_, r_) ((p1_)->pData + ((r_) * (p1_)->info.bytes))
#define colDataGetNumData(p1_, r_) ((p1_)->pData + ((r_) * (p1_)->info.bytes))
// SColumnInfoData, rowNumber
// SColumnInfoData, rowNumber
#define colDataGetData(p1_, r_) \
#define colDataGetData(p1_, r_) \
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? colDataGetVarData(p1_, r_) \
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? colDataGetVarData(p1_, r_) : colDataGetNumData(p1_, r_))
: colDataGetNumData(p1_, r_))
static
FORCE_INLINE
bool
colDataIsNull_s
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
)
{
static
FORCE_INLINE
bool
colDataIsNull_s
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
)
{
if
(
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
){
if
(
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
colDataIsNull_var
(
pColumnInfoData
,
row
))
{
if
(
colDataIsNull_var
(
pColumnInfoData
,
row
))
{
return
true
;
return
true
;
}
}
char
*
data
=
colDataGetVarData
(
pColumnInfoData
,
row
);
char
*
data
=
colDataGetVarData
(
pColumnInfoData
,
row
);
return
(
*
data
==
TSDB_DATA_TYPE_NULL
);
return
(
*
data
==
TSDB_DATA_TYPE_NULL
);
}
}
...
@@ -85,7 +85,7 @@ static FORCE_INLINE bool colDataIsNull_s(const SColumnInfoData* pColumnInfoData,
...
@@ -85,7 +85,7 @@ static FORCE_INLINE bool colDataIsNull_s(const SColumnInfoData* pColumnInfoData,
return
false
;
return
false
;
}
}
if
(
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_VARCHAR
||
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_VARCHAR
||
pColumnInfoData
->
info
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
return
colDataIsNull_var
(
pColumnInfoData
,
row
);
return
colDataIsNull_var
(
pColumnInfoData
,
row
);
}
else
{
}
else
{
if
(
pColumnInfoData
->
nullbitmap
==
NULL
)
{
if
(
pColumnInfoData
->
nullbitmap
==
NULL
)
{
...
@@ -137,7 +137,7 @@ static FORCE_INLINE void colDataAppendNULL(SColumnInfoData* pColumnInfoData, uin
...
@@ -137,7 +137,7 @@ static FORCE_INLINE void colDataAppendNULL(SColumnInfoData* pColumnInfoData, uin
static
FORCE_INLINE
void
colDataAppendNNULL
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
start
,
size_t
nRows
)
{
static
FORCE_INLINE
void
colDataAppendNNULL
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
start
,
size_t
nRows
)
{
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
for
(
int32_t
i
=
start
;
i
<
start
+
nRows
;
++
i
)
{
for
(
int32_t
i
=
start
;
i
<
start
+
nRows
;
++
i
)
{
colDataSetNull_var
(
pColumnInfoData
,
i
);
// it is a null value of VAR type.
colDataSetNull_var
(
pColumnInfoData
,
i
);
// it is a null value of VAR type.
}
}
}
else
{
}
else
{
for
(
int32_t
i
=
start
;
i
<
start
+
nRows
;
++
i
)
{
for
(
int32_t
i
=
start
;
i
<
start
+
nRows
;
++
i
)
{
...
@@ -233,6 +233,8 @@ void blockDebugShowData(const SArray* dataBlocks);
...
@@ -233,6 +233,8 @@ void blockDebugShowData(const SArray* dataBlocks);
int32_t
buildSubmitReqFromDataBlock
(
SSubmitReq
**
pReq
,
const
SArray
*
pDataBlocks
,
STSchema
*
pTSchema
,
int32_t
vgId
,
int32_t
buildSubmitReqFromDataBlock
(
SSubmitReq
**
pReq
,
const
SArray
*
pDataBlocks
,
STSchema
*
pTSchema
,
int32_t
vgId
,
tb_uid_t
uid
,
tb_uid_t
suid
);
tb_uid_t
uid
,
tb_uid_t
suid
);
SSubmitReq
*
tdBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pSchema
);
static
FORCE_INLINE
int32_t
blockGetEncodeSize
(
const
SSDataBlock
*
pBlock
)
{
static
FORCE_INLINE
int32_t
blockGetEncodeSize
(
const
SSDataBlock
*
pBlock
)
{
return
blockDataGetSerialMetaSize
(
pBlock
)
+
blockDataGetSize
(
pBlock
);
return
blockDataGetSerialMetaSize
(
pBlock
)
+
blockDataGetSize
(
pBlock
);
}
}
...
@@ -246,10 +248,10 @@ static FORCE_INLINE int32_t blockCompressColData(SColumnInfoData* pColRes, int32
...
@@ -246,10 +248,10 @@ static FORCE_INLINE int32_t blockCompressColData(SColumnInfoData* pColRes, int32
static
FORCE_INLINE
void
blockCompressEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
static
FORCE_INLINE
void
blockCompressEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
int8_t
needCompress
)
{
int8_t
needCompress
)
{
int32_t
*
actualLen
=
(
int32_t
*
)
data
;
int32_t
*
actualLen
=
(
int32_t
*
)
data
;
data
+=
sizeof
(
int32_t
);
data
+=
sizeof
(
int32_t
);
uint64_t
*
groupId
=
(
uint64_t
*
)
data
;
uint64_t
*
groupId
=
(
uint64_t
*
)
data
;
data
+=
sizeof
(
uint64_t
);
data
+=
sizeof
(
uint64_t
);
int32_t
*
colSizes
=
(
int32_t
*
)
data
;
int32_t
*
colSizes
=
(
int32_t
*
)
data
;
...
...
include/common/tdataformat.h
浏览文件 @
8e0eda6c
...
@@ -62,10 +62,10 @@ extern "C" {
...
@@ -62,10 +62,10 @@ extern "C" {
#pragma pack(push, 1)
#pragma pack(push, 1)
typedef
struct
{
typedef
struct
{
col_id_t
colId
;
// column ID(start from PRIMARYKEY_TIMESTAMP_COL_ID(1))
col_id_t
colId
;
// column ID(start from PRIMARYKEY_TIMESTAMP_COL_ID(1))
int
32_t
type
:
8
;
// column type
int
8_t
type
;
// column type
int
32_t
bytes
:
24
;
// column bytes (0~16M)
int
8_t
flags
;
// flags: 0 no index, 1 SCHEMA_SMA_ON, 2 SCHEMA_IDX_ON
int32_t
flags
:
8
;
// flags: 0 no index, 1 SCHEMA_SMA_ON, 2 SCHEMA_IDX_ON
int32_t
bytes
;
// column bytes (0~16M)
int32_t
offset
:
24
;
// point offset in STpRow after the header part.
int32_t
offset
;
// point offset in STpRow after the header part.
}
STColumn
;
}
STColumn
;
#pragma pack(pop)
#pragma pack(pop)
...
...
include/common/tmsg.h
浏览文件 @
8e0eda6c
...
@@ -245,6 +245,8 @@ int32_t tInitSubmitMsgIter(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
...
@@ -245,6 +245,8 @@ int32_t tInitSubmitMsgIter(const SSubmitReq* pMsg, SSubmitMsgIter* pIter);
int32_t
tGetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
,
SSubmitBlk
**
pPBlock
);
int32_t
tGetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
,
SSubmitBlk
**
pPBlock
);
int32_t
tInitSubmitBlkIter
(
SSubmitMsgIter
*
pMsgIter
,
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
);
int32_t
tInitSubmitBlkIter
(
SSubmitMsgIter
*
pMsgIter
,
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
);
STSRow
*
tGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
);
STSRow
*
tGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
);
// for debug
int32_t
tPrintFixedSchemaSubmitReq
(
const
SSubmitReq
*
pReq
,
STSchema
*
pSchema
);
typedef
struct
{
typedef
struct
{
int32_t
index
;
// index of failed block in submit blocks
int32_t
index
;
// index of failed block in submit blocks
...
@@ -2130,7 +2132,7 @@ static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SCoder* pDecoder, SSchemaWrapp
...
@@ -2130,7 +2132,7 @@ static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SCoder* pDecoder, SSchemaWrapp
if
(
tDecodeI32v
(
pDecoder
,
&
pSW
->
nCols
)
<
0
)
return
-
1
;
if
(
tDecodeI32v
(
pDecoder
,
&
pSW
->
nCols
)
<
0
)
return
-
1
;
if
(
tDecodeI32v
(
pDecoder
,
&
pSW
->
sver
)
<
0
)
return
-
1
;
if
(
tDecodeI32v
(
pDecoder
,
&
pSW
->
sver
)
<
0
)
return
-
1
;
pSW
->
pSchema
=
(
SSchema
*
)
t
CoderMalloc
(
pDecoder
,
sizeof
(
SSchema
)
*
pSW
->
nCols
);
pSW
->
pSchema
=
(
SSchema
*
)
t
aosMemoryCalloc
(
pSW
->
nCols
,
sizeof
(
SSchema
)
);
if
(
pSW
->
pSchema
==
NULL
)
return
-
1
;
if
(
pSW
->
pSchema
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
if
(
tDecodeSSchema
(
pDecoder
,
&
pSW
->
pSchema
[
i
])
<
0
)
return
-
1
;
if
(
tDecodeSSchema
(
pDecoder
,
&
pSW
->
pSchema
[
i
])
<
0
)
return
-
1
;
...
...
include/common/trow.h
浏览文件 @
8e0eda6c
...
@@ -622,7 +622,6 @@ static FORCE_INLINE int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols
...
@@ -622,7 +622,6 @@ static FORCE_INLINE int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
/**
/**
* @brief To judge row type: STpRow/SKvRow
* @brief To judge row type: STpRow/SKvRow
*
*
...
@@ -758,7 +757,6 @@ static int32_t tdSRowGetBuf(SRowBuilder *pBuilder, void *pBuf) {
...
@@ -758,7 +757,6 @@ static int32_t tdSRowGetBuf(SRowBuilder *pBuilder, void *pBuf) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
/**
/**
* @brief 由调用方管理存储空间的分配及释放,一次输入多个参数
* @brief 由调用方管理存储空间的分配及释放,一次输入多个参数
*
*
...
@@ -1397,14 +1395,14 @@ static void tdSCellValPrint(SCellVal *pVal, int8_t colType) {
...
@@ -1397,14 +1395,14 @@ static void tdSCellValPrint(SCellVal *pVal, int8_t colType) {
}
}
}
}
static
void
tdSRowPrint
(
STSRow
*
row
,
STSchema
*
pSchema
,
const
char
*
tag
)
{
static
void
tdSRowPrint
(
STSRow
*
row
,
STSchema
*
pSchema
,
const
char
*
tag
)
{
STSRowIter
iter
=
{
0
};
STSRowIter
iter
=
{
0
};
tdSTSRowIterInit
(
&
iter
,
pSchema
);
tdSTSRowIterInit
(
&
iter
,
pSchema
);
tdSTSRowIterReset
(
&
iter
,
row
);
tdSTSRowIterReset
(
&
iter
,
row
);
printf
(
"%s >>>"
,
tag
);
printf
(
"%s >>>"
,
tag
);
for
(
int
i
=
0
;
i
<
pSchema
->
numOfCols
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pSchema
->
numOfCols
;
++
i
)
{
STColumn
*
stCol
=
pSchema
->
columns
+
i
;
STColumn
*
stCol
=
pSchema
->
columns
+
i
;
SCellVal
sVal
=
{
255
,
NULL
};
SCellVal
sVal
=
{
255
,
NULL
};
if
(
!
tdSTSRowIterNext
(
&
iter
,
stCol
->
colId
,
stCol
->
type
,
&
sVal
))
{
if
(
!
tdSTSRowIterNext
(
&
iter
,
stCol
->
colId
,
stCol
->
type
,
&
sVal
))
{
break
;
break
;
}
}
...
...
include/libs/parser/parser.h
浏览文件 @
8e0eda6c
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "querynodes.h"
#include "query.h"
#include "query.h"
#include "querynodes.h"
typedef
struct
SStmtCallback
{
typedef
struct
SStmtCallback
{
TAOS_STMT
*
pStmt
;
TAOS_STMT
*
pStmt
;
...
@@ -34,16 +34,18 @@ typedef struct SStmtCallback {
...
@@ -34,16 +34,18 @@ typedef struct SStmtCallback {
typedef
struct
SParseContext
{
typedef
struct
SParseContext
{
uint64_t
requestId
;
uint64_t
requestId
;
int32_t
acctId
;
int32_t
acctId
;
const
char
*
db
;
const
char
*
db
;
bool
topicQuery
;
bool
topicQuery
;
void
*
pTransporter
;
void
*
pTransporter
;
SEpSet
mgmtEpSet
;
SEpSet
mgmtEpSet
;
const
char
*
pSql
;
// sql string
const
char
*
pSql
;
// sql string
size_t
sqlLen
;
// length of the sql string
size_t
sqlLen
;
// length of the sql string
char
*
pMsg
;
// extended error message if exists to help identifying the problem in sql statement.
char
*
pMsg
;
// extended error message if exists to help identifying the problem in sql statement.
int32_t
msgLen
;
// max length of the msg
int32_t
msgLen
;
// max length of the msg
struct
SCatalog
*
pCatalog
;
struct
SCatalog
*
pCatalog
;
SStmtCallback
*
pStmtCb
;
SStmtCallback
*
pStmtCb
;
const
char
*
pUser
;
bool
isSuperUser
;
}
SParseContext
;
}
SParseContext
;
typedef
struct
SCmdMsgInfo
{
typedef
struct
SCmdMsgInfo
{
...
@@ -89,14 +91,16 @@ int32_t qCloneStmtDataBlock(void** pDst, void* pSrc);
...
@@ -89,14 +91,16 @@ int32_t qCloneStmtDataBlock(void** pDst, void* pSrc);
void
qFreeStmtDataBlock
(
void
*
pDataBlock
);
void
qFreeStmtDataBlock
(
void
*
pDataBlock
);
int32_t
qRebuildStmtDataBlock
(
void
**
pDst
,
void
*
pSrc
);
int32_t
qRebuildStmtDataBlock
(
void
**
pDst
,
void
*
pSrc
);
void
qDestroyStmtDataBlock
(
void
*
pBlock
);
void
qDestroyStmtDataBlock
(
void
*
pBlock
);
int32_t
qBindStmtColsValue
(
void
*
pBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
);
int32_t
qBindStmtColsValue
(
void
*
pBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
);
int32_t
qBindStmtSingleColValue
(
void
*
pBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
,
int32_t
colIdx
,
int32_t
rowNum
);
int32_t
qBindStmtSingleColValue
(
void
*
pBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
,
int32_t
colIdx
,
int32_t
qBuildStmtColFields
(
void
*
pDataBlock
,
int32_t
*
fieldNum
,
TAOS_FIELD
**
fields
);
int32_t
rowNum
);
int32_t
qBuildStmtTagFields
(
void
*
pBlock
,
void
*
boundTags
,
int32_t
*
fieldNum
,
TAOS_FIELD
**
fields
);
int32_t
qBuildStmtColFields
(
void
*
pDataBlock
,
int32_t
*
fieldNum
,
TAOS_FIELD
**
fields
);
int32_t
qBindStmtTagsValue
(
void
*
pBlock
,
void
*
boundTags
,
int64_t
suid
,
SName
*
pName
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
);
int32_t
qBuildStmtTagFields
(
void
*
pBlock
,
void
*
boundTags
,
int32_t
*
fieldNum
,
TAOS_FIELD
**
fields
);
int32_t
qBindStmtTagsValue
(
void
*
pBlock
,
void
*
boundTags
,
int64_t
suid
,
SName
*
pName
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
);
void
destroyBoundColumnInfo
(
void
*
pBoundInfo
);
void
destroyBoundColumnInfo
(
void
*
pBoundInfo
);
int32_t
qCreateSName
(
SName
*
pName
,
const
char
*
pTableName
,
int32_t
acctId
,
char
*
dbName
,
char
*
msgBuf
,
int32_t
msgBufLen
);
int32_t
qCreateSName
(
SName
*
pName
,
const
char
*
pTableName
,
int32_t
acctId
,
char
*
dbName
,
char
*
msgBuf
,
int32_t
msgBufLen
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/libs/stream/tstream.h
浏览文件 @
8e0eda6c
...
@@ -71,7 +71,9 @@ typedef struct {
...
@@ -71,7 +71,9 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int8_t
reserved
;
int8_t
reserved
;
SSchemaWrapper
*
pSchemaWrapper
;
// not applicable to encoder and decoder
// not applicable to encoder and decoder
STSchema
*
pTSchema
;
SHashObj
*
pHash
;
// groupId to tbuid
SHashObj
*
pHash
;
// groupId to tbuid
}
STaskSinkTb
;
}
STaskSinkTb
;
...
...
source/client/src/clientStmt.c
浏览文件 @
8e0eda6c
...
@@ -649,6 +649,19 @@ int stmtGetParamNum(TAOS_STMT *stmt, int *nums) {
...
@@ -649,6 +649,19 @@ int stmtGetParamNum(TAOS_STMT *stmt, int *nums) {
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_FETCH_FIELDS
));
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_FETCH_FIELDS
));
if
(
pStmt
->
bInfo
.
needParse
&&
pStmt
->
sql
.
runTimes
&&
pStmt
->
sql
.
type
>
0
&&
STMT_TYPE_MULTI_INSERT
!=
pStmt
->
sql
.
type
)
{
pStmt
->
bInfo
.
needParse
=
false
;
}
if
(
pStmt
->
exec
.
pRequest
&&
STMT_TYPE_QUERY
==
pStmt
->
sql
.
type
&&
pStmt
->
sql
.
runTimes
)
{
taos_free_result
(
pStmt
->
exec
.
pRequest
);
pStmt
->
exec
.
pRequest
=
NULL
;
}
if
(
NULL
==
pStmt
->
exec
.
pRequest
)
{
STMT_ERR_RET
(
buildRequest
(
pStmt
->
taos
,
pStmt
->
sql
.
sqlStr
,
pStmt
->
sql
.
sqlLen
,
&
pStmt
->
exec
.
pRequest
));
}
if
(
pStmt
->
bInfo
.
needParse
)
{
if
(
pStmt
->
bInfo
.
needParse
)
{
STMT_ERR_RET
(
stmtParseSql
(
pStmt
));
STMT_ERR_RET
(
stmtParseSql
(
pStmt
));
}
}
...
@@ -658,6 +671,9 @@ int stmtGetParamNum(TAOS_STMT *stmt, int *nums) {
...
@@ -658,6 +671,9 @@ int stmtGetParamNum(TAOS_STMT *stmt, int *nums) {
STMT_ERR_RET
(
getQueryPlan
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQuery
,
&
pStmt
->
sql
.
nodeList
));
STMT_ERR_RET
(
getQueryPlan
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQuery
,
&
pStmt
->
sql
.
nodeList
));
pStmt
->
sql
.
pQueryPlan
=
pStmt
->
exec
.
pRequest
->
body
.
pDag
;
pStmt
->
sql
.
pQueryPlan
=
pStmt
->
exec
.
pRequest
->
body
.
pDag
;
pStmt
->
exec
.
pRequest
->
body
.
pDag
=
NULL
;
pStmt
->
exec
.
pRequest
->
body
.
pDag
=
NULL
;
STMT_ERR_RET
(
stmtBackupQueryFields
(
pStmt
));
}
else
{
STMT_ERR_RET
(
stmtRestoreQueryFields
(
pStmt
));
}
}
*
nums
=
taosArrayGetSize
(
pStmt
->
sql
.
pQueryPlan
->
pPlaceholderValues
);
*
nums
=
taosArrayGetSize
(
pStmt
->
sql
.
pQueryPlan
->
pPlaceholderValues
);
...
...
source/common/src/tdatablock.c
浏览文件 @
8e0eda6c
...
@@ -1594,3 +1594,68 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
...
@@ -1594,3 +1594,68 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SSubmitReq
*
tdBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pTSchema
)
{
SSubmitReq
*
ret
=
NULL
;
// cal size
int32_t
cap
=
sizeof
(
SSubmitReq
);
int32_t
sz
=
taosArrayGetSize
(
pBlocks
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pBlocks
,
i
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
// TODO min
int32_t
rowSize
=
pDataBlock
->
info
.
rowSize
;
int32_t
maxLen
=
TD_ROW_MAX_BYTES_FROM_SCHEMA
(
pTSchema
);
cap
+=
sizeof
(
SSubmitBlk
)
+
rows
*
maxLen
;
}
// assign data
ret
=
taosMemoryCalloc
(
1
,
cap
);
ret
->
version
=
htonl
(
1
);
ret
->
length
=
htonl
(
cap
-
sizeof
(
SSubmitReq
));
ret
->
numOfBlocks
=
htonl
(
sz
);
void
*
submitBlk
=
POINTER_SHIFT
(
ret
,
sizeof
(
SSubmitReq
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pBlocks
,
i
);
SSubmitBlk
*
blkHead
=
submitBlk
;
blkHead
->
numOfRows
=
htons
(
pDataBlock
->
info
.
rows
);
blkHead
->
schemaLen
=
0
;
blkHead
->
sversion
=
htonl
(
pTSchema
->
version
);
// TODO
blkHead
->
suid
=
0
;
blkHead
->
uid
=
htobe64
(
pDataBlock
->
info
.
uid
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
maxLen
=
TD_ROW_MAX_BYTES_FROM_SCHEMA
(
pTSchema
);
/*blkHead->dataLen = htonl(rows * maxLen);*/
blkHead
->
dataLen
=
0
;
void
*
blockData
=
POINTER_SHIFT
(
submitBlk
,
sizeof
(
SSubmitBlk
));
STSRow
*
rowData
=
blockData
;
for
(
int32_t
j
=
0
;
j
<
pDataBlock
->
info
.
rows
;
j
++
)
{
SRowBuilder
rb
=
{
0
};
tdSRowInit
(
&
rb
,
pTSchema
->
version
);
tdSRowSetTpInfo
(
&
rb
,
pTSchema
->
numOfCols
,
pTSchema
->
flen
);
tdSRowResetBuf
(
&
rb
,
rowData
);
for
(
int32_t
k
=
0
;
k
<
pTSchema
->
numOfCols
;
k
++
)
{
const
STColumn
*
pColumn
=
&
pTSchema
->
columns
[
k
];
SColumnInfoData
*
pColData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
k
);
void
*
data
=
colDataGetData
(
pColData
,
j
);
tdAppendColValToRow
(
&
rb
,
pColumn
->
colId
,
pColumn
->
type
,
TD_VTYPE_NORM
,
data
,
true
,
pColumn
->
offset
,
k
);
}
int32_t
rowLen
=
TD_ROW_LEN
(
rowData
);
rowData
=
POINTER_SHIFT
(
rowData
,
rowLen
);
blkHead
->
dataLen
+=
rowLen
;
}
int32_t
len
=
blkHead
->
dataLen
;
blkHead
->
dataLen
=
htonl
(
len
);
blkHead
=
POINTER_SHIFT
(
blkHead
,
len
);
}
return
ret
;
}
source/common/src/tdataformat.c
浏览文件 @
8e0eda6c
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "tdataformat.h"
#include "tdataformat.h"
#include "tcoding.h"
#include "tcoding.h"
#include "tdatablock.h"
#include "tlog.h"
#include "tlog.h"
static
void
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
);
static
void
dataColSetNEleNull
(
SDataCol
*
pCol
,
int
nEle
);
...
@@ -128,6 +129,50 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
...
@@ -128,6 +129,50 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
return
buf
;
return
buf
;
}
}
#if 0
int32_t tEncodeSTColumn(SCoder *pEncoder, const STColumn *pCol) {
if (tEncodeI16(pEncoder, pCol->colId) < 0) return -1;
if (tEncodeI8(pEncoder, pCol->type) < 0) return -1;
if (tEncodeI8(pEncoder, pCol->sma) < 0) return -1;
if (tEncodeI32(pEncoder, pCol->bytes) < 0) return -1;
if (tEncodeI32(pEncoder, pCol->offset) < 0) return -1;
return pEncoder->pos;
}
int32_t tDecodeSTColumn(SCoder *pDecoder, STColumn *pCol) {
if (tDecodeI16(pDecoder, &pCol->colId) < 0) return -1;
if (tDecodeI8(pDecoder, &pCol->type) < 0) return -1;
if (tDecodeI8(pDecoder, &pCol->sma) < 0) return -1;
if (tDecodeI32(pDecoder, &pCol->bytes) < 0) return -1;
if (tDecodeI32(pDecoder, &pCol->offset) < 0) return -1;
return 0;
}
int32_t tEncodeSchema(SCoder *pEncoder, const STSchema *pSchema) {
if (tEncodeI32(pEncoder, pSchema->numOfCols) < 0) return -1;
if (tEncodeI16(pEncoder, pSchema->version) < 0) return -1;
if (tEncodeU16(pEncoder, pSchema->flen) < 0) return -1;
if (tEncodeI32(pEncoder, pSchema->vlen) < 0) return -1;
if (tEncodeI32(pEncoder, pSchema->tlen) < 0) return -1;
for (int32_t i = 0; i < schemaNCols(pSchema); i++) {
const STColumn *pCol = schemaColAt(pSchema, i);
if (tEncodeSTColumn(pEncoder, pCol) < 0) return -1;
}
return 0;
}
int32_t tDecodeSchema(SCoder *pDecoder, STSchema *pSchema) {
if (tDecodeI32(pDecoder, &pSchema->numOfCols) < 0) return -1;
if (tDecodeI16(pDecoder, &pSchema->version) < 0) return -1;
if (tDecodeU16(pDecoder, &pSchema->flen) < 0) return -1;
if (tDecodeI32(pDecoder, &pSchema->vlen) < 0) return -1;
if (tDecodeI32(pDecoder, &pSchema->tlen) < 0) return -1;
return 0;
}
#endif
int
tdInitTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
,
schema_ver_t
version
)
{
int
tdInitTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
,
schema_ver_t
version
)
{
if
(
pBuilder
==
NULL
)
return
-
1
;
if
(
pBuilder
==
NULL
)
return
-
1
;
...
...
source/common/src/tglobal.c
浏览文件 @
8e0eda6c
...
@@ -224,7 +224,8 @@ struct SConfig *taosGetCfg() {
...
@@ -224,7 +224,8 @@ struct SConfig *taosGetCfg() {
return
tsCfg
;
return
tsCfg
;
}
}
static
int32_t
taosLoadCfg
(
SConfig
*
pCfg
,
const
char
**
envCmd
,
const
char
*
inputCfgDir
,
const
char
*
envFile
,
char
*
apolloUrl
)
{
static
int32_t
taosLoadCfg
(
SConfig
*
pCfg
,
const
char
**
envCmd
,
const
char
*
inputCfgDir
,
const
char
*
envFile
,
char
*
apolloUrl
)
{
char
cfgDir
[
PATH_MAX
]
=
{
0
};
char
cfgDir
[
PATH_MAX
]
=
{
0
};
char
cfgFile
[
PATH_MAX
+
100
]
=
{
0
};
char
cfgFile
[
PATH_MAX
+
100
]
=
{
0
};
...
@@ -300,15 +301,10 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) {
...
@@ -300,15 +301,10 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) {
static
int32_t
taosAddClientCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosAddClientCfg
(
SConfig
*
pCfg
)
{
char
defaultFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
char
defaultFqdn
[
TSDB_FQDN_LEN
]
=
{
0
};
int32_t
defaultServerPort
=
6030
;
int32_t
defaultServerPort
=
6030
;
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
char
defaultSecondEp
[
TSDB_EP_LEN
]
=
{
0
};
if
(
taosGetFqdn
(
defaultFqdn
)
!=
0
)
return
-
1
;
if
(
taosGetFqdn
(
defaultFqdn
)
!=
0
)
return
-
1
;
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
snprintf
(
defaultSecondEp
,
TSDB_EP_LEN
,
"%s:%d"
,
defaultFqdn
,
defaultServerPort
);
if
(
cfgAddString
(
pCfg
,
"firstEp"
,
defaultFirstEp
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"firstEp"
,
""
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"secondEp"
,
defaultSecondEp
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"secondEp"
,
""
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"fqdn"
,
defaultFqdn
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"fqdn"
,
defaultFqdn
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"serverPort"
,
defaultServerPort
,
1
,
65056
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"serverPort"
,
defaultServerPort
,
1
,
65056
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"tempDir"
,
tsTempDir
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddDir
(
pCfg
,
"tempDir"
,
tsTempDir
,
1
)
!=
0
)
return
-
1
;
...
@@ -478,15 +474,18 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
...
@@ -478,15 +474,18 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
char
defaultFirstEp
[
TSDB_EP_LEN
]
=
{
0
};
snprintf
(
defaultFirstEp
,
TSDB_EP_LEN
,
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
SConfigItem
*
pFirstEpItem
=
cfgGetItem
(
pCfg
,
"firstEp"
);
SConfigItem
*
pFirstEpItem
=
cfgGetItem
(
pCfg
,
"firstEp"
);
SEp
firstEp
=
{
0
};
SEp
firstEp
=
{
0
};
taosGetFqdnPortFromEp
(
pFirstEpItem
->
str
,
&
firstEp
);
taosGetFqdnPortFromEp
(
strlen
(
pFirstEpItem
->
str
)
==
0
?
defaultFirstEp
:
pFirstEpItem
->
str
,
&
firstEp
);
snprintf
(
tsFirst
,
sizeof
(
tsFirst
),
"%s:%u"
,
firstEp
.
fqdn
,
firstEp
.
port
);
snprintf
(
tsFirst
,
sizeof
(
tsFirst
),
"%s:%u"
,
firstEp
.
fqdn
,
firstEp
.
port
);
cfgSetItem
(
pCfg
,
"firstEp"
,
tsFirst
,
pFirstEpItem
->
stype
);
cfgSetItem
(
pCfg
,
"firstEp"
,
tsFirst
,
pFirstEpItem
->
stype
);
SConfigItem
*
pSecondpItem
=
cfgGetItem
(
pCfg
,
"secondEp"
);
SConfigItem
*
pSecondpItem
=
cfgGetItem
(
pCfg
,
"secondEp"
);
SEp
secondEp
=
{
0
};
SEp
secondEp
=
{
0
};
taosGetFqdnPortFromEp
(
pSecondpItem
->
str
,
&
secondEp
);
taosGetFqdnPortFromEp
(
strlen
(
pSecondpItem
->
str
)
==
0
?
defaultFirstEp
:
pSecondpItem
->
str
,
&
secondEp
);
snprintf
(
tsSecond
,
sizeof
(
tsSecond
),
"%s:%u"
,
secondEp
.
fqdn
,
secondEp
.
port
);
snprintf
(
tsSecond
,
sizeof
(
tsSecond
),
"%s:%u"
,
secondEp
.
fqdn
,
secondEp
.
port
);
cfgSetItem
(
pCfg
,
"secondEp"
,
tsSecond
,
pSecondpItem
->
stype
);
cfgSetItem
(
pCfg
,
"secondEp"
,
tsSecond
,
pSecondpItem
->
stype
);
...
@@ -583,8 +582,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
...
@@ -583,8 +582,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
return
0
;
return
0
;
}
}
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
**
envCmd
,
const
char
*
envFile
,
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
**
envCmd
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
c
onst
char
*
envFile
,
c
har
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
osDefaultInit
();
osDefaultInit
();
SConfig
*
pCfg
=
cfgInit
();
SConfig
*
pCfg
=
cfgInit
();
...
@@ -636,7 +635,24 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
...
@@ -636,7 +635,24 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
return
0
;
return
0
;
}
}
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
**
envCmd
,
const
char
*
envFile
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
static
int32_t
taosCheckGlobalCfg
()
{
uint32_t
ipv4
=
taosGetIpv4FromFqdn
(
tsLocalFqdn
);
if
(
ipv4
==
0xffffffff
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to get ip from fqdn:%s since %s, dnode can not be initialized"
,
tsLocalFqdn
,
terrstr
());
return
-
1
;
}
if
(
tsServerPort
<=
0
)
{
uError
(
"invalid server port:%u, dnode can not be initialized"
,
tsServerPort
);
return
-
1
;
}
return
0
;
}
int32_t
taosInitCfg
(
const
char
*
cfgDir
,
const
char
**
envCmd
,
const
char
*
envFile
,
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
if
(
tsCfg
!=
NULL
)
return
0
;
if
(
tsCfg
!=
NULL
)
return
0
;
tsCfg
=
cfgInit
();
tsCfg
=
cfgInit
();
...
@@ -674,6 +690,11 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile
...
@@ -674,6 +690,11 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile
taosSetSystemCfg
(
tsCfg
);
taosSetSystemCfg
(
tsCfg
);
cfgDumpCfg
(
tsCfg
,
tsc
,
false
);
cfgDumpCfg
(
tsCfg
,
tsc
,
false
);
if
(
taosCheckGlobalCfg
()
!=
0
)
{
return
-
1
;
}
return
0
;
return
0
;
}
}
...
...
source/common/src/tmsg.c
浏览文件 @
8e0eda6c
...
@@ -103,6 +103,25 @@ STSRow *tGetSubmitBlkNext(SSubmitBlkIter *pIter) {
...
@@ -103,6 +103,25 @@ STSRow *tGetSubmitBlkNext(SSubmitBlkIter *pIter) {
}
}
}
}
int32_t
tPrintFixedSchemaSubmitReq
(
const
SSubmitReq
*
pReq
,
STSchema
*
pTschema
)
{
SSubmitMsgIter
msgIter
=
{
0
};
if
(
tInitSubmitMsgIter
(
pReq
,
&
msgIter
)
<
0
)
return
-
1
;
while
(
true
)
{
SSubmitBlk
*
pBlock
=
NULL
;
if
(
tGetSubmitMsgNext
(
&
msgIter
,
&
pBlock
)
<
0
)
return
-
1
;
if
(
pBlock
==
NULL
)
break
;
SSubmitBlkIter
blkIter
=
{
0
};
tInitSubmitBlkIter
(
&
msgIter
,
pBlock
,
&
blkIter
);
STSRowIter
rowIter
=
{
0
};
tdSTSRowIterInit
(
&
rowIter
,
pTschema
);
STSRow
*
row
;
while
((
row
=
tGetSubmitBlkNext
(
&
blkIter
))
!=
NULL
)
{
tdSRowPrint
(
row
,
pTschema
,
"stream"
);
}
}
return
0
;
}
int32_t
tEncodeSEpSet
(
SCoder
*
pEncoder
,
const
SEpSet
*
pEp
)
{
int32_t
tEncodeSEpSet
(
SCoder
*
pEncoder
,
const
SEpSet
*
pEp
)
{
if
(
tEncodeI8
(
pEncoder
,
pEp
->
inUse
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pEp
->
inUse
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pEp
->
numOfEps
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pEp
->
numOfEps
)
<
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
8e0eda6c
...
@@ -419,6 +419,7 @@ typedef struct {
...
@@ -419,6 +419,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
char
key
[
TSDB_PARTITION_KEY_LEN
];
char
key
[
TSDB_PARTITION_KEY_LEN
];
int64_t
dbUid
;
int64_t
offset
;
int64_t
offset
;
}
SMqOffsetObj
;
}
SMqOffsetObj
;
...
...
source/dnode/mnode/impl/inc/mndOffset.h
浏览文件 @
8e0eda6c
...
@@ -37,6 +37,8 @@ static FORCE_INLINE int32_t mndMakePartitionKey(char *key, const char *cgroup, c
...
@@ -37,6 +37,8 @@ static FORCE_INLINE int32_t mndMakePartitionKey(char *key, const char *cgroup, c
return
snprintf
(
key
,
TSDB_PARTITION_KEY_LEN
,
"%d:%s:%s"
,
vgId
,
cgroup
,
topicName
);
return
snprintf
(
key
,
TSDB_PARTITION_KEY_LEN
,
"%d:%s:%s"
,
vgId
,
cgroup
,
topicName
);
}
}
int32_t
mndDropOffsetByDB
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mnode/impl/inc/mndSubscribe.h
浏览文件 @
8e0eda6c
...
@@ -31,6 +31,8 @@ void mndReleaseSubscribe(SMnode *pMnode, SMqSubscribeObj *pSub);
...
@@ -31,6 +31,8 @@ void mndReleaseSubscribe(SMnode *pMnode, SMqSubscribeObj *pSub);
int32_t
mndMakeSubscribeKey
(
char
*
key
,
const
char
*
cgroup
,
const
char
*
topicName
);
int32_t
mndMakeSubscribeKey
(
char
*
key
,
const
char
*
cgroup
,
const
char
*
topicName
);
int32_t
mndDropSubByDB
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
8e0eda6c
...
@@ -61,6 +61,7 @@ void mndTransSetDbInfo(STrans *pTrans, SDbObj *pDb);
...
@@ -61,6 +61,7 @@ void mndTransSetDbInfo(STrans *pTrans, SDbObj *pDb);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
void
mndTransProcessRsp
(
SNodeMsg
*
pRsp
);
void
mndTransProcessRsp
(
SNodeMsg
*
pRsp
);
void
mndTransPullup
(
SMnode
*
pMnode
);
void
mndTransPullup
(
SMnode
*
pMnode
);
int32_t
mndKillTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
8e0eda6c
...
@@ -17,9 +17,12 @@
...
@@ -17,9 +17,12 @@
#include "mndDb.h"
#include "mndDb.h"
#include "mndAuth.h"
#include "mndAuth.h"
#include "mndDnode.h"
#include "mndDnode.h"
#include "mndOffset.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndSma.h"
#include "mndSma.h"
#include "mndStb.h"
#include "mndStb.h"
#include "mndSubscribe.h"
#include "mndTopic.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "mndVgroup.h"
...
@@ -1027,6 +1030,9 @@ static int32_t mndDropDb(SMnode *pMnode, SNodeMsg *pReq, SDbObj *pDb) {
...
@@ -1027,6 +1030,9 @@ static int32_t mndDropDb(SMnode *pMnode, SNodeMsg *pReq, SDbObj *pDb) {
if
(
mndSetDropDbRedoLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbRedoLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbCommitLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbCommitLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
/*if (mndDropOffsetByDB(pMnode, pTrans, pDb) != 0) goto _OVER;*/
/*if (mndDropSubByDB(pMnode, pTrans, pDb) != 0) goto _OVER;*/
/*if (mndDropTopicByDB(pMnode, pTrans, pDb) != 0) goto _OVER;*/
if
(
mndSetDropDbRedoActions
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbRedoActions
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
int32_t
rspLen
=
0
;
int32_t
rspLen
=
0
;
...
...
source/dnode/mnode/impl/src/mndOffset.c
浏览文件 @
8e0eda6c
...
@@ -231,3 +231,36 @@ static void mndCancelGetNextOffset(SMnode *pMnode, void *pIter) {
...
@@ -231,3 +231,36 @@ static void mndCancelGetNextOffset(SMnode *pMnode, void *pIter) {
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
sdbCancelFetch
(
pSdb
,
pIter
);
}
}
static
int32_t
mndSetDropOffsetCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMqOffsetObj
*
pOffset
)
{
SSdbRaw
*
pCommitRaw
=
mndOffsetActionEncode
(
pOffset
);
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
)
!=
0
)
return
-
1
;
return
0
;
}
int32_t
mndDropOffsetByDB
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
int32_t
code
=
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
SMqOffsetObj
*
pOffset
=
NULL
;
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_SUBSCRIBE
,
pIter
,
(
void
**
)
&
pOffset
);
if
(
pIter
==
NULL
)
break
;
if
(
pOffset
->
dbUid
!=
pDb
->
uid
)
{
sdbRelease
(
pSdb
,
pOffset
);
continue
;
}
if
(
mndSetDropOffsetCommitLogs
(
pMnode
,
pTrans
,
pOffset
)
<
0
)
{
goto
END
;
}
}
code
=
0
;
END:
return
code
;
}
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
8e0eda6c
...
@@ -204,6 +204,8 @@ int32_t mndAddShuffledSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* p
...
@@ -204,6 +204,8 @@ int32_t mndAddShuffledSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* p
pTask
->
smaSink
.
smaId
=
pStream
->
smaId
;
pTask
->
smaSink
.
smaId
=
pStream
->
smaId
;
}
else
{
}
else
{
pTask
->
sinkType
=
TASK_SINK__TABLE
;
pTask
->
sinkType
=
TASK_SINK__TABLE
;
pTask
->
tbSink
.
pSchemaWrapper
=
tCloneSSchemaWrapper
(
&
pStream
->
outputSchema
);
ASSERT
(
pTask
->
tbSink
.
pSchemaWrapper
);
}
}
// dispatch
// dispatch
...
@@ -242,6 +244,7 @@ int32_t mndAddFixedSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStr
...
@@ -242,6 +244,7 @@ int32_t mndAddFixedSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStr
pTask
->
smaSink
.
smaId
=
pStream
->
smaId
;
pTask
->
smaSink
.
smaId
=
pStream
->
smaId
;
}
else
{
}
else
{
pTask
->
sinkType
=
TASK_SINK__TABLE
;
pTask
->
sinkType
=
TASK_SINK__TABLE
;
pTask
->
tbSink
.
pSchemaWrapper
=
tCloneSSchemaWrapper
(
&
pStream
->
outputSchema
);
}
}
//
//
// dispatch
// dispatch
...
@@ -316,6 +319,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -316,6 +319,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
pTask
->
smaSink
.
smaId
=
pStream
->
smaId
;
pTask
->
smaSink
.
smaId
=
pStream
->
smaId
;
}
else
{
}
else
{
pTask
->
sinkType
=
TASK_SINK__TABLE
;
pTask
->
sinkType
=
TASK_SINK__TABLE
;
pTask
->
tbSink
.
pSchemaWrapper
=
tCloneSSchemaWrapper
(
&
pStream
->
outputSchema
);
}
}
#endif
#endif
}
}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
8e0eda6c
...
@@ -997,7 +997,12 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
...
@@ -997,7 +997,12 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
pAction
->
msgReceived
=
0
;
pAction
->
msgReceived
=
0
;
pAction
->
errCode
=
0
;
pAction
->
errCode
=
0
;
}
else
{
}
else
{
if
(
terrno
==
TSDB_CODE_INVALID_PTR
)
rpcFreeCont
(
rpcMsg
.
pCont
);
pAction
->
msgSent
=
0
;
pAction
->
msgReceived
=
0
;
pAction
->
errCode
=
terrno
;
if
(
terrno
==
TSDB_CODE_INVALID_PTR
||
terrno
==
TSDB_CODE_NODE_OFFLINE
)
{
rpcFreeCont
(
rpcMsg
.
pCont
);
}
mError
(
"trans:%d, action:%d not send since %s"
,
pTrans
->
id
,
action
,
terrstr
());
mError
(
"trans:%d, action:%d not send since %s"
,
pTrans
->
id
,
action
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -1275,7 +1280,7 @@ static int32_t mndProcessTransReq(SNodeMsg *pReq) {
...
@@ -1275,7 +1280,7 @@ static int32_t mndProcessTransReq(SNodeMsg *pReq) {
return
0
;
return
0
;
}
}
static
int32_t
mndKillTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
mndKillTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
SArray
*
pArray
=
NULL
;
SArray
*
pArray
=
NULL
;
if
(
pTrans
->
stage
==
TRN_STAGE_REDO_ACTION
)
{
if
(
pTrans
->
stage
==
TRN_STAGE_REDO_ACTION
)
{
pArray
=
pTrans
->
redoActions
;
pArray
=
pTrans
->
redoActions
;
...
@@ -1293,14 +1298,14 @@ static int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans) {
...
@@ -1293,14 +1298,14 @@ static int32_t mndKillTrans(SMnode *pMnode, STrans *pTrans) {
if
(
pAction
==
NULL
)
continue
;
if
(
pAction
==
NULL
)
continue
;
if
(
pAction
->
msgReceived
==
0
)
{
if
(
pAction
->
msgReceived
==
0
)
{
mInfo
(
"trans:%d, action:%d set processed"
,
pTrans
->
id
,
i
);
mInfo
(
"trans:%d, action:%d set processed
for kill msg received
"
,
pTrans
->
id
,
i
);
pAction
->
msgSent
=
1
;
pAction
->
msgSent
=
1
;
pAction
->
msgReceived
=
1
;
pAction
->
msgReceived
=
1
;
pAction
->
errCode
=
0
;
pAction
->
errCode
=
0
;
}
}
if
(
pAction
->
errCode
!=
0
)
{
if
(
pAction
->
errCode
!=
0
)
{
mInfo
(
"trans:%d, action:%d set processed, errCode from %s to success"
,
pTrans
->
id
,
i
,
mInfo
(
"trans:%d, action:%d set processed
for kill msg received
, errCode from %s to success"
,
pTrans
->
id
,
i
,
tstrerror
(
pAction
->
errCode
));
tstrerror
(
pAction
->
errCode
));
pAction
->
msgSent
=
1
;
pAction
->
msgSent
=
1
;
pAction
->
msgReceived
=
1
;
pAction
->
msgReceived
=
1
;
...
...
source/dnode/mnode/impl/test/trans/trans2.cpp
浏览文件 @
8e0eda6c
...
@@ -86,7 +86,7 @@ class MndTestTrans2 : public ::testing::Test {
...
@@ -86,7 +86,7 @@ class MndTestTrans2 : public ::testing::Test {
void
SetUp
()
override
{}
void
SetUp
()
override
{}
void
TearDown
()
override
{}
void
TearDown
()
override
{}
int32_t
CreateUserLog
(
const
char
*
acct
,
const
char
*
user
)
{
int32_t
CreateUserLog
(
const
char
*
acct
,
const
char
*
user
,
ETrnType
type
,
SDbObj
*
pDb
)
{
SUserObj
userObj
=
{
0
};
SUserObj
userObj
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
"taosdata"
,
strlen
(
"taosdata"
),
userObj
.
pass
);
taosEncryptPass_c
((
uint8_t
*
)
"taosdata"
,
strlen
(
"taosdata"
),
userObj
.
pass
);
tstrncpy
(
userObj
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
userObj
.
user
,
user
,
TSDB_USER_LEN
);
...
@@ -96,7 +96,7 @@ class MndTestTrans2 : public ::testing::Test {
...
@@ -96,7 +96,7 @@ class MndTestTrans2 : public ::testing::Test {
userObj
.
superUser
=
1
;
userObj
.
superUser
=
1
;
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
0
};
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_USER
,
&
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
type
,
&
rpcMsg
);
SSdbRaw
*
pRedoRaw
=
mndUserActionEncode
(
&
userObj
);
SSdbRaw
*
pRedoRaw
=
mndUserActionEncode
(
&
userObj
);
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
);
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
);
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
);
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
);
...
@@ -108,13 +108,18 @@ class MndTestTrans2 : public ::testing::Test {
...
@@ -108,13 +108,18 @@ class MndTestTrans2 : public ::testing::Test {
char
*
param
=
strdup
(
"====> test log <====="
);
char
*
param
=
strdup
(
"====> test log <====="
);
mndTransSetCb
(
pTrans
,
TEST_TRANS_START_FUNC
,
TEST_TRANS_STOP_FUNC
,
param
,
strlen
(
param
)
+
1
);
mndTransSetCb
(
pTrans
,
TEST_TRANS_START_FUNC
,
TEST_TRANS_STOP_FUNC
,
param
,
strlen
(
param
)
+
1
);
if
(
pDb
!=
NULL
)
{
mndTransSetDbInfo
(
pTrans
,
pDb
);
}
int32_t
code
=
mndTransPrepare
(
pMnode
,
pTrans
);
int32_t
code
=
mndTransPrepare
(
pMnode
,
pTrans
);
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
return
code
;
return
code
;
}
}
int32_t
CreateUserAction
(
const
char
*
acct
,
const
char
*
user
,
bool
hasUndoAction
,
ETrnPolicy
policy
)
{
int32_t
CreateUserAction
(
const
char
*
acct
,
const
char
*
user
,
bool
hasUndoAction
,
ETrnPolicy
policy
,
ETrnType
type
,
SDbObj
*
pDb
)
{
SUserObj
userObj
=
{
0
};
SUserObj
userObj
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
"taosdata"
,
strlen
(
"taosdata"
),
userObj
.
pass
);
taosEncryptPass_c
((
uint8_t
*
)
"taosdata"
,
strlen
(
"taosdata"
),
userObj
.
pass
);
tstrncpy
(
userObj
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
userObj
.
user
,
user
,
TSDB_USER_LEN
);
...
@@ -124,7 +129,7 @@ class MndTestTrans2 : public ::testing::Test {
...
@@ -124,7 +129,7 @@ class MndTestTrans2 : public ::testing::Test {
userObj
.
superUser
=
1
;
userObj
.
superUser
=
1
;
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
0
};
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
policy
,
TRN_TYPE_CREATE_USER
,
&
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
policy
,
type
,
&
rpcMsg
);
SSdbRaw
*
pRedoRaw
=
mndUserActionEncode
(
&
userObj
);
SSdbRaw
*
pRedoRaw
=
mndUserActionEncode
(
&
userObj
);
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
);
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
);
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
);
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
);
...
@@ -170,6 +175,44 @@ class MndTestTrans2 : public ::testing::Test {
...
@@ -170,6 +175,44 @@ class MndTestTrans2 : public ::testing::Test {
mndTransAppendUndoAction
(
pTrans
,
&
action
);
mndTransAppendUndoAction
(
pTrans
,
&
action
);
}
}
{
void
*
pRsp
=
taosMemoryCalloc
(
1
,
256
);
strcpy
((
char
*
)
pRsp
,
"simple rsponse"
);
mndTransSetRpcRsp
(
pTrans
,
pRsp
,
256
);
}
if
(
pDb
!=
NULL
)
{
mndTransSetDbInfo
(
pTrans
,
pDb
);
}
int32_t
code
=
mndTransPrepare
(
pMnode
,
pTrans
);
mndTransDrop
(
pTrans
);
return
code
;
}
int32_t
CreateUserGlobal
(
const
char
*
acct
,
const
char
*
user
)
{
SUserObj
userObj
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
"taosdata"
,
strlen
(
"taosdata"
),
userObj
.
pass
);
tstrncpy
(
userObj
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
userObj
.
acct
,
acct
,
TSDB_USER_LEN
);
userObj
.
createdTime
=
taosGetTimestampMs
();
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
superUser
=
1
;
SRpcMsg
rpcMsg
=
{
0
};
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_USER
,
&
rpcMsg
);
SSdbRaw
*
pRedoRaw
=
mndUserActionEncode
(
&
userObj
);
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
);
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
);
SSdbRaw
*
pUndoRaw
=
mndUserActionEncode
(
&
userObj
);
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
);
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
);
char
*
param
=
strdup
(
"====> test log <====="
);
mndTransSetCb
(
pTrans
,
TEST_TRANS_START_FUNC
,
TEST_TRANS_STOP_FUNC
,
param
,
strlen
(
param
)
+
1
);
int32_t
code
=
mndTransPrepare
(
pMnode
,
pTrans
);
int32_t
code
=
mndTransPrepare
(
pMnode
,
pTrans
);
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
...
@@ -189,12 +232,12 @@ TEST_F(MndTestTrans2, 01_Log) {
...
@@ -189,12 +232,12 @@ TEST_F(MndTestTrans2, 01_Log) {
ASSERT_NE
(
pMnode
,
nullptr
);
ASSERT_NE
(
pMnode
,
nullptr
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user1
),
0
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user1
,
TRN_TYPE_CREATE_USER
,
NULL
),
0
);
pUser1
=
mndAcquireUser
(
pMnode
,
user1
);
pUser1
=
mndAcquireUser
(
pMnode
,
user1
);
ASSERT_NE
(
pUser1
,
nullptr
);
ASSERT_NE
(
pUser1
,
nullptr
);
// failed to create user and rollback
// failed to create user and rollback
EXPECT_EQ
(
CreateUserLog
(
acct_invalid
,
user2
),
0
);
EXPECT_EQ
(
CreateUserLog
(
acct_invalid
,
user2
,
TRN_TYPE_CREATE_USER
,
NULL
),
0
);
pUser2
=
mndAcquireUser
(
pMnode
,
user2
);
pUser2
=
mndAcquireUser
(
pMnode
,
user2
);
ASSERT_EQ
(
pUser2
,
nullptr
);
ASSERT_EQ
(
pUser2
,
nullptr
);
...
@@ -214,15 +257,16 @@ TEST_F(MndTestTrans2, 02_Action) {
...
@@ -214,15 +257,16 @@ TEST_F(MndTestTrans2, 02_Action) {
ASSERT_NE
(
pMnode
,
nullptr
);
ASSERT_NE
(
pMnode
,
nullptr
);
{
// failed to create user and rollback
// failed to create user and rollback
EXPECT_EQ
(
CreateUserAction
(
acct
,
user1
,
false
,
TRN_POLICY_ROLLBACK
),
0
);
EXPECT_EQ
(
CreateUserAction
(
acct
,
user1
,
false
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_USER
,
NULL
),
0
);
pUser1
=
mndAcquireUser
(
pMnode
,
user1
);
pUser1
=
mndAcquireUser
(
pMnode
,
user1
);
ASSERT_EQ
(
pUser1
,
nullptr
);
ASSERT_EQ
(
pUser1
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser1
);
mndReleaseUser
(
pMnode
,
pUser1
);
// create user, and fake a response
// create user, and fake a response
{
{
EXPECT_EQ
(
CreateUserAction
(
acct
,
user1
,
true
,
TRN_POLICY_ROLLBACK
),
0
);
EXPECT_EQ
(
CreateUserAction
(
acct
,
user1
,
true
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_USER
,
NULL
),
0
);
pUser1
=
mndAcquireUser
(
pMnode
,
user1
);
pUser1
=
mndAcquireUser
(
pMnode
,
user1
);
ASSERT_NE
(
pUser1
,
nullptr
);
ASSERT_NE
(
pUser1
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser1
);
mndReleaseUser
(
pMnode
,
pUser1
);
...
@@ -249,9 +293,10 @@ TEST_F(MndTestTrans2, 02_Action) {
...
@@ -249,9 +293,10 @@ TEST_F(MndTestTrans2, 02_Action) {
ASSERT_EQ
(
pUser1
,
nullptr
);
ASSERT_EQ
(
pUser1
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser1
);
mndReleaseUser
(
pMnode
,
pUser1
);
}
}
}
{
{
EXPECT_EQ
(
CreateUserAction
(
acct
,
user1
,
false
,
TRN_POLICY_RETRY
),
0
);
EXPECT_EQ
(
CreateUserAction
(
acct
,
user1
,
false
,
TRN_POLICY_RETRY
,
TRN_TYPE_CREATE_USER
,
NULL
),
0
);
pUser1
=
mndAcquireUser
(
pMnode
,
user1
);
pUser1
=
mndAcquireUser
(
pMnode
,
user1
);
ASSERT_NE
(
pUser1
,
nullptr
);
ASSERT_NE
(
pUser1
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser1
);
mndReleaseUser
(
pMnode
,
pUser1
);
...
@@ -305,4 +350,164 @@ TEST_F(MndTestTrans2, 02_Action) {
...
@@ -305,4 +350,164 @@ TEST_F(MndTestTrans2, 02_Action) {
mndReleaseUser
(
pMnode
,
pUser1
);
mndReleaseUser
(
pMnode
,
pUser1
);
}
}
}
}
{
EXPECT_EQ
(
CreateUserAction
(
acct
,
user2
,
true
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_USER
,
NULL
),
0
);
SUserObj
*
pUser2
=
(
SUserObj
*
)
sdbAcquire
(
pMnode
->
pSdb
,
SDB_USER
,
user2
);
ASSERT_NE
(
pUser2
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser2
);
{
transId
=
6
;
pTrans
=
mndAcquireTrans
(
pMnode
,
transId
);
EXPECT_EQ
(
pTrans
->
code
,
TSDB_CODE_INVALID_PTR
);
EXPECT_EQ
(
pTrans
->
stage
,
TRN_STAGE_UNDO_ACTION
);
EXPECT_EQ
(
pTrans
->
failedTimes
,
1
);
SNodeMsg
rspMsg
=
{
0
};
rspMsg
.
pNode
=
pMnode
;
int64_t
signature
=
transId
;
signature
=
(
signature
<<
32
);
signature
+=
action
;
rspMsg
.
rpcMsg
.
ahandle
=
(
void
*
)
signature
;
rspMsg
.
rpcMsg
.
code
=
0
;
mndTransProcessRsp
(
&
rspMsg
);
mndReleaseTrans
(
pMnode
,
pTrans
);
pUser2
=
mndAcquireUser
(
pMnode
,
user2
);
ASSERT_NE
(
pUser2
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser2
);
}
{
transId
=
6
;
pTrans
=
mndAcquireTrans
(
pMnode
,
transId
);
EXPECT_EQ
(
pTrans
->
code
,
TSDB_CODE_INVALID_PTR
);
EXPECT_EQ
(
pTrans
->
stage
,
TRN_STAGE_UNDO_ACTION
);
EXPECT_EQ
(
pTrans
->
failedTimes
,
2
);
STransAction
*
pAction
=
(
STransAction
*
)
taosArrayGet
(
pTrans
->
undoActions
,
action
);
pAction
->
msgSent
=
1
;
SNodeMsg
rspMsg
=
{
0
};
rspMsg
.
pNode
=
pMnode
;
int64_t
signature
=
transId
;
signature
=
(
signature
<<
32
);
signature
+=
action
;
rspMsg
.
rpcMsg
.
ahandle
=
(
void
*
)
signature
;
mndTransProcessRsp
(
&
rspMsg
);
mndReleaseTrans
(
pMnode
,
pTrans
);
pUser2
=
mndAcquireUser
(
pMnode
,
user2
);
ASSERT_EQ
(
pUser2
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser2
);
}
}
}
TEST_F
(
MndTestTrans2
,
03
_Kill
)
{
const
char
*
acct
=
"root"
;
const
char
*
user1
=
"kill1"
;
const
char
*
user2
=
"kill2"
;
SUserObj
*
pUser1
=
NULL
;
SUserObj
*
pUser2
=
NULL
;
STrans
*
pTrans
=
NULL
;
int32_t
transId
=
0
;
int32_t
action
=
0
;
ASSERT_NE
(
pMnode
,
nullptr
);
{
EXPECT_EQ
(
CreateUserAction
(
acct
,
user1
,
true
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_USER
,
NULL
),
0
);
pUser1
=
mndAcquireUser
(
pMnode
,
user1
);
ASSERT_NE
(
pUser1
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser1
);
transId
=
7
;
pTrans
=
mndAcquireTrans
(
pMnode
,
transId
);
EXPECT_EQ
(
pTrans
->
code
,
TSDB_CODE_INVALID_PTR
);
EXPECT_EQ
(
pTrans
->
stage
,
TRN_STAGE_UNDO_ACTION
);
EXPECT_EQ
(
pTrans
->
failedTimes
,
1
);
mndKillTrans
(
pMnode
,
pTrans
);
mndReleaseTrans
(
pMnode
,
pTrans
);
pUser1
=
mndAcquireUser
(
pMnode
,
user1
);
ASSERT_EQ
(
pUser1
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser1
);
}
}
TEST_F
(
MndTestTrans2
,
04
_Conflict
)
{
const
char
*
acct
=
"root"
;
const
char
*
user1
=
"conflict1"
;
const
char
*
user2
=
"conflict2"
;
const
char
*
user3
=
"conflict3"
;
const
char
*
user4
=
"conflict4"
;
const
char
*
user5
=
"conflict5"
;
const
char
*
user6
=
"conflict6"
;
const
char
*
user7
=
"conflict7"
;
const
char
*
user8
=
"conflict8"
;
SUserObj
*
pUser
=
NULL
;
STrans
*
pTrans
=
NULL
;
int32_t
transId
=
0
;
int32_t
code
=
0
;
ASSERT_NE
(
pMnode
,
nullptr
);
{
SDbObj
dbObj1
=
{
0
};
dbObj1
.
uid
=
9521
;
strcpy
(
dbObj1
.
name
,
"db"
);
SDbObj
dbObj2
=
{
0
};
dbObj2
.
uid
=
9522
;
strcpy
(
dbObj2
.
name
,
"conflict db"
);
EXPECT_EQ
(
CreateUserAction
(
acct
,
user1
,
true
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_STB
,
&
dbObj1
),
0
);
pUser
=
mndAcquireUser
(
pMnode
,
user1
);
ASSERT_NE
(
pUser
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser
);
transId
=
8
;
pTrans
=
mndAcquireTrans
(
pMnode
,
transId
);
EXPECT_EQ
(
pTrans
->
code
,
TSDB_CODE_INVALID_PTR
);
EXPECT_EQ
(
pTrans
->
stage
,
TRN_STAGE_UNDO_ACTION
);
// stb scope
EXPECT_EQ
(
CreateUserLog
(
acct
,
user2
,
TRN_TYPE_CREATE_DNODE
,
NULL
),
-
1
);
code
=
terrno
;
EXPECT_EQ
(
code
,
TSDB_CODE_MND_TRANS_CONFLICT
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user2
,
TRN_TYPE_CREATE_DB
,
&
dbObj1
),
-
1
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user2
,
TRN_TYPE_CREATE_DB
,
&
dbObj2
),
0
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user3
,
TRN_TYPE_CREATE_STB
,
&
dbObj1
),
0
);
// db scope
pTrans
->
type
=
TRN_TYPE_CREATE_DB
;
EXPECT_EQ
(
CreateUserLog
(
acct
,
user4
,
TRN_TYPE_CREATE_DNODE
,
NULL
),
-
1
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user4
,
TRN_TYPE_CREATE_DB
,
&
dbObj1
),
-
1
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user4
,
TRN_TYPE_CREATE_DB
,
&
dbObj2
),
0
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user5
,
TRN_TYPE_CREATE_STB
,
&
dbObj1
),
-
1
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user5
,
TRN_TYPE_CREATE_STB
,
&
dbObj2
),
0
);
// global scope
pTrans
->
type
=
TRN_TYPE_CREATE_DNODE
;
EXPECT_EQ
(
CreateUserLog
(
acct
,
user6
,
TRN_TYPE_CREATE_DNODE
,
NULL
),
0
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user7
,
TRN_TYPE_CREATE_DB
,
&
dbObj1
),
-
1
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user7
,
TRN_TYPE_CREATE_DB
,
&
dbObj2
),
-
1
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user7
,
TRN_TYPE_CREATE_STB
,
&
dbObj1
),
-
1
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user7
,
TRN_TYPE_CREATE_STB
,
&
dbObj2
),
-
1
);
// global scope
pTrans
->
type
=
TRN_TYPE_CREATE_USER
;
EXPECT_EQ
(
CreateUserLog
(
acct
,
user7
,
TRN_TYPE_CREATE_DB
,
&
dbObj1
),
0
);
EXPECT_EQ
(
CreateUserLog
(
acct
,
user8
,
TRN_TYPE_CREATE_DB
,
&
dbObj2
),
0
);
mndKillTrans
(
pMnode
,
pTrans
);
mndReleaseTrans
(
pMnode
,
pTrans
);
pUser
=
mndAcquireUser
(
pMnode
,
user1
);
ASSERT_EQ
(
pUser
,
nullptr
);
mndReleaseUser
(
pMnode
,
pUser
);
}
}
}
\ No newline at end of file
source/dnode/vnode/src/tq/tq.c
浏览文件 @
8e0eda6c
...
@@ -926,6 +926,12 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -926,6 +926,12 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
pTask
->
ahandle
=
pTq
->
pVnode
;
pTask
->
ahandle
=
pTq
->
pVnode
;
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
pTask
->
smaSink
.
smaHandle
=
smaHandleRes
;
pTask
->
smaSink
.
smaHandle
=
smaHandleRes
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
ASSERT
(
pTask
->
tbSink
.
pSchemaWrapper
);
ASSERT
(
pTask
->
tbSink
.
pSchemaWrapper
->
pSchema
);
pTask
->
tbSink
.
pTSchema
=
tdGetSTSChemaFromSSChema
(
&
pTask
->
tbSink
.
pSchemaWrapper
->
pSchema
,
pTask
->
tbSink
.
pSchemaWrapper
->
nCols
);
ASSERT
(
pTask
->
tbSink
.
pTSchema
);
}
}
taosHashPut
(
pTq
->
pStreamTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
pTask
,
sizeof
(
SStreamTask
));
taosHashPut
(
pTq
->
pStreamTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
pTask
,
sizeof
(
SStreamTask
));
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
8e0eda6c
...
@@ -4830,6 +4830,7 @@ static SArray* createSortInfo(SNodeList* pNodeList, SNodeList* pNodeListTarget);
...
@@ -4830,6 +4830,7 @@ static SArray* createSortInfo(SNodeList* pNodeList, SNodeList* pNodeListTarget);
static
SArray
*
createIndexMap
(
SNodeList
*
pNodeList
);
static
SArray
*
createIndexMap
(
SNodeList
*
pNodeList
);
static
SArray
*
extractPartitionColInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
extractPartitionColInfo
(
SNodeList
*
pNodeList
);
static
int32_t
initQueryTableDataCond
(
SQueryTableDataCond
*
pCond
,
const
STableScanPhysiNode
*
pTableScanNode
);
static
int32_t
initQueryTableDataCond
(
SQueryTableDataCond
*
pCond
,
const
STableScanPhysiNode
*
pTableScanNode
);
static
void
setJoinColumnInfo
(
SColumnInfo
*
pInfo
,
const
SColumnNode
*
pLeftNode
);
static
SInterval
extractIntervalInfo
(
const
STableScanPhysiNode
*
pTableScanNode
)
{
static
SInterval
extractIntervalInfo
(
const
STableScanPhysiNode
*
pTableScanNode
)
{
SInterval
interval
=
{
SInterval
interval
=
{
...
@@ -5624,14 +5625,10 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
...
@@ -5624,14 +5625,10 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
goto
_error
;
goto
_error
;
}
}
pOperator
->
resultInfo
.
capacity
=
4096
;
initResultSizeInfo
(
pOperator
,
4096
);
pOperator
->
resultInfo
.
threshold
=
4096
*
0
.
75
;
// initResultRowInf
// o(&pInfo->binfo.resultRowInfo, 8);
pInfo
->
pRes
=
pResBlock
;
pInfo
->
pRes
=
pResBlock
;
pOperator
->
name
=
"MergeJoinOperator"
;
pOperator
->
name
=
"JoinOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_JOIN
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_JOIN
;
pOperator
->
blocking
=
false
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
...
@@ -5640,9 +5637,17 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
...
@@ -5640,9 +5637,17 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
SOperatorNode
*
pNode
=
(
SOperatorNode
*
)
pOnCondition
;
setJoinColumnInfo
(
&
pInfo
->
leftCol
,
(
SColumnNode
*
)
pNode
->
pLeft
);
setJoinColumnInfo
(
&
pInfo
->
rightCol
,
(
SColumnNode
*
)
pNode
->
pRight
);
pOperator
->
fpSet
=
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doMergeJoin
,
NULL
,
NULL
,
destroyBasicOperatorInfo
,
NULL
,
NULL
,
NULL
);
createOperatorFpSet
(
operatorDummyOpenFn
,
doMergeJoin
,
NULL
,
NULL
,
destroyBasicOperatorInfo
,
NULL
,
NULL
,
NULL
);
int32_t
code
=
appendDownstream
(
pOperator
,
pDownstream
,
numOfDownstream
);
int32_t
code
=
appendDownstream
(
pOperator
,
pDownstream
,
numOfDownstream
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
return
pOperator
;
return
pOperator
;
_error:
_error:
...
@@ -5651,3 +5656,11 @@ _error:
...
@@ -5651,3 +5656,11 @@ _error:
pTaskInfo
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
pTaskInfo
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
void
setJoinColumnInfo
(
SColumnInfo
*
pColumn
,
const
SColumnNode
*
pColumnNode
)
{
pColumn
->
slotId
=
pColumnNode
->
slotId
;
pColumn
->
type
=
pColumnNode
->
node
.
resType
.
type
;
pColumn
->
bytes
=
pColumnNode
->
node
.
resType
.
bytes
;
pColumn
->
precision
=
pColumnNode
->
node
.
resType
.
precision
;
pColumn
->
scale
=
pColumnNode
->
node
.
resType
.
scale
;
}
source/libs/function/src/builtins.c
浏览文件 @
8e0eda6c
...
@@ -913,7 +913,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -913,7 +913,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
{
.
name
=
"tbname"
,
.
name
=
"tbname"
,
.
type
=
FUNCTION_TYPE_TBNAME
,
.
type
=
FUNCTION_TYPE_TBNAME
,
.
classification
=
FUNC_MGT_PSEUDO_COLUMN_FUNC
,
.
classification
=
FUNC_MGT_PSEUDO_COLUMN_FUNC
|
FUNC_MGT_SCAN_PC_FUNC
,
.
translateFunc
=
translateTbnameColumn
,
.
translateFunc
=
translateTbnameColumn
,
.
getEnvFunc
=
NULL
,
.
getEnvFunc
=
NULL
,
.
initFunc
=
NULL
,
.
initFunc
=
NULL
,
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
8e0eda6c
...
@@ -100,6 +100,17 @@ void generateInformationSchema(MockCatalogService* mcs) {
...
@@ -100,6 +100,17 @@ void generateInformationSchema(MockCatalogService* mcs) {
}
}
}
}
/*
* Table:t1
* Field | Type | DataType | Bytes |
* ==========================================================================
* ts | column | TIMESTAMP | 8 |
* c1 | column | INT | 4 |
* c2 | column | VARCHAR | 20 |
* c3 | column | BIGINT | 8 |
* c4 | column | DOUBLE | 8 |
* c5 | column | DOUBLE | 8 |
*/
void
generateTestT1
(
MockCatalogService
*
mcs
)
{
void
generateTestT1
(
MockCatalogService
*
mcs
)
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"t1"
,
TSDB_NORMAL_TABLE
,
6
)
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"t1"
,
TSDB_NORMAL_TABLE
,
6
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
...
@@ -113,6 +124,17 @@ void generateTestT1(MockCatalogService* mcs) {
...
@@ -113,6 +124,17 @@ void generateTestT1(MockCatalogService* mcs) {
builder
.
done
();
builder
.
done
();
}
}
/*
* Super Table: st1
* Field | Type | DataType | Bytes |
* ==========================================================================
* ts | column | TIMESTAMP | 8 |
* c1 | column | INT | 4 |
* c2 | column | VARCHAR | 20 |
* tag1 | tag | INT | 4 |
* tag2 | tag | VARCHAR | 20 |
* Child Table: st1s1, st1s2
*/
void
generateTestST1
(
MockCatalogService
*
mcs
)
{
void
generateTestST1
(
MockCatalogService
*
mcs
)
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"st1"
,
TSDB_SUPER_TABLE
,
3
,
2
)
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"st1"
,
TSDB_SUPER_TABLE
,
3
,
2
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
...
...
source/libs/planner/test/planSTableTest.cpp
浏览文件 @
8e0eda6c
...
@@ -23,4 +23,6 @@ TEST_F(PlanSuperTableTest, tbname) {
...
@@ -23,4 +23,6 @@ TEST_F(PlanSuperTableTest, tbname) {
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"select tbname from st1"
);
run
(
"select tbname from st1"
);
run
(
"select tbname, tag1, tag2 from st1"
);
}
}
source/libs/planner/test/planTestMain.cpp
浏览文件 @
8e0eda6c
...
@@ -36,11 +36,11 @@ class PlannerEnv : public testing::Environment {
...
@@ -36,11 +36,11 @@ class PlannerEnv : public testing::Environment {
static
void
parseArg
(
int
argc
,
char
*
argv
[])
{
static
void
parseArg
(
int
argc
,
char
*
argv
[])
{
int
opt
=
0
;
int
opt
=
0
;
const
char
*
optstring
=
""
;
const
char
*
optstring
=
""
;
static
struct
option
long_options
[]
=
{{
"dump"
,
no
_argument
,
NULL
,
'd'
},
{
0
,
0
,
0
,
0
}};
static
struct
option
long_options
[]
=
{{
"dump"
,
optional
_argument
,
NULL
,
'd'
},
{
0
,
0
,
0
,
0
}};
while
((
opt
=
getopt_long
(
argc
,
argv
,
optstring
,
long_options
,
NULL
))
!=
-
1
)
{
while
((
opt
=
getopt_long
(
argc
,
argv
,
optstring
,
long_options
,
NULL
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'd'
:
case
'd'
:
g_isDump
=
true
;
setDumpModule
(
optarg
)
;
break
;
break
;
default:
default:
break
;
break
;
...
...
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
8e0eda6c
...
@@ -34,7 +34,41 @@ using namespace testing;
...
@@ -34,7 +34,41 @@ using namespace testing;
} \
} \
} while (0);
} while (0);
bool
g_isDump
=
false
;
enum
DumpModule
{
DUMP_MODULE_NOTHING
=
1
,
DUMP_MODULE_PARSER
,
DUMP_MODULE_LOGIC
,
DUMP_MODULE_OPTIMIZED
,
DUMP_MODULE_SPLIT
,
DUMP_MODULE_SCALED
,
DUMP_MODULE_PHYSICAL
,
DUMP_MODULE_SUBPLAN
,
DUMP_MODULE_ALL
};
DumpModule
g_dumpModule
=
DUMP_MODULE_NOTHING
;
void
setDumpModule
(
const
char
*
pModule
)
{
if
(
NULL
==
pModule
)
{
g_dumpModule
=
DUMP_MODULE_ALL
;
}
else
if
(
0
==
strncasecmp
(
pModule
,
"parser"
,
strlen
(
pModule
)))
{
g_dumpModule
=
DUMP_MODULE_PARSER
;
}
else
if
(
0
==
strncasecmp
(
pModule
,
"logic"
,
strlen
(
pModule
)))
{
g_dumpModule
=
DUMP_MODULE_LOGIC
;
}
else
if
(
0
==
strncasecmp
(
pModule
,
"optimized"
,
strlen
(
pModule
)))
{
g_dumpModule
=
DUMP_MODULE_OPTIMIZED
;
}
else
if
(
0
==
strncasecmp
(
pModule
,
"split"
,
strlen
(
pModule
)))
{
g_dumpModule
=
DUMP_MODULE_SPLIT
;
}
else
if
(
0
==
strncasecmp
(
pModule
,
"scaled"
,
strlen
(
pModule
)))
{
g_dumpModule
=
DUMP_MODULE_SCALED
;
}
else
if
(
0
==
strncasecmp
(
pModule
,
"physical"
,
strlen
(
pModule
)))
{
g_dumpModule
=
DUMP_MODULE_PHYSICAL
;
}
else
if
(
0
==
strncasecmp
(
pModule
,
"subplan"
,
strlen
(
pModule
)))
{
g_dumpModule
=
DUMP_MODULE_SUBPLAN
;
}
else
if
(
0
==
strncasecmp
(
pModule
,
"all"
,
strlen
(
pModule
)))
{
g_dumpModule
=
DUMP_MODULE_PHYSICAL
;
}
}
class
PlannerTestBaseImpl
{
class
PlannerTestBaseImpl
{
public:
public:
...
@@ -66,11 +100,9 @@ class PlannerTestBaseImpl {
...
@@ -66,11 +100,9 @@ class PlannerTestBaseImpl {
SQueryPlan
*
pPlan
=
nullptr
;
SQueryPlan
*
pPlan
=
nullptr
;
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
);
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
);
if
(
g_isDump
)
{
dump
(
g_dumpModule
);
dump
();
}
}
catch
(...)
{
}
catch
(...)
{
dump
();
dump
(
DUMP_MODULE_ALL
);
throw
;
throw
;
}
}
}
}
...
@@ -109,25 +141,50 @@ class PlannerTestBaseImpl {
...
@@ -109,25 +141,50 @@ class PlannerTestBaseImpl {
res_
.
physiSubplans_
.
clear
();
res_
.
physiSubplans_
.
clear
();
}
}
void
dump
()
{
void
dump
(
DumpModule
module
)
{
if
(
DUMP_MODULE_NOTHING
==
module
)
{
return
;
}
cout
<<
"==========================================sql : ["
<<
stmtEnv_
.
sql_
<<
"]"
<<
endl
;
cout
<<
"==========================================sql : ["
<<
stmtEnv_
.
sql_
<<
"]"
<<
endl
;
if
(
DUMP_MODULE_ALL
==
module
||
DUMP_MODULE_PARSER
==
module
)
{
cout
<<
"syntax tree : "
<<
endl
;
cout
<<
"syntax tree : "
<<
endl
;
cout
<<
res_
.
ast_
<<
endl
;
cout
<<
res_
.
ast_
<<
endl
;
}
if
(
DUMP_MODULE_ALL
==
module
||
DUMP_MODULE_LOGIC
==
module
)
{
cout
<<
"raw logic plan : "
<<
endl
;
cout
<<
"raw logic plan : "
<<
endl
;
cout
<<
res_
.
rawLogicPlan_
<<
endl
;
cout
<<
res_
.
rawLogicPlan_
<<
endl
;
}
if
(
DUMP_MODULE_ALL
==
module
||
DUMP_MODULE_OPTIMIZED
==
module
)
{
cout
<<
"optimized logic plan : "
<<
endl
;
cout
<<
"optimized logic plan : "
<<
endl
;
cout
<<
res_
.
optimizedLogicPlan_
<<
endl
;
cout
<<
res_
.
optimizedLogicPlan_
<<
endl
;
}
if
(
DUMP_MODULE_ALL
==
module
||
DUMP_MODULE_SPLIT
==
module
)
{
cout
<<
"split logic plan : "
<<
endl
;
cout
<<
"split logic plan : "
<<
endl
;
cout
<<
res_
.
splitLogicPlan_
<<
endl
;
cout
<<
res_
.
splitLogicPlan_
<<
endl
;
}
if
(
DUMP_MODULE_ALL
==
module
||
DUMP_MODULE_SCALED
==
module
)
{
cout
<<
"scaled logic plan : "
<<
endl
;
cout
<<
"scaled logic plan : "
<<
endl
;
cout
<<
res_
.
scaledLogicPlan_
<<
endl
;
cout
<<
res_
.
scaledLogicPlan_
<<
endl
;
}
if
(
DUMP_MODULE_ALL
==
module
||
DUMP_MODULE_PHYSICAL
==
module
)
{
cout
<<
"physical plan : "
<<
endl
;
cout
<<
"physical plan : "
<<
endl
;
cout
<<
res_
.
physiPlan_
<<
endl
;
cout
<<
res_
.
physiPlan_
<<
endl
;
}
if
(
DUMP_MODULE_ALL
==
module
||
DUMP_MODULE_SUBPLAN
==
module
)
{
cout
<<
"physical subplan : "
<<
endl
;
cout
<<
"physical subplan : "
<<
endl
;
for
(
const
auto
&
subplan
:
res_
.
physiSubplans_
)
{
for
(
const
auto
&
subplan
:
res_
.
physiSubplans_
)
{
cout
<<
subplan
<<
endl
;
cout
<<
subplan
<<
endl
;
}
}
}
}
}
void
doParseSql
(
const
string
&
sql
,
SQuery
**
pQuery
)
{
void
doParseSql
(
const
string
&
sql
,
SQuery
**
pQuery
)
{
stmtEnv_
.
sql_
=
sql
;
stmtEnv_
.
sql_
=
sql
;
...
...
source/libs/planner/test/planTestUtil.h
浏览文件 @
8e0eda6c
...
@@ -32,6 +32,6 @@ class PlannerTestBase : public testing::Test {
...
@@ -32,6 +32,6 @@ class PlannerTestBase : public testing::Test {
std
::
unique_ptr
<
PlannerTestBaseImpl
>
impl_
;
std
::
unique_ptr
<
PlannerTestBaseImpl
>
impl_
;
};
};
extern
bool
g_isDump
;
extern
void
setDumpModule
(
const
char
*
pModule
)
;
#endif // PLAN_TEST_UTIL_H
#endif // PLAN_TEST_UTIL_H
source/libs/scalar/src/sclvector.c
浏览文件 @
8e0eda6c
...
@@ -297,6 +297,22 @@ static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIn
...
@@ -297,6 +297,22 @@ static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIn
taosMemoryFree
(
t
);
taosMemoryFree
(
t
);
}
}
static
FORCE_INLINE
void
ncharToVar
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
rowIndex
)
{
int32_t
inputLen
=
varDataLen
(
buf
);
char
*
t
=
taosMemoryCalloc
(
1
,
inputLen
+
VARSTR_HEADER_SIZE
);
int32_t
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
buf
),
varDataLen
(
buf
),
varDataVal
(
t
));
if
(
len
<
0
)
{
taosMemoryFree
(
t
);
return
;
}
varDataSetLen
(
t
,
len
);
colDataAppend
(
pOut
->
columnData
,
rowIndex
,
t
,
false
);
taosMemoryFree
(
t
);
}
//TODO opt performance, tmp is not needed.
//TODO opt performance, tmp is not needed.
int32_t
vectorConvertFromVarData
(
const
SScalarParam
*
pIn
,
SScalarParam
*
pOut
,
int32_t
inType
,
int32_t
outType
)
{
int32_t
vectorConvertFromVarData
(
const
SScalarParam
*
pIn
,
SScalarParam
*
pOut
,
int32_t
inType
,
int32_t
outType
)
{
int32_t
bufSize
=
pIn
->
columnData
->
info
.
bytes
;
int32_t
bufSize
=
pIn
->
columnData
->
info
.
bytes
;
...
@@ -313,6 +329,10 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
...
@@ -313,6 +329,10 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
func
=
varToUnsigned
;
func
=
varToUnsigned
;
}
else
if
(
IS_FLOAT_TYPE
(
outType
))
{
}
else
if
(
IS_FLOAT_TYPE
(
outType
))
{
func
=
varToFloat
;
func
=
varToFloat
;
}
else
if
(
outType
==
TSDB_DATA_TYPE_BINARY
)
{
// nchar -> binary
ASSERT
(
inType
==
TSDB_DATA_TYPE_NCHAR
);
func
=
ncharToVar
;
vton
=
true
;
}
else
if
(
outType
==
TSDB_DATA_TYPE_NCHAR
)
{
// binary -> nchar
}
else
if
(
outType
==
TSDB_DATA_TYPE_NCHAR
)
{
// binary -> nchar
ASSERT
(
inType
==
TSDB_DATA_TYPE_VARCHAR
);
ASSERT
(
inType
==
TSDB_DATA_TYPE_VARCHAR
);
func
=
varToNchar
;
func
=
varToNchar
;
...
@@ -608,7 +628,7 @@ int8_t gConvertTypes[TSDB_DATA_TYPE_BLOB+1][TSDB_DATA_TYPE_BLOB+1] = {
...
@@ -608,7 +628,7 @@ int8_t gConvertTypes[TSDB_DATA_TYPE_BLOB+1][TSDB_DATA_TYPE_BLOB+1] = {
/*BIGI*/
0
,
0
,
0
,
0
,
0
,
0
,
6
,
7
,
7
,
0
,
7
,
5
,
5
,
5
,
7
,
0
,
7
,
0
,
0
,
/*BIGI*/
0
,
0
,
0
,
0
,
0
,
0
,
6
,
7
,
7
,
0
,
7
,
5
,
5
,
5
,
7
,
0
,
7
,
0
,
0
,
/*FLOA*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
7
,
7
,
6
,
7
,
6
,
6
,
6
,
6
,
0
,
7
,
0
,
0
,
/*FLOA*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
7
,
7
,
6
,
7
,
6
,
6
,
6
,
6
,
0
,
7
,
0
,
0
,
/*DOUB*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
0
,
7
,
0
,
0
,
/*DOUB*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
7
,
7
,
7
,
7
,
7
,
7
,
7
,
0
,
7
,
0
,
0
,
/*VARC*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
9
,
0
,
7
,
7
,
7
,
7
,
0
,
0
,
0
,
0
,
/*VARC*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
9
,
8
,
7
,
7
,
7
,
7
,
0
,
0
,
0
,
0
,
/*TIME*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
9
,
9
,
9
,
9
,
7
,
0
,
7
,
0
,
0
,
/*TIME*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
9
,
9
,
9
,
9
,
7
,
0
,
7
,
0
,
0
,
/*NCHA*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
7
,
7
,
7
,
7
,
0
,
0
,
0
,
0
,
/*NCHA*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
7
,
7
,
7
,
7
,
0
,
0
,
0
,
0
,
/*UTIN*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
12
,
13
,
14
,
0
,
7
,
0
,
0
,
/*UTIN*/
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
12
,
13
,
14
,
0
,
7
,
0
,
0
,
...
...
source/libs/stream/src/tstream.c
浏览文件 @
8e0eda6c
...
@@ -152,8 +152,10 @@ int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, in
...
@@ -152,8 +152,10 @@ int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, in
// sink
// sink
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
//
/*blockDebugShowData(pRes);*/
blockDebugShowData
(
pRes
);
ASSERT
(
pTask
->
tbSink
.
pTSchema
);
SSubmitReq
*
pReq
=
tdBlockToSubmit
(
pRes
,
pTask
->
tbSink
.
pTSchema
);
tPrintFixedSchemaSubmitReq
(
pReq
,
pTask
->
tbSink
.
pTSchema
);
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
pTask
->
smaSink
.
smaHandle
(
pTask
->
ahandle
,
pTask
->
smaSink
.
smaId
,
pRes
);
pTask
->
smaSink
.
smaHandle
(
pTask
->
ahandle
,
pTask
->
smaSink
.
smaId
,
pRes
);
//
//
...
@@ -274,7 +276,8 @@ int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask) {
...
@@ -274,7 +276,8 @@ int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask) {
}
}
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
if
(
tEncodeI8
(
pEncoder
,
pTask
->
tbSink
.
reserved
)
<
0
)
return
-
1
;
/*if (tEncodeI8(pEncoder, pTask->tbSink.reserved) < 0) return -1;*/
if
(
tEncodeSSchemaWrapper
(
pEncoder
,
pTask
->
tbSink
.
pSchemaWrapper
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
if
(
tEncodeI64
(
pEncoder
,
pTask
->
smaSink
.
smaId
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pTask
->
smaSink
.
smaId
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__FETCH
)
{
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__FETCH
)
{
...
@@ -318,7 +321,10 @@ int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask) {
...
@@ -318,7 +321,10 @@ int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask) {
}
}
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
tbSink
.
reserved
)
<
0
)
return
-
1
;
/*if (tDecodeI8(pDecoder, &pTask->tbSink.reserved) < 0) return -1;*/
pTask
->
tbSink
.
pSchemaWrapper
=
taosMemoryCalloc
(
1
,
sizeof
(
SSchemaWrapper
));
if
(
pTask
->
tbSink
.
pSchemaWrapper
==
NULL
)
return
-
1
;
if
(
tDecodeSSchemaWrapper
(
pDecoder
,
pTask
->
tbSink
.
pSchemaWrapper
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
smaSink
.
smaId
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
smaSink
.
smaId
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__FETCH
)
{
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__FETCH
)
{
...
...
tests/script/api/batchprepare.c
浏览文件 @
8e0eda6c
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
int32_t
shortColList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_INT
};
int32_t
shortColList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_INT
};
int32_t
fullColList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_BOOL
,
TSDB_DATA_TYPE_TINYINT
,
TSDB_DATA_TYPE_UTINYINT
,
TSDB_DATA_TYPE_SMALLINT
,
TSDB_DATA_TYPE_USMALLINT
,
TSDB_DATA_TYPE_INT
,
TSDB_DATA_TYPE_UINT
,
TSDB_DATA_TYPE_BIGINT
,
TSDB_DATA_TYPE_UBIGINT
,
TSDB_DATA_TYPE_FLOAT
,
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DATA_TYPE_NCHAR
};
int32_t
fullColList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_BOOL
,
TSDB_DATA_TYPE_TINYINT
,
TSDB_DATA_TYPE_UTINYINT
,
TSDB_DATA_TYPE_SMALLINT
,
TSDB_DATA_TYPE_USMALLINT
,
TSDB_DATA_TYPE_INT
,
TSDB_DATA_TYPE_UINT
,
TSDB_DATA_TYPE_BIGINT
,
TSDB_DATA_TYPE_UBIGINT
,
TSDB_DATA_TYPE_FLOAT
,
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DATA_TYPE_NCHAR
};
int32_t
bindColTypeList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_
NCHAR
,
TSDB_DATA_TYPE_BOOL
};
int32_t
bindColTypeList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_
SMALLINT
,
TSDB_DATA_TYPE_DOUBLE
};
int32_t
optrIdxList
[]
=
{
2
,
11
,
6
};
int32_t
optrIdxList
[]
=
{
0
,
1
,
2
};
typedef
struct
{
typedef
struct
{
char
*
oper
;
char
*
oper
;
...
@@ -169,8 +169,8 @@ typedef struct {
...
@@ -169,8 +169,8 @@ typedef struct {
int32_t
caseRunNum
;
// total run case num
int32_t
caseRunNum
;
// total run case num
}
CaseCtrl
;
}
CaseCtrl
;
#if
1
#if
0
CaseCtrl
gCaseCtrl
=
{
CaseCtrl gCaseCtrl = {
// default
.bindNullNum = 0,
.bindNullNum = 0,
.prepareStb = false,
.prepareStb = false,
.printCreateTblSql = false,
.printCreateTblSql = false,
...
@@ -186,23 +186,43 @@ CaseCtrl gCaseCtrl = {
...
@@ -186,23 +186,43 @@ CaseCtrl gCaseCtrl = {
.checkParamNum = false,
.checkParamNum = false,
.printRes = true,
.printRes = true,
.runTimes = 0,
.runTimes = 0,
//
.caseIdx = -1,
.caseIdx = -1,
//
.caseNum = -1,
.caseNum = -1,
.caseRunIdx = -1,
.caseRunIdx = -1,
// .caseRunNum = -1,
.caseRunNum = -1,
};
#endif
// .optrIdxListNum = tListLen(optrIdxList),
#if 0
// .optrIdxList = optrIdxList,
CaseCtrl gCaseCtrl = { // query case with specified col&oper
// .bindColTypeNum = tListLen(bindColTypeList),
.bindNullNum = 0,
// .bindColTypeList = bindColTypeList,
.prepareStb = false,
.printCreateTblSql = false,
.printQuerySql = true,
.printStmtSql = true,
.rowNum = 0,
.bindColNum = 0,
.bindRowNum = 0,
.bindColTypeNum = 0,
.bindColTypeList = NULL,
.optrIdxListNum = 0,
.optrIdxList = NULL,
.checkParamNum = false,
.printRes = true,
.runTimes = 0,
.caseRunIdx = -1,
.optrIdxListNum = 0,
.optrIdxList = NULL,
.bindColTypeNum = 0,
.bindColTypeList = NULL,
.caseIdx = 22,
.caseIdx = 22,
.caseNum = 1,
.caseNum = 1,
.caseRunNum = 1,
.caseRunNum = 1,
};
};
#else
#endif
CaseCtrl
gCaseCtrl
=
{
#if 1
CaseCtrl
gCaseCtrl
=
{
// query case with specified col&oper
.
bindNullNum
=
0
,
.
bindNullNum
=
0
,
.
prepareStb
=
false
,
.
prepareStb
=
false
,
.
printCreateTblSql
=
false
,
.
printCreateTblSql
=
false
,
...
@@ -211,17 +231,22 @@ CaseCtrl gCaseCtrl = {
...
@@ -211,17 +231,22 @@ CaseCtrl gCaseCtrl = {
.
rowNum
=
0
,
.
rowNum
=
0
,
.
bindColNum
=
0
,
.
bindColNum
=
0
,
.
bindRowNum
=
0
,
.
bindRowNum
=
0
,
.
bindColTypeNum
=
tListLen
(
bindColTypeList
),
.
bindColTypeNum
=
0
,
.
bindColTypeList
=
bindColTypeList
,
.
bindColTypeList
=
NULL
,
.
checkParamNum
=
false
,
.
optrIdxListNum
=
0
,
.
optrIdxList
=
NULL
,
.
checkParamNum
=
true
,
.
printRes
=
true
,
.
printRes
=
true
,
.
runTimes
=
0
,
.
runTimes
=
0
,
.
caseIdx
=
2
,
.
caseNum
=
1
,
.
caseRunIdx
=
-
1
,
.
caseRunIdx
=
-
1
,
.
optrIdxListNum
=
tListLen
(
optrIdxList
),
.
optrIdxList
=
optrIdxList
,
.
bindColTypeNum
=
tListLen
(
bindColTypeList
),
.
bindColTypeList
=
bindColTypeList
,
.
caseIdx
=
22
,
.
caseNum
=
1
,
.
caseRunNum
=
1
,
.
caseRunNum
=
1
,
};
};
#endif
#endif
int32_t
taosGetTimeOfDay
(
struct
timeval
*
tv
)
{
int32_t
taosGetTimeOfDay
(
struct
timeval
*
tv
)
{
...
@@ -437,6 +462,29 @@ void generateQuerySQL(BindData *data, int32_t tblIdx) {
...
@@ -437,6 +462,29 @@ void generateQuerySQL(BindData *data, int32_t tblIdx) {
}
}
}
}
void
generateErrorSQL
(
BindData
*
data
,
int32_t
tblIdx
)
{
int32_t
len
=
0
;
data
->
sql
=
taosMemoryCalloc
(
1
,
1024
);
switch
(
tblIdx
)
{
case
0
:
len
=
sprintf
(
data
->
sql
,
"insert into %s%d values (?, 1)"
,
bpTbPrefix
,
tblIdx
);
break
;
case
1
:
len
=
sprintf
(
data
->
sql
,
"select * from ?"
);
break
;
case
2
:
len
=
sprintf
(
data
->
sql
,
"select * from %s%d where ? = ?"
,
bpTbPrefix
,
tblIdx
);
break
;
default:
len
=
sprintf
(
data
->
sql
,
"select count(*) from %s%d group by ?"
,
bpTbPrefix
,
tblIdx
);
break
;
}
if
(
gCaseCtrl
.
printStmtSql
)
{
printf
(
"
\t
STMT SQL: %s
\n
"
,
data
->
sql
);
}
}
void
generateDataType
(
BindData
*
data
,
int32_t
bindIdx
,
int32_t
colIdx
,
int32_t
*
dataType
)
{
void
generateDataType
(
BindData
*
data
,
int32_t
bindIdx
,
int32_t
colIdx
,
int32_t
*
dataType
)
{
if
(
bindIdx
<
gCurCase
->
bindColNum
)
{
if
(
bindIdx
<
gCurCase
->
bindColNum
)
{
...
@@ -687,6 +735,8 @@ int32_t prepareQueryData(BindData *data, int32_t tblIdx) {
...
@@ -687,6 +735,8 @@ int32_t prepareQueryData(BindData *data, int32_t tblIdx) {
}
}
void
destroyData
(
BindData
*
data
)
{
void
destroyData
(
BindData
*
data
)
{
taosMemoryFree
(
data
->
tsData
);
taosMemoryFree
(
data
->
tsData
);
taosMemoryFree
(
data
->
boolData
);
taosMemoryFree
(
data
->
boolData
);
...
@@ -1329,6 +1379,7 @@ int insertMPMETest1(TAOS_STMT *stmt, TAOS *taos) {
...
@@ -1329,6 +1379,7 @@ int insertMPMETest1(TAOS_STMT *stmt, TAOS *taos) {
return
0
;
return
0
;
}
}
/* select * from table */
int
querySUBTTest1
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
)
{
int
querySUBTTest1
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
)
{
BindData
data
=
{
0
};
BindData
data
=
{
0
};
...
@@ -1374,6 +1425,74 @@ int querySUBTTest1(TAOS_STMT *stmt, TAOS *taos) {
...
@@ -1374,6 +1425,74 @@ int querySUBTTest1(TAOS_STMT *stmt, TAOS *taos) {
return
0
;
return
0
;
}
}
/* value in query sql */
int
querySUBTTest2
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
)
{
BindData
data
=
{
0
};
for
(
int32_t
t
=
0
;
t
<
gCurCase
->
tblNum
;
++
t
)
{
memset
(
&
data
,
0
,
sizeof
(
data
));
prepareQueryData
(
&
data
,
t
);
int
code
=
taos_stmt_prepare
(
stmt
,
data
.
sql
,
0
);
if
(
code
!=
0
){
printf
(
"!!!failed to execute taos_stmt_prepare. error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
for
(
int32_t
n
=
0
;
n
<
(
gCurCase
->
rowNum
/
gCurCase
->
bindRowNum
);
++
n
)
{
bpCheckIsInsert
(
stmt
,
0
);
if
(
gCaseCtrl
.
checkParamNum
)
{
bpCheckParamNum
(
stmt
);
}
if
(
bpBindParam
(
stmt
,
data
.
pBind
+
n
*
gCurCase
->
bindColNum
))
{
exit
(
1
);
}
if
(
taos_stmt_add_batch
(
stmt
))
{
printf
(
"!!!taos_stmt_add_batch error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
if
(
taos_stmt_execute
(
stmt
)
!=
0
)
{
printf
(
"!!!taos_stmt_execute error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
exit
(
1
);
}
bpCheckQueryResult
(
stmt
,
taos
,
data
.
sql
,
data
.
pBind
+
n
*
gCurCase
->
bindColNum
);
}
bpCheckIsInsert
(
stmt
,
0
);
destroyData
(
&
data
);
}
return
0
;
}
int
errorSQLTest1
(
TAOS_STMT
*
stmt
,
TAOS
*
taos
)
{
BindData
data
=
{
0
};
for
(
int32_t
t
=
0
;
t
<
gCurCase
->
tblNum
;
++
t
)
{
memset
(
&
data
,
0
,
sizeof
(
data
));
generateErrorSQL
(
&
data
,
t
);
int
code
=
taos_stmt_prepare
(
stmt
,
data
.
sql
,
0
);
if
(
code
!=
0
){
printf
(
"*taos_stmt_prepare error as expected, error:%s
\n
"
,
taos_stmt_errstr
(
stmt
));
}
else
{
printf
(
"!!!taos_stmt_prepare succeed, which should be error
\n
"
);
exit
(
1
);
}
destroyData
(
&
data
);
}
return
0
;
}
#if 0
#if 0
...
@@ -1398,6 +1517,72 @@ int stmt_funcb_autoctb1(TAOS_STMT *stmt) {
...
@@ -1398,6 +1517,72 @@ int stmt_funcb_autoctb1(TAOS_STMT *stmt) {
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
exit(1);
}
int id = 0;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf, tags);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code);
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
}
//1 tables 10 records
int stmt_funcb_autoctb2(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
int8_t v1[10];
int16_t v2[10];
int32_t v4[10];
int64_t v8[10];
float f4[10];
double f8[10];
char bin[10][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 1 * 10);
int *lb = taosMemoryMalloc(10 * sizeof(int));
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
// int one_null = 1;
// int one_null = 1;
int one_not_null = 0;
int one_not_null = 0;
...
@@ -1547,7 +1732,7 @@ int stmt_funcb_autoctb1(TAOS_STMT *stmt) {
...
@@ -1547,7 +1732,7 @@ int stmt_funcb_autoctb1(TAOS_STMT *stmt) {
unsigned long long starttime = taosGetTimestampUs();
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(
?,?,?,?,?,?,?,?,?
) values(?,?,?,?,?,?,?,?,?,?)";
char *sql = "insert into ? using stb1 tags(
1,true,2,3,4,5.0,6.0,'a','b'
) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
...
@@ -1590,8 +1775,9 @@ int stmt_funcb_autoctb1(TAOS_STMT *stmt) {
...
@@ -1590,8 +1775,9 @@ int stmt_funcb_autoctb1(TAOS_STMT *stmt) {
//1 tables 10 records
//1 tables 10 records
int stmt_funcb_autoctb
2
(TAOS_STMT *stmt) {
int stmt_funcb_autoctb
3
(TAOS_STMT *stmt) {
struct {
struct {
int64_t *ts;
int64_t *ts;
int8_t b[10];
int8_t b[10];
...
@@ -1711,56 +1897,31 @@ int stmt_funcb_autoctb2(TAOS_STMT *stmt) {
...
@@ -1711,56 +1897,31 @@ int stmt_funcb_autoctb2(TAOS_STMT *stmt) {
for (int i = 0; i < 1; ++i) {
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_
INT
;
tags[i+0].buffer_type = TSDB_DATA_TYPE_
BOOL
;
tags[i+0].buffer = v.
v4
;
tags[i+0].buffer = v.
b
;
tags[i+0].is_null = &one_not_null;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_
BOOL
;
tags[i+1].buffer_type = TSDB_DATA_TYPE_
SMALLINT
;
tags[i+1].buffer = v.
b
;
tags[i+1].buffer = v.
v2
;
tags[i+1].is_null = &one_not_null;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_
TINYIN
T;
tags[i+2].buffer_type = TSDB_DATA_TYPE_
FLOA
T;
tags[i+2].buffer = v.
v1
;
tags[i+2].buffer = v.
f4
;
tags[i+2].is_null = &one_not_null;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_
SMALLINT
;
tags[i+3].buffer_type = TSDB_DATA_TYPE_
BINARY
;
tags[i+3].buffer = v.
v2
;
tags[i+3].buffer = v.
bin
;
tags[i+3].is_null = &one_not_null;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = NULL;
tags[i+3].length = (uintptr_t *)lb;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
tags[i+8].buffer = v.bin;
tags[i+8].is_null = &one_not_null;
tags[i+8].length = (uintptr_t *)lb;
}
}
unsigned long long starttime = taosGetTimestampUs();
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(1,
true,2,3,4,5.0,6.0,'a'
,'b') values(?,?,?,?,?,?,?,?,?,?)";
char *sql = "insert into ? using stb1 tags(1,
?,2,?,4,?,6.0,?
,'b') values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
...
@@ -1804,8 +1965,10 @@ int stmt_funcb_autoctb2(TAOS_STMT *stmt) {
...
@@ -1804,8 +1965,10 @@ int stmt_funcb_autoctb2(TAOS_STMT *stmt) {
//1 tables 10 records
//1 tables 10 records
int stmt_funcb_autoctb
3
(TAOS_STMT *stmt) {
int stmt_funcb_autoctb
4
(TAOS_STMT *stmt) {
struct {
struct {
int64_t *ts;
int64_t *ts;
int8_t b[10];
int8_t b[10];
...
@@ -1823,7 +1986,7 @@ int stmt_funcb_autoctb3(TAOS_STMT *stmt) {
...
@@ -1823,7 +1986,7 @@ int stmt_funcb_autoctb3(TAOS_STMT *stmt) {
int *lb = taosMemoryMalloc(10 * sizeof(int));
int *lb = taosMemoryMalloc(10 * sizeof(int));
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*
10
);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*
5
);
// int one_null = 1;
// int one_null = 1;
int one_not_null = 0;
int one_not_null = 0;
...
@@ -1845,7 +2008,7 @@ int stmt_funcb_autoctb3(TAOS_STMT *stmt) {
...
@@ -1845,7 +2008,7 @@ int stmt_funcb_autoctb3(TAOS_STMT *stmt) {
memset(v.bin[i], '0'+i%10, 40);
memset(v.bin[i], '0'+i%10, 40);
}
}
for (int i = 0; i <
10; i+=10
) {
for (int i = 0; i <
5; i+=5
) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[10*i/10];
params[i+0].buffer = &v.ts[10*i/10];
...
@@ -1860,200 +2023,9 @@ int stmt_funcb_autoctb3(TAOS_STMT *stmt) {
...
@@ -1860,200 +2023,9 @@ int stmt_funcb_autoctb3(TAOS_STMT *stmt) {
params[i+1].is_null = is_null;
params[i+1].is_null = is_null;
params[i+1].num = 10;
params[i+1].num = 10;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_type = TSDB_DATA_TYPE_INT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer_length = sizeof(int32_t);
params[i+2].buffer = v.v1;
params[i+2].buffer = v.v4;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 10;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 10;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 10;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 10;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 10;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 10;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 10;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 10;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 10; ++i) {
v.ts[i] = tts + i;
}
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_BOOL;
tags[i+0].buffer = v.b;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_SMALLINT;
tags[i+1].buffer = v.v2;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+2].buffer = v.f4;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+3].buffer = v.bin;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(1,?,2,?,4,?,6.0,?,'b') values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
exit(1);
}
int id = 0;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf, tags);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code);
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
}
//1 tables 10 records
int stmt_funcb_autoctb4(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
int8_t v1[10];
int16_t v2[10];
int32_t v4[10];
int64_t v8[10];
float f4[10];
double f8[10];
char bin[10][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 1 * 10);
int *lb = taosMemoryMalloc(10 * sizeof(int));
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*5);
// int one_null = 1;
int one_not_null = 0;
char* is_null = taosMemoryMalloc(sizeof(char) * 10);
char* no_null = taosMemoryMalloc(sizeof(char) * 10);
for (int i = 0; i < 10; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 5; i+=5) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[10*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 10;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 10;
params[i+2].buffer_type = TSDB_DATA_TYPE_INT;
params[i+2].buffer_length = sizeof(int32_t);
params[i+2].buffer = v.v4;
params[i+2].length = NULL;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].is_null = is_null;
params[i+2].num = 10;
params[i+2].num = 10;
...
@@ -2358,185 +2330,38 @@ int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) {
...
@@ -2358,185 +2330,38 @@ int stmt_funcb_autoctb_e2(TAOS_STMT *stmt) {
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
// int one_null = 1;
unsigned long long starttime = taosGetTimestampUs();
int one_not_null = 0;
char* is_null = taosMemoryMalloc(sizeof(char) * 10);
char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)";
char* no_null = taosMemoryMalloc(sizeof(char) * 10);
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
exit(1);
}
for (int i = 0; i < 10; ++i) {
int id = 0;
lb[i] = 40;
for (int zz = 0; zz < 1; zz++) {
no_null[i] = 0;
char buf[32];
is_null[i] = (i % 10 == 2) ? 1 : 0;
sprintf(buf, "m%d", zz);
v.b[i] = (int8_t)(i % 2);
code = taos_stmt_set_tbname_tags(stmt, buf, NULL);
v.v1[i] = (int8_t)((i+1) % 2);
if (code != 0){
v.v2[i] = (int16_t)i;
printf("failed to execute taos_stmt_set_tbname_tags. code:%s\n", taos_stmt_errstr(stmt));
v.v4[i] = (int32_t)(i+1);
return -1;
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
}
for (int i = 0; i < 10; i+=10) {
taos_stmt_bind_param_batch(stmt, params + id * 10);
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
taos_stmt_add_batch(stmt);
params[i+0].buffer_length = sizeof(int64_t);
}
params[i+0].buffer = &v.ts[10*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 10;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
if (taos_stmt_execute(stmt) != 0) {
params[i+1].buffer_length = sizeof(int8_t);
printf("failed to execute insert statement.\n");
params[i+1].buffer = v.b;
exit(1);
params[i+1].length = NULL;
}
params[i+1].is_null = is_null;
params[i+1].num = 10;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
++id;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 10;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
unsigned long long endtime = taosGetTimestampUs();
params[i+3].buffer_length = sizeof(int16_t);
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10));
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 10;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 10;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 10;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 10;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 10;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 10;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 10;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 10; ++i) {
v.ts[i] = tts + i;
}
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
tags[i+0].buffer = v.v4;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
tags[i+1].buffer = v.b;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
tags[i+2].buffer = v.v1;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
tags[i+3].buffer = v.v2;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = NULL;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
tags[i+8].buffer = v.bin;
tags[i+8].is_null = &one_not_null;
tags[i+8].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
exit(1);
}
int id = 0;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf, NULL);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. code:%s\n", taos_stmt_errstr(stmt));
return -1;
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10));
taosMemoryFree(v.ts);
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(lb);
...
@@ -2575,1341 +2400,28 @@ int stmt_funcb_autoctb_e3(TAOS_STMT *stmt) {
...
@@ -2575,1341 +2400,28 @@ int stmt_funcb_autoctb_e3(TAOS_STMT *stmt) {
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
// int one_null = 1;
int one_not_null = 0;
char* is_null = taosMemoryMalloc(sizeof(char) * 10);
char* no_null = taosMemoryMalloc(sizeof(char) * 10);
for (int i = 0; i < 10; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 10; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[10*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 10;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 10;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 10;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 10;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 10;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 10;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 10;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 10;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 10;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 10;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 10; ++i) {
v.ts[i] = tts + i;
}
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
tags[i+0].buffer = v.v4;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
tags[i+1].buffer = v.b;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
tags[i+2].buffer = v.v1;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
tags[i+3].buffer = v.v2;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = NULL;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
unsigned long long starttime = taosGetTimestampUs();
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
tags[i+8].buffer = v.bin;
tags[i+8].is_null = &one_not_null;
tags[i+8].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 (id1,id2,id3,id4,id5,id6,id7,id8,id9) tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)";
char *sql = "insert into ? using stb1 (id1,id2,id3,id4,id5,id6,id7,id8,id9) tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt));
printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt));
return -1;
return -1;
//exit(1);
//exit(1);
}
int id = 0;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf, NULL);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code);
return -1;
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
}
//1 tables 10 records
int stmt_funcb_autoctb_e4(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
int8_t v1[10];
int16_t v2[10];
int32_t v4[10];
int64_t v8[10];
float f4[10];
double f8[10];
char bin[10][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 1 * 10);
int *lb = taosMemoryMalloc(10 * sizeof(int));
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
// int one_null = 1;
int one_not_null = 0;
char* is_null = taosMemoryMalloc(sizeof(char) * 10);
char* no_null = taosMemoryMalloc(sizeof(char) * 10);
for (int i = 0; i < 10; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 10; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[10*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 10;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 10;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 10;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 10;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 10;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 10;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 10;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 10;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 10;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 10;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 10; ++i) {
v.ts[i] = tts + i;
}
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
tags[i+0].buffer = v.v4;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
tags[i+1].buffer = v.b;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
tags[i+2].buffer = v.v1;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
tags[i+3].buffer = v.v2;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = NULL;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
tags[i+8].buffer = v.bin;
tags[i+8].is_null = &one_not_null;
tags[i+8].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
int id = 0;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf, tags);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
return -1;
}
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
}
//1 tables 10 records
int stmt_funcb_autoctb_e5(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[10];
int8_t v1[10];
int16_t v2[10];
int32_t v4[10];
int64_t v8[10];
float f4[10];
double f8[10];
char bin[10][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 1 * 10);
int *lb = taosMemoryMalloc(10 * sizeof(int));
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
// int one_null = 1;
int one_not_null = 0;
char* is_null = taosMemoryMalloc(sizeof(char) * 10);
char* no_null = taosMemoryMalloc(sizeof(char) * 10);
for (int i = 0; i < 10; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 10; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[10*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 10;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 10;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 10;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 10;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 10;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 10;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 10;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 10;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 10;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 10;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 10; ++i) {
v.ts[i] = tts + i;
}
for (int i = 0; i < 1; ++i) {
tags[i+0].buffer_type = TSDB_DATA_TYPE_INT;
tags[i+0].buffer = v.v4;
tags[i+0].is_null = &one_not_null;
tags[i+0].length = NULL;
tags[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
tags[i+1].buffer = v.b;
tags[i+1].is_null = &one_not_null;
tags[i+1].length = NULL;
tags[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
tags[i+2].buffer = v.v1;
tags[i+2].is_null = &one_not_null;
tags[i+2].length = NULL;
tags[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
tags[i+3].buffer = v.v2;
tags[i+3].is_null = &one_not_null;
tags[i+3].length = NULL;
tags[i+4].buffer_type = TSDB_DATA_TYPE_BIGINT;
tags[i+4].buffer = v.v8;
tags[i+4].is_null = &one_not_null;
tags[i+4].length = NULL;
tags[i+5].buffer_type = TSDB_DATA_TYPE_FLOAT;
tags[i+5].buffer = v.f4;
tags[i+5].is_null = &one_not_null;
tags[i+5].length = NULL;
tags[i+6].buffer_type = TSDB_DATA_TYPE_DOUBLE;
tags[i+6].buffer = v.f8;
tags[i+6].is_null = &one_not_null;
tags[i+6].length = NULL;
tags[i+7].buffer_type = TSDB_DATA_TYPE_BINARY;
tags[i+7].buffer = v.bin;
tags[i+7].is_null = &one_not_null;
tags[i+7].length = (uintptr_t *)lb;
tags[i+8].buffer_type = TSDB_DATA_TYPE_NCHAR;
tags[i+8].buffer = v.bin;
tags[i+8].is_null = &one_not_null;
tags[i+8].length = (uintptr_t *)lb;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? using stb1 tags(?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(NULL, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(NULL));
return -1;
}
int id = 0;
for (int zz = 0; zz < 1; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname_tags(stmt, buf, tags);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname_tags. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
return -1;
}
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 10, (endtime-starttime)/1000000UL, (endtime-starttime)/(10));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
}
//samets
int stmt_funcb4(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[60];
int8_t v1[60];
int16_t v2[60];
int32_t v4[60];
int64_t v8[60];
float f4[60];
double f8[60];
char bin[60][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 900000 * 60);
int *lb = taosMemoryMalloc(60 * sizeof(int));
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10);
char* is_null = taosMemoryMalloc(sizeof(char) * 60);
char* no_null = taosMemoryMalloc(sizeof(char) * 60);
for (int i = 0; i < 60; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 9000000; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[60*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 60;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 60;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 60;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 60;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 60;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 60;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 60;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 60;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 60;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 60;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 54000000; ++i) {
v.ts[i] = tts;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
}
int id = 0;
for (int l = 0; l < 3000; l++) {
for (int zz = 0; zz < 300; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
}
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
return 0;
}
//1table 18000 reocrds
int stmt_funcb5(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[18000];
int8_t v1[18000];
int16_t v2[18000];
int32_t v4[18000];
int64_t v8[18000];
float f4[18000];
double f8[18000];
char bin[18000][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 900000 * 60);
int *lb = taosMemoryMalloc(18000 * sizeof(int));
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 3000*10);
char* is_null = taosMemoryMalloc(sizeof(char) * 18000);
char* no_null = taosMemoryMalloc(sizeof(char) * 18000);
for (int i = 0; i < 18000; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 30000; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[18000*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 18000;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 18000;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 18000;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 18000;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 18000;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 18000;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 18000;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 18000;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 18000;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 18000;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 54000000; ++i) {
v.ts[i] = tts + i;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into m0 values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
}
int id = 0;
for (int l = 0; l < 10; l++) {
for (int zz = 0; zz < 1; zz++) {
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
}
}
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
return 0;
}
//1table 200000 reocrds
int stmt_funcb_ssz1(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int b[30000];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 30000 * 3000);
int *lb = taosMemoryMalloc(30000 * sizeof(int));
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 3000*10);
char* no_null = taosMemoryMalloc(sizeof(int) * 200000);
for (int i = 0; i < 30000; ++i) {
lb[i] = 40;
no_null[i] = 0;
v.b[i] = (int8_t)(i % 2);
}
for (int i = 0; i < 30000; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[30000*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 30000;
params[i+1].buffer_type = TSDB_DATA_TYPE_INT;
params[i+1].buffer_length = sizeof(int);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = no_null;
params[i+1].num = 30000;
}
int64_t tts = 0;
for (int64_t i = 0; i < 90000000LL; ++i) {
v.ts[i] = tts + i;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? values(?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
}
int id = 0;
for (int l = 0; l < 10; l++) {
for (int zz = 0; zz < 300; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
}
}
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(no_null);
return 0;
}
//one table 60 records one time
int stmt_funcb_s1(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[60];
int8_t v1[60];
int16_t v2[60];
int32_t v4[60];
int64_t v8[60];
float f4[60];
double f8[60];
char bin[60][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 900000 * 60);
int *lb = taosMemoryMalloc(60 * sizeof(int));
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10);
char* is_null = taosMemoryMalloc(sizeof(char) * 60);
char* no_null = taosMemoryMalloc(sizeof(char) * 60);
for (int i = 0; i < 60; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 9000000; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[60*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 60;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 60;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 60;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 60;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 60;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 60;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 60;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 60;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 60;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 60;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 54000000; ++i) {
v.ts[i] = tts + i;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
}
int id = 0;
for (int l = 0; l < 3000; l++) {
for (int zz = 0; zz < 300; zz++) {
char buf[32];
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf);
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
exit(1);
}
++id;
}
}
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n", 3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*60));
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
return 0;
}
//300 tables 60 records single column bind
int stmt_funcb_sc1(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[60];
int8_t v1[60];
int16_t v2[60];
int32_t v4[60];
int64_t v8[60];
float f4[60];
double f8[60];
char bin[60][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 900000 * 60);
int *lb = taosMemoryMalloc(60 * sizeof(int));
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10);
char* is_null = taosMemoryMalloc(sizeof(char) * 60);
char* no_null = taosMemoryMalloc(sizeof(char) * 60);
for (int i = 0; i < 60; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 9000000; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[60*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 60;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 60;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 60;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 60;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 60;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 60;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 60;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 60;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 60;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 60;
}
int64_t tts = 1591060628000;
for (int i = 0; i < 54000000; ++i) {
v.ts[i] = tts + i;
}
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
}
}
int id = 0;
int id = 0;
for (int l = 0; l < 3000; l++) {
for (int zz = 0; zz < 1; zz++) {
for (int zz = 0; zz < 300; zz++) {
char buf[32];
char buf[32];
sprintf(buf, "m%d", zz);
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf
);
code = taos_stmt_set_tbname_tags(stmt, buf, NULL
);
if (code != 0){
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
printf("failed to execute taos_stmt_set_tbname_tags. code:0x%x\n", code);
}
return -1;
for (int col=0; col < 10; ++col) {
taos_stmt_bind_single_param_batch(stmt, params + id++, col);
}
}
taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_add_batch(stmt);
taos_stmt_add_batch(stmt);
}
}
...
@@ -3917,315 +2429,155 @@ int stmt_funcb_sc1(TAOS_STMT *stmt) {
...
@@ -3917,315 +2429,155 @@ int stmt_funcb_sc1(TAOS_STMT *stmt) {
printf("failed to execute insert statement.\n");
printf("failed to execute insert statement.\n");
exit(1);
exit(1);
}
}
}
++id;
unsigned long long endtime = taosGetTimestampUs();
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n",
3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*6
0));
printf("insert total %d records, used %u seconds, avg:%u useconds\n",
10, (endtime-starttime)/1000000UL, (endtime-starttime)/(1
0));
taosMemoryFree(v.ts);
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
return 0;
}
}
//1 tables 60 records single column bind
int stmt_funcb_sc2(TAOS_STMT *stmt) {
//1 tables 10 records
int stmt_funcb_autoctb_e4(TAOS_STMT *stmt) {
struct {
struct {
int64_t *ts;
int64_t *ts;
int8_t b[
6
0];
int8_t b[
1
0];
int8_t v1[
6
0];
int8_t v1[
1
0];
int16_t v2[
6
0];
int16_t v2[
1
0];
int32_t v4[
6
0];
int32_t v4[
1
0];
int64_t v8[
6
0];
int64_t v8[
1
0];
float f4[
6
0];
float f4[
1
0];
double f8[
6
0];
double f8[
1
0];
char bin[
6
0][40];
char bin[
1
0][40];
} v = {0};
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 900000 * 60);
v.ts = taosMemoryMalloc(sizeof(int64_t) * 1 * 10);
int *lb = taosMemoryMalloc(60 * sizeof(int));
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 900000*10);
char* is_null = taosMemoryMalloc(sizeof(char) * 60);
char* no_null = taosMemoryMalloc(sizeof(char) * 60);
for (int i = 0; i < 60; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
for (int i = 0; i < 9000000; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[60*i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = 60;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = 60;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = 60;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = 60;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = 60;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = 60;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = 60;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
params[i+7].buffer_length = sizeof(double);
params[i+7].buffer = v.f8;
params[i+7].length = NULL;
params[i+7].is_null = is_null;
params[i+7].num = 60;
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = 60;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = 60;
}
int *lb = taosMemoryMalloc(10 * sizeof(int));
int64_t tts = 1591060628000;
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
for (int i = 0; i < 54000000; ++i) {
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
v.ts[i] = tts + i;
}
unsigned long long starttime = taosGetTimestampUs();
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
char *sql = "insert into ?
using stb1 tags(?,?,?,?,?,?,?,?,?)
values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(stmt, sql, 0);
int code = taos_stmt_prepare(stmt, sql, 0);
if (code != 0){
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
}
int id = 0;
int id = 0;
for (int l = 0; l < 3000; l++) {
for (int zz = 0; zz < 1; zz++) {
for (int zz = 0; zz < 300; zz++) {
char buf[32];
char buf[32];
sprintf(buf, "m%d", zz);
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname(stmt, buf
);
code = taos_stmt_set_tbname_tags(stmt, buf, tags
);
if (code != 0){
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
printf("failed to execute taos_stmt_set_tbname_tags. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
}
for (int col=0; col < 10; ++col) {
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_bind_single_param_batch(stmt, params + id++, col);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
return -1;
}
}
taos_stmt_add_batch(stmt);
taos_stmt_add_batch(stmt);
}
if (taos_stmt_execute(stmt) != 0) {
if (taos_stmt_execute(stmt) != 0) {
printf("failed to execute insert statement.\n");
printf("failed to execute insert statement.\n");
exit(1);
exit(1);
}
}
}
++id;
}
unsigned long long endtime = taosGetTimestampUs();
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n",
3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*6
0));
printf("insert total %d records, used %u seconds, avg:%u useconds\n",
10, (endtime-starttime)/1000000UL, (endtime-starttime)/(1
0));
taosMemoryFree(v.ts);
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
return 0;
}
}
//10 tables [1...10] records single column bind
int stmt_funcb_sc3(TAOS_STMT *stmt) {
struct {
int64_t *ts;
int8_t b[60];
int8_t v1[60];
int16_t v2[60];
int32_t v4[60];
int64_t v8[60];
float f4[60];
double f8[60];
char bin[60][40];
} v = {0};
v.ts = taosMemoryMalloc(sizeof(int64_t) * 60);
int *lb = taosMemoryMalloc(60 * sizeof(int));
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 60*10);
char* is_null = taosMemoryMalloc(sizeof(char) * 60);
char* no_null = taosMemoryMalloc(sizeof(char) * 60);
for (int i = 0; i < 60; ++i) {
lb[i] = 40;
no_null[i] = 0;
is_null[i] = (i % 10 == 2) ? 1 : 0;
v.b[i] = (int8_t)(i % 2);
v.v1[i] = (int8_t)((i+1) % 2);
v.v2[i] = (int16_t)i;
v.v4[i] = (int32_t)(i+1);
v.v8[i] = (int64_t)(i+2);
v.f4[i] = (float)(i+3);
v.f8[i] = (double)(i+4);
memset(v.bin[i], '0'+i%10, 40);
}
int g = 0;
for (int i = 0; i < 600; i+=10) {
params[i+0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP;
params[i+0].buffer_length = sizeof(int64_t);
params[i+0].buffer = &v.ts[i/10];
params[i+0].length = NULL;
params[i+0].is_null = no_null;
params[i+0].num = g%10+1;
params[i+1].buffer_type = TSDB_DATA_TYPE_BOOL;
params[i+1].buffer_length = sizeof(int8_t);
params[i+1].buffer = v.b;
params[i+1].length = NULL;
params[i+1].is_null = is_null;
params[i+1].num = g%10+1;
params[i+2].buffer_type = TSDB_DATA_TYPE_TINYINT;
params[i+2].buffer_length = sizeof(int8_t);
params[i+2].buffer = v.v1;
params[i+2].length = NULL;
params[i+2].is_null = is_null;
params[i+2].num = g%10+1;
params[i+3].buffer_type = TSDB_DATA_TYPE_SMALLINT;
params[i+3].buffer_length = sizeof(int16_t);
params[i+3].buffer = v.v2;
params[i+3].length = NULL;
params[i+3].is_null = is_null;
params[i+3].num = g%10+1;
params[i+4].buffer_type = TSDB_DATA_TYPE_INT;
params[i+4].buffer_length = sizeof(int32_t);
params[i+4].buffer = v.v4;
params[i+4].length = NULL;
params[i+4].is_null = is_null;
params[i+4].num = g%10+1;
params[i+5].buffer_type = TSDB_DATA_TYPE_BIGINT;
params[i+5].buffer_length = sizeof(int64_t);
params[i+5].buffer = v.v8;
params[i+5].length = NULL;
params[i+5].is_null = is_null;
params[i+5].num = g%10+1;
params[i+6].buffer_type = TSDB_DATA_TYPE_FLOAT;
params[i+6].buffer_length = sizeof(float);
params[i+6].buffer = v.f4;
params[i+6].length = NULL;
params[i+6].is_null = is_null;
params[i+6].num = g%10+1;
params[i+7].buffer_type = TSDB_DATA_TYPE_DOUBLE;
//1 tables 10 records
params[i+7].buffer_length = sizeof(double);
int stmt_funcb_autoctb_e5(TAOS_STMT *stmt) {
params[i+7].buffer = v.f8;
struct {
params[i+7].length = NULL;
int64_t *ts;
params[i+7].is_null = is_null;
int8_t b[10];
params[i+7].num = g%10+1;
int8_t v1[10];
int16_t v2[10];
int32_t v4[10];
int64_t v8[10];
float f4[10];
double f8[10];
char bin[10][40];
} v = {0};
params[i+8].buffer_type = TSDB_DATA_TYPE_BINARY;
v.ts = taosMemoryMalloc(sizeof(int64_t) * 1 * 10);
params[i+8].buffer_length = 40;
params[i+8].buffer = v.bin;
params[i+8].length = lb;
params[i+8].is_null = is_null;
params[i+8].num = g%10+1;
params[i+9].buffer_type = TSDB_DATA_TYPE_BINARY;
int *lb = taosMemoryMalloc(10 * sizeof(int));
params[i+9].buffer_length = 40;
params[i+9].buffer = v.bin;
params[i+9].length = lb;
params[i+9].is_null = is_null;
params[i+9].num = g%10+1;
++g;
}
int64_t tts = 1591060628000;
TAOS_BIND *tags = taosMemoryCalloc(1, sizeof(TAOS_BIND) * 9 * 1);
for (int i = 0; i < 60; ++i) {
TAOS_MULTI_BIND *params = taosMemoryCalloc(1, sizeof(TAOS_MULTI_BIND) * 1*10);
v.ts[i] = tts + i;
}
unsigned long long starttime = taosGetTimestampUs();
unsigned long long starttime = taosGetTimestampUs();
char *sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)";
char *sql = "insert into ?
using stb1 tags(?,?,?,?,?,?,?,?,?)
values(?,?,?,?,?,?,?,?,?,?)";
int code = taos_stmt_prepare(
stmt
, sql, 0);
int code = taos_stmt_prepare(
NULL
, sql, 0);
if (code != 0){
if (code != 0){
printf("failed to execute taos_stmt_prepare. code:0x%x\n", code);
printf("failed to execute taos_stmt_prepare. code:%s\n", taos_stmt_errstr(NULL));
return -1;
}
}
int id = 0;
int id = 0;
for (int zz = 0; zz < 1
0
; zz++) {
for (int zz = 0; zz < 1; zz++) {
char buf[32];
char buf[32];
sprintf(buf, "m%d", zz);
sprintf(buf, "m%d", zz);
code = taos_stmt_set_tbname
(stmt, buf
);
code = taos_stmt_set_tbname
_tags(stmt, buf, tags
);
if (code != 0){
if (code != 0){
printf("failed to execute taos_stmt_set_tbname. code:0x%x\n", code);
printf("failed to execute taos_stmt_set_tbname_tags. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
exit(1);
}
}
for (int col=0; col < 10; ++col) {
code = taos_stmt_bind_param_batch(stmt, params + id * 10);
taos_stmt_bind_single_param_batch(stmt, params + id++, col);
if (code != 0) {
printf("failed to execute taos_stmt_bind_param_batch. error:%s\n", taos_stmt_errstr(stmt));
return -1;
}
}
taos_stmt_add_batch(stmt);
taos_stmt_add_batch(stmt);
...
@@ -4236,17 +2588,21 @@ int stmt_funcb_sc3(TAOS_STMT *stmt) {
...
@@ -4236,17 +2588,21 @@ int stmt_funcb_sc3(TAOS_STMT *stmt) {
exit(1);
exit(1);
}
}
++id;
unsigned long long endtime = taosGetTimestampUs();
unsigned long long endtime = taosGetTimestampUs();
printf("insert total %d records, used %u seconds, avg:%u useconds\n",
3000*300*60, (endtime-starttime)/1000000UL, (endtime-starttime)/(3000*300*6
0));
printf("insert total %d records, used %u seconds, avg:%u useconds\n",
10, (endtime-starttime)/1000000UL, (endtime-starttime)/(1
0));
taosMemoryFree(v.ts);
taosMemoryFree(v.ts);
taosMemoryFree(lb);
taosMemoryFree(lb);
taosMemoryFree(params);
taosMemoryFree(params);
taosMemoryFree(is_null);
taosMemoryFree(is_null);
taosMemoryFree(no_null);
taosMemoryFree(no_null);
taosMemoryFree(tags);
return 0;
return 0;
}
}
#endif
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录