Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/hzcheng_3.0
This commit is contained in:
commit
1be190531e
|
@ -48,6 +48,8 @@ pysim/
|
|||
*.out
|
||||
*DS_Store
|
||||
tests/script/api/batchprepare
|
||||
taosadapter
|
||||
taosadapter-debug
|
||||
|
||||
# Doxygen Generated files
|
||||
html/
|
||||
|
|
|
@ -13,12 +13,3 @@
|
|||
[submodule "examples/rust"]
|
||||
path = examples/rust
|
||||
url = https://github.com/songtianyi/tdengine-rust-bindings.git
|
||||
[submodule "tools/taos-tools"]
|
||||
path = tools/taos-tools
|
||||
url = https://github.com/taosdata/taos-tools
|
||||
[submodule "tools/taosadapter"]
|
||||
path = tools/taosadapter
|
||||
url = https://github.com/taosdata/taosadapter.git
|
||||
[submodule "tools/taosws-rs"]
|
||||
path = tools/taosws-rs
|
||||
url = https://github.com/taosdata/taosws-rs
|
||||
|
|
13
Jenkinsfile2
13
Jenkinsfile2
|
@ -113,6 +113,12 @@ def pre_test(){
|
|||
echo "unmatched reposiotry ${CHANGE_URL}"
|
||||
'''
|
||||
}
|
||||
sh '''
|
||||
cd ${WKC}
|
||||
git rm --cached tools/taos-tools 2>/dev/null || :
|
||||
git rm --cached tools/taosadapter 2>/dev/null || :
|
||||
git rm --cached tools/taosws-rs 2>/dev/null || :
|
||||
'''
|
||||
sh '''
|
||||
cd ${WKC}
|
||||
git submodule update --init --recursive
|
||||
|
@ -258,6 +264,13 @@ def pre_test_win(){
|
|||
git branch
|
||||
git log -5
|
||||
'''
|
||||
bat '''
|
||||
cd %WIN_COMMUNITY_ROOT%
|
||||
git rm --cached tools/taos-tools 2>nul
|
||||
git rm --cached tools/taosadapter 2>nul
|
||||
git rm --cached tools/taosws-rs 2>nul
|
||||
exit 0
|
||||
'''
|
||||
bat '''
|
||||
cd %WIN_COMMUNITY_ROOT%
|
||||
git submodule update --init --recursive
|
||||
|
|
|
@ -40,7 +40,7 @@ database_option: {
|
|||
|
||||
### 参数说明
|
||||
|
||||
- buffer: 一个 VNODE 写入内存池大小,单位为 MB,默认为 96,最小为 3,最大为 16384。
|
||||
- BUFFER: 一个 VNODE 写入内存池大小,单位为 MB,默认为 96,最小为 3,最大为 16384。
|
||||
- CACHEMODEL:表示是否在内存中缓存子表的最近数据。默认为 none。
|
||||
- none:表示不缓存。
|
||||
- last_row:表示缓存子表最近一行数据。这将显著改善 LAST_ROW 函数的性能表现。
|
||||
|
@ -52,7 +52,7 @@ database_option: {
|
|||
- 1:表示一阶段压缩。
|
||||
- 2:表示两阶段压缩。
|
||||
- DURATION:数据文件存储数据的时间跨度。可以使用加单位的表示形式,如 DURATION 100h、DURATION 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。不加时间单位时默认单位为天,如 DURATION 50 表示 50 天。
|
||||
- FSYNC:当 WAL 参数设置为 2 时,落盘的周期。默认为 3000,单位毫秒。最小为 0,表示每次写入立即落盘;最大为 180000,即三分钟。
|
||||
- WAL_FSYNC_PERIOD:当 WAL 参数设置为 2 时,落盘的周期。默认为 3000,单位毫秒。最小为 0,表示每次写入立即落盘;最大为 180000,即三分钟。
|
||||
- MAXROWS:文件块中记录的最大条数,默认为 4096 条。
|
||||
- MINROWS:文件块中记录的最小条数,默认为 100 条。
|
||||
- KEEP:表示数据文件保存的天数,缺省值为 3650,取值范围 [1, 365000],且必须大于或等于 DURATION 参数值。数据库会自动删除保存时间超过 KEEP 值的数据。KEEP 可以使用加单位的表示形式,如 KEEP 100h、KEEP 10d 等,支持 m(分钟)、h(小时)和 d(天)三个单位。也可以不写单位,如 KEEP 50,此时默认单位为天。
|
||||
|
@ -64,7 +64,7 @@ database_option: {
|
|||
- STRICT:表示数据同步的一致性要求,默认为 off。
|
||||
- on 表示强一致,即运行标准的 raft 协议,半数提交返回成功。
|
||||
- off 表示弱一致,本地提交即返回成功。
|
||||
- WAL:WAL 级别,默认为 1。
|
||||
- WAL_LEVEL:WAL 级别,默认为 1。
|
||||
- 1:写 WAL,但不执行 fsync。
|
||||
- 2:写 WAL,而且执行 fsync。
|
||||
- VGROUPS:数据库中初始 vgroup 的数目。
|
||||
|
|
|
@ -80,8 +80,8 @@ TODO
|
|||
| 9 | buffer | INT | 每个 vnode 写缓存的内存块大小,单位 MB |
|
||||
| 10 | minrows | INT | 文件块中记录的最大条数 |
|
||||
| 11 | maxrows | INT | 文件块中记录的最小条数 |
|
||||
| 12 | wallevel | INT | WAL 级别 |
|
||||
| 13 | fsync | INT | 数据落盘周期 |
|
||||
| 12 | wal_level | INT | WAL 级别 |
|
||||
| 13 | walfsync_period | INT | 数据落盘周期 |
|
||||
| 14 | comp | INT | 数据压缩方式 |
|
||||
| 15 | precision | BINARY(2) | 时间分辨率 |
|
||||
| 16 | status | BINARY(10) | 数据库状态 |
|
||||
|
|
|
@ -1 +1 @@
|
|||
label: 参考指南
|
||||
label: 参考手册
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
title: 参考指南
|
||||
title: 参考手册
|
||||
---
|
||||
|
||||
参考指南是对 TDengine 本身、 TDengine 各语言连接器及自带的工具最详细的介绍。
|
||||
参考手册是对 TDengine 本身、 TDengine 各语言连接器及自带的工具最详细的介绍。
|
||||
|
||||
```mdx-code-block
|
||||
import DocCardList from '@theme/DocCardList';
|
||||
|
|
|
@ -3044,12 +3044,41 @@ typedef struct SDeleteRes {
|
|||
int64_t skey;
|
||||
int64_t ekey;
|
||||
int64_t affectedRows;
|
||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
||||
char tableFName[TSDB_TABLE_NAME_LEN];
|
||||
char tsColName[TSDB_COL_NAME_LEN];
|
||||
} SDeleteRes;
|
||||
|
||||
int32_t tEncodeDeleteRes(SEncoder* pCoder, const SDeleteRes* pRes);
|
||||
int32_t tDecodeDeleteRes(SDecoder* pCoder, SDeleteRes* pRes);
|
||||
|
||||
typedef struct {
|
||||
int32_t msgType;
|
||||
int32_t msgLen;
|
||||
void* msg;
|
||||
} SBatchMsg;
|
||||
|
||||
typedef struct {
|
||||
SMsgHead header;
|
||||
int32_t msgNum;
|
||||
SBatchMsg msg[];
|
||||
} SBatchReq;
|
||||
|
||||
typedef struct {
|
||||
int32_t reqType;
|
||||
int32_t msgLen;
|
||||
int32_t rspCode;
|
||||
void* msg;
|
||||
} SBatchRsp;
|
||||
|
||||
static FORCE_INLINE void tFreeSBatchRsp(void *p) {
|
||||
if (NULL == p) {
|
||||
return;
|
||||
}
|
||||
|
||||
SBatchRsp* pRsp = (SBatchRsp*)p;
|
||||
taosMemoryFree(pRsp->msg);
|
||||
}
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -136,6 +136,7 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_INDEX, "drop-index", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_INDEX, "get-index", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_GET_TABLE_INDEX, "get-table-index", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_BATCH_META, "batch-meta", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_TABLE_CFG, "table-cfg", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TOPIC, "create-topic", SMCreateTopicReq, SMCreateTopicRsp)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_TOPIC, "alter-topic", NULL, NULL)
|
||||
|
@ -180,6 +181,7 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_VND_TABLE_META, "vnode-table-meta", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TABLES_META, "vnode-tables-meta", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_TABLE_CFG, "vnode-table-cfg", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_BATCH_META, "vnode-batch-meta", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_CREATE_STB, "vnode-create-stb", SVCreateStbReq, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_ALTER_STB, "vnode-alter-stb", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", SVDropStbReq, NULL)
|
||||
|
|
|
@ -38,7 +38,8 @@ typedef struct SDeleterRes {
|
|||
int64_t skey;
|
||||
int64_t ekey;
|
||||
int64_t affectedRows;
|
||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
char tsColName[TSDB_COL_NAME_LEN];
|
||||
} SDeleterRes;
|
||||
|
||||
typedef struct SDeleterParam {
|
||||
|
|
|
@ -64,17 +64,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers);
|
|||
* @param SReadHandle
|
||||
* @return
|
||||
*/
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols,
|
||||
SSchemaWrapper** pSchema);
|
||||
|
||||
/**
|
||||
* Set the input data block for the stream scan.
|
||||
* @param tinfo
|
||||
* @param input
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool assignUid);
|
||||
qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, SSchemaWrapper** pSchema);
|
||||
|
||||
/**
|
||||
* Set multiple input data blocks for the stream scan.
|
||||
|
@ -84,7 +74,7 @@ int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool
|
|||
* @param type
|
||||
* @return
|
||||
*/
|
||||
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type, bool assignUid);
|
||||
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type);
|
||||
|
||||
/**
|
||||
* Update the table id list, add or remove.
|
||||
|
|
|
@ -209,6 +209,7 @@ typedef enum EFuncDataRequired {
|
|||
} EFuncDataRequired;
|
||||
|
||||
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||
EFuncDataRequired fmFuncDynDataRequired(int32_t funcId, void* pRes, STimeWindow* pTimeWindow);
|
||||
|
||||
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||
int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet);
|
||||
|
|
|
@ -151,7 +151,8 @@ typedef struct SVnodeModifyLogicNode {
|
|||
uint64_t tableId;
|
||||
uint64_t stableId;
|
||||
int8_t tableType; // table type
|
||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
char tsColName[TSDB_COL_NAME_LEN];
|
||||
STimeWindow deleteTimeRange;
|
||||
SVgroupsInfo* pVgroupList;
|
||||
SNodeList* pInsertCols;
|
||||
|
@ -494,7 +495,7 @@ typedef struct SQueryInserterNode {
|
|||
uint64_t tableId;
|
||||
uint64_t stableId;
|
||||
int8_t tableType; // table type
|
||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
||||
char tableName[TSDB_TABLE_NAME_LEN];
|
||||
int32_t vgId;
|
||||
SEpSet epSet;
|
||||
} SQueryInserterNode;
|
||||
|
@ -503,7 +504,7 @@ typedef struct SDataDeleterNode {
|
|||
SDataSinkNode sink;
|
||||
uint64_t tableId;
|
||||
int8_t tableType; // table type
|
||||
char tableFName[TSDB_TABLE_FNAME_LEN];
|
||||
char tableFName[TSDB_TABLE_NAME_LEN];
|
||||
char tsColName[TSDB_COL_NAME_LEN];
|
||||
STimeWindow deleteTimeRange;
|
||||
SNode* pAffectedRows;
|
||||
|
|
|
@ -270,7 +270,7 @@ typedef struct SStreamTask {
|
|||
int64_t startVer;
|
||||
int64_t checkpointVer;
|
||||
int64_t processedVer;
|
||||
int32_t numOfVgroups;
|
||||
// int32_t numOfVgroups;
|
||||
|
||||
// children info
|
||||
SArray* childEpInfo; // SArray<SStreamChildEpInfo*>
|
||||
|
|
|
@ -2823,35 +2823,35 @@ end:
|
|||
|
||||
// delete from db.tabl where .. -> delete from tabl where ..
|
||||
// delete from db .tabl where .. -> delete from tabl where ..
|
||||
static void getTbName(char *sql){
|
||||
char *ch = sql;
|
||||
|
||||
bool inBackQuote = false;
|
||||
int8_t dotIndex = 0;
|
||||
while(*ch != '\0'){
|
||||
if(!inBackQuote && *ch == '`'){
|
||||
inBackQuote = true;
|
||||
ch++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(inBackQuote && *ch == '`'){
|
||||
inBackQuote = false;
|
||||
ch++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!inBackQuote && *ch == '.'){
|
||||
dotIndex ++;
|
||||
if(dotIndex == 2){
|
||||
memmove(sql, ch + 1, strlen(ch + 1) + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ch++;
|
||||
}
|
||||
}
|
||||
//static void getTbName(char *sql){
|
||||
// char *ch = sql;
|
||||
//
|
||||
// bool inBackQuote = false;
|
||||
// int8_t dotIndex = 0;
|
||||
// while(*ch != '\0'){
|
||||
// if(!inBackQuote && *ch == '`'){
|
||||
// inBackQuote = true;
|
||||
// ch++;
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if(inBackQuote && *ch == '`'){
|
||||
// inBackQuote = false;
|
||||
// ch++;
|
||||
//
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if(!inBackQuote && *ch == '.'){
|
||||
// dotIndex ++;
|
||||
// if(dotIndex == 2){
|
||||
// memmove(sql, ch + 1, strlen(ch + 1) + 1);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// ch++;
|
||||
// }
|
||||
//}
|
||||
|
||||
static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
|
||||
SDeleteRes req = {0};
|
||||
|
@ -2867,9 +2867,9 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) {
|
|||
goto end;
|
||||
}
|
||||
|
||||
getTbName(req.tableFName);
|
||||
// getTbName(req.tableFName);
|
||||
char sql[256] = {0};
|
||||
sprintf(sql, "delete from `%s` where `%s` >= %" PRId64" and `%s` <= %" PRId64, req.tableFName, "ts", req.skey, "ts", req.ekey);
|
||||
sprintf(sql, "delete from `%s` where `%s` >= %" PRId64" and `%s` <= %" PRId64, req.tableFName, req.tsColName, req.skey, req.tsColName, req.ekey);
|
||||
printf("delete sql:%s\n", sql);
|
||||
|
||||
TAOS_RES* res = taos_query(taos, sql);
|
||||
|
|
|
@ -5682,6 +5682,7 @@ int32_t tEncodeDeleteRes(SEncoder *pCoder, const SDeleteRes *pRes) {
|
|||
if (tEncodeI64v(pCoder, pRes->affectedRows) < 0) return -1;
|
||||
|
||||
if (tEncodeCStr(pCoder, pRes->tableFName) < 0) return -1;
|
||||
if (tEncodeCStr(pCoder, pRes->tsColName) < 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -5700,6 +5701,7 @@ int32_t tDecodeDeleteRes(SDecoder *pCoder, SDeleteRes *pRes) {
|
|||
if (tDecodeI64v(pCoder, &pRes->affectedRows) < 0) return -1;
|
||||
|
||||
if (tDecodeCStrTo(pCoder, pRes->tableFName) < 0) return -1;
|
||||
if (tDecodeCStrTo(pCoder, pRes->tsColName) < 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
int32_t tEncodeSMqDataRsp(SEncoder *pEncoder, const SMqDataRsp *pRsp) {
|
||||
|
|
|
@ -184,6 +184,7 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_BATCH_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_CFG, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -343,6 +343,7 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_VND_UPDATE_TAG_VAL, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_CFG, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_BATCH_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -89,7 +89,7 @@ static void vmProcessStreamQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo);
|
||||
if (code != 0) {
|
||||
if (terrno != 0) code = terrno;
|
||||
dGError("vgId:%d, msg:%p failed to stream since %s", pVnode->vgId, pMsg, terrstr());
|
||||
dGError("vgId:%d, msg:%p failed to process stream since %s", pVnode->vgId, pMsg, terrstr());
|
||||
vmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
aux_source_directory(src MNODE_SRC)
|
||||
IF (TD_PRIVILEGE)
|
||||
ADD_DEFINITIONS(-D_PRIVILEGE)
|
||||
ENDIF ()
|
||||
IF (TD_PRIVILEGE)
|
||||
LIST(APPEND MNODE_SRC ${TD_ENTERPRISE_DIR}/src/plugins/privilege/src/privilege.c)
|
||||
ENDIF ()
|
||||
|
||||
add_library(mnode STATIC ${MNODE_SRC})
|
||||
target_include_directories(
|
||||
mnode
|
||||
|
@ -8,11 +15,8 @@ target_include_directories(
|
|||
target_link_libraries(
|
||||
mnode scheduler sdb wal transport cjson sync monitor executor qworker stream parser
|
||||
)
|
||||
|
||||
IF (TD_GRANT)
|
||||
TARGET_LINK_LIBRARIES(mnode grant)
|
||||
ENDIF ()
|
||||
IF (TD_GRANT)
|
||||
ADD_DEFINITIONS(-D_GRANT)
|
||||
ENDIF ()
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType
|
|||
int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname);
|
||||
int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname);
|
||||
int32_t mndCheckAlterUserPrivilege(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter);
|
||||
int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define _TD_MND_USER_H_
|
||||
|
||||
#include "mndInt.h"
|
||||
#include "thash.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -28,9 +29,10 @@ SUserObj *mndAcquireUser(SMnode *pMnode, const char *userName);
|
|||
void mndReleaseUser(SMnode *pMnode, SUserObj *pUser);
|
||||
|
||||
// for trans test
|
||||
SSdbRaw *mndUserActionEncode(SUserObj *pUser);
|
||||
int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp,
|
||||
int32_t *pRspLen);
|
||||
SSdbRaw *mndUserActionEncode(SUserObj *pUser);
|
||||
SHashObj *mndDupDbHash(SHashObj *pOld);
|
||||
int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp,
|
||||
int32_t *pRspLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,177 +18,20 @@
|
|||
#include "mndDb.h"
|
||||
#include "mndUser.h"
|
||||
|
||||
#ifndef _PRIVILEGE
|
||||
int32_t mndInitPrivilege(SMnode *pMnode) { return 0; }
|
||||
|
||||
void mndCleanupPrivilege(SMnode *pMnode) {}
|
||||
|
||||
int32_t mndCheckOperPrivilege(SMnode *pMnode, const char *user, EOperType operType) {
|
||||
int32_t code = 0;
|
||||
SUserObj *pUser = mndAcquireUser(pMnode, user);
|
||||
|
||||
if (pUser == NULL) {
|
||||
terrno = TSDB_CODE_MND_NO_USER_FROM_CONN;
|
||||
code = -1;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (pUser->superUser) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (!pUser->enable) {
|
||||
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||
code = -1;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
switch (operType) {
|
||||
case MND_OPER_CONNECT:
|
||||
case MND_OPER_CREATE_FUNC:
|
||||
case MND_OPER_DROP_FUNC:
|
||||
case MND_OPER_SHOW_VARIBALES:
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||
code = -1;
|
||||
}
|
||||
|
||||
_OVER:
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t mndCheckAlterUserPrivilege(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) {
|
||||
if (pUser->superUser && pAlter->alterType != TSDB_ALTER_USER_PASSWD) {
|
||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pOperUser->superUser) return 0;
|
||||
|
||||
if (!pOperUser->enable) {
|
||||
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pAlter->alterType == TSDB_ALTER_USER_PASSWD) {
|
||||
if (strcmp(pUser->user, pOperUser->user) == 0) {
|
||||
if (pOperUser->sysInfo) return 0;
|
||||
}
|
||||
}
|
||||
|
||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname) {
|
||||
int32_t code = 0;
|
||||
SUserObj *pUser = mndAcquireUser(pMnode, user);
|
||||
|
||||
if (pUser == NULL) {
|
||||
code = -1;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (pUser->superUser) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (!pUser->enable) {
|
||||
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||
code = -1;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (pUser->sysInfo) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
switch (showType) {
|
||||
case TSDB_MGMT_TABLE_DB:
|
||||
case TSDB_MGMT_TABLE_STB:
|
||||
case TSDB_MGMT_TABLE_INDEX:
|
||||
case TSDB_MGMT_TABLE_STREAMS:
|
||||
case TSDB_MGMT_TABLE_CONSUMERS:
|
||||
case TSDB_MGMT_TABLE_TOPICS:
|
||||
case TSDB_MGMT_TABLE_SUBSCRIPTIONS:
|
||||
case TSDB_MGMT_TABLE_FUNC:
|
||||
case TSDB_MGMT_TABLE_QUERIES:
|
||||
case TSDB_MGMT_TABLE_CONNS:
|
||||
case TSDB_MGMT_TABLE_APPS:
|
||||
case TSDB_MGMT_TABLE_TRANS:
|
||||
code = 0;
|
||||
break;
|
||||
default:
|
||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||
code = -1;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (showType == TSDB_MGMT_TABLE_STB || showType == TSDB_MGMT_TABLE_VGROUP || showType == TSDB_MGMT_TABLE_INDEX) {
|
||||
code = mndCheckDbPrivilegeByName(pMnode, user, MND_OPER_READ_OR_WRITE_DB, dbname);
|
||||
}
|
||||
|
||||
_OVER:
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb) {
|
||||
int32_t code = 0;
|
||||
SUserObj *pUser = mndAcquireUser(pMnode, user);
|
||||
|
||||
if (pUser == NULL) {
|
||||
code = -1;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (pUser->superUser) goto _OVER;
|
||||
|
||||
if (!pUser->enable) {
|
||||
terrno = TSDB_CODE_MND_USER_DISABLED;
|
||||
code = -1;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (operType == MND_OPER_CREATE_DB) {
|
||||
if (pUser->sysInfo) goto _OVER;
|
||||
}
|
||||
|
||||
if (operType == MND_OPER_ALTER_DB || operType == MND_OPER_DROP_DB || operType == MND_OPER_COMPACT_DB ||
|
||||
operType == MND_OPER_TRIM_DB) {
|
||||
if (strcmp(pUser->user, pDb->createUser) == 0 && pUser->sysInfo) goto _OVER;
|
||||
}
|
||||
|
||||
if (operType == MND_OPER_USE_DB || operType == MND_OPER_READ_OR_WRITE_DB) {
|
||||
if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER;
|
||||
if (taosHashGet(pUser->readDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||
if (taosHashGet(pUser->writeDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||
}
|
||||
|
||||
if (operType == MND_OPER_WRITE_DB) {
|
||||
if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER;
|
||||
if (taosHashGet(pUser->writeDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||
}
|
||||
|
||||
if (operType == MND_OPER_READ_DB) {
|
||||
if (strcmp(pUser->user, pDb->createUser) == 0) goto _OVER;
|
||||
if (taosHashGet(pUser->readDbs, pDb->name, strlen(pDb->name) + 1) != NULL) goto _OVER;
|
||||
}
|
||||
|
||||
terrno = TSDB_CODE_MND_NO_RIGHTS;
|
||||
code = -1;
|
||||
|
||||
_OVER:
|
||||
mndReleaseUser(pMnode, pUser);
|
||||
return code;
|
||||
}
|
||||
|
||||
void mndCleanupPrivilege(SMnode *pMnode) {}
|
||||
int32_t mndCheckOperPrivilege(SMnode *pMnode, const char *user, EOperType operType) { return 0; }
|
||||
int32_t mndCheckAlterUserPrivilege(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter) { return 0; }
|
||||
int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname) { return 0; }
|
||||
int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb) { return 0; }
|
||||
int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname) {
|
||||
SDbObj *pDb = mndAcquireDb(pMnode, dbname);
|
||||
if (pDb == NULL) return -1;
|
||||
|
||||
int32_t code = mndCheckDbPrivilege(pMnode, user, operType, pDb);
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
return code;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp) {
|
||||
memcpy(pRsp->user, pUser->user, TSDB_USER_LEN);
|
||||
pRsp->superAuth = 1;
|
||||
pRsp->version = pUser->authVersion;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -63,6 +63,106 @@ int32_t mndProcessQueryMsg(SRpcMsg *pMsg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
||||
int32_t code = 0;
|
||||
int32_t offset = 0;
|
||||
int32_t rspSize = 0;
|
||||
SBatchReq *batchReq = (SBatchReq*)pMsg->pCont;
|
||||
int32_t msgNum = ntohl(batchReq->msgNum);
|
||||
offset += sizeof(SBatchReq);
|
||||
SBatchMsg req = {0};
|
||||
SBatchRsp rsp = {0};
|
||||
SRpcMsg reqMsg = *pMsg;
|
||||
SRpcMsg rspMsg = {0};
|
||||
void* pRsp = NULL;
|
||||
SMnode *pMnode = pMsg->info.node;
|
||||
|
||||
SArray* batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp));
|
||||
if (NULL == batchRsp) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
req.msgType = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgType);
|
||||
|
||||
req.msgLen = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgLen);
|
||||
|
||||
req.msg = (char*)pMsg->pCont + offset;
|
||||
offset += req.msgLen;
|
||||
|
||||
reqMsg.msgType = req.msgType;
|
||||
reqMsg.pCont = req.msg;
|
||||
reqMsg.contLen = req.msgLen;
|
||||
reqMsg.info.rsp = NULL;
|
||||
reqMsg.info.rspLen = 0;
|
||||
|
||||
MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(req.msgType)];
|
||||
if (fp == NULL) {
|
||||
mError("msg:%p, failed to get msg handle, app:%p type:%s", pMsg, pMsg->info.ahandle, TMSG_INFO(pMsg->msgType));
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((*fp)(&reqMsg)) {
|
||||
rsp.rspCode = terrno;
|
||||
} else {
|
||||
rsp.rspCode = 0;
|
||||
}
|
||||
rsp.reqType = reqMsg.msgType;
|
||||
rsp.msgLen = reqMsg.info.rspLen;
|
||||
rsp.msg = reqMsg.info.rsp;
|
||||
|
||||
taosArrayPush(batchRsp, &rsp);
|
||||
|
||||
rspSize += sizeof(rsp) + rsp.msgLen - POINTER_BYTES;
|
||||
}
|
||||
|
||||
rspSize += sizeof(int32_t);
|
||||
offset = 0;
|
||||
|
||||
pRsp = rpcMallocCont(rspSize);
|
||||
if (pRsp == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(msgNum);
|
||||
offset += sizeof(msgNum);
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
SBatchRsp *p = taosArrayGet(batchRsp, i);
|
||||
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(p->reqType);
|
||||
offset += sizeof(p->reqType);
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(p->msgLen);
|
||||
offset += sizeof(p->msgLen);
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(p->rspCode);
|
||||
offset += sizeof(p->rspCode);
|
||||
memcpy((char*)pRsp + offset, p->msg, p->msgLen);
|
||||
offset += p->msgLen;
|
||||
|
||||
rpcFreeCont(p->msg);
|
||||
}
|
||||
|
||||
taosArrayDestroy(batchRsp);
|
||||
batchRsp = NULL;
|
||||
|
||||
_exit:
|
||||
|
||||
pMsg->info.rsp = pRsp;
|
||||
pMsg->info.rspLen = rspSize;
|
||||
|
||||
if (code) {
|
||||
mError("mnd get batch meta failed cause of %s", tstrerror(code));
|
||||
}
|
||||
|
||||
taosArrayDestroyEx(batchRsp, tFreeSBatchRsp);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t mndInitQuery(SMnode *pMnode) {
|
||||
if (qWorkerInit(NODE_TYPE_MNODE, MNODE_HANDLE, NULL, (void **)&pMnode->pQuery, &pMnode->msgCb) != 0) {
|
||||
mError("failed to init qworker in mnode since %s", terrstr());
|
||||
|
@ -76,6 +176,7 @@ int32_t mndInitQuery(SMnode *pMnode) {
|
|||
mndSetMsgHandle(pMnode, TDMT_SCH_MERGE_FETCH, mndProcessQueryMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_SCH_DROP_TASK, mndProcessQueryMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_SCH_QUERY_HEARTBEAT, mndProcessQueryMsg);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_BATCH_META, mndProcessBatchMetaMsg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -391,10 +391,12 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
|||
// exec
|
||||
pInnerTask->execType = TASK_EXEC__PIPE;
|
||||
|
||||
#if 0
|
||||
SDbObj* pSourceDb = mndAcquireDb(pMnode, pStream->sourceDb);
|
||||
ASSERT(pDbObj != NULL);
|
||||
sdbRelease(pSdb, pSourceDb);
|
||||
pInnerTask->numOfVgroups = pSourceDb->cfg.numOfVgroups;
|
||||
#endif
|
||||
|
||||
if (tsSchedStreamToSnode) {
|
||||
SSnodeObj* pSnode = mndSchedFetchOneSnode(pMnode);
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndUser.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndDb.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndTrans.h"
|
||||
#include "tbase64.h"
|
||||
|
@ -408,7 +408,7 @@ static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpc
|
|||
return 0;
|
||||
}
|
||||
|
||||
static SHashObj *mndDupDbHash(SHashObj *pOld) {
|
||||
SHashObj *mndDupDbHash(SHashObj *pOld) {
|
||||
SHashObj *pNew =
|
||||
taosHashInit(taosHashGetSize(pOld), taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
if (pNew == NULL) {
|
||||
|
@ -662,38 +662,6 @@ _OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp) {
|
||||
memcpy(pRsp->user, pUser->user, TSDB_USER_LEN);
|
||||
pRsp->superAuth = pUser->superUser;
|
||||
pRsp->version = pUser->authVersion;
|
||||
taosRLockLatch(&pUser->lock);
|
||||
pRsp->readDbs = mndDupDbHash(pUser->readDbs);
|
||||
pRsp->writeDbs = mndDupDbHash(pUser->writeDbs);
|
||||
taosRUnLockLatch(&pUser->lock);
|
||||
pRsp->createdDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK);
|
||||
if (NULL == pRsp->createdDbs) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
while (1) {
|
||||
SDbObj *pDb = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_DB, pIter, (void **)&pDb);
|
||||
if (pIter == NULL) break;
|
||||
|
||||
if (strcmp(pDb->createUser, pUser->user) == 0) {
|
||||
int32_t len = strlen(pDb->name) + 1;
|
||||
taosHashPut(pRsp->createdDbs, pDb->name, len, pDb->name, len);
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pDb);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t mndProcessGetUserAuthReq(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
int32_t code = -1;
|
||||
|
|
|
@ -78,8 +78,9 @@ void vnodeBufPoolReset(SVBufPool* pPool);
|
|||
// vnodeQuery.c
|
||||
int32_t vnodeQueryOpen(SVnode* pVnode);
|
||||
void vnodeQueryClose(SVnode* pVnode);
|
||||
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg);
|
||||
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg);
|
||||
int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||
int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg, bool direct);
|
||||
int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg);
|
||||
|
||||
// vnodeCommit.c
|
||||
int32_t vnodeBegin(SVnode* pVnode);
|
||||
|
|
|
@ -611,8 +611,8 @@ static int32_t tdRSmaFetchAndSubmitResult(SRSmaInfoItem *pItem, STSchema *pTSche
|
|||
goto _err;
|
||||
}
|
||||
|
||||
smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " version:%"PRIi64, SMA_VID(pSma),
|
||||
suid, pItem->level, output->info.version);
|
||||
smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " version:%" PRIi64,
|
||||
SMA_VID(pSma), suid, pItem->level, output->info.version);
|
||||
|
||||
taosMemoryFreeClear(pReq);
|
||||
taosArrayClear(pResult);
|
||||
|
@ -644,7 +644,7 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
|
|||
smaDebug("vgId:%d, execute rsma %" PRIi8 " task for qTaskInfo:%p suid:%" PRIu64, SMA_VID(pSma), level,
|
||||
pItem->taskInfo, suid);
|
||||
|
||||
if (qSetStreamInput(pItem->taskInfo, pMsg, inputType, true) < 0) { // INPUT__DATA_SUBMIT
|
||||
if (qSetMultiStreamInput(pItem->taskInfo, pMsg, 1, inputType) < 0) { // INPUT__DATA_SUBMIT
|
||||
smaError("vgId:%d, rsma % " PRIi8 " qSetStreamInput failed since %s", SMA_VID(pSma), level, tstrerror(terrno));
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
|
@ -1329,7 +1329,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
tdRefRSmaInfo(pSma, pRSmaInfo);
|
||||
|
||||
SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL};
|
||||
qSetStreamInput(pItem->taskInfo, &dataBlock, STREAM_INPUT__DATA_BLOCK, false);
|
||||
qSetMultiStreamInput(pItem->taskInfo, &dataBlock, 1, STREAM_INPUT__DATA_BLOCK);
|
||||
tdRSmaFetchAndSubmitResult(pItem, pRSmaInfo->pTSchema, pRSmaInfo->suid, pStat, STREAM_INPUT__DATA_BLOCK);
|
||||
|
||||
tdUnRefRSmaInfo(pSma, pRSmaInfo);
|
||||
|
@ -1356,4 +1356,4 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
|
|||
|
||||
_end:
|
||||
tdReleaseSmaRef(smaMgmt.rsetId, pItem->refId, __func__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -653,7 +653,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
|
|||
} else {
|
||||
SReadHandle mgHandle = {
|
||||
.vnode = NULL,
|
||||
.numOfVgroups = pTask->numOfVgroups,
|
||||
.numOfVgroups = (int32_t)taosArrayGetSize(pTask->childEpInfo),
|
||||
};
|
||||
pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ int vnodeQueryOpen(SVnode *pVnode) {
|
|||
|
||||
void vnodeQueryClose(SVnode *pVnode) { qWorkerDestroy((void **)&pVnode->pQuery); }
|
||||
|
||||
int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||
STableInfoReq infoReq = {0};
|
||||
STableMetaRsp metaRsp = {0};
|
||||
SMetaReader mer1 = {0};
|
||||
|
@ -99,7 +99,12 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
pRsp = rpcMallocCont(rspLen);
|
||||
if (direct) {
|
||||
pRsp = rpcMallocCont(rspLen);
|
||||
} else {
|
||||
pRsp = taosMemoryCalloc(1, rspLen);
|
||||
}
|
||||
|
||||
if (pRsp == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
|
@ -117,15 +122,19 @@ _exit:
|
|||
qError("get table %s meta failed cause of %s", infoReq.tbName, tstrerror(code));
|
||||
}
|
||||
|
||||
tmsgSendRsp(&rpcMsg);
|
||||
|
||||
if (direct) {
|
||||
tmsgSendRsp(&rpcMsg);
|
||||
} else {
|
||||
*pMsg = rpcMsg;
|
||||
}
|
||||
|
||||
taosMemoryFree(metaRsp.pSchemas);
|
||||
metaReaderClear(&mer2);
|
||||
metaReaderClear(&mer1);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
|
||||
STableCfgReq cfgReq = {0};
|
||||
STableCfgRsp cfgRsp = {0};
|
||||
SMetaReader mer1 = {0};
|
||||
|
@ -209,7 +218,12 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
goto _exit;
|
||||
}
|
||||
|
||||
pRsp = rpcMallocCont(rspLen);
|
||||
if (direct) {
|
||||
pRsp = rpcMallocCont(rspLen);
|
||||
} else {
|
||||
pRsp = taosMemoryCalloc(1, rspLen);
|
||||
}
|
||||
|
||||
if (pRsp == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
|
@ -227,14 +241,124 @@ _exit:
|
|||
qError("get table %s cfg failed cause of %s", cfgReq.tbName, tstrerror(code));
|
||||
}
|
||||
|
||||
tmsgSendRsp(&rpcMsg);
|
||||
|
||||
if (direct) {
|
||||
tmsgSendRsp(&rpcMsg);
|
||||
} else {
|
||||
*pMsg = rpcMsg;
|
||||
}
|
||||
|
||||
tFreeSTableCfgRsp(&cfgRsp);
|
||||
metaReaderClear(&mer2);
|
||||
metaReaderClear(&mer1);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
int32_t code = 0;
|
||||
int32_t offset = 0;
|
||||
int32_t rspSize = 0;
|
||||
SBatchReq *batchReq = (SBatchReq*)pMsg->pCont;
|
||||
int32_t msgNum = ntohl(batchReq->msgNum);
|
||||
offset += sizeof(SBatchReq);
|
||||
SBatchMsg req = {0};
|
||||
SBatchRsp rsp = {0};
|
||||
SRpcMsg reqMsg = *pMsg;
|
||||
SRpcMsg rspMsg = {0};
|
||||
void* pRsp = NULL;
|
||||
|
||||
SArray* batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp));
|
||||
if (NULL == batchRsp) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
req.msgType = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgType);
|
||||
|
||||
req.msgLen = ntohl(*(int32_t*)((char*)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgLen);
|
||||
|
||||
req.msg = (char*)pMsg->pCont + offset;
|
||||
offset += req.msgLen;
|
||||
|
||||
reqMsg.msgType = req.msgType;
|
||||
reqMsg.pCont = req.msg;
|
||||
reqMsg.contLen = req.msgLen;
|
||||
|
||||
switch (req.msgType) {
|
||||
case TDMT_VND_TABLE_META:
|
||||
vnodeGetTableMeta(pVnode, &reqMsg, false);
|
||||
break;
|
||||
case TDMT_VND_TABLE_CFG:
|
||||
vnodeGetTableCfg(pVnode, &reqMsg, false);
|
||||
break;
|
||||
default:
|
||||
qError("invalid req msgType %d", req.msgType);
|
||||
reqMsg.code = TSDB_CODE_INVALID_MSG;
|
||||
reqMsg.pCont = NULL;
|
||||
reqMsg.contLen = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
rsp.reqType = reqMsg.msgType;
|
||||
rsp.msgLen = reqMsg.contLen;
|
||||
rsp.rspCode = reqMsg.code;
|
||||
rsp.msg = reqMsg.pCont;
|
||||
|
||||
taosArrayPush(batchRsp, &rsp);
|
||||
|
||||
rspSize += sizeof(rsp) + rsp.msgLen - POINTER_BYTES;
|
||||
}
|
||||
|
||||
rspSize += sizeof(int32_t);
|
||||
offset = 0;
|
||||
|
||||
pRsp = rpcMallocCont(rspSize);
|
||||
if (pRsp == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(msgNum);
|
||||
offset += sizeof(msgNum);
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
SBatchRsp *p = taosArrayGet(batchRsp, i);
|
||||
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(p->reqType);
|
||||
offset += sizeof(p->reqType);
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(p->msgLen);
|
||||
offset += sizeof(p->msgLen);
|
||||
*(int32_t*)((char*)pRsp + offset) = htonl(p->rspCode);
|
||||
offset += sizeof(p->rspCode);
|
||||
memcpy((char*)pRsp + offset, p->msg, p->msgLen);
|
||||
offset += p->msgLen;
|
||||
|
||||
taosMemoryFreeClear(p->msg);
|
||||
}
|
||||
|
||||
taosArrayDestroy(batchRsp);
|
||||
batchRsp = NULL;
|
||||
|
||||
_exit:
|
||||
|
||||
rspMsg.info = pMsg->info;
|
||||
rspMsg.pCont = pRsp;
|
||||
rspMsg.contLen = rspSize;
|
||||
rspMsg.code = code;
|
||||
rspMsg.msgType = pMsg->msgType;
|
||||
|
||||
if (code) {
|
||||
qError("vnd get batch meta failed cause of %s", tstrerror(code));
|
||||
}
|
||||
|
||||
taosArrayDestroyEx(batchRsp, tFreeSBatchRsp);
|
||||
|
||||
tmsgSendRsp(&rspMsg);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
|
||||
pLoad->vgId = TD_VID(pVnode);
|
||||
pLoad->syncState = syncGetMyRole(pVnode->sync);
|
||||
|
|
|
@ -298,7 +298,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
||||
vTrace("message in fetch queue is processing");
|
||||
if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META ||
|
||||
pMsg->msgType == TDMT_VND_TABLE_CFG) &&
|
||||
pMsg->msgType == TDMT_VND_TABLE_CFG || pMsg->msgType == TDMT_VND_BATCH_META) &&
|
||||
!vnodeIsLeader(pVnode)) {
|
||||
vnodeRedirectRpcMsg(pVnode, pMsg);
|
||||
return 0;
|
||||
|
@ -320,9 +320,11 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
case TDMT_SCH_QUERY_HEARTBEAT:
|
||||
return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg, 0);
|
||||
case TDMT_VND_TABLE_META:
|
||||
return vnodeGetTableMeta(pVnode, pMsg);
|
||||
return vnodeGetTableMeta(pVnode, pMsg, true);
|
||||
case TDMT_VND_TABLE_CFG:
|
||||
return vnodeGetTableCfg(pVnode, pMsg);
|
||||
return vnodeGetTableCfg(pVnode, pMsg, true);
|
||||
case TDMT_VND_BATCH_META:
|
||||
return vnodeGetBatchMeta(pVnode, pMsg);
|
||||
case TDMT_VND_CONSUME:
|
||||
return tqProcessPollReq(pVnode->pTq, pMsg);
|
||||
case TDMT_STREAM_TASK_RUN:
|
||||
|
|
|
@ -31,6 +31,7 @@ extern "C" {
|
|||
#define CTG_DEFAULT_RENT_SECOND 10
|
||||
#define CTG_DEFAULT_RENT_SLOT_SIZE 10
|
||||
#define CTG_DEFAULT_MAX_RETRY_TIMES 3
|
||||
#define CTG_DEFAULT_BATCH_NUM 64
|
||||
|
||||
#define CTG_RENT_SLOT_SECOND 1.5
|
||||
|
||||
|
@ -38,6 +39,8 @@ extern "C" {
|
|||
|
||||
#define CTG_ERR_CODE_TABLE_NOT_EXIST TSDB_CODE_PAR_TABLE_NOT_EXIST
|
||||
|
||||
#define CTG_BATCH_FETCH 1
|
||||
|
||||
enum {
|
||||
CTG_READ = 1,
|
||||
CTG_WRITE,
|
||||
|
@ -200,8 +203,20 @@ typedef struct SCatalog {
|
|||
SCtgRentMgmt stbRent;
|
||||
} SCatalog;
|
||||
|
||||
typedef struct SCtgBatch {
|
||||
int32_t batchId;
|
||||
int32_t msgType;
|
||||
int32_t msgSize;
|
||||
SArray* pMsgs;
|
||||
SRequestConnInfo conn;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
SArray* pTaskIds;
|
||||
} SCtgBatch;
|
||||
|
||||
typedef struct SCtgJob {
|
||||
int64_t refId;
|
||||
int32_t batchId;
|
||||
SHashObj* pBatchs;
|
||||
SArray* pTasks;
|
||||
int32_t taskDone;
|
||||
SMetaData jobRes;
|
||||
|
@ -236,6 +251,16 @@ typedef struct SCtgMsgCtx {
|
|||
char* target;
|
||||
} SCtgMsgCtx;
|
||||
|
||||
|
||||
typedef struct SCtgTaskCallbackParam {
|
||||
uint64_t queryId;
|
||||
int64_t refId;
|
||||
SArray* taskId;
|
||||
int32_t reqType;
|
||||
int32_t batchId;
|
||||
} SCtgTaskCallbackParam;
|
||||
|
||||
|
||||
typedef struct SCtgTask SCtgTask;
|
||||
typedef int32_t (*ctgSubTaskCbFp)(SCtgTask*);
|
||||
|
||||
|
@ -258,6 +283,7 @@ typedef struct SCtgTask {
|
|||
SRWLatch lock;
|
||||
SArray* pParents;
|
||||
SCtgSubRes subRes;
|
||||
SHashObj* pBatchs;
|
||||
} SCtgTask;
|
||||
|
||||
typedef int32_t (*ctgInitTaskFp)(SCtgJob*, int32_t, void*);
|
||||
|
@ -618,6 +644,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa
|
|||
int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask);
|
||||
int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask);
|
||||
int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask);
|
||||
int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob *pJob, SHashObj* pBatchs);
|
||||
|
||||
int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param);
|
||||
int32_t ctgLaunchJob(SCtgJob *pJob);
|
||||
|
@ -626,6 +653,9 @@ int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp,
|
|||
int32_t ctgGetTbCfgCb(SCtgTask *pTask);
|
||||
void ctgFreeHandle(SCatalog* pCatalog);
|
||||
|
||||
void ctgFreeMsgSendParam(void* param);
|
||||
void ctgFreeBatch(SCtgBatch *pBatch);
|
||||
void ctgFreeBatchs(SHashObj *pBatchs);
|
||||
int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst);
|
||||
int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput);
|
||||
int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray** pList);
|
||||
|
@ -642,7 +672,7 @@ int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2);
|
|||
void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput);
|
||||
int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target);
|
||||
char * ctgTaskTypeStr(CTG_TASK_TYPE type);
|
||||
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask);
|
||||
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId);
|
||||
int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes);
|
||||
void ctgFreeSTableIndex(void *info);
|
||||
void ctgClearSubTaskRes(SCtgSubRes *pRes);
|
||||
|
|
|
@ -20,12 +20,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SCtgTaskCallbackParam {
|
||||
uint64_t queryId;
|
||||
int64_t refId;
|
||||
uint64_t taskId;
|
||||
int32_t reqType;
|
||||
} SCtgTaskCallbackParam;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -473,8 +473,15 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const
|
|||
pJob->tbCfgNum = tbCfgNum;
|
||||
pJob->svrVerNum = svrVerNum;
|
||||
|
||||
pJob->pTasks = taosArrayInit(taskNum, sizeof(SCtgTask));
|
||||
#if CTG_BATCH_FETCH
|
||||
pJob->pBatchs = taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if (NULL == pJob->pBatchs) {
|
||||
ctgError("taosHashInit %d batch failed", CTG_DEFAULT_BATCH_NUM);
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
#endif
|
||||
|
||||
pJob->pTasks = taosArrayInit(taskNum, sizeof(SCtgTask));
|
||||
if (NULL == pJob->pTasks) {
|
||||
ctgError("taosArrayInit %d tasks failed", taskNum);
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
|
@ -560,7 +567,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const
|
|||
|
||||
_return:
|
||||
|
||||
taosMemoryFreeClear(*job);
|
||||
ctgFreeJob(*job);
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
@ -776,7 +783,8 @@ int32_t ctgCallSubCb(SCtgTask *pTask) {
|
|||
pParent->subRes.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pParent->pBatchs = pTask->pBatchs;
|
||||
CTG_ERR_JRET(pParent->subRes.fp(pParent));
|
||||
}
|
||||
|
||||
|
@ -872,7 +880,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
|
|||
SVgroupInfo vgInfo = {0};
|
||||
CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, ctx->pName, &vgInfo));
|
||||
|
||||
ctgDebug("will refresh tbmeta, not supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
|
||||
ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s, flag:%d", tNameGetTableName(ctx->pName), ctx->flag);
|
||||
|
||||
ctx->vgId = vgInfo.vgId;
|
||||
CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, ctx->pName, &vgInfo, NULL, pTask));
|
||||
|
@ -890,7 +898,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
ctgError("no tbmeta got, tbNmae:%s", tNameGetTableName(ctx->pName));
|
||||
ctgError("no tbmeta got, tbName:%s", tNameGetTableName(ctx->pName));
|
||||
ctgRemoveTbMetaFromCache(pCtg, ctx->pName, false);
|
||||
|
||||
CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST);
|
||||
|
@ -1653,6 +1661,7 @@ int32_t ctgSetSubTaskCb(SCtgTask *pSub, SCtgTask *pTask) {
|
|||
if (CTG_TASK_DONE == pSub->status) {
|
||||
pTask->subRes.code = pSub->code;
|
||||
CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].cloneFp)(pSub, &pTask->subRes.res));
|
||||
pTask->pBatchs = pSub->pBatchs;
|
||||
CTG_ERR_JRET(pTask->subRes.fp(pTask));
|
||||
} else {
|
||||
if (NULL == pSub->pParents) {
|
||||
|
@ -1690,6 +1699,7 @@ int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp,
|
|||
CTG_ERR_RET(ctgSetSubTaskCb(pSub, pTask));
|
||||
|
||||
if (newTask) {
|
||||
pSub->pBatchs = pTask->pBatchs;
|
||||
CTG_ERR_RET((*gCtgAsyncFps[pSub->type].launchFp)(pSub));
|
||||
pSub->status = CTG_TASK_LAUNCHED;
|
||||
}
|
||||
|
@ -1702,9 +1712,11 @@ int32_t ctgLaunchJob(SCtgJob *pJob) {
|
|||
|
||||
for (int32_t i = 0; i < taskNum; ++i) {
|
||||
SCtgTask *pTask = taosArrayGet(pJob->pTasks, i);
|
||||
pTask->pBatchs = pJob->pBatchs;
|
||||
|
||||
qDebug("QID:0x%" PRIx64 " ctg launch [%dth] task", pJob->queryId, pTask->taskId);
|
||||
CTG_ERR_RET((*gCtgAsyncFps[pTask->type].launchFp)(pTask));
|
||||
|
||||
pTask->status = CTG_TASK_LAUNCHED;
|
||||
}
|
||||
|
||||
|
@ -1712,6 +1724,10 @@ int32_t ctgLaunchJob(SCtgJob *pJob) {
|
|||
qDebug("QID:0x%" PRIx64 " ctg call user callback with rsp %s", pJob->queryId, tstrerror(pJob->jobResCode));
|
||||
|
||||
taosAsyncExec(ctgCallUserCb, pJob, NULL);
|
||||
#if CTG_BATCH_FETCH
|
||||
} else {
|
||||
ctgLaunchBatchs(pJob->pCtg, pJob, pJob->pBatchs);
|
||||
#endif
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -18,9 +18,67 @@
|
|||
#include "tname.h"
|
||||
#include "catalogInt.h"
|
||||
#include "systable.h"
|
||||
#include "ctgRemote.h"
|
||||
#include "tref.h"
|
||||
|
||||
int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBuf *pMsg, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
SArray* pTaskId = cbParam->taskId;
|
||||
SCatalog* pCtg = pJob->pCtg;
|
||||
int32_t taskNum = taosArrayGetSize(pTaskId);
|
||||
SDataBuf taskMsg = *pMsg;
|
||||
int32_t offset = 0;
|
||||
int32_t msgNum = (TSDB_CODE_SUCCESS == rspCode && pMsg->pData && (pMsg->len > 0)) ? ntohl(*(int32_t*)pMsg->pData) : 0;
|
||||
ASSERT(taskNum == msgNum || 0 == msgNum);
|
||||
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg got batch %d rsp %s", pJob->queryId, cbParam->batchId, TMSG_INFO(cbParam->reqType + 1));
|
||||
|
||||
offset += sizeof(msgNum);
|
||||
SBatchRsp rsp = {0};
|
||||
SHashObj* pBatchs = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if (NULL == pBatchs) {
|
||||
ctgError("taosHashInit %d batch failed", taskNum);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < taskNum; ++i) {
|
||||
int32_t* taskId = taosArrayGet(pTaskId, i);
|
||||
SCtgTask *pTask = taosArrayGet(pJob->pTasks, *taskId);
|
||||
if (msgNum > 0) {
|
||||
rsp.reqType = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
offset += sizeof(rsp.reqType);
|
||||
rsp.msgLen = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
offset += sizeof(rsp.msgLen);
|
||||
rsp.rspCode = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
offset += sizeof(rsp.rspCode);
|
||||
rsp.msg = ((char*)pMsg->pData) + offset;
|
||||
offset += rsp.msgLen;
|
||||
|
||||
taskMsg.msgType = rsp.reqType;
|
||||
taskMsg.pData = rsp.msg;
|
||||
taskMsg.len = rsp.msgLen;
|
||||
} else {
|
||||
rsp.reqType = -1;
|
||||
taskMsg.msgType = -1;
|
||||
taskMsg.pData = NULL;
|
||||
taskMsg.len = 0;
|
||||
}
|
||||
|
||||
pTask->pBatchs = pBatchs;
|
||||
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(taskMsg.msgType + 1));
|
||||
|
||||
(*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, rsp.reqType, &taskMsg, (rsp.rspCode ? rsp.rspCode : rspCode));
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs));
|
||||
|
||||
_return:
|
||||
|
||||
ctgFreeBatchs(pBatchs);
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target) {
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -233,6 +291,11 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
if (TSDB_CODE_SUCCESS != rspCode) {
|
||||
qError("Got error rsp, error:%s", tstrerror(rspCode));
|
||||
CTG_ERR_RET(rspCode);
|
||||
}
|
||||
|
||||
qError("invalid req type %s", TMSG_INFO(reqType));
|
||||
return TSDB_CODE_APP_ERROR;
|
||||
}
|
||||
|
@ -254,12 +317,32 @@ int32_t ctgHandleMsgCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
|||
goto _return;
|
||||
}
|
||||
|
||||
SCtgTask *pTask = taosArrayGet(pJob->pTasks, cbParam->taskId);
|
||||
SCatalog* pCtg = pJob->pCtg;
|
||||
|
||||
qDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(cbParam->reqType + 1));
|
||||
if (TDMT_VND_BATCH_META == cbParam->reqType || TDMT_MND_BATCH_META == cbParam->reqType) {
|
||||
CTG_ERR_JRET(ctgHandleBatchRsp(pJob, cbParam, pMsg, rspCode));
|
||||
} else {
|
||||
int32_t *taskId = taosArrayGet(cbParam->taskId, 0);
|
||||
SCtgTask *pTask = taosArrayGet(pJob->pTasks, *taskId);
|
||||
|
||||
qDebug("QID:0x%" PRIx64 " ctg task %d start to handle rsp %s", pJob->queryId, pTask->taskId, TMSG_INFO(cbParam->reqType + 1));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
SHashObj* pBatchs = taosHashInit(CTG_DEFAULT_BATCH_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if (NULL == pBatchs) {
|
||||
ctgError("taosHashInit %d batch failed", CTG_DEFAULT_BATCH_NUM);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
pTask->pBatchs = pBatchs;
|
||||
#endif
|
||||
|
||||
CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, cbParam->reqType, pMsg, rspCode));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs));
|
||||
#endif
|
||||
}
|
||||
|
||||
CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].handleRspFp)(pTask, cbParam->reqType, pMsg, rspCode));
|
||||
|
||||
_return:
|
||||
|
||||
taosMemoryFree(pMsg->pData);
|
||||
|
@ -272,12 +355,12 @@ _return:
|
|||
}
|
||||
|
||||
|
||||
int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsgSendInfo) {
|
||||
int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, int32_t msgType, SMsgSendInfo **pMsgSendInfo) {
|
||||
int32_t code = 0;
|
||||
SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (NULL == msgSendInfo) {
|
||||
qError("calloc %d failed", (int32_t)sizeof(SMsgSendInfo));
|
||||
CTG_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
CTG_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
SCtgTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SCtgTaskCallbackParam));
|
||||
|
@ -287,12 +370,13 @@ int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsg
|
|||
}
|
||||
|
||||
param->reqType = msgType;
|
||||
param->queryId = pTask->pJob->queryId;
|
||||
param->refId = pTask->pJob->refId;
|
||||
param->taskId = pTask->taskId;
|
||||
param->queryId = pJob->queryId;
|
||||
param->refId = pJob->refId;
|
||||
param->taskId = pTaskId;
|
||||
param->batchId = batchId;
|
||||
|
||||
msgSendInfo->param = param;
|
||||
msgSendInfo->paramFreeFp = taosMemoryFree;
|
||||
msgSendInfo->paramFreeFp = ctgFreeMsgSendParam;
|
||||
msgSendInfo->fp = ctgHandleMsgCallback;
|
||||
|
||||
*pMsgSendInfo = msgSendInfo;
|
||||
|
@ -301,18 +385,19 @@ int32_t ctgMakeMsgSendInfo(SCtgTask* pTask, int32_t msgType, SMsgSendInfo **pMsg
|
|||
|
||||
_return:
|
||||
|
||||
taosMemoryFree(param);
|
||||
taosMemoryFree(msgSendInfo);
|
||||
taosArrayDestroy(pTaskId);
|
||||
destroySendMsgInfo(msgSendInfo);
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTask* pTask, int32_t msgType, void *msg, uint32_t msgSize) {
|
||||
int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob* pJob, SArray* pTaskId,
|
||||
int32_t batchId, char* dbFName, int32_t vgId, int32_t msgType, void *msg, uint32_t msgSize) {
|
||||
int32_t code = 0;
|
||||
SMsgSendInfo *pMsgSendInfo = NULL;
|
||||
CTG_ERR_JRET(ctgMakeMsgSendInfo(pTask, msgType, &pMsgSendInfo));
|
||||
CTG_ERR_JRET(ctgMakeMsgSendInfo(pJob, pTaskId, batchId, msgType, &pMsgSendInfo));
|
||||
|
||||
ctgUpdateSendTargetInfo(pMsgSendInfo, msgType, pTask);
|
||||
ctgUpdateSendTargetInfo(pMsgSendInfo, msgType, dbFName, vgId);
|
||||
|
||||
pMsgSendInfo->requestId = pConn->requestId;
|
||||
pMsgSendInfo->requestObjRefId = pConn->requestObjRefId;
|
||||
|
@ -323,24 +408,178 @@ int32_t ctgAsyncSendMsg(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTask* pTask
|
|||
|
||||
int64_t transporterId = 0;
|
||||
code = asyncSendMsgToServer(pConn->pTrans, &pConn->mgmtEps, &transporterId, pMsgSendInfo);
|
||||
pMsgSendInfo = NULL;
|
||||
if (code) {
|
||||
ctgError("asyncSendMsgToSever failed, error: %s", tstrerror(code));
|
||||
CTG_ERR_JRET(code);
|
||||
}
|
||||
|
||||
ctgDebug("ctg req msg sent, reqId:0x%" PRIx64 ", msg type:%d, %s", pTask->pJob->queryId, msgType, TMSG_INFO(msgType));
|
||||
ctgDebug("ctg req msg sent, reqId:0x%" PRIx64 ", msg type:%d, %s", pJob->queryId, msgType, TMSG_INFO(msgType));
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
if (pMsgSendInfo) {
|
||||
taosMemoryFreeClear(pMsgSendInfo->param);
|
||||
taosMemoryFreeClear(pMsgSendInfo);
|
||||
destroySendMsgInfo(pMsgSendInfo);
|
||||
}
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo *pConn, SCtgTask* pTask, int32_t msgType, void *msg, uint32_t msgSize) {
|
||||
int32_t code = 0;
|
||||
SHashObj* pBatchs = pTask->pBatchs;
|
||||
SCtgJob* pJob = pTask->pJob;
|
||||
SCtgBatch* pBatch = taosHashGet(pBatchs, &vgId, sizeof(vgId));
|
||||
int32_t taskNum = taosArrayGetSize(pTask->pJob->pTasks);
|
||||
SCtgBatch newBatch = {0};
|
||||
SBatchMsg req = {0};
|
||||
|
||||
if (NULL == pBatch) {
|
||||
newBatch.pMsgs = taosArrayInit(taskNum, sizeof(SBatchMsg));
|
||||
newBatch.pTaskIds = taosArrayInit(taskNum, sizeof(int32_t));
|
||||
if (NULL == newBatch.pMsgs || NULL == newBatch.pTaskIds) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
newBatch.conn = *pConn;
|
||||
|
||||
req.msgType = msgType;
|
||||
req.msgLen = msgSize;
|
||||
req.msg = msg;
|
||||
if (NULL == taosArrayPush(newBatch.pMsgs, &req)) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
if (NULL == taosArrayPush(newBatch.pTaskIds, &pTask->taskId)) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
newBatch.msgSize = sizeof(SBatchReq) + sizeof(req) + msgSize - POINTER_BYTES;
|
||||
|
||||
if (vgId > 0) {
|
||||
if (TDMT_VND_TABLE_CFG == msgType) {
|
||||
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
|
||||
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||
} else if (TDMT_VND_TABLE_META == msgType) {
|
||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||
} else {
|
||||
ctgError("invalid vnode msgType %d", msgType);
|
||||
CTG_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
newBatch.msgType = (vgId > 0) ? TDMT_VND_BATCH_META : TDMT_MND_BATCH_META;
|
||||
newBatch.batchId = atomic_add_fetch_32(&pJob->batchId, 1);
|
||||
|
||||
if (0 != taosHashPut(pBatchs, &vgId, sizeof(vgId), &newBatch, sizeof(newBatch))) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), newBatch.batchId, vgId);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
req.msgType = msgType;
|
||||
req.msgLen = msgSize;
|
||||
req.msg = msg;
|
||||
if (NULL == taosArrayPush(pBatch->pMsgs, &req)) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
if (NULL == taosArrayPush(pBatch->pTaskIds, &pTask->taskId)) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
pBatch->msgSize += sizeof(req) + msgSize - POINTER_BYTES;
|
||||
|
||||
if (vgId > 0) {
|
||||
if (TDMT_VND_TABLE_CFG == msgType) {
|
||||
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
|
||||
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||
} else if (TDMT_VND_TABLE_META == msgType) {
|
||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||
tNameGetFullDbName(ctx->pName, newBatch.dbFName);
|
||||
} else {
|
||||
ctgError("invalid vnode msgType %d", msgType);
|
||||
CTG_ERR_JRET(TSDB_CODE_APP_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
ctgDebug("task %d %s req added to batch %d, target vgId %d", pTask->taskId, TMSG_INFO(msgType), pBatch->batchId, vgId);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
ctgFreeBatch(&newBatch);
|
||||
taosMemoryFree(msg);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t ctgBuildBatchReqMsg(SCtgBatch* pBatch, int32_t vgId, void** msg) {
|
||||
*msg = taosMemoryMalloc(pBatch->msgSize);
|
||||
if (NULL == (*msg)) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
int32_t offset = 0;
|
||||
int32_t num = taosArrayGetSize(pBatch->pMsgs);
|
||||
SBatchReq *pBatchReq = (SBatchReq*)(*msg);
|
||||
|
||||
pBatchReq->header.vgId = htonl(vgId);
|
||||
pBatchReq->msgNum = htonl(num);
|
||||
offset += sizeof(SBatchReq);
|
||||
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SBatchMsg* pReq = taosArrayGet(pBatch->pMsgs, i);
|
||||
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgType);
|
||||
offset += sizeof(pReq->msgType);
|
||||
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgLen);
|
||||
offset += sizeof(pReq->msgLen);
|
||||
memcpy((char*)(*msg) + offset, pReq->msg, pReq->msgLen);
|
||||
offset += pReq->msgLen;
|
||||
}
|
||||
|
||||
ASSERT(pBatch->msgSize == offset);
|
||||
|
||||
qDebug("batch req %d to vg %d msg built with %d meta reqs", pBatch->batchId, vgId, num);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob *pJob, SHashObj* pBatchs) {
|
||||
int32_t code = 0;
|
||||
void* msg = NULL;
|
||||
void* p = taosHashIterate(pBatchs, NULL);
|
||||
while (NULL != p) {
|
||||
size_t len = 0;
|
||||
int32_t* vgId = taosHashGetKey(p, &len);
|
||||
SCtgBatch* pBatch = (SCtgBatch*)p;
|
||||
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg start to launch batch %d", pJob->queryId, pBatch->batchId);
|
||||
|
||||
CTG_ERR_JRET(ctgBuildBatchReqMsg(pBatch, *vgId, &msg));
|
||||
code = ctgAsyncSendMsg(pCtg, &pBatch->conn, pJob, pBatch->pTaskIds, pBatch->batchId,
|
||||
pBatch->dbFName, *vgId, pBatch->msgType, msg, pBatch->msgSize);
|
||||
pBatch->pTaskIds = NULL;
|
||||
CTG_ERR_JRET(code);
|
||||
|
||||
p = taosHashIterate(pBatchs, p);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
||||
_return:
|
||||
|
||||
if (p) {
|
||||
taosHashCancelIterate(pBatchs, p);
|
||||
}
|
||||
taosMemoryFree(msg);
|
||||
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
||||
|
||||
int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray *out, SCtgTask* pTask) {
|
||||
char *msg = NULL;
|
||||
int32_t msgLen = 0;
|
||||
|
@ -361,7 +600,18 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray
|
|||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, NULL));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -396,7 +646,18 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray
|
|||
|
||||
if (pTask) {
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -436,8 +697,18 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildU
|
|||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, input->db));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -476,8 +747,18 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char
|
|||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)dbFName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -516,8 +797,18 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
|
|||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)indexName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -559,8 +850,18 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *n
|
|||
}
|
||||
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)tbFName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -599,8 +900,18 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const ch
|
|||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)funcName));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -639,8 +950,18 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const
|
|||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, (char*)user));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -684,8 +1005,17 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char
|
|||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, pOut, tbFName));
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -744,7 +1074,21 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa
|
|||
.requestId = pConn->requestId,
|
||||
.requestObjRefId = pConn->requestObjRefId,
|
||||
.mgmtEps = vgroupInfo->epSet};
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask, reqType, msg, msgLen));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(ctx->pName, dbFName);
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, dbFName, ctx->vgId, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -791,7 +1135,20 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
|
|||
.requestId = pConn->requestId,
|
||||
.requestObjRefId = pConn->requestObjRefId,
|
||||
.mgmtEps = vgroupInfo->epSet};
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask, reqType, msg, msgLen));
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SCtgTbCfgCtx* ctx = (SCtgTbCfgCtx*)pTask->taskCtx;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(ctx->pName, dbFName);
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, dbFName, ctx->pVgInfo->vgId, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -832,8 +1189,17 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
|
|||
|
||||
if (pTask) {
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, (char*)tbFName));
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
@ -868,8 +1234,18 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **ou
|
|||
|
||||
if (pTask) {
|
||||
CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, NULL));
|
||||
|
||||
#if CTG_BATCH_FETCH
|
||||
CTG_RET(ctgAddBatch(pCtg, 0, pConn, pTask, reqType, msg, msgLen));
|
||||
#else
|
||||
SArray* pTaskId = taosArrayInit(1, sizeof(int32_t));
|
||||
if (NULL == pTaskId) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
taosArrayPush(pTaskId, &pTask->taskId);
|
||||
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen));
|
||||
CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, 0, reqType, msg, msgLen));
|
||||
#endif
|
||||
}
|
||||
|
||||
SRpcMsg rpcMsg = {
|
||||
|
|
|
@ -19,6 +19,39 @@
|
|||
#include "catalogInt.h"
|
||||
#include "systable.h"
|
||||
|
||||
void ctgFreeMsgSendParam(void* param) {
|
||||
if (NULL == param) {
|
||||
return;
|
||||
}
|
||||
|
||||
SCtgTaskCallbackParam* pParam = (SCtgTaskCallbackParam*)param;
|
||||
taosArrayDestroy(pParam->taskId);
|
||||
|
||||
taosMemoryFree(param);
|
||||
}
|
||||
|
||||
void ctgFreeBatch(SCtgBatch *pBatch) {
|
||||
if (NULL == pBatch) {
|
||||
return;
|
||||
}
|
||||
|
||||
taosArrayDestroy(pBatch->pMsgs);
|
||||
taosArrayDestroy(pBatch->pTaskIds);
|
||||
}
|
||||
|
||||
void ctgFreeBatchs(SHashObj *pBatchs) {
|
||||
void* p = taosHashIterate(pBatchs, NULL);
|
||||
while (NULL != p) {
|
||||
SCtgBatch* pBatch = (SCtgBatch*)p;
|
||||
|
||||
ctgFreeBatch(pBatch);
|
||||
|
||||
p = taosHashIterate(pBatchs, p);
|
||||
}
|
||||
|
||||
taosHashCleanup(pBatchs);
|
||||
}
|
||||
|
||||
char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
|
||||
switch (type) {
|
||||
case CTG_TASK_GET_QNODE:
|
||||
|
@ -612,6 +645,7 @@ void ctgFreeJob(void* job) {
|
|||
uint64_t qid = pJob->queryId;
|
||||
|
||||
ctgFreeTasks(pJob->pTasks);
|
||||
ctgFreeBatchs(pJob->pBatchs);
|
||||
|
||||
ctgFreeSMetaData(&pJob->jobRes);
|
||||
|
||||
|
@ -867,14 +901,10 @@ int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes) {
|
|||
}
|
||||
|
||||
|
||||
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask) {
|
||||
if (msgType == TDMT_VND_TABLE_META) {
|
||||
SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(ctx->pName, dbFName);
|
||||
|
||||
int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId) {
|
||||
if (msgType == TDMT_VND_TABLE_META || msgType == TDMT_VND_TABLE_CFG || msgType == TDMT_VND_BATCH_META) {
|
||||
pMsgSendInfo->target.type = TARGET_TYPE_VNODE;
|
||||
pMsgSendInfo->target.vgId = ctx->vgId;
|
||||
pMsgSendInfo->target.vgId = vgId;
|
||||
pMsgSendInfo->target.dbFName = strdup(dbFName);
|
||||
} else {
|
||||
pMsgSendInfo->target.type = TARGET_TYPE_MNODE;
|
||||
|
|
|
@ -90,7 +90,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp
|
|||
pRes->uidList = pHandle->pParam->pUidList;
|
||||
pRes->skey = pHandle->pDeleter->deleteTimeRange.skey;
|
||||
pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey;
|
||||
strcpy(pRes->tableFName, pHandle->pDeleter->tableFName);
|
||||
strcpy(pRes->tableName, pHandle->pDeleter->tableFName);
|
||||
strcpy(pRes->tsColName, pHandle->pDeleter->tsColName);
|
||||
pRes->affectedRows = *(int64_t*)pColRes->pData;
|
||||
|
||||
pBuf->useSize += pEntry->dataLen;
|
||||
|
|
|
@ -30,8 +30,7 @@ static void cleanupRefPool() {
|
|||
taosCloseRef(ref);
|
||||
}
|
||||
|
||||
static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t numOfBlocks, int32_t type, bool assignUid,
|
||||
char* id) {
|
||||
static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t numOfBlocks, int32_t type, char* id) {
|
||||
ASSERT(pOperator != NULL);
|
||||
if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
|
||||
if (pOperator->numOfDownstream == 0) {
|
||||
|
@ -44,12 +43,12 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
}
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
return doSetStreamBlock(pOperator->pDownstream[0], input, numOfBlocks, type, assignUid, id);
|
||||
return doSetStreamBlock(pOperator->pDownstream[0], input, numOfBlocks, type, id);
|
||||
} else {
|
||||
pOperator->status = OP_NOT_OPENED;
|
||||
|
||||
SStreamScanInfo* pInfo = pOperator->info;
|
||||
pInfo->assignBlockUid = assignUid;
|
||||
/*pInfo->assignBlockUid = assignUid;*/
|
||||
|
||||
// TODO: if a block was set but not consumed,
|
||||
// prevent setting a different type of block
|
||||
|
@ -95,11 +94,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
|
|||
}
|
||||
}
|
||||
|
||||
int32_t qSetStreamInput(qTaskInfo_t tinfo, const void* input, int32_t type, bool assignUid) {
|
||||
return qSetMultiStreamInput(tinfo, input, 1, type, assignUid);
|
||||
}
|
||||
|
||||
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type, bool assignUid) {
|
||||
int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type) {
|
||||
if (tinfo == NULL) {
|
||||
return TSDB_CODE_QRY_APP_ERROR;
|
||||
}
|
||||
|
@ -110,8 +105,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
|
|||
|
||||
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
|
||||
|
||||
int32_t code =
|
||||
doSetStreamBlock(pTaskInfo->pRoot, (void**)pBlocks, numOfBlocks, type, assignUid, GET_TASKID(pTaskInfo));
|
||||
int32_t code = doSetStreamBlock(pTaskInfo->pRoot, (void**)pBlocks, numOfBlocks, type, GET_TASKID(pTaskInfo));
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
qError("%s failed to set the stream block data", GET_TASKID(pTaskInfo));
|
||||
} else {
|
||||
|
@ -337,7 +331,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
|
|||
}
|
||||
|
||||
code = dsCreateDataSinker(pSubplan->pDataSink, handle, pSinkParam);
|
||||
if(code != TSDB_CODE_SUCCESS){
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
taosMemoryFreeClear(pSinkParam);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,8 +83,6 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
|
|||
} else if (pJoinNode->inputTsOrder == ORDER_DESC) {
|
||||
pInfo->inputTsOrder = TSDB_ORDER_DESC;
|
||||
}
|
||||
//TODO: remove this when JoinNode inputTsOrder is ready
|
||||
pInfo->inputTsOrder = TSDB_ORDER_ASC;
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, NULL, destroyMergeJoinOperator, NULL, NULL, NULL);
|
||||
|
@ -116,7 +114,9 @@ void destroyMergeJoinOperator(void* param, int32_t numOfOutput) {
|
|||
|
||||
taosMemoryFreeClear(param);
|
||||
}
|
||||
static void doJoinOneRow(struct SOperatorInfo* pOperator, SSDataBlock* pRes, int32_t currRow) {
|
||||
|
||||
static void mergeJoinJoinLeftRight(struct SOperatorInfo* pOperator, SSDataBlock* pRes, int32_t currRow,
|
||||
SSDataBlock* pLeftBlock, int32_t leftPos, SSDataBlock* pRightBlock, int32_t rightPos) {
|
||||
SJoinOperatorInfo* pJoinInfo = pOperator->info;
|
||||
|
||||
for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) {
|
||||
|
@ -130,11 +130,11 @@ static void doJoinOneRow(struct SOperatorInfo* pOperator, SSDataBlock* pRes, int
|
|||
|
||||
SColumnInfoData* pSrc = NULL;
|
||||
if (pJoinInfo->pLeft->info.blockId == blockId) {
|
||||
pSrc = taosArrayGet(pJoinInfo->pLeft->pDataBlock, slotId);
|
||||
rowIndex = pJoinInfo->leftPos;
|
||||
pSrc = taosArrayGet(pLeftBlock->pDataBlock, slotId);
|
||||
rowIndex = leftPos;
|
||||
} else {
|
||||
pSrc = taosArrayGet(pJoinInfo->pRight->pDataBlock, slotId);
|
||||
rowIndex = pJoinInfo->rightPos;
|
||||
pSrc = taosArrayGet(pRightBlock->pDataBlock, slotId);
|
||||
rowIndex = rightPos;
|
||||
}
|
||||
|
||||
if (colDataIsNull_s(pSrc, rowIndex)) {
|
||||
|
@ -146,6 +146,45 @@ static void doJoinOneRow(struct SOperatorInfo* pOperator, SSDataBlock* pRes, int
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
static bool mergeJoinGetNextTimestamp(SOperatorInfo* pOperator, int64_t* pLeftTs, int64_t* pRightTs) {
|
||||
SJoinOperatorInfo* pJoinInfo = pOperator->info;
|
||||
|
||||
if (pJoinInfo->pLeft == NULL || pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) {
|
||||
SOperatorInfo* ds1 = pOperator->pDownstream[0];
|
||||
pJoinInfo->pLeft = ds1->fpSet.getNextFn(ds1);
|
||||
|
||||
pJoinInfo->leftPos = 0;
|
||||
if (pJoinInfo->pLeft == NULL) {
|
||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (pJoinInfo->pRight == NULL || pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) {
|
||||
SOperatorInfo* ds2 = pOperator->pDownstream[1];
|
||||
pJoinInfo->pRight = ds2->fpSet.getNextFn(ds2);
|
||||
|
||||
pJoinInfo->rightPos = 0;
|
||||
if (pJoinInfo->pRight == NULL) {
|
||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// only the timestamp match support for ordinary table
|
||||
SColumnInfoData* pLeftCol = taosArrayGet(pJoinInfo->pLeft->pDataBlock, pJoinInfo->leftCol.slotId);
|
||||
char* pLeftVal = colDataGetData(pLeftCol, pJoinInfo->leftPos);
|
||||
*pLeftTs = *(int64_t*)pLeftVal;
|
||||
|
||||
SColumnInfoData* pRightCol = taosArrayGet(pJoinInfo->pRight->pDataBlock, pJoinInfo->rightCol.slotId);
|
||||
char* pRightVal = colDataGetData(pRightCol, pJoinInfo->rightPos);
|
||||
*pRightTs = *(int64_t*)pRightVal;
|
||||
|
||||
ASSERT(pLeftCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
ASSERT(pRightCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes) {
|
||||
SJoinOperatorInfo* pJoinInfo = pOperator->info;
|
||||
|
||||
|
@ -154,52 +193,27 @@ static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes)
|
|||
bool asc = (pJoinInfo->inputTsOrder == TSDB_ORDER_ASC) ? true : false;
|
||||
|
||||
while (1) {
|
||||
// todo extract method
|
||||
if (pJoinInfo->pLeft == NULL || pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) {
|
||||
SOperatorInfo* ds1 = pOperator->pDownstream[0];
|
||||
pJoinInfo->pLeft = ds1->fpSet.getNextFn(ds1);
|
||||
|
||||
pJoinInfo->leftPos = 0;
|
||||
if (pJoinInfo->pLeft == NULL) {
|
||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||
break;
|
||||
}
|
||||
int64_t leftTs = 0;
|
||||
int64_t rightTs = 0;
|
||||
bool hasNextTs = mergeJoinGetNextTimestamp(pOperator, &leftTs, &rightTs);
|
||||
if (!hasNextTs) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (pJoinInfo->pRight == NULL || pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) {
|
||||
SOperatorInfo* ds2 = pOperator->pDownstream[1];
|
||||
pJoinInfo->pRight = ds2->fpSet.getNextFn(ds2);
|
||||
|
||||
pJoinInfo->rightPos = 0;
|
||||
if (pJoinInfo->pRight == NULL) {
|
||||
setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SColumnInfoData* pLeftCol = taosArrayGet(pJoinInfo->pLeft->pDataBlock, pJoinInfo->leftCol.slotId);
|
||||
char* pLeftVal = colDataGetData(pLeftCol, pJoinInfo->leftPos);
|
||||
|
||||
SColumnInfoData* pRightCol = taosArrayGet(pJoinInfo->pRight->pDataBlock, pJoinInfo->rightCol.slotId);
|
||||
char* pRightVal = colDataGetData(pRightCol, pJoinInfo->rightPos);
|
||||
|
||||
// only the timestamp match support for ordinary table
|
||||
ASSERT(pLeftCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||
if (*(int64_t*)pLeftVal == *(int64_t*)pRightVal) {
|
||||
doJoinOneRow(pOperator, pRes, nrows);
|
||||
if (leftTs == rightTs) {
|
||||
mergeJoinJoinLeftRight(pOperator, pRes, nrows,
|
||||
pJoinInfo->pLeft, pJoinInfo->leftPos, pJoinInfo->pRight, pJoinInfo->rightPos);
|
||||
pJoinInfo->leftPos += 1;
|
||||
pJoinInfo->rightPos += 1;
|
||||
|
||||
nrows += 1;
|
||||
} else if (asc && *(int64_t*)pLeftVal < *(int64_t*)pRightVal ||
|
||||
!asc && *(int64_t*)pLeftVal > *(int64_t*)pRightVal) {
|
||||
} else if (asc && leftTs < rightTs || !asc && leftTs > rightTs) {
|
||||
pJoinInfo->leftPos += 1;
|
||||
|
||||
if (pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) {
|
||||
continue;
|
||||
}
|
||||
} else if (asc && *(int64_t*)pLeftVal > *(int64_t*)pRightVal ||
|
||||
!asc && *(int64_t*)pLeftVal < *(int64_t*)pRightVal) {
|
||||
} else if (asc && leftTs > rightTs || !asc && leftTs < rightTs) {
|
||||
pJoinInfo->rightPos += 1;
|
||||
if (pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) {
|
||||
continue;
|
||||
|
|
|
@ -25,6 +25,7 @@ extern "C" {
|
|||
typedef int32_t (*FTranslateFunc)(SFunctionNode* pFunc, char* pErrBuf, int32_t len);
|
||||
typedef EFuncDataRequired (*FFuncDataRequired)(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||
typedef int32_t (*FCreateMergeFuncParameters)(SNodeList* pRawParameters, SNode* pPartialRes, SNodeList** pParameters);
|
||||
typedef EFuncDataRequired (*FFuncDynDataRequired)(void* pRes, STimeWindow* pTimeWindow);
|
||||
|
||||
typedef struct SBuiltinFuncDefinition {
|
||||
const char* name;
|
||||
|
@ -32,6 +33,7 @@ typedef struct SBuiltinFuncDefinition {
|
|||
uint64_t classification;
|
||||
FTranslateFunc translateFunc;
|
||||
FFuncDataRequired dataRequiredFunc;
|
||||
FFuncDynDataRequired dynDataRequiredFunc;
|
||||
FExecGetEnv getEnvFunc;
|
||||
FExecInit initFunc;
|
||||
FExecProcess processFunc;
|
||||
|
|
|
@ -466,7 +466,7 @@ int32_t functionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||
|
||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||
pResInfo->isNullRes = (pResInfo->numOfRes == 0) ? 1 : 0;
|
||||
pResInfo->isNullRes = (pResInfo->isNullRes == 1) ? 1 : (pResInfo->numOfRes == 0);
|
||||
|
||||
char* in = GET_ROWCELL_INTERBUF(pResInfo);
|
||||
colDataAppend(pCol, pBlock->info.rows, in, pResInfo->isNullRes);
|
||||
|
@ -663,7 +663,8 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) {
|
|||
|
||||
// check for overflow
|
||||
if (IS_FLOAT_TYPE(type) && (isinf(pSumRes->dsum) || isnan(pSumRes->dsum))) {
|
||||
numOfElem = 0;
|
||||
GET_RES_INFO(pCtx)->isNullRes = 1;
|
||||
numOfElem = 1;
|
||||
}
|
||||
|
||||
_sum_over:
|
||||
|
@ -1605,7 +1606,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
int32_t currentRow = pBlock->info.rows;
|
||||
|
||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||
pEntryInfo->isNullRes = (pEntryInfo->numOfRes == 0);
|
||||
pEntryInfo->isNullRes = (pEntryInfo->isNullRes == 1) ? 1 : (pEntryInfo->numOfRes == 0);
|
||||
|
||||
if (pCol->info.type == TSDB_DATA_TYPE_FLOAT) {
|
||||
float v = *(double*)&pRes->v;
|
||||
|
|
|
@ -103,6 +103,13 @@ EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWin
|
|||
return funcMgtBuiltins[pFunc->funcId].dataRequiredFunc(pFunc, pTimeWindow);
|
||||
}
|
||||
|
||||
EFuncDataRequired fmFuncDynDataRequired(int32_t funcId, void* pRes, STimeWindow* pTimeWindow) {
|
||||
if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||
return TSDB_CODE_FAILED;
|
||||
}
|
||||
return funcMgtBuiltins[funcId].dynDataRequiredFunc(pRes, pTimeWindow);
|
||||
}
|
||||
|
||||
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet) {
|
||||
if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||
return TSDB_CODE_FAILED;
|
||||
|
|
|
@ -401,7 +401,8 @@ static int32_t logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModi
|
|||
COPY_SCALAR_FIELD(tableId);
|
||||
COPY_SCALAR_FIELD(stableId);
|
||||
COPY_SCALAR_FIELD(tableType);
|
||||
COPY_CHAR_ARRAY_FIELD(tableFName);
|
||||
COPY_CHAR_ARRAY_FIELD(tableName);
|
||||
COPY_CHAR_ARRAY_FIELD(tsColName);
|
||||
COPY_OBJECT_FIELD(deleteTimeRange, sizeof(STimeWindow));
|
||||
CLONE_OBJECT_FIELD(pVgroupList, vgroupsInfoClone);
|
||||
CLONE_NODE_LIST_FIELD(pInsertCols);
|
||||
|
|
|
@ -1712,6 +1712,7 @@ static int32_t jsonToPhysiProjectNode(const SJson* pJson, void* pObj) {
|
|||
}
|
||||
|
||||
static const char* jkJoinPhysiPlanJoinType = "JoinType";
|
||||
static const char* jkJoinPhysiPlanInputTsOrder = "InputTsOrder";
|
||||
static const char* jkJoinPhysiPlanMergeCondition = "MergeCondition";
|
||||
static const char* jkJoinPhysiPlanOnConditions = "OnConditions";
|
||||
static const char* jkJoinPhysiPlanTargets = "Targets";
|
||||
|
@ -1723,6 +1724,9 @@ static int32_t physiJoinNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanJoinType, pNode->joinType);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkJoinPhysiPlanInputTsOrder, pNode->inputTsOrder);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkJoinPhysiPlanMergeCondition, nodeToJson, pNode->pMergeCondition);
|
||||
}
|
||||
|
@ -1742,7 +1746,9 @@ static int32_t jsonToPhysiJoinNode(const SJson* pJson, void* pObj) {
|
|||
int32_t code = jsonToPhysicPlanNode(pJson, pObj);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
tjsonGetNumberValue(pJson, jkJoinPhysiPlanJoinType, pNode->joinType, code);
|
||||
;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
tjsonGetNumberValue(pJson, jkJoinPhysiPlanInputTsOrder, pNode->inputTsOrder, code);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkJoinPhysiPlanOnConditions, &pNode->pOnConditions);
|
||||
|
@ -2326,7 +2332,7 @@ static int32_t physiQueryInsertNodeToJson(const void* pObj, SJson* pJson) {
|
|||
code = tjsonAddIntegerToObject(pJson, jkQueryInsertPhysiPlanTableType, pNode->tableType);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddStringToObject(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableFName);
|
||||
code = tjsonAddStringToObject(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableName);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkQueryInsertPhysiPlanVgId, pNode->vgId);
|
||||
|
@ -2355,7 +2361,7 @@ static int32_t jsonToPhysiQueryInsertNode(const SJson* pJson, void* pObj) {
|
|||
code = tjsonGetTinyIntValue(pJson, jkQueryInsertPhysiPlanTableType, &pNode->tableType);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetStringValue(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableFName);
|
||||
code = tjsonGetStringValue(pJson, jkQueryInsertPhysiPlanTableFName, pNode->tableName);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetIntValue(pJson, jkQueryInsertPhysiPlanVgId, &pNode->vgId);
|
||||
|
@ -2370,6 +2376,7 @@ static int32_t jsonToPhysiQueryInsertNode(const SJson* pJson, void* pObj) {
|
|||
static const char* jkDeletePhysiPlanTableId = "TableId";
|
||||
static const char* jkDeletePhysiPlanTableType = "TableType";
|
||||
static const char* jkDeletePhysiPlanTableFName = "TableFName";
|
||||
static const char* jkDeletePhysiPlanTsColName = "TsColName";
|
||||
static const char* jkDeletePhysiPlanDeleteTimeRangeStartKey = "DeleteTimeRangeStartKey";
|
||||
static const char* jkDeletePhysiPlanDeleteTimeRangeEndKey = "DeleteTimeRangeEndKey";
|
||||
static const char* jkDeletePhysiPlanAffectedRows = "AffectedRows";
|
||||
|
@ -2387,6 +2394,9 @@ static int32_t physiDeleteNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddStringToObject(pJson, jkDeletePhysiPlanTableFName, pNode->tableFName);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddStringToObject(pJson, jkDeletePhysiPlanTsColName, pNode->tsColName);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddIntegerToObject(pJson, jkDeletePhysiPlanDeleteTimeRangeStartKey, pNode->deleteTimeRange.skey);
|
||||
}
|
||||
|
@ -2413,6 +2423,9 @@ static int32_t jsonToPhysiDeleteNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetStringValue(pJson, jkDeletePhysiPlanTableFName, pNode->tableFName);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetStringValue(pJson, jkDeletePhysiPlanTsColName, pNode->tsColName);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonGetBigIntValue(pJson, jkDeletePhysiPlanDeleteTimeRangeStartKey, &pNode->deleteTimeRange.skey);
|
||||
}
|
||||
|
|
|
@ -1292,8 +1292,8 @@ static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDelet
|
|||
pModify->modifyType = MODIFY_TABLE_TYPE_DELETE;
|
||||
pModify->tableId = pRealTable->pMeta->uid;
|
||||
pModify->tableType = pRealTable->pMeta->tableType;
|
||||
snprintf(pModify->tableFName, sizeof(pModify->tableFName), "%d.%s.%s", pCxt->pPlanCxt->acctId,
|
||||
pRealTable->table.dbName, pRealTable->table.tableName);
|
||||
snprintf(pModify->tableName, sizeof(pModify->tableName), "%s", pRealTable->table.tableName);
|
||||
strcpy(pModify->tsColName, pRealTable->pMeta->schema->name);
|
||||
pModify->deleteTimeRange = pDelete->timeRange;
|
||||
pModify->pAffectedRows = nodesCloneNode(pDelete->pCountFunc);
|
||||
if (NULL == pModify->pAffectedRows) {
|
||||
|
@ -1342,8 +1342,7 @@ static int32_t createVnodeModifLogicNodeByInsert(SLogicPlanContext* pCxt, SInser
|
|||
pModify->tableId = pRealTable->pMeta->uid;
|
||||
pModify->stableId = pRealTable->pMeta->suid;
|
||||
pModify->tableType = pRealTable->pMeta->tableType;
|
||||
snprintf(pModify->tableFName, sizeof(pModify->tableFName), "%d.%s.%s", pCxt->pPlanCxt->acctId,
|
||||
pRealTable->table.dbName, pRealTable->table.tableName);
|
||||
snprintf(pModify->tableName, sizeof(pModify->tableName), "%s", pRealTable->table.tableName);
|
||||
TSWAP(pModify->pVgroupList, pRealTable->pVgroupList);
|
||||
pModify->pInsertCols = nodesCloneList(pInsert->pCols);
|
||||
if (NULL == pModify->pInsertCols) {
|
||||
|
|
|
@ -633,6 +633,7 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
|||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
pJoin->joinType = pJoinLogicNode->joinType;
|
||||
pJoin->inputTsOrder = pJoinLogicNode->inputTsOrder;
|
||||
setNodeSlotId(pCxt, pLeftDesc->dataBlockId, pRightDesc->dataBlockId, pJoinLogicNode->pMergeCondition,
|
||||
&pJoin->pMergeCondition);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -1587,7 +1588,7 @@ static int32_t createQueryInserter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNod
|
|||
pInserter->tableId = pModify->tableId;
|
||||
pInserter->stableId = pModify->stableId;
|
||||
pInserter->tableType = pModify->tableType;
|
||||
strcpy(pInserter->tableFName, pModify->tableFName);
|
||||
strcpy(pInserter->tableName, pModify->tableName);
|
||||
pInserter->vgId = pModify->pVgroupList->vgroups[0].vgId;
|
||||
pInserter->epSet = pModify->pVgroupList->vgroups[0].epSet;
|
||||
vgroupInfoToNodeAddr(pModify->pVgroupList->vgroups, &pSubplan->execNode);
|
||||
|
@ -1637,7 +1638,8 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode*
|
|||
|
||||
pDeleter->tableId = pModify->tableId;
|
||||
pDeleter->tableType = pModify->tableType;
|
||||
strcpy(pDeleter->tableFName, pModify->tableFName);
|
||||
strcpy(pDeleter->tableFName, pModify->tableName);
|
||||
strcpy(pDeleter->tsColName, pModify->tsColName);
|
||||
pDeleter->deleteTimeRange = pModify->deleteTimeRange;
|
||||
|
||||
int32_t code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pAffectedRows,
|
||||
|
|
|
@ -283,7 +283,8 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes
|
|||
pRes->skey = pDelRes->skey;
|
||||
pRes->ekey = pDelRes->ekey;
|
||||
pRes->affectedRows = pDelRes->affectedRows;
|
||||
strcpy(pRes->tableFName, pDelRes->tableFName);
|
||||
strcpy(pRes->tableFName, pDelRes->tableName);
|
||||
strcpy(pRes->tsColName, pDelRes->tsColName);
|
||||
taosMemoryFree(output.pData);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
|
@ -227,6 +227,8 @@ int32_t streamDispatchOneReq(SStreamTask* pTask, const SStreamDispatchReq* pReq,
|
|||
msg.pCont = buf;
|
||||
msg.msgType = pTask->dispatchMsgType;
|
||||
|
||||
qDebug("dispatch from task %d to task %d node %d", pTask->taskId, pReq->taskId, vgId);
|
||||
|
||||
tmsgSendReq(pEpSet, &msg);
|
||||
|
||||
code = 0;
|
||||
|
@ -281,8 +283,10 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
|||
return code;
|
||||
|
||||
} else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) {
|
||||
SArray* vgInfo = pTask->shuffleDispatcher.dbInfo.pVgroupInfos;
|
||||
ASSERT(pTask->shuffleDispatcher.waitingRspCnt == 0);
|
||||
int32_t rspCnt = atomic_load_32(&pTask->shuffleDispatcher.waitingRspCnt);
|
||||
ASSERT(rspCnt == 0);
|
||||
|
||||
SArray* vgInfo = pTask->shuffleDispatcher.dbInfo.pVgroupInfos;
|
||||
int32_t vgSz = taosArrayGetSize(vgInfo);
|
||||
SStreamDispatchReq* pReqs = taosMemoryCalloc(vgSz, sizeof(SStreamDispatchReq));
|
||||
if (pReqs == NULL) {
|
||||
|
@ -301,7 +305,10 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
|||
if (pReqs[i].data == NULL || pReqs[i].dataLen == NULL) {
|
||||
goto FAIL_SHUFFLE_DISPATCH;
|
||||
}
|
||||
SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, i);
|
||||
pReqs[i].taskId = pVgInfo->taskId;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < blockNum; i++) {
|
||||
SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i);
|
||||
char* ctbName = buildCtbNameByGroupId(pTask->shuffleDispatcher.stbFullName, pDataBlock->info.groupId);
|
||||
|
@ -309,6 +316,9 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
|||
// TODO: get hash function by hashMethod
|
||||
uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName));
|
||||
|
||||
taosMemoryFree(ctbName);
|
||||
|
||||
bool found = false;
|
||||
// TODO: optimize search
|
||||
int32_t j;
|
||||
for (j = 0; j < vgSz; j++) {
|
||||
|
@ -318,12 +328,17 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
|||
if (streamAddBlockToDispatchMsg(pDataBlock, &pReqs[j]) < 0) {
|
||||
goto FAIL_SHUFFLE_DISPATCH;
|
||||
}
|
||||
pReqs[j].taskId = pVgInfo->taskId;
|
||||
if (pReqs[j].blockNum == 0) {
|
||||
atomic_add_fetch_32(&pTask->shuffleDispatcher.waitingRspCnt, 1);
|
||||
}
|
||||
pReqs[j].blockNum++;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT(found);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < vgSz; i++) {
|
||||
if (pReqs[i].blockNum > 0) {
|
||||
// send
|
||||
|
@ -331,7 +346,6 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
|
|||
if (streamDispatchOneReq(pTask, &pReqs[i], pVgInfo->vgId, &pVgInfo->epSet) < 0) {
|
||||
goto FAIL_SHUFFLE_DISPATCH;
|
||||
}
|
||||
pTask->shuffleDispatcher.waitingRspCnt++;
|
||||
}
|
||||
}
|
||||
code = 0;
|
||||
|
|
|
@ -22,22 +22,22 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes)
|
|||
SStreamQueueItem* pItem = (SStreamQueueItem*)data;
|
||||
if (pItem->type == STREAM_INPUT__GET_RES) {
|
||||
SStreamTrigger* pTrigger = (SStreamTrigger*)data;
|
||||
qSetMultiStreamInput(exec, pTrigger->pBlock, 1, STREAM_INPUT__DATA_BLOCK, false);
|
||||
qSetMultiStreamInput(exec, pTrigger->pBlock, 1, STREAM_INPUT__DATA_BLOCK);
|
||||
} else if (pItem->type == STREAM_INPUT__DATA_SUBMIT) {
|
||||
ASSERT(pTask->isDataScan);
|
||||
SStreamDataSubmit* pSubmit = (SStreamDataSubmit*)data;
|
||||
qDebug("task %d %p set submit input %p %p %d 1", pTask->taskId, pTask, pSubmit, pSubmit->data, *pSubmit->dataRef);
|
||||
qSetStreamInput(exec, pSubmit->data, STREAM_INPUT__DATA_SUBMIT, false);
|
||||
qSetMultiStreamInput(exec, pSubmit->data, 1, STREAM_INPUT__DATA_SUBMIT);
|
||||
} else if (pItem->type == STREAM_INPUT__DATA_BLOCK || pItem->type == STREAM_INPUT__DATA_RETRIEVE) {
|
||||
SStreamDataBlock* pBlock = (SStreamDataBlock*)data;
|
||||
SArray* blocks = pBlock->blocks;
|
||||
qDebug("task %d %p set ssdata input", pTask->taskId, pTask);
|
||||
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__DATA_BLOCK, false);
|
||||
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__DATA_BLOCK);
|
||||
} else if (pItem->type == STREAM_INPUT__MERGED_SUBMIT) {
|
||||
SStreamMergedSubmit* pMerged = (SStreamMergedSubmit*)data;
|
||||
SArray* blocks = pMerged->reqs;
|
||||
qDebug("task %d %p set submit input (merged), batch num: %d", pTask->taskId, pTask, (int32_t)blocks->size);
|
||||
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__MERGED_SUBMIT, false);
|
||||
qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_INPUT__MERGED_SUBMIT);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
|
|||
if (tEncodeI32(pEncoder, pTask->selfChildId) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1;
|
||||
if (tEncodeSEpSet(pEncoder, &pTask->epSet) < 0) return -1;
|
||||
if (tEncodeI32(pEncoder, pTask->numOfVgroups) < 0) return -1;
|
||||
/*if (tEncodeI32(pEncoder, pTask->numOfVgroups) < 0) return -1;*/
|
||||
|
||||
int32_t epSz = taosArrayGetSize(pTask->childEpInfo);
|
||||
if (tEncodeI32(pEncoder, epSz) < 0) return -1;
|
||||
|
@ -119,7 +119,7 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
|
|||
if (tDecodeI32(pDecoder, &pTask->selfChildId) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1;
|
||||
if (tDecodeSEpSet(pDecoder, &pTask->epSet) < 0) return -1;
|
||||
if (tDecodeI32(pDecoder, &pTask->numOfVgroups) < 0) return -1;
|
||||
/*if (tDecodeI32(pDecoder, &pTask->numOfVgroups) < 0) return -1;*/
|
||||
|
||||
int32_t epSz;
|
||||
if (tDecodeI32(pDecoder, &epSz) < 0) return -1;
|
||||
|
|
|
@ -76,14 +76,17 @@ int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg)
|
|||
|
||||
ASSERT(xFree);
|
||||
|
||||
for (int iOvfl = 0; iOvfl < pPage->nOverflow; iOvfl++) {
|
||||
tdbOsFree(pPage->apOvfl[iOvfl]);
|
||||
}
|
||||
|
||||
ptr = pPage->pData;
|
||||
xFree(arg, ptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int,
|
||||
TXN *, SBTree *pBt)) {
|
||||
void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt)) {
|
||||
pPage->pPageHdr = pPage->pData + szAmHdr;
|
||||
TDB_PAGE_NCELLS_SET(pPage, 0);
|
||||
TDB_PAGE_CCELLS_SET(pPage, pPage->pageSize - sizeof(SPageFtr));
|
||||
|
@ -99,8 +102,7 @@ void tdbPageZero(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell
|
|||
ASSERT((u8 *)pPage->pPageFtr == pPage->pFreeEnd);
|
||||
}
|
||||
|
||||
void tdbPageInit(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int,
|
||||
TXN *, SBTree *pBt)) {
|
||||
void tdbPageInit(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell *, int, TXN *, SBTree *pBt)) {
|
||||
pPage->pPageHdr = pPage->pData + szAmHdr;
|
||||
pPage->pCellIdx = pPage->pPageHdr + TDB_PAGE_HDR_SIZE(pPage);
|
||||
pPage->pFreeStart = pPage->pCellIdx + TDB_PAGE_OFFSET_SIZE(pPage) * TDB_PAGE_NCELLS(pPage);
|
||||
|
@ -124,9 +126,8 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
|
|||
|
||||
nFree = TDB_PAGE_NFREE(pPage);
|
||||
nCells = TDB_PAGE_NCELLS(pPage);
|
||||
iOvfl = 0;
|
||||
|
||||
for (; iOvfl < pPage->nOverflow; iOvfl++) {
|
||||
for (iOvfl = 0; iOvfl < pPage->nOverflow; ++iOvfl) {
|
||||
if (pPage->aiOvfl[iOvfl] >= idx) {
|
||||
break;
|
||||
}
|
||||
|
@ -146,6 +147,8 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
|
|||
pNewCell = (SCell *)tdbOsMalloc(szCell);
|
||||
memcpy(pNewCell, pCell, szCell);
|
||||
|
||||
tdbDebug("tdbPage/new ovfl cell: %p", pNewCell);
|
||||
|
||||
pPage->apOvfl[iOvfl] = pNewCell;
|
||||
pPage->aiOvfl[iOvfl] = idx;
|
||||
pPage->nOverflow++;
|
||||
|
@ -193,6 +196,8 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) {
|
|||
for (; iOvfl < pPage->nOverflow; iOvfl++) {
|
||||
if (pPage->aiOvfl[iOvfl] == idx) {
|
||||
// remove the over flow cell
|
||||
tdbOsFree(pPage->apOvfl[iOvfl]);
|
||||
tdbDebug("tdbPage/free ovfl cell: %p", pPage->apOvfl[iOvfl]);
|
||||
for (; (++iOvfl) < pPage->nOverflow;) {
|
||||
pPage->aiOvfl[iOvfl - 1] = pPage->aiOvfl[iOvfl] - 1;
|
||||
pPage->apOvfl[iOvfl - 1] = pPage->apOvfl[iOvfl];
|
||||
|
@ -248,7 +253,7 @@ void tdbPageCopy(SPage *pFromPage, SPage *pToPage) {
|
|||
|
||||
int tdbPageCapacity(int pageSize, int amHdrSize) {
|
||||
int szPageHdr;
|
||||
int minCellIndexSize; // at least one cell in cell index
|
||||
int minCellIndexSize; // at least one cell in cell index
|
||||
|
||||
if (pageSize < 65536) {
|
||||
szPageHdr = pageMethods.szPageHdr;
|
||||
|
|
|
@ -60,6 +60,7 @@ typedef struct SCliThrd {
|
|||
int64_t pid; // pid
|
||||
uv_loop_t* loop;
|
||||
SAsyncPool* asyncPool;
|
||||
uv_idle_t* idle;
|
||||
uv_timer_t timer;
|
||||
void* pool; // conn pool
|
||||
|
||||
|
@ -116,6 +117,7 @@ static void cliSendCb(uv_write_t* req, int status);
|
|||
// callback after conn to server
|
||||
static void cliConnCb(uv_connect_t* req, int status);
|
||||
static void cliAsyncCb(uv_async_t* handle);
|
||||
static void cliIdleCb(uv_idle_t* handle);
|
||||
|
||||
static int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg);
|
||||
|
||||
|
@ -962,6 +964,10 @@ static void cliAsyncCb(uv_async_t* handle) {
|
|||
}
|
||||
if (pThrd->stopMsg != NULL) cliHandleQuit(pThrd->stopMsg, pThrd);
|
||||
}
|
||||
static void cliIdleCb(uv_idle_t* handle) {
|
||||
SCliThrd* thrd = handle->data;
|
||||
tTrace("do idle work");
|
||||
}
|
||||
|
||||
static void* cliWorkThread(void* arg) {
|
||||
SCliThrd* pThrd = (SCliThrd*)arg;
|
||||
|
@ -1024,6 +1030,11 @@ static SCliThrd* createThrdObj() {
|
|||
uv_timer_init(pThrd->loop, &pThrd->timer);
|
||||
pThrd->timer.data = pThrd;
|
||||
|
||||
// pThrd->idle = taosMemoryCalloc(1, sizeof(uv_idle_t));
|
||||
// uv_idle_init(pThrd->loop, pThrd->idle);
|
||||
// pThrd->idle->data = pThrd;
|
||||
// uv_idle_start(pThrd->idle, cliIdleCb);
|
||||
|
||||
pThrd->pool = createConnPool(4);
|
||||
transDQCreate(pThrd->loop, &pThrd->delayQueue);
|
||||
|
||||
|
@ -1045,6 +1056,8 @@ static void destroyThrdObj(SCliThrd* pThrd) {
|
|||
|
||||
transDQDestroy(pThrd->delayQueue, destroyCmsg);
|
||||
transDQDestroy(pThrd->timeoutQueue, NULL);
|
||||
|
||||
taosMemoryFree(pThrd->idle);
|
||||
taosMemoryFree(pThrd->loop);
|
||||
taosMemoryFree(pThrd);
|
||||
}
|
||||
|
|
|
@ -152,16 +152,18 @@ int transDumpFromBuffer(SConnBuffer* connBuf, char** buf) {
|
|||
|
||||
int transResetBuffer(SConnBuffer* connBuf) {
|
||||
SConnBuffer* p = connBuf;
|
||||
if (p->total <= p->len) {
|
||||
if (p->total < p->len) {
|
||||
int left = p->len - p->total;
|
||||
memmove(p->buf, p->buf + p->total, left);
|
||||
p->left = -1;
|
||||
p->total = 0;
|
||||
p->len = left;
|
||||
} else {
|
||||
} else if (p->total == p->len) {
|
||||
p->left = -1;
|
||||
p->total = 0;
|
||||
p->len = 0;
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ static void uvHandleReq(SSvrConn* pConn) {
|
|||
transMsg.msgType = pHead->msgType;
|
||||
transMsg.code = pHead->code;
|
||||
|
||||
transClearBuffer(&pConn->readBuf);
|
||||
// transClearBuffer(&pConn->readBuf);
|
||||
|
||||
pConn->inType = pHead->msgType;
|
||||
if (pConn->status == ConnNormal) {
|
||||
|
|
|
@ -61,26 +61,31 @@ static inline int32_t compareWalFileInfo(const void* pLeft, const void* pRight)
|
|||
}
|
||||
|
||||
static inline int64_t walGetLastFileSize(SWal* pWal) {
|
||||
if (taosArrayGetSize(pWal->fileInfoSet) == 0) return 0;
|
||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet);
|
||||
return pInfo->fileSize;
|
||||
}
|
||||
|
||||
static inline int64_t walGetLastFileFirstVer(SWal* pWal) {
|
||||
if (taosArrayGetSize(pWal->fileInfoSet) == 0) return -1;
|
||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGetLast(pWal->fileInfoSet);
|
||||
return pInfo->firstVer;
|
||||
}
|
||||
|
||||
static inline int64_t walGetCurFileFirstVer(SWal* pWal) {
|
||||
if (pWal->writeCur == -1) return -1;
|
||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
||||
return pInfo->firstVer;
|
||||
}
|
||||
|
||||
static inline int64_t walGetCurFileLastVer(SWal* pWal) {
|
||||
if (pWal->writeCur == -1) return -1;
|
||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
||||
return pInfo->firstVer;
|
||||
}
|
||||
|
||||
static inline int64_t walGetCurFileOffset(SWal* pWal) {
|
||||
if (pWal->writeCur == -1) return -1;
|
||||
SWalFileInfo* pInfo = (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
||||
return pInfo->fileSize;
|
||||
}
|
||||
|
@ -88,6 +93,7 @@ static inline int64_t walGetCurFileOffset(SWal* pWal) {
|
|||
static inline bool walCurFileClosed(SWal* pWal) { return taosArrayGetSize(pWal->fileInfoSet) != pWal->writeCur; }
|
||||
|
||||
static inline SWalFileInfo* walGetCurFileInfo(SWal* pWal) {
|
||||
if (pWal->writeCur == -1) return NULL;
|
||||
return (SWalFileInfo*)taosArrayGet(pWal->fileInfoSet, pWal->writeCur);
|
||||
}
|
||||
|
||||
|
|
|
@ -266,6 +266,7 @@ static void pushfrontNodeInEntryList(SCacheEntry *pEntry, SCacheNode *pNode) {
|
|||
pNode->pNext = pEntry->next;
|
||||
pEntry->next = pNode;
|
||||
pEntry->num += 1;
|
||||
ASSERT((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0));
|
||||
}
|
||||
|
||||
static void removeNodeInEntryList(SCacheEntry *pe, SCacheNode *prev, SCacheNode *pNode) {
|
||||
|
@ -278,6 +279,7 @@ static void removeNodeInEntryList(SCacheEntry *pe, SCacheNode *prev, SCacheNode
|
|||
|
||||
pNode->pNext = NULL;
|
||||
pe->num -= 1;
|
||||
ASSERT((pe->next && pe->num > 0) || (NULL == pe->next && pe->num == 0));
|
||||
}
|
||||
|
||||
static FORCE_INLINE SCacheEntry *doFindEntry(SCacheObj *pCacheObj, const void *key, size_t keyLen) {
|
||||
|
@ -657,15 +659,18 @@ void doTraverseElems(SCacheObj *pCacheObj, bool (*fp)(void *param, SCacheNode *p
|
|||
|
||||
taosWLockLatch(&pEntry->latch);
|
||||
|
||||
SCacheNode **pPre = &pEntry->next;
|
||||
SCacheNode *pNode = pEntry->next;
|
||||
while (pNode != NULL) {
|
||||
SCacheNode *next = pNode->pNext;
|
||||
|
||||
if (fp(pSup, pNode)) {
|
||||
pPre = &pNode->pNext;
|
||||
pNode = pNode->pNext;
|
||||
} else {
|
||||
pEntry->next = next;
|
||||
*pPre = next;
|
||||
pEntry->num -= 1;
|
||||
ASSERT((pEntry->next && pEntry->num > 0) || (NULL == pEntry->next && pEntry->num == 0));
|
||||
|
||||
atomic_sub_fetch_ptr(&pCacheObj->numOfElems, 1);
|
||||
pNode = next;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#======================b1-start===============
|
||||
|
||||
# ---- user
|
||||
# ---- user ----
|
||||
./test.sh -f tsim/user/basic.sim
|
||||
./test.sh -f tsim/user/password.sim
|
||||
./test.sh -f tsim/user/privilege_db.sim
|
||||
|
@ -58,13 +58,13 @@
|
|||
# unsupport ./test.sh -f tsim/dnode/vnode_clean.sim
|
||||
./test.sh -f tsim/dnode/use_dropped_dnode.sim
|
||||
|
||||
# ---- import
|
||||
# ---- import ----
|
||||
./test.sh -f tsim/import/basic.sim
|
||||
./test.sh -f tsim/import/commit.sim
|
||||
./test.sh -f tsim/import/large.sim
|
||||
./test.sh -f tsim/import/replica1.sim
|
||||
|
||||
# ---- insert
|
||||
# ---- insert ----
|
||||
./test.sh -f tsim/insert/backquote.sim
|
||||
./test.sh -f tsim/insert/basic.sim
|
||||
./test.sh -f tsim/insert/basic0.sim
|
||||
|
@ -110,7 +110,7 @@
|
|||
./test.sh -f tsim/parser/fill.sim
|
||||
./test.sh -f tsim/parser/first_last.sim
|
||||
./test.sh -f tsim/parser/fourArithmetic-basic.sim
|
||||
# TD-17659 ./test.sh -f tsim/parser/function.sim
|
||||
./test.sh -f tsim/parser/function.sim
|
||||
./test.sh -f tsim/parser/groupby-basic.sim
|
||||
./test.sh -f tsim/parser/groupby.sim
|
||||
./test.sh -f tsim/parser/having_child.sim
|
||||
|
@ -132,8 +132,8 @@
|
|||
./test.sh -f tsim/parser/lastrow.sim
|
||||
./test.sh -f tsim/parser/lastrow2.sim
|
||||
./test.sh -f tsim/parser/like.sim
|
||||
# TD-17464 ./test.sh -f tsim/parser/limit.sim
|
||||
# TD-17464 ./test.sh -f tsim/parser/limit1.sim
|
||||
./test.sh -f tsim/parser/limit.sim
|
||||
./test.sh -f tsim/parser/limit1.sim
|
||||
# TD-17623 ./test.sh -f tsim/parser/limit2.sim
|
||||
./test.sh -f tsim/parser/mixed_blocks.sim
|
||||
./test.sh -f tsim/parser/nchar.sim
|
||||
|
@ -145,7 +145,7 @@
|
|||
./test.sh -f tsim/parser/select_across_vnodes.sim
|
||||
./test.sh -f tsim/parser/select_distinct_tag.sim
|
||||
./test.sh -f tsim/parser/select_from_cache_disk.sim
|
||||
# TD-17659 ./test.sh -f tsim/parser/select_with_tags.sim
|
||||
# TD-17832 ./test.sh -f tsim/parser/select_with_tags.sim
|
||||
./test.sh -f tsim/parser/selectResNum.sim
|
||||
./test.sh -f tsim/parser/set_tag_vals.sim
|
||||
./test.sh -f tsim/parser/single_row_in_tb.sim
|
||||
|
@ -164,7 +164,7 @@
|
|||
# TD-17704 ./test.sh -f tsim/parser/union_sysinfo.sim
|
||||
# TD-17661 ./test.sh -f tsim/parser/where.sim
|
||||
|
||||
# ---- query
|
||||
# ---- query ----
|
||||
./test.sh -f tsim/query/charScalarFunction.sim
|
||||
# ./test.sh -f tsim/query/explain.sim
|
||||
./test.sh -f tsim/query/interval-offset.sim
|
||||
|
@ -190,7 +190,7 @@
|
|||
./test.sh -f tsim/mnode/basic4.sim
|
||||
./test.sh -f tsim/mnode/basic5.sim
|
||||
|
||||
# ---- show
|
||||
# ---- show ----
|
||||
./test.sh -f tsim/show/basic.sim
|
||||
|
||||
# ---- table
|
||||
|
@ -260,7 +260,7 @@
|
|||
./test.sh -f tsim/tmq/snapshot.sim
|
||||
./test.sh -f tsim/tmq/snapshot1.sim
|
||||
|
||||
# --- stable
|
||||
# --- stable ----
|
||||
./test.sh -f tsim/stable/alter_comment.sim
|
||||
./test.sh -f tsim/stable/alter_count.sim
|
||||
./test.sh -f tsim/stable/alter_import.sim
|
||||
|
@ -274,7 +274,6 @@
|
|||
./test.sh -f tsim/stable/dnode3.sim
|
||||
./test.sh -f tsim/stable/metrics.sim
|
||||
./test.sh -f tsim/stable/refcount.sim
|
||||
./test.sh -f tsim/stable/show.sim
|
||||
./test.sh -f tsim/stable/tag_add.sim
|
||||
./test.sh -f tsim/stable/tag_drop.sim
|
||||
./test.sh -f tsim/stable/tag_filter.sim
|
||||
|
@ -298,8 +297,9 @@
|
|||
# --- sma
|
||||
./test.sh -f tsim/sma/drop_sma.sim
|
||||
./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim
|
||||
./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim
|
||||
./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim
|
||||
# temp disable
|
||||
#./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim
|
||||
#./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim
|
||||
|
||||
# --- valgrind
|
||||
./test.sh -f tsim/valgrind/checkError1.sim
|
||||
|
@ -308,6 +308,7 @@
|
|||
./test.sh -f tsim/valgrind/checkError4.sim
|
||||
./test.sh -f tsim/valgrind/checkError5.sim
|
||||
./test.sh -f tsim/valgrind/checkError6.sim
|
||||
./test.sh -f tsim/valgrind/checkError7.sim
|
||||
|
||||
# --- vnode
|
||||
# unsupport ./test.sh -f tsim/vnode/replica3_basic.sim
|
||||
|
@ -350,13 +351,13 @@
|
|||
./test.sh -f tsim/column/metrics.sim
|
||||
./test.sh -f tsim/column/table.sim
|
||||
|
||||
# ---- compress
|
||||
# ---- compress ----
|
||||
./test.sh -f tsim/compress/commitlog.sim
|
||||
./test.sh -f tsim/compress/compress2.sim
|
||||
./test.sh -f tsim/compress/compress.sim
|
||||
./test.sh -f tsim/compress/uncompress.sim
|
||||
|
||||
# ---- compute
|
||||
# ---- compute ----
|
||||
./test.sh -f tsim/compute/avg.sim
|
||||
./test.sh -f tsim/compute/block_dist.sim
|
||||
./test.sh -f tsim/compute/bottom.sim
|
||||
|
|
|
@ -826,7 +826,7 @@ sql select derivative(k, 200a, 0) from tm0;
|
|||
sql select derivative(k, 999a, 0) from tm0;
|
||||
sql_error select derivative(k, 20s, -12) from tm0;
|
||||
|
||||
sql select derivative(k, 1s, 0) from tm0
|
||||
sql select ts, derivative(k, 1s, 0) from tm0
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -858,7 +858,7 @@ if $data31 != -0.000236111 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select derivative(k, 6m, 0) from tm0;
|
||||
sql select ts ,derivative(k, 6m, 0) from tm0;
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -888,7 +888,7 @@ if $data31 != -0.085000000 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select derivative(k, 12m, 0) from tm0;
|
||||
sql select ts, derivative(k, 12m, 0) from tm0;
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -938,44 +938,17 @@ sql insert into t1 values('2020-1-1 1:1:6', 200);
|
|||
sql insert into t1 values('2020-1-1 1:1:8', 2000);
|
||||
sql insert into t1 values('2020-1-1 1:1:10', 20000);
|
||||
|
||||
sql_error select derivative(k, 1s, 0) from m1;
|
||||
sql select derivative(k, 1s, 0) from m1;
|
||||
sql_error select derivative(k, 1s, 0) from m1 group by a;
|
||||
sql_error select derivative(f1, 1s, 0) from (select k from t1);
|
||||
|
||||
sql select derivative(k, 1s, 0) from m1 group by tbname
|
||||
if $rows != 12 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @20-01-01 01:01:03.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 1.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != @t0@ then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @20-01-01 01:02:04.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != 0.016393443 then
|
||||
return -1
|
||||
endi
|
||||
if $data12 != t0 then
|
||||
return -1
|
||||
endi
|
||||
if $data90 != @20-01-01 01:01:06.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data91 != 90.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data92 != t1 then
|
||||
sql select ts, derivative(k, 1s, 0) from m1
|
||||
if $rows != 13 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =========================>TD-5190
|
||||
sql select stddev(f1) from st1 where ts>'2021-07-01 1:1:1' and ts<'2021-07-30 00:00:00' interval(1d) fill(NULL);
|
||||
sql select _wstart, stddev(f1) from st1 where ts>'2021-07-01 1:1:1' and ts<'2021-07-30 00:00:00' interval(1d) fill(NULL);
|
||||
if $rows != 29 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -986,7 +959,7 @@ if $data01 != NULL then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select derivative(test_column_alias_name, 1s, 0) from (select avg(k) test_column_alias_name from t1 interval(1s));
|
||||
sql select derivative(test_column_alias_name, 1s, 0) from (select _wstart, avg(k) test_column_alias_name from t1 interval(1s));
|
||||
|
||||
sql create table smeters (ts timestamp, current float, voltage int) tags (t1 int);
|
||||
sql create table smeter1 using smeters tags (1);
|
||||
|
@ -994,7 +967,7 @@ sql insert into smeter1 values ('2021-08-08 10:10:10', 10, 2);
|
|||
sql insert into smeter1 values ('2021-08-08 10:10:12', 10, 2);
|
||||
sql insert into smeter1 values ('2021-08-08 10:10:14', 20, 1);
|
||||
|
||||
sql select stddev(voltage) from smeters where ts>='2021-08-08 10:10:10.000' and ts < '2021-08-08 10:10:20.000' and current=10 interval(1000a);
|
||||
sql select _wstart, stddev(voltage) from smeters where ts>='2021-08-08 10:10:10.000' and ts < '2021-08-08 10:10:20.000' and current=10 interval(1000a);
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -1018,4 +991,3 @@ endi
|
|||
if $data00 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
|
|
@ -51,40 +51,10 @@ endi
|
|||
##TBASE-352
|
||||
$offset = $tbNum * $rowNum
|
||||
$offset = $offset - 1
|
||||
sql select * from $stb limit 2 offset $offset
|
||||
sql select * from $stb order by ts limit 2 offset $offset
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-11-25 19:30:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 9.00000 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data05 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data06 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data07 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data08 != binary9 then
|
||||
return -1
|
||||
endi
|
||||
if $data09 != nchar9 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$offset = $tbNum * $rowNum
|
||||
$offset = $offset / 2
|
||||
|
@ -197,58 +167,16 @@ endi
|
|||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 4;
|
||||
sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb order by ts limit 1 offset 4;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 09:40:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 4.00000 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != 4.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data05 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data06 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data08 != binary4 then
|
||||
return -1
|
||||
endi
|
||||
if $data09 != nchar4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
### select from supertable + where + limit offset
|
||||
sql select * from $stb where ts > '2018-09-17 09:30:00.000' and ts < '2018-09-17 10:30:00.000' limit 5 offset 1
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data21 != 7 then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != 4 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$offset = $totalNum / 2
|
||||
sql select * from $stb where ts >= $ts0 and ts <= $tsu limit 5 offset $offset
|
||||
|
@ -393,12 +321,12 @@ endi
|
|||
## TBASE-353
|
||||
$limit = $totalNum / 2
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit $limit offset 1
|
||||
if $rows != 0 then
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$limit = $totalNum / 2
|
||||
sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit $limit offset 0
|
||||
sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9),t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit $limit offset 0
|
||||
if $rows != 6 then
|
||||
print expect 6, actual:$rows
|
||||
return -1
|
||||
|
@ -447,12 +375,12 @@ endi
|
|||
|
||||
$limit = $totalNum / 2
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit $limit offset 1
|
||||
if $rows != 0 then
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
$limit = $totalNum / 2
|
||||
sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit $limit offset 0
|
||||
sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9),t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit $limit offset 0
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -505,7 +433,7 @@ endi
|
|||
|
||||
### supertable aggregation + where + interval + limit offset
|
||||
## TBASE-355
|
||||
sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit 5 offset 1
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit 5 offset 1
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -521,20 +449,11 @@ endi
|
|||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data15 != 12 then
|
||||
return -1
|
||||
endi
|
||||
if $data40 != @18-09-17 09:50:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
### [TBASE-361]
|
||||
$offset = $rowNum / 2
|
||||
$offset = $offset + 1
|
||||
sql select max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset
|
||||
$val = $rowNum - $offset
|
||||
if $rows != $val then
|
||||
print expect $val, actual:$rows
|
||||
|
@ -546,31 +465,10 @@ endi
|
|||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data05 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @18-10-22 03:00:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data42 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data53 != 6.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data54 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data55 != 36 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
## supertable aggregation + where + interval + group by order by tag + limit offset
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 2 offset 0
|
||||
if $rows != 6 then
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9),t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 2 offset 0
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 5 then
|
||||
|
@ -579,117 +477,18 @@ endi
|
|||
if $data09 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data19 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data22 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data29 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data33 != 6.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data39 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data44 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data49 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data58 != nchar6 then
|
||||
return -1
|
||||
endi
|
||||
if $data59 != 2 then
|
||||
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 2 offset 1
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 2 offset 1
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data09 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data13 != 5.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data19 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data28 != nchar6 then
|
||||
return -1
|
||||
endi
|
||||
if $data29 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data46 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data59 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 1 offset 0
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) limit 1 offset 0
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data09 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data13 != 5.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data19 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data28 != nchar5 then
|
||||
return -1
|
||||
endi
|
||||
if $data29 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 2 offset 0
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 partition by t1 interval(5m) limit 2 offset 0
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data09 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data19 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data23 != 5.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data29 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data39 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data48 != nchar5 then
|
||||
return -1
|
||||
endi
|
||||
if $data49 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data59 != 2 then
|
||||
return -1
|
||||
endi
|
||||
endi
|
|
@ -437,7 +437,7 @@ if $rows != $res then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select diff(c1) from $tb where c1 > 5 limit 2 offset 1
|
||||
sql select ts, diff(c1) from $tb where c1 > 5 limit 2 offset 1
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -462,7 +462,7 @@ endi
|
|||
$limit = $rowNum / 2
|
||||
$offset = $limit + 1
|
||||
$val = $limit - 2
|
||||
sql select diff(c1) from $tb where c1 >= 0 limit $limit offset $offset
|
||||
sql select ts, diff(c1) from $tb where c1 >= 0 limit $limit offset $offset
|
||||
if $rows != $val then
|
||||
return -1
|
||||
endi
|
||||
|
@ -493,7 +493,8 @@ endi
|
|||
if $data41 != 4 then
|
||||
return -1
|
||||
endi
|
||||
sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 offset 1
|
||||
|
||||
sql select _wstart, max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) limit 5 offset 1
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -529,7 +530,7 @@ if $data41 != 5 then
|
|||
endi
|
||||
|
||||
## TBASE-334
|
||||
sql select max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 2 offset 1
|
||||
sql select _wstart, max(c1), max(c2), max(c3), max(c4), max(c5), max(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 2 offset 1
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -549,7 +550,7 @@ if $data21 != null then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
sql select _wstart, min(c1), min(c2), min(c3), min(c4), min(c5), min(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -563,7 +564,7 @@ if $data21 != 0 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5
|
||||
sql select _wstart, sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -582,7 +583,7 @@ endi
|
|||
if $data41 != 9 then
|
||||
return -1
|
||||
endi
|
||||
sql select sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1
|
||||
sql select _wstart, sum(c1), sum(c2), sum(c3), sum(c4), sum(c5), sum(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -602,7 +603,7 @@ if $data41 != 18 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 0
|
||||
sql select _wstart, avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 0
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -618,7 +619,7 @@ endi
|
|||
if $data31 != null then
|
||||
return -1
|
||||
endi
|
||||
sql select avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
sql select _wstart, avg(c1), avg(c2), avg(c3), avg(c4), avg(c5), avg(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -640,7 +641,7 @@ sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6
|
|||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql select stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1
|
||||
sql select _wstart, stddev(c1), stddev(c2), stddev(c3), stddev(c4), stddev(c5), stddev(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 5 offset 1
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -660,7 +661,7 @@ if $data21 != 4.027681991 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m)
|
||||
sql select _wstart, count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m)
|
||||
if $rows != 3704 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -676,7 +677,7 @@ endi
|
|||
if $data31 != 3 then
|
||||
return -1
|
||||
endi
|
||||
sql select count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) limit 5 offset 1
|
||||
sql select _wstart, count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) limit 5 offset 1
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -720,7 +721,7 @@ if $rows != 0 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
sql select _wstart, first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -739,7 +740,7 @@ sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb w
|
|||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
sql select _wstart, last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -753,7 +754,7 @@ if $data23 != 1.00000 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0
|
||||
sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -788,7 +789,7 @@ if $data29 != nchar8 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1
|
||||
sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
|
|
@ -125,7 +125,7 @@ endi
|
|||
|
||||
$offset = $tbNum * $rowNum
|
||||
$offset = $offset - 1
|
||||
sql select * from $stb limit 2 offset $offset
|
||||
sql select * from $stb order by ts limit 2 offset $offset
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -163,40 +163,40 @@ endi
|
|||
$offset = $tbNum * $rowNum
|
||||
$offset = $offset / 2
|
||||
$offset = $offset - 1
|
||||
sql select * from $stb limit 2 offset $offset
|
||||
sql select * from $stb order by ts limit 2 offset $offset
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 10:30:00.002@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data03 != 9.00000 then
|
||||
return -1
|
||||
endi
|
||||
if $data04 != 9.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data05 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data06 != 9 then
|
||||
return -1
|
||||
endi
|
||||
if $data07 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data08 != binary9 then
|
||||
return -1
|
||||
endi
|
||||
if $data09 != nchar9 then
|
||||
return -1
|
||||
endi
|
||||
#if $data00 != @18-09-17 10:30:00.002@ then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data01 != 9 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data02 != 9 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data03 != 9.00000 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data04 != 9.000000000 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data05 != 9 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data06 != 9 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data07 != 1 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data08 != binary9 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data09 != nchar9 then
|
||||
# return -1
|
||||
#endi
|
||||
#if $data10 != @18-09-17 09:00:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
|
@ -249,7 +249,7 @@ endi
|
|||
if $data01 != 1 then
|
||||
return -1
|
||||
endi
|
||||
sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb limit 1 offset 4;
|
||||
sql select ts, c1, c2, c3, c4, c5, c6, c7, c8, c9 from $stb order by ts limit 1 offset 40;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -327,7 +327,7 @@ if $data41 != 3 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.009' order by ts asc limit 1 offset 0;
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.009' limit 1 offset 0;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -358,7 +358,7 @@ if $data07 != nchar0 then
|
|||
endi
|
||||
|
||||
#sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 > 0 and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0;
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 = 'true' and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0;
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 = true and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0;
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -398,12 +398,12 @@ endi
|
|||
|
||||
## TBASE-345
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit 5 offset 1
|
||||
if $rows != 0 then
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit 5 offset 0
|
||||
if $rows != 6 then
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 asc limit 5 offset 0
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 9 then
|
||||
|
@ -430,17 +430,14 @@ endi
|
|||
if $data47 != nchar0 then
|
||||
return -1
|
||||
endi
|
||||
if $data58 != 7 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit 5 offset 1
|
||||
if $rows != 0 then
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit 5 offset 0
|
||||
if $rows != 6 then
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 group by t1 order by t1 desc limit 5 offset 0
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != 9 then
|
||||
|
@ -470,15 +467,9 @@ endi
|
|||
if $data24 != 9.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data53 != 45 then
|
||||
return -1
|
||||
endi
|
||||
if $data58 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
### supertable aggregation + where + interval + limit offset
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit 5 offset 1
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit 5 offset 1
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -496,7 +487,7 @@ if $data41 != 5 then
|
|||
endi
|
||||
$offset = $rowNum / 2
|
||||
$offset = $offset + 1
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset
|
||||
$val = $rowNum - $offset
|
||||
if $rows != $val then
|
||||
return -1
|
||||
|
@ -516,8 +507,8 @@ endi
|
|||
|
||||
### supertable aggregation + where + interval + group by order by tag + limit offset
|
||||
## TBASE-345
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 3 offset 0
|
||||
if $rows != 6 then
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 3 offset 0
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 5 then
|
||||
|
@ -538,26 +529,9 @@ endi
|
|||
if $data29 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data33 != 6.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data39 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data44 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data49 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data58 != nchar6 then
|
||||
return -1
|
||||
endi
|
||||
if $data59 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 3 offset 1
|
||||
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -567,21 +541,9 @@ endi
|
|||
if $data09 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data13 != 6.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data19 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data28 != nchar6 then
|
||||
return -1
|
||||
endi
|
||||
if $data29 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 1 offset 0
|
||||
if $rows != 3 then
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 1 offset 0
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 5 then
|
||||
|
@ -590,21 +552,9 @@ endi
|
|||
if $data09 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data13 != 5.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data19 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data28 != nchar5 then
|
||||
return -1
|
||||
endi
|
||||
if $data29 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 interval(5m) group by t1 order by t1 desc limit 3 offset 0
|
||||
if $rows != 6 then
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 3 offset 0
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 5 then
|
||||
|
@ -622,80 +572,12 @@ endi
|
|||
if $data29 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data39 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data48 != nchar5 then
|
||||
return -1
|
||||
endi
|
||||
if $data49 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data59 != 2 then
|
||||
|
||||
sql select _wstart, max(c1), min(c1), avg(c1), count(c1), sum(c1), spread(c1), first(c1), last(c1), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 partition by t1 interval(5m) order by t1 asc limit 1 offset 0
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select max(c1), min(c1), avg(c1), count(c1), sum(c1), spread(c1), first(c1), last(c1) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) group by t1 order by t1 desc limit 1 offset 0
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 0 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 0 then
|
||||
return -1
|
||||
endi
|
||||
if $data09 != 7 then
|
||||
return -1
|
||||
endi
|
||||
print $data13
|
||||
if $data13 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data19 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data24 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data29 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != 0 then
|
||||
return -1
|
||||
endi
|
||||
if $data32 != 0 then
|
||||
return -1
|
||||
endi
|
||||
if $data33 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data34 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data35 != 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print $data36
|
||||
if $data36 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data37 != 0 then
|
||||
return -1
|
||||
endi
|
||||
if $data38 != 0 then
|
||||
return -1
|
||||
endi
|
||||
if $data39 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data49 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data59 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
#sql select max(c2), min(c2), avg(c2), count(c2), sum(c2), spread(c2), first(c2), last(c2) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1
|
||||
#if $rows != 3 then
|
||||
|
@ -741,89 +623,8 @@ endi
|
|||
# return -1
|
||||
#endi
|
||||
|
||||
sql select max(c2), min(c2), avg(c2), count(c2), spread(c2), first(c2), last(c2), count(ts) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 interval(5m) group by t1 order by t1 desc limit 3 offset 1
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 09:10:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data09 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data13 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data19 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @18-09-17 09:30:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data24 != 0 then
|
||||
return -1
|
||||
endi
|
||||
if $data25 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data26 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data27 != NULL then
|
||||
return -1
|
||||
endi
|
||||
if $data28 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data29 != 5 then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @18-09-17 09:10:00.000@ then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data32 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data33 != 1.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data34 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data35 != 0.000000000 then
|
||||
return -1
|
||||
endi
|
||||
if $data36 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data37 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data38 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data39 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data49 != 4 then
|
||||
return -1
|
||||
endi
|
||||
if $data51 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data59 != 4 then
|
||||
sql select _wstart, max(c2), min(c2), avg(c2), count(c2), spread(c2), first(c2), last(c2), count(ts), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 3 and t1 < 6 partition by t1 interval(5m) order by t1 desc limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -832,7 +633,7 @@ if $rows != 0 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1
|
||||
sql select ts, top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -840,7 +641,7 @@ if $data01 != 9 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1
|
||||
sql select ts, top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -848,180 +649,18 @@ if $data01 != 9 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 desc slimit 2 soffset 1 limit 3 offset 1
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 10:00:00.008@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @18-09-17 10:10:00.008@ then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != 7 then
|
||||
return -1
|
||||
endi
|
||||
if $data12 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @18-09-17 10:20:00.008@ then
|
||||
return -1
|
||||
endi
|
||||
if $data21 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data22 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @18-09-17 10:00:00.007@ then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data32 != 7 then
|
||||
return -1
|
||||
endi
|
||||
if $data40 != @18-09-17 10:10:00.007@ then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != 7 then
|
||||
return -1
|
||||
endi
|
||||
if $data42 != 7 then
|
||||
return -1
|
||||
endi
|
||||
if $data50 != @18-09-17 10:20:00.007@ then
|
||||
return -1
|
||||
endi
|
||||
if $data51 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data52 != 7 then
|
||||
sql select ts, top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 desc limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 asc slimit 2 soffset 1 limit 3 offset 1
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 10:00:00.001@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @18-09-17 10:10:00.001@ then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != 7 then
|
||||
return -1
|
||||
endi
|
||||
if $data12 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @18-09-17 10:20:00.001@ then
|
||||
return -1
|
||||
endi
|
||||
if $data21 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data22 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @18-09-17 10:00:00.002@ then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data32 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data40 != @18-09-17 10:10:00.002@ then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != 7 then
|
||||
return -1
|
||||
endi
|
||||
if $data42 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data50 != @18-09-17 10:20:00.002@ then
|
||||
return -1
|
||||
endi
|
||||
if $data51 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data52 != 2 then
|
||||
sql select ts, top(c1, 5), t1 from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 asc limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by ts desc slimit 2 soffset 1 limit 3 offset 1
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data00 != @18-09-17 10:20:00.001@ then
|
||||
return -1
|
||||
endi
|
||||
if $data01 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data10 != @18-09-17 10:10:00.001@ then
|
||||
return -1
|
||||
endi
|
||||
if $data11 != 7 then
|
||||
return -1
|
||||
endi
|
||||
if $data12 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data20 != @18-09-17 10:00:00.001@ then
|
||||
return -1
|
||||
endi
|
||||
if $data21 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data22 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data30 != @18-09-17 10:20:00.002@ then
|
||||
return -1
|
||||
endi
|
||||
if $data31 != 8 then
|
||||
return -1
|
||||
endi
|
||||
if $data32 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data40 != @18-09-17 10:10:00.002@ then
|
||||
return -1
|
||||
endi
|
||||
if $data41 != 7 then
|
||||
return -1
|
||||
endi
|
||||
if $data42 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data50 != @18-09-17 10:00:00.002@ then
|
||||
return -1
|
||||
endi
|
||||
if $data51 != 6 then
|
||||
return -1
|
||||
endi
|
||||
if $data52 != 2 then
|
||||
sql select top(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu partition by t1 order by ts desc limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
|
@ -1036,7 +675,7 @@ if $rows != 0 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1
|
||||
sql select ts, bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts desc limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -1047,7 +686,7 @@ if $data01 != 0 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1
|
||||
sql select ts, bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -1058,183 +697,20 @@ if $data01 != 0 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 desc,ts desc slimit 2 soffset 1 limit 3 offset 1
|
||||
sql select ts, bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu partition by t1 slimit 2 soffset 1 limit 3 offset 1
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
#if $data00 != @18-09-17 09:30:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data01 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 8 then
|
||||
return -1
|
||||
endi
|
||||
#if $data10 != @18-09-17 09:20:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data11 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data12 != 8 then
|
||||
return -1
|
||||
endi
|
||||
#if $data20 != @18-09-17 09:10:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data21 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data22 != 8 then
|
||||
return -1
|
||||
endi
|
||||
#if $data30 != @18-09-17 09:30:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data31 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data32 != 7 then
|
||||
return -1
|
||||
endi
|
||||
#if $data40 != @18-09-17 09:20:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data41 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data42 != 7 then
|
||||
return -1
|
||||
endi
|
||||
#if $data50 != @18-09-17 09:10:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data51 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data52 != 7 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by t1 asc,ts desc slimit 2 soffset 1 limit 3 offset 1
|
||||
sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu partition by t1 slimit 2 soffset 1 limit 3 offset 1
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
#if $data00 != @18-09-17 09:30:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data01 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 1 then
|
||||
return -1
|
||||
endi
|
||||
#if $data10 != @18-09-17 09:20:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data11 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data12 != 1 then
|
||||
return -1
|
||||
endi
|
||||
#if $data20 != @18-09-17 09:10:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data21 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data22 != 1 then
|
||||
return -1
|
||||
endi
|
||||
#if $data30 != @18-09-17 09:30:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data31 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data32 != 2 then
|
||||
return -1
|
||||
endi
|
||||
#if $data40 != @18-09-17 09:20:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data41 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data42 != 2 then
|
||||
return -1
|
||||
endi
|
||||
#if $data50 != @18-09-17 09:10:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data51 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data52 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu group by t1 order by ts desc slimit 2 soffset 1 limit 3 offset 1
|
||||
sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu partition by t1 slimit 2 soffset 1 limit 3 offset 1
|
||||
if $rows != 6 then
|
||||
return -1
|
||||
endi
|
||||
#if $data00 != @18-09-17 09:30:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data01 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data02 != 1 then
|
||||
return -1
|
||||
endi
|
||||
#if $data10 != @18-09-17 09:20:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data11 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data12 != 1 then
|
||||
return -1
|
||||
endi
|
||||
#if $data20 != @18-09-17 09:10:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data21 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data22 != 1 then
|
||||
return -1
|
||||
endi
|
||||
#if $data30 != @18-09-17 09:30:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data31 != 3 then
|
||||
return -1
|
||||
endi
|
||||
if $data32 != 2 then
|
||||
return -1
|
||||
endi
|
||||
#if $data40 != @18-09-17 09:20:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data41 != 2 then
|
||||
return -1
|
||||
endi
|
||||
if $data42 != 2 then
|
||||
return -1
|
||||
endi
|
||||
#if $data50 != @18-09-17 09:10:00.000@ then
|
||||
# return -1
|
||||
#endi
|
||||
if $data51 != 1 then
|
||||
return -1
|
||||
endi
|
||||
if $data52 != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
sql select bottom(c1, 5) from $stb where ts >= $ts0 and ts <= $tsu order by ts asc limit 3 offset 5
|
||||
if $rows != 0 then
|
||||
return -1
|
||||
|
|
|
@ -445,7 +445,7 @@ if $rows != 0 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select diff(c1) from $tb where c1 > 5 limit 2 offset 1
|
||||
sql select ts, diff(c1) from $tb where c1 > 5 limit 2 offset 1
|
||||
if $rows != 2 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -728,7 +728,7 @@ sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb w
|
|||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
sql select _wstart, last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -742,7 +742,7 @@ if $data23 != 9.00000 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0
|
||||
sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -777,7 +777,7 @@ if $data29 != nchar8 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1
|
||||
sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
system sh/stop_dnodes.sh
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sql connect
|
||||
|
||||
print ======================== create stable
|
||||
sql create database d1
|
||||
sql use d1
|
||||
|
||||
$x = 0
|
||||
while $x < 128
|
||||
$tb = d1.s . $x
|
||||
sql create table $tb (ts timestamp, i int) tags (j int)
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
print ======================== describe stables
|
||||
# TODO : create stable error
|
||||
$m = 0
|
||||
while $m < 128
|
||||
$tb = s . $m
|
||||
$filter = ' . $tb
|
||||
$filter = $filter . '
|
||||
sql show stables like $filter
|
||||
print sql : show stables like $filter
|
||||
if $rows != 1 then
|
||||
print expect 1, actual: $rows
|
||||
return -1
|
||||
endi
|
||||
$m = $m + 1
|
||||
endw
|
||||
|
||||
|
||||
print ======================== show stables
|
||||
|
||||
sql show d1.stables
|
||||
|
||||
print num of stables is $rows
|
||||
if $rows != 128 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print ======================== create table
|
||||
|
||||
$x = 0
|
||||
while $x < 424
|
||||
$tb = d1.t . $x
|
||||
sql create table $tb using d1.s0 tags( $x )
|
||||
$x = $x + 1
|
||||
endw
|
||||
|
||||
print ======================== show stables
|
||||
|
||||
sql show d1.tables
|
||||
|
||||
print num of tables is $rows
|
||||
if $rows != 424 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
@ -83,22 +83,22 @@ if $data11 != 3 then
|
|||
goto loop0
|
||||
endi
|
||||
|
||||
if $data12 != 10 then
|
||||
if $data12 != NULL then
|
||||
print ======data12=$data12
|
||||
goto loop0
|
||||
endi
|
||||
|
||||
if $data13 != 10 then
|
||||
if $data13 != NULL then
|
||||
print ======data13=$data13
|
||||
goto loop0
|
||||
endi
|
||||
|
||||
if $data14 != 1.100000000 then
|
||||
if $data14 != NULL then
|
||||
print ======data14=$data14
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data15 != 0.000000000 then
|
||||
if $data15 != NULL then
|
||||
print ======data15=$data15
|
||||
return -1
|
||||
endi
|
||||
|
@ -141,22 +141,22 @@ if $data01 != 7 then
|
|||
goto loop1
|
||||
endi
|
||||
|
||||
if $data02 != 18 then
|
||||
if $data02 != NULL then
|
||||
print =====data02=$data02
|
||||
goto loop1
|
||||
endi
|
||||
|
||||
if $data03 != 4 then
|
||||
if $data03 != NULL then
|
||||
print =====data03=$data03
|
||||
goto loop1
|
||||
endi
|
||||
|
||||
if $data04 != 1.000000000 then
|
||||
if $data04 != NULL then
|
||||
print ======$data04
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $data05 != 1.154700538 then
|
||||
if $data05 != NULL then
|
||||
print ======$data05
|
||||
return -1
|
||||
endi
|
||||
|
|
|
@ -105,6 +105,40 @@ sql select * from stb where tbcol + 3 <> null;
|
|||
print =============== step5: explain
|
||||
|
||||
|
||||
print =============== check
|
||||
$null=
|
||||
|
||||
system_content sh/checkValgrind.sh -n dnode1
|
||||
print cmd return result ----> [ $system_content ]
|
||||
if $system_content > 0 then
|
||||
return -1
|
||||
endi
|
||||
|
||||
if $system_content == $null then
|
||||
return -1
|
||||
endi
|
||||
|
||||
print =============== restart
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
system sh/exec.sh -n dnode1 -s start -v
|
||||
|
||||
sql select avg(tbcol) as c from stb
|
||||
sql select avg(tbcol) as c from stb where ts <= 1601481840000
|
||||
sql select avg(tbcol) as c from stb where tgcol < 5 and ts <= 1601481840000
|
||||
sql select avg(tbcol) as c from stb interval(1m)
|
||||
sql select avg(tbcol) as c from stb interval(1d)
|
||||
sql select avg(tbcol) as b from stb where ts <= 1601481840000 interval(1m)
|
||||
sql select avg(tbcol) as c from stb group by tgcol
|
||||
sql select avg(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m)
|
||||
sql show table distributed stb
|
||||
sql select count(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m)
|
||||
sql select diff(tbcol) from stb where ts <= 1601481840000
|
||||
sql select first(tbcol), last(tbcol) as c from stb group by tgcol
|
||||
sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 and tbcol2 is null partition by tgcol interval(1m)
|
||||
sql select first(tbcol), last(tbcol) as b from stb where ts <= 1601481840000 partition by tgcol interval(1m)
|
||||
sql select count(tbcol), avg(tbcol), max(tbcol), min(tbcol), sum(tbcol), stddev(tbcol) from stb where ts <= 1601481840000 partition by tgcol interval(1m)
|
||||
sql select last_row(tbcol), stddev(tbcol) from stb where tbcol > 5 and tbcol < 20 group by tgcol
|
||||
|
||||
_OVER:
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||
print =============== check
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
|
||||
import taos
|
||||
import sys
|
||||
import time
|
||||
import socket
|
||||
import os
|
||||
import threading
|
||||
|
||||
from util.log import *
|
||||
from util.sql import *
|
||||
from util.cases import *
|
||||
from util.dnodes import *
|
||||
from util.common import *
|
||||
sys.path.append("./7-tmq")
|
||||
from tmqCommon import *
|
||||
|
||||
class TDTestCase:
|
||||
def init(self, conn, logSql):
|
||||
tdLog.debug(f"start to excute {__file__}")
|
||||
tdSql.init(conn.cursor())
|
||||
#tdSql.init(conn.cursor(), logSql) # output sql.txt file
|
||||
|
||||
def checkFileContent(self):
|
||||
buildPath = tdCom.getBuildPath()
|
||||
cfgPath = tdCom.getClientCfgPath()
|
||||
cmdStr = '%s/build/bin/tmq_taosx_ci -c %s'%(buildPath, cfgPath)
|
||||
tdLog.info(cmdStr)
|
||||
os.system(cmdStr)
|
||||
|
||||
srcFile = '%s/../log/tmq_taosx_tmp.source'%(cfgPath)
|
||||
dstFile = '%s/../log/tmq_taosx_tmp.result'%(cfgPath)
|
||||
tdLog.info("compare file: %s, %s"%(srcFile, dstFile))
|
||||
|
||||
consumeFile = open(srcFile, mode='r')
|
||||
queryFile = open(dstFile, mode='r')
|
||||
|
||||
while True:
|
||||
dst = queryFile.readline()
|
||||
src = consumeFile.readline()
|
||||
|
||||
if dst:
|
||||
if dst != src:
|
||||
tdLog.exit("compare error: %s != %s"%src, dst)
|
||||
else:
|
||||
break
|
||||
|
||||
tdSql.execute('use db_taosx')
|
||||
tdSql.query("select * from ct3")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 1, 51)
|
||||
tdSql.checkData(0, 4, 940)
|
||||
tdSql.checkData(1, 1, 23)
|
||||
tdSql.checkData(1, 4, None)
|
||||
|
||||
tdSql.query("select * from ct1")
|
||||
tdSql.checkRows(4)
|
||||
|
||||
tdSql.query("select * from ct2")
|
||||
tdSql.checkRows(0)
|
||||
|
||||
tdSql.query("select * from ct0")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 3, "a")
|
||||
tdSql.checkData(1, 4, None)
|
||||
|
||||
tdSql.query("select * from n1")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 1, "eeee")
|
||||
tdSql.checkData(1, 2, 940)
|
||||
|
||||
tdSql.query("select * from jt")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkData(0, 1, 11)
|
||||
tdSql.checkData(0, 2, None)
|
||||
tdSql.checkData(1, 1, 1)
|
||||
tdSql.checkData(1, 2, '{"k1":1,"k2":"hello"}')
|
||||
|
||||
return
|
||||
|
||||
def run(self):
|
||||
tdSql.prepare()
|
||||
self.checkFileContent()
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
tdLog.success(f"{__file__} successfully executed")
|
||||
|
||||
event = threading.Event()
|
||||
|
||||
tdCases.addLinux(__file__, TDTestCase())
|
||||
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -227,6 +227,7 @@ python3 ./test.py -f 7-tmq/tmqUdf-multCtb-snapshot1.py
|
|||
python3 ./test.py -f 7-tmq/stbTagFilter-1ctb.py
|
||||
python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py
|
||||
python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py
|
||||
python3 ./test.py -f 7-tmq/tmq_taosx.py
|
||||
# python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py
|
||||
|
||||
#------------querPolicy 2-----------
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
add_executable(tmq_demo tmqDemo.c)
|
||||
add_executable(tmq_sim tmqSim.c)
|
||||
add_executable(create_table createTable.c)
|
||||
add_executable(tmq_taosx_ci tmq_taosx_ci.c)
|
||||
target_link_libraries(
|
||||
create_table
|
||||
PUBLIC taos_static
|
||||
|
@ -22,6 +23,13 @@ target_link_libraries(
|
|||
PUBLIC common
|
||||
PUBLIC os
|
||||
)
|
||||
target_link_libraries(
|
||||
tmq_taosx_ci
|
||||
PUBLIC taos_static
|
||||
PUBLIC util
|
||||
PUBLIC common
|
||||
PUBLIC os
|
||||
)
|
||||
|
||||
add_executable(sdbDump sdbDump.c)
|
||||
target_link_libraries(
|
||||
|
|
|
@ -0,0 +1,520 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "taos.h"
|
||||
#include "types.h"
|
||||
|
||||
static int running = 1;
|
||||
TdFilePtr g_fp = NULL;
|
||||
char dir[64]={0};
|
||||
|
||||
static TAOS* use_db(){
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
if (pConn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "use db_taosx");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in use db_taosx, reason:%s\n", taos_errstr(pRes));
|
||||
return NULL;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
return pConn;
|
||||
}
|
||||
|
||||
static void msg_process(TAOS_RES* msg) {
|
||||
/*memset(buf, 0, 1024);*/
|
||||
printf("-----------topic-------------: %s\n", tmq_get_topic_name(msg));
|
||||
printf("db: %s\n", tmq_get_db_name(msg));
|
||||
printf("vg: %d\n", tmq_get_vgroup_id(msg));
|
||||
TAOS *pConn = use_db();
|
||||
if (tmq_get_res_type(msg) == TMQ_RES_TABLE_META) {
|
||||
char* result = tmq_get_json_meta(msg);
|
||||
if (result) {
|
||||
printf("meta result: %s\n", result);
|
||||
}
|
||||
taosFprintfFile(g_fp, result);
|
||||
taosFprintfFile(g_fp, "\n");
|
||||
tmq_free_json_meta(result);
|
||||
}
|
||||
|
||||
tmq_raw_data raw = {0};
|
||||
tmq_get_raw(msg, &raw);
|
||||
int32_t ret = tmq_write_raw(pConn, raw);
|
||||
printf("write raw data: %s\n", tmq_err2str(ret));
|
||||
|
||||
// else{
|
||||
// while(1){
|
||||
// int numOfRows = 0;
|
||||
// void *pData = NULL;
|
||||
// taos_fetch_raw_block(msg, &numOfRows, &pData);
|
||||
// if(numOfRows == 0) break;
|
||||
// printf("write data: tbname:%s, numOfRows:%d\n", tmq_get_table_name(msg), numOfRows);
|
||||
// int ret = taos_write_raw_block(pConn, numOfRows, pData, tmq_get_table_name(msg));
|
||||
// printf("write raw data: %s\n", tmq_err2str(ret));
|
||||
// }
|
||||
// }
|
||||
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
int32_t init_env() {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
if (pConn == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "drop database if exists db_taosx");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create database if not exists db_taosx vgroups 1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "drop database if exists abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in drop db, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in create db, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "use abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn,
|
||||
"create stable if not exists st1 (ts timestamp, c1 int, c2 float, c3 binary(16)) tags(t1 int, t3 "
|
||||
"nchar(8), t4 bool)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists ct0 using st1 tags(1000, \"ttt\", true)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create child table tu1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into ct0 values(1626006833600, 1, 2, 'a')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct0, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists ct1 using st1(t1) tags(2000)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create child table ct1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists ct2 using st1(t1) tags(NULL)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create child table ct2, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into ct1 values(1626006833600, 3, 4, 'b')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists ct3 using st1(t1) tags(3000)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create child table ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into ct3 values(1626006833600, 5, 6, 'c') ct1 values(1626006833601, 2, 3, 'sds') (1626006833602, 4, 5, 'ddd') ct0 values(1626006833602, 4, 3, 'hwj') ct1 values(now+5s, 23, 32, 's21ds')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table st1 add column c4 bigint");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table st1 modify column c3 binary(64)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into ct3 values(1626006833605, 53, 63, 'cffffffffffffffffffffffffffff', 8989898899999) (1626006833609, 51, 62, 'c333', 940)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into ct3 select * from ct1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table st1 add tag t2 binary(64)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter super table st1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table ct3 set tag t1=5000");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to slter child table ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "delete from abc1 .ct3 where ts < 1626006833606");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into ct3, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table if not exists n1(ts timestamp, c1 int, c2 nchar(4))");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table n1 add column c3 bigint");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table n1 modify column c2 nchar(8)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table n1 rename column c3 cc3");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table n1 comment 'hello'");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "alter table n1 drop column c1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to alter normal table n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into n1 values(now, 'eeee', 8989898899999) (now+9s, 'c333', 940)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to insert into n1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table jt(ts timestamp, i int) tags(t json)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table jt1 using jt tags('{\"k1\":1, \"k2\":\"hello\"}')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create super table jt, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create table jt2 using jt tags('')");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into jt1 values(now, 1)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create super table jt1, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "insert into jt2 values(now, 11)");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create super table jt2, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
taos_close(pConn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t create_topic() {
|
||||
printf("create topic\n");
|
||||
TAOS_RES* pRes;
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
if (pConn == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pRes = taos_query(pConn, "use abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "create topic topic_ctb_column with meta as database abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to create topic topic_ctb_column, reason:%s\n", taos_errstr(pRes));
|
||||
return -1;
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
|
||||
taos_close(pConn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) {
|
||||
printf("commit %d tmq %p param %p\n", code, tmq, param);
|
||||
}
|
||||
|
||||
tmq_t* build_consumer() {
|
||||
#if 0
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
assert(pConn != NULL);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||
}
|
||||
taos_free_result(pRes);
|
||||
#endif
|
||||
|
||||
tmq_conf_t* conf = tmq_conf_new();
|
||||
tmq_conf_set(conf, "group.id", "tg2");
|
||||
tmq_conf_set(conf, "client.id", "my app 1");
|
||||
tmq_conf_set(conf, "td.connect.user", "root");
|
||||
tmq_conf_set(conf, "td.connect.pass", "taosdata");
|
||||
tmq_conf_set(conf, "msg.with.table.name", "true");
|
||||
tmq_conf_set(conf, "enable.auto.commit", "true");
|
||||
tmq_conf_set(conf, "enable.heartbeat.background", "true");
|
||||
|
||||
/*tmq_conf_set(conf, "experimental.snapshot.enable", "true");*/
|
||||
|
||||
tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL);
|
||||
tmq_t* tmq = tmq_consumer_new(conf, NULL, 0);
|
||||
assert(tmq);
|
||||
tmq_conf_destroy(conf);
|
||||
return tmq;
|
||||
}
|
||||
|
||||
tmq_list_t* build_topic_list() {
|
||||
tmq_list_t* topic_list = tmq_list_new();
|
||||
tmq_list_append(topic_list, "topic_ctb_column");
|
||||
/*tmq_list_append(topic_list, "tmq_test_db_multi_insert_topic");*/
|
||||
return topic_list;
|
||||
}
|
||||
|
||||
void basic_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
||||
int32_t code;
|
||||
|
||||
if ((code = tmq_subscribe(tmq, topics))) {
|
||||
fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code));
|
||||
printf("subscribe err\n");
|
||||
return;
|
||||
}
|
||||
int32_t cnt = 0;
|
||||
while (running) {
|
||||
TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000);
|
||||
if (tmqmessage) {
|
||||
cnt++;
|
||||
msg_process(tmqmessage);
|
||||
/*if (cnt >= 2) break;*/
|
||||
/*printf("get data\n");*/
|
||||
taos_free_result(tmqmessage);
|
||||
/*} else {*/
|
||||
/*break;*/
|
||||
/*tmq_commit_sync(tmq, NULL);*/
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
code = tmq_consumer_close(tmq);
|
||||
if (code)
|
||||
fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code));
|
||||
else
|
||||
fprintf(stderr, "%% Consumer closed\n");
|
||||
}
|
||||
|
||||
void sync_consume_loop(tmq_t* tmq, tmq_list_t* topics) {
|
||||
static const int MIN_COMMIT_COUNT = 1;
|
||||
|
||||
int msg_count = 0;
|
||||
int32_t code;
|
||||
|
||||
if ((code = tmq_subscribe(tmq, topics))) {
|
||||
fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code));
|
||||
return;
|
||||
}
|
||||
|
||||
tmq_list_t* subList = NULL;
|
||||
tmq_subscription(tmq, &subList);
|
||||
char** subTopics = tmq_list_to_c_array(subList);
|
||||
int32_t sz = tmq_list_get_size(subList);
|
||||
printf("subscribed topics: ");
|
||||
for (int32_t i = 0; i < sz; i++) {
|
||||
printf("%s, ", subTopics[i]);
|
||||
}
|
||||
printf("\n");
|
||||
tmq_list_destroy(subList);
|
||||
|
||||
while (running) {
|
||||
TAOS_RES* tmqmessage = tmq_consumer_poll(tmq, 1000);
|
||||
if (tmqmessage) {
|
||||
msg_process(tmqmessage);
|
||||
taos_free_result(tmqmessage);
|
||||
|
||||
/*tmq_commit_sync(tmq, NULL);*/
|
||||
/*if ((++msg_count % MIN_COMMIT_COUNT) == 0) tmq_commit(tmq, NULL, 0);*/
|
||||
}
|
||||
}
|
||||
|
||||
code = tmq_consumer_close(tmq);
|
||||
if (code)
|
||||
fprintf(stderr, "%% Failed to close consumer: %s\n", tmq_err2str(code));
|
||||
else
|
||||
fprintf(stderr, "%% Consumer closed\n");
|
||||
}
|
||||
|
||||
void initLogFile() {
|
||||
char f1[256] = {0};
|
||||
char f2[256] = {0};
|
||||
|
||||
sprintf(f1, "%s/../log/tmq_taosx_tmp.source", dir);
|
||||
sprintf(f2, "%s/../log/tmq_taosx_tmp.result", dir);
|
||||
TdFilePtr pFile = taosOpenFile(f1, TD_FILE_TEXT | TD_FILE_TRUNC | TD_FILE_STREAM);
|
||||
if (NULL == pFile) {
|
||||
fprintf(stderr, "Failed to open %s for save result\n", f1);
|
||||
exit(-1);
|
||||
}
|
||||
g_fp = pFile;
|
||||
|
||||
TdFilePtr pFile2 = taosOpenFile(f2, TD_FILE_TEXT | TD_FILE_TRUNC | TD_FILE_STREAM);
|
||||
if (NULL == pFile2) {
|
||||
fprintf(stderr, "Failed to open %s for save result\n", f2);
|
||||
exit(-1);
|
||||
}
|
||||
char *result[] = {
|
||||
"{\"type\":\"create\",\"tableName\":\"st1\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":6},{\"name\":\"c3\",\"type\":8,\"length\":16}],\"tags\":[{\"name\":\"t1\",\"type\":4},{\"name\":\"t3\",\"type\":10,\"length\":8},{\"name\":\"t4\",\"type\":1}]}",
|
||||
"{\"type\":\"create\",\"tableName\":\"ct0\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":1000},{\"name\":\"t3\",\"type\":10,\"value\":\"\\\"ttt\\\"\"},{\"name\":\"t4\",\"type\":1,\"value\":1}]}",
|
||||
"{\"type\":\"create\",\"tableName\":\"ct1\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":2000}]}",
|
||||
"{\"type\":\"create\",\"tableName\":\"ct2\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[]}",
|
||||
"{\"type\":\"create\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"using\":\"st1\",\"tagNum\":3,\"tags\":[{\"name\":\"t1\",\"type\":4,\"value\":3000}]}",
|
||||
"{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":5,\"colName\":\"c4\",\"colType\":5}",
|
||||
"{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":7,\"colName\":\"c3\",\"colType\":8,\"colLength\":64}",
|
||||
"{\"type\":\"alter\",\"tableName\":\"st1\",\"tableType\":\"super\",\"alterType\":1,\"colName\":\"t2\",\"colType\":8,\"colLength\":64}",
|
||||
"{\"type\":\"alter\",\"tableName\":\"ct3\",\"tableType\":\"child\",\"alterType\":4,\"colName\":\"t1\",\"colValue\":\"5000\",\"colValueNull\":false}",
|
||||
"{\"type\":\"create\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"c1\",\"type\":4},{\"name\":\"c2\",\"type\":10,\"length\":4}],\"tags\":[]}",
|
||||
"{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":5,\"colName\":\"c3\",\"colType\":5}",
|
||||
"{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":7,\"colName\":\"c2\",\"colType\":10,\"colLength\":8}",
|
||||
"{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":10,\"colName\":\"c3\",\"colNewName\":\"cc3\"}",
|
||||
"{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":9}",
|
||||
"{\"type\":\"alter\",\"tableName\":\"n1\",\"tableType\":\"normal\",\"alterType\":6,\"colName\":\"c1\"}",
|
||||
"{\"type\":\"create\",\"tableName\":\"jt\",\"tableType\":\"super\",\"columns\":[{\"name\":\"ts\",\"type\":9},{\"name\":\"i\",\"type\":4}],\"tags\":[{\"name\":\"t\",\"type\":15}]}",
|
||||
"{\"type\":\"create\",\"tableName\":\"jt1\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[{\"name\":\"t\",\"type\":15,\"value\":\"{\\\"k1\\\":1,\\\"k2\\\":\\\"hello\\\"}\"}]}",
|
||||
"{\"type\":\"create\",\"tableName\":\"jt2\",\"tableType\":\"child\",\"using\":\"jt\",\"tagNum\":1,\"tags\":[]}"
|
||||
};
|
||||
|
||||
for(int i = 0; i < sizeof(result)/sizeof(result[0]); i++){
|
||||
taosFprintfFile(pFile2, result[i]);
|
||||
taosFprintfFile(pFile2, "\n");
|
||||
}
|
||||
taosCloseFile(&pFile2);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if(argc == 3 && strcmp(argv[1], "-c") == 0) {
|
||||
strcpy(dir, argv[2]);
|
||||
}else{
|
||||
strcpy(dir, "../../../sim/psim/cfg");
|
||||
}
|
||||
|
||||
printf("env init\n");
|
||||
initLogFile();
|
||||
|
||||
if (init_env() < 0) {
|
||||
return -1;
|
||||
}
|
||||
create_topic();
|
||||
|
||||
tmq_t* tmq = build_consumer();
|
||||
tmq_list_t* topic_list = build_topic_list();
|
||||
basic_consume_loop(tmq, topic_list);
|
||||
/*sync_consume_loop(tmq, topic_list);*/
|
||||
taosCloseFile(&g_fp);
|
||||
}
|
Loading…
Reference in New Issue