提交 fc955b06 编写于 作者: C changshuaiqiang

Merge branch 'develop' into feature/changshuaiqiang/testcase

* develop: (48 commits)
  fix tsdb log format
  [TD-276] add user auth
  fix drop table coredump
  [td-225]
  [td-225] FIX BUGS IN DIFF
  add log in tsdb
  Additional fix for TD-225
  forward to peer only the data packet is from client or CQ
  [td-225] fix bug in diff query
  [td-225]
  [td-225] fix bugs in tags filter query
  scripts
  scripts
  [TD-271]
  support RpcIpSet change
  [TD-271] fix bug while drop stable
  integer division yields float in python3.
  change tables to maxtables according to Dr. Liao
  fixup: fix make command to make coverity_scan work.
  add log for database create
  ...
...@@ -49,7 +49,7 @@ matrix: ...@@ -49,7 +49,7 @@ matrix:
./test-all.sh $TRAVIS_EVENT_TYPE || travis_terminate $? ./test-all.sh $TRAVIS_EVENT_TYPE || travis_terminate $?
cd ${TRAVIS_BUILD_DIR}/tests/pytest cd ${TRAVIS_BUILD_DIR}/tests/pytest
./smoketest.sh -g 2>&1 | tee mem-error-out.txt ./valgrind-test.sh -g 2>&1 | tee mem-error-out.txt
sleep 1 sleep 1
# Color setting # Color setting
...@@ -59,12 +59,12 @@ matrix: ...@@ -59,12 +59,12 @@ matrix:
GREEN_UNDERLINE='\033[4;32m' GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m' NC='\033[0m'
grep 'ERROR SUMMARY' mem-error-out.txt | uniq | tee uniq-mem-error-out.txt grep 'ERROR SUMMARY' mem-error-out.txt|grep -v 'grep'|uniq|tee uniq-mem-error-out.txt
for memError in `cat uniq-mem-error-out.txt | awk '{print $4}'` for memError in `cat uniq-mem-error-out.txt | awk '{print $4}'`
do do
if [ -n "$memError" ]; then if [ -n "$memError" ]; then
if [ "$memError" -gt 16 ]; then if [ "$memError" -gt 5 ]; then
echo -e "${RED} ## Memory errors number valgrind reports is $memError.\ echo -e "${RED} ## Memory errors number valgrind reports is $memError.\
More than our threshold! ## ${NC}" More than our threshold! ## ${NC}"
travis_terminate $memError travis_terminate $memError
...@@ -72,11 +72,11 @@ matrix: ...@@ -72,11 +72,11 @@ matrix:
fi fi
done done
grep 'definitely lost:' mem-error-out.txt | uniq | tee uniq-definitely-lost-out.txt grep 'definitely lost:' mem-error-out.txt|grep -v 'grep'|uniq|tee uniq-definitely-lost-out.txt
for defiMemError in `cat uniq-definitely-lost-out.txt | awk '{print $4}'` for defiMemError in `cat uniq-definitely-lost-out.txt | awk '{print $7}'`
do do
if [ -n "$defiMemError" ]; then if [ -n "$defiMemError" ]; then
if [ "$defiMemError" -gt 16 ]; then if [ "$defiMemError" -gt 3 ]; then
echo -e "${RED} ## Memory errors number valgrind reports \ echo -e "${RED} ## Memory errors number valgrind reports \
Definitely lost is $defiMemError. More than our threshold! ## ${NC}" Definitely lost is $defiMemError. More than our threshold! ## ${NC}"
travis_terminate $defiMemError travis_terminate $defiMemError
...@@ -115,7 +115,7 @@ matrix: ...@@ -115,7 +115,7 @@ matrix:
# The command that will be added as an argument to "cov-build" to compile your project for analysis, # The command that will be added as an argument to "cov-build" to compile your project for analysis,
# ** likely specific to your build ** # ** likely specific to your build **
build_command: make > /dev/null build_command: make
# Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'. # Pattern to match selecting branches that will run analysis. We recommend leaving this set to 'coverity_scan'.
# Take care in resource usage, and consider the build frequency allowances per # Take care in resource usage, and consider the build frequency allowances per
...@@ -163,11 +163,9 @@ matrix: ...@@ -163,11 +163,9 @@ matrix:
cd ${TRAVIS_BUILD_DIR}/tests cd ${TRAVIS_BUILD_DIR}/tests
./test-all.sh ./test-all.sh $TRAVIS_EVENT_TYPE COVER
if [ "$?" -ne "0" ]; then TEST_RESULT=$?
travis_terminate $?
fi
pkill taosd pkill taosd
sleep 1 sleep 1
...@@ -199,6 +197,9 @@ matrix: ...@@ -199,6 +197,9 @@ matrix:
echo -e "${RED} ## Codecov did not collect coverage report! ## ${NC} " echo -e "${RED} ## Codecov did not collect coverage report! ## ${NC} "
fi fi
if [ "$TEST_RESULT" -ne "0" ]; then
travis_terminate $?
fi
;; ;;
esac esac
......
...@@ -121,7 +121,7 @@ TDengine provides abundant developing tools for users to develop on TDengine. Fo ...@@ -121,7 +121,7 @@ TDengine provides abundant developing tools for users to develop on TDengine. Fo
1. sudo apt install 1. sudo apt install
build-essential cmake net-tools python-pip python-setuptools python3-pip build-essential cmake net-tools python-pip python-setuptools python3-pip
python3-setuptools valgrind python3-setuptools valgrind psmisc curl
2. git clone <https://github.com/taosdata/TDengine>; cd TDengine 2. git clone <https://github.com/taosdata/TDengine>; cd TDengine
......
...@@ -22,25 +22,25 @@ extern "C" { ...@@ -22,25 +22,25 @@ extern "C" {
#include "tlog.h" #include "tlog.h"
extern int32_t cdebugFlag; extern int32_t cDebugFlag;
#define tscError(...) \ #define tscError(...) \
if (cdebugFlag & DEBUG_ERROR) { \ if (cDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR TSC ", 255, __VA_ARGS__); \ taosPrintLog("ERROR TSC ", 255, __VA_ARGS__); \
} }
#define tscWarn(...) \ #define tscWarn(...) \
if (cdebugFlag & DEBUG_WARN) { \ if (cDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN TSC ", cdebugFlag, __VA_ARGS__); \ taosPrintLog("WARN TSC ", cDebugFlag, __VA_ARGS__); \
} }
#define tscTrace(...) \ #define tscTrace(...) \
if (cdebugFlag & DEBUG_TRACE) { \ if (cDebugFlag & DEBUG_TRACE) { \
taosPrintLog("TSC ", cdebugFlag, __VA_ARGS__); \ taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); \
} }
#define tscPrint(...) \ #define tscPrint(...) \
{ taosPrintLog("TSC ", 255, __VA_ARGS__); } { taosPrintLog("TSC ", 255, __VA_ARGS__); }
#define tscDump(...) \ #define tscDump(...) \
if (cdebugFlag & DEBUG_TRACE) { \ if (cDebugFlag & DEBUG_TRACE) { \
taosPrintLongString("TSC ", cdebugFlag, __VA_ARGS__); \ taosPrintLongString("TSC ", cDebugFlag, __VA_ARGS__); \
} }
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -365,7 +365,7 @@ void tscInitMsgsFp(); ...@@ -365,7 +365,7 @@ void tscInitMsgsFp();
int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion); int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion);
void tscProcessMsgFromServer(SRpcMsg *rpcMsg); void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet);
int tscProcessSql(SSqlObj *pSql); int tscProcessSql(SSqlObj *pSql);
int tscRenewMeterMeta(SSqlObj *pSql, char *tableId); int tscRenewMeterMeta(SSqlObj *pSql, char *tableId);
......
...@@ -23,16 +23,16 @@ ...@@ -23,16 +23,16 @@
#include "ttime.h" #include "ttime.h"
#define jniError(...) \ #define jniError(...) \
if (jnidebugFlag & DEBUG_ERROR) { \ if (jniDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR JNI ", jnidebugFlag, __VA_ARGS__); \ taosPrintLog("ERROR JNI ", jniDebugFlag, __VA_ARGS__); \
} }
#define jniWarn(...) \ #define jniWarn(...) \
if (jnidebugFlag & DEBUG_WARN) { \ if (jniDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN JNI ", jnidebugFlag, __VA_ARGS__); \ taosPrintLog("WARN JNI ", jniDebugFlag, __VA_ARGS__); \
} }
#define jniTrace(...) \ #define jniTrace(...) \
if (jnidebugFlag & DEBUG_TRACE) { \ if (jniDebugFlag & DEBUG_TRACE) { \
taosPrintLog("JNI ", jnidebugFlag, __VA_ARGS__); \ taosPrintLog("JNI ", jniDebugFlag, __VA_ARGS__); \
} }
#define jniPrint(...) \ #define jniPrint(...) \
{ taosPrintLog("JNI ", 255, __VA_ARGS__); } { taosPrintLog("JNI ", 255, __VA_ARGS__); }
......
...@@ -1691,10 +1691,7 @@ static void last_function(SQLFunctionCtx *pCtx) { ...@@ -1691,10 +1691,7 @@ static void last_function(SQLFunctionCtx *pCtx) {
} }
static void last_function_f(SQLFunctionCtx *pCtx, int32_t index) { static void last_function_f(SQLFunctionCtx *pCtx, int32_t index) {
if (pCtx->order == TSDB_ORDER_ASC) { assert(pCtx->order != TSDB_ORDER_ASC);
return;
}
void *pData = GET_INPUT_CHAR_INDEX(pCtx, index); void *pData = GET_INPUT_CHAR_INDEX(pCtx, index);
if (pCtx->hasNull && isNull(pData, pCtx->inputType)) { if (pCtx->hasNull && isNull(pData, pCtx->inputType)) {
return; return;
...@@ -2912,7 +2909,7 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) { ...@@ -2912,7 +2909,7 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) {
} }
static void date_col_output_function(SQLFunctionCtx *pCtx) { static void date_col_output_function(SQLFunctionCtx *pCtx) {
if (pCtx->scanFlag == SUPPLEMENTARY_SCAN) { if (pCtx->scanFlag == REVERSE_SCAN) {
return; return;
} }
...@@ -2969,11 +2966,12 @@ static void tag_project_function(SQLFunctionCtx *pCtx) { ...@@ -2969,11 +2966,12 @@ static void tag_project_function(SQLFunctionCtx *pCtx) {
char* output = pCtx->aOutputBuf; char* output = pCtx->aOutputBuf;
if (pCtx->tag.nType == TSDB_DATA_TYPE_BINARY || pCtx->tag.nType == TSDB_DATA_TYPE_NCHAR) { if (pCtx->tag.nType == TSDB_DATA_TYPE_BINARY || pCtx->tag.nType == TSDB_DATA_TYPE_NCHAR) {
*(int16_t*) output = pCtx->tag.nLen; varDataSetLen(output, pCtx->tag.nLen);
output += VARSTR_HEADER_SIZE; tVariantDump(&pCtx->tag, varDataVal(output), pCtx->outputType);
} else {
tVariantDump(&pCtx->tag, output, pCtx->outputType);
} }
tVariantDump(&pCtx->tag, output, pCtx->outputType);
pCtx->aOutputBuf += pCtx->outputBytes; pCtx->aOutputBuf += pCtx->outputBytes;
} }
} }
......
...@@ -5563,8 +5563,8 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { ...@@ -5563,8 +5563,8 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3); return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg3);
} }
*(VarDataLenT*)tagVal = pList->a[i].pVar.nLen; ret = tVariantDump(&(pList->a[i].pVar), varDataVal(tagVal), pTagSchema[i].type);
ret = tVariantDump(&(pList->a[i].pVar), tagVal + VARSTR_HEADER_SIZE, pTagSchema[i].type); varDataSetLen(tagVal, pList->a[i].pVar.nLen);
} else { } else {
ret = tVariantDump(&(pList->a[i].pVar), tagVal, pTagSchema[i].type); ret = tVariantDump(&(pList->a[i].pVar), tagVal, pTagSchema[i].type);
} }
...@@ -5911,7 +5911,7 @@ int32_t exprTreeFromSqlExpr(tExprNode **pExpr, const tSQLExpr* pSqlExpr, SArray* ...@@ -5911,7 +5911,7 @@ int32_t exprTreeFromSqlExpr(tExprNode **pExpr, const tSQLExpr* pSqlExpr, SArray*
} }
if (pSqlExpr->pLeft == NULL) { if (pSqlExpr->pLeft == NULL) {
if (pSqlExpr->nSQLOptr >= TK_TINYINT && pSqlExpr->nSQLOptr <= TK_DOUBLE) { if (pSqlExpr->nSQLOptr >= TK_BOOL && pSqlExpr->nSQLOptr <= TK_STRING) {
*pExpr = calloc(1, sizeof(tExprNode)); *pExpr = calloc(1, sizeof(tExprNode));
(*pExpr)->nodeType = TSQL_NODE_VALUE; (*pExpr)->nodeType = TSQL_NODE_VALUE;
(*pExpr)->pVal = calloc(1, sizeof(tVariant)); (*pExpr)->pVal = calloc(1, sizeof(tVariant));
......
...@@ -221,7 +221,7 @@ int tscSendMsgToServer(SSqlObj *pSql) { ...@@ -221,7 +221,7 @@ int tscSendMsgToServer(SSqlObj *pSql) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
void tscProcessMsgFromServer(SRpcMsg *rpcMsg) { void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcIpSet *pIpSet) {
SSqlObj *pSql = (SSqlObj *)rpcMsg->handle; SSqlObj *pSql = (SSqlObj *)rpcMsg->handle;
if (pSql == NULL) { if (pSql == NULL) {
tscError("%p sql is already released", pSql->signature); tscError("%p sql is already released", pSql->signature);
...@@ -245,6 +245,12 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) { ...@@ -245,6 +245,12 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
return; return;
} }
if (pCmd->command < TSDB_SQL_MGMT) {
if (pIpSet) pSql->ipList = *pIpSet;
} else {
if (pIpSet) tscMgmtIpSet = *pIpSet;
}
if (rpcMsg->pCont == NULL) { if (rpcMsg->pCont == NULL) {
rpcMsg->code = TSDB_CODE_NETWORK_UNAVAIL; rpcMsg->code = TSDB_CODE_NETWORK_UNAVAIL;
} else { } else {
...@@ -492,13 +498,15 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -492,13 +498,15 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg += sizeof(pQueryInfo->type); pMsg += sizeof(pQueryInfo->type);
// todo valid the vgroupId at the client side // todo valid the vgroupId at the client side
if (UTIL_TABLE_IS_SUPERTABLE(pQueryInfo->pTableMetaInfo[0])) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
SVgroupsInfo* pVgroupInfo = pQueryInfo->pTableMetaInfo[0]->vgroupList;
assert(pVgroupInfo->numOfVgroups == 1); // todo fix me
pRetrieveMsg->header.vgId = htonl(pVgroupInfo->vgroups[0].vgId); if (UTIL_TABLE_IS_SUPERTABLE(pTableMetaInfo)) {
int32_t vgIndex = pTableMetaInfo->vgroupIndex;
SVgroupsInfo* pVgroupInfo = pTableMetaInfo->vgroupList;
pRetrieveMsg->header.vgId = htonl(pVgroupInfo->vgroups[vgIndex].vgId);
} else { } else {
STableMeta* pTableMeta = pQueryInfo->pTableMetaInfo[0]->pTableMeta; STableMeta* pTableMeta = pTableMetaInfo->pTableMeta;
pRetrieveMsg->header.vgId = htonl(pTableMeta->vgroupInfo.vgId); pRetrieveMsg->header.vgId = htonl(pTableMeta->vgroupInfo.vgId);
} }
......
...@@ -172,7 +172,7 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) { ...@@ -172,7 +172,7 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) {
} }
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) { TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
tscTrace("try to create a connection to %s", ip); tscTrace("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db);
STscObj *pObj = taosConnectImpl(ip, user, pass, db, port, NULL, NULL, NULL); STscObj *pObj = taosConnectImpl(ip, user, pass, db, port, NULL, NULL, NULL);
if (pObj != NULL) { if (pObj != NULL) {
...@@ -191,7 +191,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha ...@@ -191,7 +191,7 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
return NULL; return NULL;
} }
tscTrace("%p DB connection is opening", pObj); tscTrace("%p DB connection is opening, dnodeConn:%p", pObj, pObj->pDnodeConn);
// version compare only requires the first 3 segments of the version string // version compare only requires the first 3 segments of the version string
int code = taosCheckVersion(version, taos_get_server_info(pObj), 3); int code = taosCheckVersion(version, taos_get_server_info(pObj), 3);
......
...@@ -1436,8 +1436,8 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO ...@@ -1436,8 +1436,8 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
return; return;
} else { // reach the maximum retry count, abort } else { // reach the maximum retry count, abort
atomic_val_compare_exchange_32(&pState->code, TSDB_CODE_SUCCESS, numOfRows); atomic_val_compare_exchange_32(&pState->code, TSDB_CODE_SUCCESS, numOfRows);
tscError("%p sub:%p retrieve failed,code:%d,orderOfSub:%d failed.no more retry,set global code:%d", pPObj, pSql, tscError("%p sub:%p retrieve failed,code:%s,orderOfSub:%d failed.no more retry,set global code:%s", pPObj, pSql,
numOfRows, subqueryIndex, tstrerror(pState->code)); tstrerror(numOfRows), subqueryIndex, tstrerror(pState->code));
} }
} }
...@@ -1450,7 +1450,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO ...@@ -1450,7 +1450,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
} }
// all subqueries are failed // all subqueries are failed
tscError("%p retrieve from %d vnode(s) completed,code:%d.FAILED.", pPObj, pState->numOfTotal, pState->code); tscError("%p retrieve from %d vnode(s) completed,code:%s.FAILED.", pPObj, pState->numOfTotal, tstrerror(pState->code));
pPObj->res.code = pState->code; pPObj->res.code = pState->code;
// release allocated resource // release allocated resource
......
...@@ -63,12 +63,15 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) { ...@@ -63,12 +63,15 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) {
rpcInit.user = (char*)user; rpcInit.user = (char*)user;
rpcInit.idleTime = 2000; rpcInit.idleTime = 2000;
rpcInit.ckey = "key"; rpcInit.ckey = "key";
rpcInit.spi = 1;
rpcInit.secret = secretEncrypt; rpcInit.secret = secretEncrypt;
*pDnodeConn = rpcOpen(&rpcInit); *pDnodeConn = rpcOpen(&rpcInit);
if (*pDnodeConn == NULL) { if (*pDnodeConn == NULL) {
tscError("failed to init connection to TDengine"); tscError("failed to init connection to TDengine");
return -1; return -1;
} else {
tscTrace("dnodeConn:%p is created, user:%s", *pDnodeConn, user);
} }
} }
......
...@@ -766,7 +766,7 @@ void tscCloseTscObj(STscObj* pObj) { ...@@ -766,7 +766,7 @@ void tscCloseTscObj(STscObj* pObj) {
rpcClose(pObj->pDnodeConn); rpcClose(pObj->pDnodeConn);
} }
tscTrace("%p DB connection is closed", pObj); tscTrace("%p DB connection is closed, dnodeConn:%p", pObj, pObj->pDnodeConn);
tfree(pObj); tfree(pObj);
} }
...@@ -1144,23 +1144,21 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) { ...@@ -1144,23 +1144,21 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) {
} }
SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters) { SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters) {
SColumnFilterInfo* pFilter = NULL; if (numOfFilters == 0) {
if (numOfFilters > 0) {
pFilter = calloc(1, numOfFilters * sizeof(SColumnFilterInfo));
} else {
assert(src == NULL); assert(src == NULL);
return NULL; return NULL;
} }
SColumnFilterInfo* pFilter = calloc(1, numOfFilters * sizeof(SColumnFilterInfo));
memcpy(pFilter, src, sizeof(SColumnFilterInfo) * numOfFilters); memcpy(pFilter, src, sizeof(SColumnFilterInfo) * numOfFilters);
for (int32_t j = 0; j < numOfFilters; ++j) { for (int32_t j = 0; j < numOfFilters; ++j) {
if (pFilter[j].filterstr) { if (pFilter[j].filterstr) {
size_t len = (size_t) pFilter[j].len + 1; size_t len = (size_t) pFilter[j].len + 1;
pFilter[j].pz = (int64_t) calloc(1, len);
char* pTmp = calloc(1, len); memcpy((char*)pFilter[j].pz, (char*)src[j].pz, (size_t)len);
pFilter[j].pz = (int64_t) pTmp;
memcpy((char*)pFilter[j].pz, (char*)src->pz, (size_t)len);
} }
} }
...@@ -1675,10 +1673,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST ...@@ -1675,10 +1673,7 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
pTableMetaInfo->pTableMeta = pTableMeta; pTableMetaInfo->pTableMeta = pTableMeta;
if (vgroupList != NULL) { if (vgroupList != NULL) {
assert(vgroupList->numOfVgroups == 1); // todo fix me
size_t size = sizeof(SVgroupsInfo) + sizeof(SCMVgroupInfo) * vgroupList->numOfVgroups; size_t size = sizeof(SVgroupsInfo) + sizeof(SCMVgroupInfo) * vgroupList->numOfVgroups;
pTableMetaInfo->vgroupList = malloc(size); pTableMetaInfo->vgroupList = malloc(size);
memcpy(pTableMetaInfo->vgroupList, vgroupList, size); memcpy(pTableMetaInfo->vgroupList, vgroupList, size);
} }
......
...@@ -115,10 +115,8 @@ static FORCE_INLINE void *tdGetRowDataOfCol(SDataRow row, int8_t type, int32_t o ...@@ -115,10 +115,8 @@ static FORCE_INLINE void *tdGetRowDataOfCol(SDataRow row, int8_t type, int32_t o
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
return POINTER_SHIFT(row, *(VarDataOffsetT *)POINTER_SHIFT(row, offset)); return POINTER_SHIFT(row, *(VarDataOffsetT *)POINTER_SHIFT(row, offset));
break;
default: default:
return POINTER_SHIFT(row, offset); return POINTER_SHIFT(row, offset);
break;
} }
} }
......
...@@ -141,9 +141,9 @@ extern int32_t tsAsyncLog; ...@@ -141,9 +141,9 @@ extern int32_t tsAsyncLog;
extern int32_t tsNumOfLogLines; extern int32_t tsNumOfLogLines;
extern int32_t dDebugFlag; extern int32_t dDebugFlag;
extern int32_t vDebugFlag; extern int32_t vDebugFlag;
extern int32_t mdebugFlag; extern int32_t mDebugFlag;
extern int32_t cdebugFlag; extern int32_t cDebugFlag;
extern int32_t jnidebugFlag; extern int32_t jniDebugFlag;
extern int32_t tmrDebugFlag; extern int32_t tmrDebugFlag;
extern int32_t sdbDebugFlag; extern int32_t sdbDebugFlag;
extern int32_t httpDebugFlag; extern int32_t httpDebugFlag;
...@@ -151,8 +151,8 @@ extern int32_t monitorDebugFlag; ...@@ -151,8 +151,8 @@ extern int32_t monitorDebugFlag;
extern int32_t uDebugFlag; extern int32_t uDebugFlag;
extern int32_t rpcDebugFlag; extern int32_t rpcDebugFlag;
extern int32_t debugFlag; extern int32_t debugFlag;
extern int32_t odbcdebugFlag; extern int32_t odbcDebugFlag;
extern int32_t qdebugFlag; extern int32_t qDebugFlag;
extern uint32_t taosMaxTmrCtrl; extern uint32_t taosMaxTmrCtrl;
......
...@@ -127,16 +127,16 @@ int32_t tsRestRowLimit = 10240; ...@@ -127,16 +127,16 @@ int32_t tsRestRowLimit = 10240;
int32_t tsMaxSQLStringLen = TSDB_MAX_SQL_LEN; int32_t tsMaxSQLStringLen = TSDB_MAX_SQL_LEN;
int32_t tsNumOfLogLines = 10000000; int32_t tsNumOfLogLines = 10000000;
int32_t mdebugFlag = 135; int32_t mDebugFlag = 135;
int32_t sdbDebugFlag = 135; int32_t sdbDebugFlag = 135;
int32_t dDebugFlag = 135; int32_t dDebugFlag = 135;
int32_t vDebugFlag = 135; int32_t vDebugFlag = 135;
int32_t cdebugFlag = 135; int32_t cDebugFlag = 135;
int32_t jnidebugFlag = 131; int32_t jniDebugFlag = 131;
int32_t odbcdebugFlag = 131; int32_t odbcDebugFlag = 131;
int32_t httpDebugFlag = 131; int32_t httpDebugFlag = 131;
int32_t monitorDebugFlag = 131; int32_t monitorDebugFlag = 131;
int32_t qdebugFlag = 131; int32_t qDebugFlag = 131;
int32_t rpcDebugFlag = 135; int32_t rpcDebugFlag = 135;
int32_t uDebugFlag = 131; int32_t uDebugFlag = 131;
int32_t debugFlag = 131; int32_t debugFlag = 131;
...@@ -204,19 +204,19 @@ static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT; ...@@ -204,19 +204,19 @@ static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;
void taosSetAllDebugFlag() { void taosSetAllDebugFlag() {
for (int32_t i = 0; i < tsGlobalConfigNum; ++i) { for (int32_t i = 0; i < tsGlobalConfigNum; ++i) {
mdebugFlag = debugFlag; mDebugFlag = debugFlag;
sdbDebugFlag = debugFlag; sdbDebugFlag = debugFlag;
dDebugFlag = debugFlag; dDebugFlag = debugFlag;
vDebugFlag = debugFlag; vDebugFlag = debugFlag;
cdebugFlag = debugFlag; cDebugFlag = debugFlag;
jnidebugFlag = debugFlag; jniDebugFlag = debugFlag;
odbcdebugFlag = debugFlag; odbcDebugFlag = debugFlag;
httpDebugFlag = debugFlag; httpDebugFlag = debugFlag;
monitorDebugFlag = debugFlag; monitorDebugFlag = debugFlag;
rpcDebugFlag = debugFlag; rpcDebugFlag = debugFlag;
uDebugFlag = debugFlag; uDebugFlag = debugFlag;
sDebugFlag = debugFlag; sDebugFlag = debugFlag;
//qdebugFlag = debugFlag; //qDebugFlag = debugFlag;
} }
uPrint("all debug flag are set to %d", debugFlag); uPrint("all debug flag are set to %d", debugFlag);
} }
...@@ -1002,7 +1002,7 @@ static void doInitGlobalConfig() { ...@@ -1002,7 +1002,7 @@ static void doInitGlobalConfig() {
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "mDebugFlag"; cfg.option = "mDebugFlag";
cfg.ptr = &mdebugFlag; cfg.ptr = &mDebugFlag;
cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG;
cfg.minValue = 0; cfg.minValue = 0;
...@@ -1062,7 +1062,7 @@ static void doInitGlobalConfig() { ...@@ -1062,7 +1062,7 @@ static void doInitGlobalConfig() {
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "cDebugFlag"; cfg.option = "cDebugFlag";
cfg.ptr = &cdebugFlag; cfg.ptr = &cDebugFlag;
cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 0; cfg.minValue = 0;
...@@ -1072,7 +1072,7 @@ static void doInitGlobalConfig() { ...@@ -1072,7 +1072,7 @@ static void doInitGlobalConfig() {
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "jniDebugFlag"; cfg.option = "jniDebugFlag";
cfg.ptr = &jnidebugFlag; cfg.ptr = &jniDebugFlag;
cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 0; cfg.minValue = 0;
...@@ -1082,7 +1082,7 @@ static void doInitGlobalConfig() { ...@@ -1082,7 +1082,7 @@ static void doInitGlobalConfig() {
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "odbcDebugFlag"; cfg.option = "odbcDebugFlag";
cfg.ptr = &odbcdebugFlag; cfg.ptr = &odbcDebugFlag;
cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 0; cfg.minValue = 0;
...@@ -1122,7 +1122,7 @@ static void doInitGlobalConfig() { ...@@ -1122,7 +1122,7 @@ static void doInitGlobalConfig() {
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "qDebugFlag"; cfg.option = "qDebugFlag";
cfg.ptr = &qdebugFlag; cfg.ptr = &qDebugFlag;
cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 0; cfg.minValue = 0;
......
...@@ -167,9 +167,9 @@ static int32_t dnodeInitSystem() { ...@@ -167,9 +167,9 @@ static int32_t dnodeInitSystem() {
if (dnodeInitRead() != 0) return -1; if (dnodeInitRead() != 0) return -1;
if (dnodeInitWrite() != 0) return -1; if (dnodeInitWrite() != 0) return -1;
if (dnodeInitClient() != 0) return -1; if (dnodeInitClient() != 0) return -1;
if (dnodeInitModules() != 0) return -1;
if (dnodeInitServer() != 0) return -1; if (dnodeInitServer() != 0) return -1;
if (dnodeInitMgmt() != 0) return -1; if (dnodeInitMgmt() != 0) return -1;
if (dnodeInitModules() != 0) return -1;
if (dnodeInitShell() != 0) return -1; if (dnodeInitShell() != 0) return -1;
dnodeStartModules(); dnodeStartModules();
...@@ -184,14 +184,14 @@ static void dnodeCleanUpSystem() { ...@@ -184,14 +184,14 @@ static void dnodeCleanUpSystem() {
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_STOPPED) { if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_STOPPED) {
dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_STOPPED); dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_STOPPED);
dnodeCleanupShell(); dnodeCleanupShell();
dnodeCleanupServer(); dnodeCleanUpModules();
dnodeCleanupMgmt(); dnodeCleanupMgmt();
dnodeCleanupServer();
dnodeCleanupClient(); dnodeCleanupClient();
dnodeCleanupWrite(); dnodeCleanupWrite();
dnodeCleanupRead(); dnodeCleanupRead();
dnodeCleanUpModules();
taos_cleanup();
dnodeCleanupStorage(); dnodeCleanupStorage();
taos_cleanup();
taosCloseLog(); taosCloseLog();
} }
} }
......
...@@ -266,9 +266,12 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) { ...@@ -266,9 +266,12 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
return taosCfgDynamicOptions(pCfg->config); return taosCfgDynamicOptions(pCfg->config);
} }
void dnodeUpdateIpSet(SRpcIpSet *pIpSet) {
dPrint("mnode IP list is changed, numOfIps:%d inUse:%d", pIpSet->numOfIps, pIpSet->inUse);
for (int i = 0; i < pIpSet->numOfIps; ++i) {
dPrint("mnode index:%d %s:%u", i, pIpSet->fqdn[i], pIpSet->port[i])
}
void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet) {
dTrace("mgmt IP list is changed for ufp is called");
tsMnodeIpSet = *pIpSet; tsMnodeIpSet = *pIpSet;
} }
......
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
#include "dnodeVWrite.h" #include "dnodeVWrite.h"
#include "mnode.h" #include "mnode.h"
extern void dnodeUpdateIpSet(void *ahandle, SRpcIpSet *pIpSet); extern void dnodeUpdateIpSet(SRpcIpSet *pIpSet);
static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg); static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *);
static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg); static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg);
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg); static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet);
static void *tsDnodeServerRpc = NULL; static void *tsDnodeServerRpc = NULL;
static void *tsDnodeClientRpc = NULL; static void *tsDnodeClientRpc = NULL;
...@@ -52,6 +52,7 @@ int32_t dnodeInitServer() { ...@@ -52,6 +52,7 @@ int32_t dnodeInitServer() {
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mgmtProcessReqMsgFromDnode; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = mgmtProcessReqMsgFromDnode;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = mgmtProcessReqMsgFromDnode; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = mgmtProcessReqMsgFromDnode;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = mgmtProcessReqMsgFromDnode; dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = mgmtProcessReqMsgFromDnode;
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_AUTH] = mgmtProcessReqMsgFromDnode;
SRpcInit rpcInit; SRpcInit rpcInit;
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&rpcInit, 0, sizeof(rpcInit));
...@@ -61,7 +62,7 @@ int32_t dnodeInitServer() { ...@@ -61,7 +62,7 @@ int32_t dnodeInitServer() {
rpcInit.cfp = dnodeProcessReqMsgFromDnode; rpcInit.cfp = dnodeProcessReqMsgFromDnode;
rpcInit.sessions = 100; rpcInit.sessions = 100;
rpcInit.connType = TAOS_CONN_SERVER; rpcInit.connType = TAOS_CONN_SERVER;
rpcInit.idleTime = tsShellActivityTimer * 2000; rpcInit.idleTime = tsShellActivityTimer * 1000;
tsDnodeServerRpc = rpcOpen(&rpcInit); tsDnodeServerRpc = rpcOpen(&rpcInit);
if (tsDnodeServerRpc == NULL) { if (tsDnodeServerRpc == NULL) {
...@@ -81,7 +82,7 @@ void dnodeCleanupServer() { ...@@ -81,7 +82,7 @@ void dnodeCleanupServer() {
} }
} }
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg) { static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SRpcMsg rspMsg; SRpcMsg rspMsg;
rspMsg.handle = pMsg->handle; rspMsg.handle = pMsg->handle;
rspMsg.pCont = NULL; rspMsg.pCont = NULL;
...@@ -119,10 +120,9 @@ int32_t dnodeInitClient() { ...@@ -119,10 +120,9 @@ int32_t dnodeInitClient() {
rpcInit.label = "DND-C"; rpcInit.label = "DND-C";
rpcInit.numOfThreads = 1; rpcInit.numOfThreads = 1;
rpcInit.cfp = dnodeProcessRspFromDnode; rpcInit.cfp = dnodeProcessRspFromDnode;
rpcInit.ufp = dnodeUpdateIpSet;
rpcInit.sessions = 100; rpcInit.sessions = 100;
rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.idleTime = tsShellActivityTimer * 2000; rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.user = "t"; rpcInit.user = "t";
rpcInit.ckey = "key"; rpcInit.ckey = "key";
rpcInit.secret = "secret"; rpcInit.secret = "secret";
...@@ -145,9 +145,10 @@ void dnodeCleanupClient() { ...@@ -145,9 +145,10 @@ void dnodeCleanupClient() {
} }
} }
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg) { static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
if (dnodeProcessRspMsgFp[pMsg->msgType]) { if (dnodeProcessRspMsgFp[pMsg->msgType]) {
if (pMsg->msgType == TSDB_MSG_TYPE_DM_STATUS_RSP && pIpSet) dnodeUpdateIpSet(pIpSet);
(*dnodeProcessRspMsgFp[pMsg->msgType])(pMsg); (*dnodeProcessRspMsgFp[pMsg->msgType])(pMsg);
} else { } else {
dError("RPC %p, msg:%s is not processed", pMsg->handle, taosMsg[pMsg->msgType]); dError("RPC %p, msg:%s is not processed", pMsg->handle, taosMsg[pMsg->msgType]);
...@@ -163,3 +164,9 @@ void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) { ...@@ -163,3 +164,9 @@ void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) { void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg) {
rpcSendRequest(tsDnodeClientRpc, ipSet, rpcMsg); rpcSendRequest(tsDnodeClientRpc, ipSet, rpcMsg);
} }
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp) {
SRpcIpSet ipSet = {0};
dnodeGetMnodeDnodeIpSet(&ipSet);
rpcSendRecv(tsDnodeClientRpc, &ipSet, rpcMsg, rpcRsp);
}
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "trpc.h" #include "trpc.h"
#include "tglobal.h" #include "tglobal.h"
#include "http.h" #include "http.h"
#include "mnode.h"
#include "dnode.h" #include "dnode.h"
#include "dnodeInt.h" #include "dnodeInt.h"
#include "dnodeVRead.h" #include "dnodeVRead.h"
...@@ -28,7 +29,7 @@ ...@@ -28,7 +29,7 @@
#include "dnodeShell.h" #include "dnodeShell.h"
static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *); static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
static void dnodeProcessMsgFromShell(SRpcMsg *pMsg); static void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *);
static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey); static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
static void * tsDnodeShellRpc = NULL; static void * tsDnodeShellRpc = NULL;
static int32_t tsDnodeQueryReqNum = 0; static int32_t tsDnodeQueryReqNum = 0;
...@@ -86,7 +87,7 @@ int32_t dnodeInitShell() { ...@@ -86,7 +87,7 @@ int32_t dnodeInitShell() {
rpcInit.cfp = dnodeProcessMsgFromShell; rpcInit.cfp = dnodeProcessMsgFromShell;
rpcInit.sessions = TSDB_SESSIONS_PER_DNODE; rpcInit.sessions = TSDB_SESSIONS_PER_DNODE;
rpcInit.connType = TAOS_CONN_SERVER; rpcInit.connType = TAOS_CONN_SERVER;
rpcInit.idleTime = tsShellActivityTimer * 1500; rpcInit.idleTime = tsShellActivityTimer * 1000;
rpcInit.afp = dnodeRetrieveUserAuthInfo; rpcInit.afp = dnodeRetrieveUserAuthInfo;
tsDnodeShellRpc = rpcOpen(&rpcInit); tsDnodeShellRpc = rpcOpen(&rpcInit);
...@@ -106,7 +107,7 @@ void dnodeCleanupShell() { ...@@ -106,7 +107,7 @@ void dnodeCleanupShell() {
} }
} }
void dnodeProcessMsgFromShell(SRpcMsg *pMsg) { void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SRpcMsg rpcMsg; SRpcMsg rpcMsg;
rpcMsg.handle = pMsg->handle; rpcMsg.handle = pMsg->handle;
rpcMsg.pCont = NULL; rpcMsg.pCont = NULL;
...@@ -138,7 +139,34 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) { ...@@ -138,7 +139,34 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg) {
} }
static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) { static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
return TSDB_CODE_SUCCESS; int code = mgmtRetriveAuth(user, spi, encrypt, secret, ckey);
if (code != TSDB_CODE_NOT_READY) return code;
SDMAuthMsg *pMsg = rpcMallocCont(sizeof(SDMAuthMsg));
strcpy(pMsg->user, user);
SRpcMsg rpcMsg = {0};
rpcMsg.pCont = pMsg;
rpcMsg.contLen = sizeof(SDMAuthMsg);
rpcMsg.msgType = TSDB_MSG_TYPE_DM_AUTH;
dTrace("user:%s, send auth msg to mnode", user);
SRpcMsg rpcRsp = {0};
dnodeSendMsgToDnodeRecv(&rpcMsg, &rpcRsp);
if (rpcRsp.code != 0) {
dError("user:%s, auth msg received from mnode, error:%s", user, tstrerror(rpcRsp.code));
} else {
dTrace("user:%s, auth msg received from mnode", user);
SDMAuthRsp *pRsp = rpcRsp.pCont;
memcpy(secret, pRsp->secret, TSDB_KEY_LEN);
memcpy(ckey, pRsp->ckey, TSDB_KEY_LEN);
*spi = pRsp->spi;
*encrypt = pRsp->encrypt;
}
rpcFreeCont(rpcRsp.pCont);
return rpcRsp.code;
} }
SDnodeStatisInfo dnodeGetStatisInfo() { SDnodeStatisInfo dnodeGetStatisInfo() {
......
...@@ -52,6 +52,7 @@ int32_t dnodeGetDnodeId(); ...@@ -52,6 +52,7 @@ int32_t dnodeGetDnodeId();
void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
void dnodeAddServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); void dnodeAddServerMsgHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg));
void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg); void dnodeSendMsgToDnode(SRpcIpSet *ipSet, SRpcMsg *rpcMsg);
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -26,9 +26,11 @@ void mgmtCleanUpSystem(); ...@@ -26,9 +26,11 @@ void mgmtCleanUpSystem();
void mgmtStopSystem(); void mgmtStopSystem();
void sdbUpdateSync(); void sdbUpdateSync();
int32_t mgmtRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg); void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg);
void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg); void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -36,6 +36,11 @@ extern "C" { ...@@ -36,6 +36,11 @@ extern "C" {
typedef int32_t VarDataOffsetT; typedef int32_t VarDataOffsetT;
typedef int16_t VarDataLenT; typedef int16_t VarDataLenT;
typedef struct tstr {
VarDataLenT len;
char data[];
} tstr;
#define VARSTR_HEADER_SIZE sizeof(VarDataLenT) #define VARSTR_HEADER_SIZE sizeof(VarDataLenT)
#define varDataLen(v) ((VarDataLenT *)(v))[0] #define varDataLen(v) ((VarDataLenT *)(v))[0]
......
...@@ -100,6 +100,7 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_TABLE, "config-table" ) ...@@ -100,6 +100,7 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_TABLE, "config-table" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_VNODE, "config-vnode" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_CONFIG_VNODE, "config-vnode" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_STATUS, "status" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_STATUS, "status" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_GRANT, "grant" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_GRANT, "grant" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DM_AUTH, "auth" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY12, "dummy12" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY12, "dummy12" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY13, "dummy13" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY13, "dummy13" )
TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY14, "dummy14" ) TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_DUMMY14, "dummy14" )
...@@ -737,6 +738,14 @@ typedef struct { ...@@ -737,6 +738,14 @@ typedef struct {
char tableId[TSDB_TABLE_ID_LEN + 1]; char tableId[TSDB_TABLE_ID_LEN + 1];
} SMDAlterStreamMsg; } SMDAlterStreamMsg;
typedef struct {
char user[TSDB_USER_LEN + 1];
char spi;
char encrypt;
char secret[TSDB_KEY_LEN + 1];
char ckey[TSDB_KEY_LEN + 1];
} SDMAuthMsg, SDMAuthRsp;
#pragma pack(pop) #pragma pack(pop)
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -66,10 +66,7 @@ typedef struct { ...@@ -66,10 +66,7 @@ typedef struct {
char *ckey; // ciphering key char *ckey; // ciphering key
// call back to process incoming msg, code shall be ignored by server app // call back to process incoming msg, code shall be ignored by server app
void (*cfp)(SRpcMsg *); void (*cfp)(SRpcMsg *, SRpcIpSet *);
// call back to process notify the ipSet changes, for client app only
void (*ufp)(void *ahandle, SRpcIpSet *pIpSet);
// call back to retrieve the client auth info, for server app only // call back to retrieve the client auth info, for server app only
int (*afp)(char *tableId, char *spi, char *encrypt, char *secret, char *ckey); int (*afp)(char *tableId, char *spi, char *encrypt, char *secret, char *ckey);
......
...@@ -102,13 +102,15 @@ int tsdbTableSetSName(STableCfg *config, char *sname, bool dup); ...@@ -102,13 +102,15 @@ int tsdbTableSetSName(STableCfg *config, char *sname, bool dup);
void tsdbClearTableCfg(STableCfg *config); void tsdbClearTableCfg(STableCfg *config);
int32_t tsdbGetTableTagVal(TsdbRepoT *repo, STableId* id, int32_t colId, int16_t *type, int16_t *bytes, char **val); int32_t tsdbGetTableTagVal(TsdbRepoT *repo, STableId* id, int32_t colId, int16_t *type, int16_t *bytes, char **val);
int32_t tsdbGetTableName(TsdbRepoT *repo, STableId* id, char** name); char* tsdbGetTableName(TsdbRepoT *repo, const STableId* id, int16_t* bytes);
int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg); int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg);
int tsdbDropTable(TsdbRepoT *pRepo, STableId tableId); int tsdbDropTable(TsdbRepoT *pRepo, STableId tableId);
int tsdbAlterTable(TsdbRepoT *repo, STableCfg *pCfg); int tsdbAlterTable(TsdbRepoT *repo, STableCfg *pCfg);
TSKEY tsdbGetTableLastKey(TsdbRepoT *repo, int64_t uid); TSKEY tsdbGetTableLastKey(TsdbRepoT *repo, int64_t uid);
uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, int32_t *size);
// the TSDB repository info // the TSDB repository info
typedef struct STsdbRepoInfo { typedef struct STsdbRepoInfo {
STsdbCfg tsdbCfg; STsdbCfg tsdbCfg;
......
...@@ -85,8 +85,7 @@ typedef struct SSuperTableObj { ...@@ -85,8 +85,7 @@ typedef struct SSuperTableObj {
int32_t numOfTables; int32_t numOfTables;
int16_t nextColId; int16_t nextColId;
SSchema * schema; SSchema * schema;
int32_t vgLen; void * vgHash;
int32_t * vgList;
} SSuperTableObj; } SSuperTableObj;
typedef struct { typedef struct {
......
...@@ -23,13 +23,13 @@ extern "C" { ...@@ -23,13 +23,13 @@ extern "C" {
#include "tlog.h" #include "tlog.h"
#include "monitor.h" #include "monitor.h"
extern int32_t mdebugFlag; extern int32_t mDebugFlag;
extern int32_t sdbDebugFlag; extern int32_t sdbDebugFlag;
// mnode log function // mnode log function
#define mError(...) if (mdebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND ", 255, __VA_ARGS__); } #define mError(...) if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR MND ", 255, __VA_ARGS__); }
#define mWarn(...) if (mdebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND ", mdebugFlag, __VA_ARGS__); } #define mWarn(...) if (mDebugFlag & DEBUG_WARN) { taosPrintLog("WARN MND ", mDebugFlag, __VA_ARGS__); }
#define mTrace(...) if (mdebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mdebugFlag, __VA_ARGS__); } #define mTrace(...) if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }
#define mPrint(...) { taosPrintLog("MND ", 255, __VA_ARGS__); } #define mPrint(...) { taosPrintLog("MND ", 255, __VA_ARGS__); }
#define mLError(...) monitorSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__) #define mLError(...) monitorSaveLog(2, __VA_ARGS__); mError(__VA_ARGS__)
......
...@@ -297,8 +297,10 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) { ...@@ -297,8 +297,10 @@ static int32_t mgmtCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
if (pDb != NULL) { if (pDb != NULL) {
mgmtDecDbRef(pDb); mgmtDecDbRef(pDb);
if (pCreate->ignoreExist) { if (pCreate->ignoreExist) {
mTrace("db:%s, already exist, ignore exist is set", pCreate->db);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} else { } else {
mError("db:%s, is already exist, ignore exist not set", pCreate->db);
return TSDB_CODE_DB_ALREADY_EXIST; return TSDB_CODE_DB_ALREADY_EXIST;
} }
} }
...@@ -751,6 +753,8 @@ static void mgmtProcessCreateDbMsg(SQueuedMsg *pMsg) { ...@@ -751,6 +753,8 @@ static void mgmtProcessCreateDbMsg(SQueuedMsg *pMsg) {
code = mgmtCreateDb(pMsg->pUser->pAcct, pCreate); code = mgmtCreateDb(pMsg->pUser->pAcct, pCreate);
if (code == TSDB_CODE_SUCCESS) { if (code == TSDB_CODE_SUCCESS) {
mLPrint("db:%s, is created by %s", pCreate->db, pMsg->pUser->user); mLPrint("db:%s, is created by %s", pCreate->db, pMsg->pUser->user);
} else {
mError("db:%s, failed to create, reason:%s", pCreate->db, tstrerror(code));
} }
} }
......
...@@ -278,7 +278,7 @@ void sdbUpdateSync() { ...@@ -278,7 +278,7 @@ void sdbUpdateSync() {
sdbPrint("mnode:%d, %s:%d", syncCfg.nodeInfo[i].nodeId, syncCfg.nodeInfo[i].nodeFqdn, syncCfg.nodeInfo[i].nodePort); sdbPrint("mnode:%d, %s:%d", syncCfg.nodeInfo[i].nodeId, syncCfg.nodeInfo[i].nodeFqdn, syncCfg.nodeInfo[i].nodePort);
} }
SSyncInfo syncInfo; SSyncInfo syncInfo = {0};
syncInfo.vgId = 1; syncInfo.vgId = 1;
syncInfo.version = sdbGetVersion(); syncInfo.version = sdbGetVersion();
syncInfo.syncCfg = syncCfg; syncInfo.syncCfg = syncCfg;
......
...@@ -88,10 +88,12 @@ void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg) { ...@@ -88,10 +88,12 @@ void mgmtProcessReqMsgFromDnode(SRpcMsg *rpcMsg) {
SRpcIpSet ipSet = {0}; SRpcIpSet ipSet = {0};
dnodeGetMnodeDnodeIpSet(&ipSet); dnodeGetMnodeDnodeIpSet(&ipSet);
for (int i = 0; i < ipSet.numOfIps; ++i)
ipSet.port[i] = htons(ipSet.port[i]);
mTrace("conn from dnode ip:%s user:%s redirect msg, inUse:%d", taosIpStr(connInfo.clientIp), connInfo.user, ipSet.inUse); mTrace("conn from dnode ip:%s user:%s redirect msg, inUse:%d", taosIpStr(connInfo.clientIp), connInfo.user, ipSet.inUse);
for (int32_t i = 0; i < ipSet.numOfIps; ++i) { for (int32_t i = 0; i < ipSet.numOfIps; ++i) {
mTrace("index:%d %s:%d", i, ipSet.fqdn[i], ipSet.port[i]); mTrace("mnode index:%d %s:%d", i, ipSet.fqdn[i], htons(ipSet.port[i]));
} }
rpcSendRedirectRsp(rpcMsg->handle, &ipSet); rpcSendRedirectRsp(rpcMsg->handle, &ipSet);
return; return;
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
typedef int32_t (*SShowMetaFp)(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn); typedef int32_t (*SShowMetaFp)(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
typedef int32_t (*SShowRetrieveFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn); typedef int32_t (*SShowRetrieveFp)(SShowObj *pShow, char *data, int32_t rows, void *pConn);
//static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg); static bool mgmtCheckMsgReadOnly(SQueuedMsg *pMsg);
static void mgmtProcessUnSupportMsg(SRpcMsg *rpcMsg); static void mgmtProcessUnSupportMsg(SRpcMsg *rpcMsg);
static void mgmtProcessShowMsg(SQueuedMsg *queuedMsg); static void mgmtProcessShowMsg(SQueuedMsg *queuedMsg);
...@@ -137,7 +136,7 @@ void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) { ...@@ -137,7 +136,7 @@ void mgmtProcessMsgFromShell(SRpcMsg *rpcMsg) {
mgmtGetMnodeIpSet(&ipSet); mgmtGetMnodeIpSet(&ipSet);
mTrace("conn from shell ip:%s user:%s redirect msg, inUse:%d", taosIpStr(connInfo.clientIp), connInfo.user, ipSet.inUse); mTrace("conn from shell ip:%s user:%s redirect msg, inUse:%d", taosIpStr(connInfo.clientIp), connInfo.user, ipSet.inUse);
for (int32_t i = 0; i < ipSet.numOfIps; ++i) { for (int32_t i = 0; i < ipSet.numOfIps; ++i) {
mTrace("index:%d ip:%s:%d", i, ipSet.fqdn[i], ipSet.port[i]); mTrace("mnode index:%d ip:%s:%d", i, ipSet.fqdn[i], htons(ipSet.port[i]));
} }
rpcSendRedirectRsp(rpcMsg->handle, &ipSet); rpcSendRedirectRsp(rpcMsg->handle, &ipSet);
...@@ -343,29 +342,6 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) { ...@@ -343,29 +342,6 @@ static void mgmtProcessHeartBeatMsg(SQueuedMsg *pMsg) {
rpcSendResponse(&rpcRsp); rpcSendResponse(&rpcRsp);
} }
/*
static int mgmtShellRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
*spi = 1;
*encrypt = 0;
*ckey = 0;
if (!sdbIsMaster()) {
*secret = 0;
return TSDB_CODE_NOT_READY;
}
SUserObj *pUser = mgmtGetUser(user);
if (pUser == NULL) {
*secret = 0;
return TSDB_CODE_INVALID_USER;
} else {
memcpy(secret, pUser->pass, TSDB_KEY_LEN);
mgmtDecUserRef(pUser);
return TSDB_CODE_SUCCESS;
}
}
*/
static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) { static void mgmtProcessConnectMsg(SQueuedMsg *pMsg) {
SRpcMsg rpcRsp = {.handle = pMsg->thandle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0}; SRpcMsg rpcRsp = {.handle = pMsg->thandle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0};
SCMConnectMsg *pConnectMsg = pMsg->pCont; SCMConnectMsg *pConnectMsg = pMsg->pCont;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "tname.h" #include "tname.h"
#include "tidpool.h" #include "tidpool.h"
#include "tglobal.h" #include "tglobal.h"
#include "hash.h"
#include "dnode.h" #include "dnode.h"
#include "mgmtDef.h" #include "mgmtDef.h"
#include "mgmtInt.h" #include "mgmtInt.h"
...@@ -363,39 +364,35 @@ static void mgmtCleanUpChildTables() { ...@@ -363,39 +364,35 @@ static void mgmtCleanUpChildTables() {
} }
static void mgmtAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) { static void mgmtAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) {
if (pStable->vgLen == 0) { pStable->numOfTables++;
pStable->vgLen = 8;
pStable->vgList = calloc(pStable->vgLen, sizeof(int32_t));
}
bool find = false; if (pStable->vgHash == NULL) {
int32_t pos = 0; pStable->vgHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false);
for (pos = 0; pos < pStable->vgLen; ++pos) {
if (pStable->vgList[pos] == 0) break;
if (pStable->vgList[pos] == pCtable->vgId) {
find = true;
break;
}
} }
if (!find) { if (pStable->vgHash != NULL) {
if (pos >= pStable->vgLen) { taosHashPut(pStable->vgHash, (char *)&pCtable->vgId, sizeof(pCtable->vgId), &pCtable->vgId, sizeof(pCtable->vgId));
pStable->vgLen *= 2;
pStable->vgList = realloc(pStable->vgList, pStable->vgLen * sizeof(int32_t));
}
pStable->vgList[pos] = pCtable->vgId;
} }
pStable->numOfTables++;
} }
static void mgmtRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *pCtable) { static void mgmtRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *pCtable) {
pStable->numOfTables--; pStable->numOfTables--;
if (pStable->vgHash == NULL) return;
SVgObj *pVgroup = mgmtGetVgroup(pCtable->vgId);
if (pVgroup != NULL) {
taosHashRemove(pStable->vgHash, (char *)&pCtable->vgId, sizeof(pCtable->vgId));
}
mgmtDecVgroupRef(pVgroup);
} }
static void mgmtDestroySuperTable(SSuperTableObj *pStable) { static void mgmtDestroySuperTable(SSuperTableObj *pStable) {
if (pStable->vgHash != NULL) {
taosHashCleanup(pStable->vgHash);
pStable->vgHash = NULL;
}
tfree(pStable->schema); tfree(pStable->schema);
tfree(pStable->vgList)
tfree(pStable); tfree(pStable);
} }
...@@ -434,7 +431,7 @@ static int32_t mgmtSuperTableActionUpdate(SSdbOper *pOper) { ...@@ -434,7 +431,7 @@ static int32_t mgmtSuperTableActionUpdate(SSdbOper *pOper) {
void *oldSchema = pTable->schema; void *oldSchema = pTable->schema;
memcpy(pTable, pNew, pOper->rowSize); memcpy(pTable, pNew, pOper->rowSize);
pTable->schema = pNew->schema; pTable->schema = pNew->schema;
free(pNew->vgList); free(pNew->vgHash);
free(pNew); free(pNew);
free(oldSchema); free(oldSchema);
} }
...@@ -797,26 +794,26 @@ static void mgmtProcessCreateSuperTableMsg(SQueuedMsg *pMsg) { ...@@ -797,26 +794,26 @@ static void mgmtProcessCreateSuperTableMsg(SQueuedMsg *pMsg) {
static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) { static void mgmtProcessDropSuperTableMsg(SQueuedMsg *pMsg) {
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable; SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
if (pStable->numOfTables != 0) { if (pStable->numOfTables != 0) {
mgmtDropAllChildTablesInStable(pStable); SHashMutableIterator *pIter = taosHashCreateIter(pStable->vgHash);
for (int32_t vg = 0; vg < pStable->vgLen; ++vg) { while (taosHashIterNext(pIter)) {
int32_t vgId = pStable->vgList[vg]; int32_t *pVgId = taosHashIterGet(pIter);
if (vgId == 0) break; SVgObj *pVgroup = mgmtGetVgroup(*pVgId);
SVgObj *pVgroup = mgmtGetVgroup(vgId);
if (pVgroup == NULL) break; if (pVgroup == NULL) break;
SMDDropSTableMsg *pDrop = rpcMallocCont(sizeof(SMDDropSTableMsg)); SMDDropSTableMsg *pDrop = rpcMallocCont(sizeof(SMDDropSTableMsg));
pDrop->contLen = htonl(sizeof(SMDDropSTableMsg)); pDrop->contLen = htonl(sizeof(SMDDropSTableMsg));
pDrop->vgId = htonl(vgId); pDrop->vgId = htonl(pVgroup->vgId);
pDrop->uid = htobe64(pStable->uid); pDrop->uid = htobe64(pStable->uid);
mgmtExtractTableName(pStable->info.tableId, pDrop->tableId); mgmtExtractTableName(pStable->info.tableId, pDrop->tableId);
mPrint("stable:%s, send drop stable msg to vgId:%d", pStable->info.tableId, vgId); mPrint("stable:%s, send drop stable msg to vgId:%d", pStable->info.tableId, pVgroup->vgId);
SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup); SRpcIpSet ipSet = mgmtGetIpSetFromVgroup(pVgroup);
SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE}; SRpcMsg rpcMsg = {.pCont = pDrop, .contLen = sizeof(SMDDropSTableMsg), .msgType = TSDB_MSG_TYPE_MD_DROP_STABLE};
dnodeSendMsgToDnode(&ipSet, &rpcMsg); dnodeSendMsgToDnode(&ipSet, &rpcMsg);
mgmtDecVgroupRef(pVgroup); mgmtDecVgroupRef(pVgroup);
} }
mgmtDropAllChildTablesInStable(pStable);
} }
SSdbOper oper = { SSdbOper oper = {
...@@ -1244,13 +1241,18 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { ...@@ -1244,13 +1241,18 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) {
SCMSTableVgroupMsg *pInfo = pMsg->pCont; SCMSTableVgroupMsg *pInfo = pMsg->pCont;
int32_t numOfTable = htonl(pInfo->numOfTables); int32_t numOfTable = htonl(pInfo->numOfTables);
char* name = (char*) pInfo + sizeof(struct SCMSTableVgroupMsg); // reserve space
SCMSTableVgroupRspMsg *pRsp = NULL; int32_t contLen = sizeof(SCMSTableVgroupRspMsg) + 32 * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo);
for (int32_t i = 0; i < numOfTable; ++i) {
// todo set the initial size to be 10, fix me char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i;
int32_t contLen = sizeof(SCMSTableVgroupRspMsg) + (sizeof(SCMVgroupInfo) * 10 + sizeof(SVgroupsInfo))*numOfTable; SSuperTableObj *pTable = mgmtGetSuperTable(stableName);
if (pTable->vgHash != NULL) {
contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SCMVgroupInfo) + sizeof(SVgroupsInfo));
}
mgmtDecTableRef(pTable);
}
pRsp = rpcMallocCont(contLen); SCMSTableVgroupRspMsg *pRsp = rpcMallocCont(contLen);
if (pRsp == NULL) { if (pRsp == NULL) {
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY); mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_SERV_OUT_OF_MEMORY);
return; return;
...@@ -1259,43 +1261,37 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) { ...@@ -1259,43 +1261,37 @@ static void mgmtProcessSuperTableVgroupMsg(SQueuedMsg *pMsg) {
pRsp->numOfTables = htonl(numOfTable); pRsp->numOfTables = htonl(numOfTable);
char* msg = (char*) pRsp + sizeof(SCMSTableVgroupRspMsg); char* msg = (char*) pRsp + sizeof(SCMSTableVgroupRspMsg);
for(int32_t i = 0; i < numOfTable; ++i) { for (int32_t i = 0; i < numOfTable; ++i) {
SSuperTableObj *pTable = mgmtGetSuperTable(name); char *stableName = (char*)pInfo + sizeof(SCMSTableVgroupMsg) + (TSDB_TABLE_ID_LEN) * i;
SSuperTableObj *pTable = mgmtGetSuperTable(stableName);
pMsg->pTable = (STableObj *)pTable; SVgroupsInfo *pVgroupInfo = (SVgroupsInfo *)msg;
if (pMsg->pTable == NULL) {
mgmtSendSimpleResp(pMsg->thandle, TSDB_CODE_INVALID_TABLE); SHashMutableIterator *pIter = taosHashCreateIter(pTable->vgHash);
return; int32_t vgSize = 0;
} while (taosHashIterNext(pIter)) {
int32_t *pVgId = taosHashIterGet(pIter);
SVgroupsInfo* pVgroup = (SVgroupsInfo*) msg; SVgObj * pVgroup = mgmtGetVgroup(*pVgId);
if (pVgroup == NULL) continue;
int32_t vg = 0;
for (; vg < pTable->vgLen; ++vg) { pVgroupInfo->vgroups[vgSize].vgId = htonl(pVgroup->vgId);
int32_t vgId = pTable->vgList[vg]; for (int32_t vn = 0; vn < pVgroup->numOfVnodes; ++vn) {
if (vgId == 0) break; SDnodeObj *pDnode = pVgroup->vnodeGid[vn].pDnode;
SVgObj *vgItem = mgmtGetVgroup(vgId);
if (vgItem == NULL) break;
pVgroup->vgroups[vg].vgId = htonl(vgId);
for (int32_t vn = 0; vn < vgItem->numOfVnodes; ++vn) {
SDnodeObj *pDnode = vgItem->vnodeGid[vn].pDnode;
if (pDnode == NULL) break; if (pDnode == NULL) break;
strncpy(pVgroup->vgroups[vg].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn)); strncpy(pVgroupInfo->vgroups[vgSize].ipAddr[vn].fqdn, pDnode->dnodeFqdn, tListLen(pDnode->dnodeFqdn));
pVgroup->vgroups[vg].ipAddr[vn].port = htons(tsDnodeShellPort); pVgroupInfo->vgroups[vgSize].ipAddr[vn].port = htons(tsDnodeShellPort);
pVgroup->vgroups[vg].numOfIps++; pVgroupInfo->vgroups[vgSize].numOfIps++;
} }
mgmtDecVgroupRef(vgItem); vgSize++;
mgmtDecVgroupRef(pVgroup);
} }
pVgroup->numOfVgroups = htonl(vg); pVgroupInfo->numOfVgroups = htonl(vgSize);
// one table is done, try the next table // one table is done, try the next table
msg += sizeof(SVgroupsInfo) + vg * sizeof(SCMVgroupInfo); msg += sizeof(SVgroupsInfo) + vgSize * sizeof(SCMVgroupInfo);
} }
SRpcMsg rpcRsp = {0}; SRpcMsg rpcRsp = {0};
......
...@@ -37,6 +37,7 @@ static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void ...@@ -37,6 +37,7 @@ static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void
static void mgmtProcessCreateUserMsg(SQueuedMsg *pMsg); static void mgmtProcessCreateUserMsg(SQueuedMsg *pMsg);
static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg); static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg);
static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg); static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg);
static void mgmtProcessAuthMsg(SRpcMsg *rpcMsg);
static int32_t mgmtUserActionDestroy(SSdbOper *pOper) { static int32_t mgmtUserActionDestroy(SSdbOper *pOper) {
tfree(pOper->pObj); tfree(pOper->pObj);
...@@ -140,6 +141,7 @@ int32_t mgmtInitUsers() { ...@@ -140,6 +141,7 @@ int32_t mgmtInitUsers() {
mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_DROP_USER, mgmtProcessDropUserMsg); mgmtAddShellMsgHandle(TSDB_MSG_TYPE_CM_DROP_USER, mgmtProcessDropUserMsg);
mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_USER, mgmtGetUserMeta); mgmtAddShellShowMetaHandle(TSDB_MGMT_TABLE_USER, mgmtGetUserMeta);
mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_USER, mgmtRetrieveUsers); mgmtAddShellShowRetrieveHandle(TSDB_MGMT_TABLE_USER, mgmtRetrieveUsers);
dnodeAddServerMsgHandle(TSDB_MSG_TYPE_DM_AUTH, mgmtProcessAuthMsg);
mTrace("table:%s, hash is created", tableDesc.tableName); mTrace("table:%s, hash is created", tableDesc.tableName);
return 0; return 0;
...@@ -529,3 +531,40 @@ void mgmtDropAllUsers(SAcctObj *pAcct) { ...@@ -529,3 +531,40 @@ void mgmtDropAllUsers(SAcctObj *pAcct) {
mTrace("acct:%s, all users:%d is dropped from sdb", pAcct->user, numOfUsers); mTrace("acct:%s, all users:%d is dropped from sdb", pAcct->user, numOfUsers);
} }
int32_t mgmtRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey) {
if (!sdbIsMaster()) {
*secret = 0;
mTrace("user:%s, failed to auth user, reason:%s", user, tstrerror(TSDB_CODE_NOT_READY));
return TSDB_CODE_NOT_READY;
}
SUserObj *pUser = mgmtGetUser(user);
if (pUser == NULL) {
*secret = 0;
mError("user:%s, failed to auth user, reason:%s", user, tstrerror(TSDB_CODE_INVALID_USER));
return TSDB_CODE_INVALID_USER;
} else {
*spi = 1;
*encrypt = 0;
*ckey = 0;
memcpy(secret, pUser->pass, TSDB_KEY_LEN);
mgmtDecUserRef(pUser);
mTrace("user:%s, auth info is returned", user);
return TSDB_CODE_SUCCESS;
}
}
static void mgmtProcessAuthMsg(SRpcMsg *rpcMsg) {
SRpcMsg rpcRsp = {.handle = rpcMsg->handle, .pCont = NULL, .contLen = 0, .code = 0, .msgType = 0};
SDMAuthMsg *pAuthMsg = rpcMsg->pCont;
SDMAuthRsp *pAuthRsp = rpcMallocCont(sizeof(SDMAuthRsp));
rpcRsp.code = mgmtRetriveAuth(pAuthMsg->user, &pAuthRsp->spi, &pAuthRsp->encrypt, pAuthRsp->secret, pAuthRsp->ckey);
rpcRsp.pCont = pAuthRsp;
rpcRsp.contLen = sizeof(SDMAuthRsp);
rpcSendResponse(&rpcRsp);
}
...@@ -50,11 +50,11 @@ typedef struct tQueryInfo { ...@@ -50,11 +50,11 @@ typedef struct tQueryInfo {
SSchema sch; // schema of tags SSchema sch; // schema of tags
char* q; char* q;
__compar_fn_t compare; // filter function __compar_fn_t compare; // filter function
void* param; // STSchema, void* param; // STSchema
} tQueryInfo; } tQueryInfo;
typedef struct SExprTraverseSupp { typedef struct SExprTraverseSupp {
__result_filter_fn_t fp; __result_filter_fn_t nodeFilterFn;
__do_filter_suppl_fn_t setupInfoFn; __do_filter_suppl_fn_t setupInfoFn;
void * pExtInfo; void * pExtInfo;
} SExprTraverseSupp; } SExprTraverseSupp;
......
...@@ -110,6 +110,14 @@ typedef struct STableQueryInfo { // todo merge with the STableQueryInfo struct ...@@ -110,6 +110,14 @@ typedef struct STableQueryInfo { // todo merge with the STableQueryInfo struct
SWindowResInfo windowResInfo; SWindowResInfo windowResInfo;
} STableQueryInfo; } STableQueryInfo;
typedef struct SQueryCostSummary {
} SQueryCostSummary;
typedef struct SGroupItem {
STableId id;
STableQueryInfo* info;
} SGroupItem;
typedef struct SQuery { typedef struct SQuery {
int16_t numOfCols; int16_t numOfCols;
int16_t numOfTags; int16_t numOfTags;
...@@ -131,17 +139,15 @@ typedef struct SQuery { ...@@ -131,17 +139,15 @@ typedef struct SQuery {
SColumnInfo* tagColList; SColumnInfo* tagColList;
int32_t numOfFilterCols; int32_t numOfFilterCols;
int64_t* defaultVal; int64_t* defaultVal;
TSKEY lastKey; // TSKEY lastKey;
uint32_t status; // query status uint32_t status; // query status
SResultRec rec; SResultRec rec;
int32_t pos; int32_t pos;
SData** sdata; SData** sdata;
STableQueryInfo* current;
SSingleColumnFilterInfo* pFilterInfo; SSingleColumnFilterInfo* pFilterInfo;
} SQuery; } SQuery;
typedef struct SQueryCostSummary {
} SQueryCostSummary;
typedef struct SQueryRuntimeEnv { typedef struct SQueryRuntimeEnv {
SResultInfo* resultInfo; // todo refactor to merge with SWindowResInfo SResultInfo* resultInfo; // todo refactor to merge with SWindowResInfo
SQuery* pQuery; SQuery* pQuery;
......
...@@ -22,20 +22,20 @@ extern "C" { ...@@ -22,20 +22,20 @@ extern "C" {
#include "tlog.h" #include "tlog.h"
extern int32_t qdebugFlag; extern int32_t qDebugFlag;
#define qTrace(...) \ #define qTrace(...) \
if (qdebugFlag & DEBUG_TRACE) { \ if (qDebugFlag & DEBUG_TRACE) { \
taosPrintLog("DND QRY ", qdebugFlag, __VA_ARGS__); \ taosPrintLog("DND QRY ", qDebugFlag, __VA_ARGS__); \
} }
#define qError(...) \ #define qError(...) \
if (qdebugFlag & DEBUG_ERROR) { \ if (qDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR QRY ", qdebugFlag, __VA_ARGS__); \ taosPrintLog("ERROR QRY ", qDebugFlag, __VA_ARGS__); \
} }
#define qWarn(...) \ #define qWarn(...) \
if (qdebugFlag & DEBUG_WARN) { \ if (qDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN QRY ", qdebugFlag, __VA_ARGS__); \ taosPrintLog("WARN QRY ", qDebugFlag, __VA_ARGS__); \
} }
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -104,7 +104,7 @@ extern "C" { ...@@ -104,7 +104,7 @@ extern "C" {
enum { enum {
MASTER_SCAN = 0x0u, MASTER_SCAN = 0x0u,
SUPPLEMENTARY_SCAN = 0x1u, REVERSE_SCAN = 0x1u,
REPEAT_SCAN = 0x2u, //repeat scan belongs to the master scan REPEAT_SCAN = 0x2u, //repeat scan belongs to the master scan
FIRST_STAGE_MERGE = 0x10u, FIRST_STAGE_MERGE = 0x10u,
SECONDARY_STAGE_MERGE = 0x20u, SECONDARY_STAGE_MERGE = 0x20u,
......
...@@ -540,8 +540,11 @@ static int32_t setQueryCond(tQueryInfo *queryColInfo, SQueryCond* pCond) { ...@@ -540,8 +540,11 @@ static int32_t setQueryCond(tQueryInfo *queryColInfo, SQueryCond* pCond) {
static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* result) { static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* result) {
SSkipListIterator* iter = NULL; SSkipListIterator* iter = NULL;
SQueryCond cond = {0}; SQueryCond cond = {0};
setQueryCond(pQueryInfo, &cond); if (setQueryCond(pQueryInfo, &cond) != TSDB_CODE_SUCCESS) {
//todo handle error
}
if (cond.start != NULL) { if (cond.start != NULL) {
iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_ASC); iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_ASC);
...@@ -552,18 +555,18 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr ...@@ -552,18 +555,18 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
if (cond.start != NULL) { if (cond.start != NULL) {
int32_t optr = cond.start->optr; int32_t optr = cond.start->optr;
if (optr == TSDB_RELATION_EQUAL) { if (optr == TSDB_RELATION_EQUAL) { // equals
while(tSkipListIterNext(iter)) { while(tSkipListIterNext(iter)) {
SSkipListNode* pNode = tSkipListIterGet(iter); SSkipListNode* pNode = tSkipListIterGet(iter);
int32_t ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v); int32_t ret = pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v);
if (ret == 0) { if (ret != 0) {
taosArrayPush(result, SL_GET_NODE_DATA(pNode));
} else {
break; break;
} }
taosArrayPush(result, SL_GET_NODE_DATA(pNode));
} }
} else if (optr == TSDB_RELATION_GREATER || optr == TSDB_RELATION_GREATER_EQUAL) { } else if (optr == TSDB_RELATION_GREATER || optr == TSDB_RELATION_GREATER_EQUAL) { // greater equal
bool comp = true; bool comp = true;
int32_t ret = 0; int32_t ret = 0;
...@@ -582,8 +585,33 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr ...@@ -582,8 +585,33 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
comp = false; comp = false;
} }
} }
} else if (optr == TSDB_RELATION_NOT_EQUAL) { } else if (optr == TSDB_RELATION_NOT_EQUAL) { // not equal
assert(0); bool comp = true;
while(tSkipListIterNext(iter)) {
SSkipListNode* pNode = tSkipListIterGet(iter);
comp = comp && (pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v) == 0);
if (comp) {
continue;
}
taosArrayPush(result, SL_GET_NODE_DATA(pNode));
}
tSkipListDestroyIter(iter);
comp = true;
iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_DESC);
while(tSkipListIterNext(iter)) {
SSkipListNode* pNode = tSkipListIterGet(iter);
comp = comp && (pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v) == 0);
if (comp) {
continue;
}
taosArrayPush(result, SL_GET_NODE_DATA(pNode));
}
} else { } else {
assert(0); assert(0);
} }
...@@ -732,7 +760,7 @@ static bool filterItem(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *p ...@@ -732,7 +760,7 @@ static bool filterItem(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *p
assert(pLeft->nodeType == TSQL_NODE_COL && pRight->nodeType == TSQL_NODE_VALUE); assert(pLeft->nodeType == TSQL_NODE_COL && pRight->nodeType == TSQL_NODE_VALUE);
param->setupInfoFn(pExpr, param->pExtInfo); param->setupInfoFn(pExpr, param->pExtInfo);
return param->fp(pItem, pExpr->_node.info); return param->nodeFilterFn(pItem, pExpr->_node.info);
} }
/** /**
...@@ -773,35 +801,33 @@ static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSki ...@@ -773,35 +801,33 @@ static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSki
tSkipListDestroyIter(iter); tSkipListDestroyIter(iter);
} }
static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* res, __result_filter_fn_t filterFp) {
static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArray* result) {
SSkipListIterator* iter = tSkipListCreateIter(pSkipList); SSkipListIterator* iter = tSkipListCreateIter(pSkipList);
while (tSkipListIterNext(iter)) { while (tSkipListIterNext(iter)) {
bool addToResult = false; bool addToResult = false;
SSkipListNode *pNode = tSkipListIterGet(iter); SSkipListNode *pNode = tSkipListIterGet(iter);
char* pTable = SL_GET_NODE_DATA(pNode); char * pData = SL_GET_NODE_DATA(pNode);
//todo refactor: // todo refactor:
char* name = (*(STable**) pTable)->name; tstr *name = ((STableIndexElem *)pData)->pTable->name;
// char* name = NULL; // char* name = NULL;
// tsdbGetTableName(tsdb, pTable, &name); // tsdbGetTableName(pQueryInfo->, pTable, &name);
// todo speed up by using hash // todo speed up by using hash
if (pQueryInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) { if (pQueryInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) {
if (pQueryInfo->optr == TSDB_RELATION_IN) { if (pQueryInfo->optr == TSDB_RELATION_IN) {
addToResult = pQueryInfo->compare(name, pQueryInfo->q); addToResult = pQueryInfo->compare(name, pQueryInfo->q);
} else if(pQueryInfo->optr == TSDB_RELATION_LIKE) { } else if (pQueryInfo->optr == TSDB_RELATION_LIKE) {
addToResult = !pQueryInfo->compare(name, pQueryInfo->q); addToResult = !pQueryInfo->compare(name, pQueryInfo->q);
} }
} else { } else {
// TODO: other columns addToResult = filterFp(pNode, pQueryInfo);
} }
if (addToResult) { if (addToResult) {
taosArrayPush(result, pTable); taosArrayPush(res, pData);
} }
} }
...@@ -825,7 +851,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S ...@@ -825,7 +851,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
param->setupInfoFn(pExpr, param->pExtInfo); param->setupInfoFn(pExpr, param->pExtInfo);
if (pSkipList == NULL) { if (pSkipList == NULL) {
tArrayTraverse(pExpr, param->fp, result); tArrayTraverse(pExpr, param->nodeFilterFn, result);
return; return;
} }
...@@ -833,7 +859,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S ...@@ -833,7 +859,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
if (pQueryInfo->colIndex == 0 && pQueryInfo->optr != TSDB_RELATION_LIKE) { if (pQueryInfo->colIndex == 0 && pQueryInfo->optr != TSDB_RELATION_LIKE) {
tQueryIndexColumn(pSkipList, pQueryInfo, result); tQueryIndexColumn(pSkipList, pQueryInfo, result);
} else { } else {
tQueryIndexlessColumn(pSkipList, pQueryInfo, result); tQueryIndexlessColumn(pSkipList, pQueryInfo, result, param->nodeFilterFn);
} }
return; return;
......
...@@ -820,7 +820,7 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI ...@@ -820,7 +820,7 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI
pInfo->pDCLInfo->dbOpt = *pDB; pInfo->pDCLInfo->dbOpt = *pDB;
pInfo->pDCLInfo->dbOpt.dbname = *pToken; pInfo->pDCLInfo->dbOpt.dbname = *pToken;
pInfo->pDCLInfo->dbOpt.ignoreExists = (pIgExists->z != NULL); pInfo->pDCLInfo->dbOpt.ignoreExists = pIgExists->n; // sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
} }
void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken *pPwd, SCreateAcctSQL *pAcctInfo) { void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken *pPwd, SCreateAcctSQL *pAcctInfo) {
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
#define QUERY_IS_ASC_QUERY(q) (GET_FORWARD_DIRECTION_FACTOR((q)->order.order) == QUERY_ASC_FORWARD_STEP) #define QUERY_IS_ASC_QUERY(q) (GET_FORWARD_DIRECTION_FACTOR((q)->order.order) == QUERY_ASC_FORWARD_STEP)
#define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN) #define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN)
#define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == SUPPLEMENTARY_SCAN) #define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN)
#define SET_MASTER_SCAN_FLAG(runtime) ((runtime)->scanFlag = MASTER_SCAN) #define SET_MASTER_SCAN_FLAG(runtime) ((runtime)->scanFlag = MASTER_SCAN)
#define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = SUPPLEMENTARY_SCAN) #define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = REVERSE_SCAN)
#define GET_QINFO_ADDR(x) ((void *)((char *)(x)-offsetof(SQInfo, runtimeEnv))) #define GET_QINFO_ADDR(x) ((void *)((char *)(x)-offsetof(SQInfo, runtimeEnv)))
...@@ -96,11 +96,6 @@ typedef struct { ...@@ -96,11 +96,6 @@ typedef struct {
STSCursor cur; STSCursor cur;
} SQueryStatusInfo; } SQueryStatusInfo;
typedef struct SGroupItem {
STableId id;
STableQueryInfo* info;
} SGroupItem;
static void setQueryStatus(SQuery *pQuery, int8_t status); static void setQueryStatus(SQuery *pQuery, int8_t status);
static bool isIntervalQuery(SQuery *pQuery) { return pQuery->intervalTime > 0; } static bool isIntervalQuery(SQuery *pQuery) { return pQuery->intervalTime > 0; }
...@@ -121,7 +116,7 @@ static bool hasMainOutput(SQuery *pQuery); ...@@ -121,7 +116,7 @@ static bool hasMainOutput(SQuery *pQuery);
static void createTableQueryInfo(SQInfo *pQInfo); static void createTableQueryInfo(SQInfo *pQInfo);
static void buildTagQueryResult(SQInfo *pQInfo); static void buildTagQueryResult(SQInfo *pQInfo);
static int32_t setAdditionalInfo(SQInfo *pQInfo, STableId *pTaleId, STableQueryInfo *pTableQueryInfo); static int32_t setAdditionalInfo(SQInfo *pQInfo, STableId *pTableId, STableQueryInfo *pTableQueryInfo);
static int32_t flushFromResultBuf(SQInfo *pQInfo); static int32_t flushFromResultBuf(SQInfo *pQInfo);
bool getNeighborPoints(SQInfo *pQInfo, void *pMeterObj, SPointInterpoSupporter *pPointInterpSupporter) { bool getNeighborPoints(SQInfo *pQInfo, void *pMeterObj, SPointInterpoSupporter *pPointInterpSupporter) {
...@@ -428,9 +423,10 @@ static bool hasNullValue(SQuery *pQuery, int32_t col, SDataBlockInfo *pDataBlock ...@@ -428,9 +423,10 @@ static bool hasNullValue(SQuery *pQuery, int32_t col, SDataBlockInfo *pDataBlock
return false; return false;
} }
*pColStatis = NULL;
if (pStatis != NULL) { if (pStatis != NULL) {
*pColStatis = getStatisInfo(pQuery, pStatis, pDataBlockInfo, col); *pColStatis = getStatisInfo(pQuery, pStatis, pDataBlockInfo, col);
} else {
*pColStatis = NULL;
} }
if ((*pColStatis) != NULL && (*pColStatis)->numOfNull == 0) { if ((*pColStatis) != NULL && (*pColStatis)->numOfNull == 0) {
...@@ -620,8 +616,8 @@ static void doCheckQueryCompleted(SQueryRuntimeEnv *pRuntimeEnv, TSKEY lastKey, ...@@ -620,8 +616,8 @@ static void doCheckQueryCompleted(SQueryRuntimeEnv *pRuntimeEnv, TSKEY lastKey,
} }
// query completed // query completed
if ((lastKey >= pQuery->window.ekey && QUERY_IS_ASC_QUERY(pQuery)) || if ((lastKey >= pQuery->current->win.ekey && QUERY_IS_ASC_QUERY(pQuery)) ||
(lastKey <= pQuery->window.ekey && !QUERY_IS_ASC_QUERY(pQuery))) { (lastKey <= pQuery->current->win.ekey && !QUERY_IS_ASC_QUERY(pQuery))) {
closeAllTimeWindow(pWindowResInfo); closeAllTimeWindow(pWindowResInfo);
pWindowResInfo->curIndex = pWindowResInfo->size - 1; pWindowResInfo->curIndex = pWindowResInfo->size - 1;
...@@ -661,22 +657,22 @@ static void doCheckQueryCompleted(SQueryRuntimeEnv *pRuntimeEnv, TSKEY lastKey, ...@@ -661,22 +657,22 @@ static void doCheckQueryCompleted(SQueryRuntimeEnv *pRuntimeEnv, TSKEY lastKey,
setQueryStatus(pQuery, QUERY_RESBUF_FULL); setQueryStatus(pQuery, QUERY_RESBUF_FULL);
} }
qTrace("QInfo:%p total window:%d, closed:%d", GET_QINFO_ADDR(pQuery), pWindowResInfo->size, n); qTrace("QInfo:%p total window:%d, closed:%d", GET_QINFO_ADDR(pRuntimeEnv), pWindowResInfo->size, n);
} }
assert(pWindowResInfo->prevSKey != 0); assert(pWindowResInfo->prevSKey != 0);
} }
static int32_t getNumOfRowsInTimeWindow(SQuery *pQuery, SDataBlockInfo *pDataBlockInfo, TSKEY *pPrimaryColumn, static int32_t getNumOfRowsInTimeWindow(SQuery *pQuery, SDataBlockInfo *pDataBlockInfo, TSKEY *pPrimaryColumn,
int32_t startPos, TSKEY ekey, __block_search_fn_t searchFn, int32_t startPos, TSKEY ekey, __block_search_fn_t searchFn, bool updateLastKey) {
bool updateLastKey) {
assert(startPos >= 0 && startPos < pDataBlockInfo->rows); assert(startPos >= 0 && startPos < pDataBlockInfo->rows);
int32_t num = -1; int32_t num = -1;
int32_t order = pQuery->order.order; int32_t order = pQuery->order.order;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(order); int32_t step = GET_FORWARD_DIRECTION_FACTOR(order);
STableQueryInfo* item = pQuery->current;
if (QUERY_IS_ASC_QUERY(pQuery)) { if (QUERY_IS_ASC_QUERY(pQuery)) {
if (ekey < pDataBlockInfo->window.ekey) { if (ekey < pDataBlockInfo->window.ekey) {
num = getForwardStepsInBlock(pDataBlockInfo->rows, searchFn, ekey, startPos, order, pPrimaryColumn); num = getForwardStepsInBlock(pDataBlockInfo->rows, searchFn, ekey, startPos, order, pPrimaryColumn);
...@@ -684,13 +680,13 @@ static int32_t getNumOfRowsInTimeWindow(SQuery *pQuery, SDataBlockInfo *pDataBlo ...@@ -684,13 +680,13 @@ static int32_t getNumOfRowsInTimeWindow(SQuery *pQuery, SDataBlockInfo *pDataBlo
assert(ekey < pPrimaryColumn[startPos]); assert(ekey < pPrimaryColumn[startPos]);
} else { } else {
if (updateLastKey) { if (updateLastKey) {
pQuery->lastKey = pPrimaryColumn[startPos + (num - 1)] + step; item->lastKey = pPrimaryColumn[startPos + (num - 1)] + step;
} }
} }
} else { } else {
num = pDataBlockInfo->rows - startPos; num = pDataBlockInfo->rows - startPos;
if (updateLastKey) { if (updateLastKey) {
pQuery->lastKey = pDataBlockInfo->window.ekey + step; item->lastKey = pDataBlockInfo->window.ekey + step;
} }
} }
} else { // desc } else { // desc
...@@ -700,13 +696,13 @@ static int32_t getNumOfRowsInTimeWindow(SQuery *pQuery, SDataBlockInfo *pDataBlo ...@@ -700,13 +696,13 @@ static int32_t getNumOfRowsInTimeWindow(SQuery *pQuery, SDataBlockInfo *pDataBlo
assert(ekey > pPrimaryColumn[startPos]); assert(ekey > pPrimaryColumn[startPos]);
} else { } else {
if (updateLastKey) { if (updateLastKey) {
pQuery->lastKey = pPrimaryColumn[startPos - (num - 1)] + step; item->lastKey = pPrimaryColumn[startPos - (num - 1)] + step;
} }
} }
} else { } else {
num = startPos + 1; num = startPos + 1;
if (updateLastKey) { if (updateLastKey) {
pQuery->lastKey = pDataBlockInfo->window.skey + step; item->lastKey = pDataBlockInfo->window.skey + step;
} }
} }
} }
...@@ -820,7 +816,21 @@ static TSKEY reviseWindowEkey(SQuery *pQuery, STimeWindow *pWindow) { ...@@ -820,7 +816,21 @@ static TSKEY reviseWindowEkey(SQuery *pQuery, STimeWindow *pWindow) {
return ekey; return ekey;
} }
char *getDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas, int32_t col, int32_t size, //todo binary search
static void* getDataBlockImpl(SArray* pDataBlock, int32_t colId) {
int32_t numOfCols = taosArrayGetSize(pDataBlock);
for (int32_t i = 0; i < numOfCols; ++i) {
SColumnInfoData *p = taosArrayGet(pDataBlock, i);
if (colId == p->info.colId) {
return p->pData;
}
}
return NULL;
}
static char *getDataBlock(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas, int32_t col, int32_t size,
SArray *pDataBlock) { SArray *pDataBlock) {
char *dataBlock = NULL; char *dataBlock = NULL;
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
...@@ -867,20 +877,7 @@ char *getDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas, int3 ...@@ -867,20 +877,7 @@ char *getDataBlocks(SQueryRuntimeEnv *pRuntimeEnv, SArithmeticSupport *sas, int3
if (TSDB_COL_IS_TAG(pCol->flag) || pDataBlock == NULL) { if (TSDB_COL_IS_TAG(pCol->flag) || pDataBlock == NULL) {
dataBlock = NULL; dataBlock = NULL;
} else { } else {
/* dataBlock = getDataBlockImpl(pDataBlock, pCol->colId);
* the colIndex is acquired from the first meter of all qualified meters in this vnode during query prepare
* stage, the remain meter may not have the required column in cache actually. So, the validation of required
* column in cache with the corresponding meter schema is reinforced.
*/
int32_t numOfCols = taosArrayGetSize(pDataBlock);
for (int32_t i = 0; i < numOfCols; ++i) {
SColumnInfoData *p = taosArrayGet(pDataBlock, i);
if (pCol->colId == p->info.colId) {
dataBlock = p->pData;
break;
}
}
} }
} }
...@@ -904,8 +901,8 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis * ...@@ -904,8 +901,8 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
SQuery * pQuery = pRuntimeEnv->pQuery; SQuery * pQuery = pRuntimeEnv->pQuery;
SColumnInfoData *pColInfo = NULL; SColumnInfoData *pColInfo = NULL;
TSKEY * primaryKeyCol = NULL;
TSKEY *primaryKeyCol = NULL;
if (pDataBlock != NULL) { if (pDataBlock != NULL) {
pColInfo = taosArrayGet(pDataBlock, 0); pColInfo = taosArrayGet(pDataBlock, 0);
primaryKeyCol = (TSKEY *)(pColInfo->pData); primaryKeyCol = (TSKEY *)(pColInfo->pData);
...@@ -919,7 +916,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis * ...@@ -919,7 +916,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
SDataStatis *tpField = NULL; SDataStatis *tpField = NULL;
bool hasNull = hasNullValue(pQuery, k, pDataBlockInfo, pStatis, &tpField); bool hasNull = hasNullValue(pQuery, k, pDataBlockInfo, pStatis, &tpField);
char *dataBlock = getDataBlocks(pRuntimeEnv, &sasArray[k], k, pDataBlockInfo->rows, pDataBlock); char *dataBlock = getDataBlock(pRuntimeEnv, &sasArray[k], k, pDataBlockInfo->rows, pDataBlock);
setExecParams(pQuery, &pCtx[k], dataBlock, primaryKeyCol, pDataBlockInfo->rows, functionId, tpField, hasNull, setExecParams(pQuery, &pCtx[k], dataBlock, primaryKeyCol, pDataBlockInfo->rows, functionId, tpField, hasNull,
&sasArray[k], pRuntimeEnv->scanFlag); &sasArray[k], pRuntimeEnv->scanFlag);
...@@ -1095,15 +1092,20 @@ static int32_t doTSJoinFilter(SQueryRuntimeEnv *pRuntimeEnv, int32_t offset) { ...@@ -1095,15 +1092,20 @@ static int32_t doTSJoinFilter(SQueryRuntimeEnv *pRuntimeEnv, int32_t offset) {
static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx *pCtx, int32_t functionId) { static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx *pCtx, int32_t functionId) {
SResultInfo *pResInfo = GET_RES_INFO(pCtx); SResultInfo *pResInfo = GET_RES_INFO(pCtx);
SQuery* pQuery = pRuntimeEnv->pQuery;
if (pResInfo->complete || functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) { if (pResInfo->complete || functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) {
return false; return false;
} }
if (functionId == TSDB_FUNC_LAST_DST || functionId == TSDB_FUNC_LAST) {
return !QUERY_IS_ASC_QUERY(pQuery);
} else if (functionId == TSDB_FUNC_FIRST_DST || functionId == TSDB_FUNC_FIRST) {
return QUERY_IS_ASC_QUERY(pQuery);
}
// in the supplementary scan, only the following functions need to be executed // in the supplementary scan, only the following functions need to be executed
if (IS_REVERSE_SCAN(pRuntimeEnv) && if (IS_REVERSE_SCAN(pRuntimeEnv)) {// && (functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_TS)) {
!(functionId == TSDB_FUNC_LAST_DST || functionId == TSDB_FUNC_FIRST_DST || functionId == TSDB_FUNC_FIRST ||
functionId == TSDB_FUNC_LAST || functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_TS)) {
return false; return false;
} }
...@@ -1115,8 +1117,9 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS ...@@ -1115,8 +1117,9 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx; SQLFunctionCtx *pCtx = pRuntimeEnv->pCtx;
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
TSKEY *primaryKeyCol = (TSKEY*) ((SColumnInfoData *)taosArrayGet(pDataBlock, 0))->pData; STableQueryInfo* item = pQuery->current;
TSKEY *primaryKeyCol = (TSKEY*) ((SColumnInfoData *)taosArrayGet(pDataBlock, 0))->pData;
bool groupbyStateValue = isGroupbyNormalCol(pQuery->pGroupbyExpr); bool groupbyStateValue = isGroupbyNormalCol(pQuery->pGroupbyExpr);
SArithmeticSupport *sasArray = calloc((size_t)pQuery->numOfOutput, sizeof(SArithmeticSupport)); SArithmeticSupport *sasArray = calloc((size_t)pQuery->numOfOutput, sizeof(SArithmeticSupport));
...@@ -1134,7 +1137,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS ...@@ -1134,7 +1137,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
SDataStatis *pColStatis = NULL; SDataStatis *pColStatis = NULL;
bool hasNull = hasNullValue(pQuery, k, pDataBlockInfo, pStatis, &pColStatis); bool hasNull = hasNullValue(pQuery, k, pDataBlockInfo, pStatis, &pColStatis);
char *dataBlock = getDataBlocks(pRuntimeEnv, &sasArray[k], k, pDataBlockInfo->rows, pDataBlock); char *dataBlock = getDataBlock(pRuntimeEnv, &sasArray[k], k, pDataBlockInfo->rows, pDataBlock);
setExecParams(pQuery, &pCtx[k], dataBlock, primaryKeyCol, pDataBlockInfo->rows, functionId, pColStatis, hasNull, setExecParams(pQuery, &pCtx[k], dataBlock, primaryKeyCol, pDataBlockInfo->rows, functionId, pColStatis, hasNull,
&sasArray[k], pRuntimeEnv->scanFlag); &sasArray[k], pRuntimeEnv->scanFlag);
...@@ -1143,7 +1146,8 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS ...@@ -1143,7 +1146,8 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
// set the input column data // set the input column data
for (int32_t k = 0; k < pQuery->numOfFilterCols; ++k) { for (int32_t k = 0; k < pQuery->numOfFilterCols; ++k) {
SSingleColumnFilterInfo *pFilterInfo = &pQuery->pFilterInfo[k]; SSingleColumnFilterInfo *pFilterInfo = &pQuery->pFilterInfo[k];
pFilterInfo->pData = getDataBlocks(pRuntimeEnv, &sasArray[k], pFilterInfo->info.colId, pDataBlockInfo->rows, pDataBlock); pFilterInfo->pData = getDataBlockImpl(pDataBlock, pFilterInfo->info.colId);
assert(pFilterInfo->pData != NULL);
} }
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
...@@ -1157,10 +1161,10 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS ...@@ -1157,10 +1161,10 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
} }
int32_t j = 0; int32_t j = 0;
TSKEY lastKey = -1; int32_t offset = -1;
for (j = 0; j < pDataBlockInfo->rows; ++j) { for (j = 0; j < pDataBlockInfo->rows; ++j) {
int32_t offset = GET_COL_DATA_POS(pQuery, j, step); offset = GET_COL_DATA_POS(pQuery, j, step);
if (pRuntimeEnv->pTSBuf != NULL) { if (pRuntimeEnv->pTSBuf != NULL) {
int32_t r = doTSJoinFilter(pRuntimeEnv, offset); int32_t r = doTSJoinFilter(pRuntimeEnv, offset);
...@@ -1194,7 +1198,6 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS ...@@ -1194,7 +1198,6 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
SWindowStatus *pStatus = getTimeWindowResStatus(pWindowResInfo, curTimeWindow(pWindowResInfo)); SWindowStatus *pStatus = getTimeWindowResStatus(pWindowResInfo, curTimeWindow(pWindowResInfo));
doRowwiseApplyFunctions(pRuntimeEnv, pStatus, &win, offset); doRowwiseApplyFunctions(pRuntimeEnv, pStatus, &win, offset);
lastKey = ts;
STimeWindow nextWin = win; STimeWindow nextWin = win;
int32_t index = pWindowResInfo->curIndex; int32_t index = pWindowResInfo->curIndex;
...@@ -1223,17 +1226,14 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS ...@@ -1223,17 +1226,14 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
} else { // other queries } else { // other queries
// decide which group this rows belongs to according to current state value // decide which group this rows belongs to according to current state value
if (groupbyStateValue) { if (groupbyStateValue) {
char *stateVal = groupbyColumnData + bytes * offset; char *val = groupbyColumnData + bytes * offset;
int32_t ret = setGroupResultOutputBuf(pRuntimeEnv, stateVal, type, bytes); int32_t ret = setGroupResultOutputBuf(pRuntimeEnv, val, type, bytes);
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
continue; continue;
} }
} }
// update the lastKey
lastKey = primaryKeyCol[offset];
// all startOffset are identical // all startOffset are identical
offset -= pCtx[0].startOffset; offset -= pCtx[0].startOffset;
...@@ -1254,7 +1254,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS ...@@ -1254,7 +1254,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
} }
} }
pQuery->lastKey = lastKey + step; item->lastKey = primaryKeyCol[offset] + step;
// todo refactor: extract method // todo refactor: extract method
for(int32_t i = 0; i < pQuery->numOfOutput; ++i) { for(int32_t i = 0; i < pQuery->numOfOutput; ++i) {
...@@ -1269,10 +1269,12 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS ...@@ -1269,10 +1269,12 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
} }
static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pDataBlockInfo, static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pDataBlockInfo,
SDataStatis *pStatis, __block_search_fn_t searchFn, SDataStatis *pStatis, __block_search_fn_t searchFn, SArray *pDataBlock) {
SWindowResInfo *pWindowResInfo, SArray *pDataBlock) {
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
STableQueryInfo* pTableQInfo = pQuery->current;
SWindowResInfo* pWindowResInfo = &pRuntimeEnv->windowResInfo;
if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL || isGroupbyNormalCol(pQuery->pGroupbyExpr)) { if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTSBuf != NULL || isGroupbyNormalCol(pQuery->pGroupbyExpr)) {
rowwiseApplyFunctions(pRuntimeEnv, pStatis, pDataBlockInfo, pWindowResInfo, pDataBlock); rowwiseApplyFunctions(pRuntimeEnv, pStatis, pDataBlockInfo, pWindowResInfo, pDataBlock);
} else { } else {
...@@ -1280,7 +1282,7 @@ static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBl ...@@ -1280,7 +1282,7 @@ static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBl
} }
TSKEY lastKey = QUERY_IS_ASC_QUERY(pQuery) ? pDataBlockInfo->window.ekey : pDataBlockInfo->window.skey; TSKEY lastKey = QUERY_IS_ASC_QUERY(pQuery) ? pDataBlockInfo->window.ekey : pDataBlockInfo->window.skey;
pQuery->lastKey = lastKey + GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); pTableQInfo->lastKey = lastKey + GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
doCheckQueryCompleted(pRuntimeEnv, lastKey, pWindowResInfo); doCheckQueryCompleted(pRuntimeEnv, lastKey, pWindowResInfo);
...@@ -1746,73 +1748,6 @@ static UNUSED_FUNC bool doSetDataInfo(SQInfo *pQInfo, SPointInterpoSupporter *pP ...@@ -1746,73 +1748,6 @@ static UNUSED_FUNC bool doSetDataInfo(SQInfo *pQInfo, SPointInterpoSupporter *pP
} }
} }
// TODO refactor code, the best way to implement the last_row is utilizing the iterator
bool normalizeUnBoundLastRowQuery(SQInfo *pQInfo, SPointInterpoSupporter *pPointInterpSupporter) {
#if 0
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
SQuery * pQuery = pRuntimeEnv->pQuery;
SMeterObj *pMeterObj = pRuntimeEnv->pTabObj;
assert(!QUERY_IS_ASC_QUERY(pQuery) && notHasQueryTimeRange(pQuery));
__block_search_fn_t searchFn = vnodeSearchKeyFunc[pMeterObj->searchAlgorithm];
TSKEY lastKey = -1;
pQuery->fileId = -1;
vnodeFreeFieldsEx(pRuntimeEnv);
// keep in-memory cache status in local variables in case that it may be changed by write operation
getBasicCacheInfoSnapshot(pQuery, pMeterObj->pCache, pMeterObj->vnode);
SCacheInfo *pCacheInfo = (SCacheInfo *)pMeterObj->pCache;
if (pCacheInfo != NULL && pCacheInfo->cacheBlocks != NULL && pQuery->numOfBlocks > 0) {
pQuery->fileId = -1;
TSKEY key = pMeterObj->lastKey;
pQuery->window.skey = key;
pQuery->window.ekey = key;
pQuery->lastKey = pQuery->window.skey;
/*
* cache block may have been flushed to disk, and no data in cache anymore.
* So, copy cache block to local buffer is required.
*/
lastKey = getQueryStartPositionInCache(pRuntimeEnv, &pQuery->slot, &pQuery->pos, false);
if (lastKey < 0) { // data has been flushed to disk, try again search in file
lastKey = getQueryPositionForCacheInvalid(pRuntimeEnv, searchFn);
if (Q_STATUS_EQUAL(pQuery->status, QUERY_NO_DATA_TO_CHECK | QUERY_COMPLETED)) {
return false;
}
}
} else { // no data in cache, try file
TSKEY key = pMeterObj->lastKeyOnFile;
pQuery->window.skey = key;
pQuery->window.ekey = key;
pQuery->lastKey = pQuery->window.skey;
bool ret = getQualifiedDataBlock(pMeterObj, pRuntimeEnv, QUERY_RANGE_LESS_EQUAL, searchFn);
if (!ret) { // no data in file, return false;
return false;
}
lastKey = getTimestampInDiskBlock(pRuntimeEnv, pQuery->pos);
}
assert(lastKey <= pQuery->window.skey);
pQuery->window.skey = lastKey;
pQuery->window.ekey = lastKey;
pQuery->lastKey = pQuery->window.skey;
return getNeighborPoints(pQInfo, pMeterObj, pPointInterpSupporter);
#endif
return true;
}
static void setScanLimitationByResultBuffer(SQuery *pQuery) { static void setScanLimitationByResultBuffer(SQuery *pQuery) {
if (isTopBottomQuery(pQuery)) { if (isTopBottomQuery(pQuery)) {
pQuery->checkBuffer = 0; pQuery->checkBuffer = 0;
...@@ -2327,7 +2262,7 @@ static void getNextTimeWindow(SQuery *pQuery, STimeWindow *pTimeWindow) { ...@@ -2327,7 +2262,7 @@ static void getNextTimeWindow(SQuery *pQuery, STimeWindow *pTimeWindow) {
pTimeWindow->ekey = pTimeWindow->skey + (pQuery->intervalTime - 1); pTimeWindow->ekey = pTimeWindow->skey + (pQuery->intervalTime - 1);
} }
SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBlockInfo, SDataStatis **pStatis) { SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, void* pQueryHandle, SDataBlockInfo* pBlockInfo, SDataStatis **pStatis) {
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
uint32_t r = 0; uint32_t r = 0;
...@@ -2351,16 +2286,16 @@ SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBl ...@@ -2351,16 +2286,16 @@ SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBl
qTrace("QInfo:%p data block ignored, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_QINFO_ADDR(pRuntimeEnv), qTrace("QInfo:%p data block ignored, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_QINFO_ADDR(pRuntimeEnv),
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
} else if (r == BLK_DATA_FILEDS_NEEDED) { } else if (r == BLK_DATA_FILEDS_NEEDED) {
if (tsdbRetrieveDataBlockStatisInfo(pRuntimeEnv->pQueryHandle, pStatis) != TSDB_CODE_SUCCESS) { if (tsdbRetrieveDataBlockStatisInfo(pQueryHandle, pStatis) != TSDB_CODE_SUCCESS) {
// return DISK_DATA_LOAD_FAILED; // return DISK_DATA_LOAD_FAILED;
} }
if (*pStatis == NULL) { if (*pStatis == NULL) {
pDataBlock = tsdbRetrieveDataBlock(pRuntimeEnv->pQueryHandle, NULL); pDataBlock = tsdbRetrieveDataBlock(pQueryHandle, NULL);
} }
} else { } else {
assert(r == BLK_DATA_ALL_NEEDED); assert(r == BLK_DATA_ALL_NEEDED);
if (tsdbRetrieveDataBlockStatisInfo(pRuntimeEnv->pQueryHandle, pStatis) != TSDB_CODE_SUCCESS) { if (tsdbRetrieveDataBlockStatisInfo(pQueryHandle, pStatis) != TSDB_CODE_SUCCESS) {
// return DISK_DATA_LOAD_FAILED; // return DISK_DATA_LOAD_FAILED;
} }
...@@ -2376,7 +2311,7 @@ SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBl ...@@ -2376,7 +2311,7 @@ SArray *loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBl
// return DISK_DATA_DISCARDED; // return DISK_DATA_DISCARDED;
} }
pDataBlock = tsdbRetrieveDataBlock(pRuntimeEnv->pQueryHandle, NULL); pDataBlock = tsdbRetrieveDataBlock(pQueryHandle, NULL);
} }
return pDataBlock; return pDataBlock;
...@@ -2447,8 +2382,11 @@ int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order) { ...@@ -2447,8 +2382,11 @@ int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order) {
static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
STableQueryInfo* pTableQueryInfo = pQuery->current;
qTrace("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", lastkey:%" PRId64 ", order:%d", qTrace("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", lastkey:%" PRId64 ", order:%d",
GET_QINFO_ADDR(pRuntimeEnv), pQuery->window.skey, pQuery->window.ekey, pQuery->lastKey, pQuery->order.order); GET_QINFO_ADDR(pRuntimeEnv), pTableQueryInfo->win.skey, pTableQueryInfo->win.ekey, pTableQueryInfo->lastKey,
pQuery->order.order);
TsdbQueryHandleT pQueryHandle = IS_MASTER_SCAN(pRuntimeEnv)? pRuntimeEnv->pQueryHandle : pRuntimeEnv->pSecQueryHandle; TsdbQueryHandleT pQueryHandle = IS_MASTER_SCAN(pRuntimeEnv)? pRuntimeEnv->pQueryHandle : pRuntimeEnv->pSecQueryHandle;
while (tsdbNextDataBlock(pQueryHandle)) { while (tsdbNextDataBlock(pQueryHandle)) {
...@@ -2479,7 +2417,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -2479,7 +2417,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
} }
} }
// in case of prj/diff query, ensure the output buffer is sufficient to accomodate the results of current block // in case of prj/diff query, ensure the output buffer is sufficient to accommodate the results of current block
if (!isIntervalQuery(pQuery) && !isGroupbyNormalCol(pQuery->pGroupbyExpr) && !isFixedOutputQuery(pQuery)) { if (!isIntervalQuery(pQuery) && !isGroupbyNormalCol(pQuery->pGroupbyExpr) && !isFixedOutputQuery(pQuery)) {
SResultRec *pRec = &pQuery->rec; SResultRec *pRec = &pQuery->rec;
...@@ -2498,18 +2436,25 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -2498,18 +2436,25 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
// set the pCtx output buffer position // set the pCtx output buffer position
pRuntimeEnv->pCtx[i].aOutputBuf = pQuery->sdata[i]->data + pRec->rows * bytes; pRuntimeEnv->pCtx[i].aOutputBuf = pQuery->sdata[i]->data + pRec->rows * bytes;
int32_t functionId = pQuery->pSelectExpr[i].base.functionId;
if (functionId == TSDB_FUNC_TOP || functionId == TSDB_FUNC_BOTTOM || functionId == TSDB_FUNC_DIFF) {
pRuntimeEnv->pCtx[i].ptsOutputBuf = pRuntimeEnv->pCtx[0].aOutputBuf;
} }
}
qTrace("QInfo: %p realloc output buffer, new size: %d rows, old:%d, remain:%d", GET_QINFO_ADDR(pRuntimeEnv),
newSize, pRec->capacity, newSize - pRec->rows);
pRec->capacity = newSize; pRec->capacity = newSize;
} }
} }
SDataStatis *pStatis = NULL; SDataStatis *pStatis = NULL;
SArray * pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, &blockInfo, &pStatis); SArray * pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis);
pQuery->pos = QUERY_IS_ASC_QUERY(pQuery) ? 0 : blockInfo.rows - 1; pQuery->pos = QUERY_IS_ASC_QUERY(pQuery) ? 0 : blockInfo.rows - 1;
int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, binarySearchForKey, int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, pStatis, binarySearchForKey, pDataBlock);
&pRuntimeEnv->windowResInfo, pDataBlock);
qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, res:%d", GET_QINFO_ADDR(pRuntimeEnv), qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, res:%d", GET_QINFO_ADDR(pRuntimeEnv),
blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, numOfRes); blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, numOfRes);
...@@ -2520,7 +2465,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -2520,7 +2465,7 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
} }
} }
// if the result buffer is not full, set the query completed flag // if the result buffer is not full, set the query complete
if (!Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL)) { if (!Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL)) {
setQueryStatus(pQuery, QUERY_COMPLETED); setQueryStatus(pQuery, QUERY_COMPLETED);
} }
...@@ -2530,8 +2475,8 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -2530,8 +2475,8 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
int32_t step = QUERY_IS_ASC_QUERY(pQuery) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP; int32_t step = QUERY_IS_ASC_QUERY(pQuery) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP;
closeAllTimeWindow(&pRuntimeEnv->windowResInfo); closeAllTimeWindow(&pRuntimeEnv->windowResInfo);
removeRedundantWindow(&pRuntimeEnv->windowResInfo, pQuery->lastKey - step, step); removeRedundantWindow(&pRuntimeEnv->windowResInfo, pTableQueryInfo->lastKey - step, step);
pRuntimeEnv->windowResInfo.curIndex = pRuntimeEnv->windowResInfo.size - 1; pRuntimeEnv->windowResInfo.curIndex = pRuntimeEnv->windowResInfo.size - 1; // point to the last time window
} else { } else {
assert(Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL)); assert(Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL));
} }
...@@ -2540,8 +2485,6 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -2540,8 +2485,6 @@ static int64_t doScanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
return 0; return 0;
} }
static void updatelastkey(SQuery *pQuery, STableQueryInfo *pTableQInfo) { pTableQInfo->lastKey = pQuery->lastKey; }
/* /*
* set tag value in SQLFunctionCtx * set tag value in SQLFunctionCtx
* e.g.,tag information into input buffer * e.g.,tag information into input buffer
...@@ -2554,17 +2497,17 @@ static void doSetTagValueInParam(void *tsdb, STableId* pTableId, int32_t tagColI ...@@ -2554,17 +2497,17 @@ static void doSetTagValueInParam(void *tsdb, STableId* pTableId, int32_t tagColI
int16_t type = 0; int16_t type = 0;
if (tagColId == TSDB_TBNAME_COLUMN_INDEX) { if (tagColId == TSDB_TBNAME_COLUMN_INDEX) {
tsdbGetTableName(tsdb, pTableId, &val); val = tsdbGetTableName(tsdb, pTableId, &bytes);
bytes = strnlen(val, TSDB_TABLE_NAME_LEN);
type = TSDB_DATA_TYPE_BINARY; type = TSDB_DATA_TYPE_BINARY;
tVariantCreateFromBinary(param, varDataVal(val), varDataLen(val), type);
} else { } else {
tsdbGetTableTagVal(tsdb, pTableId, tagColId, &type, &bytes, &val); tsdbGetTableTagVal(tsdb, pTableId, tagColId, &type, &bytes, &val);
}
if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
tVariantCreateFromBinary(param, varDataVal(val), varDataLen(val), type);
} else {
tVariantCreateFromBinary(param, val, bytes, type); tVariantCreateFromBinary(param, val, bytes, type);
}
if (tagColId == TSDB_TBNAME_COLUMN_INDEX) {
tfree(val);
} }
} }
...@@ -2706,26 +2649,21 @@ static UNUSED_FUNC void printBinaryData(int32_t functionId, char *data, int32_t ...@@ -2706,26 +2649,21 @@ static UNUSED_FUNC void printBinaryData(int32_t functionId, char *data, int32_t
} }
} }
void UNUSED_FUNC displayInterResult(SData **pdata, SQuery *pQuery, int32_t numOfRows) { void UNUSED_FUNC displayInterResult(SData **pdata, SQueryRuntimeEnv* pRuntimeEnv, int32_t numOfRows) {
#if 0 SQuery* pQuery = pRuntimeEnv->pQuery;
int32_t numOfCols = pQuery->numOfOutput; int32_t numOfCols = pQuery->numOfOutput;
printf("super table query intermediate result, total:%d\n", numOfRows); printf("super table query intermediate result, total:%d\n", numOfRows);
SQInfo * pQInfo = (SQInfo *)(GET_QINFO_ADDR(pQuery));
SMeterObj *pMeterObj = pQInfo->pObj;
for (int32_t j = 0; j < numOfRows; ++j) { for (int32_t j = 0; j < numOfRows; ++j) {
for (int32_t i = 0; i < numOfCols; ++i) { for (int32_t i = 0; i < numOfCols; ++i) {
switch (pQuery->pSelectExpr[i].type) { switch (pQuery->pSelectExpr[i].type) {
case TSDB_DATA_TYPE_BINARY: { case TSDB_DATA_TYPE_BINARY: {
int32_t colIndex = pQuery->pSelectExpr[i].base.colInfo.colIndex; // int32_t colIndex = pQuery->pSelectExpr[i].base.colInfo.colIndex;
int32_t type = 0; int32_t type = pQuery->pSelectExpr[i].type;
// } else {
if (TSDB_COL_IS_TAG(pQuery->pSelectExpr[i].base.colInfo.flag)) { // type = pMeterObj->schema[colIndex].type;
type = pQuery->pSelectExpr[i].type; // }
} else {
type = pMeterObj->schema[colIndex].type;
}
printBinaryData(pQuery->pSelectExpr[i].base.functionId, pdata[i]->data + pQuery->pSelectExpr[i].bytes * j, printBinaryData(pQuery->pSelectExpr[i].base.functionId, pdata[i]->data + pQuery->pSelectExpr[i].bytes * j,
type); type);
break; break;
...@@ -2747,7 +2685,6 @@ void UNUSED_FUNC displayInterResult(SData **pdata, SQuery *pQuery, int32_t numOf ...@@ -2747,7 +2685,6 @@ void UNUSED_FUNC displayInterResult(SData **pdata, SQuery *pQuery, int32_t numOf
} }
printf("\n"); printf("\n");
} }
#endif
} }
typedef struct SCompSupporter { typedef struct SCompSupporter {
...@@ -3015,7 +2952,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) { ...@@ -3015,7 +2952,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
int64_t endt = taosGetTimestampMs(); int64_t endt = taosGetTimestampMs();
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->num); displayInterResult(pQuery->sdata, pRuntimeEnv, pQuery->sdata[0]->num);
#endif #endif
qTrace("QInfo:%p result merge completed, elapsed time:%" PRId64 " ms", GET_QINFO_ADDR(pQuery), endt - startt); qTrace("QInfo:%p result merge completed, elapsed time:%" PRId64 " ms", GET_QINFO_ADDR(pQuery), endt - startt);
...@@ -3082,11 +3019,6 @@ void resetMergeResultBuf(SQuery *pQuery, SQLFunctionCtx *pCtx, SResultInfo *pRes ...@@ -3082,11 +3019,6 @@ void resetMergeResultBuf(SQuery *pQuery, SQLFunctionCtx *pCtx, SResultInfo *pRes
} }
} }
void setTableDataInfo(STableQueryInfo *pTableQueryInfo, int32_t tableIndex, int32_t groupId) {
pTableQueryInfo->groupIdx = groupId;
pTableQueryInfo->tableIndex = tableIndex;
}
static void updateTableQueryInfoForReverseScan(SQuery *pQuery, STableQueryInfo *pTableQueryInfo) { static void updateTableQueryInfoForReverseScan(SQuery *pQuery, STableQueryInfo *pTableQueryInfo) {
if (pTableQueryInfo == NULL) { if (pTableQueryInfo == NULL) {
return; return;
...@@ -3132,19 +3064,6 @@ static void disableFuncInReverseScanImpl(SQInfo* pQInfo, SWindowResInfo *pWindow ...@@ -3132,19 +3064,6 @@ static void disableFuncInReverseScanImpl(SQInfo* pQInfo, SWindowResInfo *pWindow
} }
} }
} }
int32_t numOfGroups = taosArrayGetSize(pQInfo->groupInfo.pGroupList);
for(int32_t i = 0; i < numOfGroups; ++i) {
SArray *group = taosArrayGetP(pQInfo->groupInfo.pGroupList, i);
qTrace("QInfo:%p no result in group %d, continue", pQInfo, pQInfo->groupIndex - 1);
size_t t = taosArrayGetSize(group);
for (int32_t j = 0; j < t; ++j) {
SGroupItem *item = taosArrayGet(group, j);
updateTableQueryInfoForReverseScan(pQuery, item->info);
}
}
} }
void disableFuncInReverseScan(SQInfo *pQInfo) { void disableFuncInReverseScan(SQInfo *pQInfo) {
...@@ -3170,6 +3089,18 @@ void disableFuncInReverseScan(SQInfo *pQInfo) { ...@@ -3170,6 +3089,18 @@ void disableFuncInReverseScan(SQInfo *pQInfo) {
} }
} }
} }
int32_t numOfGroups = taosArrayGetSize(pQInfo->groupInfo.pGroupList);
for(int32_t i = 0; i < numOfGroups; ++i) {
SArray *group = taosArrayGetP(pQInfo->groupInfo.pGroupList, i);
size_t t = taosArrayGetSize(group);
for (int32_t j = 0; j < t; ++j) {
SGroupItem *item = taosArrayGet(group, j);
updateTableQueryInfoForReverseScan(pQuery, item->info);
}
}
} }
void switchCtxOrder(SQueryRuntimeEnv *pRuntimeEnv) { void switchCtxOrder(SQueryRuntimeEnv *pRuntimeEnv) {
...@@ -3345,13 +3276,14 @@ bool needScanDataBlocksAgain(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -3345,13 +3276,14 @@ bool needScanDataBlocksAgain(SQueryRuntimeEnv *pRuntimeEnv) {
static SQueryStatusInfo getQueryStatusInfo(SQueryRuntimeEnv *pRuntimeEnv) { static SQueryStatusInfo getQueryStatusInfo(SQueryRuntimeEnv *pRuntimeEnv) {
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
STableQueryInfo* pTableQueryInfo = pQuery->current;
SQueryStatusInfo info = { SQueryStatusInfo info = {
.status = pQuery->status, .status = pQuery->status,
.windowIndex = pRuntimeEnv->windowResInfo.curIndex, .windowIndex = pRuntimeEnv->windowResInfo.curIndex,
.lastKey = pQuery->lastKey, .lastKey = pTableQueryInfo->lastKey,
.w = pQuery->window, .w = pQuery->window,
.curWindow = {.skey = pQuery->lastKey, .ekey = pQuery->window.ekey}, .curWindow = {.skey = pTableQueryInfo->lastKey, .ekey = pTableQueryInfo->win.ekey},
}; };
return info; return info;
...@@ -3395,6 +3327,7 @@ static void setEnvBeforeReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusI ...@@ -3395,6 +3327,7 @@ static void setEnvBeforeReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusI
static void clearEnvAfterReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusInfo *pStatus) { static void clearEnvAfterReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatusInfo *pStatus) {
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
STableQueryInfo* pTableQueryInfo = pQuery->current;
SWITCH_ORDER(pQuery->order.order); SWITCH_ORDER(pQuery->order.order);
switchCtxOrder(pRuntimeEnv); switchCtxOrder(pRuntimeEnv);
...@@ -3408,17 +3341,19 @@ static void clearEnvAfterReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatus ...@@ -3408,17 +3341,19 @@ static void clearEnvAfterReverseScan(SQueryRuntimeEnv *pRuntimeEnv, SQueryStatus
// update the pQuery->window.skey and pQuery->window.ekey to limit the scan scope of sliding query // update the pQuery->window.skey and pQuery->window.ekey to limit the scan scope of sliding query
// during reverse scan // during reverse scan
pQuery->lastKey = pStatus->lastKey; pTableQueryInfo->lastKey = pStatus->lastKey;
pQuery->status = pStatus->status; pQuery->status = pStatus->status;
pQuery->window = pStatus->w; pTableQueryInfo->win = pStatus->w;
} }
void scanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { void scanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
SQInfo *pQInfo = (SQInfo *) GET_QINFO_ADDR(pRuntimeEnv);
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
STableQueryInfo *pTableQueryInfo = pQuery->current;
setQueryStatus(pQuery, QUERY_NOT_COMPLETED); setQueryStatus(pQuery, QUERY_NOT_COMPLETED);
// store the start query position // store the start query position
SQInfo * pQInfo = (SQInfo *)GET_QINFO_ADDR(pRuntimeEnv);
SQueryStatusInfo qstatus = getQueryStatusInfo(pRuntimeEnv); SQueryStatusInfo qstatus = getQueryStatusInfo(pRuntimeEnv);
SET_MASTER_SCAN_FLAG(pRuntimeEnv); SET_MASTER_SCAN_FLAG(pRuntimeEnv);
...@@ -3429,7 +3364,7 @@ void scanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -3429,7 +3364,7 @@ void scanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
if (pRuntimeEnv->scanFlag == MASTER_SCAN) { if (pRuntimeEnv->scanFlag == MASTER_SCAN) {
qstatus.status = pQuery->status; qstatus.status = pQuery->status;
qstatus.curWindow.ekey = pQuery->lastKey - step; qstatus.curWindow.ekey = pTableQueryInfo->lastKey - step;
} }
if (!needScanDataBlocksAgain(pRuntimeEnv)) { if (!needScanDataBlocksAgain(pRuntimeEnv)) {
...@@ -3549,12 +3484,10 @@ void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo, int32_t numOfCols) ...@@ -3549,12 +3484,10 @@ void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo, int32_t numOfCols)
void restoreIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo *pTableQueryInfo) { void restoreIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo *pTableQueryInfo) {
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
pQuery->current = pTableQueryInfo;
pQuery->window = pTableQueryInfo->win; assert(((pTableQueryInfo->lastKey >= pTableQueryInfo->win.skey) && QUERY_IS_ASC_QUERY(pQuery)) ||
pQuery->lastKey = pTableQueryInfo->lastKey; ((pTableQueryInfo->lastKey <= pTableQueryInfo->win.skey) && !QUERY_IS_ASC_QUERY(pQuery)));
assert(((pQuery->lastKey >= pQuery->window.skey) && QUERY_IS_ASC_QUERY(pQuery)) ||
((pQuery->lastKey <= pQuery->window.skey) && !QUERY_IS_ASC_QUERY(pQuery)));
} }
/** /**
...@@ -3562,8 +3495,10 @@ void restoreIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo *p ...@@ -3562,8 +3495,10 @@ void restoreIntervalQueryRange(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo *p
* @param pRuntimeEnv * @param pRuntimeEnv
* @param pDataBlockInfo * @param pDataBlockInfo
*/ */
void setExecutionContext(SQInfo *pQInfo, STableQueryInfo *pTableQueryInfo, STableId* pTableId, int32_t groupIdx, TSKEY nextKey) { void setExecutionContext(SQInfo *pQInfo, STableId* pTableId, int32_t groupIdx, TSKEY nextKey) {
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
STableQueryInfo *pTableQueryInfo = pRuntimeEnv->pQuery->current;
SWindowResInfo * pWindowResInfo = &pRuntimeEnv->windowResInfo; SWindowResInfo * pWindowResInfo = &pRuntimeEnv->windowResInfo;
int32_t GROUPRESULTID = 1; int32_t GROUPRESULTID = 1;
...@@ -3647,15 +3582,16 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, STableId* pTableId, STableQueryInfo *p ...@@ -3647,15 +3582,16 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, STableId* pTableId, STableQueryInfo *p
* merged during merge stage. In this case, we need the pTableQueryInfo->lastResRows to decide if there * merged during merge stage. In this case, we need the pTableQueryInfo->lastResRows to decide if there
* is a previous result generated or not. * is a previous result generated or not.
*/ */
void setIntervalQueryRange(STableQueryInfo *pTableQueryInfo, SQInfo *pQInfo, TSKEY key) { void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
SQuery * pQuery = pRuntimeEnv->pQuery; SQuery * pQuery = pRuntimeEnv->pQuery;
STableQueryInfo *pTableQueryInfo = pQuery->current;
if (pTableQueryInfo->queryRangeSet) { if (pTableQueryInfo->queryRangeSet) {
pQuery->lastKey = key;
pTableQueryInfo->lastKey = key; pTableQueryInfo->lastKey = key;
} else { } else {
pQuery->window.skey = key; // pQuery->window.skey = key;
pTableQueryInfo->win.skey = key;
STimeWindow win = {.skey = key, .ekey = pQuery->window.ekey}; STimeWindow win = {.skey = key, .ekey = pQuery->window.ekey};
// for too small query range, no data in this interval. // for too small query range, no data in this interval.
...@@ -3675,7 +3611,7 @@ void setIntervalQueryRange(STableQueryInfo *pTableQueryInfo, SQInfo *pQInfo, TSK ...@@ -3675,7 +3611,7 @@ void setIntervalQueryRange(STableQueryInfo *pTableQueryInfo, SQInfo *pQInfo, TSK
SWindowResInfo *pWindowResInfo = &pTableQueryInfo->windowResInfo; SWindowResInfo *pWindowResInfo = &pTableQueryInfo->windowResInfo;
getAlignQueryTimeWindow(pQuery, win.skey, win.skey, win.ekey, &skey1, &ekey1, &w); getAlignQueryTimeWindow(pQuery, win.skey, win.skey, win.ekey, &skey1, &ekey1, &w);
pWindowResInfo->startTime = pQuery->window.skey; // windowSKey may be 0 in case of 1970 timestamp pWindowResInfo->startTime = pTableQueryInfo->win.skey; // windowSKey may be 0 in case of 1970 timestamp
if (pWindowResInfo->prevSKey == 0) { if (pWindowResInfo->prevSKey == 0) {
if (QUERY_IS_ASC_QUERY(pQuery)) { if (QUERY_IS_ASC_QUERY(pQuery)) {
...@@ -3687,10 +3623,8 @@ void setIntervalQueryRange(STableQueryInfo *pTableQueryInfo, SQInfo *pQInfo, TSK ...@@ -3687,10 +3623,8 @@ void setIntervalQueryRange(STableQueryInfo *pTableQueryInfo, SQInfo *pQInfo, TSK
} }
pTableQueryInfo->queryRangeSet = 1; pTableQueryInfo->queryRangeSet = 1;
pTableQueryInfo->lastKey = pQuery->window.skey; pTableQueryInfo->lastKey = pTableQueryInfo->win.skey;
pTableQueryInfo->win.skey = pQuery->window.skey; pTableQueryInfo->win.skey = pTableQueryInfo->win.skey;
pQuery->lastKey = pQuery->window.skey;
} }
} }
...@@ -3710,7 +3644,9 @@ bool needPrimaryTimestampCol(SQuery *pQuery, SDataBlockInfo *pDataBlockInfo) { ...@@ -3710,7 +3644,9 @@ bool needPrimaryTimestampCol(SQuery *pQuery, SDataBlockInfo *pDataBlockInfo) {
* 2. if there are top/bottom, first_dst/last_dst functions, we need to load timestamp column in any cases; * 2. if there are top/bottom, first_dst/last_dst functions, we need to load timestamp column in any cases;
*/ */
STimeWindow *w = &pDataBlockInfo->window; STimeWindow *w = &pDataBlockInfo->window;
bool loadPrimaryTS = (pQuery->lastKey >= w->skey && pQuery->lastKey <= w->ekey) || STableQueryInfo* pTableQueryInfo = pQuery->current;
bool loadPrimaryTS = (pTableQueryInfo->lastKey >= w->skey && pTableQueryInfo->lastKey <= w->ekey) ||
(pQuery->window.ekey >= w->skey && pQuery->window.ekey <= w->ekey) || requireTimestamp(pQuery); (pQuery->window.ekey >= w->skey && pQuery->window.ekey <= w->ekey) || requireTimestamp(pQuery);
return loadPrimaryTS; return loadPrimaryTS;
...@@ -3793,7 +3729,7 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde ...@@ -3793,7 +3729,7 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde
qTrace("QInfo:%p copy data to query buf completed", pQInfo); qTrace("QInfo:%p copy data to query buf completed", pQInfo);
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
displayInterResult(pQuery->sdata, pQuery, numOfResult); displayInterResult(pQuery->sdata, pRuntimeEnv, numOfResult);
#endif #endif
return numOfResult; return numOfResult;
} }
...@@ -3847,7 +3783,6 @@ void stableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo ...@@ -3847,7 +3783,6 @@ void stableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo
} }
updateWindowResNumOfRes(pRuntimeEnv, pTableQueryInfo); updateWindowResNumOfRes(pRuntimeEnv, pTableQueryInfo);
updatelastkey(pQuery, pTableQueryInfo);
} }
bool vnodeHasRemainResults(void *handle) { bool vnodeHasRemainResults(void *handle) {
...@@ -4041,10 +3976,12 @@ void vnodePrintQueryStatistics(SQInfo *pQInfo) { ...@@ -4041,10 +3976,12 @@ void vnodePrintQueryStatistics(SQInfo *pQInfo) {
static void updateOffsetVal(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBlockInfo) { static void updateOffsetVal(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBlockInfo) {
SQuery *pQuery = pRuntimeEnv->pQuery; SQuery *pQuery = pRuntimeEnv->pQuery;
STableQueryInfo* pTableQueryInfo = pQuery->current;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
if (pQuery->limit.offset == pBlockInfo->rows) { // current block will ignore completed if (pQuery->limit.offset == pBlockInfo->rows) { // current block will ignore completed
pQuery->lastKey = QUERY_IS_ASC_QUERY(pQuery) ? pBlockInfo->window.ekey + step : pBlockInfo->window.skey + step; pTableQueryInfo->lastKey = QUERY_IS_ASC_QUERY(pQuery) ? pBlockInfo->window.ekey + step : pBlockInfo->window.skey + step;
pQuery->limit.offset = 0; pQuery->limit.offset = 0;
return; return;
} }
...@@ -4064,11 +4001,10 @@ static void updateOffsetVal(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBloc ...@@ -4064,11 +4001,10 @@ static void updateOffsetVal(SQueryRuntimeEnv *pRuntimeEnv, SDataBlockInfo *pBloc
TSKEY *keys = (TSKEY *)pColInfoData->pData; TSKEY *keys = (TSKEY *)pColInfoData->pData;
// update the offset value // update the offset value
pQuery->lastKey = keys[pQuery->pos]; pTableQueryInfo->lastKey = keys[pQuery->pos];
pQuery->limit.offset = 0; pQuery->limit.offset = 0;
int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, pDataBlock);
&pRuntimeEnv->windowResInfo, pDataBlock);
qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, res:%d", GET_QINFO_ADDR(pRuntimeEnv), qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, res:%d", GET_QINFO_ADDR(pRuntimeEnv),
pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes); pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes);
...@@ -4084,6 +4020,7 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -4084,6 +4020,7 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
pQuery->pos = 0; pQuery->pos = 0;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order); int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQuery->order.order);
STableQueryInfo* pTableQueryInfo = pQuery->current;
TsdbQueryHandleT pQueryHandle = pRuntimeEnv->pQueryHandle; TsdbQueryHandleT pQueryHandle = pRuntimeEnv->pQueryHandle;
while (tsdbNextDataBlock(pQueryHandle)) { while (tsdbNextDataBlock(pQueryHandle)) {
...@@ -4095,8 +4032,8 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -4095,8 +4032,8 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
if (pQuery->limit.offset > blockInfo.rows) { if (pQuery->limit.offset > blockInfo.rows) {
pQuery->limit.offset -= blockInfo.rows; pQuery->limit.offset -= blockInfo.rows;
pQuery->lastKey = (QUERY_IS_ASC_QUERY(pQuery)) ? blockInfo.window.ekey : blockInfo.window.skey; pTableQueryInfo->lastKey = (QUERY_IS_ASC_QUERY(pQuery)) ? blockInfo.window.ekey : blockInfo.window.skey;
pQuery->lastKey += step; pTableQueryInfo->lastKey += step;
qTrace("QInfo:%p skip rows:%d, offset:%" PRId64 "", GET_QINFO_ADDR(pRuntimeEnv), blockInfo.rows, qTrace("QInfo:%p skip rows:%d, offset:%" PRId64 "", GET_QINFO_ADDR(pRuntimeEnv), blockInfo.rows,
pQuery->limit.offset); pQuery->limit.offset);
...@@ -4125,6 +4062,7 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -4125,6 +4062,7 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) {
TSKEY skey1, ekey1; TSKEY skey1, ekey1;
STimeWindow w = {0}; STimeWindow w = {0};
SWindowResInfo *pWindowResInfo = &pRuntimeEnv->windowResInfo; SWindowResInfo *pWindowResInfo = &pRuntimeEnv->windowResInfo;
STableQueryInfo *pTableQueryInfo = pQuery->current;
while (tsdbNextDataBlock(pRuntimeEnv->pQueryHandle)) { while (tsdbNextDataBlock(pRuntimeEnv->pQueryHandle)) {
SDataBlockInfo blockInfo = tsdbRetrieveDataBlockInfo(pRuntimeEnv->pQueryHandle); SDataBlockInfo blockInfo = tsdbRetrieveDataBlockInfo(pRuntimeEnv->pQueryHandle);
...@@ -4170,11 +4108,10 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -4170,11 +4108,10 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) {
// set the abort info // set the abort info
pQuery->pos = startPos; pQuery->pos = startPos;
pQuery->lastKey = ((TSKEY *)pColInfoData->pData)[startPos]; pTableQueryInfo->lastKey = ((TSKEY *)pColInfoData->pData)[startPos];
pWindowResInfo->prevSKey = tw.skey; pWindowResInfo->prevSKey = tw.skey;
int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, NULL, binarySearchForKey, int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, &blockInfo, NULL, binarySearchForKey, pDataBlock);
&pRuntimeEnv->windowResInfo, pDataBlock);
qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, res:%d", qTrace("QInfo:%p check data block, brange:%" PRId64 "-%" PRId64 ", rows:%d, res:%d",
GET_QINFO_ADDR(pRuntimeEnv), blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, numOfRes); GET_QINFO_ADDR(pRuntimeEnv), blockInfo.window.skey, blockInfo.window.ekey, blockInfo.rows, numOfRes);
...@@ -4199,7 +4136,7 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -4199,7 +4136,7 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv) {
// set the abort info // set the abort info
pQuery->pos = startPos; pQuery->pos = startPos;
pQuery->lastKey = ((TSKEY *)pColInfoData->pData)[startPos]; pTableQueryInfo->lastKey = ((TSKEY *)pColInfoData->pData)[startPos];
pWindowResInfo->prevSKey = tw.skey; pWindowResInfo->prevSKey = tw.skey;
win = tw; win = tw;
} else { } else {
...@@ -4220,9 +4157,6 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool ...@@ -4220,9 +4157,6 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool
setScanLimitationByResultBuffer(pQuery); setScanLimitationByResultBuffer(pQuery);
changeExecuteScanOrder(pQuery, false); changeExecuteScanOrder(pQuery, false);
// dataInCache requires lastKey value
pQuery->lastKey = pQuery->window.skey;
STsdbQueryCond cond = { STsdbQueryCond cond = {
.twindow = pQuery->window, .twindow = pQuery->window,
.order = pQuery->order.order, .order = pQuery->order.order,
...@@ -4238,6 +4172,9 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool ...@@ -4238,6 +4172,9 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool
} else if (!isSTableQuery || isIntervalQuery(pQuery) || isFixedOutputQuery(pQuery)) { } else if (!isSTableQuery || isIntervalQuery(pQuery) || isFixedOutputQuery(pQuery)) {
pRuntimeEnv->pQueryHandle = tsdbQueryTables(tsdb, &cond, &pQInfo->tableIdGroupInfo); pRuntimeEnv->pQueryHandle = tsdbQueryTables(tsdb, &cond, &pQInfo->tableIdGroupInfo);
} }
// create the table query support structures
createTableQueryInfo(pQInfo);
} }
pQInfo->tsdb = tsdb; pQInfo->tsdb = tsdb;
...@@ -4331,7 +4268,6 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool ...@@ -4331,7 +4268,6 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool
// } // }
// the pQuery->window.skey is changed during normalizedFirstQueryRange, so set the newest lastkey value // the pQuery->window.skey is changed during normalizedFirstQueryRange, so set the newest lastkey value
pQuery->lastKey = pQuery->window.skey;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -4404,13 +4340,14 @@ static int64_t queryOnDataBlocks(SQInfo *pQInfo) { ...@@ -4404,13 +4340,14 @@ static int64_t queryOnDataBlocks(SQInfo *pQInfo) {
restoreIntervalQueryRange(pRuntimeEnv, pTableQueryInfo); restoreIntervalQueryRange(pRuntimeEnv, pTableQueryInfo);
SDataStatis *pStatis = NULL; SDataStatis *pStatis = NULL;
SArray * pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, &blockInfo, &pStatis);
SArray *pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis);
TSKEY nextKey = blockInfo.window.skey; TSKEY nextKey = blockInfo.window.skey;
if (!isIntervalQuery(pQuery)) { if (!isIntervalQuery(pQuery)) {
setExecutionContext(pQInfo, pTableQueryInfo, &pTableQueryInfo->id, pTableQueryInfo->groupIdx, nextKey); setExecutionContext(pQInfo, &pTableQueryInfo->id, pTableQueryInfo->groupIdx, nextKey);
} else { // interval query } else { // interval query
setIntervalQueryRange(pTableQueryInfo, pQInfo, nextKey); setIntervalQueryRange(pQInfo, nextKey);
int32_t ret = setAdditionalInfo(pQInfo, &pTableQueryInfo->id, pTableQueryInfo); int32_t ret = setAdditionalInfo(pQInfo, &pTableQueryInfo->id, pTableQueryInfo);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
...@@ -4446,6 +4383,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) { ...@@ -4446,6 +4383,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
.numOfCols = pQuery->numOfCols, .numOfCols = pQuery->numOfCols,
}; };
// todo refactor
SArray *g1 = taosArrayInit(1, POINTER_BYTES); SArray *g1 = taosArrayInit(1, POINTER_BYTES);
SArray *tx = taosArrayInit(1, sizeof(STableId)); SArray *tx = taosArrayInit(1, sizeof(STableId));
...@@ -4564,6 +4502,9 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -4564,6 +4502,9 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
initCtxOutputBuf(pRuntimeEnv); initCtxOutputBuf(pRuntimeEnv);
setTagVal(pRuntimeEnv, (STableId*) taosArrayGet(tx, 0), pQInfo->tsdb); setTagVal(pRuntimeEnv, (STableId*) taosArrayGet(tx, 0), pQInfo->tsdb);
// here we simply set the first table as current table
pRuntimeEnv->pQuery->current = ((SGroupItem*) taosArrayGet(group, 0))->info;
scanAllDataBlocks(pRuntimeEnv); scanAllDataBlocks(pRuntimeEnv);
int64_t numOfRes = getNumOfResult(pRuntimeEnv); int64_t numOfRes = getNumOfResult(pRuntimeEnv);
...@@ -4580,8 +4521,6 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -4580,8 +4521,6 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
} }
} }
} else { } else {
createTableQueryInfo(pQInfo);
/* /*
* 1. super table projection query, 2. group-by on normal columns query, 3. ts-comp query * 1. super table projection query, 2. group-by on normal columns query, 3. ts-comp query
* if the subgroup index is larger than 0, results generated by group by tbname,k is existed. * if the subgroup index is larger than 0, results generated by group by tbname,k is existed.
...@@ -4614,11 +4553,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -4614,11 +4553,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
} }
SGroupItem *item = taosArrayGet(group, pQInfo->tableIndex); SGroupItem *item = taosArrayGet(group, pQInfo->tableIndex);
pQuery->current = item->info;
STableQueryInfo *pInfo = item->info;
if (pInfo->lastKey > 0) {
pQuery->window.skey = pInfo->lastKey;
}
if (!multiTableMultioutputHelper(pQInfo, pQInfo->tableIndex)) { if (!multiTableMultioutputHelper(pQInfo, pQInfo->tableIndex)) {
pQInfo->tableIndex++; pQInfo->tableIndex++;
...@@ -4627,7 +4562,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -4627,7 +4562,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
// SPointInterpoSupporter pointInterpSupporter = {0}; // SPointInterpoSupporter pointInterpSupporter = {0};
// TODO handle the limit problem // TODO handle the limit offset problem
if (pQuery->numOfFilterCols == 0 && pQuery->limit.offset > 0) { if (pQuery->numOfFilterCols == 0 && pQuery->limit.offset > 0) {
// skipBlocks(pRuntimeEnv); // skipBlocks(pRuntimeEnv);
...@@ -4659,8 +4594,6 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -4659,8 +4594,6 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
* to ensure that, we can reset the query range once query on a meter is completed. * to ensure that, we can reset the query range once query on a meter is completed.
*/ */
pQInfo->tableIndex++; pQInfo->tableIndex++;
pInfo->lastKey = pQuery->lastKey;
// if the buffer is full or group by each table, we need to jump out of the loop // if the buffer is full or group by each table, we need to jump out of the loop
if (Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL) /*|| if (Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL) /*||
isGroupbyEachTable(pQuery->pGroupbyExpr, pSupporter->pSidSet)*/) { isGroupbyEachTable(pQuery->pGroupbyExpr, pSupporter->pSidSet)*/) {
...@@ -4668,7 +4601,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) { ...@@ -4668,7 +4601,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
} }
} else { // forward query range } else { // forward query range
pQuery->window.skey = pQuery->lastKey; pQuery->window.skey = pQuery->current->lastKey;
// all data in the result buffer are skipped due to the offset, continue to retrieve data from current meter // all data in the result buffer are skipped due to the offset, continue to retrieve data from current meter
if (pQuery->rec.rows == 0) { if (pQuery->rec.rows == 0) {
...@@ -4836,7 +4769,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { ...@@ -4836,7 +4769,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
copyResToQueryResultBuf(pQInfo, pQuery); copyResToQueryResultBuf(pQInfo, pQuery);
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->num); displayInterResult(pQuery->sdata, pRuntimeEnv, pQuery->sdata[0]->num);
#endif #endif
} else { } else {
copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult); copyFromWindowResToSData(pQInfo, pRuntimeEnv->windowResInfo.pResult);
...@@ -4853,12 +4786,9 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { ...@@ -4853,12 +4786,9 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
qTrace("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", order:%d, forward scan start", pQInfo, qTrace("QInfo:%p query start, qrange:%" PRId64 "-%" PRId64 ", order:%d, forward scan start", pQInfo,
pQuery->window.skey, pQuery->window.ekey, pQuery->order.order); pQuery->window.skey, pQuery->window.ekey, pQuery->order.order);
// create the query support structures
createTableQueryInfo(pQInfo);
// do check all qualified data blocks // do check all qualified data blocks
int64_t el = queryOnDataBlocks(pQInfo); int64_t el = queryOnDataBlocks(pQInfo);
qTrace("QInfo:%p forward scan completed, elapsed time: %lldms, reversed scan start", pQInfo, el); qTrace("QInfo:%p master scan completed, elapsed time: %lldms, reverse scan start", pQInfo, el);
// query error occurred or query is killed, abort current execution // query error occurred or query is killed, abort current execution
if (pQInfo->code != TSDB_CODE_SUCCESS || isQueryKilled(pQInfo)) { if (pQInfo->code != TSDB_CODE_SUCCESS || isQueryKilled(pQInfo)) {
...@@ -4892,7 +4822,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { ...@@ -4892,7 +4822,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
copyResToQueryResultBuf(pQInfo, pQuery); copyResToQueryResultBuf(pQInfo, pQuery);
#ifdef _DEBUG_VIEW #ifdef _DEBUG_VIEW
displayInterResult(pQuery->sdata, pQuery, pQuery->sdata[0]->num); displayInterResult(pQuery->sdata, pRuntimeEnv, pQuery->sdata[0]->num);
#endif #endif
} }
} else { // not a interval query } else { // not a interval query
...@@ -4909,9 +4839,11 @@ static void multiTableQueryProcess(SQInfo *pQInfo) { ...@@ -4909,9 +4839,11 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
* select count(*)/top(field,k)/avg(field name) from table_name [where ts>now-1a]; * select count(*)/top(field,k)/avg(field name) from table_name [where ts>now-1a];
* select count(*) from table_name group by status_column; * select count(*) from table_name group by status_column;
*/ */
static void tableFixedOutputProcess(SQInfo *pQInfo) { static void tableFixedOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) {
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
SQuery * pQuery = pRuntimeEnv->pQuery;
SQuery *pQuery = pRuntimeEnv->pQuery;
pQuery->current = pTableInfo; // set current query table info
scanAllDataBlocks(pRuntimeEnv); scanAllDataBlocks(pRuntimeEnv);
finalizeQueryResult(pRuntimeEnv); finalizeQueryResult(pRuntimeEnv);
...@@ -4932,9 +4864,11 @@ static void tableFixedOutputProcess(SQInfo *pQInfo) { ...@@ -4932,9 +4864,11 @@ static void tableFixedOutputProcess(SQInfo *pQInfo) {
limitResults(pQInfo); limitResults(pQInfo);
} }
static void tableMultiOutputProcess(SQInfo *pQInfo) { static void tableMultiOutputProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) {
SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv; SQueryRuntimeEnv *pRuntimeEnv = &pQInfo->runtimeEnv;
SQuery * pQuery = pRuntimeEnv->pQuery;
SQuery *pQuery = pRuntimeEnv->pQuery;
pQuery->current = pTableInfo;
// for ts_comp query, re-initialized is not allowed // for ts_comp query, re-initialized is not allowed
if (!isTSCompQuery(pQuery)) { if (!isTSCompQuery(pQuery)) {
...@@ -4970,15 +4904,15 @@ static void tableMultiOutputProcess(SQInfo *pQInfo) { ...@@ -4970,15 +4904,15 @@ static void tableMultiOutputProcess(SQInfo *pQInfo) {
} }
qTrace("QInfo:%p vid:%d sid:%d id:%s, skip current result, offset:%" PRId64 ", next qrange:%" PRId64 "-%" PRId64, qTrace("QInfo:%p vid:%d sid:%d id:%s, skip current result, offset:%" PRId64 ", next qrange:%" PRId64 "-%" PRId64,
pQInfo, pQuery->limit.offset, pQuery->lastKey); pQInfo, pQuery->limit.offset, pQuery->current->lastKey);
resetCtxOutputBuf(pRuntimeEnv); resetCtxOutputBuf(pRuntimeEnv);
} }
limitResults(pQInfo); limitResults(pQInfo);
if (Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL)) { if (Q_STATUS_EQUAL(pQuery->status, QUERY_RESBUF_FULL)) {
qTrace("QInfo:%p query paused due to output limitation, next qrange:%" PRId64 "-%" PRId64, pQInfo, pQuery->lastKey, qTrace("QInfo:%p query paused due to output limitation, next qrange:%" PRId64 "-%" PRId64, pQInfo,
pQuery->window.ekey); pQuery->current->lastKey, pQuery->window.ekey);
} }
if (!isTSCompQuery(pQuery)) { if (!isTSCompQuery(pQuery)) {
...@@ -5018,11 +4952,12 @@ static void tableIntervalProcessImpl(SQueryRuntimeEnv *pRuntimeEnv) { ...@@ -5018,11 +4952,12 @@ static void tableIntervalProcessImpl(SQueryRuntimeEnv *pRuntimeEnv) {
} }
// handle time interval query on table // handle time interval query on table
static void tableIntervalProcess(SQInfo *pQInfo) { static void tableIntervalProcess(SQInfo *pQInfo, STableQueryInfo* pTableInfo) {
SQueryRuntimeEnv *pRuntimeEnv = &(pQInfo->runtimeEnv); SQueryRuntimeEnv *pRuntimeEnv = &(pQInfo->runtimeEnv);
SQuery * pQuery = pRuntimeEnv->pQuery;
int32_t numOfInterpo = 0; int32_t numOfInterpo = 0;
SQuery *pQuery = pRuntimeEnv->pQuery;
pQuery->current = pTableInfo;
// skip blocks without load the actual data block from file if no filter condition present // skip blocks without load the actual data block from file if no filter condition present
skipTimeInterval(pRuntimeEnv); skipTimeInterval(pRuntimeEnv);
...@@ -5132,14 +5067,18 @@ static void tableQueryImpl(SQInfo *pQInfo) { ...@@ -5132,14 +5067,18 @@ static void tableQueryImpl(SQInfo *pQInfo) {
pQuery->rec.rows = 0; pQuery->rec.rows = 0;
int64_t st = taosGetTimestampUs(); int64_t st = taosGetTimestampUs();
assert(pQInfo->groupInfo.numOfTables == 1);
SArray* g = taosArrayGetP(pQInfo->groupInfo.pGroupList, 0);
SGroupItem* item = taosArrayGet(g, 0);
// group by normal column, sliding window query, interval query are handled by interval query processor // group by normal column, sliding window query, interval query are handled by interval query processor
if (isIntervalQuery(pQuery) || isGroupbyNormalCol(pQuery->pGroupbyExpr)) { // interval (down sampling operation) if (isIntervalQuery(pQuery) || isGroupbyNormalCol(pQuery->pGroupbyExpr)) { // interval (down sampling operation)
tableIntervalProcess(pQInfo); tableIntervalProcess(pQInfo, item->info);
} else if (isFixedOutputQuery(pQuery)) { } else if (isFixedOutputQuery(pQuery)) {
tableFixedOutputProcess(pQInfo); tableFixedOutputProcess(pQInfo, item->info);
} else { // diff/add/multiply/subtract/division } else { // diff/add/multiply/subtract/division
assert(pQuery->checkBuffer == 1); assert(pQuery->checkBuffer == 1);
tableMultiOutputProcess(pQInfo); tableMultiOutputProcess(pQInfo, item->info);
} }
// record the total elapsed time // record the total elapsed time
...@@ -5340,26 +5279,26 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, ...@@ -5340,26 +5279,26 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
} }
for (int32_t f = 0; f < numOfFilters; ++f) { for (int32_t f = 0; f < numOfFilters; ++f) {
SColumnFilterInfo *pFilterInfo = (SColumnFilterInfo *)pMsg; SColumnFilterInfo *pFilterMsg = (SColumnFilterInfo *)pMsg;
SColumnFilterInfo *pDestFilterInfo = &pColInfo->filters[f];
pDestFilterInfo->filterstr = htons(pFilterInfo->filterstr); SColumnFilterInfo *pColFilter = &pColInfo->filters[f];
pColFilter->filterstr = htons(pFilterMsg->filterstr);
pMsg += sizeof(SColumnFilterInfo); pMsg += sizeof(SColumnFilterInfo);
if (pDestFilterInfo->filterstr) { if (pColFilter->filterstr) {
pDestFilterInfo->len = htobe64(pFilterInfo->len); pColFilter->len = htobe64(pFilterMsg->len);
pDestFilterInfo->pz = (int64_t) calloc(1, pDestFilterInfo->len); pColFilter->pz = (int64_t) calloc(1, pColFilter->len);
memcpy((void *)pDestFilterInfo->pz, pMsg, pDestFilterInfo->len); memcpy((void *)pColFilter->pz, pMsg, pColFilter->len);
pMsg += (pDestFilterInfo->len); pMsg += (pColFilter->len + 1);
} else { } else {
pDestFilterInfo->lowerBndi = htobe64(pFilterInfo->lowerBndi); pColFilter->lowerBndi = htobe64(pFilterMsg->lowerBndi);
pDestFilterInfo->upperBndi = htobe64(pFilterInfo->upperBndi); pColFilter->upperBndi = htobe64(pFilterMsg->upperBndi);
} }
pDestFilterInfo->lowerRelOptr = htons(pFilterInfo->lowerRelOptr); pColFilter->lowerRelOptr = htons(pFilterMsg->lowerRelOptr);
pDestFilterInfo->upperRelOptr = htons(pFilterInfo->upperRelOptr); pColFilter->upperRelOptr = htons(pFilterMsg->upperRelOptr);
} }
} }
...@@ -5756,9 +5695,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou ...@@ -5756,9 +5695,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
for (int16_t i = 0; i < numOfCols; ++i) { for (int16_t i = 0; i < numOfCols; ++i) {
pQuery->colList[i] = pQueryMsg->colList[i]; pQuery->colList[i] = pQueryMsg->colList[i];
pQuery->colList[i].filters = tscFilterInfoClone(pQueryMsg->colList[i].filters, pQuery->colList[i].numOfFilters);
SColumnInfo *pColInfo = &pQuery->colList[i];
pColInfo->filters = tscFilterInfoClone(pQueryMsg->colList[i].filters, pColInfo->numOfFilters);
} }
pQuery->tagColList = pTagCols; pQuery->tagColList = pTagCols;
...@@ -5833,7 +5770,6 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou ...@@ -5833,7 +5770,6 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
pQuery->pos = -1; pQuery->pos = -1;
pQuery->window = pQueryMsg->window; pQuery->window = pQueryMsg->window;
pQuery->lastKey = pQuery->window.skey;
if (sem_init(&pQInfo->dataReady, 0, 0) != 0) { if (sem_init(&pQInfo->dataReady, 0, 0) != 0) {
qError("QInfo:%p init dataReady sem failed, reason:%s", pQInfo, strerror(errno)); qError("QInfo:%p init dataReady sem failed, reason:%s", pQInfo, strerror(errno));
...@@ -5911,8 +5847,6 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ ...@@ -5911,8 +5847,6 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
goto _error; goto _error;
} }
// qTrace("QInfo:%p set query flag and prepare runtime environment completed, ref:%d, wait for schedule", pQInfo,
// pQInfo->refCount);
return code; return code;
_error: _error:
...@@ -6085,34 +6019,35 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi ...@@ -6085,34 +6019,35 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
if (pQueryMsg->numOfTables <= 0) { if (pQueryMsg->numOfTables <= 0) {
qError("Invalid number of tables to query, numOfTables:%d", pQueryMsg->numOfTables); qError("Invalid number of tables to query, numOfTables:%d", pQueryMsg->numOfTables);
code = TSDB_CODE_INVALID_QUERY_MSG; code = TSDB_CODE_INVALID_QUERY_MSG;
goto _query_over; goto _over;
} }
if (pTableIdList == NULL || taosArrayGetSize(pTableIdList) == 0) { if (pTableIdList == NULL || taosArrayGetSize(pTableIdList) == 0) {
qError("qmsg:%p, SQueryTableMsg wrong format", pQueryMsg); qError("qmsg:%p, SQueryTableMsg wrong format", pQueryMsg);
code = TSDB_CODE_INVALID_QUERY_MSG; code = TSDB_CODE_INVALID_QUERY_MSG;
goto _query_over; goto _over;
} }
SExprInfo *pExprs = NULL; SExprInfo *pExprs = NULL;
if ((code = createSqlFunctionExprFromMsg(pQueryMsg, &pExprs, pExprMsg, pTagColumnInfo)) != TSDB_CODE_SUCCESS) { if ((code = createSqlFunctionExprFromMsg(pQueryMsg, &pExprs, pExprMsg, pTagColumnInfo)) != TSDB_CODE_SUCCESS) {
goto _query_over; goto _over;
} }
SSqlGroupbyExpr *pGroupbyExpr = createGroupbyExprFromMsg(pQueryMsg, pGroupColIndex, &code); SSqlGroupbyExpr *pGroupbyExpr = createGroupbyExprFromMsg(pQueryMsg, pGroupColIndex, &code);
if ((pGroupbyExpr == NULL && pQueryMsg->numOfGroupCols != 0) || code != TSDB_CODE_SUCCESS) { if ((pGroupbyExpr == NULL && pQueryMsg->numOfGroupCols != 0) || code != TSDB_CODE_SUCCESS) {
goto _query_over; goto _over;
} }
bool isSTableQuery = false; bool isSTableQuery = false;
STableGroupInfo groupInfo = {0}; STableGroupInfo groupInfo = {0};
//todo multitable_query??
if (TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_MULTITABLE_QUERY|TSDB_QUERY_TYPE_TABLE_QUERY)) { if (TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_MULTITABLE_QUERY|TSDB_QUERY_TYPE_TABLE_QUERY)) {
isSTableQuery = TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_MULTITABLE_QUERY); isSTableQuery = TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_MULTITABLE_QUERY);
STableId *id = taosArrayGet(pTableIdList, 0); STableId *id = taosArrayGet(pTableIdList, 0);
if ((code = tsdbGetOneTableGroup(tsdb, id->uid, &groupInfo)) != TSDB_CODE_SUCCESS) { if ((code = tsdbGetOneTableGroup(tsdb, id->uid, &groupInfo)) != TSDB_CODE_SUCCESS) {
goto _query_over; goto _over;
} }
} else if (TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_STABLE_QUERY)) { } else if (TSDB_QUERY_HAS_TYPE(pQueryMsg->queryType, TSDB_QUERY_TYPE_STABLE_QUERY)) {
isSTableQuery = true; isSTableQuery = true;
...@@ -6129,7 +6064,7 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi ...@@ -6129,7 +6064,7 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
numOfGroupByCols); numOfGroupByCols);
if (groupInfo.numOfTables == 0) { // no qualified tables no need to do query if (groupInfo.numOfTables == 0) { // no qualified tables no need to do query
code = TSDB_CODE_SUCCESS; code = TSDB_CODE_SUCCESS;
goto _query_over; goto _over;
} }
} else { } else {
assert(0); assert(0);
...@@ -6138,11 +6073,12 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi ...@@ -6138,11 +6073,12 @@ int32_t qCreateQueryInfo(void *tsdb, int32_t vgId, SQueryTableMsg *pQueryMsg, qi
(*pQInfo) = createQInfoImpl(pQueryMsg, pGroupbyExpr, pExprs, &groupInfo, pTagColumnInfo); (*pQInfo) = createQInfoImpl(pQueryMsg, pGroupbyExpr, pExprs, &groupInfo, pTagColumnInfo);
if ((*pQInfo) == NULL) { if ((*pQInfo) == NULL) {
code = TSDB_CODE_SERV_OUT_OF_MEMORY; code = TSDB_CODE_SERV_OUT_OF_MEMORY;
goto _over;
} }
code = initQInfo(pQueryMsg, tsdb, vgId, *pQInfo, isSTableQuery); code = initQInfo(pQueryMsg, tsdb, vgId, *pQInfo, isSTableQuery);
_query_over: _over:
tfree(tagCond); tfree(tagCond);
tfree(tbnameCond); tfree(tbnameCond);
taosArrayDestroy(pTableIdList); taosArrayDestroy(pTableIdList);
...@@ -6318,12 +6254,10 @@ static void buildTagQueryResult(SQInfo* pQInfo) { ...@@ -6318,12 +6254,10 @@ static void buildTagQueryResult(SQInfo* pQInfo) {
for(int32_t j = 0; j < pQuery->numOfOutput; ++j) { for(int32_t j = 0; j < pQuery->numOfOutput; ++j) {
// todo check the return value, refactor codes // todo check the return value, refactor codes
if (pExprInfo[j].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) { if (pExprInfo[j].base.colInfo.colId == TSDB_TBNAME_COLUMN_INDEX) {
tsdbGetTableName(pQInfo->tsdb, &item->id, &data); data = tsdbGetTableName(pQInfo->tsdb, &item->id, &bytes);
char* dst = pQuery->sdata[j]->data + i * (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE); char* dst = pQuery->sdata[j]->data + i * (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE);
STR_WITH_MAXSIZE_TO_VARSTR(dst, data, TSDB_TABLE_NAME_LEN); memcpy(dst, data, varDataTLen(data));
tfree(data);
} else {// todo refactor, return the true length of binary|nchar data } else {// todo refactor, return the true length of binary|nchar data
tsdbGetTableTagVal(pQInfo->tsdb, &item->id, pExprInfo[j].base.colInfo.colId, &type, &bytes, &data); tsdbGetTableTagVal(pQInfo->tsdb, &item->id, pExprInfo[j].base.colInfo.colId, &type, &bytes, &data);
assert(bytes == pExprInfo[j].bytes && type == pExprInfo[j].type); assert(bytes == pExprInfo[j].bytes && type == pExprInfo[j].type);
......
...@@ -183,33 +183,33 @@ bool equal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) { ...@@ -183,33 +183,33 @@ bool equal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
bool equal_str(SColumnFilterElem *pFilter, char *minval, char *maxval) { bool equal_str(SColumnFilterElem *pFilter, char *minval, char *maxval) {
// query condition string is greater than the max length of string, not qualified data // query condition string is greater than the max length of string, not qualified data
if (pFilter->filterInfo.len > pFilter->bytes) { if (pFilter->filterInfo.len != varDataLen(minval)) {
return false; return false;
} }
return strncmp((char *)pFilter->filterInfo.pz, minval, pFilter->bytes) == 0; return strncmp((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)) == 0;
} }
bool equal_nchar(SColumnFilterElem *pFilter, char *minval, char *maxval) { bool equal_nchar(SColumnFilterElem *pFilter, char *minval, char *maxval) {
// query condition string is greater than the max length of string, not qualified data // query condition string is greater than the max length of string, not qualified data
if (pFilter->filterInfo.len > pFilter->bytes) { if (pFilter->filterInfo.len != varDataLen(minval)) {
return false; return false;
} }
return wcsncmp((wchar_t *)pFilter->filterInfo.pz, (wchar_t*) minval, pFilter->bytes/TSDB_NCHAR_SIZE) == 0; return wcsncmp((wchar_t *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE) == 0;
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
bool like_str(SColumnFilterElem *pFilter, char *minval, char *maxval) { bool like_str(SColumnFilterElem *pFilter, char *minval, char *maxval) {
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
return patternMatch((char *)pFilter->filterInfo.pz, minval, pFilter->bytes, &info) == TSDB_PATTERN_MATCH; return patternMatch((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval), &info) == TSDB_PATTERN_MATCH;
} }
bool like_nchar(SColumnFilterElem* pFilter, char* minval, char *maxval) { bool like_nchar(SColumnFilterElem* pFilter, char* minval, char *maxval) {
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
return WCSPatternMatch((wchar_t*) pFilter->filterInfo.pz, (wchar_t*) minval, pFilter->bytes/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH; return WCSPatternMatch((wchar_t*) pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE, &info) == TSDB_PATTERN_MATCH;
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
...@@ -270,11 +270,11 @@ bool nequal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) { ...@@ -270,11 +270,11 @@ bool nequal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
} }
bool nequal_str(SColumnFilterElem *pFilter, char *minval, char *maxval) { bool nequal_str(SColumnFilterElem *pFilter, char *minval, char *maxval) {
if (pFilter->filterInfo.len > pFilter->bytes) { if (pFilter->filterInfo.len != varDataLen(minval)) {
return true; return true;
} }
return strncmp((char *)pFilter->filterInfo.pz, minval, pFilter->bytes) != 0; return strncmp((char *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)) != 0;
} }
bool nequal_nchar(SColumnFilterElem *pFilter, char* minval, char *maxval) { bool nequal_nchar(SColumnFilterElem *pFilter, char* minval, char *maxval) {
...@@ -282,7 +282,7 @@ bool nequal_nchar(SColumnFilterElem *pFilter, char* minval, char *maxval) { ...@@ -282,7 +282,7 @@ bool nequal_nchar(SColumnFilterElem *pFilter, char* minval, char *maxval) {
return true; return true;
} }
return wcsncmp((wchar_t *)pFilter->filterInfo.pz, (wchar_t*)minval, pFilter->bytes/TSDB_NCHAR_SIZE) != 0; return wcsncmp((wchar_t *)pFilter->filterInfo.pz, varDataVal(minval), varDataLen(minval)/TSDB_NCHAR_SIZE) != 0;
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
......
...@@ -389,6 +389,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) { ...@@ -389,6 +389,7 @@ static int32_t toBinary(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
return 0; return 0;
} }
// todo handle the error
static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
char tmpBuf[40] = {0}; char tmpBuf[40] = {0};
...@@ -424,7 +425,12 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) { ...@@ -424,7 +425,12 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
pVariant->wpz = (wchar_t *)tmp; pVariant->wpz = (wchar_t *)tmp;
} else { } else {
taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE, NULL); size_t output = -1;
taosMbsToUcs4(pDst, nLen, *pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output);
if (pDestSize != NULL) {
*pDestSize = output;
}
} }
return 0; return 0;
...@@ -779,7 +785,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, char type) { ...@@ -779,7 +785,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, char type) {
} }
case TSDB_DATA_TYPE_NCHAR: { case TSDB_DATA_TYPE_NCHAR: {
if (pVariant->nType == TSDB_DATA_TYPE_NULL) { if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
*(uint32_t *)payload = TSDB_DATA_NCHAR_NULL; *(uint32_t *) payload = TSDB_DATA_NCHAR_NULL;
} else { } else {
if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) { if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) {
toNchar(pVariant, &payload, &pVariant->nLen); toNchar(pVariant, &payload, &pVariant->nLen);
......
...@@ -76,4 +76,8 @@ TEST(testCase, patternMatchTest) { ...@@ -76,4 +76,8 @@ TEST(testCase, patternMatchTest) {
str = "carzero"; str = "carzero";
ret = patternMatch("%o", str, strlen(str), &info); ret = patternMatch("%o", str, strlen(str), &info);
EXPECT_EQ(ret, TSDB_PATTERN_MATCH); EXPECT_EQ(ret, TSDB_PATTERN_MATCH);
str = "19";
ret = patternMatch("%9", str, 2, &info);
EXPECT_EQ(ret, TSDB_PATTERN_MATCH);
} }
...@@ -55,9 +55,8 @@ typedef struct { ...@@ -55,9 +55,8 @@ typedef struct {
char secret[TSDB_KEY_LEN]; // secret for the link char secret[TSDB_KEY_LEN]; // secret for the link
char ckey[TSDB_KEY_LEN]; // ciphering key char ckey[TSDB_KEY_LEN]; // ciphering key
void (*cfp)(SRpcMsg *); void (*cfp)(SRpcMsg *, SRpcIpSet *);
int (*afp)(char *user, char *spi, char *encrypt, char *secret, char *ckey); int (*afp)(char *user, char *spi, char *encrypt, char *secret, char *ckey);
void (*ufp)(void *ahandle, SRpcIpSet *pIpSet);
void *idPool; // handle to ID pool void *idPool; // handle to ID pool
void *tmrCtrl; // handle to timer void *tmrCtrl; // handle to timer
...@@ -222,7 +221,6 @@ void *rpcOpen(const SRpcInit *pInit) { ...@@ -222,7 +221,6 @@ void *rpcOpen(const SRpcInit *pInit) {
if (pInit->secret) strcpy(pRpc->secret, pInit->secret); if (pInit->secret) strcpy(pRpc->secret, pInit->secret);
if (pInit->ckey) strcpy(pRpc->ckey, pInit->ckey); if (pInit->ckey) strcpy(pRpc->ckey, pInit->ckey);
pRpc->spi = pInit->spi; pRpc->spi = pInit->spi;
pRpc->ufp = pInit->ufp;
pRpc->cfp = pInit->cfp; pRpc->cfp = pInit->cfp;
pRpc->afp = pInit->afp; pRpc->afp = pInit->afp;
...@@ -793,7 +791,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) { ...@@ -793,7 +791,7 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) {
pConn->chandle = pRecv->chandle; pConn->chandle = pRecv->chandle;
pConn->peerIp = pRecv->ip; pConn->peerIp = pRecv->ip;
if (pConn->peerPort == 0) pConn->peerPort = pRecv->port; pConn->peerPort = pRecv->port;
if (pHead->port) pConn->peerPort = htons(pHead->port); if (pHead->port) pConn->peerPort = htons(pHead->port);
terrno = rpcCheckAuthentication(pConn, (char *)pHead, pRecv->msgLen); terrno = rpcCheckAuthentication(pConn, (char *)pHead, pRecv->msgLen);
...@@ -900,10 +898,11 @@ static void rpcNotifyClient(SRpcReqContext *pContext, SRpcMsg *pMsg) { ...@@ -900,10 +898,11 @@ static void rpcNotifyClient(SRpcReqContext *pContext, SRpcMsg *pMsg) {
memcpy(pContext->pRsp, pMsg, sizeof(SRpcMsg)); memcpy(pContext->pRsp, pMsg, sizeof(SRpcMsg));
} else { } else {
// for asynchronous API // for asynchronous API
if (pRpc->ufp && (pContext->ipSet.inUse != pContext->oldInUse || pContext->redirect)) SRpcIpSet *pIpSet = NULL;
(*pRpc->ufp)(pContext->ahandle, &pContext->ipSet); // notify the update of ipSet if (pContext->ipSet.inUse != pContext->oldInUse || pContext->redirect)
pIpSet = &pContext->ipSet;
(*pRpc->cfp)(pMsg); (*pRpc->cfp)(pMsg, pIpSet);
} }
// free the request message // free the request message
...@@ -924,7 +923,7 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) { ...@@ -924,7 +923,7 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead) {
if ( rpcIsReq(pHead->msgType) ) { if ( rpcIsReq(pHead->msgType) ) {
rpcMsg.handle = pConn; rpcMsg.handle = pConn;
taosTmrReset(rpcProcessProgressTimer, tsRpcTimer/2, pConn, pRpc->tmrCtrl, &pConn->pTimer); taosTmrReset(rpcProcessProgressTimer, tsRpcTimer/2, pConn, pRpc->tmrCtrl, &pConn->pTimer);
(*(pRpc->cfp))(&rpcMsg); (*(pRpc->cfp))(&rpcMsg, NULL);
} else { } else {
// it's a response // it's a response
SRpcReqContext *pContext = pConn->pContext; SRpcReqContext *pContext = pConn->pContext;
...@@ -1094,8 +1093,8 @@ static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) { ...@@ -1094,8 +1093,8 @@ static void rpcSendMsgToPeer(SRpcConn *pConn, void *msg, int msgLen) {
} else { } else {
if (pHead->code == 0) pConn->secured = 1; // for success response, set link as secured if (pHead->code == 0) pConn->secured = 1; // for success response, set link as secured
if (pHead->msgType < TSDB_MSG_TYPE_CM_HEARTBEAT || (rpcDebugFlag & 16)) if (pHead->msgType < TSDB_MSG_TYPE_CM_HEARTBEAT || (rpcDebugFlag & 16))
tTrace( "%s %p, %s is sent to %s:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d", tTrace( "%s %p, %s is sent to 0x%x:%hu, code:0x%x len:%d sig:0x%08x:0x%08x:%d",
pRpc->label, pConn, taosMsg[pHead->msgType], pConn->peerFqdn, pConn->peerPort, pRpc->label, pConn, taosMsg[pHead->msgType], pConn->peerIp, pConn->peerPort,
htonl(pHead->code), msgLen, pHead->sourceId, pHead->destId, pHead->tranId); htonl(pHead->code), msgLen, pHead->sourceId, pHead->destId, pHead->tranId);
} }
......
...@@ -31,22 +31,16 @@ typedef struct { ...@@ -31,22 +31,16 @@ typedef struct {
void *pRpc; void *pRpc;
} SInfo; } SInfo;
static void processResponse(SRpcMsg *pMsg) { static void processResponse(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SInfo *pInfo = (SInfo *)pMsg->handle; SInfo *pInfo = (SInfo *)pMsg->handle;
tTrace("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code); tTrace("thread:%d, response is received, type:%d contLen:%d code:0x%x", pInfo->index, pMsg->msgType, pMsg->contLen, pMsg->code);
rpcFreeCont(pMsg->pCont); if (pIpSet) pInfo->ipSet = *pIpSet;
rpcFreeCont(pMsg->pCont);
sem_post(&pInfo->rspSem); sem_post(&pInfo->rspSem);
} }
static void processUpdateIpSet(void *handle, SRpcIpSet *pIpSet) {
SInfo *pInfo = (SInfo *)handle;
tTrace("thread:%d, ip set is changed, index:%d", pInfo->index, pIpSet->inUse);
pInfo->ipSet = *pIpSet;
}
static int tcount = 0; static int tcount = 0;
static void *sendRequest(void *param) { static void *sendRequest(void *param) {
...@@ -99,7 +93,6 @@ int main(int argc, char *argv[]) { ...@@ -99,7 +93,6 @@ int main(int argc, char *argv[]) {
rpcInit.label = "APP"; rpcInit.label = "APP";
rpcInit.numOfThreads = 1; rpcInit.numOfThreads = 1;
rpcInit.cfp = processResponse; rpcInit.cfp = processResponse;
rpcInit.ufp = processUpdateIpSet;
rpcInit.sessions = 100; rpcInit.sessions = 100;
rpcInit.idleTime = tsShellActivityTimer*1000; rpcInit.idleTime = tsShellActivityTimer*1000;
rpcInit.user = "michael"; rpcInit.user = "michael";
......
...@@ -32,12 +32,6 @@ typedef struct { ...@@ -32,12 +32,6 @@ typedef struct {
void *pRpc; void *pRpc;
} SInfo; } SInfo;
static void processUpdateIpSet(void *handle, SRpcIpSet *pIpSet) {
SInfo *pInfo = (SInfo *)handle;
tTrace("thread:%d, ip set is changed, index:%d", pInfo->index, pIpSet->inUse);
pInfo->ipSet = *pIpSet;
}
static int tcount = 0; static int tcount = 0;
static int terror = 0; static int terror = 0;
...@@ -100,8 +94,6 @@ int main(int argc, char *argv[]) { ...@@ -100,8 +94,6 @@ int main(int argc, char *argv[]) {
rpcInit.localPort = 0; rpcInit.localPort = 0;
rpcInit.label = "APP"; rpcInit.label = "APP";
rpcInit.numOfThreads = 1; rpcInit.numOfThreads = 1;
// rpcInit.cfp = processResponse;
rpcInit.ufp = processUpdateIpSet;
rpcInit.sessions = 100; rpcInit.sessions = 100;
rpcInit.idleTime = tsShellActivityTimer*1000; rpcInit.idleTime = tsShellActivityTimer*1000;
rpcInit.user = "michael"; rpcInit.user = "michael";
......
...@@ -113,7 +113,7 @@ int retrieveAuthInfo(char *meterId, char *spi, char *encrypt, char *secret, char ...@@ -113,7 +113,7 @@ int retrieveAuthInfo(char *meterId, char *spi, char *encrypt, char *secret, char
return ret; return ret;
} }
void processRequestMsg(SRpcMsg *pMsg) { void processRequestMsg(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SRpcMsg *pTemp; SRpcMsg *pTemp;
pTemp = taosAllocateQitem(sizeof(SRpcMsg)); pTemp = taosAllocateQitem(sizeof(SRpcMsg));
......
...@@ -81,7 +81,6 @@ typedef struct { ...@@ -81,7 +81,6 @@ typedef struct {
// ---------- TSDB TABLE DEFINITION // ---------- TSDB TABLE DEFINITION
typedef struct STable { typedef struct STable {
int8_t type; int8_t type;
char * name;
STableId tableId; STableId tableId;
int64_t superUid; // Super table UID int64_t superUid; // Super table UID
int32_t sversion; int32_t sversion;
...@@ -96,9 +95,10 @@ typedef struct STable { ...@@ -96,9 +95,10 @@ typedef struct STable {
TSKEY lastKey; // lastkey inserted in this table, initialized as 0, TODO: make a structure TSKEY lastKey; // lastkey inserted in this table, initialized as 0, TODO: make a structure
struct STable *next; // TODO: remove the next struct STable *next; // TODO: remove the next
struct STable *prev; struct STable *prev;
tstr * name; // NOTE: there a flexible string here
} STable; } STable;
#define TSDB_GET_TABLE_LAST_KEY(pTable) ((pTable)->lastKey) #define TSDB_GET_TABLE_LAST_KEY(tb) ((tb)->lastKey)
void * tsdbEncodeTable(STable *pTable, int *contLen); void * tsdbEncodeTable(STable *pTable, int *contLen);
STable *tsdbDecodeTable(void *cont, int contLen); STable *tsdbDecodeTable(void *cont, int contLen);
...@@ -121,6 +121,12 @@ typedef struct { ...@@ -121,6 +121,12 @@ typedef struct {
int maxCols; int maxCols;
} STsdbMeta; } STsdbMeta;
// element put in skiplist for each table
typedef struct STableIndexElem {
STsdbMeta* pMeta;
STable* pTable;
} STableIndexElem;
STsdbMeta *tsdbInitMeta(char *rootDir, int32_t maxTables); STsdbMeta *tsdbInitMeta(char *rootDir, int32_t maxTables);
int32_t tsdbFreeMeta(STsdbMeta *pMeta); int32_t tsdbFreeMeta(STsdbMeta *pMeta);
STSchema * tsdbGetTableSchema(STsdbMeta *pMeta, STable *pTable); STSchema * tsdbGetTableSchema(STsdbMeta *pMeta, STable *pTable);
...@@ -145,12 +151,10 @@ STSchema * tsdbGetTableTagSchema(STsdbMeta *pMeta, STable *pTable); ...@@ -145,12 +151,10 @@ STSchema * tsdbGetTableTagSchema(STsdbMeta *pMeta, STable *pTable);
STsdbMeta *tsdbGetMeta(TsdbRepoT *pRepo); STsdbMeta *tsdbGetMeta(TsdbRepoT *pRepo);
int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg);
int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId);
STable *tsdbIsValidTableToInsert(STsdbMeta *pMeta, STableId tableId); STable *tsdbIsValidTableToInsert(STsdbMeta *pMeta, STableId tableId);
// int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable); // int32_t tsdbInsertRowToTableImpl(SSkipListNode *pNode, STable *pTable);
STable *tsdbGetTableByUid(STsdbMeta *pMeta, int64_t uid); STable *tsdbGetTableByUid(STsdbMeta *pMeta, int64_t uid);
char * getTupleKey(const void *data); char *getTSTupleKey(const void * data);
typedef struct { typedef struct {
int blockId; int blockId;
...@@ -493,6 +497,7 @@ int tsdbWriteCompIdx(SRWHelper *pHelper); ...@@ -493,6 +497,7 @@ int tsdbWriteCompIdx(SRWHelper *pHelper);
void tsdbFitRetention(STsdbRepo *pRepo); void tsdbFitRetention(STsdbRepo *pRepo);
int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks); int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks);
void tsdbAdjustCacheBlocks(STsdbCache *pCache); void tsdbAdjustCacheBlocks(STsdbCache *pCache);
int32_t tsdbGetMetaFileName(char *rootDir, char *fname);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -164,7 +164,7 @@ int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks) { ...@@ -164,7 +164,7 @@ int tsdbAlterCacheTotalBlocks(STsdbRepo *pRepo, int totalBlocks) {
} }
tsdbUnLockRepo((TsdbRepoT *)pRepo); tsdbUnLockRepo((TsdbRepoT *)pRepo);
tsdbTrace("tsdbId %d: tsdb total cache blocks changed from %d to %d", pRepo->config.tsdbId, oldNumOfBlocks, totalBlocks); tsdbTrace("vgId: %d tsdb total cache blocks changed from %d to %d", pRepo->config.tsdbId, oldNumOfBlocks, totalBlocks);
return 0; return 0;
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "tscompression.h" #include "tscompression.h"
#include "tchecksum.h" #include "tchecksum.h"
#include "ttime.h" #include "ttime.h"
#include <sys/stat.h>
int tsdbDebugFlag = 135; int tsdbDebugFlag = 135;
...@@ -133,6 +134,7 @@ int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter /* TODO */) ...@@ -133,6 +134,7 @@ int32_t tsdbCreateRepo(char *rootDir, STsdbCfg *pCfg, void *limiter /* TODO */)
*/ */
int32_t tsdbDropRepo(TsdbRepoT *repo) { int32_t tsdbDropRepo(TsdbRepoT *repo) {
STsdbRepo *pRepo = (STsdbRepo *)repo; STsdbRepo *pRepo = (STsdbRepo *)repo;
int id = pRepo->config.tsdbId;
pRepo->state = TSDB_REPO_STATE_CLOSED; pRepo->state = TSDB_REPO_STATE_CLOSED;
...@@ -148,6 +150,8 @@ int32_t tsdbDropRepo(TsdbRepoT *repo) { ...@@ -148,6 +150,8 @@ int32_t tsdbDropRepo(TsdbRepoT *repo) {
free(pRepo->rootDir); free(pRepo->rootDir);
free(pRepo); free(pRepo);
tsdbTrace("vgId: %d tsdb repository is dropped!", id);
return 0; return 0;
} }
...@@ -238,6 +242,7 @@ TsdbRepoT *tsdbOpenRepo(char *tsdbDir, STsdbAppH *pAppH) { ...@@ -238,6 +242,7 @@ TsdbRepoT *tsdbOpenRepo(char *tsdbDir, STsdbAppH *pAppH) {
pRepo->state = TSDB_REPO_STATE_ACTIVE; pRepo->state = TSDB_REPO_STATE_ACTIVE;
tsdbTrace("vgId: %d open tsdb repository successfully!", pRepo->config.tsdbId);
return (TsdbRepoT *)pRepo; return (TsdbRepoT *)pRepo;
} }
...@@ -256,6 +261,7 @@ TsdbRepoT *tsdbOpenRepo(char *tsdbDir, STsdbAppH *pAppH) { ...@@ -256,6 +261,7 @@ TsdbRepoT *tsdbOpenRepo(char *tsdbDir, STsdbAppH *pAppH) {
int32_t tsdbCloseRepo(TsdbRepoT *repo) { int32_t tsdbCloseRepo(TsdbRepoT *repo) {
STsdbRepo *pRepo = (STsdbRepo *)repo; STsdbRepo *pRepo = (STsdbRepo *)repo;
if (pRepo == NULL) return 0; if (pRepo == NULL) return 0;
int id = pRepo->config.tsdbId;
pRepo->state = TSDB_REPO_STATE_CLOSED; pRepo->state = TSDB_REPO_STATE_CLOSED;
tsdbLockRepo(repo); tsdbLockRepo(repo);
...@@ -289,6 +295,8 @@ int32_t tsdbCloseRepo(TsdbRepoT *repo) { ...@@ -289,6 +295,8 @@ int32_t tsdbCloseRepo(TsdbRepoT *repo) {
tfree(pRepo->rootDir); tfree(pRepo->rootDir);
tfree(pRepo); tfree(pRepo);
tsdbTrace("vgId: %d repository is closed!", id);
return 0; return 0;
} }
...@@ -349,6 +357,7 @@ int32_t tsdbTriggerCommit(TsdbRepoT *repo) { ...@@ -349,6 +357,7 @@ int32_t tsdbTriggerCommit(TsdbRepoT *repo) {
pthread_attr_init(&thattr); pthread_attr_init(&thattr);
pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_DETACHED);
pthread_create(&(pRepo->commitThread), &thattr, tsdbCommitData, (void *)repo); pthread_create(&(pRepo->commitThread), &thattr, tsdbCommitData, (void *)repo);
tsdbTrace("vgId: %d start to commit!", pRepo->config.tsdbId);
return 0; return 0;
} }
...@@ -376,11 +385,6 @@ STsdbRepoInfo *tsdbGetStatus(TsdbRepoT *pRepo) { ...@@ -376,11 +385,6 @@ STsdbRepoInfo *tsdbGetStatus(TsdbRepoT *pRepo) {
return NULL; return NULL;
} }
int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) {
STsdbRepo *pRepo = (STsdbRepo *)repo;
return tsdbCreateTableImpl(pRepo->tsdbMeta, pCfg);
}
int tsdbAlterTable(TsdbRepoT *pRepo, STableCfg *pCfg) { int tsdbAlterTable(TsdbRepoT *pRepo, STableCfg *pCfg) {
// TODO // TODO
return 0; return 0;
...@@ -395,13 +399,6 @@ TSKEY tsdbGetTableLastKey(TsdbRepoT *repo, int64_t uid) { ...@@ -395,13 +399,6 @@ TSKEY tsdbGetTableLastKey(TsdbRepoT *repo, int64_t uid) {
return TSDB_GET_TABLE_LAST_KEY(pTable); return TSDB_GET_TABLE_LAST_KEY(pTable);
} }
int tsdbDropTable(TsdbRepoT *repo, STableId tableId) {
if (repo == NULL) return -1;
STsdbRepo *pRepo = (STsdbRepo *)repo;
return tsdbDropTableImpl(pRepo->tsdbMeta, tableId);
}
STableInfo *tsdbGetTableInfo(TsdbRepoT *pRepo, STableId tableId) { STableInfo *tsdbGetTableInfo(TsdbRepoT *pRepo, STableId tableId) {
// TODO // TODO
return NULL; return NULL;
...@@ -756,12 +753,12 @@ static int32_t tsdbSetRepoEnv(STsdbRepo *pRepo) { ...@@ -756,12 +753,12 @@ static int32_t tsdbSetRepoEnv(STsdbRepo *pRepo) {
if (tsdbGetDataDirName(pRepo, dirName) < 0) return -1; if (tsdbGetDataDirName(pRepo, dirName) < 0) return -1;
if (mkdir(dirName, 0755) < 0) { if (mkdir(dirName, 0755) < 0) {
tsdbError("id %d: failed to create repository directory! reason %s", pRepo->config.tsdbId, strerror(errno)); tsdbError("vgId: %d failed to create repository directory! reason %s", pRepo->config.tsdbId, strerror(errno));
return -1; return -1;
} }
tsdbError( tsdbTrace(
"id %d: set up tsdb environment succeed! cacheBlockSize %d, totalBlocks %d, maxTables %d, daysPerFile %d, keep " "vgId: %d set up tsdb environment succeed! cacheBlockSize %d, totalBlocks %d, maxTables %d, daysPerFile %d, keep "
"%d, minRowsPerFileBlock %d, maxRowsPerFileBlock %d, precision %d, compression%d", "%d, minRowsPerFileBlock %d, maxRowsPerFileBlock %d, precision %d, compression%d",
pRepo->config.tsdbId, pCfg->cacheBlockSize, pCfg->totalBlocks, pCfg->maxTables, pCfg->daysPerFile, pCfg->keep, pRepo->config.tsdbId, pCfg->cacheBlockSize, pCfg->totalBlocks, pCfg->maxTables, pCfg->daysPerFile, pCfg->keep,
pCfg->minRowsPerFileBlock, pCfg->maxRowsPerFileBlock, pCfg->precision, pCfg->compression); pCfg->minRowsPerFileBlock, pCfg->maxRowsPerFileBlock, pCfg->precision, pCfg->compression);
...@@ -808,7 +805,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable ...@@ -808,7 +805,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable
if (pTable->mem == NULL) { if (pTable->mem == NULL) {
pTable->mem = (SMemTable *)calloc(1, sizeof(SMemTable)); pTable->mem = (SMemTable *)calloc(1, sizeof(SMemTable));
if (pTable->mem == NULL) return -1; if (pTable->mem == NULL) return -1;
pTable->mem->pData = tSkipListCreate(5, TSDB_DATA_TYPE_TIMESTAMP, TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP], 0, 0, 0, getTupleKey); pTable->mem->pData = tSkipListCreate(5, TSDB_DATA_TYPE_TIMESTAMP, TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP], 0, 0, 0, getTSTupleKey);
pTable->mem->keyFirst = INT64_MAX; pTable->mem->keyFirst = INT64_MAX;
pTable->mem->keyLast = 0; pTable->mem->keyLast = 0;
} }
...@@ -831,7 +828,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable ...@@ -831,7 +828,7 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable
if (pTable->mem == NULL) { if (pTable->mem == NULL) {
pTable->mem = (SMemTable *)calloc(1, sizeof(SMemTable)); pTable->mem = (SMemTable *)calloc(1, sizeof(SMemTable));
if (pTable->mem == NULL) return -1; if (pTable->mem == NULL) return -1;
pTable->mem->pData = tSkipListCreate(5, TSDB_DATA_TYPE_TIMESTAMP, TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP], 0, 0, 0, getTupleKey); pTable->mem->pData = tSkipListCreate(5, TSDB_DATA_TYPE_TIMESTAMP, TYPE_BYTES[TSDB_DATA_TYPE_TIMESTAMP], 0, 0, 0, getTSTupleKey);
pTable->mem->keyFirst = INT64_MAX; pTable->mem->keyFirst = INT64_MAX;
pTable->mem->keyLast = 0; pTable->mem->keyLast = 0;
} }
...@@ -842,6 +839,9 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable ...@@ -842,6 +839,9 @@ static int32_t tdInsertRowToTable(STsdbRepo *pRepo, SDataRow row, STable *pTable
pTable->mem->numOfPoints = tSkipListGetSize(pTable->mem->pData); pTable->mem->numOfPoints = tSkipListGetSize(pTable->mem->pData);
tsdbTrace("vgId: %d, tid: %d, uid: " PRId64 "a row is inserted to table! key" PRId64,
pRepo->config.tsdbId, pTable->tableId.tid, pTable->tableId.uid, dataRowKey(row));
return 0; return 0;
} }
...@@ -1104,11 +1104,14 @@ static int tsdbHasDataToCommit(SSkipListIterator **iters, int nIters, TSKEY minK ...@@ -1104,11 +1104,14 @@ static int tsdbHasDataToCommit(SSkipListIterator **iters, int nIters, TSKEY minK
} }
static void tsdbAlterCompression(STsdbRepo *pRepo, int8_t compression) { static void tsdbAlterCompression(STsdbRepo *pRepo, int8_t compression) {
int8_t oldCompRession = pRepo->config.compression;
pRepo->config.compression = compression; pRepo->config.compression = compression;
tsdbTrace("vgId: %d tsdb compression is changed from %d to %d", oldCompRession, compression);
} }
static void tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) { static void tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) {
STsdbCfg *pCfg = &pRepo->config; STsdbCfg *pCfg = &pRepo->config;
int oldKeep = pCfg->keep;
int maxFiles = keep / pCfg->maxTables + 3; int maxFiles = keep / pCfg->maxTables + 3;
if (pRepo->config.keep > keep) { if (pRepo->config.keep > keep) {
...@@ -1120,8 +1123,57 @@ static void tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) { ...@@ -1120,8 +1123,57 @@ static void tsdbAlterKeep(STsdbRepo *pRepo, int32_t keep) {
} }
pRepo->tsdbFileH->maxFGroups = maxFiles; pRepo->tsdbFileH->maxFGroups = maxFiles;
} }
tsdbTrace("vgId: %d keep is changed from %d to %d", pRepo->config.tsdbId, oldKeep, keep);
} }
static void tsdbAlterMaxTables(STsdbRepo *pRepo, int32_t maxTables) { static void tsdbAlterMaxTables(STsdbRepo *pRepo, int32_t maxTables) {
// TODO // TODO
int oldMaxTables = pRepo->config.maxTables;
tsdbTrace("vgId: %d tsdb maxTables is changed from %d to %d!", pRepo->config.tsdbId, oldMaxTables, maxTables);
}
uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, int32_t *size) {
// TODO: need to refactor this function
STsdbRepo *pRepo = (STsdbRepo *)repo;
// STsdbMeta *pMeta = pRepo->tsdbMeta;
STsdbFileH *pFileH = pRepo->tsdbFileH;
uint32_t magic = 0;
char fname[256] = "\0";
struct stat fState;
char *spath = strdup(pRepo->rootDir);
char *prefixDir = dirname(spath);
if (name[0] == 0) {
// Map index to the file name
int fid = (*index) / 3;
if (fid > pFileH->numOfFGroups) {
// return meta data file
if ((*index) % 3 > 0) { // it is finished
tfree(spath);
return 0;
} else {
tsdbGetMetaFileName(pRepo->rootDir, fname);
}
} else {
// return data file name
strcpy(fname, pFileH->fGroup[fid].files[(*index) % 3].fname);
}
strcpy(name, fname + strlen(spath));
} else {
// Name is provided, need to get the file info
sprintf(fname, "%s/%s", prefixDir, name);
}
if (stat(fname, &fState) < 0) {
tfree(spath);
return 0;
}
*size = fState.st_size;
magic = *size;
return magic;
} }
\ No newline at end of file
#include <stdlib.h> #include <stdlib.h>
// #include "taosdef.h"
#include "tskiplist.h" #include "tskiplist.h"
#include "tsdb.h" #include "tsdb.h"
#include "taosdef.h" #include "taosdef.h"
...@@ -10,6 +8,8 @@ ...@@ -10,6 +8,8 @@
#define TSDB_SUPER_TABLE_SL_LEVEL 5 // TODO: may change here #define TSDB_SUPER_TABLE_SL_LEVEL 5 // TODO: may change here
#define TSDB_META_FILE_NAME "META" #define TSDB_META_FILE_NAME "META"
const int32_t DEFAULT_TAG_INDEX_COLUMN = 0; // skip list built based on the first column of tags
static int tsdbFreeTable(STable *pTable); static int tsdbFreeTable(STable *pTable);
static int32_t tsdbCheckTableCfg(STableCfg *pCfg); static int32_t tsdbCheckTableCfg(STableCfg *pCfg);
static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx); static int tsdbAddTableToMeta(STsdbMeta *pMeta, STable *pTable, bool addIdx);
...@@ -39,11 +39,12 @@ void *tsdbEncodeTable(STable *pTable, int *contLen) { ...@@ -39,11 +39,12 @@ void *tsdbEncodeTable(STable *pTable, int *contLen) {
void *ptr = ret; void *ptr = ret;
T_APPEND_MEMBER(ptr, pTable, STable, type); T_APPEND_MEMBER(ptr, pTable, STable, type);
// Encode name // Encode name, todo refactor
*(int *)ptr = strlen(pTable->name); *(int *)ptr = varDataLen(pTable->name);
ptr = (char *)ptr + sizeof(int); ptr = (char *)ptr + sizeof(int);
memcpy(ptr, pTable->name, strlen(pTable->name)); memcpy(ptr, varDataVal(pTable->name), varDataLen(pTable->name));
ptr = (char *)ptr + strlen(pTable->name); ptr = (char *)ptr + varDataLen(pTable->name);
T_APPEND_MEMBER(ptr, &(pTable->tableId), STableId, uid); T_APPEND_MEMBER(ptr, &(pTable->tableId), STableId, uid);
T_APPEND_MEMBER(ptr, &(pTable->tableId), STableId, tid); T_APPEND_MEMBER(ptr, &(pTable->tableId), STableId, tid);
T_APPEND_MEMBER(ptr, pTable, STable, superUid); T_APPEND_MEMBER(ptr, pTable, STable, superUid);
...@@ -79,9 +80,12 @@ STable *tsdbDecodeTable(void *cont, int contLen) { ...@@ -79,9 +80,12 @@ STable *tsdbDecodeTable(void *cont, int contLen) {
T_READ_MEMBER(ptr, int8_t, pTable->type); T_READ_MEMBER(ptr, int8_t, pTable->type);
int len = *(int *)ptr; int len = *(int *)ptr;
ptr = (char *)ptr + sizeof(int); ptr = (char *)ptr + sizeof(int);
pTable->name = calloc(1, len + 1); pTable->name = calloc(1, len + VARSTR_HEADER_SIZE);
if (pTable->name == NULL) return NULL; if (pTable->name == NULL) return NULL;
memcpy(pTable->name, ptr, len);
varDataSetLen(pTable->name, len);
memcpy(pTable->name->data, ptr, len);
ptr = (char *)ptr + len; ptr = (char *)ptr + len;
T_READ_MEMBER(ptr, int64_t, pTable->tableId.uid); T_READ_MEMBER(ptr, int64_t, pTable->tableId.uid);
T_READ_MEMBER(ptr, int32_t, pTable->tableId.tid); T_READ_MEMBER(ptr, int32_t, pTable->tableId.tid);
...@@ -105,8 +109,13 @@ void tsdbFreeEncode(void *cont) { ...@@ -105,8 +109,13 @@ void tsdbFreeEncode(void *cont) {
} }
static char* getTagIndexKey(const void* pData) { static char* getTagIndexKey(const void* pData) {
STable* table = *(STable**) pData; STableIndexElem* elem = (STableIndexElem*) pData;
return getTupleKey(table->tagVal);
SDataRow row = elem->pTable->tagVal;
STSchema* pSchema = tsdbGetTableTagSchema(elem->pMeta, elem->pTable);
STColumn* pCol = &pSchema->columns[DEFAULT_TAG_INDEX_COLUMN];
return tdGetRowDataOfCol(row, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset);
} }
int tsdbRestoreTable(void *pHandle, void *cont, int contLen) { int tsdbRestoreTable(void *pHandle, void *cont, int contLen) {
...@@ -230,31 +239,23 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t ...@@ -230,31 +239,23 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t
STable* pTable = tsdbGetTableByUid(pMeta, id->uid); STable* pTable = tsdbGetTableByUid(pMeta, id->uid);
STSchema* pSchema = tsdbGetTableTagSchema(pMeta, pTable); STSchema* pSchema = tsdbGetTableTagSchema(pMeta, pTable);
STColumn* pCol = NULL; STColumn* pCol = NULL;
int32_t offset = 0;
// todo binary search
for(int32_t col = 0; col < schemaNCols(pSchema); ++col) { for(int32_t col = 0; col < schemaNCols(pSchema); ++col) {
STColumn* p = schemaColAt(pSchema, col); STColumn* p = schemaColAt(pSchema, col);
if (p->colId == colId) { if (p->colId == colId) {
pCol = p; pCol = p;
break; break;
} }
if (p->type == TSDB_DATA_TYPE_BINARY || p->type == TSDB_DATA_TYPE_NCHAR) {
offset += sizeof(int32_t);
} else {
offset += p->bytes;
}
} }
if (pCol == NULL) { if (pCol == NULL) {
return -1; // No matched tags. Maybe the modification of tags has not been done yet. return -1; // No matched tags. Maybe the modification of tags has not been done yet.
} }
assert(pCol != NULL);
SDataRow row = (SDataRow)pTable->tagVal; SDataRow row = (SDataRow)pTable->tagVal;
char* d = tdGetRowDataOfCol(row, pCol->type, TD_DATA_ROW_HEAD_SIZE + offset); char* d = tdGetRowDataOfCol(row, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset);
*val = d; *val = d;
*type = pCol->type; *type = pCol->type;
...@@ -263,19 +264,29 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t ...@@ -263,19 +264,29 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t tsdbGetTableName(TsdbRepoT *repo, STableId* id, char** name) { char* tsdbGetTableName(TsdbRepoT *repo, const STableId* id, int16_t* bytes) {
STsdbMeta* pMeta = tsdbGetMeta(repo); STsdbMeta* pMeta = tsdbGetMeta(repo);
STable* pTable = tsdbGetTableByUid(pMeta, id->uid); STable* pTable = tsdbGetTableByUid(pMeta, id->uid);
*name = strndup(pTable->name, TSDB_TABLE_NAME_LEN); if (pTable == NULL) {
if (*name == NULL) { if (bytes != NULL) {
return -1; *bytes = 0;
}
return NULL;
} else { } else {
return 0; if (bytes != NULL) {
*bytes = varDataLen(pTable->name);
}
return (char*) pTable->name;
} }
} }
int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) { int tsdbCreateTable(TsdbRepoT *repo, STableCfg *pCfg) {
STsdbRepo *pRepo = (STsdbRepo *)repo;
STsdbMeta *pMeta = pRepo->tsdbMeta;
if (tsdbCheckTableCfg(pCfg) < 0) return -1; if (tsdbCheckTableCfg(pCfg) < 0) return -1;
STable *super = NULL; STable *super = NULL;
...@@ -296,7 +307,11 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) { ...@@ -296,7 +307,11 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
super->schema = tdDupSchema(pCfg->schema); super->schema = tdDupSchema(pCfg->schema);
super->tagSchema = tdDupSchema(pCfg->tagSchema); super->tagSchema = tdDupSchema(pCfg->tagSchema);
super->tagVal = NULL; super->tagVal = NULL;
super->name = strdup(pCfg->sname);
// todo refactor extract method
size_t size = strnlen(pCfg->sname, TSDB_TABLE_NAME_LEN);
super->name = malloc(size + VARSTR_HEADER_SIZE);
STR_WITH_SIZE_TO_VARSTR(super->name, pCfg->sname, size);
// index the first tag column // index the first tag column
STColumn* pColSchema = schemaColAt(super->tagSchema, 0); STColumn* pColSchema = schemaColAt(super->tagSchema, 0);
...@@ -322,7 +337,11 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) { ...@@ -322,7 +337,11 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
} }
table->tableId = pCfg->tableId; table->tableId = pCfg->tableId;
table->name = strdup(pCfg->name);
size_t size = strnlen(pCfg->name, TSDB_TABLE_NAME_LEN);
table->name = malloc(size + VARSTR_HEADER_SIZE);
STR_WITH_SIZE_TO_VARSTR(table->name, pCfg->name, size);
table->lastKey = 0; table->lastKey = 0;
if (IS_CREATE_STABLE(pCfg)) { // TSDB_CHILD_TABLE if (IS_CREATE_STABLE(pCfg)) { // TSDB_CHILD_TABLE
table->type = TSDB_CHILD_TABLE; table->type = TSDB_CHILD_TABLE;
...@@ -335,8 +354,14 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) { ...@@ -335,8 +354,14 @@ int32_t tsdbCreateTableImpl(STsdbMeta *pMeta, STableCfg *pCfg) {
} }
// Register to meta // Register to meta
if (newSuper) tsdbAddTableToMeta(pMeta, super, true); if (newSuper) {
tsdbAddTableToMeta(pMeta, super, true);
tsdbTrace("vgId: %d super table is created! uid " PRId64, pRepo->config.tsdbId,
super->tableId.uid);
}
tsdbAddTableToMeta(pMeta, table, true); tsdbAddTableToMeta(pMeta, table, true);
tsdbTrace("vgId: %d table is created! tid %d, uid " PRId64, pRepo->config.tsdbId, table->tableId.tid,
table->tableId.uid);
// Write to meta file // Write to meta file
int bufLen = 0; int bufLen = 0;
...@@ -369,13 +394,24 @@ STable *tsdbIsValidTableToInsert(STsdbMeta *pMeta, STableId tableId) { ...@@ -369,13 +394,24 @@ STable *tsdbIsValidTableToInsert(STsdbMeta *pMeta, STableId tableId) {
return pTable; return pTable;
} }
int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) { // int32_t tsdbDropTableImpl(STsdbMeta *pMeta, STableId tableId) {
int tsdbDropTable(TsdbRepoT *repo, STableId tableId) {
STsdbRepo *pRepo = (STsdbRepo *)repo;
if (pRepo == NULL) return -1;
STsdbMeta *pMeta = pRepo->tsdbMeta;
if (pMeta == NULL) return -1; if (pMeta == NULL) return -1;
STable *pTable = tsdbGetTableByUid(pMeta, tableId.uid); STable *pTable = tsdbGetTableByUid(pMeta, tableId.uid);
if (pTable == NULL) return -1; if (pTable == NULL) {
tsdbError("vgId %d: failed to drop table since table not exists! tid %d, uid " PRId64, pRepo->config.tsdbId,
tableId.tid, tableId.uid);
return -1;
}
tsdbTrace("vgId: %d table is dropped! tid %d, uid " PRId64, pRepo->config.tsdbId, tableId.tid, tableId.uid);
if (tsdbRemoveTableFromMeta(pMeta, pTable) < 0) return -1; if (tsdbRemoveTableFromMeta(pMeta, pTable) < 0) return -1;
return 0; return 0;
} }
...@@ -467,7 +503,9 @@ static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) { ...@@ -467,7 +503,9 @@ static int tsdbRemoveTableFromMeta(STsdbMeta *pMeta, STable *pTable) {
if (pTable->type == TSDB_SUPER_TABLE) { if (pTable->type == TSDB_SUPER_TABLE) {
SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex); SSkipListIterator *pIter = tSkipListCreateIter(pTable->pIndex);
while (tSkipListIterNext(pIter)) { while (tSkipListIterNext(pIter)) {
STable *tTable = *(STable **)SL_GET_NODE_DATA(tSkipListIterGet(pIter)); STableIndexElem *pEle = (STableIndexElem *)SL_GET_NODE_DATA(tSkipListIterGet(pIter));
STable *tTable = pEle->pTable;
ASSERT(tTable != NULL && tTable->type == TSDB_CHILD_TABLE); ASSERT(tTable != NULL && tTable->type == TSDB_CHILD_TABLE);
pMeta->tables[tTable->tableId.tid] = NULL; pMeta->tables[tTable->tableId.tid] = NULL;
...@@ -513,11 +551,14 @@ static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable) { ...@@ -513,11 +551,14 @@ static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable) {
// NOTE: do not allocate the space for key, since in each skip list node, only keep the pointer to pTable, not the // NOTE: do not allocate the space for key, since in each skip list node, only keep the pointer to pTable, not the
// actual key value, and the key value will be retrieved during query through the pTable and getTagIndexKey function // actual key value, and the key value will be retrieved during query through the pTable and getTagIndexKey function
SSkipListNode* pNode = calloc(1, headSize + POINTER_BYTES); SSkipListNode* pNode = calloc(1, headSize + sizeof(STableIndexElem));
pNode->level = level; pNode->level = level;
SSkipList* list = pSTable->pIndex; SSkipList* list = pSTable->pIndex;
memcpy(SL_GET_NODE_DATA(pNode), &pTable, POINTER_BYTES); STableIndexElem* elem = (STableIndexElem*) (SL_GET_NODE_DATA(pNode));
elem->pTable = pTable;
elem->pMeta = pMeta;
tSkipListPut(list, pNode); tSkipListPut(list, pNode);
return 0; return 0;
...@@ -529,7 +570,10 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) { ...@@ -529,7 +570,10 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
STable* pSTable = tsdbGetTableByUid(pMeta, pTable->superUid); STable* pSTable = tsdbGetTableByUid(pMeta, pTable->superUid);
assert(pSTable != NULL); assert(pSTable != NULL);
char* key = dataRowTuple(pTable->tagVal); // key STSchema* pSchema = tsdbGetTableTagSchema(pMeta, pTable);
STColumn* pCol = &pSchema->columns[DEFAULT_TAG_INDEX_COLUMN];
char* key = tdGetRowDataOfCol(pTable->tagVal, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset);
bool ret = tSkipListRemove(pSTable->pIndex, key); bool ret = tSkipListRemove(pSTable->pIndex, key);
assert(ret); assert(ret);
...@@ -539,7 +583,7 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) { ...@@ -539,7 +583,7 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
static int tsdbEstimateTableEncodeSize(STable *pTable) { static int tsdbEstimateTableEncodeSize(STable *pTable) {
int size = 0; int size = 0;
size += T_MEMBER_SIZE(STable, type); size += T_MEMBER_SIZE(STable, type);
size += sizeof(int) + strlen(pTable->name); size += sizeof(int) + varDataLen(pTable->name);
size += T_MEMBER_SIZE(STable, tableId); size += T_MEMBER_SIZE(STable, tableId);
size += T_MEMBER_SIZE(STable, superUid); size += T_MEMBER_SIZE(STable, superUid);
size += T_MEMBER_SIZE(STable, sversion); size += T_MEMBER_SIZE(STable, sversion);
...@@ -556,8 +600,7 @@ static int tsdbEstimateTableEncodeSize(STable *pTable) { ...@@ -556,8 +600,7 @@ static int tsdbEstimateTableEncodeSize(STable *pTable) {
return size; return size;
} }
char *getTupleKey(const void * data) { char *getTSTupleKey(const void * data) {
SDataRow row = (SDataRow)data; SDataRow row = (SDataRow)data;
return POINTER_SHIFT(row, TD_DATA_ROW_HEAD_SIZE); return POINTER_SHIFT(row, TD_DATA_ROW_HEAD_SIZE);
} }
\ No newline at end of file
...@@ -28,7 +28,7 @@ typedef struct { ...@@ -28,7 +28,7 @@ typedef struct {
int64_t uid; int64_t uid;
} SRecordInfo; } SRecordInfo;
static int32_t tsdbGetMetaFileName(char *rootDir, char *fname); // static int32_t tsdbGetMetaFileName(char *rootDir, char *fname);
// static int32_t tsdbCheckMetaHeader(int fd); // static int32_t tsdbCheckMetaHeader(int fd);
static int32_t tsdbWriteMetaHeader(int fd); static int32_t tsdbWriteMetaHeader(int fd);
static int tsdbCreateMetaFile(char *fname); static int tsdbCreateMetaFile(char *fname);
...@@ -180,7 +180,7 @@ void tsdbCloseMetaFile(SMetaFile *mfh) { ...@@ -180,7 +180,7 @@ void tsdbCloseMetaFile(SMetaFile *mfh) {
tfree(mfh); tfree(mfh);
} }
static int32_t tsdbGetMetaFileName(char *rootDir, char *fname) { int32_t tsdbGetMetaFileName(char *rootDir, char *fname) {
if (rootDir == NULL) return -1; if (rootDir == NULL) return -1;
sprintf(fname, "%s/%s", rootDir, TSDB_META_FILE_NAME); sprintf(fname, "%s/%s", rootDir, TSDB_META_FILE_NAME);
return 0; return 0;
......
...@@ -620,9 +620,13 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf ...@@ -620,9 +620,13 @@ static void filterDataInDataBlock(STsdbQueryHandle* pQueryHandle, STableCheckInf
if (pCol->info.type != TSDB_DATA_TYPE_BINARY && pCol->info.type != TSDB_DATA_TYPE_NCHAR) { if (pCol->info.type != TSDB_DATA_TYPE_BINARY && pCol->info.type != TSDB_DATA_TYPE_NCHAR) {
memmove(pCol->pData, src->pData + bytes * start, bytes * pQueryHandle->realNumOfRows); memmove(pCol->pData, src->pData + bytes * start, bytes * pQueryHandle->realNumOfRows);
} else { // handle the var-string } else { // handle the var-string
char* dst = pCol->pData;
// todo refactor, only copy one-by-one
for(int32_t k = start; k < pQueryHandle->realNumOfRows + start; ++k) { for(int32_t k = start; k < pQueryHandle->realNumOfRows + start; ++k) {
char* p = tdGetColDataOfRow(src, k); char* p = tdGetColDataOfRow(src, k);
memcpy(pCol->pData + k * bytes, p, varDataTLen(p)); // todo refactor memcpy(dst, p, varDataTLen(p));
dst += bytes;
} }
} }
...@@ -1076,17 +1080,13 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY ...@@ -1076,17 +1080,13 @@ static int tsdbReadRowsFromCache(SSkipListIterator* pIter, STable* pTable, TSKEY
} }
assert(offset != -1); // todo handle error assert(offset != -1); // todo handle error
void *value = tdGetRowDataOfCol(row, pColInfo->info.type, TD_DATA_ROW_HEAD_SIZE + offset);
if (pColInfo->info.type == TSDB_DATA_TYPE_BINARY || pColInfo->info.type == TSDB_DATA_TYPE_NCHAR) { if (pColInfo->info.type == TSDB_DATA_TYPE_BINARY || pColInfo->info.type == TSDB_DATA_TYPE_NCHAR) {
void *value = tdGetRowDataOfCol(row, pColInfo->info.type, TD_DATA_ROW_HEAD_SIZE + offset);
memcpy(pData, value, varDataTLen(value)); memcpy(pData, value, varDataTLen(value));
offset += sizeof(int32_t);
} else { } else {
memcpy(pData, dataRowTuple(row) + offset, pColInfo->info.bytes); memcpy(pData, value, pColInfo->info.bytes);
offset += pColInfo->info.bytes;
} }
} }
numOfRows++; numOfRows++;
...@@ -1225,8 +1225,8 @@ static int32_t getAllTableIdList(STable* pSuperTable, SArray* list) { ...@@ -1225,8 +1225,8 @@ static int32_t getAllTableIdList(STable* pSuperTable, SArray* list) {
while (tSkipListIterNext(iter)) { while (tSkipListIterNext(iter)) {
SSkipListNode* pNode = tSkipListIterGet(iter); SSkipListNode* pNode = tSkipListIterGet(iter);
STable* t = *(STable**)SL_GET_NODE_DATA(pNode); STableIndexElem* elem = (STableIndexElem*)(SL_GET_NODE_DATA((SSkipListNode*) pNode));
taosArrayPush(list, &t->tableId); taosArrayPush(list, &elem->pTable->tableId);
} }
tSkipListDestroyIter(iter); tSkipListDestroyIter(iter);
...@@ -1235,6 +1235,7 @@ static int32_t getAllTableIdList(STable* pSuperTable, SArray* list) { ...@@ -1235,6 +1235,7 @@ static int32_t getAllTableIdList(STable* pSuperTable, SArray* list) {
/** /**
* convert the result pointer to table id instead of table object pointer * convert the result pointer to table id instead of table object pointer
* todo remove it by using callback function to change the final result in-time.
* @param pRes * @param pRes
*/ */
static void convertQueryResult(SArray* pRes, SArray* pTableList) { static void convertQueryResult(SArray* pRes, SArray* pTableList) {
...@@ -1244,8 +1245,8 @@ static void convertQueryResult(SArray* pRes, SArray* pTableList) { ...@@ -1244,8 +1245,8 @@ static void convertQueryResult(SArray* pRes, SArray* pTableList) {
size_t size = taosArrayGetSize(pTableList); size_t size = taosArrayGetSize(pTableList);
for (int32_t i = 0; i < size; ++i) { // todo speedup by using reserve space. for (int32_t i = 0; i < size; ++i) { // todo speedup by using reserve space.
STable* pTable = taosArrayGetP(pTableList, i); STableIndexElem* elem = taosArrayGet(pTableList, i);
taosArrayPush(pRes, &pTable->tableId); taosArrayPush(pRes, &elem->pTable->tableId);
} }
} }
...@@ -1309,8 +1310,13 @@ void filterPrepare(void* expr, void* param) { ...@@ -1309,8 +1310,13 @@ void filterPrepare(void* expr, void* param) {
pInfo->q = (char*) pCond->arr; pInfo->q = (char*) pCond->arr;
} else { } else {
pInfo->q = calloc(1, pSchema->bytes); pInfo->q = calloc(1, pSchema->bytes);
if (pSchema->type == TSDB_DATA_TYPE_BINARY || pSchema->type == TSDB_DATA_TYPE_NCHAR) {
tVariantDump(pCond, varDataVal(pInfo->q), pSchema->type);
varDataSetLen(pInfo->q, pCond->nLen); // the length may be changed after dump, so assign its value after dump
} else {
tVariantDump(pCond, pInfo->q, pSchema->type); tVariantDump(pCond, pInfo->q, pSchema->type);
} }
}
} }
typedef struct STableGroupSupporter { typedef struct STableGroupSupporter {
...@@ -1341,16 +1347,16 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) { ...@@ -1341,16 +1347,16 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
int32_t bytes = 0; int32_t bytes = 0;
if (colIndex == TSDB_TBNAME_COLUMN_INDEX) { if (colIndex == TSDB_TBNAME_COLUMN_INDEX) {
f1 = pTable1->name; f1 = (char*) pTable1->name;
f2 = pTable2->name; f2 = (char*) pTable2->name;
type = TSDB_DATA_TYPE_BINARY; type = TSDB_DATA_TYPE_BINARY;
bytes = TSDB_TABLE_NAME_LEN; bytes = TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE;
} else { } else {
f1 = dataRowTuple(pTable1->tagVal); STColumn* pCol = schemaColAt(pTableGroupSupp->pTagSchema, colIndex);
f2 = dataRowTuple(pTable2->tagVal); bytes = pCol->bytes;
type = schemaColAt(pTableGroupSupp->pTagSchema, colIndex)->type; f1 = tdGetRowDataOfCol(pTable1->tagVal, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset);
bytes = schemaColAt(pTableGroupSupp->pTagSchema, colIndex)->bytes; f2 = tdGetRowDataOfCol(pTable2->tagVal, pCol->type, TD_DATA_ROW_HEAD_SIZE + pCol->offset);
} }
int32_t ret = doCompare(f1, f2, type, bytes); int32_t ret = doCompare(f1, f2, type, bytes);
...@@ -1426,26 +1432,22 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC ...@@ -1426,26 +1432,22 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
return pTableGroup; return pTableGroup;
} }
bool tSkipListNodeFilterCallback(const void* pNode, void* param) { bool indexedNodeFilterFp(const void* pNode, void* param) {
tQueryInfo* pInfo = (tQueryInfo*) param; tQueryInfo* pInfo = (tQueryInfo*) param;
STable* pTable = *(STable**)(SL_GET_NODE_DATA((SSkipListNode*)pNode)); STableIndexElem* elem = (STableIndexElem*)(SL_GET_NODE_DATA((SSkipListNode*)pNode));
char* val = NULL; char* val = NULL;
int8_t type = pInfo->sch.type; int8_t type = pInfo->sch.type;
if (pInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) { if (pInfo->colIndex == TSDB_TBNAME_COLUMN_INDEX) {
val = pTable->name; val = (char*) elem->pTable->name;
type = TSDB_DATA_TYPE_BINARY; type = TSDB_DATA_TYPE_BINARY;
} else { } else {
STSchema* pTSchema = (STSchema*) pInfo->param; // todo table schema is identical to stable schema?? STSchema* pTSchema = (STSchema*) pInfo->param; // todo table schema is identical to stable schema??
int32_t offset = pTSchema->columns[pInfo->colIndex].offset; int32_t offset = pTSchema->columns[pInfo->colIndex].offset;
if (pInfo->sch.type == TSDB_DATA_TYPE_BINARY || pInfo->sch.type == TSDB_DATA_TYPE_NCHAR) { val = tdGetRowDataOfCol(elem->pTable->tagVal, pInfo->sch.type, TD_DATA_ROW_HEAD_SIZE + offset);
val = tdGetRowDataOfCol(pTable->tagVal, pInfo->sch.type, TD_DATA_ROW_HEAD_SIZE + offset);
} else {
val = dataRowTuple(pTable->tagVal) + offset;
}
} }
int32_t ret = 0; int32_t ret = 0;
...@@ -1456,8 +1458,6 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) { ...@@ -1456,8 +1458,6 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) {
ret = pInfo->compare(val, pInfo->q); ret = pInfo->compare(val, pInfo->q);
} }
} else { } else {
// tVariant t = {0};
// tVariantCreateFromBinary(&t, val, (uint32_t)pInfo->sch.bytes, type);
ret = pInfo->compare(val, pInfo->q); ret = pInfo->compare(val, pInfo->q);
} }
...@@ -1497,12 +1497,12 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) { ...@@ -1497,12 +1497,12 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) {
static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) { static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr) {
// query according to the expression tree // query according to the expression tree
SExprTraverseSupp supp = { SExprTraverseSupp supp = {
.fp = (__result_filter_fn_t) tSkipListNodeFilterCallback, .nodeFilterFn = (__result_filter_fn_t) indexedNodeFilterFp,
.setupInfoFn = filterPrepare, .setupInfoFn = filterPrepare,
.pExtInfo = pSTable->tagSchema, .pExtInfo = pSTable->tagSchema,
}; };
SArray* pTableList = taosArrayInit(8, POINTER_BYTES); SArray* pTableList = taosArrayInit(8, sizeof(STableIndexElem));
tExprTreeTraverse(pExpr, pSTable->pIndex, pTableList, &supp); tExprTreeTraverse(pExpr, pSTable->pIndex, pTableList, &supp);
tExprTreeDestroy(&pExpr, destroyHelper); tExprTreeDestroy(&pExpr, destroyHelper);
......
...@@ -144,11 +144,11 @@ static void tqsortImpl(void *src, int32_t start, int32_t end, size_t size, const ...@@ -144,11 +144,11 @@ static void tqsortImpl(void *src, int32_t start, int32_t end, size_t size, const
} }
if (leftPartEnd > start) { if (leftPartEnd > start) {
tqsortImpl(src, size, start, leftPartEnd, param, comparFn, buf); tqsortImpl(src, start, leftPartEnd, size, param, comparFn, buf);
} }
if (rightPartStart < end) { if (rightPartStart < end) {
tqsortImpl(src, size, rightPartStart, end, param, comparFn, buf); tqsortImpl(src, rightPartStart, end, size, param, comparFn, buf);
} }
} }
......
...@@ -51,42 +51,54 @@ int32_t compareDoubleIntVal(const void *pLeft, const void *pRight) { ...@@ -51,42 +51,54 @@ int32_t compareDoubleIntVal(const void *pLeft, const void *pRight) {
} }
} }
int32_t compareFloatVal(const void *pLeft, const void *pRight) {
float ret = GET_FLOAT_VAL(pLeft) - GET_FLOAT_VAL(pRight);
if (fabs(ret) < FLT_EPSILON) {
return 0;
} else {
return ret > 0? 1 : -1;
}
}
int32_t compareDoubleVal(const void *pLeft, const void *pRight) { int32_t compareDoubleVal(const void *pLeft, const void *pRight) {
double ret = GET_DOUBLE_VAL(pLeft) - GET_DOUBLE_VAL(pRight); double ret = GET_DOUBLE_VAL(pLeft) - GET_DOUBLE_VAL(pRight);
if (fabs(ret) < FLT_EPSILON) { if (fabs(ret) < FLT_EPSILON) {
return 0; return 0;
} else { } else {
return ret > 0 ? 1 : -1; return ret > 0? 1 : -1;
} }
} }
int32_t compareStrVal(const void *pLeft, const void *pRight) { int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight) {
return (int32_t)strcmp(pLeft, pRight); int32_t len1 = varDataLen(pLeft);
int32_t len2 = varDataLen(pRight);
if (len1 != len2) {
return len1 > len2? 1:-1;
} else {
int32_t ret = strncmp(varDataVal(pLeft), varDataVal(pRight), len1);
if (ret == 0) {
return 0;
} else {
return ret > 0 ? 1:-1;
}
}
} }
int32_t compareWStrVal(const void *pLeft, const void *pRight) { int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) {
// SSkipListKey *pL = (SSkipListKey *)pLeft; int32_t len1 = varDataLen(pLeft);
// SSkipListKey *pR = (SSkipListKey *)pRight; int32_t len2 = varDataLen(pRight);
//
// if (pL->nLen == 0 && pR->nLen == 0) { if (len1 != len2) {
// return 0; return len1 > len2? 1:-1;
// } } else {
// int32_t ret = wcsncmp(varDataVal(pLeft), varDataVal(pRight), len1);
// // handle only one-side bound compare situation, there is only lower bound or only upper bound if (ret == 0) {
// if (pL->nLen == -1) {
// return 1; // no lower bound, lower bound is minimum, always return -1;
// } else if (pR->nLen == -1) {
// return -1; // no upper bound, upper bound is maximum situation, always return 1;
// }
//
// int32_t ret = wcscmp(((SSkipListKey *)pLeft)->wpz, ((SSkipListKey *)pRight)->wpz);
//
// if (ret == 0) {
// return 0;
// } else {
// return ret > 0 ? 1 : -1;
// }
return 0; return 0;
} else {
return ret > 0 ? 1 : -1;
}
}
} }
/* /*
...@@ -124,7 +136,7 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat ...@@ -124,7 +136,7 @@ int patternMatch(const char *patterStr, const char *str, size_t size, const SPat
size_t n = strcspn(str, next); size_t n = strcspn(str, next);
str += n; str += n;
if (str[0] == 0 || (n >= size - 1)) { if (str[0] == 0 || (n >= size)) {
break; break;
} }
...@@ -172,10 +184,10 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c ...@@ -172,10 +184,10 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
wchar_t accept[3] = {towupper(c), towlower(c), 0}; wchar_t accept[3] = {towupper(c), towlower(c), 0};
while (1) { while (1) {
size_t n = wcsspn(str, accept); size_t n = wcscspn(str, accept);
str += n; str += n;
if (str[0] == 0 || (n >= size - 1)) { if (str[0] == 0 || (n >= size)) {
break; break;
} }
...@@ -254,7 +266,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { ...@@ -254,7 +266,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
} }
case TSDB_DATA_TYPE_FLOAT: { case TSDB_DATA_TYPE_FLOAT: {
comparFn = compareDoubleVal; break; comparFn = compareFloatVal; break;
} }
case TSDB_DATA_TYPE_DOUBLE: { case TSDB_DATA_TYPE_DOUBLE: {
...@@ -267,7 +279,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { ...@@ -267,7 +279,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
} else if (optr == TSDB_RELATION_IN) { } else if (optr == TSDB_RELATION_IN) {
comparFn = compareFindStrInArray; comparFn = compareFindStrInArray;
} else { /* normal relational comparFn */ } else { /* normal relational comparFn */
comparFn = compareStrVal; comparFn = compareLenPrefixedStr;
} }
break; break;
...@@ -277,7 +289,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) { ...@@ -277,7 +289,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
if (optr == TSDB_RELATION_LIKE) { if (optr == TSDB_RELATION_LIKE) {
comparFn = compareWStrPatternComp; comparFn = compareWStrPatternComp;
} else { } else {
comparFn = compareWStrVal; comparFn = compareLenPrefixedWStr;
} }
break; break;
...@@ -296,6 +308,7 @@ __compar_fn_t getKeyComparFunc(int32_t keyType) { ...@@ -296,6 +308,7 @@ __compar_fn_t getKeyComparFunc(int32_t keyType) {
switch (keyType) { switch (keyType) {
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
case TSDB_DATA_TYPE_BOOL:
comparFn = compareInt8Val; comparFn = compareInt8Val;
break; break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
...@@ -308,21 +321,19 @@ __compar_fn_t getKeyComparFunc(int32_t keyType) { ...@@ -308,21 +321,19 @@ __compar_fn_t getKeyComparFunc(int32_t keyType) {
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
comparFn = compareInt64Val; comparFn = compareInt64Val;
break; break;
case TSDB_DATA_TYPE_BOOL:
comparFn = compareInt32Val;
break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
comparFn = compareFloatVal;
break;
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
comparFn = compareDoubleVal; comparFn = compareDoubleVal;
break; break;
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
comparFn = compareStrVal; comparFn = compareLenPrefixedStr;
break; break;
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
comparFn = compareWStrVal; comparFn = compareLenPrefixedWStr;
break; break;
default: default:
...@@ -349,13 +360,20 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) { ...@@ -349,13 +360,20 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
} }
return (ret < 0) ? -1 : 1; return (ret < 0) ? -1 : 1;
} }
default: { default: { // todo refactor
int32_t ret = strncmp(f1, f2, (size_t)size); tstr* t1 = (tstr*) f1;
tstr* t2 = (tstr*) f2;
if (t1->len != t2->len) {
return t1->len > t2->len? 1:-1;
} else {
int32_t ret = strncmp(t1->data, t2->data, t1->len);
if (ret == 0) { if (ret == 0) {
return ret; return 0;
} else {
return ret < 0? -1:1;
}
} }
return (ret < 0) ? -1 : 1;
} }
} }
} }
...@@ -236,7 +236,7 @@ void taosReadGlobalLogCfg() { ...@@ -236,7 +236,7 @@ void taosReadGlobalLogCfg() {
int olen, vlen; int olen, vlen;
char fileName[PATH_MAX] = {0}; char fileName[PATH_MAX] = {0};
mdebugFlag = 135; mDebugFlag = 135;
sdbDebugFlag = 135; sdbDebugFlag = 135;
wordexp_t full_path; wordexp_t full_path;
......
...@@ -267,7 +267,7 @@ void vnodeRelease(void *pVnodeRaw) { ...@@ -267,7 +267,7 @@ void vnodeRelease(void *pVnodeRaw) {
assert(refCount >= 0); assert(refCount >= 0);
if (refCount > 0) { if (refCount > 0) {
vTrace("vgId:%d, release vnode, refCount:%d", pVnode, vgId, refCount); vTrace("vgId:%d, release vnode, refCount:%d", vgId, refCount);
return; return;
} }
...@@ -383,9 +383,8 @@ static int vnodeWalCallback(void *arg) { ...@@ -383,9 +383,8 @@ static int vnodeWalCallback(void *arg) {
} }
static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size) { static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size) {
// SVnodeObj *pVnode = ahandle; SVnodeObj *pVnode = ahandle;
//tsdbGetFileInfo(pVnode->tsdb, name, index, size); return tsdbGetFileInfo(pVnode->tsdb, name, index, size);
return 0;
} }
static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index) { static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index) {
...@@ -405,9 +404,9 @@ static void vnodeNotifyRole(void *ahandle, int8_t role) { ...@@ -405,9 +404,9 @@ static void vnodeNotifyRole(void *ahandle, int8_t role) {
static void vnodeNotifyFileSynced(void *ahandle) { static void vnodeNotifyFileSynced(void *ahandle) {
SVnodeObj *pVnode = ahandle; SVnodeObj *pVnode = ahandle;
vTrace("pVnode:%p vgId:%d, data file is synced", pVnode, pVnode->vgId); vTrace("vgId:%d, data file is synced", pVnode->vgId);
// clsoe tsdb, then open tsdb // close tsdb, then open tsdb
} }
static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) { static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg) {
...@@ -693,8 +692,9 @@ static bool vnodeReadVersion(SVnodeObj *pVnode) { ...@@ -693,8 +692,9 @@ static bool vnodeReadVersion(SVnodeObj *pVnode) {
sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId); sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId);
FILE *fp = fopen(versionFile, "r"); FILE *fp = fopen(versionFile, "r");
if (!fp) { if (!fp) {
vTrace("vgId:%d, failed to open version file:%s error:%s", pVnode->vgId, if (errno != ENOENT) {
versionFile, strerror(errno)); vError("vgId:%d, failed to open version file:%s error:%s", pVnode->vgId, versionFile, strerror(errno));
}
return false; return false;
} }
......
...@@ -65,7 +65,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont ...@@ -65,7 +65,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
pRet->len = sizeof(SQueryTableRsp); pRet->len = sizeof(SQueryTableRsp);
pRet->rsp = pRsp; pRet->rsp = pRsp;
vTrace("vgId:%d QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo); vTrace("vgId:%d, QInfo:%p, dnode query msg disposed", pVnode->vgId, pQInfo);
} else { } else {
pQInfo = pCont; pQInfo = pCont;
code = TSDB_CODE_ACTION_IN_PROGRESS; code = TSDB_CODE_ACTION_IN_PROGRESS;
...@@ -83,7 +83,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t cont ...@@ -83,7 +83,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
vTrace("vgId:%d QInfo:%p, retrieve msg is received", pVnode->vgId, pQInfo); vTrace("vgId:%d, QInfo:%p, retrieve msg is received", pVnode->vgId, pQInfo);
pRet->code = qRetrieveQueryResultInfo(pQInfo); pRet->code = qRetrieveQueryResultInfo(pQInfo);
if (pRet->code != TSDB_CODE_SUCCESS) { if (pRet->code != TSDB_CODE_SUCCESS) {
...@@ -104,6 +104,6 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t cont ...@@ -104,6 +104,6 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, void *pCont, int32_t cont
} }
} }
vTrace("vgId:%d QInfo:%p, retrieve msg is disposed", pVnode->vgId, pQInfo); vTrace("vgId:%d, QInfo:%p, retrieve msg is disposed", pVnode->vgId, pQInfo);
return code; return code;
} }
...@@ -51,10 +51,7 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { ...@@ -51,10 +51,7 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) {
if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL) if (vnodeProcessWriteMsgFp[pHead->msgType] == NULL)
return TSDB_CODE_MSG_NOT_PROCESSED; return TSDB_CODE_MSG_NOT_PROCESSED;
if (pVnode->status != TAOS_VN_STATUS_READY && qtype == TAOS_QTYPE_RPC) if (pHead->version == 0) { // from client or CQ
return TSDB_CODE_NOT_ACTIVE_VNODE;
if (pHead->version == 0) { // from client
if (pVnode->status != TAOS_VN_STATUS_READY) if (pVnode->status != TAOS_VN_STATUS_READY)
return TSDB_CODE_NOT_ACTIVE_VNODE; return TSDB_CODE_NOT_ACTIVE_VNODE;
...@@ -64,22 +61,24 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) { ...@@ -64,22 +61,24 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) {
// assign version // assign version
pVnode->version++; pVnode->version++;
pHead->version = pVnode->version; pHead->version = pVnode->version;
} else { } else { // from wal or forward
// for data from WAL or forward, version may be smaller // for data from WAL or forward, version may be smaller
if (pHead->version <= pVnode->version) return 0; if (pHead->version <= pVnode->version) return 0;
} }
// more status and role checking here
pVnode->version = pHead->version; pVnode->version = pHead->version;
// write into WAL // write into WAL
code = walWrite(pVnode->wal, pHead); code = walWrite(pVnode->wal, pHead);
if (code < 0) return code; if (code < 0) return code;
int32_t syncCode = syncForwardToPeer(pVnode->sync, pHead, item); // forward to peers if data is from RPC or CQ
int32_t syncCode = 0;
if (qtype == TAOS_QTYPE_RPC || qtype == TAOS_QTYPE_CQ)
syncCode = syncForwardToPeer(pVnode->sync, pHead, item);
if (syncCode < 0) return syncCode; if (syncCode < 0) return syncCode;
// write data locally
code = (*vnodeProcessWriteMsgFp[pHead->msgType])(pVnode, pHead->cont, item); code = (*vnodeProcessWriteMsgFp[pHead->msgType])(pVnode, pHead->cont, item);
if (code < 0) return code; if (code < 0) return code;
...@@ -239,7 +238,7 @@ static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, SRspRet ...@@ -239,7 +238,7 @@ static int32_t vnodeProcessDropStableMsg(SVnodeObj *pVnode, void *pCont, SRspRet
code = tsdbDropTable(pVnode->tsdb, stableId); code = tsdbDropTable(pVnode->tsdb, stableId);
vTrace("vgId:%d, stable:%s, drop stable result:%s", pVnode, pTable->tableId, tstrerror(code)); vTrace("vgId:%d, stable:%s, drop stable result:%s", pVnode->vgId, pTable->tableId, tstrerror(code));
return code; return code;
} }
......
...@@ -46,16 +46,16 @@ class TDTestCase: ...@@ -46,16 +46,16 @@ class TDTestCase:
self.maxrows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import %d sequential data" % (self.maxrows / 2)) tdLog.info("import %d sequential data" % (self.maxrows // 2))
startTime = self.startTime startTime = self.startTime
sqlcmd = ['import into tb1 values'] sqlcmd = ['import into tb1 values']
for rid in range(1, self.maxrows / 2 + 1): for rid in range(1, self.maxrows // 2 + 1):
sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) sqlcmd.append('(%ld, %d)' % (startTime + rid, rid))
tdSql.execute(" ".join(sqlcmd)) tdSql.execute(" ".join(sqlcmd))
tdLog.info("================= step3") tdLog.info("================= step3")
tdSql.query('select * from tb1') tdSql.query('select * from tb1')
tdSql.checkRows(self.maxrows / 2) tdSql.checkRows(self.maxrows // 2)
tdLog.info("================= step4") tdLog.info("================= step4")
tdDnodes.stop(1) tdDnodes.stop(1)
...@@ -70,7 +70,7 @@ class TDTestCase: ...@@ -70,7 +70,7 @@ class TDTestCase:
tdLog.info("================= step7") tdLog.info("================= step7")
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.query('select * from tb1 order by ts desc') tdSql.query('select * from tb1 order by ts desc')
tdSql.checkRows(self.maxrows / 2 + 1) tdSql.checkRows(self.maxrows // 2 + 1)
tdLog.info("================= step8") tdLog.info("================= step8")
tdLog.info("import 10 data in batch before") tdLog.info("import 10 data in batch before")
...@@ -83,7 +83,7 @@ class TDTestCase: ...@@ -83,7 +83,7 @@ class TDTestCase:
tdLog.info("================= step9") tdLog.info("================= step9")
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.query('select * from tb1 order by ts desc') tdSql.query('select * from tb1 order by ts desc')
tdSql.checkRows(self.maxrows / 2 + 11) tdSql.checkRows(self.maxrows // 2 + 11)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -46,16 +46,17 @@ class TDTestCase: ...@@ -46,16 +46,17 @@ class TDTestCase:
self.maxrows) self.maxrows)
tdLog.info("================= step2") tdLog.info("================= step2")
tdLog.info("import %d sequential data" % (self.maxrows / 2)) tdLog.info("import %d sequential data" % (self.maxrows // 2))
startTime = self.startTime startTime = self.startTime
sqlcmd = ['import into tb1 values'] sqlcmd = ['import into tb1 values']
for rid in range(1, self.maxrows / 2 + 1): for rid in range(1, self.maxrows // 2 + 1):
sqlcmd.append('(%ld, %d)' % (startTime + rid, rid)) sqlcmd.append('(%ld, %d)' % (startTime + rid, rid))
tdSql.execute(" ".join(sqlcmd)) tdSql.execute(" ".join(sqlcmd))
tdLog.info("================= step3") tdLog.info("================= step3")
tdSql.query('select * from tb1') tdSql.query('select * from tb1')
tdSql.checkRows(self.maxrows / 2) tdSql.checkRows(self.maxrows // 2)
tdLog.info("================= step4") tdLog.info("================= step4")
tdDnodes.stop(1) tdDnodes.stop(1)
...@@ -73,7 +74,7 @@ class TDTestCase: ...@@ -73,7 +74,7 @@ class TDTestCase:
tdLog.info("================= step9") tdLog.info("================= step9")
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.query('select * from tb1 order by ts desc') tdSql.query('select * from tb1 order by ts desc')
tdSql.checkRows(self.maxrows / 2) tdSql.checkRows(self.maxrows // 2)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
...@@ -33,7 +33,7 @@ class TDTestCase: ...@@ -33,7 +33,7 @@ class TDTestCase:
tdDnodes.start(1) tdDnodes.start(1)
tdSql.execute('reset query cache') tdSql.execute('reset query cache')
tdSql.execute('drop database if exists db') tdSql.execute('drop database if exists db')
tdSql.execute('create database db cache 512 tables 10') tdSql.execute('create database db cache 512 maxtables 10')
tdSql.execute('use db') tdSql.execute('use db')
tdLog.info("================= step1") tdLog.info("================= step1")
......
...@@ -29,88 +29,17 @@ python3 ./test.py $1 -s && sleep 1 ...@@ -29,88 +29,17 @@ python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f table/db_table.py python3 ./test.py $1 -f table/db_table.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataLastTO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataLastT.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataTO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataT.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHeadOverlap.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHeadPartOverlap.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHORestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHPORestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHRestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importLastSub.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1HO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1HPO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1H.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1S.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1Sub.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1TO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1TPO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock1T.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2HO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2HPO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2H.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2S.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2Sub.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2TO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2TPO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlock2T.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importBlockbetween.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importCacheFileSub.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importCacheFileTO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importCacheFileT.py python3 ./test.py $1 -f import_merge/importCacheFileT.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataLastSub.py python3 ./test.py $1 -f import_merge/importDataLastSub.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHead.py python3 ./test.py $1 -f import_merge/importHead.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importLastTO.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importLastT.py python3 ./test.py $1 -f import_merge/importLastT.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importSpan.py python3 ./test.py $1 -f import_merge/importSpan.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importSRestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importSubRestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTailOverlap.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTail.py python3 ./test.py $1 -f import_merge/importTail.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTORestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTPORestart.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTRestart.py python3 ./test.py $1 -f import_merge/importTRestart.py
python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -s && sleep 1
...@@ -201,8 +201,8 @@ class TDDnode: ...@@ -201,8 +201,8 @@ class TDDnode:
self.running = 1 self.running = 1
tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) tdLog.debug("dnode:%d is running with %s " % (self.index, cmd))
tdLog.debug("wait 2 seconds for the dnode:%d to start." % (self.index)) tdLog.debug("wait 4 seconds for the dnode:%d to start." % (self.index))
time.sleep(2) time.sleep(4)
def stop(self): def stop(self):
if self.valgrind == 0: if self.valgrind == 0:
......
#!/bin/bash
python3 ./test.py $1 -f insert/basic.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/int.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/float.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/bigint.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/bool.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/double.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/smallint.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/tinyint.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/binary.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/date.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f insert/nchar.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f table/column_name.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f table/column_num.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f table/db_table.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importCacheFileT.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importDataLastSub.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importHead.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importLastT.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importSpan.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTail.py
python3 ./test.py $1 -s && sleep 1
python3 ./test.py $1 -f import_merge/importTRestart.py
python3 ./test.py $1 -s && sleep 1
#################################
run general/cache/new_metrics.sim run general/cache/new_metrics.sim
run general/compress/compress.sim run general/compress/compress.sim
run general/compute/avg.sim run general/compute/avg.sim
run general/compute/bottom.sim
run general/compute/count.sim run general/compute/count.sim
run general/db/len.sim run general/db/len.sim
run general/db/basic4.sim run general/db/basic4.sim
run general/http/restful_insert.sim run general/http/restful_insert.sim
run general/import/basic.sim run general/import/basic.sim
run general/import/commit.sim run general/import/commit.sim
run general/insert/basic.sim
run general/insert/query_file_memory.sim run general/insert/query_file_memory.sim
run general/parser/binary_escapeCharacter.sim run general/parser/binary_escapeCharacter.sim
run general/parser/columnValue_bigint.sim run general/parser/columnValue_bigint.sim
run general/parser/select_from_cache_disk.sim run general/parser/select_from_cache_disk.sim
run general/table/autocreate.sim run general/table/autocreate.sim
run general/table/basic3.sim
run general/table/column_name.sim run general/table/column_name.sim
run general/table/int.sim run general/table/int.sim
run general/table/vgroup.sim run general/table/vgroup.sim
run general/user/basic1.sim run general/user/basic1.sim
run general/user/user_len.sim run general/user/pass_alter.sim
run general/vector/single.sim run general/vector/single.sim
run general/connection/connection.sim run general/connection/connection.sim
run general/user/authority.sim run general/user/authority.sim
##################################
...@@ -27,11 +27,15 @@ sql create table $tb using $mt tags( "1" ) ...@@ -27,11 +27,15 @@ sql create table $tb using $mt tags( "1" )
sql insert into $tb values (now, 1) sql insert into $tb values (now, 1)
sql select * from $tb sql select * from $tb
print ===>rows $rows, data $data01 #print ===>rows $rows, data $data01
if $rows != 1 then if $rows != 1 then
print expect 1, actual: $rows
return -1 return -1
endi endi
if $data01 != 1 then if $data01 != 1 then
print expect 1 actual: $data01
return -1 return -1
endi endi
...@@ -67,7 +71,9 @@ print ===>rows $rows, data $data01 ...@@ -67,7 +71,9 @@ print ===>rows $rows, data $data01
if $rows != 1 then if $rows != 1 then
return -1 return -1
endi endi
if $data01 != 1 then if $data01 != 1 then
print expect 1, actual $data01
return -1 return -1
endi endi
...@@ -80,6 +86,7 @@ if $data01 != 1 then ...@@ -80,6 +86,7 @@ if $data01 != 1 then
return -1 return -1
endi endi
if $data02 != 3 then if $data02 != 3 then
print expect 3 actual: $data02
return -1 return -1
endi endi
......
...@@ -81,7 +81,7 @@ sql_error select diff(c8) from $tb ...@@ -81,7 +81,7 @@ sql_error select diff(c8) from $tb
sql_error select diff(c9) from $tb sql_error select diff(c9) from $tb
sql_error select diff(ts) from $tb sql_error select diff(ts) from $tb
sql_error select diff(c1), diff(c2) from $tb sql_error select diff(c1), diff(c2) from $tb
sql_error select 2+diff(c1) from $tb #sql_error select 2+diff(c1) from $tb
sql_error select diff(c1+2) from $tb sql_error select diff(c1+2) from $tb
sql_error select diff(c1) from $tb where ts > 0 and ts < now + 100m interval(10m) sql_error select diff(c1) from $tb where ts > 0 and ts < now + 100m interval(10m)
sql_error select diff(c1) from $mt sql_error select diff(c1) from $mt
......
...@@ -26,6 +26,7 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4 ...@@ -26,6 +26,7 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
print ========= start dnodes print ========= start dnodes
sleep 2000
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
sql connect sql connect
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 10
system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 10 system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 10
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 10 system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 10
...@@ -36,7 +34,7 @@ while $i < 10 ...@@ -36,7 +34,7 @@ while $i < 10
sql create table $tb1 using st tags(1) sql create table $tb1 using st tags(1)
sql insert into $tb1 values(now, 1); sql insert into $tb1 values(now, 1);
$tb1 = $tb . 5 $tb1 = $tb . 4
sql create table $tb1 using st tags(1) sql create table $tb1 using st tags(1)
sql insert into $tb1 values(now, 1); sql insert into $tb1 values(now, 1);
...@@ -58,7 +56,7 @@ while $i < 10 ...@@ -58,7 +56,7 @@ while $i < 10
sql drop table st sql drop table st
sleep 1000 sleep 2000
print times $i print times $i
$i = $i + 1 $i = $i + 1
......
run general//db/basic.sim run general/db/basic.sim
run general/db/basic1.sim run general/db/basic1.sim
run general/db/basic2.sim run general/db/basic2.sim
run general/db/basic3.sim run general/db/basic3.sim
...@@ -13,3 +13,4 @@ run general/db/delete_writing2.sim ...@@ -13,3 +13,4 @@ run general/db/delete_writing2.sim
run general/db/len.sim run general/db/len.sim
run general/db/repeat.sim run general/db/repeat.sim
run general/db/tables.sim run general/db/tables.sim
run general/db/vnodes.sim
system sh/stop_dnodes.sh
$totalVnodes = 10
$maxTables = 4
$totalRows = $totalVnodes * $maxTables
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 0
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $maxTables
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v $totalVnodes
system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 100000
system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 100000
system sh/cfg.sh -n dnode1 -c maxShellConns -v 100000
system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 100000
print ========== prepare data
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql connect
sql create database db blocks 2 cache 1 maxTables $maxTables
sql use db
print ========== step1
sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int)
$x = 0
while $x < $totalRows
$tb = t . $x
sql create table $tb using mt tags( $x )
sql insert into $tb values (now, $x )
$x = $x + 1
endw
print ========== step2
sql select * from mt
if $rows != $totalRows then
return -1
endi
sql select count(*) from mt
if $data00 != $totalRows then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
...@@ -132,7 +132,9 @@ endi ...@@ -132,7 +132,9 @@ endi
print =============== step6 print =============== step6
sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol sql select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = 1 group by tgcol
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 print $data00 $data01 $data02 $data03 $data04 $data05 $data06
print $data10 $data11 $data12 $data13 $data14 $data15 $data16
if $data00 != 100 then if $data00 != 100 then
print expect 100, actual $data00
return -1 return -1
endi endi
......
...@@ -96,25 +96,25 @@ $ts1 = $ts0 + 1000 ...@@ -96,25 +96,25 @@ $ts1 = $ts0 + 1000
$ts2 = $ts0 + 2000 $ts2 = $ts0 + 2000
sql insert into tb_1 using $stb tags (-1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar') sql insert into tb_1 using $stb tags (-1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar')
sql select * from $stb sql select * from $stb
if $rows != 3 then if $rows != 5 then
return -1 return -1
endi endi
if $data19 != 涛思数据 then if $data09 != 涛思数据 then
return -1 return -1
endi endi
if $data11 != 1 then if $data01 != 1 then
return -1 return -1
endi endi
if $data22 != 2 then if $data42 != 2 then
return -2 return -2
endi endi
if $data23 != 2.00000 then if $data43 != 2.00000 then
return -1 return -1
endi endi
if $data25 != binar then if $data45 != binar then
return -1 return -1
endi endi
if $data29 != nchar then if $data49 != nchar then
return -1 return -1
endi endi
sql drop table tb_1 sql drop table tb_1
...@@ -127,22 +127,22 @@ sql select * from $stb ...@@ -127,22 +127,22 @@ sql select * from $stb
if $rows != 5 then if $rows != 5 then
return -1 return -1
endi endi
if $data19 != 涛思数据 then if $data09 != 涛思数据 then
return -1 return -1
endi endi
if $data11 != 1 then if $data01 != 1 then
return -1 return -1
endi endi
if $data22 != 2 then if $data42 != 2 then
return -2 return -2
endi endi
if $data23 != 2.00000 then if $data43 != 2.00000 then
return -1 return -1
endi endi
if $data25 != binar then if $data45 != binar then
return -1 return -1
endi endi
if $data29 != nchar then if $data49 != nchar then
return -1 return -1
endi endi
...@@ -154,13 +154,13 @@ sql show tables ...@@ -154,13 +154,13 @@ sql show tables
if $rows != 3 then if $rows != 3 then
return -1 return -1
endi endi
if $data00 != tb3 then if $data00 != tb1 then
return -1 return -1
endi endi
if $data10 != tb2 then if $data10 != tb2 then
return -1 return -1
endi endi
if $data20 != tb1 then if $data20 != tb3 then
return -1 return -1
endi endi
......
...@@ -43,9 +43,11 @@ if $data07 != 1 then ...@@ -43,9 +43,11 @@ if $data07 != 1 then
return -1 return -1
endi endi
if $data08 != BINARY then if $data08 != BINARY then
print expect BINARY actual: $data08
return -1 return -1
endi endi
if $data09 != NCHAR then if $data09 != NCHAR then
print expect NCHAR actual: $data09
return -1 return -1
endi endi
...@@ -194,8 +194,10 @@ sql reset query cache ...@@ -194,8 +194,10 @@ sql reset query cache
sql select * from $mt where tgcol = '1' sql select * from $mt where tgcol = '1'
step2: step2:
if $rows != 100 then if $rows != 100 then
print expect 100, actual: $rows
return -1 return -1
endi endi
sql select * from $mt where tgcol > '0' sql select * from $mt where tgcol > '0'
#print rows = $rows #print rows = $rows
if $rows != 100 then if $rows != 100 then
......
# run general/parser/alter.sim #run general/parser/alter.sim
# sleep 2000 #sleep 2000
# run general/parser/alter1.sim #run general/parser/alter1.sim
# sleep 2000 #sleep 2000
# run general/parser/alter_stable.sim #run general/parser/alter_stable.sim
# sleep 2000 #sleep 2000
# run general/parser/auto_create_tb.sim #run general/parser/auto_create_tb.sim
# sleep 2000 #sleep 2000
# run general/parser/auto_create_tb_drop_tb.sim #run general/parser/auto_create_tb_drop_tb.sim
# sleep 2000
run general/parser/binary_escapeCharacter.sim
sleep 2000
run general/parser/bug.sim
sleep 2000 sleep 2000
run general/parser/col_arithmetic_operation.sim run general/parser/col_arithmetic_operation.sim
sleep 2000 sleep 2000
run general/parser/columnValue_bigint.sim run general/parser/columnValue.sim
sleep 2000
run general/parser/commit.sim
sleep 2000
run general/parser/create_db.sim
sleep 2000
run general/parser/create_mt.sim
sleep 2000
run general/parser/create_tb.sim
sleep 2000 sleep 2000
run general/parser/columnValue_bool.sim run general/parser/dbtbnameValidate.sim
sleep 2000 sleep 2000
run general/parser/columnValue_double.sim run general/parser/import_commit1.sim
sleep 2000 sleep 2000
run general/parser/columnValue_float.sim run general/parser/import_commit2.sim
sleep 2000 sleep 2000
run general/parser/columnValue_int.sim run general/parser/import_commit3.sim
sleep 2000 sleep 2000
run general/parser/insert_tb.sim
sleep 2000
run general/parser/first_last.sim
sleep 2000
run general/parser/import_file.sim
sleep 2000
run general/parser/lastrow.sim
sleep 2000
run general/parser/nchar.sim
# sleep 2000 sleep 2000
# run general/parser/col_arithmetic_operation.sim run general/parser/null_char.sim
# sleep 2000 sleep 2000
# run general/parser/columnValue.sim run general/parser/single_row_in_tb.sim
# sleep 2000 sleep 2000
# run general/parser/commit.sim
# run general/parser/create_db.sim
# sleep 2000
# run general/parser/create_mt.sim
# sleep 2000
# run general/parser/create_tb.sim
# sleep 2000
# run general/parser/dbtbnameValidate.sim
# sleep 2000
# run general/parser/fill.sim
# sleep 2000
# run general/parser/fill_stb.sim
# sleep 2000
# run general/parser/first_last.sim
# sleep 2000
# run general/parser/import_commit1.sim
# sleep 2000
# run general/parser/import_commit2.sim
# sleep 2000
# run general/parser/import_commit3.sim
# sleep 2000
# run general/parser/import_file.sim
# sleep 2000
# run general/parser/insert_tb.sim
# sleep 2000
# run general/parser/tags_dynamically_specifiy.sim
# sleep 2000
# run general/parser/interp.sim
# run general/parser/lastrow.sim
# sleep 2000
# run general/parser/limit.sim
# sleep 2000
# run general/parser/limit1.sim
# sleep 2000
# run general/parser/limit1_tblocks100.sim
# sleep 2000
# run general/parser/limit2.sim
# sleep 2000
# run general/parser/mixed_blocks.sim
# sleep 2000
# run general/parser/nchar.sim
# sleep 2000
# run general/parser/null_char.sim
# sleep 2000
# run general/parser/selectResNum.sim
# sleep 2000
# run general/parser/select_across_vnodes.sim
# sleep 2000
run general/parser/select_from_cache_disk.sim run general/parser/select_from_cache_disk.sim
sleep 2000 sleep 2000
# run general/parser/set_tag_vals.sim run general/parser/limit.sim
# sleep 2000
# run general/parser/single_row_in_tb.sim sleep 2000
# sleep 2000 run general/parser/fill.sim
# run general/parser/slimit.sim sleep 2000
# sleep 2000 run general/parser/fill_stb.sim
sleep 2000
run general/parser/tags_dynamically_specifiy.sim
sleep 2000
run general/parser/interp.sim
sleep 2000
run general/parser/limit1.sim
sleep 2000
run general/parser/limit1_tblocks100.sim
sleep 2000
run general/parser/limit2.sim
sleep 2000
run general/parser/mixed_blocks.sim
sleep 2000
run general/parser/selectResNum.sim
sleep 2000
run general/parser/select_across_vnodes.sim
sleep 2000
run general/parser/set_tag_vals.sim
sleep 2000
run general/parser/slimit.sim
sleep 2000
run general/parser/slimit1.sim run general/parser/slimit1.sim
sleep 2000 sleep 2000
run general/parser/slimit1_query.sim run general/parser/slimit_alter_tags.sim
sleep 2000 sleep 2000
# run general/parser/slimit_alter_tags.sim run general/parser/stream_on_sys.sim
# sleep 2000 sleep 2000
# run general/parser/stream_on_sys.sim run general/parser/stream.sim
# sleep 2000 sleep 2000
# run general/parser/stream.sim run general/parser/tbnameIn.sim
# sleep 2000 sleep 2000
# run general/parser/tbnameIn.sim run general/parser/where.sim
# sleep 2000 sleep 2000
# run general/parser/where.sim #run general/parser/repeatAlter.sim
# sleep 2000 sleep 2000
# #run general/parser/repeatAlter.sim #run general/parser/repeatStream.sim
# sleep 2000 sleep 2000
# #run general/parser/repeatStream.sim run general/parser/join.sim
# sleep 2000 sleep 2000
# run general/parser/join.sim run general/parser/join_multivnode.sim
# run general/parser/join_multivnode.sim sleep 2000
# run general/parser/projection_limit_offset.sim run general/parser/projection_limit_offset.sim
# sleep 2000 sleep 2000
# run general/parser/select_with_tags.sim run general/parser/select_with_tags.sim
# run general/parser/groupby.sim sleep 2000
run general/parser/groupby.sim
...@@ -42,7 +42,7 @@ sql select count(*), last(ts), min(k), max(k), avg(k) from db.mt where a=0 and t ...@@ -42,7 +42,7 @@ sql select count(*), last(ts), min(k), max(k), avg(k) from db.mt where a=0 and t
print =================== step2 print =================== step2
system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 10000 sleep 5000
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 3000 sleep 3000
......
...@@ -123,6 +123,7 @@ if $rows != 100 then ...@@ -123,6 +123,7 @@ if $rows != 100 then
endi endi
sql select * from $mt where tgcol = 1 sql select * from $mt where tgcol = 1
if $rows != 100 then if $rows != 100 then
print expect 100, actual:$rows
return -1 return -1
endi endi
sql select * from $mt where tgcol <> 1 sql select * from $mt where tgcol <> 1
......
...@@ -135,6 +135,7 @@ if $data01 != 1 then ...@@ -135,6 +135,7 @@ if $data01 != 1 then
endi endi
sql select * from $mt where tgcol = 0 sql select * from $mt where tgcol = 0
if $rows != 0 then if $rows != 0 then
print expect 0, actual: $rows
return -1 return -1
endi endi
...@@ -185,6 +186,7 @@ sql create table $tb using $mt tags( 1, 2 ) ...@@ -185,6 +186,7 @@ sql create table $tb using $mt tags( 1, 2 )
sql insert into $tb values(now, 1) sql insert into $tb values(now, 1)
sql select * from $mt where tgcol2 = 2 sql select * from $mt where tgcol2 = 2
if $rows != 1 then if $rows != 1 then
print expect 1, actual: $rows
return -1 return -1
endi endi
if $data01 != 1 then if $data01 != 1 then
......
...@@ -123,6 +123,7 @@ print =============== step14 ...@@ -123,6 +123,7 @@ print =============== step14
sql select count(tbcol) as c from $mt where ts > 1000 group by tgcol sql select count(tbcol) as c from $mt where ts > 1000 group by tgcol
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 print $data00 $data01 $data02 $data03 $data04 $data05 $data06
if $data00 != 100 then if $data00 != 100 then
print expect 100, actual $data00
return -1 return -1
endi endi
......
...@@ -19,28 +19,47 @@ endi ...@@ -19,28 +19,47 @@ endi
print ============= step2 print ============= step2
sql close sql close
sleep 2500
print user read login
sql connect read sql connect read
sleep 2000
sql alter user read pass 'taosdata' sql alter user read pass 'taosdata'
sql alter user write pass 'taosdata1' -x step2 sql alter user write pass 'taosdata1' -x step2
return -1 return -1
step2: step2:
sql_error create user read pass 'taosdata1'
sql_error create user write pass 'taosdata1'
sql show users
if $rows != 5 then
return -1
endi
print ============= step3 print ============= step3
sql close sql close
sleep 2500
print user write login
sql connect write sql connect write
sleep 2000
sql_error create user read pass 'taosdata1'
sql_error create user write pass 'taosdata1'
sql alter user write pass 'taosdata' sql alter user write pass 'taosdata'
sql alter user read pass 'taosdata' -x step3 sql alter user read pass 'taosdata' -x step3
return -1 return -1
step3: step3:
sql show users
if $rows != 5 then
return -1
endi
print ============= step4 print ============= step4
sql close sql close
sleep 2500
print root write login
sql connect sql connect
sleep 2000
sql create user oroot pass 'taosdata' sql create user oroot pass 'taosdata'
sql show users sql show users
if $rows != 6 then if $rows != 6 then
return -1 return -1
......
cd ../../debug; cmake .. cd ../../debug; cmake ..
#cd ../../debug; make clean
cd ../../debug; make cd ../../debug; make
cd ../../../debug; cmake .. cd ../../../debug; cmake ..
#cd ../../../debug; make clean
cd ../../../debug; make cd ../../../debug; make
#./test.sh -f general/alter/cached_schema_after_alter.sim #./test.sh -f general/alter/cached_schema_after_alter.sim
...@@ -15,12 +12,12 @@ cd ../../../debug; make ...@@ -15,12 +12,12 @@ cd ../../../debug; make
#./test.sh -f general/alter/table.sim #./test.sh -f general/alter/table.sim
./test.sh -f general/cache/new_metrics.sim ./test.sh -f general/cache/new_metrics.sim
#./test.sh -f general/cache/restart_metrics.sim ./test.sh -f general/cache/restart_metrics.sim
./test.sh -f general/cache/restart_table.sim ./test.sh -f general/cache/restart_table.sim
#./test.sh -f general/column/commit.sim #hongze ./test.sh -f general/column/commit.sim
#./test.sh -f general/column/metrics.sim #hongze ./test.sh -f general/column/metrics.sim
#./test.sh -f general/column/table.sim #hongze ./test.sh -f general/column/table.sim
./test.sh -f general/compress/commitlog.sim ./test.sh -f general/compress/commitlog.sim
./test.sh -f general/compress/compress.sim ./test.sh -f general/compress/compress.sim
...@@ -31,11 +28,11 @@ cd ../../../debug; make ...@@ -31,11 +28,11 @@ cd ../../../debug; make
./test.sh -f general/compute/bottom.sim ./test.sh -f general/compute/bottom.sim
./test.sh -f general/compute/count.sim ./test.sh -f general/compute/count.sim
./test.sh -f general/compute/diff.sim ./test.sh -f general/compute/diff.sim
#./test.sh -f general/compute/diff2.sim # liao./test.sh -f general/compute/diff2.sim
./test.sh -f general/compute/first.sim ./test.sh -f general/compute/first.sim
#./test.sh -f general/compute/interval.sim # liao./test.sh -f general/compute/interval.sim
#./test.sh -f general/compute/last.sim # liao./test.sh -f general/compute/last.sim
#./test.sh -f general/compute/leastsquare.sim # liao./test.sh -f general/compute/leastsquare.sim
./test.sh -f general/compute/max.sim ./test.sh -f general/compute/max.sim
./test.sh -f general/compute/min.sim ./test.sh -f general/compute/min.sim
./test.sh -f general/compute/null.sim ./test.sh -f general/compute/null.sim
...@@ -53,41 +50,42 @@ cd ../../../debug; make ...@@ -53,41 +50,42 @@ cd ../../../debug; make
./test.sh -f general/db/delete_reuse1.sim ./test.sh -f general/db/delete_reuse1.sim
./test.sh -f general/db/delete_reuse2.sim ./test.sh -f general/db/delete_reuse2.sim
./test.sh -f general/db/delete_reusevnode.sim ./test.sh -f general/db/delete_reusevnode.sim
#./test.sh -f general/db/delete_reusevnode2.sim ./test.sh -f general/db/delete_reusevnode2.sim
./test.sh -f general/db/delete_writing1.sim ./test.sh -f general/db/delete_writing1.sim
./test.sh -f general/db/delete_writing2.sim ./test.sh -f general/db/delete_writing2.sim
./test.sh -f general/db/len.sim ./test.sh -f general/db/len.sim
#./test.sh -u -f general/db/vnodes.sim
./test.sh -f general/db/repeat.sim ./test.sh -f general/db/repeat.sim
./test.sh -f general/db/tables.sim ./test.sh -f general/db/tables.sim
#./test.sh -f general/field/2.sim ./test.sh -f general/field/2.sim
#./test.sh -f general/field/3.sim #./test.sh -f general/field/3.sim
#./test.sh -f general/field/4.sim #./test.sh -f general/field/4.sim
#./test.sh -f general/field/5.sim #./test.sh -f general/field/5.sim
#./test.sh -f general/field/6.sim #./test.sh -f general/field/6.sim
##./test.sh -f general/field/bigint.sim ./test.sh -f general/field/bigint.sim
#./test.sh -f general/field/binary.sim # liao./test.sh -f general/field/binary.sim
##./test.sh -f general/field/bool.sim ./test.sh -f general/field/bool.sim
#./test.sh -f general/field/single.sim ./test.sh -f general/field/single.sim
##./test.sh -f general/field/smallint.sim ./test.sh -f general/field/smallint.sim
##./test.sh -f general/field/tinyint.sim ./test.sh -f general/field/tinyint.sim
##./test.sh -f general/http/restful.sim # jeff ./test.sh -f general/http/restful.sim
./test.sh -f general/http/restful_insert.sim ./test.sh -f general/http/restful_insert.sim
./test.sh -f general/http/restful_limit.sim ./test.sh -f general/http/restful_limit.sim
##./test.sh -f general/http/restful_full.sim # jeff ./test.sh -f general/http/restful_full.sim
./test.sh -f general/http/prepare.sim ./test.sh -f general/http/prepare.sim
./test.sh -f general/http/telegraf.sim ./test.sh -f general/http/telegraf.sim
./test.sh -f general/http/grafana_bug.sim ./test.sh -f general/http/grafana_bug.sim
#./test.sh -f general/http/grafana.sim # jeff ./test.sh -f general/http/grafana.sim
./test.sh -f general/import/basic.sim ./test.sh -f general/import/basic.sim
./test.sh -f general/import/commit.sim ./test.sh -f general/import/commit.sim
./test.sh -f general/import/large.sim ./test.sh -f general/import/large.sim
#./test.sh -f general/import/replica1.sim #hongze ./test.sh -f general/import/replica1.sim
./test.sh -f general/insert/basic.sim ./test.sh -f general/insert/basic.sim
#./test.sh -f general/insert/insert_drop.sim #hongze ./test.sh -f general/insert/insert_drop.sim
./test.sh -f general/insert/query_block1_memory.sim ./test.sh -f general/insert/query_block1_memory.sim
./test.sh -f general/insert/query_block2_memory.sim ./test.sh -f general/insert/query_block2_memory.sim
./test.sh -f general/insert/query_block1_file.sim ./test.sh -f general/insert/query_block1_file.sim
...@@ -96,8 +94,6 @@ cd ../../../debug; make ...@@ -96,8 +94,6 @@ cd ../../../debug; make
./test.sh -f general/insert/query_multi_file.sim ./test.sh -f general/insert/query_multi_file.sim
./test.sh -f general/insert/tcp.sim ./test.sh -f general/insert/tcp.sim
#parser
# ./test.sh -f general/parser/alter.sim # ./test.sh -f general/parser/alter.sim
# ./test.sh -f general/parser/alter1.sim # ./test.sh -f general/parser/alter1.sim
# ./test.sh -f general/parser/alter_stable.sim # ./test.sh -f general/parser/alter_stable.sim
...@@ -112,8 +108,8 @@ cd ../../../debug; make ...@@ -112,8 +108,8 @@ cd ../../../debug; make
./test.sh -f general/parser/columnValue_float.sim ./test.sh -f general/parser/columnValue_float.sim
./test.sh -f general/parser/columnValue_int.sim ./test.sh -f general/parser/columnValue_int.sim
# ./test.sh -f general/parser/col_arithmetic_operation.sim # ./test.sh -f general/parser/col_arithmetic_operation.sim
# ./test.sh -f general/parser/columnValue.sim ./test.sh -f general/parser/columnValue.sim
# ./test.sh -f general/parser/commit.sim ./test.sh -f general/parser/commit.sim
# ./test.sh -f general/parser/create_db.sim # ./test.sh -f general/parser/create_db.sim
# ./test.sh -f general/parser/create_mt.sim # ./test.sh -f general/parser/create_mt.sim
# ./test.sh -f general/parser/create_tb.sim # ./test.sh -f general/parser/create_tb.sim
...@@ -121,9 +117,9 @@ cd ../../../debug; make ...@@ -121,9 +117,9 @@ cd ../../../debug; make
# ./test.sh -f general/parser/fill.sim # ./test.sh -f general/parser/fill.sim
# ./test.sh -f general/parser/fill_stb.sim # ./test.sh -f general/parser/fill_stb.sim
# ./test.sh -f general/parser/first_last.sim # ./test.sh -f general/parser/first_last.sim
# ./test.sh -f general/parser/import_commit1.sim ./test.sh -f general/parser/import_commit1.sim
# ./test.sh -f general/parser/import_commit2.sim ./test.sh -f general/parser/import_commit2.sim
# ./test.sh -f general/parser/import_commit3.sim ./test.sh -f general/parser/import_commit3.sim
# ./test.sh -f general/parser/import_file.sim # ./test.sh -f general/parser/import_file.sim
# ./test.sh -f general/parser/insert_tb.sim # ./test.sh -f general/parser/insert_tb.sim
# ./test.sh -f general/parser/tags_dynamically_specifiy.sim # ./test.sh -f general/parser/tags_dynamically_specifiy.sim
...@@ -160,14 +156,12 @@ cd ../../../debug; make ...@@ -160,14 +156,12 @@ cd ../../../debug; make
#./test.sh -f general/stable/disk.sim #./test.sh -f general/stable/disk.sim
#./test.sh -f general/stable/metrics.sim #./test.sh -f general/stable/metrics.sim
#./test.sh -f general/stable/values.sim #./test.sh -f general/stable/values.sim
#./test.sh -f general/stable/vnode3.sim ./test.sh -f general/stable/vnode3.sim
#stream
./test.sh -f general/table/autocreate.sim ./test.sh -f general/table/autocreate.sim
./test.sh -f general/table/basic1.sim ./test.sh -f general/table/basic1.sim
./test.sh -f general/table/basic2.sim ./test.sh -f general/table/basic2.sim
./test.sh -f general/table/basic3.sim #hongze ./test.sh -f general/table/basic3.sim
./test.sh -f general/table/bigint.sim ./test.sh -f general/table/bigint.sim
./test.sh -f general/table/binary.sim ./test.sh -f general/table/binary.sim
./test.sh -f general/table/bool.sim ./test.sh -f general/table/bool.sim
...@@ -177,17 +171,17 @@ cd ../../../debug; make ...@@ -177,17 +171,17 @@ cd ../../../debug; make
./test.sh -f general/table/column2.sim ./test.sh -f general/table/column2.sim
./test.sh -f general/table/date.sim ./test.sh -f general/table/date.sim
./test.sh -f general/table/db.table.sim ./test.sh -f general/table/db.table.sim
#./test.sh -f general/table/delete_reuse1.sim ./test.sh -f general/table/delete_reuse1.sim
#./test.sh -f general/table/delete_reuse2.sim ./test.sh -f general/table/delete_reuse2.sim
#./test.sh -f general/table/delete_writing.sim #hongze ./test.sh -f general/table/delete_writing.sim
#./test.sh -f general/table/describe.sim ./test.sh -f general/table/describe.sim
./test.sh -f general/table/double.sim ./test.sh -f general/table/double.sim
#./test.sh -f general/table/fill.sim ./test.sh -f general/table/fill.sim
./test.sh -f general/table/float.sim ./test.sh -f general/table/float.sim
./test.sh -f general/table/int.sim ./test.sh -f general/table/int.sim
./test.sh -f general/table/limit.sim ./test.sh -f general/table/limit.sim
./test.sh -f general/table/smallint.sim ./test.sh -f general/table/smallint.sim
#./test.sh -f general/table/table_len.sim ./test.sh -f general/table/table_len.sim
./test.sh -f general/table/table.sim ./test.sh -f general/table/table.sim
./test.sh -f general/table/tinyint.sim ./test.sh -f general/table/tinyint.sim
./test.sh -f general/table/vgroup.sim ./test.sh -f general/table/vgroup.sim
...@@ -197,63 +191,61 @@ cd ../../../debug; make ...@@ -197,63 +191,61 @@ cd ../../../debug; make
#./test.sh -f general/tag/5.sim #./test.sh -f general/tag/5.sim
#./test.sh -f general/tag/6.sim #./test.sh -f general/tag/6.sim
#./test.sh -f general/tag/add.sim #./test.sh -f general/tag/add.sim
#./test.sh -f general/tag/bigint.sim ./test.sh -f general/tag/bigint.sim
#./test.sh -f general/tag/binary_binary.sim #./test.sh -f general/tag/binary_binary.sim
#./test.sh -f general/tag/binary.sim #./test.sh -f general/tag/binary.sim
#./test.sh -f general/tag/bool_binary.sim #./test.sh -f general/tag/bool_binary.sim
#./test.sh -f general/tag/bool_int.sim #./test.sh -f general/tag/bool_int.sim
#./test.sh -f general/tag/bool.sim ./test.sh -f general/tag/bool.sim
#./test.sh -f general/tag/change.sim #./test.sh -f general/tag/change.sim
#./test.sh -f general/tag/column.sim #liao ./test.sh -f general/tag/column.sim
#./test.sh -f general/tag/commit.sim #./test.sh -f general/tag/commit.sim
#./test.sh -f general/tag/create.sim #liao ./test.sh -f general/tag/create.sim
#./test.sh -f general/tag/delete.sim #./test.sh -f general/tag/delete.sim
#./test.sh -f general/tag/double.sim #./test.sh -f general/tag/double.sim
#./test.sh -f general/tag/filter.sim ./test.sh -f general/tag/filter.sim
#./test.sh -f general/tag/float.sim #./test.sh -f general/tag/float.sim
#./test.sh -f general/tag/int_binary.sim #./test.sh -f general/tag/int_binary.sim
#./test.sh -f general/tag/int_float.sim #./test.sh -f general/tag/int_float.sim
#./test.sh -f general/tag/int.sim ./test.sh -f general/tag/int.sim
#./test.sh -f general/tag/set.sim #./test.sh -f general/tag/set.sim
#./test.sh -f general/tag/smallint.sim ./test.sh -f general/tag/smallint.sim
#./test.sh -f general/tag/tinyint.sim ./test.sh -f general/tag/tinyint.sim
./test.sh -f general/user/basic1.sim ./test.sh -f general/user/basic1.sim
#./test.sh -f general/user/monitor.sim ./test.sh -f general/user/monitor.sim
##./test.sh -f general/user/pass_alter.sim ./test.sh -f general/user/pass_alter.sim
./test.sh -f general/user/pass_len.sim ./test.sh -f general/user/pass_len.sim
##./test.sh -f general/user/user_create.sim ./test.sh -f general/user/user_create.sim
./test.sh -f general/user/user_len.sim ./test.sh -f general/user/user_len.sim
#./test.sh -f general/vector/metrics_field.sim ./test.sh -f general/vector/metrics_field.sim
#./test.sh -f general/vector/metrics_mix.sim ./test.sh -f general/vector/metrics_mix.sim
#./test.sh -f general/vector/metrics_query.sim ./test.sh -f general/vector/metrics_query.sim
#./test.sh -f general/vector/metrics_tag.sim ./test.sh -f general/vector/metrics_tag.sim
#./test.sh -f general/vector/metrics_time.sim ./test.sh -f general/vector/metrics_time.sim
#./test.sh -f general/vector/multi.sim #liao ./test.sh -f general/vector/multi.sim
./test.sh -f general/vector/single.sim ./test.sh -f general/vector/single.sim
#./test.sh -f general/vector/table_field.sim ./test.sh -f general/vector/table_field.sim
#./test.sh -f general/vector/table_mix.sim ./test.sh -f general/vector/table_mix.sim
#./test.sh -f general/vector/table_query.sim ./test.sh -f general/vector/table_query.sim
#./test.sh -f general/vector/table_time.sim ./test.sh -f general/vector/table_time.sim
#################################
./test.sh -u -f unique/account/account_create.sim ./test.sh -u -f unique/account/account_create.sim
##./test.sh -u -f unique/account/account_delete.sim ./test.sh -u -f unique/account/account_delete.sim
./test.sh -u -f unique/account/account_len.sim ./test.sh -u -f unique/account/account_len.sim
##./test.sh -u -f unique/account/authority.sim ./test.sh -u -f unique/account/authority.sim
./test.sh -u -f unique/account/basic.sim ./test.sh -u -f unique/account/basic.sim
./test.sh -u -f unique/account/paras.sim ./test.sh -u -f unique/account/paras.sim
##./test.sh -u -f unique/account/pass_alter.sim ./test.sh -u -f unique/account/pass_alter.sim
./test.sh -u -f unique/account/pass_len.sim ./test.sh -u -f unique/account/pass_len.sim
./test.sh -u -f unique/account/usage.sim ./test.sh -u -f unique/account/usage.sim
##./test.sh -u -f unique/account/user_create.sim ./test.sh -u -f unique/account/user_create.sim
./test.sh -u -f unique/account/user_len.sim ./test.sh -u -f unique/account/user_len.sim
#./test.sh -u -f unique/big/balance.sim #./test.sh -u -f unique/big/balance.sim
#./test.sh -u -f unique/big/maxvnodes.sim #slguan ./test.sh -u -f unique/big/maxvnodes.sim
#./test.sh -u -f unique/big/tcp.sim ./test.sh -u -f unique/big/tcp.sim
##./test.sh -u -f unique/cluster/balance1.sim ##./test.sh -u -f unique/cluster/balance1.sim
##./test.sh -u -f unique/cluster/balance2.sim ##./test.sh -u -f unique/cluster/balance2.sim
...@@ -298,27 +290,22 @@ cd ../../../debug; make ...@@ -298,27 +290,22 @@ cd ../../../debug; make
#./test.sh -u -f unique/metrics/replica3_dnode6.sim #./test.sh -u -f unique/metrics/replica3_dnode6.sim
#./test.sh -u -f unique/metrics/replica3_vnode3.sim #./test.sh -u -f unique/metrics/replica3_vnode3.sim
##./test.sh -u -f unique/mnode/mgmt22.sim ./test.sh -u -f unique/mnode/mgmt22.sim
##./test.sh -u -f unique/mnode/mgmt23.sim ./test.sh -u -f unique/mnode/mgmt23.sim
##./test.sh -u -f unique/mnode/mgmt24.sim ./test.sh -u -f unique/mnode/mgmt24.sim
##./test.sh -u -f unique/mnode/mgmt25.sim ./test.sh -u -f unique/mnode/mgmt25.sim
##./test.sh -u -f unique/mnode/mgmt26.sim ./test.sh -u -f unique/mnode/mgmt26.sim
##./test.sh -u -f unique/mnode/mgmt33.sim ./test.sh -u -f unique/mnode/mgmt33.sim
##./test.sh -u -f unique/mnode/mgmt34.sim ./test.sh -u -f unique/mnode/mgmt34.sim
#./test.sh -u -f unique/mnode/mgmtr2.sim #./test.sh -u -f unique/mnode/mgmtr2.sim
#./test.sh -u -f unique/mnode/secondIp.sim #./test.sh -u -f unique/mnode/secondIp.sim
#stream
##./test.sh -u -f unique/table/delete_part.sim ##./test.sh -u -f unique/table/delete_part.sim
##./test.sh -u -f unique/vnode/replica2_basic2.sim
##./test.sh -u -f unique/vnode/replica3_basic.sim
#./test.sh -u -f unique/vnode/commit.sim #./test.sh -u -f unique/vnode/commit.sim
#./test.sh -u -f unique/vnode/many.sim #./test.sh -u -f unique/vnode/many.sim
#./test.sh -u -f unique/vnode/replica2_basic.sim #./test.sh -u -f unique/vnode/replica2_basic.sim
##./test.sh -u -f unique/vnode/replica2_basic2.sim ./test.sh -u -f unique/vnode/replica2_basic2.sim
#./test.sh -u -f unique/vnode/replica2_repeat.sim #./test.sh -u -f unique/vnode/replica2_repeat.sim
##./test.sh -u -f unique/vnode/replica3_basic.sim ##./test.sh -u -f unique/vnode/replica3_basic.sim
#./test.sh -u -f unique/vnode/replica3_repeat.sim #./test.sh -u -f unique/vnode/replica3_repeat.sim
......
...@@ -99,7 +99,7 @@ echo "logDir $LOG_DIR" >> $TAOS_CFG ...@@ -99,7 +99,7 @@ echo "logDir $LOG_DIR" >> $TAOS_CFG
echo "dDebugFlag 199" >> $TAOS_CFG echo "dDebugFlag 199" >> $TAOS_CFG
echo "mDebugFlag 199" >> $TAOS_CFG echo "mDebugFlag 199" >> $TAOS_CFG
echo "sdbDebugFlag 199" >> $TAOS_CFG echo "sdbDebugFlag 199" >> $TAOS_CFG
echo "rpcDebugFlag 135" >> $TAOS_CFG echo "rpcDebugFlag 151" >> $TAOS_CFG
echo "tmrDebugFlag 131" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG
echo "cDebugFlag 135" >> $TAOS_CFG echo "cDebugFlag 135" >> $TAOS_CFG
echo "httpDebugFlag 135" >> $TAOS_CFG echo "httpDebugFlag 135" >> $TAOS_CFG
......
...@@ -99,7 +99,8 @@ echo "cDebugFlag 135" >> $TAOS_CFG ...@@ -99,7 +99,8 @@ echo "cDebugFlag 135" >> $TAOS_CFG
echo "httpDebugFlag 135" >> $TAOS_CFG echo "httpDebugFlag 135" >> $TAOS_CFG
echo "monitorDebugFlag 135" >> $TAOS_CFG echo "monitorDebugFlag 135" >> $TAOS_CFG
echo "udebugFlag 135" >> $TAOS_CFG echo "udebugFlag 135" >> $TAOS_CFG
echo "clog 0" >> $TAOS_CFG echo "tablemetakeeptimer 5" >> $TAOS_CFG
echo "wal 0" >> $TAOS_CFG
echo "asyncLog 0" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG
echo "locale en_US.UTF-8" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG
echo " " >> $TAOS_CFG echo " " >> $TAOS_CFG
......
...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1 ...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000 sleep 3000
sql connect
print ============================ dnode1 start print ============================ dnode1 start
......
...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1 ...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000 sleep 3000
sql connect
print ============= step1 print ============= step1
sql create account oroot pass 'taosdata' sql create account oroot pass 'taosdata'
......
...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1 ...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000 sleep 3000
sql connect
$i = 0 $i = 0
$dbPrefix = aldb $dbPrefix = aldb
......
...@@ -4,8 +4,8 @@ system sh/cfg.sh -n dnode1 -c wallevel -v 0 ...@@ -4,8 +4,8 @@ system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000 sleep 3000
sql connect
print ============= step1 print ============= step1
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sleep 3000
sql connect sql connect
print =============== show accounts print =============== show accounts
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sleep 3000
sql connect sql connect
print =============== show accounts print =============== show accounts
......
...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1 ...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000 sleep 3000
sql connect
print ============= step1 print ============= step1
sql create user read pass 'taosdata1' sql create user read pass 'taosdata1'
......
...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1 ...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000 sleep 3000
sql connect
$i = 0 $i = 0
$dbPrefix = apdb $dbPrefix = apdb
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sleep 3000
sql connect sql connect
print =============== show accounts print =============== show accounts
......
...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1 ...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000 sleep 3000
sql connect
print =============== step1 print =============== step1
sql show users sql show users
......
...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1 ...@@ -3,8 +3,8 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0 system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000 sleep 3000
sql connect
$i = 0 $i = 0
$dbPrefix = lm_us_db $dbPrefix = lm_us_db
......
...@@ -20,7 +20,7 @@ system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4 ...@@ -20,7 +20,7 @@ system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 1000 system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 1000
print =============== prepare data print =============== prepare data
system sh/exec.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sleep 3000 sleep 3000
sql connect sql connect
...@@ -87,7 +87,7 @@ endi ...@@ -87,7 +87,7 @@ endi
print ========== step1 print ========== step1
sql create dnode $hostname2 sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start system sh/exec_up.sh -n dnode2 -s start
$x = 0 $x = 0
show1: show1:
...@@ -98,12 +98,12 @@ show1: ...@@ -98,12 +98,12 @@ show1:
endi endi
sql show dnodes sql show dnodes
print dnode1 freeVnodes $data3_192.168.0.1 print dnode1 openvnodes $data2_1
print dnode2 freeVnodes $data3_192.168.0.2 print dnode2 openvnodes $data2_2
if $data3_192.168.0.1 != 2 then if $data2_1 != 2 then
goto show1 goto show1
endi endi
if $data3_192.168.0.2 != 2 then if $data2_2 != 2 then
goto show1 goto show1
endi endi
...@@ -139,7 +139,7 @@ endi ...@@ -139,7 +139,7 @@ endi
print ========== step2 print ========== step2
sql create dnode $hostname3 sql create dnode $hostname3
system sh/exec.sh -n dnode3 -s start system sh/exec_up.sh -n dnode3 -s start
sleep 10000 sleep 10000
print ========== step3 print ========== step3
...@@ -154,20 +154,20 @@ show3: ...@@ -154,20 +154,20 @@ show3:
endi endi
sql show dnodes sql show dnodes
print dnode1 freeVnodes $data3_192.168.0.1 print dnode1 freeVnodes $data2_1
print dnode2 freeVnodes $data3_192.168.0.2 print dnode2 freeVnodes $data2_2
print dnode3 freeVnodes $data3_192.168.0.3 print dnode3 freeVnodes $data2_3
if $data3_192.168.0.1 != 2 then if $data2_1 != 2 then
goto show3 goto show3
endi endi
if $data3_192.168.0.2 != NULL then if $data2_2 != NULL then
goto show3 goto show3
endi endi
if $data3_192.168.0.3 != 2 then if $data2_3 != 2 then
goto show3 goto show3
endi endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT system sh/exec_up.sh -n dnode2 -s stop -x SIGINT
sql select count(*) from t10 sql select count(*) from t10
print select count(*) from t10 $data00 expect $rowNum print select count(*) from t10 $data00 expect $rowNum
...@@ -211,16 +211,16 @@ show4: ...@@ -211,16 +211,16 @@ show4:
endi endi
sql show dnodes sql show dnodes
print dnode1 freeVnodes $data3_192.168.0.1 print dnode1 freeVnodes $data2_1
print dnode3 freeVnodes $data3_192.168.0.3 print dnode3 freeVnodes $data2_3
if $data3_192.168.0.1 != 0 then if $data2_1 != 0 then
goto show4 goto show4
endi endi
if $data3_192.168.0.3 != NULL then if $data2_3 != NULL then
goto show4 goto show4
endi endi
system sh/exec.sh -n dnode3 -s stop -x SIGINT system sh/exec_up.sh -n dnode3 -s stop -x SIGINT
sql select count(*) from t10 sql select count(*) from t10
print select count(*) from t10 $data00 expect $rowNum print select count(*) from t10 $data00 expect $rowNum
...@@ -255,7 +255,7 @@ endi ...@@ -255,7 +255,7 @@ endi
print ========== step5 print ========== step5
sql alter database db replica 2 sql alter database db replica 2
sql create dnode $hostname4 sql create dnode $hostname4
system sh/exec.sh -n dnode4 -s start system sh/exec_up.sh -n dnode4 -s start
$x = 0 $x = 0
show5: show5:
...@@ -266,12 +266,12 @@ show5: ...@@ -266,12 +266,12 @@ show5:
endi endi
sql show dnodes sql show dnodes
print dnode1 freeVnodes $data3_192.168.0.1 print dnode1 freeVnodes $data2_1
print dnode4 freeVnodes $data3_192.168.0.4 print dnode4 freeVnodes $data2_4
if $data3_192.168.0.1 != 0 then if $data2_1 != 0 then
goto show5 goto show5
endi endi
if $data3_192.168.0.4 != 0 then if $data2_4 != 0 then
goto show5 goto show5
endi endi
......
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
$totalVnodes = 100
$minVnodes = 48
$maxVnodes = 52
$maxTables = 4
$totalRows = $totalVnodes * $maxTables
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 0 system sh/cfg.sh -n dnode1 -c walLevel -v 0
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 100 system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v $maxTables
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 256 system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v $totalVnodes
system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 100000 system sh/cfg.sh -n dnode1 -c maxVnodeConnections -v 100000
system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 100000 system sh/cfg.sh -n dnode1 -c maxMeterConnections -v 100000
system sh/cfg.sh -n dnode1 -c maxShellConns -v 100000 system sh/cfg.sh -n dnode1 -c maxShellConns -v 100000
system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 100000 system sh/cfg.sh -n dnode1 -c maxMgmtConnections -v 100000
print ========== prepare data print ========== prepare data
system sh/exec.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sleep 3000
sql connect sql connect
sql create database db sql create database db blocks 2 cache 1 maxTables $maxTables
sql use db sql use db
print ========== step1 print ========== step1
sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int) sql create table mt (ts timestamp, tbcol int) TAGS(tgcol int)
$x = 0 $x = 0
while $x < 25600 while $x < $totalRows
$tb = t . $x $tb = t . $x
sql create table $tb using mt tags( $x ) sql create table $tb using mt tags( $x )
sql insert into $tb values (now, $x ) sql insert into $tb values (now, $x )
...@@ -28,16 +35,15 @@ endw ...@@ -28,16 +35,15 @@ endw
print ========== step2 print ========== step2
sql select * from mt sql select * from mt
if $rows != 25600 then if $rows != $totalRows then
return -1 return -1
endi endi
sql select count(*) from mt sql select count(*) from mt
if $data00 != 25600 then if $data00 != $totalRows then
return -1 return -1
endi endi
system sh/deploy.sh -n dnode2 -i 2 system sh/deploy.sh -n dnode2 -i 2
system sh/cfg.sh -n dnode2 -c walLevel -v 0 system sh/cfg.sh -n dnode2 -c walLevel -v 0
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 100 system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 100
...@@ -49,7 +55,7 @@ system sh/cfg.sh -n dnode2 -c maxMgmtConnections -v 100000 ...@@ -49,7 +55,7 @@ system sh/cfg.sh -n dnode2 -c maxMgmtConnections -v 100000
print ========== step2 print ========== step2
sql create dnode $hostname2 sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start system sh/exec_up.sh -n dnode2 -s start
$x = 0 $x = 0
show3: show3:
...@@ -60,23 +66,23 @@ show3: ...@@ -60,23 +66,23 @@ show3:
endi endi
sql show dnodes sql show dnodes
print dnode1 freeVnodes $data3_192.168.0.1 print dnode1 openvnodes $data2_1
print dnode2 freeVnodes $data3_192.168.0.2 print dnode2 openvnodes $data2_2
if $data3_192.168.0.1 != 126 then if $data2_1 != $minVnodes then
goto show3 goto show3
endi endi
if $data3_192.168.0.2 != 130 then if $data2_2 != $maxVnodes then
goto show3 goto show3
endi endi
print ========== step4 print ========== step4
sql select * from mt sql select * from mt
if $rows != 25600 then if $rows != $totalRows then
return -1 return -1
endi endi
sql select count(*) from mt sql select count(*) from mt
if $data00 != 25600 then if $data00 != $totalRows then
return -1 return -1
endi endi
......
...@@ -14,8 +14,8 @@ system sh/cfg.sh -n dnode1 -c adminDebugFlag -v 131 ...@@ -14,8 +14,8 @@ system sh/cfg.sh -n dnode1 -c adminDebugFlag -v 131
system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135 system sh/cfg.sh -n dnode1 -c httpDebugFlag -v 135
system sh/cfg.sh -n dnode1 -c debugFlag -v 131 system sh/cfg.sh -n dnode1 -c debugFlag -v 131
system sh/exec.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sleep 3000
sql connect sql connect
print ======================== dnode1 start print ======================== dnode1 start
...@@ -52,7 +52,7 @@ while $i < $tbNum ...@@ -52,7 +52,7 @@ while $i < $tbNum
endw endw
$i = 0 $i = 0
while $i < 100 while $i < 10
print =============== step3 $i print =============== step3 $i
sql select count(*) from $mt sql select count(*) from $mt
print ===> $data00 $data01 print ===> $data00 $data01
...@@ -83,7 +83,7 @@ while $i < $tbNum ...@@ -83,7 +83,7 @@ while $i < $tbNum
endw endw
$i = 0 $i = 0
while $i < 100 while $i < 10
print =============== step5 $i print =============== step5 $i
sql select count(*) from $mt where tgcol < 20200 sql select count(*) from $mt where tgcol < 20200
print ===> $data00 $data01 print ===> $data00 $data01
......
...@@ -41,14 +41,21 @@ if $data2_2 != slave then ...@@ -41,14 +41,21 @@ if $data2_2 != slave then
goto show2 goto show2
endi endi
print ============== step3
sql_error drop dnode $hostname1 -x error1
print should not drop master
system sh/exec_up.sh -n dnode1 -s stop -x SIGINT system sh/exec_up.sh -n dnode1 -s stop -x SIGINT
system sh/exec_up.sh -n dnode2 -s stop -x SIGINT system sh/exec_up.sh -n dnode2 -s stop -x SIGINT
system sh/exec_up.sh -n dnode3 -s stop -x SIGINT
system sh/exec_up.sh -n dnode4 -s stop -x SIGINT
system sh/exec_up.sh -n dnode5 -s stop -x SIGINT
system sh/exec_up.sh -n dnode6 -s stop -x SIGINT
system sh/exec_up.sh -n dnode7 -s stop -x SIGINT
system sh/exec_up.sh -n dnode8 -s stop -x SIGINT
return return
print ============== step3
sql_error drop dnode $hostname1 -x error1
print should not drop master
print ============== step4 print ============== step4
system sh/exec_up.sh -n dnode1 -s stop -x SIGINT system sh/exec_up.sh -n dnode1 -s stop -x SIGINT
sql_error show mnodes sql_error show mnodes
...@@ -83,7 +90,7 @@ if $data2_2 != slave then ...@@ -83,7 +90,7 @@ if $data2_2 != slave then
endi endi
print ============== step7 print ============== step7
system sh/exec_up.sh -n dnode3 -s start -t system sh/exec_up.sh -n dnode3 -s start
sql create dnode $hostname3 sql create dnode $hostname3
sleep 5000 sleep 5000
...@@ -105,7 +112,7 @@ endi ...@@ -105,7 +112,7 @@ endi
if $data2_2 != slave then if $data2_2 != slave then
goto show7 goto show7
endi endi
if $data3_3 != NULL then if $data3_3 != null then
goto show7 goto show7
endi endi
......
...@@ -59,7 +59,7 @@ endi ...@@ -59,7 +59,7 @@ endi
if $dnode2Role != slave then if $dnode2Role != slave then
return -1 return -1
endi endi
if $dnode3Role != NULL then if $dnode3Role != null then
return -1 return -1
endi endi
...@@ -78,7 +78,7 @@ print dnode3 ==> $dnode3Role ...@@ -78,7 +78,7 @@ print dnode3 ==> $dnode3Role
if $dnode1Role != master then if $dnode1Role != master then
return -1 return -1
endi endi
if $dnode2Role != NULL then if $dnode2Role != null then
return -1 return -1
endi endi
if $dnode3Role != slave then if $dnode3Role != slave then
...@@ -106,7 +106,7 @@ print dnode3 ==> $dnode3Role ...@@ -106,7 +106,7 @@ print dnode3 ==> $dnode3Role
if $dnode1Role != master then if $dnode1Role != master then
return -1 return -1
endi endi
if $dnode2Role != NULL then if $dnode2Role != null then
return -1 return -1
endi endi
if $dnode3Role != slave then if $dnode3Role != slave then
......
...@@ -59,7 +59,7 @@ endi ...@@ -59,7 +59,7 @@ endi
if $dnode2Role != slave then if $dnode2Role != slave then
return -1 return -1
endi endi
if $dnode3Role != NULL then if $dnode3Role != null then
return -1 return -1
endi endi
...@@ -78,7 +78,7 @@ print dnode3 ==> $dnode3Role ...@@ -78,7 +78,7 @@ print dnode3 ==> $dnode3Role
if $dnode1Role != master then if $dnode1Role != master then
return -1 return -1
endi endi
if $dnode2Role != NULL then if $dnode2Role != null then
return -1 return -1
endi endi
if $dnode3Role != slave then if $dnode3Role != slave then
......
...@@ -59,7 +59,7 @@ endi ...@@ -59,7 +59,7 @@ endi
if $dnode2Role != slave then if $dnode2Role != slave then
return -1 return -1
endi endi
if $dnode3Role != NULL then if $dnode3Role != null then
return -1 return -1
endi endi
...@@ -79,7 +79,7 @@ print dnode3 ==> $dnode3Role ...@@ -79,7 +79,7 @@ print dnode3 ==> $dnode3Role
if $dnode1Role != master then if $dnode1Role != master then
return -1 return -1
endi endi
if $dnode2Role != NULL then if $dnode2Role != null then
return -1 return -1
endi endi
if $dnode3Role != slave then if $dnode3Role != slave then
...@@ -106,7 +106,7 @@ print dnode3 ==> $dnode3Role ...@@ -106,7 +106,7 @@ print dnode3 ==> $dnode3Role
if $dnode1Role != master then if $dnode1Role != master then
return -1 return -1
endi endi
if $dnode2Role != NULL then if $dnode2Role != null then
return -1 return -1
endi endi
if $dnode3Role != slave then if $dnode3Role != slave then
......
...@@ -18,10 +18,10 @@ print dnode3 ==> $data3_3 ...@@ -18,10 +18,10 @@ print dnode3 ==> $data3_3
if $data2_1 != master then if $data2_1 != master then
return -1 return -1
endi endi
if $data3_2 != NULL then if $data3_2 != null then
return -1 return -1
endi endi
if $data3_3 != NULL then if $data3_3 != null then
return -1 return -1
endi endi
...@@ -44,7 +44,7 @@ endi ...@@ -44,7 +44,7 @@ endi
if $dnode2Role != slave then if $dnode2Role != slave then
return -1 return -1
endi endi
if $dnode3Role != NULL then if $dnode3Role != null then
return -1 return -1
endi endi
...@@ -86,7 +86,7 @@ print dnode3 ==> $dnode3Role ...@@ -86,7 +86,7 @@ print dnode3 ==> $dnode3Role
if $dnode1Role != master then if $dnode1Role != master then
return -1 return -1
endi endi
if $dnode2Role != NULL then if $dnode2Role != null then
return -1 return -1
endi endi
if $dnode3Role != slave then if $dnode3Role != slave then
...@@ -156,7 +156,7 @@ print dnode1 ==> $dnode1Role ...@@ -156,7 +156,7 @@ print dnode1 ==> $dnode1Role
print dnode2 ==> $dnode2Role print dnode2 ==> $dnode2Role
print dnode3 ==> $dnode3Role print dnode3 ==> $dnode3Role
if $dnode1Role != NULL then if $dnode1Role != null then
return -1 return -1
endi endi
#if $dnode2Role != master then #if $dnode2Role != master then
......
...@@ -22,10 +22,10 @@ print dnode3 ==> $data3_3 ...@@ -22,10 +22,10 @@ print dnode3 ==> $data3_3
if $data2_1 != master then if $data2_1 != master then
return -1 return -1
endi endi
if $data3_2 != NULL then if $data3_2 != null then
return -1 return -1
endi endi
if $data3_3 != NULL then if $data3_3 != null then
return -1 return -1
endi endi
...@@ -50,10 +50,10 @@ endi ...@@ -50,10 +50,10 @@ endi
if $dnode2Role != slave then if $dnode2Role != slave then
return -1 return -1
endi endi
if $dnode3Role != NULL then if $dnode3Role != null then
return -1 return -1
endi endi
if $dnode4Role != NULL then if $dnode4Role != null then
return -1 return -1
endi endi
...@@ -81,7 +81,7 @@ endi ...@@ -81,7 +81,7 @@ endi
if $dnode3Role != slave then if $dnode3Role != slave then
return -1 return -1
endi endi
if $dnode4Role != NULL then if $dnode4Role != null then
return -1 return -1
endi endi
...@@ -110,7 +110,7 @@ endi ...@@ -110,7 +110,7 @@ endi
if $dnode3Role != slave then if $dnode3Role != slave then
return -1 return -1
endi endi
if $dnode4Role != NULL then if $dnode4Role != null then
return -1 return -1
endi endi
...@@ -131,7 +131,7 @@ print dnode4 ==> $dnode4Role ...@@ -131,7 +131,7 @@ print dnode4 ==> $dnode4Role
if $dnode1Role != master then if $dnode1Role != master then
return -1 return -1
endi endi
if $dnode2Role != NULL then if $dnode2Role != null then
return -1 return -1
endi endi
if $dnode3Role != slave then if $dnode3Role != slave then
...@@ -165,7 +165,7 @@ print dnode4 ==> $dnode4Role ...@@ -165,7 +165,7 @@ print dnode4 ==> $dnode4Role
if $dnode1Role != master then if $dnode1Role != master then
return -1 return -1
endi endi
if $dnode2Role != NULL then if $dnode2Role != null then
return -1 return -1
endi endi
if $dnode3Role != slave then if $dnode3Role != slave then
...@@ -207,7 +207,7 @@ print dnode2 ==> $dnode2Role ...@@ -207,7 +207,7 @@ print dnode2 ==> $dnode2Role
print dnode3 ==> $dnode3Role print dnode3 ==> $dnode3Role
print dnode4 ==> $dnode4Role print dnode4 ==> $dnode4Role
if $dnode1Role != NULL then if $dnode1Role != null then
return -1 return -1
endi endi
if $dnode2Role != slave then if $dnode2Role != slave then
......
...@@ -27,6 +27,7 @@ system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4 ...@@ -27,6 +27,7 @@ system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
print ========= start dnodes print ========= start dnodes
system sh/exec_up.sh -n dnode1 -s start system sh/exec_up.sh -n dnode1 -s start
sleep 3000
sql connect sql connect
sql create dnode $hostname2 sql create dnode $hostname2
system sh/exec_up.sh -n dnode2 -s start system sh/exec_up.sh -n dnode2 -s start
...@@ -89,6 +90,19 @@ if $data2_3 != 4 then ...@@ -89,6 +90,19 @@ if $data2_3 != 4 then
return -1 return -1
endi endi
if $data4_1 != ready then
print dnode1 status should ready but is $data4_1
return -1
endi
if $data4_2 != ready then
return -1
endi
if $data4_3 != ready then
return -1
endi
print ========= step2 print ========= step2
sql insert into d1.t1 values(now, 2) sql insert into d1.t1 values(now, 2)
sql insert into d2.t2 values(now, 2) sql insert into d2.t2 values(now, 2)
......
...@@ -21,11 +21,12 @@ fi ...@@ -21,11 +21,12 @@ fi
echo -e "${GREEN} ### Total $totalSuccess TSIM case(s) succeed! ### ${NC}" echo -e "${GREEN} ### Total $totalSuccess TSIM case(s) succeed! ### ${NC}"
totalFailed=`grep 'failed\|fault' out.txt | wc -l` totalFailed=`grep 'failed\|fault' out.txt | wc -l`
echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}" # echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}"
if [ "$totalFailed" -ne "0" ]; then if [ "$totalFailed" -ne "0" ]; then
# echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}" echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}"
exit $totalFailed
# exit $totalFailed
fi fi
echo "### run Python script ###" echo "### run Python script ###"
...@@ -46,6 +47,7 @@ fi ...@@ -46,6 +47,7 @@ fi
totalPyFailed=`grep 'failed\|fault' pytest-out.txt | wc -l` totalPyFailed=`grep 'failed\|fault' pytest-out.txt | wc -l`
if [ "$totalPyFailed" -ne "0" ]; then if [ "$totalPyFailed" -ne "0" ]; then
echo -e "${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}" echo -e "${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}"
exit $totalPyFailed # exit $totalPyFailed
fi fi
exit $(($totalFailed + $totalPyFailed))
...@@ -415,7 +415,7 @@ void simCloseNativeConnect(SScript *script) { ...@@ -415,7 +415,7 @@ void simCloseNativeConnect(SScript *script) {
simTrace("script:%s, taos:%p closed", script->fileName, script->taos); simTrace("script:%s, taos:%p closed", script->fileName, script->taos);
taos_close(script->taos); taos_close(script->taos);
taosMsleep(1000); taosMsleep(1200);
script->taos = NULL; script->taos = NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册