From b8391fad62eb5d23544f7218a272685325e40aea Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Tue, 12 Apr 2022 19:10:52 +0800 Subject: [PATCH 01/48] fix heartbeat msg --- include/common/tmsg.h | 114 ++++++---- include/libs/scheduler/scheduler.h | 2 + include/util/tarray.h | 8 + source/client/inc/clientInt.h | 10 +- source/client/src/clientEnv.c | 70 +++++- source/client/src/clientHb.c | 146 +++++++++++- source/client/src/clientImpl.c | 2 +- source/client/src/clientMain.c | 6 +- source/client/src/clientMsgHandler.c | 2 +- source/common/src/tmsg.c | 117 +++++++++- source/dnode/mnode/impl/inc/mndInt.h | 1 - source/dnode/mnode/impl/src/mndDb.c | 2 + source/dnode/mnode/impl/src/mndProfile.c | 277 +++++++++++------------ source/libs/scheduler/inc/schedulerInt.h | 4 +- source/libs/scheduler/src/scheduler.c | 30 ++- source/util/src/tarray.c | 15 ++ 16 files changed, 586 insertions(+), 220 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index ba9147dcdd..dd7d904255 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -341,12 +341,12 @@ int32_t tSerializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq); int32_t tDeserializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq); typedef struct { - int32_t acctId; - int64_t clusterId; - int32_t connId; - int8_t superUser; - SEpSet epSet; - char sVersion[128]; + int32_t acctId; + int64_t clusterId; + uint32_t connId; + int8_t superUser; + SEpSet epSet; + char sVersion[128]; } SConnectRsp; int32_t tSerializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp); @@ -1038,40 +1038,6 @@ typedef struct { int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq); int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq); -typedef struct { - char sql[TSDB_SHOW_SQL_LEN]; - int32_t queryId; - int64_t useconds; - int64_t stime; - int64_t qId; - int64_t sqlObjId; - int32_t pid; - char fqdn[TSDB_FQDN_LEN]; - int8_t stableQuery; - int32_t numOfSub; - char subSqlInfo[TSDB_SHOW_SUBQUERY_LEN]; // include subqueries' index, Obj IDs and states(C-complete/I-imcomplete) -} SQueryDesc; - -typedef struct { - int32_t connId; - int32_t pid; - int32_t numOfQueries; - int32_t numOfStreams; - char app[TSDB_APP_NAME_LEN]; - char pData[]; -} SHeartBeatReq; - -typedef struct { - int32_t connId; - int32_t queryId; - int32_t streamId; - int32_t totalDnodes; - int32_t onlineDnodes; - int8_t killConnection; - int8_t align[3]; - SEpSet epSet; -} SHeartBeatRsp; - typedef struct { int32_t connId; int32_t queryId; @@ -1674,13 +1640,48 @@ typedef struct { } SKv; typedef struct { - int32_t connId; + int64_t tscRid; int32_t hbType; } SClientHbKey; typedef struct { - SClientHbKey connKey; - SHashObj* info; // hash + int64_t tid; + int32_t status; +} SQuerySubDesc; + +typedef struct { + char sql[TSDB_SHOW_SQL_LEN]; + uint64_t queryId; + int64_t useconds; + int64_t stime; + int64_t reqRid; + int32_t pid; + char fqdn[TSDB_FQDN_LEN]; + int32_t subPlanNum; + SArray* subDesc; // SArray +} SQueryDesc; + +typedef struct { + uint32_t connId; + int32_t pid; + char app[TSDB_APP_NAME_LEN]; + SArray* queryDesc; // SArray +} SQueryHbReqBasic; + +typedef struct { + uint32_t connId; + uint64_t killRid; + int32_t totalDnodes; + int32_t onlineDnodes; + int8_t killConnection; + int8_t align[3]; + SEpSet epSet; +} SQueryHbRspBasic; + +typedef struct { + SClientHbKey connKey; + SQueryHbReqBasic* query; + SHashObj* info; // hash } SClientHbReq; typedef struct { @@ -1689,9 +1690,10 @@ typedef struct { } SClientHbBatchReq; typedef struct { - SClientHbKey connKey; - int32_t status; - SArray* info; // Array + SClientHbKey connKey; + int32_t status; + SQueryHbRspBasic* query; + SArray* info; // Array } SClientHbRsp; typedef struct { @@ -1711,8 +1713,23 @@ static FORCE_INLINE void tFreeReqKvHash(SHashObj* info) { } } +static FORCE_INLINE void tFreeClientHbQueryDesc(void* pDesc) { + SQueryDesc* desc = (SQueryDesc*)pDesc; + if (desc->subDesc) { + taosArrayDestroy(desc->subDesc); + desc->subDesc = NULL; + } +} + static FORCE_INLINE void tFreeClientHbReq(void* pReq) { SClientHbReq* req = (SClientHbReq*)pReq; + if (req->query) { + if (req->query->queryDesc) { + taosArrayDestroyEx(req->query->queryDesc, tFreeClientHbQueryDesc); + } + taosMemoryFreeClear(req->query); + } + if (req->info) { tFreeReqKvHash(req->info); taosHashCleanup(req->info); @@ -1741,6 +1758,7 @@ static FORCE_INLINE void tFreeClientKv(void* pKv) { static FORCE_INLINE void tFreeClientHbRsp(void* pRsp) { SClientHbRsp* rsp = (SClientHbRsp*)pRsp; + taosMemoryFreeClear(rsp->query); if (rsp->info) taosArrayDestroyEx(rsp->info, tFreeClientKv); } @@ -1769,13 +1787,13 @@ static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) { } static FORCE_INLINE int32_t tEncodeSClientHbKey(SCoder* pEncoder, const SClientHbKey* pKey) { - if (tEncodeI32(pEncoder, pKey->connId) < 0) return -1; + if (tEncodeI64(pEncoder, pKey->tscRid) < 0) return -1; if (tEncodeI32(pEncoder, pKey->hbType) < 0) return -1; return 0; } static FORCE_INLINE int32_t tDecodeSClientHbKey(SCoder* pDecoder, SClientHbKey* pKey) { - if (tDecodeI32(pDecoder, &pKey->connId) < 0) return -1; + if (tDecodeI64(pDecoder, &pKey->tscRid) < 0) return -1; if (tDecodeI32(pDecoder, &pKey->hbType) < 0) return -1; return 0; } diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index 5ab4ead89c..460749243c 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -89,6 +89,8 @@ int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryPlan* pD */ int32_t schedulerFetchRows(int64_t job, void **data); +int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub); + /** * Cancel query job diff --git a/include/util/tarray.h b/include/util/tarray.h index 521e54040d..383af8309d 100644 --- a/include/util/tarray.h +++ b/include/util/tarray.h @@ -205,6 +205,14 @@ SArray* taosArrayDup(const SArray* pSrc); */ void taosArrayClear(SArray* pArray); +/** + * clear the array (remove all element) + * @param pArray + * @param fp + */ +void taosArrayClearEx(SArray* pArray, void (*fp)(void*)); + + /** * destroy array list * @param pArray diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 96d7cead68..4bb1d8e3ff 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -43,7 +43,8 @@ extern "C" { } \ } while (0) -#define HEARTBEAT_INTERVAL 1500 // ms +//#define HEARTBEAT_INTERVAL 1500 // ms +#define HEARTBEAT_INTERVAL 15000 // ms TODO typedef struct SAppInstInfo SAppInstInfo; @@ -139,6 +140,7 @@ typedef struct STscObj { TdThreadMutex mutex; // used to protect the operation on db int32_t numOfReqs; // number of sqlObj bound to this connection SAppInstInfo* pAppInfo; + SHashObj* pRequests; } STscObj; typedef struct SResultColumn { @@ -215,11 +217,15 @@ int taos_init(); void* createTscObj(const char* user, const char* auth, const char* db, SAppInstInfo* pAppInfo); void destroyTscObj(void* pObj); +STscObj *acquireTscObj(int64_t rid); +int32_t releaseTscObj(int64_t rid); uint64_t generateRequestId(); void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type); void destroyRequest(SRequestObj* pRequest); +SRequestObj *acquireRequest(int64_t rid); +int32_t releaseRequest(int64_t rid); char* getDbOfConnection(STscObj* pObj); void setConnectionDB(STscObj* pTscObj, const char* db); @@ -258,7 +264,7 @@ SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char* key); void appHbMgrCleanup(void); // conn level -int hbRegisterConn(SAppHbMgr* pAppHbMgr, int32_t connId, int64_t clusterId, int32_t hbType); +int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int32_t hbType); void hbDeregisterConn(SAppHbMgr* pAppHbMgr, SClientHbKey connKey); int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* value, int32_t keyLen, int32_t valueLen); diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 359649884f..f997d4cff2 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -37,7 +37,8 @@ static TdThreadOnce tscinit = PTHREAD_ONCE_INIT; volatile int32_t tscInitRes = 0; static void registerRequest(SRequestObj *pRequest) { - STscObj *pTscObj = (STscObj *)taosAcquireRef(clientConnRefPool, pRequest->pTscObj->id); + STscObj *pTscObj = acquireTscObj(pRequest->pTscObj->id); + assert(pTscObj != NULL); // connection has been released already, abort creating request. @@ -69,7 +70,7 @@ static void deregisterRequest(SRequestObj *pRequest) { tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%" PRIu64 " ms, current:%d, app current:%d", pRequest->self, pTscObj->id, pRequest->requestId, duration/1000, num, currentInst); - taosReleaseRef(clientConnRefPool, pTscObj->id); + releaseTscObj(pTscObj->id); } // todo close the transporter properly @@ -107,12 +108,24 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) { return pDnodeConn; } +void closeAllRequests(SHashObj *pRequests) { + void *pIter = taosHashIterate(pRequests, NULL); + while (pIter != NULL) { + int64_t *rid = pIter; + + releaseRequest(*rid); + + pIter = taosHashIterate(pRequests, pIter); + } +} + void destroyTscObj(void *pObj) { STscObj *pTscObj = pObj; - SClientHbKey connKey = {.connId = pTscObj->connId, .hbType = pTscObj->connType}; + SClientHbKey connKey = {.tscRid = pTscObj->id, .hbType = pTscObj->connType}; hbDeregisterConn(pTscObj->pAppInfo->pAppHbMgr, connKey); atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1); + closeAllRequests(pTscObj->pRequests); tscDebug("connObj 0x%" PRIx64 " destroyed, totalConn:%" PRId64, pTscObj->id, pTscObj->pAppInfo->numOfConns); taosThreadMutexDestroy(&pTscObj->mutex); taosMemoryFreeClear(pTscObj); @@ -125,6 +138,13 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI return NULL; } + pObj->pRequests = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK); + if (NULL == pObj->pRequests) { + taosMemoryFree(pObj); + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + return NULL; + } + pObj->pAppInfo = pAppInfo; tstrncpy(pObj->user, user, sizeof(pObj->user)); memcpy(pObj->pass, auth, TSDB_PASSWORD_LEN); @@ -140,6 +160,14 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI return pObj; } +STscObj *acquireTscObj(int64_t rid) { + return (STscObj *)taosAcquireRef(clientConnRefPool, rid); +} + +int32_t releaseTscObj(int64_t rid) { + return taosReleaseRef(clientConnRefPool, rid); +} + void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t type) { assert(pObj != NULL); @@ -160,6 +188,14 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty tsem_init(&pRequest->body.rspSem, 0, 0); registerRequest(pRequest); + + if (taosHashPut(pObj->pRequests, &pRequest->self, sizeof(pRequest->self), &pRequest->self, sizeof(pRequest->self))) { + destroyRequest(pRequest); + releaseTscObj(pObj->id); + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + return NULL; + } + return pRequest; } @@ -185,6 +221,8 @@ static void doDestroyRequest(void *p) { assert(RID_VALID(pRequest->self)); + taosHashRemove(pRequest->pTscObj->pRequests, &pRequest->self, sizeof(pRequest->self)); + taosMemoryFreeClear(pRequest->msgBuf); taosMemoryFreeClear(pRequest->sqlstr); taosMemoryFreeClear(pRequest->pInfo); @@ -213,9 +251,18 @@ void destroyRequest(SRequestObj *pRequest) { return; } - taosReleaseRef(clientReqRefPool, pRequest->self); + taosRemoveRef(clientReqRefPool, pRequest->self); } +SRequestObj *acquireRequest(int64_t rid) { + return (SRequestObj *)taosAcquireRef(clientReqRefPool, rid); +} + +int32_t releaseRequest(int64_t rid) { + return taosReleaseRef(clientReqRefPool, rid); +} + + void taos_init_imp(void) { // In the APIs of other program language, taos_cleanup is not available yet. // So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning. @@ -456,11 +503,18 @@ uint64_t generateRequestId() { } } - int64_t ts = taosGetTimestampMs(); - uint64_t pid = taosGetPId(); - int32_t val = atomic_add_fetch_32(&requestSerialId, 1); + uint64_t id = 0; + + while (true) { + int64_t ts = taosGetTimestampMs(); + uint64_t pid = taosGetPId(); + int32_t val = atomic_add_fetch_32(&requestSerialId, 1); - uint64_t id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); + id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); + if (id) { + break; + } + } return id; } diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index d389fc34c6..642ba46336 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -14,6 +14,7 @@ */ #include "catalog.h" +#include "scheduler.h" #include "clientInt.h" #include "clientLog.h" #include "trpc.h" @@ -107,10 +108,36 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) { SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pRsp->connKey, sizeof(SClientHbKey)); if (NULL == info) { - tscWarn("fail to get connInfo, may be dropped, connId:%d, type:%d", pRsp->connKey.connId, pRsp->connKey.hbType); + tscWarn("fail to get connInfo, may be dropped, refId:%" PRIx64 ", type:%d", pRsp->connKey.tscRid, pRsp->connKey.hbType); return TSDB_CODE_SUCCESS; } + if (pRsp->query) { + STscObj *pTscObj = (STscObj *)acquireTscObj(pRsp->connKey.tscRid); + if (NULL == pTscObj) { + tscDebug("tscObj rid %" PRIx64 " not exist", pRsp->connKey.tscRid); + } else { + updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pRsp->query->epSet); + pTscObj->connId = pRsp->query->connId; + + if (pRsp->query->killRid) { + SRequestObj *pRequest = acquireRequest(pRsp->query->killRid); + if (NULL == pRequest) { + tscDebug("request 0x%" PRIx64 " not exist to kill", pRsp->query->killRid); + } else { + taos_stop_query((TAOS_RES *)pRequest); + releaseRequest(pRsp->query->killRid); + } + } + + if (pRsp->query->killConnection) { + taos_close(pTscObj); + } + + releaseTscObj(pRsp->connKey.tscRid); + } + } + int32_t kvNum = pRsp->info ? taosArrayGetSize(pRsp->info) : 0; tscDebug("hb got %d rsp kv", kvNum); @@ -206,6 +233,97 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) return code; } +int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) { + int64_t now = taosGetTimestampUs(); + SQueryDesc desc = {0}; + int32_t code = 0; + + void *pIter = taosHashIterate(pObj->pRequests, NULL); + while (pIter != NULL) { + int64_t *rid = pIter; + SRequestObj *pRequest = acquireRequest(*rid); + if (NULL == pRequest) { + continue; + } + + tstrncpy(desc.sql, pRequest->sqlstr, sizeof(desc.sql)); + desc.stime = pRequest->metric.start; + desc.queryId = pRequest->requestId; + desc.useconds = now - pRequest->metric.start; + desc.reqRid = pRequest->self; + desc.pid = hbBasic->pid; + taosGetFqdn(desc.fqdn); + desc.subPlanNum = pRequest->body.pDag ? pRequest->body.pDag->numOfSubplans : 0; + + if (desc.subPlanNum) { + desc.subDesc = taosArrayInit(desc.subPlanNum, sizeof(SQuerySubDesc)); + if (NULL == desc.subDesc) { + releaseRequest(*rid); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + code = schedulerGetTasksStatus(pRequest->body.queryJob, desc.subDesc); + if (code) { + taosArrayDestroy(desc.subDesc); + desc.subDesc = NULL; + } + } + + releaseRequest(*rid); + taosArrayPush(hbBasic->queryDesc, &desc); + + pIter = taosHashIterate(pObj->pRequests, pIter); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) { + STscObj *pTscObj = (STscObj *)acquireTscObj(connKey->tscRid); + if (NULL == pTscObj) { + tscWarn("tscObj rid %" PRIx64 " not exist", connKey->tscRid); + return TSDB_CODE_QRY_APP_ERROR; + } + + int32_t numOfQueries = pTscObj->pRequests ? taosHashGetSize(pTscObj->pRequests) : 0; + if (numOfQueries <= 0) { + releaseTscObj(connKey->tscRid); + tscDebug("no queries on connection"); + return TSDB_CODE_QRY_APP_ERROR; + } + + SQueryHbReqBasic *hbBasic = (SQueryHbReqBasic *)taosMemoryCalloc(1, sizeof(SQueryHbReqBasic)); + if (NULL == hbBasic) { + tscError("calloc %d failed", (int32_t)sizeof(SQueryHbReqBasic)); + releaseTscObj(connKey->tscRid); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + hbBasic->queryDesc = taosArrayInit(numOfQueries, sizeof(SQueryDesc)); + if (NULL == hbBasic->queryDesc) { + tscWarn("taosArrayInit %d queryDesc failed", numOfQueries); + releaseTscObj(connKey->tscRid); + taosMemoryFree(hbBasic); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + hbBasic->connId = pTscObj->connId; + hbBasic->pid = taosGetPId(); + taosGetAppName(hbBasic->app, NULL); + + int32_t code = hbBuildQueryDesc(hbBasic, pTscObj); + if (code) { + releaseTscObj(connKey->tscRid); + taosMemoryFree(hbBasic); + return code; + } + + req->query = hbBasic; + releaseTscObj(connKey->tscRid); + + return TSDB_CODE_SUCCESS; +} + int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SClientHbReq *req) { SDbVgVersion *dbs = NULL; uint32_t dbNum = 0; @@ -284,6 +402,8 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req return code; } + hbGetQueryBasicInfo(connKey, req); + code = hbGetExpiredDBInfo(connKey, pCatalog, req); if (TSDB_CODE_SUCCESS != code) { return code; @@ -316,6 +436,11 @@ void hbFreeReq(void *req) { tFreeReqKvHash(pReq->info); } +void hbClearClientHbReq(SClientHbReq *pReq) { + pReq->query = NULL; + pReq->info = NULL; +} + SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) { SClientHbBatchReq *pBatchReq = taosMemoryCalloc(1, sizeof(SClientHbBatchReq)); if (pBatchReq == NULL) { @@ -334,20 +459,21 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) { if (info) { code = (*clientHbMgr.reqHandle[pOneReq->connKey.hbType])(&pOneReq->connKey, info->param, pOneReq); if (code) { - taosHashCancelIterate(pAppHbMgr->activeInfo, pIter); - break; + pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter); + continue; } } taosArrayPush(pBatchReq->reqs, pOneReq); + hbClearClientHbReq(pOneReq); pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter); } - if (code) { - taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq); - taosMemoryFreeClear(pBatchReq); - } +// if (code) { +// taosArrayDestroyEx(pBatchReq->reqs, hbFreeReq); +// taosMemoryFreeClear(pBatchReq); +// } return pBatchReq; } @@ -548,7 +674,7 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo * if (data != NULL) { return 0; } - SClientHbReq hbReq; + SClientHbReq hbReq = {0}; hbReq.connKey = connKey; hbReq.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK); @@ -565,9 +691,9 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo * return 0; } -int hbRegisterConn(SAppHbMgr *pAppHbMgr, int32_t connId, int64_t clusterId, int32_t hbType) { +int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int32_t hbType) { SClientHbKey connKey = { - .connId = connId, + .tscRid = tscRefId, .hbType = HEARTBEAT_TYPE_QUERY, }; SHbConnInfo info = {0}; diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index b311060ea9..2c58094b4d 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -458,7 +458,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t taos_close(pTscObj); pTscObj = NULL; } else { - tscDebug("0x%" PRIx64 " connection is opening, connId:%d, dnodeConn:%p, reqId:0x%" PRIx64, pTscObj->id, + tscDebug("0x%" PRIx64 " connection is opening, connId:%u, dnodeConn:%p, reqId:0x%" PRIx64, pTscObj->id, pTscObj->connId, pTscObj->pAppInfo->pTransporter, pRequest->requestId); destroyRequest(pRequest); } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index e10cf5179e..76257a7c0e 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -14,6 +14,7 @@ */ #include "catalog.h" +#include "scheduler.h" #include "clientInt.h" #include "clientLog.h" #include "os.h" @@ -66,6 +67,7 @@ void taos_cleanup(void) { rpcCleanup(); catalogDestroy(); + schedulerDestroy(); taosCloseLog(); tscInfo("all local resources released"); @@ -98,7 +100,7 @@ void taos_close(TAOS *taos) { STscObj *pTscObj = (STscObj *)taos; tscDebug("0x%" PRIx64 " try to close connection, numOfReq:%d", pTscObj->id, pTscObj->numOfReqs); - /*taosRemoveRef(clientConnRefPool, pTscObj->id);*/ + taosRemoveRef(clientConnRefPool, pTscObj->id); } int taos_errno(TAOS_RES *tres) { @@ -366,7 +368,7 @@ void taos_stop_query(TAOS_RES *res) { return; } - // scheduleCancelJob(pRequest->body.pQueryJob); + schedulerFreeJob(pRequest->body.queryJob); } bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) { diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 4314391743..ca4c681304 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -71,7 +71,7 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) { pTscObj->connType = HEARTBEAT_TYPE_QUERY; - hbRegisterConn(pTscObj->pAppInfo->pAppHbMgr, connectRsp.connId, connectRsp.clusterId, HEARTBEAT_TYPE_QUERY); + hbRegisterConn(pTscObj->pAppInfo->pAppHbMgr, pTscObj->id, connectRsp.clusterId, HEARTBEAT_TYPE_QUERY); // pRequest->body.resInfo.pRspMsg = pMsg->pData; tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId, diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 5973a70b59..92fa9b8e97 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -134,6 +134,42 @@ void *taosDecodeSEpSet(void *buf, SEpSet *pEp) { static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq) { if (tEncodeSClientHbKey(pEncoder, &pReq->connKey) < 0) return -1; + if (pReq->connKey.hbType == HEARTBEAT_TYPE_QUERY) { + int32_t queryNum = 0; + if (pReq->query) { + queryNum = 1; + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + if (tEncodeU32(pEncoder, pReq->query->connId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->query->pid) < 0) return -1; + if (tEncodeCStr(pEncoder, pReq->query->app) < 0) return -1; + + int32_t num = taosArrayGetSize(pReq->query->queryDesc); + if (tEncodeI32(pEncoder, num) < 0) return -1; + + for (int32_t i = 0; i < num; ++i) { + SQueryDesc *desc = taosArrayGet(pReq->query->queryDesc, i); + if (tEncodeCStr(pEncoder, desc->sql) < 0) return -1; + if (tEncodeU64(pEncoder, desc->queryId) < 0) return -1; + if (tEncodeI64(pEncoder, desc->useconds) < 0) return -1; + if (tEncodeI64(pEncoder, desc->stime) < 0) return -1; + if (tEncodeI64(pEncoder, desc->reqRid) < 0) return -1; + if (tEncodeI32(pEncoder, desc->pid) < 0) return -1; + if (tEncodeCStr(pEncoder, desc->fqdn) < 0) return -1; + if (tEncodeI32(pEncoder, desc->subPlanNum) < 0) return -1; + + int32_t snum = desc->subDesc ? taosArrayGetSize(desc->subDesc) : 0; + if (tEncodeI32(pEncoder, snum) < 0) return -1; + for (int32_t m = 0; m < snum; ++m) { + SQuerySubDesc *sDesc = taosArrayGet(desc->subDesc, m); + if (tEncodeI64(pEncoder, sDesc->tid) < 0) return -1; + if (tEncodeI32(pEncoder, sDesc->status) < 0) return -1; + } + } + } else { + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + } + } + int32_t kvNum = taosHashGetSize(pReq->info); if (tEncodeI32(pEncoder, kvNum) < 0) return -1; void *pIter = taosHashIterate(pReq->info, NULL); @@ -149,6 +185,53 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) { if (tDecodeSClientHbKey(pDecoder, &pReq->connKey) < 0) return -1; + if (pReq->connKey.hbType == HEARTBEAT_TYPE_QUERY) { + int32_t queryNum = 0; + if (tDecodeI32(pDecoder, &queryNum) < 0) return -1; + if (queryNum) { + pReq->query = taosMemoryCalloc(1, sizeof(*pReq->query)); + if (NULL == pReq->query) return -1; + if (tDecodeU32(pDecoder, &pReq->query->connId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->query->pid) < 0) return -1; + if (tDecodeCStrTo(pDecoder, pReq->query->app) < 0) return -1; + + int32_t num = 0; + if (tDecodeI32(pDecoder, &num) < 0) return -1; + if (num > 0) { + pReq->query->queryDesc = taosArrayInit(num, sizeof(SQueryDesc)); + if (NULL == pReq->query->queryDesc) return -1; + + for (int32_t i = 0; i < num; ++i) { + SQueryDesc desc = {0}; + if (tDecodeCStrTo(pDecoder, desc.sql) < 0) return -1; + if (tDecodeU64(pDecoder, &desc.queryId) < 0) return -1; + if (tDecodeI64(pDecoder, &desc.useconds) < 0) return -1; + if (tDecodeI64(pDecoder, &desc.stime) < 0) return -1; + if (tDecodeI64(pDecoder, &desc.reqRid) < 0) return -1; + if (tDecodeI32(pDecoder, &desc.pid) < 0) return -1; + if (tDecodeCStrTo(pDecoder, desc.fqdn) < 0) return -1; + if (tDecodeI32(pDecoder, &desc.subPlanNum) < 0) return -1; + + int32_t snum = 0; + if (tDecodeI32(pDecoder, &snum) < 0) return -1; + if (snum > 0) { + desc.subDesc = taosArrayInit(snum, sizeof(SQuerySubDesc)); + if (NULL == desc.subDesc) return -1; + + for (int32_t m = 0; m < snum; ++m) { + SQuerySubDesc sDesc = {0}; + if (tDecodeI64(pDecoder, &sDesc.tid) < 0) return -1; + if (tDecodeI32(pDecoder, &sDesc.status) < 0) return -1; + taosArrayPush(desc.subDesc, &sDesc); + } + } + + taosArrayPush(pReq->query->queryDesc, &desc); + } + } + } + } + int32_t kvNum = 0; if (tDecodeI32(pDecoder, &kvNum) < 0) return -1; if (pReq->info == NULL) { @@ -168,6 +251,20 @@ static int32_t tSerializeSClientHbRsp(SCoder *pEncoder, const SClientHbRsp *pRsp if (tEncodeSClientHbKey(pEncoder, &pRsp->connKey) < 0) return -1; if (tEncodeI32(pEncoder, pRsp->status) < 0) return -1; + int32_t queryNum = 0; + if (pRsp->query) { + queryNum = 1; + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + if (tEncodeU32(pEncoder, pRsp->query->connId) < 0) return -1; + if (tEncodeU64(pEncoder, pRsp->query->killRid) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->query->totalDnodes) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->query->onlineDnodes) < 0) return -1; + if (tEncodeI8(pEncoder, pRsp->query->killConnection) < 0) return -1; + if (tEncodeSEpSet(pEncoder, &pRsp->query->epSet) < 0) return -1; + } else { + if (tEncodeI32(pEncoder, queryNum) < 0) return -1; + } + int32_t kvNum = taosArrayGetSize(pRsp->info); if (tEncodeI32(pEncoder, kvNum) < 0) return -1; for (int32_t i = 0; i < kvNum; i++) { @@ -182,6 +279,19 @@ static int32_t tDeserializeSClientHbRsp(SCoder *pDecoder, SClientHbRsp *pRsp) { if (tDecodeSClientHbKey(pDecoder, &pRsp->connKey) < 0) return -1; if (tDecodeI32(pDecoder, &pRsp->status) < 0) return -1; + int32_t queryNum = 0; + if (tDecodeI32(pDecoder, &queryNum) < 0) return -1; + if (queryNum) { + pRsp->query = taosMemoryCalloc(1, sizeof(*pRsp->query)); + if (NULL == pRsp->query) return -1; + if (tDecodeU32(pDecoder, &pRsp->query->connId) < 0) return -1; + if (tDecodeU64(pDecoder, &pRsp->query->killRid) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->query->totalDnodes) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->query->onlineDnodes) < 0) return -1; + if (tDecodeI8(pDecoder, &pRsp->query->killConnection) < 0) return -1; + if (tDecodeSEpSet(pDecoder, &pRsp->query->epSet) < 0) return -1; + } + int32_t kvNum = 0; if (tDecodeI32(pDecoder, &kvNum) < 0) return -1; pRsp->info = taosArrayInit(kvNum, sizeof(SKv)); @@ -224,8 +334,9 @@ int32_t tDeserializeSClientHbBatchReq(void *buf, int32_t bufLen, SClientHbBatchR int32_t reqNum = 0; if (tDecodeI32(&decoder, &reqNum) < 0) return -1; - if (pBatchReq->reqs == NULL) { + if (reqNum > 0) { pBatchReq->reqs = taosArrayInit(reqNum, sizeof(SClientHbReq)); + if (NULL == pBatchReq->reqs) return -1; } for (int32_t i = 0; i < reqNum; i++) { SClientHbReq req = {0}; @@ -2564,7 +2675,7 @@ int32_t tSerializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { if (tStartEncode(&encoder) < 0) return -1; if (tEncodeI32(&encoder, pRsp->acctId) < 0) return -1; if (tEncodeI64(&encoder, pRsp->clusterId) < 0) return -1; - if (tEncodeI32(&encoder, pRsp->connId) < 0) return -1; + if (tEncodeU32(&encoder, pRsp->connId) < 0) return -1; if (tEncodeI8(&encoder, pRsp->superUser) < 0) return -1; if (tEncodeSEpSet(&encoder, &pRsp->epSet) < 0) return -1; if (tEncodeCStr(&encoder, pRsp->sVersion) < 0) return -1; @@ -2582,7 +2693,7 @@ int32_t tDeserializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { if (tStartDecode(&decoder) < 0) return -1; if (tDecodeI32(&decoder, &pRsp->acctId) < 0) return -1; if (tDecodeI64(&decoder, &pRsp->clusterId) < 0) return -1; - if (tDecodeI32(&decoder, &pRsp->connId) < 0) return -1; + if (tDecodeU32(&decoder, &pRsp->connId) < 0) return -1; if (tDecodeI8(&decoder, &pRsp->superUser) < 0) return -1; if (tDecodeSEpSet(&decoder, &pRsp->epSet) < 0) return -1; if (tDecodeCStrTo(&decoder, pRsp->sVersion) < 0) return -1; diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index fa1502fe10..ad42eebc1b 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -75,7 +75,6 @@ typedef struct { } SShowMgmt; typedef struct { - int32_t connId; SCacheObj *cache; } SProfileMgmt; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 49e9ccaba6..fe75e6c60c 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1128,6 +1128,8 @@ static int32_t mndProcessUseDbReq(SNodeMsg *pReq) { if (taosArrayGetSize(usedbRsp.pVgroupInfos) <= 0) { terrno = TSDB_CODE_MND_DB_NOT_EXIST; + } else { + code = 0; } } else { usedbRsp.vgVersion = usedbReq.vgVersion; diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 320671c332..b036b857e5 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -29,7 +29,7 @@ #define QUERY_SAVE_SIZE 20 typedef struct { - int32_t id; + uint32_t id; char user[TSDB_USER_LEN]; char app[TSDB_APP_NAME_LEN]; // app name that invokes taosc int64_t appStartTimeMs; // app start time @@ -39,15 +39,15 @@ typedef struct { int8_t killed; int64_t loginTimeMs; int64_t lastAccessTimeMs; - int32_t queryId; + uint64_t killId; int32_t numOfQueries; - SQueryDesc *pQueries; + SArray *pQueries; //SArray } SConnObj; static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, uint32_t ip, uint16_t port, int32_t pid, const char *app, int64_t startTime); static void mndFreeConn(SConnObj *pConn); -static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId); +static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId); static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn); static void *mndGetNextConn(SMnode *pMnode, SCacheIter *pIter); static void mndCancelGetNextConn(SMnode *pMnode, void *pIter); @@ -97,8 +97,9 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, uint32_t ip, ui const char *app, int64_t startTime) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; - int32_t connId = atomic_add_fetch_32(&pMgmt->connId, 1); - if (connId == 0) atomic_add_fetch_32(&pMgmt->connId, 1); + char connStr[255] = {0}; + int32_t len = snprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app); + int32_t connId = mndGenerateUid(connStr, len); if (startTime == 0) startTime = taosGetTimestampMs(); SConnObj connObj = {.id = connId, @@ -109,7 +110,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, uint32_t ip, ui .killed = 0, .loginTimeMs = taosGetTimestampMs(), .lastAccessTimeMs = 0, - .queryId = 0, + .killId = 0, .numOfQueries = 0, .pQueries = NULL}; @@ -124,35 +125,35 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, uint32_t ip, ui mError("conn:%d, failed to put into cache since %s, user:%s", connId, user, terrstr()); return NULL; } else { - mTrace("conn:%d, is created, data:%p user:%s", pConn->id, pConn, user); + mTrace("conn:%u, is created, data:%p user:%s", pConn->id, pConn, user); return pConn; } } static void mndFreeConn(SConnObj *pConn) { taosMemoryFreeClear(pConn->pQueries); - mTrace("conn:%d, is destroyed, data:%p", pConn->id, pConn); + mTrace("conn:%u, is destroyed, data:%p", pConn->id, pConn); } -static SConnObj *mndAcquireConn(SMnode *pMnode, int32_t connId) { +static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; - SConnObj *pConn = taosCacheAcquireByKey(pMgmt->cache, &connId, sizeof(int32_t)); + SConnObj *pConn = taosCacheAcquireByKey(pMgmt->cache, &connId, sizeof(connId)); if (pConn == NULL) { - mDebug("conn:%d, already destroyed", connId); + mDebug("conn:%u, already destroyed", connId); return NULL; } int32_t keepTime = tsShellActivityTimer * 3; pConn->lastAccessTimeMs = keepTime * 1000 + (uint64_t)taosGetTimestampMs(); - mTrace("conn:%d, acquired from cache, data:%p", pConn->id, pConn); + mTrace("conn:%u, acquired from cache, data:%p", pConn->id, pConn); return pConn; } static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn) { if (pConn == NULL) return; - mTrace("conn:%d, released from cache, data:%p", pConn->id, pConn); + mTrace("conn:%u, released from cache, data:%p", pConn->id, pConn); SProfileMgmt *pMgmt = &pMnode->profileMgmt; taosCacheRelease(pMgmt->cache, (void **)&pConn, false); @@ -217,6 +218,8 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) { goto CONN_OVER; } + mndAcquireConn(pMnode, pConn->id); + SConnectRsp connectRsp = {0}; connectRsp.acctId = pUser->acctId; connectRsp.superUser = pUser->superUser; @@ -236,7 +239,7 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) { pReq->rspLen = contLen; pReq->pRsp = pRsp; - mDebug("user:%s, login from %s, conn:%d, app:%s", pReq->user, ip, pConn->id, connReq.app); + mDebug("user:%s, login from %s:%d, conn:%u, app:%s", pReq->user, ip, pConn->port, pConn->id, connReq.app); code = 0; @@ -249,22 +252,13 @@ CONN_OVER: return code; } -static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) { - pConn->numOfQueries = 0; - int32_t numOfQueries = htonl(pReq->numOfQueries); +static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) { + taosArrayDestroyEx(pConn->pQueries, tFreeClientHbQueryDesc); - if (numOfQueries > 0) { - if (pConn->pQueries == NULL) { - pConn->pQueries = taosMemoryCalloc(sizeof(SQueryDesc), QUERY_SAVE_SIZE); - } - - pConn->numOfQueries = TMIN(QUERY_SAVE_SIZE, numOfQueries); - - int32_t saveSize = pConn->numOfQueries * sizeof(SQueryDesc); - if (saveSize > 0 && pConn->pQueries != NULL) { - memcpy(pConn->pQueries, pReq->pData, saveSize); - } - } + pConn->pQueries = pBasic->queryDesc; + pBasic->queryDesc = NULL; + + pConn->numOfQueries = pBasic->queryDesc ? taosArrayGetSize(pBasic->queryDesc) : 0; return TSDB_CODE_SUCCESS; } @@ -334,6 +328,111 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) { return NULL; } +static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHbReq *pHbReq, SClientHbBatchRsp *pBatchRsp) { + SProfileMgmt *pMgmt = &pMnode->profileMgmt; + SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = NULL, .query = NULL}; + + if (pHbReq->query) { + SQueryHbReqBasic *pBasic = pHbReq->query; + + SRpcConnInfo connInfo = {0}; + rpcGetConnInfo(pMsg->handle, &connInfo); + + SConnObj *pConn = mndAcquireConn(pMnode, pBasic->connId); + if (pConn == NULL) { + pConn = mndCreateConn(pMnode, connInfo.user, connInfo.clientIp, connInfo.clientPort, pBasic->pid, pBasic->app, 0); + if (pConn == NULL) { + mError("user:%s, conn:%u is freed and failed to create new since %s", connInfo.user, pBasic->connId, terrstr()); + return -1; + } else { + mDebug("user:%s, conn:%u is freed and create a new conn:%u", connInfo.user, pBasic->connId, pConn->id); + } + } else if (pConn->killed) { + mError("user:%s, conn:%u is already killed", connInfo.user, pConn->id); + mndReleaseConn(pMnode, pConn); + terrno = TSDB_CODE_MND_INVALID_CONNECTION; + return -1; + } + + SQueryHbRspBasic *rspBasic = taosMemoryCalloc(1, sizeof(SQueryHbRspBasic)); + if (rspBasic == NULL) { + mndReleaseConn(pMnode, pConn); + terrno = TSDB_CODE_OUT_OF_MEMORY; + mError("user:%s, conn:%u failed to process hb while since %s", pConn->user, pBasic->connId, terrstr()); + return -1; + } + + mndSaveQueryList(pConn, pBasic); + if (pConn->killed != 0) { + rspBasic->killConnection = 1; + } + + if (pConn->killId != 0) { + rspBasic->killRid = pConn->killId; + pConn->killId = 0; + } + + rspBasic->connId = pConn->id; + rspBasic->totalDnodes = 1; //TODO + rspBasic->onlineDnodes = 1; //TODO + mndGetMnodeEpSet(pMnode, &rspBasic->epSet); + mndReleaseConn(pMnode, pConn); + + hbRsp.query = rspBasic; + } + + int32_t kvNum = taosHashGetSize(pHbReq->info); + if (NULL == pHbReq->info || kvNum <= 0) { + taosArrayPush(pBatchRsp->rsps, &hbRsp); + return TSDB_CODE_SUCCESS; + } + + hbRsp.info = taosArrayInit(kvNum, sizeof(SKv)); + if (NULL == hbRsp.info) { + mError("taosArrayInit %d rsp kv failed", kvNum); + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + void *pIter = taosHashIterate(pHbReq->info, NULL); + while (pIter != NULL) { + SKv *kv = pIter; + + switch (kv->key) { + case HEARTBEAT_KEY_DBINFO: { + void *rspMsg = NULL; + int32_t rspLen = 0; + mndValidateDbInfo(pMnode, kv->value, kv->valueLen / sizeof(SDbVgVersion), &rspMsg, &rspLen); + if (rspMsg && rspLen > 0) { + SKv kv1 = {.key = HEARTBEAT_KEY_DBINFO, .valueLen = rspLen, .value = rspMsg}; + taosArrayPush(hbRsp.info, &kv1); + } + break; + } + case HEARTBEAT_KEY_STBINFO: { + void *rspMsg = NULL; + int32_t rspLen = 0; + mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableMetaVersion), &rspMsg, &rspLen); + if (rspMsg && rspLen > 0) { + SKv kv1 = {.key = HEARTBEAT_KEY_STBINFO, .valueLen = rspLen, .value = rspMsg}; + taosArrayPush(hbRsp.info, &kv1); + } + break; + } + default: + mError("invalid kv key:%d", kv->key); + hbRsp.status = TSDB_CODE_MND_APP_ERROR; + break; + } + + pIter = taosHashIterate(pHbReq->info, pIter); + } + + taosArrayPush(pBatchRsp->rsps, &hbRsp); + + return TSDB_CODE_SUCCESS; +} + static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { SMnode *pMnode = pReq->pNode; @@ -351,48 +450,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { for (int i = 0; i < sz; i++) { SClientHbReq *pHbReq = taosArrayGet(batchReq.reqs, i); if (pHbReq->connKey.hbType == HEARTBEAT_TYPE_QUERY) { - int32_t kvNum = taosHashGetSize(pHbReq->info); - if (NULL == pHbReq->info || kvNum <= 0) { - continue; - } - - SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = taosArrayInit(kvNum, sizeof(SKv))}; - - void *pIter = taosHashIterate(pHbReq->info, NULL); - while (pIter != NULL) { - SKv *kv = pIter; - - switch (kv->key) { - case HEARTBEAT_KEY_DBINFO: { - void *rspMsg = NULL; - int32_t rspLen = 0; - mndValidateDbInfo(pMnode, kv->value, kv->valueLen / sizeof(SDbVgVersion), &rspMsg, &rspLen); - if (rspMsg && rspLen > 0) { - SKv kv1 = {.key = HEARTBEAT_KEY_DBINFO, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv1); - } - break; - } - case HEARTBEAT_KEY_STBINFO: { - void *rspMsg = NULL; - int32_t rspLen = 0; - mndValidateStbInfo(pMnode, kv->value, kv->valueLen / sizeof(SSTableMetaVersion), &rspMsg, &rspLen); - if (rspMsg && rspLen > 0) { - SKv kv1 = {.key = HEARTBEAT_KEY_STBINFO, .valueLen = rspLen, .value = rspMsg}; - taosArrayPush(hbRsp.info, &kv1); - } - break; - } - default: - mError("invalid kv key:%d", kv->key); - hbRsp.status = TSDB_CODE_MND_APP_ERROR; - break; - } - - pIter = taosHashIterate(pHbReq->info, pIter); - } - - taosArrayPush(batchRsp.rsps, &hbRsp); + mndProcessQueryHeartBeat(pMnode, &pReq->rpcMsg, pHbReq, &batchRsp); } else if (pHbReq->connKey.hbType == HEARTBEAT_TYPE_MQ) { SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq); if (pRsp != NULL) { @@ -421,73 +479,8 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { taosArrayDestroy(batchRsp.rsps); pReq->rspLen = tlen; pReq->pRsp = buf; + return 0; - -#if 0 - SMnode *pMnode = pReq->pNode; - SProfileMgmt *pMgmt = &pMnode->profileMgmt; - - SHeartBeatReq *pHeartbeat = pReq->rpcMsg.pCont; - pHeartbeat->connId = htonl(pHeartbeat->connId); - pHeartbeat->pid = htonl(pHeartbeat->pid); - - SConnObj *pConn = mndAcquireConn(pMnode, pHeartbeat->connId); - if (pConn == NULL) { - pConn = mndCreateConn(pMnode, &info, pHeartbeat->pid, pHeartbeat->app, 0); - if (pConn == NULL) { - mError("user:%s, conn:%d is freed and failed to create new since %s", pReq->user, pHeartbeat->connId, terrstr()); - return -1; - } else { - mDebug("user:%s, conn:%d is freed and create a new conn:%d", pReq->user, pHeartbeat->connId, pConn->id); - } - } else if (pConn->killed) { - mError("user:%s, conn:%d is already killed", pReq->user, pConn->id); - terrno = TSDB_CODE_MND_INVALID_CONNECTION; - return -1; - } else { - if (pConn->ip != info.clientIp || pConn->port != info.clientPort /* || strcmp(pConn->user, info.user) != 0 */) { - char oldIpStr[40]; - char newIpStr[40]; - taosIpPort2String(pConn->ip, pConn->port, oldIpStr); - taosIpPort2String(info.clientIp, info.clientPort, newIpStr); - mError("conn:%d, incoming conn user:%s ip:%s, not match exist user:%s ip:%s", pConn->id, info.user, newIpStr, - pConn->user, oldIpStr); - - if (pMgmt->connId < pConn->id) pMgmt->connId = pConn->id + 1; - taosCacheRelease(pMgmt->cache, (void **)&pConn, false); - terrno = TSDB_CODE_MND_INVALID_CONNECTION; - return -1; - } - } - - SHeartBeatRsp *pRsp = rpcMallocCont(sizeof(SHeartBeatRsp)); - if (pRsp == NULL) { - mndReleaseConn(pMnode, pConn); - terrno = TSDB_CODE_OUT_OF_MEMORY; - mError("user:%s, conn:%d failed to process hb while since %s", pReq->user, pHeartbeat->connId, terrstr()); - return -1; - } - - mndSaveQueryStreamList(pConn, pHeartbeat); - if (pConn->killed != 0) { - pRsp->killConnection = 1; - } - - if (pConn->queryId != 0) { - pRsp->queryId = htonl(pConn->queryId); - pConn->queryId = 0; - } - - pRsp->connId = htonl(pConn->id); - pRsp->totalDnodes = htonl(1); - pRsp->onlineDnodes = htonl(1); - mndGetMnodeEpSet(pMnode, &pRsp->epSet); - mndReleaseConn(pMnode, pConn); - - pReq->contLen = sizeof(SConnectRsp); - pReq->pRsp = pRsp; - return 0; -#endif } static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) { @@ -518,7 +511,7 @@ static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) { return -1; } else { mInfo("connId:%d, queryId:%d is killed by user:%s", killReq.connId, killReq.queryId, pReq->user); - pConn->queryId = killReq.queryId; + pConn->killId = killReq.queryId; taosCacheRelease(pMgmt->cache, (void **)&pConn, false); return 0; } @@ -651,7 +644,7 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int cols = 0; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pConn->id; + *(uint32_t *)pWrite = pConn->id; cols++; pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; @@ -808,6 +801,7 @@ static int32_t mndGetQueryMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *p static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { SMnode *pMnode = pReq->pNode; int32_t numOfRows = 0; +#if 0 SConnObj *pConn = NULL; int32_t cols = 0; char *pWrite; @@ -905,6 +899,7 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow); pShow->numOfReads += numOfRows; +#endif return numOfRows; } @@ -917,4 +912,4 @@ static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter) { int32_t mndGetNumOfConnections(SMnode *pMnode) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; return taosCacheGetNumOfObj(pMgmt->cache); -} \ No newline at end of file +} diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index 62a96b6438..d1def1bef1 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -156,8 +156,8 @@ typedef struct SSchJob { int32_t levelNum; int32_t taskNum; void *transport; - SArray *nodeList; // qnode/vnode list, element is SQueryNodeAddr - SArray *levels; // Element is SQueryLevel, starting from 0. SArray + SArray *nodeList; // qnode/vnode list, SArray + SArray *levels; // starting from 0. SArray SNodeList *subPlans; // subplan pointer copied from DAG, no need to free it in scheduler int32_t levelIdx; diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 11f8e880a6..8dd7625325 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -2655,6 +2655,34 @@ _return: SCH_RET(code); } +int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub) { + int32_t code = 0; + SSchJob *pJob = schAcquireJob(job); + if (NULL == pJob) { + qDebug("acquire job from jobRef list failed, may not started or dropped, refId:%" PRIx64, job); + SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); + } + + if (pJob->status < JOB_TASK_STATUS_NOT_START || pJob->levelNum <= 0 || NULL == pJob->levels) { + qDebug("job not initialized or not executable job, refId:%" PRIx64, job); + SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); + } + + for (int32_t i = pJob->levelNum - 1; i >= 0; --i) { + SSchLevel *pLevel = taosArrayGet(pJob->levels, i); + + for (int32_t m = 0; m < pLevel->taskNum; ++m) { + SSchTask *pTask = taosArrayGet(pLevel->subTasks, m); + SQuerySubDesc subDesc = {.tid = pTask->taskId, .status = pTask->status}; + + taosArrayPush(pSub, &subDesc); + } + } + + return TSDB_CODE_SUCCESS; +} + + int32_t scheduleCancelJob(int64_t job) { SSchJob *pJob = schAcquireJob(job); if (NULL == pJob) { @@ -2672,7 +2700,7 @@ int32_t scheduleCancelJob(int64_t job) { void schedulerFreeJob(int64_t job) { SSchJob *pJob = schAcquireJob(job); if (NULL == pJob) { - qError("acquire job from jobRef list failed, may be dropped, refId:%" PRIx64, job); + qDebug("acquire job from jobRef list failed, may be dropped, refId:%" PRIx64, job); return; } diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index a74b26a386..4477a5cacd 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -303,6 +303,21 @@ void taosArrayClear(SArray* pArray) { pArray->size = 0; } +void taosArrayClearEx(SArray* pArray, void (*fp)(void*)) { + if (pArray == NULL) return; + if (fp == NULL) { + pArray->size = 0; + return; + } + + for (int32_t i = 0; i < pArray->size; ++i) { + fp(TARRAY_GET_ELEM(pArray, i)); + } + + pArray->size = 0; +} + + void* taosArrayDestroy(SArray* pArray) { if (pArray) { taosMemoryFree(pArray->pData); From 4766deb2992b6d2bc4f388b4fdb3298ef3291015 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 13 Apr 2022 10:48:09 +0800 Subject: [PATCH 02/48] feature/qnode --- source/dnode/mnode/impl/inc/mndPerfSchema.h | 45 +++++ source/dnode/mnode/impl/src/mndPerfSchema.c | 174 ++++++++++++++++++++ 2 files changed, 219 insertions(+) create mode 100644 source/dnode/mnode/impl/inc/mndPerfSchema.h create mode 100644 source/dnode/mnode/impl/src/mndPerfSchema.c diff --git a/source/dnode/mnode/impl/inc/mndPerfSchema.h b/source/dnode/mnode/impl/inc/mndPerfSchema.h new file mode 100644 index 0000000000..2c613e253c --- /dev/null +++ b/source/dnode/mnode/impl/inc/mndPerfSchema.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_MND_PERF_SCHEMA_H_ +#define _TD_MND_PERF_SCHEMA_H_ + +#include "mndInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SPerfsTableSchema { + char *name; + int32_t type; + int32_t bytes; +} SPerfsTableSchema; + +typedef struct SPerfsTableMeta { + char *name; + const SPerfsTableSchema *schema; + int32_t colNum; +} SPerfsTableMeta; + +int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp); +int32_t mndInitPerfs(SMnode *pMnode); +void mndCleanupPerfs(SMnode *pMnode); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MND_PERF_SCHEMA_H_*/ diff --git a/source/dnode/mnode/impl/src/mndPerfSchema.c b/source/dnode/mnode/impl/src/mndPerfSchema.c new file mode 100644 index 0000000000..38e9e79228 --- /dev/null +++ b/source/dnode/mnode/impl/src/mndPerfSchema.c @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "mndPerfSchema.h" +#include "mndInt.h" + +//!!!! Note: only APPEND columns in below tables, NO insert !!!! +static const SPerfsTableSchema connectionsSchema[] = { + {.name = "conn_id", .bytes = 4, .type = TSDB_DATA_TYPE_UINT}, + {.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "program", .bytes = TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "end_point", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "login_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "last_access", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, +}; +static const SPerfsTableSchema queriesSchema[] = { + {.name = "query_id", .bytes = 4, .type = TSDB_DATA_TYPE_UBIGINT}, + {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "user", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "fqdn", .bytes = TSDB_FQDN_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "exec_time", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "sub_queries", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "sub_query_info", .bytes = TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, +}; + +static const SPerfsTableSchema topicSchema[] = { + {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, + {.name = "sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "row_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, +}; + +static const SPerfsTableSchema consumerSchema[] = { + {.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "pid", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "status", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + // ep + // up time + // topics +}; + +static const SPerfsTableSchema subscribeSchema[] = { + {.name = "topic_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "group_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, + {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "client_id", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_BINARY}, +}; + +static const SPerfsTableMeta perfsMeta[] = { + {TSDB_PERFS_TABLE_CONNECTIONS, connectionsSchema, tListLen(connectionsSchema)}, + {TSDB_PERFS_TABLE_QUERIES, queriesSchema, tListLen(queriesSchema)}, + {TSDB_PERFS_TABLE_TOPICS, topicSchema, tListLen(topicSchema)}, + {TSDB_PERFS_TABLE_CONSUMERS, consumerSchema, tListLen(consumerSchema)}, + {TSDB_PERFS_TABLE_SUBSCRIBES, subscribeSchema, tListLen(subscribeSchema)}, +}; + +// connection/application/ +int32_t mndInitPerfsTableSchema(const SPerfsTableSchema *pSrc, int32_t colNum, SSchema **pDst) { + SSchema *schema = taosMemoryCalloc(colNum, sizeof(SSchema)); + if (NULL == schema) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < colNum; ++i) { + strcpy(schema[i].name, pSrc[i].name); + + schema[i].type = pSrc[i].type; + schema[i].colId = i + 1; + schema[i].bytes = pSrc[i].bytes; + } + + *pDst = schema; + return TSDB_CODE_SUCCESS; +} + +int32_t mndPerfsInitMeta(SHashObj *hash) { + STableMetaRsp meta = {0}; + + strcpy(meta.dbFName, TSDB_INFORMATION_SCHEMA_DB); + meta.tableType = TSDB_SYSTEM_TABLE; + meta.sversion = 1; + meta.tversion = 1; + + for (int32_t i = 0; i < tListLen(perfsMeta); ++i) { + strcpy(meta.tbName, perfsMeta[i].name); + meta.numOfColumns = perfsMeta[i].colNum; + + if (mndInitPerfsTableSchema(perfsMeta[i].schema, perfsMeta[i].colNum, &meta.pSchemas)) { + return -1; + } + + if (taosHashPut(hash, meta.tbName, strlen(meta.tbName), &meta, sizeof(meta))) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + } + + return TSDB_CODE_SUCCESS; +} + +int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) { + if (NULL == pMnode->perfsMeta) { + terrno = TSDB_CODE_MND_NOT_READY; + return -1; + } + + STableMetaRsp *meta = (STableMetaRsp *)taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName)); + if (NULL == meta) { + mError("invalid performance schema table name:%s", tbName); + terrno = TSDB_CODE_MND_INVALID_INFOS_TBL; + return -1; + } + + *pRsp = *meta; + + pRsp->pSchemas = taosMemoryCalloc(meta->numOfColumns, sizeof(SSchema)); + if (pRsp->pSchemas == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + pRsp->pSchemas = NULL; + return -1; + } + + memcpy(pRsp->pSchemas, meta->pSchemas, meta->numOfColumns * sizeof(SSchema)); + + return 0; +} + +int32_t mndInitPerfs(SMnode *pMnode) { + pMnode->perfsMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + if (pMnode->perfsMeta == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + return mndPerfsInitMeta(pMnode->perfsMeta); +} + +void mndCleanupPerfs(SMnode *pMnode) { + if (NULL == pMnode->perfsMeta) { + return; + } + + void *pIter = taosHashIterate(pMnode->perfsMeta, NULL); + while (pIter) { + STableMetaRsp *meta = (STableMetaRsp *)pIter; + + taosMemoryFreeClear(meta->pSchemas); + + pIter = taosHashIterate(pMnode->perfsMeta, pIter); + } + + taosHashCleanup(pMnode->perfsMeta); + pMnode->perfsMeta = NULL; +} + From 94b5031554a6bcd11e0f1354e44b77c0c2a34cc9 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 13 Apr 2022 10:48:26 +0800 Subject: [PATCH 03/48] feature/qnode --- include/util/tdef.h | 7 ++++++ source/client/inc/clientInt.h | 3 +-- source/dnode/mnode/impl/inc/mndInt.h | 5 ++++ source/dnode/mnode/impl/src/mndInfoSchema.c | 5 +--- source/dnode/mnode/impl/src/mndStb.c | 6 +++++ source/dnode/mnode/impl/src/mnode.c | 2 ++ source/libs/catalog/inc/catalogInt.h | 8 +++---- source/libs/catalog/src/catalog.c | 26 ++++++++++----------- tools/shell/src/shellEngine.c | 2 ++ 9 files changed, 41 insertions(+), 23 deletions(-) diff --git a/include/util/tdef.h b/include/util/tdef.h index 263c90c0f8..d66e555f8c 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -113,6 +113,13 @@ extern const int32_t TYPE_BYTES[15]; #define TSDB_INS_TABLE_BNODES "bnodes" #define TSDB_INS_TABLE_SNODES "snodes" +#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" +#define TSDB_PERFS_TABLE_CONNECTIONS "connections" +#define TSDB_PERFS_TABLE_QUERIES "queries" +#define TSDB_PERFS_TABLE_TOPICS "topics" +#define TSDB_PERFS_TABLE_CONSUMERS "consumers" +#define TSDB_PERFS_TABLE_SUBSCRIBES "subscribes" + #define TSDB_INDEX_TYPE_SMA "SMA" #define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT" diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 4ec01e5693..4e3299fd1b 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -43,8 +43,7 @@ extern "C" { } \ } while (0) -//#define HEARTBEAT_INTERVAL 1500 // ms -#define HEARTBEAT_INTERVAL 15000 // ms TODO +#define HEARTBEAT_INTERVAL 1500 // ms typedef struct SAppInstInfo SAppInstInfo; diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index ad42eebc1b..5c72e47cc4 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -38,6 +38,10 @@ extern "C" { #define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }} #define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }} +#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE) + typedef int32_t (*MndMsgFp)(SNodeMsg *pMsg); typedef int32_t (*MndInitFp)(SMnode *pMnode); typedef void (*MndCleanupFp)(SMnode *pMnode); @@ -118,6 +122,7 @@ typedef struct SMnode { STelemMgmt telemMgmt; SSyncMgmt syncMgmt; SHashObj *infosMeta; + SHashObj *perfsMeta; SGrantInfo grant; MndMsgFp msgFp[TDMT_MAX]; SMsgCb msgCb; diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index d60e7f5cf9..990f5fb70d 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -15,10 +15,7 @@ #define _DEFAULT_SOURCE #include "mndInfoSchema.h" - -#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE) -#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE) -#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#include "mndInt.h" //!!!! Note: only APPEND columns in below tables, NO insert !!!! static const SInfosTableSchema dnodesSchema[] = { diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index afcea6e732..e6c5aa030b 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -18,6 +18,7 @@ #include "mndDb.h" #include "mndDnode.h" #include "mndInfoSchema.h" +#include "mndPerfSchema.h" #include "mndMnode.h" #include "mndShow.h" #include "mndTrans.h" @@ -1516,6 +1517,11 @@ static int32_t mndProcessTableMetaReq(SNodeMsg *pReq) { if (mndBuildInsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { goto RETRIEVE_META_OVER; } + } else if (0 == strcmp(infoReq.dbFName, TSDB_PERFORMANCE_SCHEMA_DB)) { + mDebug("performance_schema table:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); + if (mndBuildPerfsTableSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { + goto RETRIEVE_META_OVER; + } } else { mDebug("stb:%s.%s, start to retrieve meta", infoReq.dbFName, infoReq.tbName); if (mndBuildStbSchema(pMnode, infoReq.dbFName, infoReq.tbName, &metaRsp) != 0) { diff --git a/source/dnode/mnode/impl/src/mnode.c b/source/dnode/mnode/impl/src/mnode.c index 5a1780530c..7d1905a53e 100644 --- a/source/dnode/mnode/impl/src/mnode.c +++ b/source/dnode/mnode/impl/src/mnode.c @@ -23,6 +23,7 @@ #include "mndDnode.h" #include "mndFunc.h" #include "mndInfoSchema.h" +#include "mndPerfSchema.h" #include "mndMnode.h" #include "mndOffset.h" #include "mndProfile.h" @@ -208,6 +209,7 @@ static int32_t mndInitSteps(SMnode *pMnode, bool deploy) { if (mndAllocStep(pMnode, "mnode-stb", mndInitStb, mndCleanupStb) != 0) return -1; if (mndAllocStep(pMnode, "mnode-stb", mndInitSma, mndCleanupSma) != 0) return -1; if (mndAllocStep(pMnode, "mnode-infos", mndInitInfos, mndCleanupInfos) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-perfs", mndInitPerfs, mndCleanupPerfs) != 0) return -1; if (mndAllocStep(pMnode, "mnode-db", mndInitDb, mndCleanupDb) != 0) return -1; if (mndAllocStep(pMnode, "mnode-func", mndInitFunc, mndCleanupFunc) != 0) return -1; if (deploy) { diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 09f51dc03e..8938084724 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -227,20 +227,20 @@ typedef struct SCtgAction { #define CTG_FLAG_STB 0x1 #define CTG_FLAG_NOT_STB 0x2 #define CTG_FLAG_UNKNOWN_STB 0x4 -#define CTG_FLAG_INF_DB 0x8 +#define CTG_FLAG_SYS_DB 0x8 #define CTG_FLAG_FORCE_UPDATE 0x10 #define CTG_FLAG_IS_STB(_flag) ((_flag) & CTG_FLAG_STB) #define CTG_FLAG_IS_NOT_STB(_flag) ((_flag) & CTG_FLAG_NOT_STB) #define CTG_FLAG_IS_UNKNOWN_STB(_flag) ((_flag) & CTG_FLAG_UNKNOWN_STB) -#define CTG_FLAG_IS_INF_DB(_flag) ((_flag) & CTG_FLAG_INF_DB) +#define CTG_FLAG_IS_SYS_DB(_flag) ((_flag) & CTG_FLAG_SYS_DB) #define CTG_FLAG_IS_FORCE_UPDATE(_flag) ((_flag) & CTG_FLAG_FORCE_UPDATE) -#define CTG_FLAG_SET_INF_DB(_flag) ((_flag) |= CTG_FLAG_INF_DB) +#define CTG_FLAG_SET_SYS_DB(_flag) ((_flag) |= CTG_FLAG_SYS_DB) #define CTG_FLAG_SET_STB(_flag, tbType) do { (_flag) |= ((tbType) == TSDB_SUPER_TABLE) ? CTG_FLAG_STB : ((tbType) > TSDB_SUPER_TABLE ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB); } while (0) #define CTG_FLAG_MAKE_STB(_isStb) (((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB)) #define CTG_FLAG_MATCH_STB(_flag, tbType) (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE)) -#define CTG_IS_INF_DBNAME(_dbname) ((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) +#define CTG_IS_SYS_DBNAME(_dbname) (((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) || ((*(_dbname) == 'p') && (0 == strcmp(_dbname, TSDB_PERFORMANCE_SCHEMA_DB)))) #define CTG_META_SIZE(pMeta) (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema)) diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 2aa858fe06..21e0be40a4 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -217,7 +217,7 @@ int32_t ctgPushRmDBMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId) } char *p = strchr(dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { dbFName = p + 1; } @@ -304,7 +304,7 @@ int32_t ctgPushUpdateVgMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t d } char *p = strchr(dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { dbFName = p + 1; } @@ -336,7 +336,7 @@ int32_t ctgPushUpdateTblMsgInQueue(SCatalog* pCtg, STableMetaOutput *output, boo } char *p = strchr(output->dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { memmove(output->dbFName, p + 1, strlen(p + 1)); } @@ -410,7 +410,7 @@ void ctgWReleaseVgInfo(SCtgDBCache *dbCache) { int32_t ctgAcquireDBCacheImpl(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache, bool acquire) { char *p = strchr(dbFName, '.'); - if (p && CTG_IS_INF_DBNAME(p + 1)) { + if (p && CTG_IS_SYS_DBNAME(p + 1)) { dbFName = p + 1; } @@ -688,7 +688,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable } char dbFName[TSDB_DB_FNAME_LEN] = {0}; - if (CTG_FLAG_IS_INF_DB(flag)) { + if (CTG_FLAG_IS_SYS_DB(flag)) { strcpy(dbFName, pTableName->dbname); } else { tNameGetFullDbName(pTableName, dbFName); @@ -1721,7 +1721,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, SVgroupInfo vgroupInfo = {0}; int32_t code = 0; - if (!CTG_FLAG_IS_INF_DB(flag)) { + if (!CTG_FLAG_IS_SYS_DB(flag)) { CTG_ERR_RET(catalogGetTableHashVgroup(pCtg, pTrans, pMgmtEps, pTableName, &vgroupInfo)); } @@ -1732,7 +1732,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } - if (CTG_FLAG_IS_INF_DB(flag)) { + if (CTG_FLAG_IS_SYS_DB(flag)) { ctgDebug("will refresh tbmeta, supposed in information_schema, tbName:%s", tNameGetTableName(pTableName)); CTG_ERR_JRET(ctgGetTableMetaFromMnodeImpl(pCtg, pTrans, pMgmtEps, (char *)pTableName->dbname, (char *)pTableName->tname, output)); @@ -1820,8 +1820,8 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons uint64_t suid = 0; STableMetaOutput *output = NULL; - if (CTG_IS_INF_DBNAME(pTableName->dbname)) { - CTG_FLAG_SET_INF_DB(flag); + if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { + CTG_FLAG_SET_SYS_DB(flag); } CTG_ERR_RET(ctgGetTableMetaFromCache(pCtg, pTableName, pTableMeta, &inCache, flag, &dbId)); @@ -1829,7 +1829,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons int32_t tbType = 0; if (inCache) { - if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_INF_DB(flag)))) { + if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_SYS_DB(flag)))) { goto _return; } @@ -1885,7 +1885,7 @@ _return: if (CTG_TABLE_NOT_EXIST(code) && inCache) { char dbFName[TSDB_DB_FNAME_LEN] = {0}; - if (CTG_FLAG_IS_INF_DB(flag)) { + if (CTG_FLAG_IS_SYS_DB(flag)) { strcpy(dbFName, pTableName->dbname); } else { tNameGetFullDbName(pTableName, dbFName); @@ -2633,7 +2633,7 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - if (CTG_IS_INF_DBNAME(pTableName->dbname)) { + if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname); CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -2666,7 +2666,7 @@ _return: int32_t catalogGetTableHashVgroup(SCatalog *pCtg, void *pTrans, const SEpSet *pMgmtEps, const SName *pTableName, SVgroupInfo *pVgroup) { CTG_API_ENTER(); - if (CTG_IS_INF_DBNAME(pTableName->dbname)) { + if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname); CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index b89d517ad3..d883362636 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -344,6 +344,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { atomic_store_64(&result, 0); freeResultWithRid(oresult); + taos_free_result(pSql); + return; } From d57ecd97b0d61130240661ffa8285e44a9527301 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 13 Apr 2022 17:52:26 +0800 Subject: [PATCH 04/48] stmt --- source/client/inc/clientStmt.h | 48 ++++++++ source/client/src/clientMain.c | 179 ++++++++++++++++++++--------- source/client/src/clientStmt.c | 6 + source/libs/parser/src/parInsert.c | 19 ++- 4 files changed, 196 insertions(+), 56 deletions(-) create mode 100644 source/client/inc/clientStmt.h create mode 100644 source/client/src/clientStmt.c diff --git a/source/client/inc/clientStmt.h b/source/client/inc/clientStmt.h new file mode 100644 index 0000000000..e358ce37aa --- /dev/null +++ b/source/client/inc/clientStmt.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_CLIENTSTMT_H +#define TDENGINE_CLIENTSTMT_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + STMT_TYPE_INSERT = 1, + STMT_TYPE_MULTI_INSERT, + STMT_TYPE_QUERY, +} STMT_TYPE; + +typedef struct STscStmt { + STMT_TYPE type; + int16_t last; + STscObj* taos; + SSqlObj* pSql; + SMultiTbStmt mtb; + SNormalStmt normal; + + int numOfRows; +} STscStmt; + +#define SCH_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) +#define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) +#define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) + +#ifdef __cplusplus +} +#endif + +#endif // TDENGINE_CLIENTSTMT_H diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 2f5c1b69a4..e9d1ca0d24 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -559,76 +559,149 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { } TAOS_STMT *taos_stmt_init(TAOS *taos) { - // TODO - return NULL; + if (taos == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return NULL; + } + + return stmtInit(taos); } int taos_stmt_close(TAOS_STMT *stmt) { - // TODO - return -1; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtClose(stmt); } int taos_stmt_execute(TAOS_STMT *stmt) { - // TODO - return -1; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtExec(stmt); } char *taos_stmt_errstr(TAOS_STMT *stmt) { - // TODO - return NULL; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return NULL; + } + + return stmtErrstr(stmt); } int taos_stmt_affected_rows(TAOS_STMT *stmt) { - // TODO - return -1; + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return 0; + } + + return stmtAffectedRows(stmt); } +int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { + if (stmt == NULL || bind == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtBind(stmt, bind); +} + +int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { + if (stmt == NULL || sql == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtPrepare(stmt, sql, length); +} + +int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { + if (stmt == NULL || name == NULL || tags == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtSetTbNameTags(stmt, name, tags); +} + +int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) { + if (stmt == NULL || name == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtSetTbNameTags(stmt, name, NULL); +} + +int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { + if (stmt == NULL || insert == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtIsInsert(stmt, insert); +} + +int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { + if (stmt == NULL || nums == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtGetParamNum(stmt, nums); +} + +int taos_stmt_add_batch(TAOS_STMT *stmt) { + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtAddBatch(stmt); +} + +TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) { + if (stmt == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtUseResult(stmt); +} + +int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { + if (stmt == NULL || bind == NULL) { + tscError("NULL parameter for %s", __FUNC__); + terrno = TSDB_CODE_INVALID_PARA; + return terrno; + } + + return stmtBindBatch(stmt, bind); +} + + TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) { // TODO return NULL; } -int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { - // TODO - return -1; -} -int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { - // TODO - return -1; -} - -int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { - // TODO - return -1; -} - -int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) { - // TODO - return -1; -} - -int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { - // TODO - return -1; -} - -int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { - // TODO - return -1; -} - -int taos_stmt_add_batch(TAOS_STMT *stmt) { - // TODO - return -1; -} - -TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) { - // TODO - return NULL; -} - -int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { - // TODO - return -1; -} diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c new file mode 100644 index 0000000000..8ac7a8238d --- /dev/null +++ b/source/client/src/clientStmt.c @@ -0,0 +1,6 @@ + +#include "clientInt.h" +#include "clientLog.h" +#include "tdef.h" + + diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 435ab317e6..9a0483cd33 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -223,11 +223,15 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar return code; } -static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { +static int32_t getTableMetaImpl(SInsertParseContext* pCxt, SToken* pTname, bool isStb) { SParseContext* pBasicCtx = pCxt->pComCxt; SName name = {0}; createSName(&name, pTname, pBasicCtx, &pCxt->msg); - CHECK_CODE(catalogGetTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta)); + if (isStb) { + CHECK_CODE(catalogGetSTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta)); + } else { + CHECK_CODE(catalogGetTableMeta(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &pCxt->pTableMeta)); + } SVgroupInfo vg; CHECK_CODE(catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &vg)); CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg))); @@ -235,6 +239,15 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { return TSDB_CODE_SUCCESS; } +static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { + return getTableMetaImpl(pCxt, pTname, false); +} + +static int32_t getSTableMeta(SInsertParseContext* pCxt, SToken* pTname) { + return getTableMetaImpl(pCxt, pTname, true); +} + + static int32_t findCol(SToken* pColname, int32_t start, int32_t end, SSchema* pSchema) { while (start < end) { if (strlen(pSchema[start].name) == pColname->n && strncmp(pColname->z, pSchema[start].name, pColname->n) == 0) { @@ -811,7 +824,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken) SToken sToken; // pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...) NEXT_TOKEN(pCxt->pSql, sToken); - CHECK_CODE(getTableMeta(pCxt, &sToken)); + CHECK_CODE(getSTableMeta(pCxt, &sToken)); if (TSDB_SUPER_TABLE != pCxt->pTableMeta->tableType) { return buildInvalidOperationMsg(&pCxt->msg, "create table only from super table is allowed"); } From 3bc9550233db0700caa30b1eb861894341736444 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 13 Apr 2022 19:33:07 +0800 Subject: [PATCH 05/48] feature/qnode --- source/client/src/clientEnv.c | 9 +---- source/client/src/clientImpl.c | 7 ++++ source/client/src/clientStmt.c | 49 ++++++++++++++++++++++++++ source/libs/nodes/src/nodesUtilFuncs.c | 2 +- 4 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 source/client/src/clientStmt.c diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 20a3b5c549..7f413bdabc 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -189,14 +189,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty tsem_init(&pRequest->body.rspSem, 0, 0); registerRequest(pRequest); - - if (taosHashPut(pObj->pRequests, &pRequest->self, sizeof(pRequest->self), &pRequest->self, sizeof(pRequest->self))) { - destroyRequest(pRequest); - releaseTscObj(pObj->id); - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; - return NULL; - } - + return pRequest; } diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index c22ed0bd60..0252dfe634 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -132,6 +132,13 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj* (*pRequest)->sqlstr[sqlLen] = 0; (*pRequest)->sqlLen = sqlLen; + if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self, sizeof((*pRequest)->self))) { + destroyRequest(*pRequest); + *pRequest = NULL; + tscError("put request to request hash failed"); + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + tscDebugL("0x%" PRIx64 " SQL: %s, reqId:0x%" PRIx64, (*pRequest)->self, (*pRequest)->sqlstr, (*pRequest)->requestId); return TSDB_CODE_SUCCESS; } diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c new file mode 100644 index 0000000000..c371375bdd --- /dev/null +++ b/source/client/src/clientStmt.c @@ -0,0 +1,49 @@ + +#include "clientInt.h" +#include "clientLog.h" +#include "tdef.h" + +TAOS_STMT *stmtInit(TAOS *taos) { + STscObj* pObj = (STscObj*)taos; + STscStmt* pStmt = NULL; + +#if 0 + pStmt = taosMemoryCalloc(1, sizeof(STscStmt)); + if (pStmt == NULL) { + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscError("failed to allocate memory for statement"); + return NULL; + } + pStmt->taos = pObj; + + SSqlObj* pSql = calloc(1, sizeof(SSqlObj)); + + if (pSql == NULL) { + free(pStmt); + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscError("failed to allocate memory for statement"); + return NULL; + } + + if (TSDB_CODE_SUCCESS != tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE)) { + free(pSql); + free(pStmt); + terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + tscError("failed to malloc payload buffer"); + return NULL; + } + + tsem_init(&pSql->rspSem, 0, 0); + pSql->signature = pSql; + pSql->pTscObj = pObj; + pSql->maxRetry = TSDB_MAX_REPLICA; + pStmt->pSql = pSql; + pStmt->last = STMT_INIT; + pStmt->numOfRows = 0; + registerSqlObj(pSql); +#endif + + return pStmt; +} + + diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 1c565ddd37..772aa71eb2 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -1202,7 +1202,7 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) { case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_VARBINARY: - pVal->pz = pNode->datum.p; + pVal->pz = pNode->datum.p + VARSTR_HEADER_SIZE; break; case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_DECIMAL: From a823535f277cc9f32fc63ccae92ecd59f02cc282 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 13 Apr 2022 19:57:21 +0800 Subject: [PATCH 06/48] stmt --- source/client/inc/clientStmt.h | 33 ++++++++++++++++------ source/client/src/clientMain.c | 31 +++++++++++---------- source/client/src/clientStmt.c | 51 ++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 24 deletions(-) diff --git a/source/client/inc/clientStmt.h b/source/client/inc/clientStmt.h index e358ce37aa..c29361758d 100644 --- a/source/client/inc/clientStmt.h +++ b/source/client/inc/clientStmt.h @@ -28,18 +28,33 @@ typedef enum { typedef struct STscStmt { STMT_TYPE type; - int16_t last; - STscObj* taos; - SSqlObj* pSql; - SMultiTbStmt mtb; - SNormalStmt normal; + //int16_t last; + //STscObj* taos; + //SSqlObj* pSql; + //SMultiTbStmt mtb; + //SNormalStmt normal; - int numOfRows; + //int numOfRows; } STscStmt; -#define SCH_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) -#define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) -#define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) +#define STMT_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) +#define STMT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) +#define STMT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) + +TAOS_STMT *stmtInit(TAOS *taos); +int stmtClose(TAOS_STMT *stmt); +int stmtExec(TAOS_STMT *stmt); +char *stmtErrstr(TAOS_STMT *stmt); +int stmtAffectedRows(TAOS_STMT *stmt); +int stmtBind(TAOS_STMT *stmt, TAOS_BIND *bind); +int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length); +int stmtSetTbNameTags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags); +int stmtIsInsert(TAOS_STMT *stmt, int *insert); +int stmtGetParamNum(TAOS_STMT *stmt, int *nums); +int stmtAddBatch(TAOS_STMT *stmt); +TAOS_RES *stmtUseResult(TAOS_STMT *stmt); +int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind); + #ifdef __cplusplus } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index e9d1ca0d24..84f9c7ac30 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -16,6 +16,7 @@ #include "catalog.h" #include "scheduler.h" #include "clientInt.h" +#include "clientStmt.h" #include "clientLog.h" #include "os.h" #include "query.h" @@ -560,7 +561,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { TAOS_STMT *taos_stmt_init(TAOS *taos) { if (taos == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return NULL; } @@ -570,7 +571,7 @@ TAOS_STMT *taos_stmt_init(TAOS *taos) { int taos_stmt_close(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -580,7 +581,7 @@ int taos_stmt_close(TAOS_STMT *stmt) { int taos_stmt_execute(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -590,7 +591,7 @@ int taos_stmt_execute(TAOS_STMT *stmt) { char *taos_stmt_errstr(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return NULL; } @@ -600,7 +601,7 @@ char *taos_stmt_errstr(TAOS_STMT *stmt) { int taos_stmt_affected_rows(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return 0; } @@ -610,7 +611,7 @@ int taos_stmt_affected_rows(TAOS_STMT *stmt) { int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { if (stmt == NULL || bind == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -620,7 +621,7 @@ int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) { int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { if (stmt == NULL || sql == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -630,7 +631,7 @@ int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { if (stmt == NULL || name == NULL || tags == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -640,7 +641,7 @@ int taos_stmt_set_tbname_tags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) { if (stmt == NULL || name == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -650,7 +651,7 @@ int taos_stmt_set_tbname(TAOS_STMT *stmt, const char *name) { int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { if (stmt == NULL || insert == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -660,7 +661,7 @@ int taos_stmt_is_insert(TAOS_STMT *stmt, int *insert) { int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { if (stmt == NULL || nums == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -670,7 +671,7 @@ int taos_stmt_num_params(TAOS_STMT *stmt, int *nums) { int taos_stmt_add_batch(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -680,9 +681,9 @@ int taos_stmt_add_batch(TAOS_STMT *stmt) { TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) { if (stmt == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; - return terrno; + return NULL; } return stmtUseResult(stmt); @@ -690,7 +691,7 @@ TAOS_RES *taos_stmt_use_result(TAOS_STMT *stmt) { int taos_stmt_bind_param_batch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { if (stmt == NULL || bind == NULL) { - tscError("NULL parameter for %s", __FUNC__); + tscError("NULL parameter for %s", __FUNCTION__); terrno = TSDB_CODE_INVALID_PARA; return terrno; } diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 2d8a489381..8c4cff9251 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -1,6 +1,7 @@ #include "clientInt.h" #include "clientLog.h" +#include "clientStmt.h" #include "tdef.h" TAOS_STMT *stmtInit(TAOS *taos) { @@ -46,3 +47,53 @@ TAOS_STMT *stmtInit(TAOS *taos) { return pStmt; } +int stmtClose(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +int stmtExec(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +char *stmtErrstr(TAOS_STMT *stmt) { + return NULL; +} + +int stmtAffectedRows(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +int stmtBind(TAOS_STMT *stmt, TAOS_BIND *bind) { + return TSDB_CODE_SUCCESS; +} + +int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length) { + return TSDB_CODE_SUCCESS; +} + +int stmtSetTbNameTags(TAOS_STMT *stmt, const char *name, TAOS_BIND *tags) { + return TSDB_CODE_SUCCESS; +} + +int stmtIsInsert(TAOS_STMT *stmt, int *insert) { + return TSDB_CODE_SUCCESS; +} + +int stmtGetParamNum(TAOS_STMT *stmt, int *nums) { + return TSDB_CODE_SUCCESS; +} + +int stmtAddBatch(TAOS_STMT *stmt) { + return TSDB_CODE_SUCCESS; +} + +TAOS_RES *stmtUseResult(TAOS_STMT *stmt) { + return NULL; +} + +int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind) { + return TSDB_CODE_SUCCESS; +} + + + From d90dbe6c6e51be05d3e9ea8e90d9cadfa2311d6a Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 14 Apr 2022 11:48:59 +0800 Subject: [PATCH 07/48] disable hb --- source/client/src/clientHb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 642ba46336..4f716ba431 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -648,7 +648,7 @@ int hbMgrInit() { hbMgrInitHandle(); // init backgroud thread - hbCreateThread(); + //hbCreateThread(); return 0; } From 7d92aaaad3dfac5e04fb9baad6938b5b796218d1 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 14 Apr 2022 15:28:43 +0800 Subject: [PATCH 08/48] feature/qnode --- source/dnode/mnode/impl/src/mndProfile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index be2c311dbf..2055512e82 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -898,6 +898,7 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i } pShow->numOfRows += numOfRows; +#endif return numOfRows; } From 21a5e4f9b9ffdf80b926d820a15e172468a11bad Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 14 Apr 2022 19:54:59 +0800 Subject: [PATCH 09/48] fix hb issue --- include/common/tmsg.h | 18 +++++++------- source/client/inc/clientInt.h | 11 +++------ source/client/src/clientEnv.c | 2 +- source/client/src/clientHb.c | 24 +++++++++---------- source/common/src/tmsg.c | 3 +-- source/dnode/mnode/impl/src/mndProfile.c | 6 ++--- .../dnode/mnode/impl/test/profile/profile.cpp | 2 +- 7 files changed, 29 insertions(+), 37 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index ea7905f21a..ee81ed2042 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -70,13 +70,11 @@ typedef uint16_t tmsg_t; #define TSDB_IE_TYPE_DNODE_EXT 6 #define TSDB_IE_TYPE_DNODE_STATE 7 -typedef enum { - HEARTBEAT_TYPE_MQ = 0, - HEARTBEAT_TYPE_QUERY, - // types can be added here - // - HEARTBEAT_TYPE_MAX -} EHbType; +enum { + CONN_TYPE__QUERY = 1, + CONN_TYPE__TMQ, + CONN_TYPE__MAX +}; enum { HEARTBEAT_KEY_DBINFO = 1, @@ -1649,7 +1647,7 @@ typedef struct { typedef struct { int64_t tscRid; - int32_t hbType; + int8_t connType; } SClientHbKey; typedef struct { @@ -1796,13 +1794,13 @@ static FORCE_INLINE int32_t tDecodeSKv(SCoder* pDecoder, SKv* pKv) { static FORCE_INLINE int32_t tEncodeSClientHbKey(SCoder* pEncoder, const SClientHbKey* pKey) { if (tEncodeI64(pEncoder, pKey->tscRid) < 0) return -1; - if (tEncodeI32(pEncoder, pKey->hbType) < 0) return -1; + if (tEncodeI8(pEncoder, pKey->connType) < 0) return -1; return 0; } static FORCE_INLINE int32_t tDecodeSClientHbKey(SCoder* pDecoder, SClientHbKey* pKey) { if (tDecodeI64(pDecoder, &pKey->tscRid) < 0) return -1; - if (tDecodeI32(pDecoder, &pKey->hbType) < 0) return -1; + if (tDecodeI8(pDecoder, &pKey->connType) < 0) return -1; return 0; } diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 61a3303c3f..79d6b2fdf1 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -45,11 +45,6 @@ extern "C" { #define HEARTBEAT_INTERVAL 1500 // ms -enum { - CONN_TYPE__QUERY = 1, - CONN_TYPE__TMQ, -}; - typedef struct SAppInstInfo SAppInstInfo; typedef struct { @@ -84,8 +79,8 @@ typedef struct { TdThread thread; TdThreadMutex lock; // used when app init and cleanup SArray* appHbMgrs; // SArray one for each cluster - FHbReqHandle reqHandle[HEARTBEAT_TYPE_MAX]; - FHbRspHandle rspHandle[HEARTBEAT_TYPE_MAX]; + FHbReqHandle reqHandle[CONN_TYPE__MAX]; + FHbRspHandle rspHandle[CONN_TYPE__MAX]; } SClientHbMgr; typedef struct SQueryExecMetric { @@ -307,7 +302,7 @@ SAppHbMgr* appHbMgrInit(SAppInstInfo* pAppInstInfo, char* key); void appHbMgrCleanup(void); // conn level -int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int32_t hbType); +int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType); void hbDeregisterConn(SAppHbMgr* pAppHbMgr, SClientHbKey connKey); int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* value, int32_t keyLen, int32_t valueLen); diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 7f413bdabc..969b18f067 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -122,7 +122,7 @@ void closeAllRequests(SHashObj *pRequests) { void destroyTscObj(void *pObj) { STscObj *pTscObj = pObj; - SClientHbKey connKey = {.tscRid = pTscObj->id, .hbType = pTscObj->connType}; + SClientHbKey connKey = {.tscRid = pTscObj->id, .connType = pTscObj->connType}; hbDeregisterConn(pTscObj->pAppInfo->pAppHbMgr, connKey); atomic_sub_fetch_64(&pTscObj->pAppInfo->numOfConns, 1); closeAllRequests(pTscObj->pRequests); diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 4bd8a89a38..e65a3017d6 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -110,7 +110,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) { SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pRsp->connKey, sizeof(SClientHbKey)); if (NULL == info) { - tscWarn("fail to get connInfo, may be dropped, refId:%" PRIx64 ", type:%d", pRsp->connKey.tscRid, pRsp->connKey.hbType); + tscWarn("fail to get connInfo, may be dropped, refId:%" PRIx64 ", type:%d", pRsp->connKey.tscRid, pRsp->connKey.connType); return TSDB_CODE_SUCCESS; } @@ -224,7 +224,7 @@ static int32_t hbAsyncCallBack(void *param, const SDataBuf *pMsg, int32_t code) for (int32_t i = 0; i < rspNum; ++i) { SClientHbRsp *rsp = taosArrayGet(pRsp.rsps, i); - code = (*clientHbMgr.rspHandle[rsp->connKey.hbType])((*pInst)->pAppHbMgr, rsp); + code = (*clientHbMgr.rspHandle[rsp->connKey.connType])((*pInst)->pAppHbMgr, rsp); if (code) { break; } @@ -420,11 +420,11 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req } void hbMgrInitMqHbHandle() { - clientHbMgr.reqHandle[HEARTBEAT_TYPE_QUERY] = hbQueryHbReqHandle; - clientHbMgr.reqHandle[HEARTBEAT_TYPE_MQ] = hbMqHbReqHandle; + clientHbMgr.reqHandle[CONN_TYPE__QUERY] = hbQueryHbReqHandle; + clientHbMgr.reqHandle[CONN_TYPE__TMQ] = hbMqHbReqHandle; - clientHbMgr.rspHandle[HEARTBEAT_TYPE_QUERY] = hbQueryHbRspHandle; - clientHbMgr.rspHandle[HEARTBEAT_TYPE_MQ] = hbMqHbRspHandle; + clientHbMgr.rspHandle[CONN_TYPE__QUERY] = hbQueryHbRspHandle; + clientHbMgr.rspHandle[CONN_TYPE__TMQ] = hbMqHbRspHandle; } static FORCE_INLINE void hbMgrInitHandle() { @@ -458,7 +458,7 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) { SHbConnInfo *info = taosHashGet(pAppHbMgr->connInfo, &pOneReq->connKey, sizeof(SClientHbKey)); if (info) { - code = (*clientHbMgr.reqHandle[pOneReq->connKey.hbType])(&pOneReq->connKey, info->param, pOneReq); + code = (*clientHbMgr.reqHandle[pOneReq->connKey.connType])(&pOneReq->connKey, info->param, pOneReq); if (code) { pIter = taosHashIterate(pAppHbMgr->activeInfo, pIter); continue; @@ -692,22 +692,22 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo * return 0; } -int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int32_t hbType) { +int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, int8_t connType) { SClientHbKey connKey = { .tscRid = tscRefId, - .hbType = hbType, + .connType = connType, }; SHbConnInfo info = {0}; - switch (hbType) { - case HEARTBEAT_TYPE_QUERY: { + switch (connType) { + case CONN_TYPE__QUERY: { int64_t *pClusterId = taosMemoryMalloc(sizeof(int64_t)); *pClusterId = clusterId; info.param = pClusterId; return hbRegisterConnImpl(pAppHbMgr, connKey, &info); } - case HEARTBEAT_TYPE_MQ: { + case CONN_TYPE__TMQ: { return 0; } default: diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index a9a28b4879..d78d89ab50 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -3424,5 +3424,4 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) { taosMemoryFreeClear(pReq->sql); - taosMemoryFreeClear(pReq->ast); -} + taosMemoryFreeClear(pReq->ast) \ No newline at end of file diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 96698e80bb..f169fb4b21 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -343,7 +343,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb SConnObj *pConn = mndAcquireConn(pMnode, pBasic->connId); if (pConn == NULL) { - pConn = mndCreateConn(pMnode, connInfo.user, connInfo.clientIp, connInfo.clientPort, pBasic->pid, pBasic->app, 0); + pConn = mndCreateConn(pMnode, connInfo.user, CONN_TYPE__QUERY, connInfo.clientIp, connInfo.clientPort, pBasic->pid, pBasic->app, 0); if (pConn == NULL) { mError("user:%s, conn:%u is freed and failed to create new since %s", connInfo.user, pBasic->connId, terrstr()); return -1; @@ -451,9 +451,9 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) { int32_t sz = taosArrayGetSize(batchReq.reqs); for (int i = 0; i < sz; i++) { SClientHbReq *pHbReq = taosArrayGet(batchReq.reqs, i); - if (pHbReq->connKey.hbType == HEARTBEAT_TYPE_QUERY) { + if (pHbReq->connKey.connType == CONN_TYPE__QUERY) { mndProcessQueryHeartBeat(pMnode, &pReq->rpcMsg, pHbReq, &batchRsp); - } else if (pHbReq->connKey.hbType == HEARTBEAT_TYPE_MQ) { + } else if (pHbReq->connKey.connType == CONN_TYPE__TMQ) { SClientHbRsp *pRsp = mndMqHbBuildRsp(pMnode, pHbReq); if (pRsp != NULL) { taosArrayPush(batchRsp.rsps, pRsp); diff --git a/source/dnode/mnode/impl/test/profile/profile.cpp b/source/dnode/mnode/impl/test/profile/profile.cpp index 14b31e5282..b06c98466b 100644 --- a/source/dnode/mnode/impl/test/profile/profile.cpp +++ b/source/dnode/mnode/impl/test/profile/profile.cpp @@ -99,7 +99,7 @@ TEST_F(MndTestProfile, 04_HeartBeatMsg) { SClientHbBatchReq batchReq = {0}; batchReq.reqs = taosArrayInit(0, sizeof(SClientHbReq)); SClientHbReq req = {0}; - req.connKey = {.connId = 123, .hbType = HEARTBEAT_TYPE_MQ}; + req.connKey = {.connId = 123, .hbType = CONN_TYPE__TMQ}; req.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK); SKv kv = {0}; kv.key = 123; From 6dae667c1d16e2e4024602ef511afab425ef02dd Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Thu, 14 Apr 2022 20:13:11 +0800 Subject: [PATCH 10/48] fix hb issue --- source/common/src/tmsg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index d78d89ab50..99f173501b 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -134,7 +134,7 @@ void *taosDecodeSEpSet(void *buf, SEpSet *pEp) { static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq) { if (tEncodeSClientHbKey(pEncoder, &pReq->connKey) < 0) return -1; - if (pReq->connKey.hbType == HEARTBEAT_TYPE_QUERY) { + if (pReq->connKey.connType == CONN_TYPE__QUERY) { int32_t queryNum = 0; if (pReq->query) { queryNum = 1; @@ -185,7 +185,7 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) { if (tDecodeSClientHbKey(pDecoder, &pReq->connKey) < 0) return -1; - if (pReq->connKey.hbType == HEARTBEAT_TYPE_QUERY) { + if (pReq->connKey.connType == CONN_TYPE__QUERY) { int32_t queryNum = 0; if (tDecodeI32(pDecoder, &queryNum) < 0) return -1; if (queryNum) { @@ -3424,4 +3424,5 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) { taosMemoryFreeClear(pReq->sql); - taosMemoryFreeClear(pReq->ast) \ No newline at end of file + taosMemoryFreeClear(pReq->ast); +} From e048acfe76a734449b9141b40d5faa360d00a905 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 14 Apr 2022 12:36:35 +0000 Subject: [PATCH 11/48] refact vnode --- source/dnode/vnode/CMakeLists.txt | 2 +- source/dnode/vnode/inc/vnode.h | 3 ++- .../src/vnd/{vnodeMain.c => vnodeOpen.c} | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) rename source/dnode/vnode/src/vnd/{vnodeMain.c => vnodeOpen.c} (86%) diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 3ab007e3a2..f7a3f2f109 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -10,7 +10,7 @@ target_sources( "src/vnd/vnodeCfg.c" "src/vnd/vnodeCommit.c" "src/vnd/vnodeInt.c" - "src/vnd/vnodeMain.c" + "src/vnd/vnodeOpen.c" "src/vnd/vnodeQuery.c" "src/vnd/vnodeStateMgr.c" "src/vnd/vnodeWrite.c" diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 76fc09ca1d..0b23a42ec9 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -44,9 +44,10 @@ typedef struct SVnodeCfg SVnodeCfg; int vnodeInit(); void vnodeCleanup(); +int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs); +void vnodeDestroy(const char *path); SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg); void vnodeClose(SVnode *pVnode); -void vnodeDestroy(const char *path); void vnodePreprocessWriteReqs(SVnode *pVnode, SArray *pMsgs); int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int vnodeProcessCMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); diff --git a/source/dnode/vnode/src/vnd/vnodeMain.c b/source/dnode/vnode/src/vnd/vnodeOpen.c similarity index 86% rename from source/dnode/vnode/src/vnd/vnodeMain.c rename to source/dnode/vnode/src/vnd/vnodeOpen.c index 2fd848a39d..f208857762 100644 --- a/source/dnode/vnode/src/vnd/vnodeMain.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -20,6 +20,29 @@ static void vnodeFree(SVnode *pVnode); static int vnodeOpenImpl(SVnode *pVnode); static void vnodeCloseImpl(SVnode *pVnode); +int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { +#if 0 + char dir[TSDB_FILENAME_LEN]; + // TODO: check if directory exists + + // check config + if (vnodeCheckCfg(pCfg) < 0) { + vError("vgId: %d failed to create vnode since: %s", pCfg->vgId, tstrerror(terrno)); + return -1; + } + + // create vnode env + tfsMkdir(pTfs, path); + snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); + if (vnodeSaveCfg(dir, pCfg) < 0) { + vError("vgId: %d failed to save vnode config since %s", pCfg->vgId, tstrerror(terrno)); + return -1; + } + +#endif + return 0; +} + SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) { SVnode *pVnode = NULL; From 2b6c03bc24e147a25c58a1e39f127e2419516497 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 14 Apr 2022 12:44:25 +0000 Subject: [PATCH 12/48] more --- source/dnode/vnode/inc/vnode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 0b23a42ec9..25c6ffc1ad 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -42,7 +42,7 @@ typedef struct STsdbCfg STsdbCfg; // todo: remove typedef struct STqCfg STqCfg; // todo: remove typedef struct SVnodeCfg SVnodeCfg; -int vnodeInit(); +int vnodeInit(int nthreads); void vnodeCleanup(); int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs); void vnodeDestroy(const char *path); From ca3ce404af8c2c2e090353e5dd94ea33ace84b7a Mon Sep 17 00:00:00 2001 From: Ganlin Zhao <36554565+glzhao89@users.noreply.github.com> Date: Wed, 13 Apr 2022 12:38:57 +0800 Subject: [PATCH 13/48] feat(query): support now()/today() function in select clause TD-14243 --- include/libs/scalar/scalar.h | 2 + source/libs/function/src/builtins.c | 33 +- source/libs/parser/inc/parAst.h | 1 + source/libs/parser/inc/sql.y | 7 +- source/libs/parser/src/parAstCreater.c | 33 + source/libs/parser/src/sql.c | 2037 ++++++++++++------------ source/libs/scalar/src/sclfunc.c | 16 + 7 files changed, 1102 insertions(+), 1027 deletions(-) diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index 10b4866a96..49af10cd2c 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -78,6 +78,8 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); +int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); +int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); bool getTimePseudoFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 27067fc966..5480e48cdf 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -433,6 +433,26 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = timeDiffFunction, .finalizeFunc = NULL }, + { + .name = "now", + .type = FUNCTION_TYPE_NOW, + .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, + .checkFunc = checkAndGetResultType, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = nowFunction, + .finalizeFunc = NULL + }, + { + .name = "today", + .type = FUNCTION_TYPE_TODAY, + .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, + .checkFunc = checkAndGetResultType, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = todayFunction, + .finalizeFunc = NULL + }, { .name = "_rowts", .type = FUNCTION_TYPE_ROWTS, @@ -503,16 +523,6 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = winDurFunction, .finalizeFunc = NULL }, - { - .name = "now", - .type = FUNCTION_TYPE_NOW, - .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, - .checkFunc = checkAndGetResultType, - .getEnvFunc = getTimePseudoFuncEnv, - .initFunc = NULL, - .sprocessFunc = winDurFunction, - .finalizeFunc = NULL - } }; const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFuncDefinition)); @@ -672,7 +682,8 @@ int32_t checkAndGetResultType(SFunctionNode* pFunc) { } case FUNCTION_TYPE_NOW: - // todo + case FUNCTION_TYPE_TODAY: + pFunc->node.resType = (SDataType) { .bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; break; default: ASSERT(0); // to found the fault ASAP. diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index e781014216..f097631e08 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -93,6 +93,7 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight); SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight); SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList); +SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName); SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList); SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2); SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTableName, SToken* pTableAlias); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 12ae5819b4..5301436899 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -503,6 +503,8 @@ column_name(A) ::= NK_ID(B). function_name(A) ::= NK_ID(B). { A = B; } function_name(A) ::= FIRST(B). { A = B; } function_name(A) ::= LAST(B). { A = B; } +function_name(A) ::= NOW(B). { A = B; } +function_name(A) ::= TODAY(B). { A = B; } %type table_alias { SToken } %destructor table_alias { } @@ -535,6 +537,7 @@ expression(A) ::= pseudo_column(B). expression(A) ::= column_reference(B). { A = B; } expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); } expression(A) ::= function_name(B) NK_LP NK_STAR(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, createNodeList(pCxt, createColumnNode(pCxt, NULL, &C)))); } +expression(A) ::= function_name(B) NK_LP NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNodeNoParam(pCxt, &B)); } //for CAST function CAST(expr AS type_name) expression(A) ::= function_name(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { SNodeList *p = createNodeList(pCxt, releaseRawExprNode(pCxt, C)); @@ -587,8 +590,8 @@ expression_list(A) ::= expression_list(B) NK_COMMA expression(C). column_reference(A) ::= column_name(B). { A = createRawExprNode(pCxt, &B, createColumnNode(pCxt, NULL, &B)); } column_reference(A) ::= table_name(B) NK_DOT column_name(C). { A = createRawExprNodeExt(pCxt, &B, &C, createColumnNode(pCxt, &B, &C)); } -pseudo_column(A) ::= NOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } -pseudo_column(A) ::= TODAY(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +//pseudo_column(A) ::= NOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +//pseudo_column(A) ::= TODAY(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= ROWTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= TBNAME(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } pseudo_column(A) ::= QSTARTTS(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index a14053ada7..cd6469c084 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -367,6 +367,39 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod return (SNode*)func; } +SNode* createFunctionNodeNoParam(SAstCreateContext* pCxt, const SToken* pFuncName) { + SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + CHECK_OUT_OF_MEM(func); + char buf[64] = {0}; + + int32_t dataType; + switch (pFuncName->type) { + case TK_NOW: { + int64_t ts = taosGetTimestamp(TSDB_TIME_PRECISION_MILLI); + snprintf(buf, sizeof(buf), "%"PRId64, ts); + dataType = TSDB_DATA_TYPE_BIGINT; + break; + } + case TK_TODAY: { + int64_t ts = taosGetTimestampToday(TSDB_TIME_PRECISION_MILLI); + snprintf(buf, sizeof(buf), "%"PRId64, ts); + dataType = TSDB_DATA_TYPE_BIGINT; + break; + } + //case TK_TIMEZONE: { + // strncpy(buf, tsTimezoneStr, strlen(tsTimezoneStr)); + // dataType = TSDB_DATA_TYPE_BINARY; + // break; + //} + } + SToken token = {.type = pFuncName->type, .n = strlen(buf), .z = buf}; + + SNodeList *pParameterList = createNodeList(pCxt, createValueNode(pCxt, dataType, &token)); + strncpy(func->functionName, pFuncName->z, pFuncName->n); + func->pParameterList = pParameterList; + return (SNode*)func; +} + SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList) { SNodeListNode* list = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); CHECK_OUT_OF_MEM(list); diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index b1f8a24a83..a57142939a 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -133,17 +133,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYNSTATE 548 -#define YYNRULE 411 -#define YYNRULE_WITH_ACTION 411 +#define YYNRULE 412 +#define YYNRULE_WITH_ACTION 412 #define YYNTOKEN 209 #define YY_MAX_SHIFT 547 -#define YY_MIN_SHIFTREDUCE 808 -#define YY_MAX_SHIFTREDUCE 1218 -#define YY_ERROR_ACTION 1219 -#define YY_ACCEPT_ACTION 1220 -#define YY_NO_ACTION 1221 -#define YY_MIN_REDUCE 1222 -#define YY_MAX_REDUCE 1632 +#define YY_MIN_SHIFTREDUCE 809 +#define YY_MAX_SHIFTREDUCE 1220 +#define YY_ERROR_ACTION 1221 +#define YY_ACCEPT_ACTION 1222 +#define YY_NO_ACTION 1223 +#define YY_MIN_REDUCE 1224 +#define YY_MAX_REDUCE 1635 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -210,319 +210,320 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1539) +#define YY_ACTTAB_COUNT (1543) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 450, 257, 1483, 269, 25, 194, 1432, 117, 122, 1234, - /* 10 */ 312, 1331, 30, 28, 1479, 1486, 306, 1499, 1483, 1382, - /* 20 */ 266, 462, 1053, 21, 1075, 32, 31, 29, 27, 26, - /* 30 */ 1479, 1485, 23, 32, 31, 29, 27, 26, 1051, 274, - /* 40 */ 238, 1516, 32, 31, 29, 27, 26, 1611, 446, 1073, - /* 50 */ 11, 30, 28, 1161, 348, 406, 1483, 1058, 449, 266, - /* 60 */ 131, 1053, 1470, 1320, 1609, 30, 28, 434, 1479, 1485, - /* 70 */ 430, 9, 8, 266, 1, 1053, 463, 1051, 68, 1500, - /* 80 */ 1501, 1505, 1550, 540, 539, 72, 240, 1546, 1175, 11, - /* 90 */ 1499, 1051, 369, 424, 450, 100, 1058, 544, 1611, 407, - /* 100 */ 1433, 1342, 1261, 11, 32, 31, 29, 27, 26, 1052, - /* 110 */ 1058, 131, 348, 1, 1516, 1609, 32, 31, 29, 27, - /* 120 */ 26, 433, 118, 1389, 384, 277, 1300, 1, 98, 256, - /* 130 */ 1611, 449, 1423, 1425, 1387, 1470, 544, 432, 127, 1557, - /* 140 */ 1558, 270, 1562, 131, 498, 1137, 1054, 1609, 1052, 115, - /* 150 */ 544, 69, 1500, 1501, 1505, 1550, 845, 1344, 844, 259, - /* 160 */ 1546, 126, 1052, 1057, 1077, 1078, 1104, 1105, 1106, 1107, - /* 170 */ 1108, 1109, 1110, 1111, 1112, 164, 846, 381, 380, 372, - /* 180 */ 1578, 462, 1564, 1220, 84, 1054, 132, 83, 82, 81, - /* 190 */ 80, 79, 78, 77, 76, 75, 29, 27, 26, 1054, - /* 200 */ 1561, 374, 1057, 1077, 1078, 1104, 1105, 1106, 1107, 1108, - /* 210 */ 1109, 1110, 1111, 1112, 1319, 132, 1057, 1077, 1078, 1104, - /* 220 */ 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1318, 30, - /* 230 */ 28, 547, 305, 1564, 304, 12, 282, 266, 383, 1053, - /* 240 */ 377, 896, 132, 1215, 382, 213, 462, 97, 95, 378, - /* 250 */ 376, 1560, 379, 115, 536, 1051, 532, 528, 524, 212, - /* 260 */ 898, 1345, 32, 31, 29, 27, 26, 1611, 30, 28, - /* 270 */ 448, 1499, 463, 132, 1058, 209, 266, 498, 1053, 494, - /* 280 */ 131, 310, 30, 28, 1609, 66, 52, 1076, 206, 1074, - /* 290 */ 266, 7, 1053, 1333, 1051, 1516, 65, 1342, 1516, 96, - /* 300 */ 12, 496, 433, 1245, 334, 446, 463, 1337, 1051, 489, - /* 310 */ 101, 1214, 449, 1058, 544, 311, 1470, 1334, 459, 438, - /* 320 */ 493, 492, 491, 1185, 490, 1092, 1052, 1058, 513, 511, - /* 330 */ 7, 1342, 69, 1500, 1501, 1505, 1550, 423, 1470, 395, - /* 340 */ 259, 1546, 126, 1274, 7, 1222, 412, 132, 1470, 171, - /* 350 */ 141, 140, 393, 544, 190, 417, 1183, 1184, 1186, 1187, - /* 360 */ 413, 1577, 500, 1054, 1037, 1052, 168, 544, 1244, 93, - /* 370 */ 92, 91, 90, 89, 88, 87, 86, 85, 1327, 1052, - /* 380 */ 1057, 1077, 1078, 1104, 1105, 1106, 1107, 1108, 1109, 1110, - /* 390 */ 1111, 1112, 1079, 430, 1389, 383, 52, 377, 1611, 1329, - /* 400 */ 271, 382, 1054, 132, 97, 1387, 378, 376, 1243, 379, - /* 410 */ 1242, 1610, 405, 1470, 1241, 1609, 1054, 1338, 100, 1057, - /* 420 */ 1077, 1078, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, - /* 430 */ 1112, 1077, 1078, 1057, 1077, 1078, 1104, 1105, 1106, 1107, - /* 440 */ 1108, 1109, 1110, 1111, 1112, 430, 30, 28, 237, 420, - /* 450 */ 1073, 98, 439, 1470, 266, 1470, 1053, 327, 59, 1470, - /* 460 */ 339, 128, 1557, 1558, 1420, 1562, 1080, 1160, 397, 340, - /* 470 */ 100, 139, 1051, 32, 31, 29, 27, 26, 437, 1335, - /* 480 */ 934, 486, 485, 484, 938, 483, 940, 941, 482, 943, - /* 490 */ 479, 1058, 949, 476, 951, 952, 473, 470, 1223, 1611, - /* 500 */ 1569, 1156, 1564, 98, 425, 421, 9, 8, 1, 463, - /* 510 */ 189, 241, 131, 129, 1557, 1558, 1609, 1562, 319, 84, - /* 520 */ 1559, 1240, 83, 82, 81, 80, 79, 78, 77, 76, - /* 530 */ 75, 544, 216, 1325, 1342, 1372, 1092, 32, 31, 29, - /* 540 */ 27, 26, 338, 1052, 1124, 333, 332, 331, 330, 329, - /* 550 */ 1239, 326, 325, 324, 323, 322, 318, 317, 316, 315, - /* 560 */ 314, 313, 1271, 137, 116, 463, 1470, 1238, 501, 222, - /* 570 */ 1314, 1389, 1389, 6, 320, 32, 31, 29, 27, 26, - /* 580 */ 1054, 220, 1424, 1388, 175, 1168, 169, 447, 1237, 50, - /* 590 */ 1342, 1075, 49, 1125, 142, 1470, 488, 1057, 1077, 1078, - /* 600 */ 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1235, - /* 610 */ 1236, 1129, 1470, 241, 520, 519, 518, 517, 281, 1233, - /* 620 */ 516, 515, 514, 102, 509, 508, 507, 506, 505, 504, - /* 630 */ 503, 502, 108, 1470, 1232, 1499, 24, 264, 1119, 1120, - /* 640 */ 1121, 1122, 1123, 1127, 1128, 463, 1124, 463, 1231, 463, - /* 650 */ 1159, 844, 276, 463, 72, 1470, 347, 67, 1339, 1516, - /* 660 */ 115, 375, 460, 114, 1470, 279, 446, 367, 1344, 1256, - /* 670 */ 1342, 870, 1342, 115, 1342, 463, 449, 436, 1342, 1470, - /* 680 */ 1470, 1344, 1230, 1229, 461, 48, 47, 309, 1499, 136, - /* 690 */ 871, 386, 463, 1470, 303, 1125, 119, 1500, 1501, 1505, - /* 700 */ 1342, 208, 246, 297, 295, 1389, 291, 287, 133, 1301, - /* 710 */ 512, 278, 1516, 1129, 300, 1156, 1387, 1342, 299, 446, - /* 720 */ 157, 1053, 463, 155, 1499, 1228, 1227, 1470, 1470, 449, - /* 730 */ 445, 280, 132, 1470, 435, 1624, 1126, 1051, 24, 264, - /* 740 */ 1119, 1120, 1121, 1122, 1123, 1127, 1128, 1342, 1516, 69, - /* 750 */ 1500, 1501, 1505, 1550, 1130, 446, 1058, 259, 1546, 1623, - /* 760 */ 1499, 1459, 1226, 152, 1225, 449, 125, 191, 1584, 1470, - /* 770 */ 1470, 1470, 365, 343, 361, 357, 353, 151, 159, 22, - /* 780 */ 161, 158, 418, 160, 1516, 69, 1500, 1501, 1505, 1550, - /* 790 */ 1254, 446, 441, 259, 1546, 1623, 544, 289, 1217, 1218, - /* 800 */ 1383, 449, 250, 53, 1607, 1470, 149, 1470, 1052, 1470, - /* 810 */ 1499, 163, 389, 106, 162, 44, 178, 409, 404, 1182, - /* 820 */ 180, 69, 1500, 1501, 1505, 1550, 1490, 184, 164, 259, - /* 830 */ 1546, 1623, 372, 366, 1516, 33, 1580, 1499, 1488, 1131, - /* 840 */ 1568, 446, 431, 1116, 251, 1054, 249, 248, 1061, 371, - /* 850 */ 1517, 449, 1499, 33, 374, 1470, 193, 1088, 1073, 1060, - /* 860 */ 434, 1516, 1057, 148, 2, 121, 33, 145, 446, 284, - /* 870 */ 1020, 228, 1500, 1501, 1505, 288, 1516, 197, 449, 1499, - /* 880 */ 245, 199, 1470, 446, 143, 94, 273, 272, 104, 455, - /* 890 */ 896, 1611, 205, 449, 247, 1029, 1066, 1470, 70, 1500, - /* 900 */ 1501, 1505, 1550, 1516, 131, 321, 1549, 1546, 1609, 214, - /* 910 */ 446, 1422, 1059, 70, 1500, 1501, 1505, 1550, 64, 1064, - /* 920 */ 449, 444, 1546, 430, 1470, 106, 328, 442, 61, 927, - /* 930 */ 1063, 1058, 44, 468, 104, 138, 922, 955, 959, 336, - /* 940 */ 70, 1500, 1501, 1505, 1550, 335, 105, 337, 100, 1547, - /* 950 */ 965, 1084, 341, 106, 104, 1499, 342, 964, 107, 1083, - /* 960 */ 144, 345, 344, 1082, 346, 349, 147, 434, 51, 150, - /* 970 */ 1081, 464, 368, 370, 1332, 154, 373, 1328, 74, 1516, - /* 980 */ 399, 98, 1499, 1062, 400, 401, 446, 255, 408, 156, - /* 990 */ 1499, 187, 1557, 429, 170, 428, 449, 173, 1611, 109, - /* 1000 */ 1470, 110, 1330, 265, 1326, 111, 1516, 112, 1080, 411, - /* 1010 */ 419, 131, 1591, 446, 1516, 1609, 229, 1500, 1501, 1505, - /* 1020 */ 1067, 446, 398, 449, 410, 453, 1058, 1470, 1581, 416, - /* 1030 */ 414, 449, 176, 179, 1499, 1470, 5, 1070, 1590, 415, - /* 1040 */ 258, 422, 427, 233, 1500, 1501, 1505, 4, 99, 1079, - /* 1050 */ 1571, 232, 1500, 1501, 1505, 185, 183, 1156, 1516, 124, - /* 1060 */ 1565, 34, 443, 260, 17, 446, 1431, 1532, 1499, 186, - /* 1070 */ 440, 1430, 456, 457, 60, 449, 1499, 451, 458, 1470, - /* 1080 */ 452, 1499, 268, 426, 201, 203, 1343, 466, 58, 221, - /* 1090 */ 1626, 1315, 1516, 211, 192, 119, 1500, 1501, 1505, 446, - /* 1100 */ 1516, 1608, 215, 495, 217, 1516, 543, 446, 223, 449, - /* 1110 */ 40, 1464, 446, 1470, 224, 219, 263, 449, 1463, 283, - /* 1120 */ 1460, 1470, 449, 1499, 267, 285, 1470, 1047, 1499, 233, - /* 1130 */ 1500, 1501, 1505, 388, 1625, 286, 1499, 233, 1500, 1501, - /* 1140 */ 1505, 1048, 225, 1500, 1501, 1505, 290, 1516, 396, 1458, - /* 1150 */ 134, 294, 1516, 292, 446, 293, 1457, 296, 1456, 446, - /* 1160 */ 1516, 298, 166, 1447, 449, 391, 135, 446, 1470, 449, - /* 1170 */ 385, 301, 302, 1470, 1317, 1441, 165, 449, 1032, 1031, - /* 1180 */ 1499, 1470, 1440, 307, 231, 1500, 1501, 1505, 308, 234, - /* 1190 */ 1500, 1501, 1505, 1439, 1438, 1499, 1003, 226, 1500, 1501, - /* 1200 */ 1505, 1415, 42, 1414, 1516, 41, 1499, 1413, 1412, 1411, - /* 1210 */ 1410, 446, 1409, 1408, 1407, 1406, 1405, 1404, 1403, 1516, - /* 1220 */ 1402, 449, 1401, 1400, 103, 1470, 446, 1399, 1398, 1397, - /* 1230 */ 1516, 1499, 1396, 1395, 1394, 209, 449, 446, 1393, 494, - /* 1240 */ 1470, 235, 1500, 1501, 1505, 1392, 1005, 449, 1391, 1390, - /* 1250 */ 1273, 1470, 1455, 1449, 1437, 1516, 227, 1500, 1501, 1505, - /* 1260 */ 1428, 496, 446, 1321, 146, 1499, 1272, 236, 1500, 1501, - /* 1270 */ 1505, 1270, 449, 350, 352, 351, 1470, 863, 1499, 1268, - /* 1280 */ 493, 492, 491, 356, 490, 354, 1266, 355, 1264, 1516, - /* 1290 */ 1253, 359, 1513, 1500, 1501, 1505, 446, 358, 1252, 360, - /* 1300 */ 362, 363, 1516, 1249, 364, 1323, 449, 972, 73, 446, - /* 1310 */ 1470, 153, 1499, 512, 970, 1322, 895, 510, 894, 449, - /* 1320 */ 1499, 893, 892, 1470, 1262, 1499, 1512, 1500, 1501, 1505, - /* 1330 */ 252, 889, 888, 1257, 253, 387, 1516, 1255, 254, 243, - /* 1340 */ 1500, 1501, 1505, 446, 1516, 390, 1248, 392, 1247, 1516, - /* 1350 */ 394, 446, 71, 449, 1454, 167, 446, 1470, 1039, 1448, - /* 1360 */ 402, 449, 113, 1436, 1435, 1470, 449, 1499, 1427, 54, - /* 1370 */ 1470, 123, 1499, 1511, 1500, 1501, 1505, 172, 14, 43, - /* 1380 */ 3, 244, 1500, 1501, 1505, 33, 242, 1500, 1501, 1505, - /* 1390 */ 38, 1516, 177, 1181, 15, 403, 1516, 120, 446, 1488, - /* 1400 */ 174, 181, 37, 446, 19, 56, 1174, 182, 449, 55, - /* 1410 */ 20, 1203, 1470, 449, 36, 1153, 1152, 1470, 16, 1208, - /* 1420 */ 1202, 35, 261, 1207, 1206, 262, 8, 13, 239, 1500, - /* 1430 */ 1501, 1505, 1090, 230, 1500, 1501, 1505, 188, 130, 1117, - /* 1440 */ 1089, 195, 196, 18, 1426, 1179, 198, 454, 10, 200, - /* 1450 */ 45, 202, 57, 1068, 204, 61, 956, 39, 467, 275, - /* 1460 */ 1487, 471, 469, 207, 465, 953, 472, 474, 950, 475, - /* 1470 */ 477, 944, 478, 480, 942, 933, 481, 62, 967, 948, - /* 1480 */ 46, 63, 961, 963, 487, 861, 497, 902, 947, 499, - /* 1490 */ 946, 877, 884, 945, 883, 882, 210, 881, 899, 880, - /* 1500 */ 879, 878, 897, 874, 873, 872, 869, 1269, 868, 966, - /* 1510 */ 867, 866, 521, 522, 523, 1267, 525, 526, 527, 1265, - /* 1520 */ 529, 530, 531, 1263, 533, 534, 535, 1251, 537, 538, - /* 1530 */ 1250, 1246, 541, 542, 1221, 1055, 218, 545, 546, + /* 0 */ 117, 1222, 1236, 1391, 450, 312, 1485, 269, 216, 256, + /* 10 */ 1434, 1374, 30, 28, 1389, 21, 306, 1503, 1481, 1488, + /* 20 */ 266, 501, 1054, 1316, 1074, 32, 31, 29, 27, 26, + /* 30 */ 32, 31, 29, 27, 26, 238, 1077, 437, 1052, 257, + /* 40 */ 1333, 1521, 32, 31, 29, 27, 26, 1614, 433, 1329, + /* 50 */ 11, 30, 28, 1163, 282, 270, 1485, 1059, 449, 266, + /* 60 */ 131, 1054, 1472, 115, 1612, 30, 28, 448, 1481, 1487, + /* 70 */ 1503, 1346, 462, 266, 1, 1054, 277, 1052, 69, 1504, + /* 80 */ 1505, 1510, 1553, 1425, 1427, 1614, 259, 1549, 126, 11, + /* 90 */ 1263, 1052, 1224, 1177, 1521, 118, 1059, 544, 131, 1302, + /* 100 */ 190, 433, 1612, 25, 194, 1096, 413, 1580, 274, 1053, + /* 110 */ 1059, 449, 384, 1, 348, 1472, 93, 92, 91, 90, + /* 120 */ 89, 88, 87, 86, 85, 1485, 12, 7, 1093, 395, + /* 130 */ 52, 69, 1504, 1505, 1510, 1553, 544, 1481, 1487, 259, + /* 140 */ 1549, 126, 393, 96, 152, 1422, 1055, 125, 1053, 250, + /* 150 */ 544, 1339, 139, 365, 462, 361, 357, 353, 151, 305, + /* 160 */ 1581, 304, 1053, 1058, 1078, 1079, 1080, 1081, 1108, 1109, + /* 170 */ 1110, 1111, 1112, 1113, 1114, 164, 29, 27, 26, 372, + /* 180 */ 1078, 1079, 1080, 1081, 53, 1055, 132, 149, 6, 463, + /* 190 */ 132, 251, 132, 249, 248, 438, 371, 397, 310, 1055, + /* 200 */ 132, 374, 1058, 1078, 1079, 1080, 1081, 1108, 1109, 1110, + /* 210 */ 1111, 1112, 1113, 1114, 1344, 1322, 1058, 1078, 1079, 1080, + /* 220 */ 1081, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1614, 30, + /* 230 */ 28, 32, 31, 29, 27, 26, 436, 266, 132, 1054, + /* 240 */ 1614, 131, 30, 28, 148, 1612, 121, 463, 145, 237, + /* 250 */ 266, 1074, 1054, 1613, 1503, 1052, 72, 1612, 327, 1076, + /* 260 */ 388, 339, 1521, 369, 348, 143, 1162, 11, 1052, 446, + /* 270 */ 340, 1391, 1344, 450, 1059, 396, 498, 271, 1521, 1435, + /* 280 */ 30, 28, 1389, 123, 463, 446, 1320, 1059, 266, 166, + /* 290 */ 1054, 1, 391, 72, 1384, 449, 383, 385, 377, 1472, + /* 300 */ 375, 423, 382, 165, 7, 97, 1052, 378, 376, 1344, + /* 310 */ 379, 463, 463, 463, 544, 70, 1504, 1505, 1510, 1553, + /* 320 */ 311, 319, 320, 1552, 1549, 1059, 1053, 544, 439, 42, + /* 330 */ 1158, 846, 41, 845, 406, 498, 1344, 1344, 1344, 1053, + /* 340 */ 164, 512, 7, 338, 372, 300, 333, 332, 331, 330, + /* 350 */ 329, 847, 326, 325, 324, 323, 322, 318, 317, 316, + /* 360 */ 315, 314, 313, 1055, 84, 544, 374, 83, 82, 81, + /* 370 */ 80, 79, 78, 77, 76, 75, 1055, 1053, 407, 137, + /* 380 */ 1058, 1078, 1079, 1080, 1081, 1108, 1109, 1110, 1111, 1112, + /* 390 */ 1113, 1114, 897, 1058, 1078, 1079, 1080, 1081, 1108, 1109, + /* 400 */ 1110, 1111, 1112, 1113, 1114, 50, 540, 539, 49, 1614, + /* 410 */ 424, 899, 276, 279, 1055, 1075, 132, 30, 28, 1391, + /* 420 */ 115, 115, 131, 9, 8, 266, 1612, 1054, 1346, 1346, + /* 430 */ 1426, 1058, 1078, 1079, 1080, 1081, 1108, 1109, 1110, 1111, + /* 440 */ 1112, 1113, 1114, 1052, 32, 31, 29, 27, 26, 1161, + /* 450 */ 1335, 935, 486, 485, 484, 939, 483, 941, 942, 482, + /* 460 */ 944, 479, 1059, 950, 476, 952, 953, 473, 470, 32, + /* 470 */ 31, 29, 27, 26, 23, 65, 489, 52, 1054, 1, + /* 480 */ 1273, 463, 241, 462, 32, 31, 29, 27, 26, 101, + /* 490 */ 460, 381, 380, 500, 1052, 1472, 1336, 1139, 1340, 116, + /* 500 */ 463, 463, 544, 463, 222, 1082, 1344, 1096, 334, 347, + /* 510 */ 208, 420, 1341, 1059, 1053, 1126, 220, 513, 511, 441, + /* 520 */ 32, 31, 29, 27, 26, 1344, 1344, 1187, 1344, 142, + /* 530 */ 9, 8, 520, 519, 518, 517, 281, 12, 516, 515, + /* 540 */ 514, 102, 509, 508, 507, 506, 505, 504, 503, 502, + /* 550 */ 108, 1055, 1247, 544, 141, 140, 1246, 1331, 241, 417, + /* 560 */ 1185, 1186, 1188, 1189, 1127, 1053, 425, 421, 1058, 1078, + /* 570 */ 1079, 1080, 1081, 1108, 1109, 1110, 1111, 1112, 1113, 1114, + /* 580 */ 430, 1245, 1131, 32, 31, 29, 27, 26, 1244, 1391, + /* 590 */ 1083, 1126, 67, 1572, 1158, 278, 1217, 1472, 1567, 1567, + /* 600 */ 1389, 1472, 1055, 1219, 1220, 100, 1243, 24, 264, 1121, + /* 610 */ 1122, 1123, 1124, 1125, 1129, 1130, 1564, 1563, 1242, 1058, + /* 620 */ 48, 47, 309, 189, 136, 1241, 1472, 1237, 1567, 303, + /* 630 */ 106, 1503, 59, 1472, 409, 463, 463, 246, 98, 295, + /* 640 */ 1127, 291, 287, 133, 461, 280, 1562, 432, 127, 1560, + /* 650 */ 1561, 1472, 1565, 1337, 442, 1521, 1128, 1240, 1131, 845, + /* 660 */ 1344, 1344, 446, 1472, 1216, 1239, 1238, 132, 445, 115, + /* 670 */ 1472, 1235, 449, 1503, 1132, 367, 1472, 1347, 1234, 1233, + /* 680 */ 1327, 434, 430, 24, 264, 1121, 1122, 1123, 1124, 1125, + /* 690 */ 1129, 1130, 68, 1504, 1505, 1510, 1553, 1521, 1258, 22, + /* 700 */ 240, 1549, 1472, 1232, 446, 547, 1391, 100, 175, 114, + /* 710 */ 1472, 1472, 1614, 1231, 449, 1503, 1472, 1390, 1472, 213, + /* 720 */ 386, 1230, 95, 1472, 1472, 131, 434, 1229, 536, 1612, + /* 730 */ 532, 528, 524, 212, 69, 1504, 1505, 1510, 1553, 1521, + /* 740 */ 98, 1170, 259, 1549, 1626, 1228, 446, 1076, 1472, 297, + /* 750 */ 187, 1560, 429, 1587, 428, 1276, 449, 1614, 1472, 66, + /* 760 */ 1472, 1227, 206, 1503, 299, 157, 1472, 1461, 155, 169, + /* 770 */ 131, 44, 1472, 1062, 1612, 1184, 69, 1504, 1505, 1510, + /* 780 */ 1553, 1118, 871, 1061, 259, 1549, 1626, 1521, 159, 1256, + /* 790 */ 1472, 158, 459, 161, 446, 1610, 160, 163, 1492, 447, + /* 800 */ 162, 872, 64, 289, 449, 1503, 1472, 383, 1472, 377, + /* 810 */ 1490, 389, 61, 382, 488, 405, 97, 1303, 378, 376, + /* 820 */ 412, 379, 418, 171, 69, 1504, 1505, 1510, 1553, 1521, + /* 830 */ 191, 178, 259, 1549, 1626, 180, 446, 33, 1038, 343, + /* 840 */ 168, 1133, 404, 1571, 1065, 1385, 449, 273, 272, 33, + /* 850 */ 1472, 184, 1503, 1091, 1064, 434, 366, 1067, 33, 197, + /* 860 */ 1583, 94, 1021, 199, 431, 455, 228, 1504, 1505, 1510, + /* 870 */ 104, 1522, 193, 1060, 205, 106, 1521, 2, 44, 928, + /* 880 */ 1074, 468, 923, 446, 284, 956, 1614, 288, 245, 247, + /* 890 */ 897, 104, 1059, 449, 1503, 960, 1030, 1472, 105, 131, + /* 900 */ 1503, 214, 966, 1612, 106, 1503, 138, 104, 965, 321, + /* 910 */ 1424, 107, 328, 70, 1504, 1505, 1510, 1553, 1521, 335, + /* 920 */ 337, 444, 1549, 336, 1521, 446, 341, 1087, 1086, 1521, + /* 930 */ 342, 446, 464, 344, 144, 449, 446, 345, 1085, 1472, + /* 940 */ 147, 449, 51, 346, 1063, 1472, 449, 349, 1084, 370, + /* 950 */ 1472, 1503, 150, 265, 368, 119, 1504, 1505, 1510, 1225, + /* 960 */ 255, 70, 1504, 1505, 1510, 1553, 229, 1504, 1505, 1510, + /* 970 */ 1550, 373, 1334, 154, 1330, 1521, 1503, 156, 109, 110, + /* 980 */ 84, 1068, 446, 83, 82, 81, 80, 79, 78, 77, + /* 990 */ 76, 75, 449, 435, 1627, 1332, 1472, 1328, 1071, 414, + /* 1000 */ 1521, 111, 74, 430, 112, 398, 400, 446, 408, 170, + /* 1010 */ 411, 173, 233, 1504, 1505, 1510, 401, 449, 1503, 410, + /* 1020 */ 399, 1472, 1083, 1584, 419, 453, 1594, 430, 100, 176, + /* 1030 */ 1059, 416, 258, 1593, 1574, 179, 422, 232, 1504, 1505, + /* 1040 */ 1510, 5, 1521, 427, 415, 4, 1503, 183, 1158, 446, + /* 1050 */ 1082, 124, 100, 185, 99, 34, 186, 260, 1433, 449, + /* 1060 */ 17, 98, 440, 1472, 1568, 451, 443, 1611, 456, 426, + /* 1070 */ 1521, 128, 1560, 1561, 452, 1565, 1535, 446, 192, 119, + /* 1080 */ 1504, 1505, 1510, 1629, 1432, 98, 268, 449, 201, 1503, + /* 1090 */ 203, 1472, 457, 458, 263, 129, 1560, 1561, 215, 1565, + /* 1100 */ 58, 1345, 60, 466, 495, 1317, 217, 233, 1504, 1505, + /* 1110 */ 1510, 211, 543, 1521, 40, 223, 1503, 224, 1628, 219, + /* 1120 */ 446, 221, 1466, 1465, 283, 1462, 285, 286, 1048, 1049, + /* 1130 */ 449, 1503, 134, 290, 1472, 1460, 292, 267, 293, 294, + /* 1140 */ 1521, 1459, 1503, 296, 1458, 298, 1449, 446, 135, 301, + /* 1150 */ 233, 1504, 1505, 1510, 302, 1521, 1033, 449, 1032, 1443, + /* 1160 */ 1442, 1472, 446, 307, 308, 1441, 1521, 1440, 1004, 1417, + /* 1170 */ 1416, 1415, 449, 446, 1414, 1413, 1472, 225, 1504, 1505, + /* 1180 */ 1510, 1412, 1411, 449, 1410, 1409, 1408, 1472, 1503, 1407, + /* 1190 */ 1406, 1405, 231, 1504, 1505, 1510, 1503, 1404, 1403, 1402, + /* 1200 */ 103, 1503, 1006, 234, 1504, 1505, 1510, 1401, 1400, 1399, + /* 1210 */ 1398, 1397, 1521, 1396, 1395, 1394, 1393, 1392, 1275, 446, + /* 1220 */ 1521, 1457, 1451, 1439, 1430, 1521, 146, 446, 1323, 449, + /* 1230 */ 1503, 1274, 446, 1472, 1272, 352, 351, 449, 864, 350, + /* 1240 */ 1270, 1472, 449, 354, 1268, 1266, 1472, 356, 355, 226, + /* 1250 */ 1504, 1505, 1510, 1255, 1521, 1503, 359, 235, 1504, 1505, + /* 1260 */ 1510, 446, 227, 1504, 1505, 1510, 363, 358, 360, 364, + /* 1270 */ 362, 449, 1254, 1251, 1325, 1472, 73, 153, 971, 1521, + /* 1280 */ 973, 1324, 1503, 1264, 896, 895, 446, 894, 893, 890, + /* 1290 */ 1503, 236, 1504, 1505, 1510, 889, 449, 252, 512, 1259, + /* 1300 */ 1472, 253, 387, 1257, 510, 390, 1521, 254, 1250, 392, + /* 1310 */ 1249, 394, 71, 446, 1521, 1456, 1518, 1504, 1505, 1510, + /* 1320 */ 1040, 446, 1450, 449, 402, 1438, 1503, 1472, 167, 113, + /* 1330 */ 1437, 449, 43, 403, 1429, 1472, 54, 172, 122, 174, + /* 1340 */ 3, 33, 14, 1517, 1504, 1505, 1510, 38, 182, 20, + /* 1350 */ 1521, 243, 1504, 1505, 1510, 1503, 15, 446, 10, 177, + /* 1360 */ 1503, 1183, 120, 35, 181, 19, 1490, 449, 1503, 56, + /* 1370 */ 1176, 1472, 55, 37, 1205, 1155, 1154, 36, 16, 1521, + /* 1380 */ 1210, 1204, 188, 130, 1521, 1321, 446, 1516, 1504, 1505, + /* 1390 */ 1510, 446, 1521, 1319, 261, 1209, 449, 1208, 262, 446, + /* 1400 */ 1472, 449, 8, 195, 1119, 1472, 1094, 1092, 196, 449, + /* 1410 */ 1181, 13, 18, 1472, 1503, 198, 244, 1504, 1505, 1510, + /* 1420 */ 200, 242, 1504, 1505, 1510, 45, 1428, 202, 57, 239, + /* 1430 */ 1504, 1505, 1510, 61, 1489, 1069, 207, 39, 1521, 957, + /* 1440 */ 454, 467, 204, 465, 275, 446, 209, 469, 471, 954, + /* 1450 */ 494, 472, 474, 951, 209, 449, 475, 477, 494, 1472, + /* 1460 */ 480, 945, 478, 934, 943, 481, 949, 948, 947, 946, + /* 1470 */ 487, 62, 496, 968, 964, 230, 1504, 1505, 1510, 46, + /* 1480 */ 496, 967, 63, 962, 862, 903, 210, 497, 499, 885, + /* 1490 */ 884, 493, 492, 491, 883, 490, 882, 881, 880, 493, + /* 1500 */ 492, 491, 879, 490, 878, 900, 898, 875, 874, 873, + /* 1510 */ 870, 869, 868, 867, 1271, 521, 522, 1269, 1267, 523, + /* 1520 */ 526, 525, 527, 529, 530, 1265, 534, 533, 1253, 531, + /* 1530 */ 535, 537, 538, 1252, 1248, 541, 542, 1223, 1056, 1223, + /* 1540 */ 546, 218, 545, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 253, 240, 257, 256, 278, 279, 259, 211, 235, 213, - /* 10 */ 218, 237, 12, 13, 269, 270, 262, 212, 257, 246, - /* 20 */ 20, 20, 22, 2, 20, 12, 13, 14, 15, 16, - /* 30 */ 269, 270, 2, 12, 13, 14, 15, 16, 38, 240, - /* 40 */ 248, 236, 12, 13, 14, 15, 16, 293, 243, 20, - /* 50 */ 50, 12, 13, 14, 49, 218, 257, 57, 253, 20, - /* 60 */ 306, 22, 257, 0, 310, 12, 13, 262, 269, 270, - /* 70 */ 218, 1, 2, 20, 74, 22, 218, 38, 273, 274, - /* 80 */ 275, 276, 277, 215, 216, 227, 281, 282, 75, 50, - /* 90 */ 212, 38, 234, 20, 253, 243, 57, 97, 293, 262, - /* 100 */ 259, 243, 0, 50, 12, 13, 14, 15, 16, 109, - /* 110 */ 57, 306, 49, 74, 236, 310, 12, 13, 14, 15, - /* 120 */ 16, 243, 221, 236, 22, 245, 225, 74, 276, 242, - /* 130 */ 293, 253, 252, 253, 247, 257, 97, 285, 286, 287, - /* 140 */ 288, 228, 290, 306, 49, 75, 146, 310, 109, 236, - /* 150 */ 97, 273, 274, 275, 276, 277, 20, 244, 22, 281, - /* 160 */ 282, 283, 109, 163, 164, 165, 166, 167, 168, 169, - /* 170 */ 170, 171, 172, 173, 174, 61, 40, 222, 223, 65, - /* 180 */ 302, 20, 271, 209, 21, 146, 186, 24, 25, 26, - /* 190 */ 27, 28, 29, 30, 31, 32, 14, 15, 16, 146, - /* 200 */ 289, 87, 163, 164, 165, 166, 167, 168, 169, 170, - /* 210 */ 171, 172, 173, 174, 0, 186, 163, 164, 165, 166, - /* 220 */ 167, 168, 169, 170, 171, 172, 173, 174, 0, 12, - /* 230 */ 13, 19, 145, 271, 147, 74, 262, 20, 52, 22, - /* 240 */ 54, 38, 186, 139, 58, 33, 20, 61, 36, 63, - /* 250 */ 64, 289, 66, 236, 42, 38, 44, 45, 46, 47, - /* 260 */ 57, 244, 12, 13, 14, 15, 16, 293, 12, 13, - /* 270 */ 14, 212, 218, 186, 57, 61, 20, 49, 22, 65, - /* 280 */ 306, 227, 12, 13, 310, 73, 220, 20, 76, 20, - /* 290 */ 20, 74, 22, 212, 38, 236, 217, 243, 236, 233, - /* 300 */ 74, 87, 243, 212, 67, 243, 218, 241, 38, 85, - /* 310 */ 231, 207, 253, 57, 97, 227, 257, 238, 106, 71, - /* 320 */ 106, 107, 108, 163, 110, 75, 109, 57, 222, 223, - /* 330 */ 74, 243, 273, 274, 275, 276, 277, 275, 257, 21, - /* 340 */ 281, 282, 283, 0, 74, 0, 134, 186, 257, 137, - /* 350 */ 113, 114, 34, 97, 295, 195, 196, 197, 198, 199, - /* 360 */ 301, 302, 57, 146, 152, 109, 154, 97, 212, 24, - /* 370 */ 25, 26, 27, 28, 29, 30, 31, 32, 237, 109, + /* 0 */ 211, 209, 213, 236, 253, 218, 257, 256, 229, 242, + /* 10 */ 259, 232, 12, 13, 247, 2, 262, 212, 269, 270, + /* 20 */ 20, 224, 22, 226, 20, 12, 13, 14, 15, 16, + /* 30 */ 12, 13, 14, 15, 16, 248, 20, 3, 38, 240, + /* 40 */ 237, 236, 12, 13, 14, 15, 16, 293, 243, 237, + /* 50 */ 50, 12, 13, 14, 262, 228, 257, 57, 253, 20, + /* 60 */ 306, 22, 257, 236, 310, 12, 13, 14, 269, 270, + /* 70 */ 212, 244, 20, 20, 74, 22, 245, 38, 273, 274, + /* 80 */ 275, 276, 277, 252, 253, 293, 281, 282, 283, 50, + /* 90 */ 0, 38, 0, 75, 236, 221, 57, 97, 306, 225, + /* 100 */ 295, 243, 310, 278, 279, 75, 301, 302, 240, 109, + /* 110 */ 57, 253, 22, 74, 49, 257, 24, 25, 26, 27, + /* 120 */ 28, 29, 30, 31, 32, 257, 74, 74, 75, 21, + /* 130 */ 220, 273, 274, 275, 276, 277, 97, 269, 270, 281, + /* 140 */ 282, 283, 34, 233, 33, 243, 146, 36, 109, 35, + /* 150 */ 97, 241, 250, 42, 20, 44, 45, 46, 47, 145, + /* 160 */ 302, 147, 109, 163, 164, 165, 166, 167, 168, 169, + /* 170 */ 170, 171, 172, 173, 174, 61, 14, 15, 16, 65, + /* 180 */ 164, 165, 166, 167, 73, 146, 186, 76, 43, 218, + /* 190 */ 186, 77, 186, 79, 80, 71, 82, 262, 227, 146, + /* 200 */ 186, 87, 163, 164, 165, 166, 167, 168, 169, 170, + /* 210 */ 171, 172, 173, 174, 243, 0, 163, 164, 165, 166, + /* 220 */ 167, 168, 169, 170, 171, 172, 173, 174, 293, 12, + /* 230 */ 13, 12, 13, 14, 15, 16, 202, 20, 186, 22, + /* 240 */ 293, 306, 12, 13, 133, 310, 135, 218, 137, 18, + /* 250 */ 20, 20, 22, 306, 212, 38, 227, 310, 27, 20, + /* 260 */ 4, 30, 236, 234, 49, 154, 4, 50, 38, 243, + /* 270 */ 39, 236, 243, 253, 57, 19, 49, 242, 236, 259, + /* 280 */ 12, 13, 247, 235, 218, 243, 0, 57, 20, 33, + /* 290 */ 22, 74, 36, 227, 246, 253, 52, 41, 54, 257, + /* 300 */ 234, 275, 58, 47, 74, 61, 38, 63, 64, 243, + /* 310 */ 66, 218, 218, 218, 97, 273, 274, 275, 276, 277, + /* 320 */ 227, 227, 227, 281, 282, 57, 109, 97, 204, 73, + /* 330 */ 185, 20, 76, 22, 218, 49, 243, 243, 243, 109, + /* 340 */ 61, 71, 74, 112, 65, 75, 115, 116, 117, 118, + /* 350 */ 119, 40, 121, 122, 123, 124, 125, 126, 127, 128, + /* 360 */ 129, 130, 131, 146, 21, 97, 87, 24, 25, 26, + /* 370 */ 27, 28, 29, 30, 31, 32, 146, 109, 262, 47, /* 380 */ 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, - /* 390 */ 173, 174, 20, 218, 236, 52, 220, 54, 293, 237, - /* 400 */ 242, 58, 146, 186, 61, 247, 63, 64, 212, 66, - /* 410 */ 212, 306, 265, 257, 212, 310, 146, 241, 243, 163, - /* 420 */ 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, - /* 430 */ 174, 164, 165, 163, 164, 165, 166, 167, 168, 169, - /* 440 */ 170, 171, 172, 173, 174, 218, 12, 13, 18, 136, - /* 450 */ 20, 276, 204, 257, 20, 257, 22, 27, 217, 257, - /* 460 */ 30, 286, 287, 288, 243, 290, 20, 4, 262, 39, - /* 470 */ 243, 250, 38, 12, 13, 14, 15, 16, 3, 238, - /* 480 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, - /* 490 */ 98, 57, 100, 101, 102, 103, 104, 105, 0, 293, - /* 500 */ 184, 185, 271, 276, 191, 192, 1, 2, 74, 218, - /* 510 */ 138, 50, 306, 286, 287, 288, 310, 290, 227, 21, - /* 520 */ 289, 212, 24, 25, 26, 27, 28, 29, 30, 31, - /* 530 */ 32, 97, 229, 237, 243, 232, 75, 12, 13, 14, - /* 540 */ 15, 16, 112, 109, 83, 115, 116, 117, 118, 119, - /* 550 */ 212, 121, 122, 123, 124, 125, 126, 127, 128, 129, - /* 560 */ 130, 131, 0, 47, 18, 218, 257, 212, 224, 23, - /* 570 */ 226, 236, 236, 43, 227, 12, 13, 14, 15, 16, - /* 580 */ 146, 35, 247, 247, 138, 14, 237, 237, 212, 73, - /* 590 */ 243, 20, 76, 132, 48, 257, 237, 163, 164, 165, - /* 600 */ 166, 167, 168, 169, 170, 171, 172, 173, 174, 213, - /* 610 */ 212, 150, 257, 50, 52, 53, 54, 55, 56, 212, - /* 620 */ 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - /* 630 */ 68, 69, 70, 257, 212, 212, 175, 176, 177, 178, - /* 640 */ 179, 180, 181, 182, 183, 218, 83, 218, 212, 218, - /* 650 */ 187, 22, 228, 218, 227, 257, 227, 111, 227, 236, - /* 660 */ 236, 234, 227, 138, 257, 228, 243, 38, 244, 0, - /* 670 */ 243, 38, 243, 236, 243, 218, 253, 202, 243, 257, - /* 680 */ 257, 244, 212, 212, 227, 139, 140, 141, 212, 143, - /* 690 */ 57, 22, 218, 257, 148, 132, 273, 274, 275, 276, - /* 700 */ 243, 227, 156, 142, 158, 236, 160, 161, 162, 225, - /* 710 */ 71, 242, 236, 150, 75, 185, 247, 243, 157, 243, - /* 720 */ 78, 22, 218, 81, 212, 212, 212, 257, 257, 253, - /* 730 */ 50, 227, 186, 257, 311, 312, 132, 38, 175, 176, - /* 740 */ 177, 178, 179, 180, 181, 182, 183, 243, 236, 273, - /* 750 */ 274, 275, 276, 277, 150, 243, 57, 281, 282, 283, - /* 760 */ 212, 0, 212, 33, 212, 253, 36, 313, 292, 257, - /* 770 */ 257, 257, 42, 253, 44, 45, 46, 47, 78, 175, - /* 780 */ 78, 81, 304, 81, 236, 273, 274, 275, 276, 277, - /* 790 */ 0, 243, 71, 281, 282, 283, 97, 36, 164, 165, - /* 800 */ 246, 253, 35, 73, 292, 257, 76, 257, 109, 257, - /* 810 */ 212, 78, 22, 71, 81, 71, 71, 75, 253, 75, - /* 820 */ 75, 273, 274, 275, 276, 277, 74, 298, 61, 281, - /* 830 */ 282, 283, 65, 215, 236, 71, 272, 212, 86, 75, - /* 840 */ 292, 243, 291, 163, 77, 146, 79, 80, 38, 82, - /* 850 */ 236, 253, 212, 71, 87, 257, 307, 75, 20, 38, - /* 860 */ 262, 236, 163, 133, 294, 135, 71, 137, 243, 218, - /* 870 */ 75, 273, 274, 275, 276, 36, 236, 71, 253, 212, - /* 880 */ 268, 75, 257, 243, 154, 71, 12, 13, 71, 75, - /* 890 */ 38, 293, 75, 253, 222, 144, 22, 257, 273, 274, - /* 900 */ 275, 276, 277, 236, 306, 218, 281, 282, 310, 263, - /* 910 */ 243, 218, 38, 273, 274, 275, 276, 277, 74, 109, - /* 920 */ 253, 281, 282, 218, 257, 71, 251, 206, 84, 75, - /* 930 */ 109, 57, 71, 71, 71, 120, 75, 75, 75, 132, - /* 940 */ 273, 274, 275, 276, 277, 249, 71, 249, 243, 282, - /* 950 */ 75, 20, 218, 71, 71, 212, 267, 75, 75, 20, - /* 960 */ 220, 243, 261, 20, 254, 218, 220, 262, 220, 220, - /* 970 */ 20, 97, 214, 236, 236, 236, 222, 236, 218, 236, - /* 980 */ 267, 276, 212, 109, 153, 266, 243, 214, 261, 236, - /* 990 */ 212, 286, 287, 288, 217, 290, 253, 217, 293, 236, - /* 1000 */ 257, 236, 236, 260, 236, 236, 236, 236, 20, 254, - /* 1010 */ 194, 306, 303, 243, 236, 310, 273, 274, 275, 276, - /* 1020 */ 146, 243, 243, 253, 243, 193, 57, 257, 272, 257, - /* 1030 */ 260, 253, 258, 258, 212, 257, 201, 163, 303, 189, - /* 1040 */ 257, 257, 200, 273, 274, 275, 276, 188, 243, 20, - /* 1050 */ 300, 273, 274, 275, 276, 296, 299, 185, 236, 297, - /* 1060 */ 271, 120, 205, 208, 74, 243, 258, 280, 212, 284, - /* 1070 */ 203, 258, 135, 255, 74, 253, 212, 257, 254, 257, - /* 1080 */ 257, 212, 257, 305, 243, 217, 243, 239, 217, 210, - /* 1090 */ 314, 226, 236, 217, 308, 273, 274, 275, 276, 243, - /* 1100 */ 236, 309, 232, 222, 218, 236, 214, 243, 230, 253, - /* 1110 */ 264, 0, 243, 257, 230, 219, 260, 253, 0, 64, - /* 1120 */ 0, 257, 253, 212, 260, 38, 257, 38, 212, 273, - /* 1130 */ 274, 275, 276, 4, 312, 159, 212, 273, 274, 275, - /* 1140 */ 276, 38, 273, 274, 275, 276, 159, 236, 19, 0, - /* 1150 */ 38, 159, 236, 38, 243, 38, 0, 38, 0, 243, - /* 1160 */ 236, 38, 33, 0, 253, 36, 74, 243, 257, 253, - /* 1170 */ 41, 150, 149, 257, 0, 0, 47, 253, 109, 146, - /* 1180 */ 212, 257, 0, 53, 273, 274, 275, 276, 142, 273, - /* 1190 */ 274, 275, 276, 0, 0, 212, 86, 273, 274, 275, - /* 1200 */ 276, 0, 73, 0, 236, 76, 212, 0, 0, 0, - /* 1210 */ 0, 243, 0, 0, 0, 0, 0, 0, 0, 236, - /* 1220 */ 0, 253, 0, 0, 120, 257, 243, 0, 0, 0, - /* 1230 */ 236, 212, 0, 0, 0, 61, 253, 243, 0, 65, - /* 1240 */ 257, 273, 274, 275, 276, 0, 22, 253, 0, 0, - /* 1250 */ 0, 257, 0, 0, 0, 236, 273, 274, 275, 276, - /* 1260 */ 0, 87, 243, 0, 43, 212, 0, 273, 274, 275, - /* 1270 */ 276, 0, 253, 38, 43, 36, 257, 51, 212, 0, - /* 1280 */ 106, 107, 108, 43, 110, 38, 0, 36, 0, 236, - /* 1290 */ 0, 36, 273, 274, 275, 276, 243, 38, 0, 43, - /* 1300 */ 38, 36, 236, 0, 43, 0, 253, 38, 83, 243, - /* 1310 */ 257, 81, 212, 71, 22, 0, 38, 71, 38, 253, - /* 1320 */ 212, 38, 38, 257, 0, 212, 273, 274, 275, 276, - /* 1330 */ 22, 38, 38, 0, 22, 39, 236, 0, 22, 273, - /* 1340 */ 274, 275, 276, 243, 236, 38, 0, 22, 0, 236, - /* 1350 */ 22, 243, 20, 253, 0, 155, 243, 257, 38, 0, - /* 1360 */ 22, 253, 151, 0, 0, 257, 253, 212, 0, 74, - /* 1370 */ 257, 135, 212, 273, 274, 275, 276, 43, 190, 138, - /* 1380 */ 71, 273, 274, 275, 276, 71, 273, 274, 275, 276, - /* 1390 */ 71, 236, 75, 75, 190, 138, 236, 74, 243, 86, - /* 1400 */ 133, 74, 138, 243, 74, 4, 75, 71, 253, 74, - /* 1410 */ 71, 38, 257, 253, 71, 75, 75, 257, 71, 75, - /* 1420 */ 38, 184, 38, 38, 38, 38, 2, 74, 273, 274, - /* 1430 */ 275, 276, 75, 273, 274, 275, 276, 86, 86, 163, - /* 1440 */ 75, 86, 75, 74, 0, 75, 74, 136, 190, 74, - /* 1450 */ 74, 43, 74, 22, 133, 84, 75, 74, 38, 38, - /* 1460 */ 86, 38, 74, 86, 85, 75, 74, 38, 75, 74, - /* 1470 */ 38, 75, 74, 38, 75, 22, 74, 74, 38, 99, - /* 1480 */ 74, 74, 22, 38, 87, 51, 50, 57, 99, 72, - /* 1490 */ 99, 22, 38, 99, 38, 38, 71, 38, 57, 38, - /* 1500 */ 38, 38, 38, 38, 38, 38, 38, 0, 38, 109, - /* 1510 */ 38, 38, 38, 36, 43, 0, 38, 36, 43, 0, - /* 1520 */ 38, 36, 43, 0, 38, 36, 43, 0, 38, 37, - /* 1530 */ 0, 0, 22, 21, 315, 22, 22, 21, 20, 315, - /* 1540 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + /* 390 */ 173, 174, 38, 163, 164, 165, 166, 167, 168, 169, + /* 400 */ 170, 171, 172, 173, 174, 73, 215, 216, 76, 293, + /* 410 */ 20, 57, 228, 228, 146, 20, 186, 12, 13, 236, + /* 420 */ 236, 236, 306, 1, 2, 20, 310, 22, 244, 244, + /* 430 */ 247, 163, 164, 165, 166, 167, 168, 169, 170, 171, + /* 440 */ 172, 173, 174, 38, 12, 13, 14, 15, 16, 187, + /* 450 */ 212, 88, 89, 90, 91, 92, 93, 94, 95, 96, + /* 460 */ 97, 98, 57, 100, 101, 102, 103, 104, 105, 12, + /* 470 */ 13, 14, 15, 16, 2, 217, 85, 220, 22, 74, + /* 480 */ 0, 218, 50, 20, 12, 13, 14, 15, 16, 231, + /* 490 */ 227, 222, 223, 57, 38, 257, 238, 75, 241, 18, + /* 500 */ 218, 218, 97, 218, 23, 20, 243, 75, 67, 227, + /* 510 */ 227, 136, 227, 57, 109, 83, 35, 222, 223, 71, + /* 520 */ 12, 13, 14, 15, 16, 243, 243, 163, 243, 48, + /* 530 */ 1, 2, 52, 53, 54, 55, 56, 74, 58, 59, + /* 540 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + /* 550 */ 70, 146, 212, 97, 113, 114, 212, 237, 50, 195, + /* 560 */ 196, 197, 198, 199, 132, 109, 191, 192, 163, 164, + /* 570 */ 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, + /* 580 */ 218, 212, 150, 12, 13, 14, 15, 16, 212, 236, + /* 590 */ 20, 83, 111, 184, 185, 242, 139, 257, 271, 271, + /* 600 */ 247, 257, 146, 164, 165, 243, 212, 175, 176, 177, + /* 610 */ 178, 179, 180, 181, 182, 183, 289, 289, 212, 163, + /* 620 */ 139, 140, 141, 138, 143, 212, 257, 213, 271, 148, + /* 630 */ 71, 212, 217, 257, 75, 218, 218, 156, 276, 158, + /* 640 */ 132, 160, 161, 162, 227, 227, 289, 285, 286, 287, + /* 650 */ 288, 257, 290, 238, 206, 236, 132, 212, 150, 22, + /* 660 */ 243, 243, 243, 257, 207, 212, 212, 186, 50, 236, + /* 670 */ 257, 212, 253, 212, 150, 38, 257, 244, 212, 212, + /* 680 */ 237, 262, 218, 175, 176, 177, 178, 179, 180, 181, + /* 690 */ 182, 183, 273, 274, 275, 276, 277, 236, 0, 175, + /* 700 */ 281, 282, 257, 212, 243, 19, 236, 243, 138, 138, + /* 710 */ 257, 257, 293, 212, 253, 212, 257, 247, 257, 33, + /* 720 */ 22, 212, 36, 257, 257, 306, 262, 212, 42, 310, + /* 730 */ 44, 45, 46, 47, 273, 274, 275, 276, 277, 236, + /* 740 */ 276, 14, 281, 282, 283, 212, 243, 20, 257, 142, + /* 750 */ 286, 287, 288, 292, 290, 0, 253, 293, 257, 73, + /* 760 */ 257, 212, 76, 212, 157, 78, 257, 0, 81, 237, + /* 770 */ 306, 71, 257, 38, 310, 75, 273, 274, 275, 276, + /* 780 */ 277, 163, 38, 38, 281, 282, 283, 236, 78, 0, + /* 790 */ 257, 81, 106, 78, 243, 292, 81, 78, 74, 237, + /* 800 */ 81, 57, 74, 36, 253, 212, 257, 52, 257, 54, + /* 810 */ 86, 22, 84, 58, 237, 265, 61, 225, 63, 64, + /* 820 */ 134, 66, 304, 137, 273, 274, 275, 276, 277, 236, + /* 830 */ 313, 71, 281, 282, 283, 75, 243, 71, 152, 253, + /* 840 */ 154, 75, 253, 292, 109, 246, 253, 12, 13, 71, + /* 850 */ 257, 298, 212, 75, 109, 262, 215, 22, 71, 71, + /* 860 */ 272, 71, 75, 75, 291, 75, 273, 274, 275, 276, + /* 870 */ 71, 236, 307, 38, 75, 71, 236, 294, 71, 75, + /* 880 */ 20, 71, 75, 243, 218, 75, 293, 36, 268, 222, + /* 890 */ 38, 71, 57, 253, 212, 75, 144, 257, 71, 306, + /* 900 */ 212, 263, 75, 310, 71, 212, 120, 71, 75, 218, + /* 910 */ 218, 75, 251, 273, 274, 275, 276, 277, 236, 249, + /* 920 */ 249, 281, 282, 132, 236, 243, 218, 20, 20, 236, + /* 930 */ 267, 243, 97, 261, 220, 253, 243, 243, 20, 257, + /* 940 */ 220, 253, 220, 254, 109, 257, 253, 218, 20, 236, + /* 950 */ 257, 212, 220, 260, 214, 273, 274, 275, 276, 0, + /* 960 */ 214, 273, 274, 275, 276, 277, 273, 274, 275, 276, + /* 970 */ 282, 222, 236, 236, 236, 236, 212, 236, 236, 236, + /* 980 */ 21, 146, 243, 24, 25, 26, 27, 28, 29, 30, + /* 990 */ 31, 32, 253, 311, 312, 236, 257, 236, 163, 260, + /* 1000 */ 236, 236, 218, 218, 236, 243, 153, 243, 261, 217, + /* 1010 */ 254, 217, 273, 274, 275, 276, 266, 253, 212, 243, + /* 1020 */ 267, 257, 20, 272, 194, 193, 303, 218, 243, 258, + /* 1030 */ 57, 257, 257, 303, 300, 258, 257, 273, 274, 275, + /* 1040 */ 276, 201, 236, 200, 189, 188, 212, 299, 185, 243, + /* 1050 */ 20, 297, 243, 296, 243, 120, 284, 208, 258, 253, + /* 1060 */ 74, 276, 203, 257, 271, 257, 205, 309, 135, 305, + /* 1070 */ 236, 286, 287, 288, 257, 290, 280, 243, 308, 273, + /* 1080 */ 274, 275, 276, 314, 258, 276, 257, 253, 243, 212, + /* 1090 */ 217, 257, 255, 254, 260, 286, 287, 288, 232, 290, + /* 1100 */ 217, 243, 74, 239, 222, 226, 218, 273, 274, 275, + /* 1110 */ 276, 217, 214, 236, 264, 230, 212, 230, 312, 219, + /* 1120 */ 243, 210, 0, 0, 64, 0, 38, 159, 38, 38, + /* 1130 */ 253, 212, 38, 159, 257, 0, 38, 260, 38, 159, + /* 1140 */ 236, 0, 212, 38, 0, 38, 0, 243, 74, 150, + /* 1150 */ 273, 274, 275, 276, 149, 236, 109, 253, 146, 0, + /* 1160 */ 0, 257, 243, 53, 142, 0, 236, 0, 86, 0, + /* 1170 */ 0, 0, 253, 243, 0, 0, 257, 273, 274, 275, + /* 1180 */ 276, 0, 0, 253, 0, 0, 0, 257, 212, 0, + /* 1190 */ 0, 0, 273, 274, 275, 276, 212, 0, 0, 0, + /* 1200 */ 120, 212, 22, 273, 274, 275, 276, 0, 0, 0, + /* 1210 */ 0, 0, 236, 0, 0, 0, 0, 0, 0, 243, + /* 1220 */ 236, 0, 0, 0, 0, 236, 43, 243, 0, 253, + /* 1230 */ 212, 0, 243, 257, 0, 43, 36, 253, 51, 38, + /* 1240 */ 0, 257, 253, 38, 0, 0, 257, 43, 36, 273, + /* 1250 */ 274, 275, 276, 0, 236, 212, 36, 273, 274, 275, + /* 1260 */ 276, 243, 273, 274, 275, 276, 36, 38, 43, 43, + /* 1270 */ 38, 253, 0, 0, 0, 257, 83, 81, 22, 236, + /* 1280 */ 38, 0, 212, 0, 38, 38, 243, 38, 38, 38, + /* 1290 */ 212, 273, 274, 275, 276, 38, 253, 22, 71, 0, + /* 1300 */ 257, 22, 39, 0, 71, 38, 236, 22, 0, 22, + /* 1310 */ 0, 22, 20, 243, 236, 0, 273, 274, 275, 276, + /* 1320 */ 38, 243, 0, 253, 22, 0, 212, 257, 155, 151, + /* 1330 */ 0, 253, 138, 138, 0, 257, 74, 43, 135, 133, + /* 1340 */ 71, 71, 190, 273, 274, 275, 276, 71, 71, 71, + /* 1350 */ 236, 273, 274, 275, 276, 212, 190, 243, 190, 75, + /* 1360 */ 212, 75, 74, 184, 74, 74, 86, 253, 212, 4, + /* 1370 */ 75, 257, 74, 138, 38, 75, 75, 71, 71, 236, + /* 1380 */ 75, 38, 86, 86, 236, 0, 243, 273, 274, 275, + /* 1390 */ 276, 243, 236, 0, 38, 38, 253, 38, 38, 243, + /* 1400 */ 257, 253, 2, 86, 163, 257, 75, 75, 75, 253, + /* 1410 */ 75, 74, 74, 257, 212, 74, 273, 274, 275, 276, + /* 1420 */ 74, 273, 274, 275, 276, 74, 0, 43, 74, 273, + /* 1430 */ 274, 275, 276, 84, 86, 22, 86, 74, 236, 75, + /* 1440 */ 136, 38, 133, 85, 38, 243, 61, 74, 38, 75, + /* 1450 */ 65, 74, 38, 75, 61, 253, 74, 38, 65, 257, + /* 1460 */ 38, 75, 74, 22, 75, 74, 99, 99, 99, 99, + /* 1470 */ 87, 74, 87, 38, 38, 273, 274, 275, 276, 74, + /* 1480 */ 87, 109, 74, 22, 51, 57, 71, 50, 72, 38, + /* 1490 */ 38, 106, 107, 108, 38, 110, 38, 38, 38, 106, + /* 1500 */ 107, 108, 38, 110, 22, 57, 38, 38, 38, 38, + /* 1510 */ 38, 38, 38, 38, 0, 38, 36, 0, 0, 43, + /* 1520 */ 36, 38, 43, 38, 36, 0, 36, 38, 0, 43, + /* 1530 */ 43, 38, 37, 0, 0, 22, 21, 315, 22, 315, + /* 1540 */ 20, 22, 21, 315, 315, 315, 315, 315, 315, 315, /* 1550 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, /* 1560 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, /* 1570 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, @@ -542,151 +543,152 @@ static const YYCODETYPE yy_lookahead[] = { /* 1710 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, /* 1720 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, /* 1730 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, - /* 1740 */ 315, 315, 315, 315, 315, 315, 315, 315, + /* 1740 */ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + /* 1750 */ 315, 315, }; #define YY_SHIFT_COUNT (547) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1531) +#define YY_SHIFT_MAX (1534) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 546, 0, 39, 53, 53, 53, 53, 217, 53, 53, - /* 10 */ 270, 434, 161, 256, 270, 270, 270, 270, 270, 270, - /* 20 */ 270, 270, 270, 270, 270, 270, 270, 270, 270, 270, - /* 30 */ 270, 270, 270, 270, 226, 226, 226, 29, 874, 874, - /* 40 */ 87, 1, 1, 56, 874, 267, 267, 1, 1, 1, - /* 50 */ 1, 1, 1, 5, 4, 73, 56, 4, 1, 1, - /* 60 */ 4, 1, 4, 4, 4, 1, 95, 430, 461, 563, - /* 70 */ 563, 163, 767, 699, 186, 699, 699, 699, 699, 699, - /* 80 */ 699, 699, 699, 699, 699, 699, 699, 699, 699, 699, - /* 90 */ 699, 699, 699, 699, 267, 136, 63, 203, 372, 372, - /* 100 */ 372, 228, 203, 269, 4, 4, 4, 224, 305, 392, - /* 110 */ 392, 392, 392, 392, 392, 392, 212, 498, 343, 104, - /* 120 */ 160, 267, 114, 267, 313, 629, 446, 316, 530, 316, - /* 130 */ 571, 475, 463, 838, 839, 852, 751, 838, 838, 815, - /* 140 */ 807, 807, 838, 931, 939, 5, 269, 943, 5, 5, - /* 150 */ 838, 5, 950, 4, 4, 4, 4, 4, 4, 4, - /* 160 */ 4, 4, 4, 4, 852, 838, 950, 269, 931, 831, - /* 170 */ 939, 95, 269, 943, 95, 988, 816, 832, 969, 816, - /* 180 */ 832, 969, 969, 835, 842, 850, 859, 872, 269, 1029, - /* 190 */ 941, 855, 857, 867, 990, 4, 832, 969, 969, 832, - /* 200 */ 969, 937, 269, 943, 95, 224, 95, 269, 1000, 852, - /* 210 */ 305, 838, 95, 950, 1539, 1539, 1539, 1539, 1539, 562, - /* 220 */ 730, 345, 1129, 214, 1174, 13, 21, 30, 250, 525, - /* 230 */ 92, 92, 92, 92, 92, 92, 92, 516, 237, 182, - /* 240 */ 70, 604, 182, 182, 182, 761, 561, 639, 642, 700, - /* 250 */ 702, 733, 102, 669, 790, 318, 742, 744, 745, 505, - /* 260 */ 634, 248, 721, 764, 680, 782, 752, 795, 806, 814, - /* 270 */ 817, 854, 810, 821, 861, 862, 863, 875, 882, 883, - /* 280 */ 844, 633, 1111, 1118, 1055, 1120, 1087, 976, 1089, 1103, - /* 290 */ 1112, 987, 1149, 1115, 1117, 992, 1156, 1119, 1158, 1123, - /* 300 */ 1163, 1092, 1021, 1023, 1069, 1033, 1175, 1182, 1130, 1046, - /* 310 */ 1193, 1194, 1110, 1201, 1203, 1207, 1208, 1209, 1210, 1212, - /* 320 */ 1213, 1214, 1215, 1216, 1217, 1218, 1220, 1222, 1223, 1104, - /* 330 */ 1227, 1228, 1229, 1232, 1233, 1234, 1224, 1238, 1245, 1248, - /* 340 */ 1249, 1250, 1252, 1253, 1254, 1260, 1221, 1263, 1226, 1266, - /* 350 */ 1271, 1235, 1239, 1231, 1279, 1247, 1251, 1240, 1286, 1259, - /* 360 */ 1255, 1256, 1288, 1262, 1265, 1261, 1290, 1298, 1303, 1305, - /* 370 */ 1225, 1230, 1269, 1242, 1292, 1315, 1278, 1280, 1283, 1284, - /* 380 */ 1246, 1242, 1293, 1294, 1324, 1308, 1333, 1312, 1296, 1337, - /* 390 */ 1316, 1307, 1346, 1325, 1348, 1328, 1332, 1354, 1241, 1200, - /* 400 */ 1320, 1359, 1211, 1338, 1257, 1236, 1363, 1364, 1264, 1368, - /* 410 */ 1295, 1334, 1267, 1309, 1314, 1188, 1317, 1319, 1318, 1323, - /* 420 */ 1327, 1330, 1331, 1336, 1313, 1335, 1339, 1204, 1340, 1341, - /* 430 */ 1351, 1237, 1343, 1352, 1344, 1347, 1258, 1401, 1373, 1382, - /* 440 */ 1384, 1385, 1386, 1387, 1424, 1276, 1355, 1357, 1365, 1353, - /* 450 */ 1369, 1367, 1370, 1372, 1375, 1311, 1376, 1444, 1408, 1321, - /* 460 */ 1378, 1371, 1374, 1377, 1431, 1383, 1379, 1381, 1420, 1421, - /* 470 */ 1388, 1390, 1423, 1392, 1393, 1429, 1395, 1396, 1432, 1398, - /* 480 */ 1399, 1435, 1402, 1380, 1389, 1391, 1394, 1453, 1397, 1403, - /* 490 */ 1440, 1400, 1406, 1407, 1445, 1242, 1460, 1434, 1436, 1430, - /* 500 */ 1417, 1425, 1454, 1456, 1457, 1459, 1461, 1462, 1463, 1469, - /* 510 */ 1441, 1246, 1464, 1242, 1465, 1466, 1467, 1468, 1470, 1472, - /* 520 */ 1473, 1507, 1474, 1477, 1471, 1515, 1478, 1481, 1475, 1519, - /* 530 */ 1482, 1485, 1479, 1523, 1486, 1489, 1483, 1527, 1490, 1492, - /* 540 */ 1530, 1531, 1510, 1512, 1513, 1514, 1516, 1518, + /* 0 */ 481, 0, 39, 217, 217, 217, 217, 230, 217, 217, + /* 10 */ 268, 405, 52, 53, 268, 268, 268, 268, 268, 268, + /* 20 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + /* 30 */ 268, 268, 268, 268, 463, 463, 463, 4, 835, 835, + /* 40 */ 14, 134, 134, 6, 835, 16, 16, 134, 134, 134, + /* 50 */ 134, 134, 134, 65, 239, 390, 6, 239, 134, 134, + /* 60 */ 239, 134, 239, 239, 239, 134, 227, 231, 432, 508, + /* 70 */ 508, 343, 114, 456, 244, 456, 456, 456, 456, 456, + /* 80 */ 456, 456, 456, 456, 456, 456, 456, 456, 456, 456, + /* 90 */ 456, 456, 456, 456, 16, 311, 215, 354, 485, 485, + /* 100 */ 485, 286, 354, 395, 239, 239, 239, 391, 436, 363, + /* 110 */ 363, 363, 363, 363, 363, 363, 686, 959, 755, 457, + /* 120 */ 364, 16, 16, 279, 375, 637, 570, 409, 145, 409, + /* 130 */ 727, 34, 262, 860, 851, 852, 752, 860, 860, 786, + /* 140 */ 791, 791, 860, 907, 908, 65, 395, 918, 65, 65, + /* 150 */ 860, 65, 928, 239, 239, 239, 239, 239, 239, 239, + /* 160 */ 239, 239, 239, 239, 852, 860, 928, 395, 907, 853, + /* 170 */ 908, 227, 395, 918, 227, 1002, 830, 832, 973, 830, + /* 180 */ 832, 973, 973, 840, 843, 855, 857, 863, 395, 1030, + /* 190 */ 935, 849, 861, 859, 986, 239, 832, 973, 973, 832, + /* 200 */ 973, 933, 395, 918, 227, 391, 227, 395, 1028, 852, + /* 210 */ 436, 860, 227, 928, 1543, 1543, 1543, 1543, 1543, 480, + /* 220 */ 111, 92, 256, 1385, 1393, 18, 13, 472, 30, 571, + /* 230 */ 219, 219, 219, 219, 219, 219, 219, 332, 441, 162, + /* 240 */ 422, 524, 162, 162, 162, 767, 607, 270, 687, 710, + /* 250 */ 715, 719, 90, 698, 789, 108, 559, 700, 760, 529, + /* 260 */ 439, 124, 448, 766, 618, 778, 724, 787, 788, 790, + /* 270 */ 799, 804, 735, 745, 807, 810, 820, 827, 833, 836, + /* 280 */ 728, 744, 1122, 1123, 1060, 1125, 1088, 968, 1090, 1091, + /* 290 */ 1094, 974, 1135, 1098, 1100, 980, 1141, 1105, 1144, 1107, + /* 300 */ 1146, 1074, 999, 1005, 1047, 1012, 1159, 1160, 1110, 1022, + /* 310 */ 1165, 1167, 1082, 1169, 1170, 1171, 1174, 1175, 1181, 1182, + /* 320 */ 1184, 1185, 1186, 1189, 1190, 1191, 1197, 1198, 1199, 1080, + /* 330 */ 1207, 1208, 1209, 1210, 1211, 1213, 1180, 1214, 1215, 1216, + /* 340 */ 1217, 1218, 1221, 1222, 1223, 1224, 1183, 1228, 1187, 1231, + /* 350 */ 1234, 1201, 1200, 1192, 1240, 1205, 1212, 1204, 1244, 1229, + /* 360 */ 1220, 1225, 1245, 1232, 1230, 1226, 1253, 1272, 1273, 1274, + /* 370 */ 1193, 1196, 1242, 1227, 1256, 1281, 1246, 1247, 1249, 1250, + /* 380 */ 1233, 1227, 1251, 1257, 1283, 1275, 1299, 1279, 1263, 1303, + /* 390 */ 1285, 1267, 1308, 1287, 1310, 1289, 1292, 1315, 1194, 1173, + /* 400 */ 1282, 1322, 1178, 1302, 1195, 1203, 1325, 1330, 1235, 1334, + /* 410 */ 1262, 1294, 1206, 1269, 1270, 1152, 1284, 1276, 1286, 1288, + /* 420 */ 1290, 1291, 1295, 1277, 1280, 1298, 1278, 1166, 1300, 1301, + /* 430 */ 1296, 1179, 1306, 1297, 1305, 1307, 1168, 1365, 1336, 1343, + /* 440 */ 1356, 1357, 1359, 1360, 1400, 1241, 1317, 1331, 1332, 1337, + /* 450 */ 1338, 1333, 1335, 1341, 1346, 1304, 1351, 1426, 1384, 1309, + /* 460 */ 1354, 1349, 1348, 1350, 1413, 1363, 1358, 1364, 1403, 1406, + /* 470 */ 1373, 1374, 1410, 1377, 1378, 1414, 1382, 1386, 1419, 1388, + /* 480 */ 1389, 1422, 1391, 1367, 1368, 1369, 1370, 1441, 1383, 1397, + /* 490 */ 1435, 1372, 1405, 1408, 1436, 1227, 1461, 1433, 1437, 1428, + /* 500 */ 1416, 1415, 1451, 1452, 1456, 1458, 1459, 1460, 1464, 1482, + /* 510 */ 1448, 1233, 1468, 1227, 1469, 1470, 1471, 1472, 1473, 1474, + /* 520 */ 1475, 1514, 1477, 1480, 1476, 1517, 1483, 1484, 1479, 1518, + /* 530 */ 1485, 1488, 1486, 1525, 1489, 1490, 1487, 1528, 1493, 1495, + /* 540 */ 1533, 1534, 1513, 1515, 1516, 1519, 1521, 1520, }; #define YY_REDUCE_COUNT (218) -#define YY_REDUCE_MIN (-274) -#define YY_REDUCE_MAX (1160) +#define YY_REDUCE_MIN (-251) +#define YY_REDUCE_MAX (1202) static const short yy_reduce_ofst[] = { - /* 0 */ -26, -195, 59, -122, 476, 512, 548, 598, 625, 640, - /* 10 */ 423, 667, 705, 743, 770, 778, 822, 856, 864, 869, - /* 20 */ 911, 916, 924, 968, 983, 994, 1019, 1053, 1066, 1100, - /* 30 */ 1108, 1113, 1155, 1160, -148, 175, 227, -163, -239, -201, - /* 40 */ -246, -142, 427, 206, -255, -253, -120, 54, 88, 291, - /* 50 */ 347, 429, 431, 66, -113, 62, 105, -87, 435, 457, - /* 60 */ 158, 474, 424, 469, 437, 504, 79, -208, -274, -274, - /* 70 */ -274, -204, -227, 81, -99, 91, 156, 196, 198, 202, - /* 80 */ 309, 338, 355, 376, 398, 407, 422, 436, 470, 471, - /* 90 */ 513, 514, 550, 552, -159, -132, 176, -45, -89, -38, - /* 100 */ 231, 241, 106, 221, 17, 335, 336, 303, 344, -226, - /* 110 */ 141, 162, 296, 349, 350, 359, 147, 396, 484, 454, - /* 120 */ 478, 520, 554, 565, 529, 618, 564, 551, 551, 551, - /* 130 */ 614, 549, 570, 651, 612, 672, 646, 687, 693, 675, - /* 140 */ 696, 698, 734, 689, 701, 740, 718, 710, 746, 748, - /* 150 */ 747, 749, 758, 737, 738, 739, 741, 753, 763, 765, - /* 160 */ 766, 768, 769, 771, 754, 760, 773, 779, 713, 719, - /* 170 */ 727, 777, 781, 755, 780, 756, 709, 774, 772, 735, - /* 180 */ 775, 783, 784, 750, 757, 762, 759, 551, 805, 789, - /* 190 */ 785, 776, 792, 786, 787, 614, 808, 820, 823, 813, - /* 200 */ 825, 818, 841, 824, 868, 870, 871, 843, 848, 881, - /* 210 */ 865, 886, 876, 892, 846, 878, 884, 896, 879, + /* 0 */ -208, 419, -195, -142, 461, 503, 551, 593, 42, 640, + /* 10 */ 682, 688, 464, 693, 739, 764, 806, 834, 877, 904, + /* 20 */ 919, 930, 976, 984, 989, 1018, 1043, 1070, 1078, 1114, + /* 30 */ 1143, 1148, 1156, 1202, 362, 785, 809, 116, -201, -132, + /* 40 */ -246, 29, 66, -65, -251, -249, -169, -29, 93, 94, + /* 50 */ 95, 282, 285, -90, -233, 26, -53, -173, 263, 417, + /* 60 */ 35, 283, 184, 353, 185, 418, 258, -213, -175, -175, + /* 70 */ -175, -211, 48, 238, -126, 340, 344, 369, 376, 394, + /* 80 */ 406, 413, 445, 453, 454, 459, 466, 467, 491, 501, + /* 90 */ 509, 515, 533, 549, 20, 191, 257, 269, 327, 328, + /* 100 */ 357, 415, 295, -98, 433, 183, 470, -221, -203, -197, + /* 110 */ -188, 320, 443, 532, 562, 577, 550, 414, 592, 517, + /* 120 */ 518, 586, 589, 599, 553, 641, 588, 573, 573, 573, + /* 130 */ 635, 565, 583, 666, 620, 667, 638, 691, 692, 661, + /* 140 */ 670, 671, 708, 663, 672, 714, 694, 689, 720, 722, + /* 150 */ 729, 732, 740, 713, 736, 737, 738, 741, 742, 743, + /* 160 */ 759, 761, 765, 768, 749, 784, 746, 762, 753, 750, + /* 170 */ 747, 792, 776, 756, 794, 751, 723, 771, 774, 730, + /* 180 */ 777, 775, 779, 734, 748, 754, 757, 573, 811, 793, + /* 190 */ 772, 769, 758, 770, 796, 635, 800, 808, 817, 826, + /* 200 */ 829, 837, 845, 839, 873, 866, 883, 858, 864, 882, + /* 210 */ 879, 888, 894, 898, 850, 885, 887, 900, 911, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 10 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 20 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 30 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 40 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 50 */ 1219, 1219, 1219, 1278, 1219, 1219, 1219, 1219, 1219, 1219, - /* 60 */ 1219, 1219, 1219, 1219, 1219, 1219, 1276, 1416, 1219, 1552, - /* 70 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 80 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 90 */ 1219, 1219, 1219, 1219, 1219, 1219, 1278, 1219, 1563, 1563, - /* 100 */ 1563, 1276, 1219, 1219, 1219, 1219, 1219, 1371, 1219, 1219, - /* 110 */ 1219, 1219, 1219, 1219, 1219, 1219, 1450, 1219, 1219, 1627, - /* 120 */ 1219, 1219, 1324, 1219, 1587, 1219, 1579, 1555, 1569, 1556, - /* 130 */ 1219, 1612, 1572, 1219, 1219, 1219, 1442, 1219, 1219, 1421, - /* 140 */ 1418, 1418, 1219, 1219, 1219, 1278, 1219, 1219, 1278, 1278, - /* 150 */ 1219, 1278, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 160 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1452, - /* 170 */ 1219, 1276, 1219, 1219, 1276, 1219, 1594, 1592, 1219, 1594, - /* 180 */ 1592, 1219, 1219, 1606, 1602, 1585, 1583, 1569, 1219, 1219, - /* 190 */ 1219, 1630, 1618, 1614, 1219, 1219, 1592, 1219, 1219, 1592, - /* 200 */ 1219, 1429, 1219, 1219, 1276, 1219, 1276, 1219, 1340, 1219, - /* 210 */ 1219, 1219, 1276, 1219, 1444, 1374, 1374, 1279, 1224, 1219, - /* 220 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1514, - /* 230 */ 1515, 1605, 1604, 1514, 1529, 1528, 1527, 1219, 1219, 1509, - /* 240 */ 1219, 1219, 1510, 1508, 1507, 1219, 1219, 1219, 1219, 1219, - /* 250 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1553, - /* 260 */ 1219, 1615, 1619, 1219, 1219, 1219, 1489, 1219, 1219, 1219, - /* 270 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 280 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 290 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 300 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 310 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 320 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 330 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 340 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 350 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 360 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 370 */ 1219, 1219, 1219, 1385, 1219, 1219, 1219, 1219, 1219, 1219, - /* 380 */ 1305, 1304, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 390 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 400 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 410 */ 1219, 1219, 1219, 1576, 1586, 1219, 1219, 1219, 1219, 1219, - /* 420 */ 1219, 1219, 1219, 1219, 1489, 1219, 1603, 1219, 1562, 1558, - /* 430 */ 1219, 1219, 1554, 1219, 1219, 1613, 1219, 1219, 1219, 1219, - /* 440 */ 1219, 1219, 1219, 1219, 1548, 1219, 1219, 1219, 1219, 1219, - /* 450 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 460 */ 1219, 1219, 1488, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 470 */ 1368, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 480 */ 1219, 1219, 1219, 1353, 1351, 1350, 1349, 1219, 1346, 1219, - /* 490 */ 1219, 1219, 1219, 1219, 1219, 1376, 1219, 1219, 1219, 1219, - /* 500 */ 1219, 1299, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 510 */ 1219, 1290, 1219, 1289, 1219, 1219, 1219, 1219, 1219, 1219, - /* 520 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 530 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, - /* 540 */ 1219, 1219, 1219, 1219, 1219, 1219, 1219, 1219, + /* 0 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 10 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 20 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 30 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 40 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 50 */ 1221, 1221, 1221, 1280, 1221, 1221, 1221, 1221, 1221, 1221, + /* 60 */ 1221, 1221, 1221, 1221, 1221, 1221, 1278, 1418, 1221, 1555, + /* 70 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 80 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 90 */ 1221, 1221, 1221, 1221, 1221, 1221, 1280, 1221, 1566, 1566, + /* 100 */ 1566, 1278, 1221, 1221, 1221, 1221, 1221, 1373, 1221, 1221, + /* 110 */ 1221, 1221, 1221, 1221, 1221, 1221, 1452, 1221, 1221, 1630, + /* 120 */ 1221, 1221, 1221, 1326, 1590, 1221, 1582, 1558, 1572, 1559, + /* 130 */ 1221, 1615, 1575, 1221, 1221, 1221, 1444, 1221, 1221, 1423, + /* 140 */ 1420, 1420, 1221, 1221, 1221, 1280, 1221, 1221, 1280, 1280, + /* 150 */ 1221, 1280, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 160 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1454, + /* 170 */ 1221, 1278, 1221, 1221, 1278, 1221, 1597, 1595, 1221, 1597, + /* 180 */ 1595, 1221, 1221, 1609, 1605, 1588, 1586, 1572, 1221, 1221, + /* 190 */ 1221, 1633, 1621, 1617, 1221, 1221, 1595, 1221, 1221, 1595, + /* 200 */ 1221, 1431, 1221, 1221, 1278, 1221, 1278, 1221, 1342, 1221, + /* 210 */ 1221, 1221, 1278, 1221, 1446, 1376, 1376, 1281, 1226, 1221, + /* 220 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1519, + /* 230 */ 1520, 1608, 1607, 1519, 1532, 1531, 1530, 1221, 1221, 1514, + /* 240 */ 1221, 1221, 1515, 1513, 1512, 1221, 1221, 1221, 1221, 1221, + /* 250 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1556, + /* 260 */ 1221, 1618, 1622, 1221, 1221, 1221, 1491, 1221, 1221, 1221, + /* 270 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 280 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 290 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 300 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 310 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 320 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 330 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 340 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 350 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 360 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 370 */ 1221, 1221, 1221, 1387, 1221, 1221, 1221, 1221, 1221, 1221, + /* 380 */ 1307, 1306, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 390 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 400 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 410 */ 1221, 1221, 1221, 1579, 1589, 1221, 1221, 1221, 1221, 1221, + /* 420 */ 1221, 1221, 1221, 1221, 1491, 1221, 1606, 1221, 1565, 1561, + /* 430 */ 1221, 1221, 1557, 1221, 1221, 1616, 1221, 1221, 1221, 1221, + /* 440 */ 1221, 1221, 1221, 1221, 1551, 1221, 1221, 1221, 1221, 1221, + /* 450 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 460 */ 1221, 1221, 1490, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 470 */ 1370, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 480 */ 1221, 1221, 1221, 1355, 1353, 1352, 1351, 1221, 1348, 1221, + /* 490 */ 1221, 1221, 1221, 1221, 1221, 1378, 1221, 1221, 1221, 1221, + /* 500 */ 1221, 1301, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 510 */ 1221, 1292, 1221, 1291, 1221, 1221, 1221, 1221, 1221, 1221, + /* 520 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 530 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, + /* 540 */ 1221, 1221, 1221, 1221, 1221, 1221, 1221, 1221, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1386,146 +1388,147 @@ static const char *const yyRuleName[] = { /* 268 */ "function_name ::= NK_ID", /* 269 */ "function_name ::= FIRST", /* 270 */ "function_name ::= LAST", - /* 271 */ "table_alias ::= NK_ID", - /* 272 */ "column_alias ::= NK_ID", - /* 273 */ "user_name ::= NK_ID", - /* 274 */ "index_name ::= NK_ID", - /* 275 */ "topic_name ::= NK_ID", - /* 276 */ "stream_name ::= NK_ID", - /* 277 */ "expression ::= literal", - /* 278 */ "expression ::= pseudo_column", - /* 279 */ "expression ::= column_reference", - /* 280 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 281 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 282 */ "expression ::= function_name NK_LP expression AS type_name NK_RP", - /* 283 */ "expression ::= subquery", - /* 284 */ "expression ::= NK_LP expression NK_RP", - /* 285 */ "expression ::= NK_PLUS expression", - /* 286 */ "expression ::= NK_MINUS expression", - /* 287 */ "expression ::= expression NK_PLUS expression", - /* 288 */ "expression ::= expression NK_MINUS expression", - /* 289 */ "expression ::= expression NK_STAR expression", - /* 290 */ "expression ::= expression NK_SLASH expression", - /* 291 */ "expression ::= expression NK_REM expression", - /* 292 */ "expression_list ::= expression", - /* 293 */ "expression_list ::= expression_list NK_COMMA expression", - /* 294 */ "column_reference ::= column_name", - /* 295 */ "column_reference ::= table_name NK_DOT column_name", - /* 296 */ "pseudo_column ::= NOW", - /* 297 */ "pseudo_column ::= TODAY", - /* 298 */ "pseudo_column ::= ROWTS", - /* 299 */ "pseudo_column ::= TBNAME", - /* 300 */ "pseudo_column ::= QSTARTTS", - /* 301 */ "pseudo_column ::= QENDTS", - /* 302 */ "pseudo_column ::= WSTARTTS", - /* 303 */ "pseudo_column ::= WENDTS", - /* 304 */ "pseudo_column ::= WDURATION", - /* 305 */ "predicate ::= expression compare_op expression", - /* 306 */ "predicate ::= expression BETWEEN expression AND expression", - /* 307 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 308 */ "predicate ::= expression IS NULL", - /* 309 */ "predicate ::= expression IS NOT NULL", - /* 310 */ "predicate ::= expression in_op in_predicate_value", - /* 311 */ "compare_op ::= NK_LT", - /* 312 */ "compare_op ::= NK_GT", - /* 313 */ "compare_op ::= NK_LE", - /* 314 */ "compare_op ::= NK_GE", - /* 315 */ "compare_op ::= NK_NE", - /* 316 */ "compare_op ::= NK_EQ", - /* 317 */ "compare_op ::= LIKE", - /* 318 */ "compare_op ::= NOT LIKE", - /* 319 */ "compare_op ::= MATCH", - /* 320 */ "compare_op ::= NMATCH", - /* 321 */ "in_op ::= IN", - /* 322 */ "in_op ::= NOT IN", - /* 323 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 324 */ "boolean_value_expression ::= boolean_primary", - /* 325 */ "boolean_value_expression ::= NOT boolean_primary", - /* 326 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 327 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 328 */ "boolean_primary ::= predicate", - /* 329 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 330 */ "common_expression ::= expression", - /* 331 */ "common_expression ::= boolean_value_expression", - /* 332 */ "from_clause ::= FROM table_reference_list", - /* 333 */ "table_reference_list ::= table_reference", - /* 334 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 335 */ "table_reference ::= table_primary", - /* 336 */ "table_reference ::= joined_table", - /* 337 */ "table_primary ::= table_name alias_opt", - /* 338 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 339 */ "table_primary ::= subquery alias_opt", - /* 340 */ "table_primary ::= parenthesized_joined_table", - /* 341 */ "alias_opt ::=", - /* 342 */ "alias_opt ::= table_alias", - /* 343 */ "alias_opt ::= AS table_alias", - /* 344 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 345 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 346 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 347 */ "join_type ::=", - /* 348 */ "join_type ::= INNER", - /* 349 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 350 */ "set_quantifier_opt ::=", - /* 351 */ "set_quantifier_opt ::= DISTINCT", - /* 352 */ "set_quantifier_opt ::= ALL", - /* 353 */ "select_list ::= NK_STAR", - /* 354 */ "select_list ::= select_sublist", - /* 355 */ "select_sublist ::= select_item", - /* 356 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 357 */ "select_item ::= common_expression", - /* 358 */ "select_item ::= common_expression column_alias", - /* 359 */ "select_item ::= common_expression AS column_alias", - /* 360 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 361 */ "where_clause_opt ::=", - /* 362 */ "where_clause_opt ::= WHERE search_condition", - /* 363 */ "partition_by_clause_opt ::=", - /* 364 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 365 */ "twindow_clause_opt ::=", - /* 366 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 367 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 368 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 369 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 370 */ "sliding_opt ::=", - /* 371 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 372 */ "fill_opt ::=", - /* 373 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 374 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 375 */ "fill_mode ::= NONE", - /* 376 */ "fill_mode ::= PREV", - /* 377 */ "fill_mode ::= NULL", - /* 378 */ "fill_mode ::= LINEAR", - /* 379 */ "fill_mode ::= NEXT", - /* 380 */ "group_by_clause_opt ::=", - /* 381 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 382 */ "group_by_list ::= expression", - /* 383 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 384 */ "having_clause_opt ::=", - /* 385 */ "having_clause_opt ::= HAVING search_condition", - /* 386 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 387 */ "query_expression_body ::= query_primary", - /* 388 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 389 */ "query_primary ::= query_specification", - /* 390 */ "order_by_clause_opt ::=", - /* 391 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 392 */ "slimit_clause_opt ::=", - /* 393 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 394 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 395 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 396 */ "limit_clause_opt ::=", - /* 397 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 398 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 399 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 400 */ "subquery ::= NK_LP query_expression NK_RP", - /* 401 */ "search_condition ::= common_expression", - /* 402 */ "sort_specification_list ::= sort_specification", - /* 403 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 404 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 405 */ "ordering_specification_opt ::=", - /* 406 */ "ordering_specification_opt ::= ASC", - /* 407 */ "ordering_specification_opt ::= DESC", - /* 408 */ "null_ordering_opt ::=", - /* 409 */ "null_ordering_opt ::= NULLS FIRST", - /* 410 */ "null_ordering_opt ::= NULLS LAST", + /* 271 */ "function_name ::= NOW", + /* 272 */ "function_name ::= TODAY", + /* 273 */ "table_alias ::= NK_ID", + /* 274 */ "column_alias ::= NK_ID", + /* 275 */ "user_name ::= NK_ID", + /* 276 */ "index_name ::= NK_ID", + /* 277 */ "topic_name ::= NK_ID", + /* 278 */ "stream_name ::= NK_ID", + /* 279 */ "expression ::= literal", + /* 280 */ "expression ::= pseudo_column", + /* 281 */ "expression ::= column_reference", + /* 282 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 283 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 284 */ "expression ::= function_name NK_LP NK_RP", + /* 285 */ "expression ::= function_name NK_LP expression AS type_name NK_RP", + /* 286 */ "expression ::= subquery", + /* 287 */ "expression ::= NK_LP expression NK_RP", + /* 288 */ "expression ::= NK_PLUS expression", + /* 289 */ "expression ::= NK_MINUS expression", + /* 290 */ "expression ::= expression NK_PLUS expression", + /* 291 */ "expression ::= expression NK_MINUS expression", + /* 292 */ "expression ::= expression NK_STAR expression", + /* 293 */ "expression ::= expression NK_SLASH expression", + /* 294 */ "expression ::= expression NK_REM expression", + /* 295 */ "expression_list ::= expression", + /* 296 */ "expression_list ::= expression_list NK_COMMA expression", + /* 297 */ "column_reference ::= column_name", + /* 298 */ "column_reference ::= table_name NK_DOT column_name", + /* 299 */ "pseudo_column ::= ROWTS", + /* 300 */ "pseudo_column ::= TBNAME", + /* 301 */ "pseudo_column ::= QSTARTTS", + /* 302 */ "pseudo_column ::= QENDTS", + /* 303 */ "pseudo_column ::= WSTARTTS", + /* 304 */ "pseudo_column ::= WENDTS", + /* 305 */ "pseudo_column ::= WDURATION", + /* 306 */ "predicate ::= expression compare_op expression", + /* 307 */ "predicate ::= expression BETWEEN expression AND expression", + /* 308 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 309 */ "predicate ::= expression IS NULL", + /* 310 */ "predicate ::= expression IS NOT NULL", + /* 311 */ "predicate ::= expression in_op in_predicate_value", + /* 312 */ "compare_op ::= NK_LT", + /* 313 */ "compare_op ::= NK_GT", + /* 314 */ "compare_op ::= NK_LE", + /* 315 */ "compare_op ::= NK_GE", + /* 316 */ "compare_op ::= NK_NE", + /* 317 */ "compare_op ::= NK_EQ", + /* 318 */ "compare_op ::= LIKE", + /* 319 */ "compare_op ::= NOT LIKE", + /* 320 */ "compare_op ::= MATCH", + /* 321 */ "compare_op ::= NMATCH", + /* 322 */ "in_op ::= IN", + /* 323 */ "in_op ::= NOT IN", + /* 324 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 325 */ "boolean_value_expression ::= boolean_primary", + /* 326 */ "boolean_value_expression ::= NOT boolean_primary", + /* 327 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 328 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 329 */ "boolean_primary ::= predicate", + /* 330 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 331 */ "common_expression ::= expression", + /* 332 */ "common_expression ::= boolean_value_expression", + /* 333 */ "from_clause ::= FROM table_reference_list", + /* 334 */ "table_reference_list ::= table_reference", + /* 335 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 336 */ "table_reference ::= table_primary", + /* 337 */ "table_reference ::= joined_table", + /* 338 */ "table_primary ::= table_name alias_opt", + /* 339 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 340 */ "table_primary ::= subquery alias_opt", + /* 341 */ "table_primary ::= parenthesized_joined_table", + /* 342 */ "alias_opt ::=", + /* 343 */ "alias_opt ::= table_alias", + /* 344 */ "alias_opt ::= AS table_alias", + /* 345 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 346 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 347 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 348 */ "join_type ::=", + /* 349 */ "join_type ::= INNER", + /* 350 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 351 */ "set_quantifier_opt ::=", + /* 352 */ "set_quantifier_opt ::= DISTINCT", + /* 353 */ "set_quantifier_opt ::= ALL", + /* 354 */ "select_list ::= NK_STAR", + /* 355 */ "select_list ::= select_sublist", + /* 356 */ "select_sublist ::= select_item", + /* 357 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 358 */ "select_item ::= common_expression", + /* 359 */ "select_item ::= common_expression column_alias", + /* 360 */ "select_item ::= common_expression AS column_alias", + /* 361 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 362 */ "where_clause_opt ::=", + /* 363 */ "where_clause_opt ::= WHERE search_condition", + /* 364 */ "partition_by_clause_opt ::=", + /* 365 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 366 */ "twindow_clause_opt ::=", + /* 367 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 368 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 369 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 370 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 371 */ "sliding_opt ::=", + /* 372 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 373 */ "fill_opt ::=", + /* 374 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 375 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 376 */ "fill_mode ::= NONE", + /* 377 */ "fill_mode ::= PREV", + /* 378 */ "fill_mode ::= NULL", + /* 379 */ "fill_mode ::= LINEAR", + /* 380 */ "fill_mode ::= NEXT", + /* 381 */ "group_by_clause_opt ::=", + /* 382 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 383 */ "group_by_list ::= expression", + /* 384 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 385 */ "having_clause_opt ::=", + /* 386 */ "having_clause_opt ::= HAVING search_condition", + /* 387 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 388 */ "query_expression_body ::= query_primary", + /* 389 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 390 */ "query_primary ::= query_specification", + /* 391 */ "order_by_clause_opt ::=", + /* 392 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 393 */ "slimit_clause_opt ::=", + /* 394 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 395 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 396 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 397 */ "limit_clause_opt ::=", + /* 398 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 399 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 400 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 401 */ "subquery ::= NK_LP query_expression NK_RP", + /* 402 */ "search_condition ::= common_expression", + /* 403 */ "sort_specification_list ::= sort_specification", + /* 404 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 405 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 406 */ "ordering_specification_opt ::=", + /* 407 */ "ordering_specification_opt ::= ASC", + /* 408 */ "ordering_specification_opt ::= DESC", + /* 409 */ "null_ordering_opt ::=", + /* 410 */ "null_ordering_opt ::= NULLS FIRST", + /* 411 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2363,146 +2366,147 @@ static const YYCODETYPE yyRuleInfoLhs[] = { 253, /* (268) function_name ::= NK_ID */ 253, /* (269) function_name ::= FIRST */ 253, /* (270) function_name ::= LAST */ - 271, /* (271) table_alias ::= NK_ID */ - 272, /* (272) column_alias ::= NK_ID */ - 214, /* (273) user_name ::= NK_ID */ - 254, /* (274) index_name ::= NK_ID */ - 261, /* (275) topic_name ::= NK_ID */ - 267, /* (276) stream_name ::= NK_ID */ - 273, /* (277) expression ::= literal */ - 273, /* (278) expression ::= pseudo_column */ - 273, /* (279) expression ::= column_reference */ - 273, /* (280) expression ::= function_name NK_LP expression_list NK_RP */ - 273, /* (281) expression ::= function_name NK_LP NK_STAR NK_RP */ - 273, /* (282) expression ::= function_name NK_LP expression AS type_name NK_RP */ - 273, /* (283) expression ::= subquery */ - 273, /* (284) expression ::= NK_LP expression NK_RP */ - 273, /* (285) expression ::= NK_PLUS expression */ - 273, /* (286) expression ::= NK_MINUS expression */ - 273, /* (287) expression ::= expression NK_PLUS expression */ - 273, /* (288) expression ::= expression NK_MINUS expression */ - 273, /* (289) expression ::= expression NK_STAR expression */ - 273, /* (290) expression ::= expression NK_SLASH expression */ - 273, /* (291) expression ::= expression NK_REM expression */ - 260, /* (292) expression_list ::= expression */ - 260, /* (293) expression_list ::= expression_list NK_COMMA expression */ - 275, /* (294) column_reference ::= column_name */ - 275, /* (295) column_reference ::= table_name NK_DOT column_name */ - 274, /* (296) pseudo_column ::= NOW */ - 274, /* (297) pseudo_column ::= TODAY */ - 274, /* (298) pseudo_column ::= ROWTS */ - 274, /* (299) pseudo_column ::= TBNAME */ - 274, /* (300) pseudo_column ::= QSTARTTS */ - 274, /* (301) pseudo_column ::= QENDTS */ - 274, /* (302) pseudo_column ::= WSTARTTS */ - 274, /* (303) pseudo_column ::= WENDTS */ - 274, /* (304) pseudo_column ::= WDURATION */ - 277, /* (305) predicate ::= expression compare_op expression */ - 277, /* (306) predicate ::= expression BETWEEN expression AND expression */ - 277, /* (307) predicate ::= expression NOT BETWEEN expression AND expression */ - 277, /* (308) predicate ::= expression IS NULL */ - 277, /* (309) predicate ::= expression IS NOT NULL */ - 277, /* (310) predicate ::= expression in_op in_predicate_value */ - 278, /* (311) compare_op ::= NK_LT */ - 278, /* (312) compare_op ::= NK_GT */ - 278, /* (313) compare_op ::= NK_LE */ - 278, /* (314) compare_op ::= NK_GE */ - 278, /* (315) compare_op ::= NK_NE */ - 278, /* (316) compare_op ::= NK_EQ */ - 278, /* (317) compare_op ::= LIKE */ - 278, /* (318) compare_op ::= NOT LIKE */ - 278, /* (319) compare_op ::= MATCH */ - 278, /* (320) compare_op ::= NMATCH */ - 279, /* (321) in_op ::= IN */ - 279, /* (322) in_op ::= NOT IN */ - 280, /* (323) in_predicate_value ::= NK_LP expression_list NK_RP */ - 281, /* (324) boolean_value_expression ::= boolean_primary */ - 281, /* (325) boolean_value_expression ::= NOT boolean_primary */ - 281, /* (326) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - 281, /* (327) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - 282, /* (328) boolean_primary ::= predicate */ - 282, /* (329) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - 283, /* (330) common_expression ::= expression */ - 283, /* (331) common_expression ::= boolean_value_expression */ - 284, /* (332) from_clause ::= FROM table_reference_list */ - 285, /* (333) table_reference_list ::= table_reference */ - 285, /* (334) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - 286, /* (335) table_reference ::= table_primary */ - 286, /* (336) table_reference ::= joined_table */ - 287, /* (337) table_primary ::= table_name alias_opt */ - 287, /* (338) table_primary ::= db_name NK_DOT table_name alias_opt */ - 287, /* (339) table_primary ::= subquery alias_opt */ - 287, /* (340) table_primary ::= parenthesized_joined_table */ - 289, /* (341) alias_opt ::= */ - 289, /* (342) alias_opt ::= table_alias */ - 289, /* (343) alias_opt ::= AS table_alias */ - 290, /* (344) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - 290, /* (345) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - 288, /* (346) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 291, /* (347) join_type ::= */ - 291, /* (348) join_type ::= INNER */ - 293, /* (349) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 294, /* (350) set_quantifier_opt ::= */ - 294, /* (351) set_quantifier_opt ::= DISTINCT */ - 294, /* (352) set_quantifier_opt ::= ALL */ - 295, /* (353) select_list ::= NK_STAR */ - 295, /* (354) select_list ::= select_sublist */ - 301, /* (355) select_sublist ::= select_item */ - 301, /* (356) select_sublist ::= select_sublist NK_COMMA select_item */ - 302, /* (357) select_item ::= common_expression */ - 302, /* (358) select_item ::= common_expression column_alias */ - 302, /* (359) select_item ::= common_expression AS column_alias */ - 302, /* (360) select_item ::= table_name NK_DOT NK_STAR */ - 296, /* (361) where_clause_opt ::= */ - 296, /* (362) where_clause_opt ::= WHERE search_condition */ - 297, /* (363) partition_by_clause_opt ::= */ - 297, /* (364) partition_by_clause_opt ::= PARTITION BY expression_list */ - 298, /* (365) twindow_clause_opt ::= */ - 298, /* (366) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - 298, /* (367) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - 298, /* (368) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - 298, /* (369) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - 258, /* (370) sliding_opt ::= */ - 258, /* (371) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - 303, /* (372) fill_opt ::= */ - 303, /* (373) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - 303, /* (374) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - 304, /* (375) fill_mode ::= NONE */ - 304, /* (376) fill_mode ::= PREV */ - 304, /* (377) fill_mode ::= NULL */ - 304, /* (378) fill_mode ::= LINEAR */ - 304, /* (379) fill_mode ::= NEXT */ - 299, /* (380) group_by_clause_opt ::= */ - 299, /* (381) group_by_clause_opt ::= GROUP BY group_by_list */ - 305, /* (382) group_by_list ::= expression */ - 305, /* (383) group_by_list ::= group_by_list NK_COMMA expression */ - 300, /* (384) having_clause_opt ::= */ - 300, /* (385) having_clause_opt ::= HAVING search_condition */ - 262, /* (386) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - 306, /* (387) query_expression_body ::= query_primary */ - 306, /* (388) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - 310, /* (389) query_primary ::= query_specification */ - 307, /* (390) order_by_clause_opt ::= */ - 307, /* (391) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 308, /* (392) slimit_clause_opt ::= */ - 308, /* (393) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - 308, /* (394) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - 308, /* (395) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 309, /* (396) limit_clause_opt ::= */ - 309, /* (397) limit_clause_opt ::= LIMIT NK_INTEGER */ - 309, /* (398) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - 309, /* (399) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 276, /* (400) subquery ::= NK_LP query_expression NK_RP */ - 292, /* (401) search_condition ::= common_expression */ - 311, /* (402) sort_specification_list ::= sort_specification */ - 311, /* (403) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - 312, /* (404) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - 313, /* (405) ordering_specification_opt ::= */ - 313, /* (406) ordering_specification_opt ::= ASC */ - 313, /* (407) ordering_specification_opt ::= DESC */ - 314, /* (408) null_ordering_opt ::= */ - 314, /* (409) null_ordering_opt ::= NULLS FIRST */ - 314, /* (410) null_ordering_opt ::= NULLS LAST */ + 253, /* (271) function_name ::= NOW */ + 253, /* (272) function_name ::= TODAY */ + 271, /* (273) table_alias ::= NK_ID */ + 272, /* (274) column_alias ::= NK_ID */ + 214, /* (275) user_name ::= NK_ID */ + 254, /* (276) index_name ::= NK_ID */ + 261, /* (277) topic_name ::= NK_ID */ + 267, /* (278) stream_name ::= NK_ID */ + 273, /* (279) expression ::= literal */ + 273, /* (280) expression ::= pseudo_column */ + 273, /* (281) expression ::= column_reference */ + 273, /* (282) expression ::= function_name NK_LP expression_list NK_RP */ + 273, /* (283) expression ::= function_name NK_LP NK_STAR NK_RP */ + 273, /* (284) expression ::= function_name NK_LP NK_RP */ + 273, /* (285) expression ::= function_name NK_LP expression AS type_name NK_RP */ + 273, /* (286) expression ::= subquery */ + 273, /* (287) expression ::= NK_LP expression NK_RP */ + 273, /* (288) expression ::= NK_PLUS expression */ + 273, /* (289) expression ::= NK_MINUS expression */ + 273, /* (290) expression ::= expression NK_PLUS expression */ + 273, /* (291) expression ::= expression NK_MINUS expression */ + 273, /* (292) expression ::= expression NK_STAR expression */ + 273, /* (293) expression ::= expression NK_SLASH expression */ + 273, /* (294) expression ::= expression NK_REM expression */ + 260, /* (295) expression_list ::= expression */ + 260, /* (296) expression_list ::= expression_list NK_COMMA expression */ + 275, /* (297) column_reference ::= column_name */ + 275, /* (298) column_reference ::= table_name NK_DOT column_name */ + 274, /* (299) pseudo_column ::= ROWTS */ + 274, /* (300) pseudo_column ::= TBNAME */ + 274, /* (301) pseudo_column ::= QSTARTTS */ + 274, /* (302) pseudo_column ::= QENDTS */ + 274, /* (303) pseudo_column ::= WSTARTTS */ + 274, /* (304) pseudo_column ::= WENDTS */ + 274, /* (305) pseudo_column ::= WDURATION */ + 277, /* (306) predicate ::= expression compare_op expression */ + 277, /* (307) predicate ::= expression BETWEEN expression AND expression */ + 277, /* (308) predicate ::= expression NOT BETWEEN expression AND expression */ + 277, /* (309) predicate ::= expression IS NULL */ + 277, /* (310) predicate ::= expression IS NOT NULL */ + 277, /* (311) predicate ::= expression in_op in_predicate_value */ + 278, /* (312) compare_op ::= NK_LT */ + 278, /* (313) compare_op ::= NK_GT */ + 278, /* (314) compare_op ::= NK_LE */ + 278, /* (315) compare_op ::= NK_GE */ + 278, /* (316) compare_op ::= NK_NE */ + 278, /* (317) compare_op ::= NK_EQ */ + 278, /* (318) compare_op ::= LIKE */ + 278, /* (319) compare_op ::= NOT LIKE */ + 278, /* (320) compare_op ::= MATCH */ + 278, /* (321) compare_op ::= NMATCH */ + 279, /* (322) in_op ::= IN */ + 279, /* (323) in_op ::= NOT IN */ + 280, /* (324) in_predicate_value ::= NK_LP expression_list NK_RP */ + 281, /* (325) boolean_value_expression ::= boolean_primary */ + 281, /* (326) boolean_value_expression ::= NOT boolean_primary */ + 281, /* (327) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + 281, /* (328) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + 282, /* (329) boolean_primary ::= predicate */ + 282, /* (330) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + 283, /* (331) common_expression ::= expression */ + 283, /* (332) common_expression ::= boolean_value_expression */ + 284, /* (333) from_clause ::= FROM table_reference_list */ + 285, /* (334) table_reference_list ::= table_reference */ + 285, /* (335) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + 286, /* (336) table_reference ::= table_primary */ + 286, /* (337) table_reference ::= joined_table */ + 287, /* (338) table_primary ::= table_name alias_opt */ + 287, /* (339) table_primary ::= db_name NK_DOT table_name alias_opt */ + 287, /* (340) table_primary ::= subquery alias_opt */ + 287, /* (341) table_primary ::= parenthesized_joined_table */ + 289, /* (342) alias_opt ::= */ + 289, /* (343) alias_opt ::= table_alias */ + 289, /* (344) alias_opt ::= AS table_alias */ + 290, /* (345) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + 290, /* (346) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + 288, /* (347) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 291, /* (348) join_type ::= */ + 291, /* (349) join_type ::= INNER */ + 293, /* (350) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 294, /* (351) set_quantifier_opt ::= */ + 294, /* (352) set_quantifier_opt ::= DISTINCT */ + 294, /* (353) set_quantifier_opt ::= ALL */ + 295, /* (354) select_list ::= NK_STAR */ + 295, /* (355) select_list ::= select_sublist */ + 301, /* (356) select_sublist ::= select_item */ + 301, /* (357) select_sublist ::= select_sublist NK_COMMA select_item */ + 302, /* (358) select_item ::= common_expression */ + 302, /* (359) select_item ::= common_expression column_alias */ + 302, /* (360) select_item ::= common_expression AS column_alias */ + 302, /* (361) select_item ::= table_name NK_DOT NK_STAR */ + 296, /* (362) where_clause_opt ::= */ + 296, /* (363) where_clause_opt ::= WHERE search_condition */ + 297, /* (364) partition_by_clause_opt ::= */ + 297, /* (365) partition_by_clause_opt ::= PARTITION BY expression_list */ + 298, /* (366) twindow_clause_opt ::= */ + 298, /* (367) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + 298, /* (368) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + 298, /* (369) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + 298, /* (370) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + 258, /* (371) sliding_opt ::= */ + 258, /* (372) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + 303, /* (373) fill_opt ::= */ + 303, /* (374) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + 303, /* (375) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + 304, /* (376) fill_mode ::= NONE */ + 304, /* (377) fill_mode ::= PREV */ + 304, /* (378) fill_mode ::= NULL */ + 304, /* (379) fill_mode ::= LINEAR */ + 304, /* (380) fill_mode ::= NEXT */ + 299, /* (381) group_by_clause_opt ::= */ + 299, /* (382) group_by_clause_opt ::= GROUP BY group_by_list */ + 305, /* (383) group_by_list ::= expression */ + 305, /* (384) group_by_list ::= group_by_list NK_COMMA expression */ + 300, /* (385) having_clause_opt ::= */ + 300, /* (386) having_clause_opt ::= HAVING search_condition */ + 262, /* (387) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + 306, /* (388) query_expression_body ::= query_primary */ + 306, /* (389) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + 310, /* (390) query_primary ::= query_specification */ + 307, /* (391) order_by_clause_opt ::= */ + 307, /* (392) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 308, /* (393) slimit_clause_opt ::= */ + 308, /* (394) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + 308, /* (395) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + 308, /* (396) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 309, /* (397) limit_clause_opt ::= */ + 309, /* (398) limit_clause_opt ::= LIMIT NK_INTEGER */ + 309, /* (399) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + 309, /* (400) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 276, /* (401) subquery ::= NK_LP query_expression NK_RP */ + 292, /* (402) search_condition ::= common_expression */ + 311, /* (403) sort_specification_list ::= sort_specification */ + 311, /* (404) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + 312, /* (405) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + 313, /* (406) ordering_specification_opt ::= */ + 313, /* (407) ordering_specification_opt ::= ASC */ + 313, /* (408) ordering_specification_opt ::= DESC */ + 314, /* (409) null_ordering_opt ::= */ + 314, /* (410) null_ordering_opt ::= NULLS FIRST */ + 314, /* (411) null_ordering_opt ::= NULLS LAST */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -2779,146 +2783,147 @@ static const signed char yyRuleInfoNRhs[] = { -1, /* (268) function_name ::= NK_ID */ -1, /* (269) function_name ::= FIRST */ -1, /* (270) function_name ::= LAST */ - -1, /* (271) table_alias ::= NK_ID */ - -1, /* (272) column_alias ::= NK_ID */ - -1, /* (273) user_name ::= NK_ID */ - -1, /* (274) index_name ::= NK_ID */ - -1, /* (275) topic_name ::= NK_ID */ - -1, /* (276) stream_name ::= NK_ID */ - -1, /* (277) expression ::= literal */ - -1, /* (278) expression ::= pseudo_column */ - -1, /* (279) expression ::= column_reference */ - -4, /* (280) expression ::= function_name NK_LP expression_list NK_RP */ - -4, /* (281) expression ::= function_name NK_LP NK_STAR NK_RP */ - -6, /* (282) expression ::= function_name NK_LP expression AS type_name NK_RP */ - -1, /* (283) expression ::= subquery */ - -3, /* (284) expression ::= NK_LP expression NK_RP */ - -2, /* (285) expression ::= NK_PLUS expression */ - -2, /* (286) expression ::= NK_MINUS expression */ - -3, /* (287) expression ::= expression NK_PLUS expression */ - -3, /* (288) expression ::= expression NK_MINUS expression */ - -3, /* (289) expression ::= expression NK_STAR expression */ - -3, /* (290) expression ::= expression NK_SLASH expression */ - -3, /* (291) expression ::= expression NK_REM expression */ - -1, /* (292) expression_list ::= expression */ - -3, /* (293) expression_list ::= expression_list NK_COMMA expression */ - -1, /* (294) column_reference ::= column_name */ - -3, /* (295) column_reference ::= table_name NK_DOT column_name */ - -1, /* (296) pseudo_column ::= NOW */ - -1, /* (297) pseudo_column ::= TODAY */ - -1, /* (298) pseudo_column ::= ROWTS */ - -1, /* (299) pseudo_column ::= TBNAME */ - -1, /* (300) pseudo_column ::= QSTARTTS */ - -1, /* (301) pseudo_column ::= QENDTS */ - -1, /* (302) pseudo_column ::= WSTARTTS */ - -1, /* (303) pseudo_column ::= WENDTS */ - -1, /* (304) pseudo_column ::= WDURATION */ - -3, /* (305) predicate ::= expression compare_op expression */ - -5, /* (306) predicate ::= expression BETWEEN expression AND expression */ - -6, /* (307) predicate ::= expression NOT BETWEEN expression AND expression */ - -3, /* (308) predicate ::= expression IS NULL */ - -4, /* (309) predicate ::= expression IS NOT NULL */ - -3, /* (310) predicate ::= expression in_op in_predicate_value */ - -1, /* (311) compare_op ::= NK_LT */ - -1, /* (312) compare_op ::= NK_GT */ - -1, /* (313) compare_op ::= NK_LE */ - -1, /* (314) compare_op ::= NK_GE */ - -1, /* (315) compare_op ::= NK_NE */ - -1, /* (316) compare_op ::= NK_EQ */ - -1, /* (317) compare_op ::= LIKE */ - -2, /* (318) compare_op ::= NOT LIKE */ - -1, /* (319) compare_op ::= MATCH */ - -1, /* (320) compare_op ::= NMATCH */ - -1, /* (321) in_op ::= IN */ - -2, /* (322) in_op ::= NOT IN */ - -3, /* (323) in_predicate_value ::= NK_LP expression_list NK_RP */ - -1, /* (324) boolean_value_expression ::= boolean_primary */ - -2, /* (325) boolean_value_expression ::= NOT boolean_primary */ - -3, /* (326) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - -3, /* (327) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - -1, /* (328) boolean_primary ::= predicate */ - -3, /* (329) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - -1, /* (330) common_expression ::= expression */ - -1, /* (331) common_expression ::= boolean_value_expression */ - -2, /* (332) from_clause ::= FROM table_reference_list */ - -1, /* (333) table_reference_list ::= table_reference */ - -3, /* (334) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - -1, /* (335) table_reference ::= table_primary */ - -1, /* (336) table_reference ::= joined_table */ - -2, /* (337) table_primary ::= table_name alias_opt */ - -4, /* (338) table_primary ::= db_name NK_DOT table_name alias_opt */ - -2, /* (339) table_primary ::= subquery alias_opt */ - -1, /* (340) table_primary ::= parenthesized_joined_table */ - 0, /* (341) alias_opt ::= */ - -1, /* (342) alias_opt ::= table_alias */ - -2, /* (343) alias_opt ::= AS table_alias */ - -3, /* (344) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - -3, /* (345) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - -6, /* (346) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 0, /* (347) join_type ::= */ - -1, /* (348) join_type ::= INNER */ - -9, /* (349) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 0, /* (350) set_quantifier_opt ::= */ - -1, /* (351) set_quantifier_opt ::= DISTINCT */ - -1, /* (352) set_quantifier_opt ::= ALL */ - -1, /* (353) select_list ::= NK_STAR */ - -1, /* (354) select_list ::= select_sublist */ - -1, /* (355) select_sublist ::= select_item */ - -3, /* (356) select_sublist ::= select_sublist NK_COMMA select_item */ - -1, /* (357) select_item ::= common_expression */ - -2, /* (358) select_item ::= common_expression column_alias */ - -3, /* (359) select_item ::= common_expression AS column_alias */ - -3, /* (360) select_item ::= table_name NK_DOT NK_STAR */ - 0, /* (361) where_clause_opt ::= */ - -2, /* (362) where_clause_opt ::= WHERE search_condition */ - 0, /* (363) partition_by_clause_opt ::= */ - -3, /* (364) partition_by_clause_opt ::= PARTITION BY expression_list */ - 0, /* (365) twindow_clause_opt ::= */ - -6, /* (366) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - -4, /* (367) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - -6, /* (368) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - -8, /* (369) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - 0, /* (370) sliding_opt ::= */ - -4, /* (371) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - 0, /* (372) fill_opt ::= */ - -4, /* (373) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - -6, /* (374) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - -1, /* (375) fill_mode ::= NONE */ - -1, /* (376) fill_mode ::= PREV */ - -1, /* (377) fill_mode ::= NULL */ - -1, /* (378) fill_mode ::= LINEAR */ - -1, /* (379) fill_mode ::= NEXT */ - 0, /* (380) group_by_clause_opt ::= */ - -3, /* (381) group_by_clause_opt ::= GROUP BY group_by_list */ - -1, /* (382) group_by_list ::= expression */ - -3, /* (383) group_by_list ::= group_by_list NK_COMMA expression */ - 0, /* (384) having_clause_opt ::= */ - -2, /* (385) having_clause_opt ::= HAVING search_condition */ - -4, /* (386) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - -1, /* (387) query_expression_body ::= query_primary */ - -4, /* (388) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - -1, /* (389) query_primary ::= query_specification */ - 0, /* (390) order_by_clause_opt ::= */ - -3, /* (391) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 0, /* (392) slimit_clause_opt ::= */ - -2, /* (393) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - -4, /* (394) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - -4, /* (395) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 0, /* (396) limit_clause_opt ::= */ - -2, /* (397) limit_clause_opt ::= LIMIT NK_INTEGER */ - -4, /* (398) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - -4, /* (399) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - -3, /* (400) subquery ::= NK_LP query_expression NK_RP */ - -1, /* (401) search_condition ::= common_expression */ - -1, /* (402) sort_specification_list ::= sort_specification */ - -3, /* (403) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - -3, /* (404) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - 0, /* (405) ordering_specification_opt ::= */ - -1, /* (406) ordering_specification_opt ::= ASC */ - -1, /* (407) ordering_specification_opt ::= DESC */ - 0, /* (408) null_ordering_opt ::= */ - -2, /* (409) null_ordering_opt ::= NULLS FIRST */ - -2, /* (410) null_ordering_opt ::= NULLS LAST */ + -1, /* (271) function_name ::= NOW */ + -1, /* (272) function_name ::= TODAY */ + -1, /* (273) table_alias ::= NK_ID */ + -1, /* (274) column_alias ::= NK_ID */ + -1, /* (275) user_name ::= NK_ID */ + -1, /* (276) index_name ::= NK_ID */ + -1, /* (277) topic_name ::= NK_ID */ + -1, /* (278) stream_name ::= NK_ID */ + -1, /* (279) expression ::= literal */ + -1, /* (280) expression ::= pseudo_column */ + -1, /* (281) expression ::= column_reference */ + -4, /* (282) expression ::= function_name NK_LP expression_list NK_RP */ + -4, /* (283) expression ::= function_name NK_LP NK_STAR NK_RP */ + -3, /* (284) expression ::= function_name NK_LP NK_RP */ + -6, /* (285) expression ::= function_name NK_LP expression AS type_name NK_RP */ + -1, /* (286) expression ::= subquery */ + -3, /* (287) expression ::= NK_LP expression NK_RP */ + -2, /* (288) expression ::= NK_PLUS expression */ + -2, /* (289) expression ::= NK_MINUS expression */ + -3, /* (290) expression ::= expression NK_PLUS expression */ + -3, /* (291) expression ::= expression NK_MINUS expression */ + -3, /* (292) expression ::= expression NK_STAR expression */ + -3, /* (293) expression ::= expression NK_SLASH expression */ + -3, /* (294) expression ::= expression NK_REM expression */ + -1, /* (295) expression_list ::= expression */ + -3, /* (296) expression_list ::= expression_list NK_COMMA expression */ + -1, /* (297) column_reference ::= column_name */ + -3, /* (298) column_reference ::= table_name NK_DOT column_name */ + -1, /* (299) pseudo_column ::= ROWTS */ + -1, /* (300) pseudo_column ::= TBNAME */ + -1, /* (301) pseudo_column ::= QSTARTTS */ + -1, /* (302) pseudo_column ::= QENDTS */ + -1, /* (303) pseudo_column ::= WSTARTTS */ + -1, /* (304) pseudo_column ::= WENDTS */ + -1, /* (305) pseudo_column ::= WDURATION */ + -3, /* (306) predicate ::= expression compare_op expression */ + -5, /* (307) predicate ::= expression BETWEEN expression AND expression */ + -6, /* (308) predicate ::= expression NOT BETWEEN expression AND expression */ + -3, /* (309) predicate ::= expression IS NULL */ + -4, /* (310) predicate ::= expression IS NOT NULL */ + -3, /* (311) predicate ::= expression in_op in_predicate_value */ + -1, /* (312) compare_op ::= NK_LT */ + -1, /* (313) compare_op ::= NK_GT */ + -1, /* (314) compare_op ::= NK_LE */ + -1, /* (315) compare_op ::= NK_GE */ + -1, /* (316) compare_op ::= NK_NE */ + -1, /* (317) compare_op ::= NK_EQ */ + -1, /* (318) compare_op ::= LIKE */ + -2, /* (319) compare_op ::= NOT LIKE */ + -1, /* (320) compare_op ::= MATCH */ + -1, /* (321) compare_op ::= NMATCH */ + -1, /* (322) in_op ::= IN */ + -2, /* (323) in_op ::= NOT IN */ + -3, /* (324) in_predicate_value ::= NK_LP expression_list NK_RP */ + -1, /* (325) boolean_value_expression ::= boolean_primary */ + -2, /* (326) boolean_value_expression ::= NOT boolean_primary */ + -3, /* (327) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + -3, /* (328) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + -1, /* (329) boolean_primary ::= predicate */ + -3, /* (330) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + -1, /* (331) common_expression ::= expression */ + -1, /* (332) common_expression ::= boolean_value_expression */ + -2, /* (333) from_clause ::= FROM table_reference_list */ + -1, /* (334) table_reference_list ::= table_reference */ + -3, /* (335) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + -1, /* (336) table_reference ::= table_primary */ + -1, /* (337) table_reference ::= joined_table */ + -2, /* (338) table_primary ::= table_name alias_opt */ + -4, /* (339) table_primary ::= db_name NK_DOT table_name alias_opt */ + -2, /* (340) table_primary ::= subquery alias_opt */ + -1, /* (341) table_primary ::= parenthesized_joined_table */ + 0, /* (342) alias_opt ::= */ + -1, /* (343) alias_opt ::= table_alias */ + -2, /* (344) alias_opt ::= AS table_alias */ + -3, /* (345) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + -3, /* (346) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + -6, /* (347) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 0, /* (348) join_type ::= */ + -1, /* (349) join_type ::= INNER */ + -9, /* (350) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 0, /* (351) set_quantifier_opt ::= */ + -1, /* (352) set_quantifier_opt ::= DISTINCT */ + -1, /* (353) set_quantifier_opt ::= ALL */ + -1, /* (354) select_list ::= NK_STAR */ + -1, /* (355) select_list ::= select_sublist */ + -1, /* (356) select_sublist ::= select_item */ + -3, /* (357) select_sublist ::= select_sublist NK_COMMA select_item */ + -1, /* (358) select_item ::= common_expression */ + -2, /* (359) select_item ::= common_expression column_alias */ + -3, /* (360) select_item ::= common_expression AS column_alias */ + -3, /* (361) select_item ::= table_name NK_DOT NK_STAR */ + 0, /* (362) where_clause_opt ::= */ + -2, /* (363) where_clause_opt ::= WHERE search_condition */ + 0, /* (364) partition_by_clause_opt ::= */ + -3, /* (365) partition_by_clause_opt ::= PARTITION BY expression_list */ + 0, /* (366) twindow_clause_opt ::= */ + -6, /* (367) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + -4, /* (368) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + -6, /* (369) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + -8, /* (370) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + 0, /* (371) sliding_opt ::= */ + -4, /* (372) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + 0, /* (373) fill_opt ::= */ + -4, /* (374) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + -6, /* (375) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + -1, /* (376) fill_mode ::= NONE */ + -1, /* (377) fill_mode ::= PREV */ + -1, /* (378) fill_mode ::= NULL */ + -1, /* (379) fill_mode ::= LINEAR */ + -1, /* (380) fill_mode ::= NEXT */ + 0, /* (381) group_by_clause_opt ::= */ + -3, /* (382) group_by_clause_opt ::= GROUP BY group_by_list */ + -1, /* (383) group_by_list ::= expression */ + -3, /* (384) group_by_list ::= group_by_list NK_COMMA expression */ + 0, /* (385) having_clause_opt ::= */ + -2, /* (386) having_clause_opt ::= HAVING search_condition */ + -4, /* (387) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + -1, /* (388) query_expression_body ::= query_primary */ + -4, /* (389) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + -1, /* (390) query_primary ::= query_specification */ + 0, /* (391) order_by_clause_opt ::= */ + -3, /* (392) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 0, /* (393) slimit_clause_opt ::= */ + -2, /* (394) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + -4, /* (395) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + -4, /* (396) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 0, /* (397) limit_clause_opt ::= */ + -2, /* (398) limit_clause_opt ::= LIMIT NK_INTEGER */ + -4, /* (399) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + -4, /* (400) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + -3, /* (401) subquery ::= NK_LP query_expression NK_RP */ + -1, /* (402) search_condition ::= common_expression */ + -1, /* (403) sort_specification_list ::= sort_specification */ + -3, /* (404) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + -3, /* (405) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + 0, /* (406) ordering_specification_opt ::= */ + -1, /* (407) ordering_specification_opt ::= ASC */ + -1, /* (408) ordering_specification_opt ::= DESC */ + 0, /* (409) null_ordering_opt ::= */ + -2, /* (410) null_ordering_opt ::= NULLS FIRST */ + -2, /* (411) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3102,12 +3107,14 @@ static YYACTIONTYPE yy_reduce( case 268: /* function_name ::= NK_ID */ yytestcase(yyruleno==268); case 269: /* function_name ::= FIRST */ yytestcase(yyruleno==269); case 270: /* function_name ::= LAST */ yytestcase(yyruleno==270); - case 271: /* table_alias ::= NK_ID */ yytestcase(yyruleno==271); - case 272: /* column_alias ::= NK_ID */ yytestcase(yyruleno==272); - case 273: /* user_name ::= NK_ID */ yytestcase(yyruleno==273); - case 274: /* index_name ::= NK_ID */ yytestcase(yyruleno==274); - case 275: /* topic_name ::= NK_ID */ yytestcase(yyruleno==275); - case 276: /* stream_name ::= NK_ID */ yytestcase(yyruleno==276); + case 271: /* function_name ::= NOW */ yytestcase(yyruleno==271); + case 272: /* function_name ::= TODAY */ yytestcase(yyruleno==272); + case 273: /* table_alias ::= NK_ID */ yytestcase(yyruleno==273); + case 274: /* column_alias ::= NK_ID */ yytestcase(yyruleno==274); + case 275: /* user_name ::= NK_ID */ yytestcase(yyruleno==275); + case 276: /* index_name ::= NK_ID */ yytestcase(yyruleno==276); + case 277: /* topic_name ::= NK_ID */ yytestcase(yyruleno==277); + case 278: /* stream_name ::= NK_ID */ yytestcase(yyruleno==278); { yylhsminor.yy29 = yymsp[0].minor.yy0; } yymsp[0].minor.yy29 = yylhsminor.yy29; break; @@ -3160,7 +3167,7 @@ static YYACTIONTYPE yy_reduce( case 56: /* exists_opt ::= */ yytestcase(yyruleno==56); case 220: /* analyze_opt ::= */ yytestcase(yyruleno==220); case 228: /* agg_func_opt ::= */ yytestcase(yyruleno==228); - case 350: /* set_quantifier_opt ::= */ yytestcase(yyruleno==350); + case 351: /* set_quantifier_opt ::= */ yytestcase(yyruleno==351); { yymsp[1].minor.yy47 = false; } break; case 55: /* exists_opt ::= IF EXISTS */ @@ -3301,8 +3308,8 @@ static YYACTIONTYPE yy_reduce( case 201: /* func_name_list ::= func_name */ yytestcase(yyruleno==201); case 210: /* func_list ::= func */ yytestcase(yyruleno==210); case 263: /* literal_list ::= signed_literal */ yytestcase(yyruleno==263); - case 355: /* select_sublist ::= select_item */ yytestcase(yyruleno==355); - case 402: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==402); + case 356: /* select_sublist ::= select_item */ yytestcase(yyruleno==356); + case 403: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==403); { yylhsminor.yy334 = createNodeList(pCxt, yymsp[0].minor.yy182); } yymsp[0].minor.yy334 = yylhsminor.yy334; break; @@ -3312,8 +3319,8 @@ static YYACTIONTYPE yy_reduce( case 202: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==202); case 211: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==211); case 264: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==264); - case 356: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==356); - case 403: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==403); + case 357: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==357); + case 404: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==404); { yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, yymsp[0].minor.yy182); } yymsp[-2].minor.yy334 = yylhsminor.yy334; break; @@ -3394,9 +3401,9 @@ static YYACTIONTYPE yy_reduce( break; case 118: /* specific_tags_opt ::= */ case 149: /* tags_def_opt ::= */ yytestcase(yyruleno==149); - case 363: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==363); - case 380: /* group_by_clause_opt ::= */ yytestcase(yyruleno==380); - case 390: /* order_by_clause_opt ::= */ yytestcase(yyruleno==390); + case 364: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==364); + case 381: /* group_by_clause_opt ::= */ yytestcase(yyruleno==381); + case 391: /* order_by_clause_opt ::= */ yytestcase(yyruleno==391); { yymsp[1].minor.yy334 = NULL; } break; case 119: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ @@ -3486,7 +3493,7 @@ static YYACTIONTYPE yy_reduce( { yymsp[-5].minor.yy574 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 150: /* tags_def_opt ::= tags_def */ - case 354: /* select_list ::= select_sublist */ yytestcase(yyruleno==354); + case 355: /* select_list ::= select_sublist */ yytestcase(yyruleno==355); { yylhsminor.yy334 = yymsp[0].minor.yy334; } yymsp[0].minor.yy334 = yylhsminor.yy334; break; @@ -3631,13 +3638,13 @@ static YYACTIONTYPE yy_reduce( break; case 196: /* like_pattern_opt ::= */ case 207: /* index_options ::= */ yytestcase(yyruleno==207); - case 361: /* where_clause_opt ::= */ yytestcase(yyruleno==361); - case 365: /* twindow_clause_opt ::= */ yytestcase(yyruleno==365); - case 370: /* sliding_opt ::= */ yytestcase(yyruleno==370); - case 372: /* fill_opt ::= */ yytestcase(yyruleno==372); - case 384: /* having_clause_opt ::= */ yytestcase(yyruleno==384); - case 392: /* slimit_clause_opt ::= */ yytestcase(yyruleno==392); - case 396: /* limit_clause_opt ::= */ yytestcase(yyruleno==396); + case 362: /* where_clause_opt ::= */ yytestcase(yyruleno==362); + case 366: /* twindow_clause_opt ::= */ yytestcase(yyruleno==366); + case 371: /* sliding_opt ::= */ yytestcase(yyruleno==371); + case 373: /* fill_opt ::= */ yytestcase(yyruleno==373); + case 385: /* having_clause_opt ::= */ yytestcase(yyruleno==385); + case 393: /* slimit_clause_opt ::= */ yytestcase(yyruleno==393); + case 397: /* limit_clause_opt ::= */ yytestcase(yyruleno==397); { yymsp[1].minor.yy182 = NULL; } break; case 197: /* like_pattern_opt ::= LIKE NK_STRING */ @@ -3694,7 +3701,7 @@ static YYACTIONTYPE yy_reduce( break; case 221: /* analyze_opt ::= ANALYZE */ case 229: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==229); - case 351: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==351); + case 352: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==352); { yymsp[0].minor.yy47 = true; } break; case 222: /* explain_options ::= */ @@ -3772,20 +3779,20 @@ static YYACTIONTYPE yy_reduce( break; case 248: /* literal ::= duration_literal */ case 257: /* signed_literal ::= signed */ yytestcase(yyruleno==257); - case 277: /* expression ::= literal */ yytestcase(yyruleno==277); - case 278: /* expression ::= pseudo_column */ yytestcase(yyruleno==278); - case 279: /* expression ::= column_reference */ yytestcase(yyruleno==279); - case 283: /* expression ::= subquery */ yytestcase(yyruleno==283); - case 324: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==324); - case 328: /* boolean_primary ::= predicate */ yytestcase(yyruleno==328); - case 330: /* common_expression ::= expression */ yytestcase(yyruleno==330); - case 331: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==331); - case 333: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==333); - case 335: /* table_reference ::= table_primary */ yytestcase(yyruleno==335); - case 336: /* table_reference ::= joined_table */ yytestcase(yyruleno==336); - case 340: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==340); - case 387: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==387); - case 389: /* query_primary ::= query_specification */ yytestcase(yyruleno==389); + case 279: /* expression ::= literal */ yytestcase(yyruleno==279); + case 280: /* expression ::= pseudo_column */ yytestcase(yyruleno==280); + case 281: /* expression ::= column_reference */ yytestcase(yyruleno==281); + case 286: /* expression ::= subquery */ yytestcase(yyruleno==286); + case 325: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==325); + case 329: /* boolean_primary ::= predicate */ yytestcase(yyruleno==329); + case 331: /* common_expression ::= expression */ yytestcase(yyruleno==331); + case 332: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==332); + case 334: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==334); + case 336: /* table_reference ::= table_primary */ yytestcase(yyruleno==336); + case 337: /* table_reference ::= joined_table */ yytestcase(yyruleno==337); + case 341: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==341); + case 388: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==388); + case 390: /* query_primary ::= query_specification */ yytestcase(yyruleno==390); { yylhsminor.yy182 = yymsp[0].minor.yy182; } yymsp[0].minor.yy182 = yylhsminor.yy182; break; @@ -3839,23 +3846,27 @@ static YYACTIONTYPE yy_reduce( { yymsp[-1].minor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; case 261: /* signed_literal ::= duration_literal */ - case 357: /* select_item ::= common_expression */ yytestcase(yyruleno==357); - case 401: /* search_condition ::= common_expression */ yytestcase(yyruleno==401); + case 358: /* select_item ::= common_expression */ yytestcase(yyruleno==358); + case 402: /* search_condition ::= common_expression */ yytestcase(yyruleno==402); { yylhsminor.yy182 = releaseRawExprNode(pCxt, yymsp[0].minor.yy182); } yymsp[0].minor.yy182 = yylhsminor.yy182; break; case 262: /* signed_literal ::= NULL */ { yymsp[0].minor.yy182 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } break; - case 280: /* expression ::= function_name NK_LP expression_list NK_RP */ + case 282: /* expression ::= function_name NK_LP expression_list NK_RP */ { yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy29, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy29, yymsp[-1].minor.yy334)); } yymsp[-3].minor.yy182 = yylhsminor.yy182; break; - case 281: /* expression ::= function_name NK_LP NK_STAR NK_RP */ + case 283: /* expression ::= function_name NK_LP NK_STAR NK_RP */ { yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy29, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy29, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } yymsp[-3].minor.yy182 = yylhsminor.yy182; break; - case 282: /* expression ::= function_name NK_LP expression AS type_name NK_RP */ + case 284: /* expression ::= function_name NK_LP NK_RP */ +{ yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy0, createFunctionNodeNoParam(pCxt, &yymsp[-2].minor.yy29)); } + yymsp[-2].minor.yy182 = yylhsminor.yy182; + break; + case 285: /* expression ::= function_name NK_LP expression AS type_name NK_RP */ { SNodeList *p = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy182)); p = addValueNodeFromTypeToList(pCxt, yymsp[-1].minor.yy574, p); @@ -3863,26 +3874,26 @@ static YYACTIONTYPE yy_reduce( } yymsp[-5].minor.yy182 = yylhsminor.yy182; break; - case 284: /* expression ::= NK_LP expression NK_RP */ - case 329: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==329); + case 287: /* expression ::= NK_LP expression NK_RP */ + case 330: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==330); { yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy182)); } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 285: /* expression ::= NK_PLUS expression */ + case 288: /* expression ::= NK_PLUS expression */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy182)); } yymsp[-1].minor.yy182 = yylhsminor.yy182; break; - case 286: /* expression ::= NK_MINUS expression */ + case 289: /* expression ::= NK_MINUS expression */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy182), NULL)); } yymsp[-1].minor.yy182 = yylhsminor.yy182; break; - case 287: /* expression ::= expression NK_PLUS expression */ + case 290: /* expression ::= expression NK_PLUS expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); @@ -3890,7 +3901,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 288: /* expression ::= expression NK_MINUS expression */ + case 291: /* expression ::= expression NK_MINUS expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); @@ -3898,7 +3909,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 289: /* expression ::= expression NK_STAR expression */ + case 292: /* expression ::= expression NK_STAR expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); @@ -3906,7 +3917,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 290: /* expression ::= expression NK_SLASH expression */ + case 293: /* expression ::= expression NK_SLASH expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); @@ -3914,7 +3925,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 291: /* expression ::= expression NK_REM expression */ + case 294: /* expression ::= expression NK_REM expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); @@ -3922,36 +3933,34 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 292: /* expression_list ::= expression */ + case 295: /* expression_list ::= expression */ { yylhsminor.yy334 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy182)); } yymsp[0].minor.yy334 = yylhsminor.yy334; break; - case 293: /* expression_list ::= expression_list NK_COMMA expression */ + case 296: /* expression_list ::= expression_list NK_COMMA expression */ { yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, releaseRawExprNode(pCxt, yymsp[0].minor.yy182)); } yymsp[-2].minor.yy334 = yylhsminor.yy334; break; - case 294: /* column_reference ::= column_name */ + case 297: /* column_reference ::= column_name */ { yylhsminor.yy182 = createRawExprNode(pCxt, &yymsp[0].minor.yy29, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy29)); } yymsp[0].minor.yy182 = yylhsminor.yy182; break; - case 295: /* column_reference ::= table_name NK_DOT column_name */ + case 298: /* column_reference ::= table_name NK_DOT column_name */ { yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy29, createColumnNode(pCxt, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy29)); } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 296: /* pseudo_column ::= NOW */ - case 297: /* pseudo_column ::= TODAY */ yytestcase(yyruleno==297); - case 298: /* pseudo_column ::= ROWTS */ yytestcase(yyruleno==298); - case 299: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==299); - case 300: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==300); - case 301: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==301); - case 302: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==302); - case 303: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==303); - case 304: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==304); + case 299: /* pseudo_column ::= ROWTS */ + case 300: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==300); + case 301: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==301); + case 302: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==302); + case 303: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==303); + case 304: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==304); + case 305: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==305); { yylhsminor.yy182 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } yymsp[0].minor.yy182 = yylhsminor.yy182; break; - case 305: /* predicate ::= expression compare_op expression */ - case 310: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==310); + case 306: /* predicate ::= expression compare_op expression */ + case 311: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==311); { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); @@ -3959,7 +3968,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 306: /* predicate ::= expression BETWEEN expression AND expression */ + case 307: /* predicate ::= expression BETWEEN expression AND expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy182); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); @@ -3967,7 +3976,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-4].minor.yy182 = yylhsminor.yy182; break; - case 307: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 308: /* predicate ::= expression NOT BETWEEN expression AND expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy182); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); @@ -3975,68 +3984,68 @@ static YYACTIONTYPE yy_reduce( } yymsp[-5].minor.yy182 = yylhsminor.yy182; break; - case 308: /* predicate ::= expression IS NULL */ + case 309: /* predicate ::= expression IS NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), NULL)); } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 309: /* predicate ::= expression IS NOT NULL */ + case 310: /* predicate ::= expression IS NOT NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy182); yylhsminor.yy182 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy182), NULL)); } yymsp[-3].minor.yy182 = yylhsminor.yy182; break; - case 311: /* compare_op ::= NK_LT */ + case 312: /* compare_op ::= NK_LT */ { yymsp[0].minor.yy380 = OP_TYPE_LOWER_THAN; } break; - case 312: /* compare_op ::= NK_GT */ + case 313: /* compare_op ::= NK_GT */ { yymsp[0].minor.yy380 = OP_TYPE_GREATER_THAN; } break; - case 313: /* compare_op ::= NK_LE */ + case 314: /* compare_op ::= NK_LE */ { yymsp[0].minor.yy380 = OP_TYPE_LOWER_EQUAL; } break; - case 314: /* compare_op ::= NK_GE */ + case 315: /* compare_op ::= NK_GE */ { yymsp[0].minor.yy380 = OP_TYPE_GREATER_EQUAL; } break; - case 315: /* compare_op ::= NK_NE */ + case 316: /* compare_op ::= NK_NE */ { yymsp[0].minor.yy380 = OP_TYPE_NOT_EQUAL; } break; - case 316: /* compare_op ::= NK_EQ */ + case 317: /* compare_op ::= NK_EQ */ { yymsp[0].minor.yy380 = OP_TYPE_EQUAL; } break; - case 317: /* compare_op ::= LIKE */ + case 318: /* compare_op ::= LIKE */ { yymsp[0].minor.yy380 = OP_TYPE_LIKE; } break; - case 318: /* compare_op ::= NOT LIKE */ + case 319: /* compare_op ::= NOT LIKE */ { yymsp[-1].minor.yy380 = OP_TYPE_NOT_LIKE; } break; - case 319: /* compare_op ::= MATCH */ + case 320: /* compare_op ::= MATCH */ { yymsp[0].minor.yy380 = OP_TYPE_MATCH; } break; - case 320: /* compare_op ::= NMATCH */ + case 321: /* compare_op ::= NMATCH */ { yymsp[0].minor.yy380 = OP_TYPE_NMATCH; } break; - case 321: /* in_op ::= IN */ + case 322: /* in_op ::= IN */ { yymsp[0].minor.yy380 = OP_TYPE_IN; } break; - case 322: /* in_op ::= NOT IN */ + case 323: /* in_op ::= NOT IN */ { yymsp[-1].minor.yy380 = OP_TYPE_NOT_IN; } break; - case 323: /* in_predicate_value ::= NK_LP expression_list NK_RP */ + case 324: /* in_predicate_value ::= NK_LP expression_list NK_RP */ { yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy334)); } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 325: /* boolean_value_expression ::= NOT boolean_primary */ + case 326: /* boolean_value_expression ::= NOT boolean_primary */ { SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy182), NULL)); } yymsp[-1].minor.yy182 = yylhsminor.yy182; break; - case 326: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 327: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); @@ -4044,7 +4053,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 327: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 328: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy182); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy182); @@ -4052,52 +4061,52 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 332: /* from_clause ::= FROM table_reference_list */ - case 362: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==362); - case 385: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==385); + case 333: /* from_clause ::= FROM table_reference_list */ + case 363: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==363); + case 386: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==386); { yymsp[-1].minor.yy182 = yymsp[0].minor.yy182; } break; - case 334: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ + case 335: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ { yylhsminor.yy182 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy182, yymsp[0].minor.yy182, NULL); } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 337: /* table_primary ::= table_name alias_opt */ + case 338: /* table_primary ::= table_name alias_opt */ { yylhsminor.yy182 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy29, &yymsp[0].minor.yy29); } yymsp[-1].minor.yy182 = yylhsminor.yy182; break; - case 338: /* table_primary ::= db_name NK_DOT table_name alias_opt */ + case 339: /* table_primary ::= db_name NK_DOT table_name alias_opt */ { yylhsminor.yy182 = createRealTableNode(pCxt, &yymsp[-3].minor.yy29, &yymsp[-1].minor.yy29, &yymsp[0].minor.yy29); } yymsp[-3].minor.yy182 = yylhsminor.yy182; break; - case 339: /* table_primary ::= subquery alias_opt */ + case 340: /* table_primary ::= subquery alias_opt */ { yylhsminor.yy182 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy182), &yymsp[0].minor.yy29); } yymsp[-1].minor.yy182 = yylhsminor.yy182; break; - case 341: /* alias_opt ::= */ + case 342: /* alias_opt ::= */ { yymsp[1].minor.yy29 = nil_token; } break; - case 342: /* alias_opt ::= table_alias */ + case 343: /* alias_opt ::= table_alias */ { yylhsminor.yy29 = yymsp[0].minor.yy29; } yymsp[0].minor.yy29 = yylhsminor.yy29; break; - case 343: /* alias_opt ::= AS table_alias */ + case 344: /* alias_opt ::= AS table_alias */ { yymsp[-1].minor.yy29 = yymsp[0].minor.yy29; } break; - case 344: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 345: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==345); + case 345: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 346: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==346); { yymsp[-2].minor.yy182 = yymsp[-1].minor.yy182; } break; - case 346: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + case 347: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ { yylhsminor.yy182 = createJoinTableNode(pCxt, yymsp[-4].minor.yy162, yymsp[-5].minor.yy182, yymsp[-2].minor.yy182, yymsp[0].minor.yy182); } yymsp[-5].minor.yy182 = yylhsminor.yy182; break; - case 347: /* join_type ::= */ + case 348: /* join_type ::= */ { yymsp[1].minor.yy162 = JOIN_TYPE_INNER; } break; - case 348: /* join_type ::= INNER */ + case 349: /* join_type ::= INNER */ { yymsp[0].minor.yy162 = JOIN_TYPE_INNER; } break; - case 349: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 350: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { yymsp[-8].minor.yy182 = createSelectStmt(pCxt, yymsp[-7].minor.yy47, yymsp[-6].minor.yy334, yymsp[-5].minor.yy182); yymsp[-8].minor.yy182 = addWhereClause(pCxt, yymsp[-8].minor.yy182, yymsp[-4].minor.yy182); @@ -4107,74 +4116,74 @@ static YYACTIONTYPE yy_reduce( yymsp[-8].minor.yy182 = addHavingClause(pCxt, yymsp[-8].minor.yy182, yymsp[0].minor.yy182); } break; - case 352: /* set_quantifier_opt ::= ALL */ + case 353: /* set_quantifier_opt ::= ALL */ { yymsp[0].minor.yy47 = false; } break; - case 353: /* select_list ::= NK_STAR */ + case 354: /* select_list ::= NK_STAR */ { yymsp[0].minor.yy334 = NULL; } break; - case 358: /* select_item ::= common_expression column_alias */ + case 359: /* select_item ::= common_expression column_alias */ { yylhsminor.yy182 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy182), &yymsp[0].minor.yy29); } yymsp[-1].minor.yy182 = yylhsminor.yy182; break; - case 359: /* select_item ::= common_expression AS column_alias */ + case 360: /* select_item ::= common_expression AS column_alias */ { yylhsminor.yy182 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), &yymsp[0].minor.yy29); } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 360: /* select_item ::= table_name NK_DOT NK_STAR */ + case 361: /* select_item ::= table_name NK_DOT NK_STAR */ { yylhsminor.yy182 = createColumnNode(pCxt, &yymsp[-2].minor.yy29, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 364: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 381: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==381); - case 391: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==391); + case 365: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 382: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==382); + case 392: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==392); { yymsp[-2].minor.yy334 = yymsp[0].minor.yy334; } break; - case 366: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + case 367: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ { yymsp[-5].minor.yy182 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy182), releaseRawExprNode(pCxt, yymsp[-1].minor.yy182)); } break; - case 367: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + case 368: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ { yymsp[-3].minor.yy182 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy182)); } break; - case 368: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + case 369: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-5].minor.yy182 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy182), NULL, yymsp[-1].minor.yy182, yymsp[0].minor.yy182); } break; - case 369: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + case 370: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-7].minor.yy182 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy182), releaseRawExprNode(pCxt, yymsp[-3].minor.yy182), yymsp[-1].minor.yy182, yymsp[0].minor.yy182); } break; - case 371: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 372: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ { yymsp[-3].minor.yy182 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy182); } break; - case 373: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ + case 374: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ { yymsp[-3].minor.yy182 = createFillNode(pCxt, yymsp[-1].minor.yy144, NULL); } break; - case 374: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + case 375: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ { yymsp[-5].minor.yy182 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy334)); } break; - case 375: /* fill_mode ::= NONE */ + case 376: /* fill_mode ::= NONE */ { yymsp[0].minor.yy144 = FILL_MODE_NONE; } break; - case 376: /* fill_mode ::= PREV */ + case 377: /* fill_mode ::= PREV */ { yymsp[0].minor.yy144 = FILL_MODE_PREV; } break; - case 377: /* fill_mode ::= NULL */ + case 378: /* fill_mode ::= NULL */ { yymsp[0].minor.yy144 = FILL_MODE_NULL; } break; - case 378: /* fill_mode ::= LINEAR */ + case 379: /* fill_mode ::= LINEAR */ { yymsp[0].minor.yy144 = FILL_MODE_LINEAR; } break; - case 379: /* fill_mode ::= NEXT */ + case 380: /* fill_mode ::= NEXT */ { yymsp[0].minor.yy144 = FILL_MODE_NEXT; } break; - case 382: /* group_by_list ::= expression */ + case 383: /* group_by_list ::= expression */ { yylhsminor.yy334 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); } yymsp[0].minor.yy334 = yylhsminor.yy334; break; - case 383: /* group_by_list ::= group_by_list NK_COMMA expression */ + case 384: /* group_by_list ::= group_by_list NK_COMMA expression */ { yylhsminor.yy334 = addNodeToList(pCxt, yymsp[-2].minor.yy334, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy182))); } yymsp[-2].minor.yy334 = yylhsminor.yy334; break; - case 386: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 387: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { yylhsminor.yy182 = addOrderByClause(pCxt, yymsp[-3].minor.yy182, yymsp[-2].minor.yy334); yylhsminor.yy182 = addSlimitClause(pCxt, yylhsminor.yy182, yymsp[-1].minor.yy182); @@ -4182,46 +4191,46 @@ static YYACTIONTYPE yy_reduce( } yymsp[-3].minor.yy182 = yylhsminor.yy182; break; - case 388: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + case 389: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ { yylhsminor.yy182 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy182, yymsp[0].minor.yy182); } yymsp[-3].minor.yy182 = yylhsminor.yy182; break; - case 393: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 397: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==397); + case 394: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 398: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==398); { yymsp[-1].minor.yy182 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 394: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 398: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==398); + case 395: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 399: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==399); { yymsp[-3].minor.yy182 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 395: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 399: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==399); + case 396: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 400: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==400); { yymsp[-3].minor.yy182 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 400: /* subquery ::= NK_LP query_expression NK_RP */ + case 401: /* subquery ::= NK_LP query_expression NK_RP */ { yylhsminor.yy182 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy182); } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 404: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + case 405: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ { yylhsminor.yy182 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy182), yymsp[-1].minor.yy218, yymsp[0].minor.yy487); } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; - case 405: /* ordering_specification_opt ::= */ + case 406: /* ordering_specification_opt ::= */ { yymsp[1].minor.yy218 = ORDER_ASC; } break; - case 406: /* ordering_specification_opt ::= ASC */ + case 407: /* ordering_specification_opt ::= ASC */ { yymsp[0].minor.yy218 = ORDER_ASC; } break; - case 407: /* ordering_specification_opt ::= DESC */ + case 408: /* ordering_specification_opt ::= DESC */ { yymsp[0].minor.yy218 = ORDER_DESC; } break; - case 408: /* null_ordering_opt ::= */ + case 409: /* null_ordering_opt ::= */ { yymsp[1].minor.yy487 = NULL_ORDER_DEFAULT; } break; - case 409: /* null_ordering_opt ::= NULLS FIRST */ + case 410: /* null_ordering_opt ::= NULLS FIRST */ { yymsp[-1].minor.yy487 = NULL_ORDER_FIRST; } break; - case 410: /* null_ordering_opt ::= NULLS LAST */ + case 411: /* null_ordering_opt ::= NULLS LAST */ { yymsp[-1].minor.yy487 = NULL_ORDER_LAST; } break; default: diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 4d57af822e..2dc0702402 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1242,6 +1242,22 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p return TSDB_CODE_SUCCESS; } +int32_t nowFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + if (inputNum != 1) { + return TSDB_CODE_FAILED; + } + colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 0)); + return TSDB_CODE_SUCCESS; +} + +int32_t todayFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { + if (inputNum != 1) { + return TSDB_CODE_FAILED; + } + colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 0)); + return TSDB_CODE_SUCCESS; +} + int32_t atanFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { return doScalarFunctionUnique(pInput, inputNum, pOutput, atan); } From c490820b09305813fd866ce5bec10763ab57f85a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 14 Apr 2022 22:12:10 +0800 Subject: [PATCH 14/48] feat(query): add the merge join operator for child table inner join. --- source/libs/executor/inc/executorimpl.h | 25 +++- source/libs/executor/src/executorimpl.c | 184 +++++++++++++++++++++--- 2 files changed, 183 insertions(+), 26 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index cbd2dc66f5..78bc6947cd 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -549,8 +549,6 @@ typedef struct SStateWindowOperatorInfo { typedef struct SSortedMergeOperatorInfo { SOptrBasicInfo binfo; - bool hasVarCol; - SArray* pSortInfo; int32_t numOfSources; SSortHandle *pSortHandle; @@ -582,6 +580,24 @@ typedef struct SSortOperatorInfo { uint64_t totalElapsed; // total elapsed time } SSortOperatorInfo; +typedef struct SJoinOperatorInfo { + SSDataBlock *pRes; + int32_t joinType; + + SSDataBlock *pLeft; + int32_t leftPos; + SColumnInfo leftCol; + + SSDataBlock *pRight; + int32_t rightPos; + SColumnInfo rightCol; + + SNode *pOnCondition; +// SJoinStatus *status; +// int32_t numOfUpstream; +// SRspResultInfo resultInfo; +} SJoinOperatorInfo; + int32_t operatorDummyOpenFn(SOperatorInfo* pOperator); void operatorDummyCloseFn(void* param, int32_t numOfCols); int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num); @@ -628,6 +644,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SNode* pOnCondition, SExecTaskInfo* pTaskInfo); + #if 0 SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv); SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, @@ -635,9 +653,6 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput); - -SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOfDownstream, SSchema* pSchema, - int32_t numOfOutput); #endif void projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx, int32_t numOfOutput, SArray* pPseudoList); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 14acff3204..45674d31bc 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -6600,10 +6600,10 @@ bool validateExprColumnInfo(SQueriedTableInfo* pTableInfo, SExprBasicInfo* pExpr static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, int32_t scale, int32_t precision, const char* name) { SResSchema s = {0}; - s.scale = scale; - s.type = type; - s.bytes = bytes; - s.slotId = slotId; + s.scale = scale; + s.type = type; + s.bytes = bytes; + s.slotId = slotId; s.precision = precision; strncpy(s.name, name, tListLen(s.name)); @@ -6679,8 +6679,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* SFunctionNode* pFuncNode = (SFunctionNode*)pTargetNode->pExpr; SDataType* pType = &pFuncNode->node.resType; - pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, - pType->precision, pFuncNode->node.aliasName); + pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale, pType->precision, pFuncNode->node.aliasName); pExp->pExpr->_function.functionId = pFuncNode->funcId; pExp->pExpr->_function.pFunctNode = pFuncNode; @@ -6756,7 +6755,7 @@ static SArray* createIndexMap(SNodeList* pNodeList); static SArray* extractPartitionColInfo(SNodeList* pNodeList); SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, - uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) { + uint64_t queryId, uint64_t taskId, STableGroupInfo* pTableGroupInfo) { if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) { int32_t type = nodeType(pPhyNode); if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) { @@ -6764,6 +6763,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo int32_t numOfCols = 0; tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId); + if (pDataReader == NULL) { + return NULL; + } + SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc); @@ -6802,13 +6805,15 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } } + int32_t num = 0; int32_t type = nodeType(pPhyNode); - size_t size = LIST_LENGTH(pPhyNode->pChildren); - ASSERT(size == 1); + size_t size = LIST_LENGTH(pPhyNode->pChildren); - SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0); - SOperatorInfo* op = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo); - int32_t num = 0; + SOperatorInfo** ops = taosMemoryCalloc(size, POINTER_BYTES); + for(int32_t i = 0; i < size; ++i) { + SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i); + ops[i] = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo); + } if (QUERY_NODE_PHYSICAL_PLAN_PROJECT == type) { SProjectPhysiNode* pProjPhyNode = (SProjectPhysiNode*) pPhyNode; @@ -6817,7 +6822,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); SLimit limit = {.limit = pProjPhyNode->limit, .offset = pProjPhyNode->offset}; SLimit slimit = {.limit = pProjPhyNode->slimit, .offset = pProjPhyNode->soffset}; - return createProjectOperatorInfo(op, pExprInfo, num, pResBlock, &limit, &slimit, pTaskInfo); + return createProjectOperatorInfo(ops[0], pExprInfo, num, pResBlock, &limit, &slimit, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_AGG == type) { SAggPhysiNode* pAggNode = (SAggPhysiNode*)pPhyNode; SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); @@ -6831,9 +6836,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); } - return createGroupOperatorInfo(op, pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL); + return createGroupOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL); } else { - return createAggregateOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo); + return createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo); } } else if (QUERY_NODE_PHYSICAL_PLAN_INTERVAL == type) { SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; @@ -6851,33 +6856,39 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo }; int32_t primaryTsSlotId = ((SColumnNode*) pIntervalPhyNode->window.pTspk)->slotId; - return createIntervalOperatorInfo(op, pExprInfo, num, pResBlock, &interval, primaryTsSlotId, pTableGroupInfo, pTaskInfo); + return createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, primaryTsSlotId, pTableGroupInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) { SSortPhysiNode* pSortPhyNode = (SSortPhysiNode*)pPhyNode; SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); SArray* info = createSortInfo(pSortPhyNode->pSortKeys, pSortPhyNode->pTargets); SArray* slotMap = createIndexMap(pSortPhyNode->pTargets); - return createSortOperatorInfo(op, pResBlock, info, slotMap, pTaskInfo); + return createSortOperatorInfo(ops[0], pResBlock, info, slotMap, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW == type) { SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode; SExprInfo* pExprInfo = createExprInfo(pSessionNode->window.pFuncs, NULL, &num); SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); - return createSessionAggOperatorInfo(op, pExprInfo, num, pResBlock, pSessionNode->gap, pTaskInfo); + return createSessionAggOperatorInfo(ops[0], pExprInfo, num, pResBlock, pSessionNode->gap, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_PARTITION == type) { SPartitionPhysiNode* pPartNode = (SPartitionPhysiNode*) pPhyNode; SArray* pColList = extractPartitionColInfo(pPartNode->pPartitionKeys); SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &num); - return createPartitionOperatorInfo(op, pExprInfo, num, pResBlock, pColList, pTaskInfo, NULL); - } else if (QUERY_NODE_STATE_WINDOW == type) { + return createPartitionOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pTaskInfo, NULL); + } else if (QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW == type) { SStateWinodwPhysiNode* pStateNode = (SStateWinodwPhysiNode*) pPhyNode; SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num); SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); - return createStatewindowOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo); + return createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo); + } else if (QUERY_NODE_PHYSICAL_PLAN_JOIN == type) { + SJoinPhysiNode* pJoinNode = (SJoinPhysiNode*) pPhyNode; + SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + + SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &num); + return createJoinOperatorInfo(ops, size, pExprInfo, num, pResBlock, pJoinNode->pOnConditions, pTaskInfo); } else { ASSERT(0); } /*else if (pPhyNode->info.type == OP_MultiTableAggregate) { @@ -7374,4 +7385,135 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo *operatorInfo, SExplainExecInfo return TSDB_CODE_SUCCESS; } +static SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator, bool* newgroup) { + SJoinOperatorInfo* pJoinInfo = pOperator->info; +// SOptrBasicInfo* pInfo = &pJoinInfo->binfo; + SSDataBlock* pRes = pJoinInfo->pRes; + blockDataCleanup(pRes); + blockDataEnsureCapacity(pRes, 4096); + + int32_t nrows = 0; + + while (1) { + bool prevVal = *newgroup; + + if (pJoinInfo->pLeft == NULL || pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) { + SOperatorInfo* ds1 = pOperator->pDownstream[0]; + publishOperatorProfEvent(ds1, QUERY_PROF_BEFORE_OPERATOR_EXEC); + pJoinInfo->pLeft = ds1->getNextFn(ds1, newgroup); + publishOperatorProfEvent(ds1, QUERY_PROF_AFTER_OPERATOR_EXEC); + + pJoinInfo->leftPos = 0; + if (pJoinInfo->pLeft == NULL) { + setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); + break; + } + } + + if (pJoinInfo->pRight == NULL || pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) { + SOperatorInfo* ds2 = pOperator->pDownstream[1]; + publishOperatorProfEvent(ds2, QUERY_PROF_BEFORE_OPERATOR_EXEC); + pJoinInfo->pRight = ds2->getNextFn(ds2, newgroup); + publishOperatorProfEvent(ds2, QUERY_PROF_AFTER_OPERATOR_EXEC); + + pJoinInfo->rightPos = 0; + if (pJoinInfo->pRight == NULL) { + setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); + break; + } + } + + SColumnInfoData* pLeftCol = taosArrayGet(pJoinInfo->pLeft->pDataBlock, pJoinInfo->leftCol.slotId); + char* pLeftVal = colDataGetData(pLeftCol, pJoinInfo->leftPos); + + SColumnInfoData* pRightCol = taosArrayGet(pJoinInfo->pRight->pDataBlock, pJoinInfo->rightCol.slotId); + char* pRightVal = colDataGetData(pRightCol, pJoinInfo->rightPos); + + // only the timestamp match support for ordinary table + ASSERT(pLeftCol->info.type == TSDB_DATA_TYPE_TIMESTAMP); + if (*(int64_t*) pLeftVal == *(int64_t*) pRightVal) { + for(int32_t i = 0; i < pOperator->numOfOutput; ++i) { + SColumnInfoData* pDst = taosArrayGet(pRes->pDataBlock, i); + + SExprInfo* pExprInfo = &pOperator->pExpr[i]; + + int32_t blockId = pExprInfo->base.pParam[0].pCol->dataBlockId; + int32_t slotId = pExprInfo->base.pParam[0].pCol->slotId; + + SColumnInfoData* pSrc = NULL; + if (pJoinInfo->pLeft->info.blockId == blockId) { + pSrc = taosArrayGet(pJoinInfo->pLeft->pDataBlock, slotId); + } else { + pSrc = taosArrayGet(pJoinInfo->pRight->pDataBlock, slotId); + } + + if (colDataIsNull_s(pSrc, pJoinInfo->leftPos)) { + colDataAppendNULL(pDst, nrows); + } else { + char* p = colDataGetData(pSrc, pJoinInfo->leftPos); + colDataAppend(pDst, nrows, p, false); + } + } + + pJoinInfo->leftPos += 1; + pJoinInfo->rightPos += 1; + + nrows += 1; + } else if (*(int64_t*) pLeftVal < *(int64_t*) pRightVal) { + pJoinInfo->leftPos += 1; + + if (pJoinInfo->leftPos >= pJoinInfo->pLeft->info.rows) { + continue; + } + } else if (*(int64_t*) pLeftVal > *(int64_t*) pRightVal) { + pJoinInfo->rightPos += 1; + if (pJoinInfo->rightPos >= pJoinInfo->pRight->info.rows) { + continue; + } + } + + // the pDataBlock are always the same one, no need to call this again + pRes->info.rows = nrows; + if (pRes->info.rows >= pOperator->resultInfo.threshold) { + break; + } + } + + return (pRes->info.rows > 0) ? pRes : NULL; +} + +SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SNode* pOnCondition, SExecTaskInfo* pTaskInfo) { + SJoinOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SJoinOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pOperator == NULL || pInfo == NULL) { + goto _error; + } + + pOperator->resultInfo.capacity = 4096; + pOperator->resultInfo.threshold = 4096 * 0.75; + +// initResultRowInf +// o(&pInfo->binfo.resultRowInfo, 8); + pInfo->pRes = pResBlock; + + pOperator->name = "JoinOperator"; + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_JOIN; + pOperator->blockingOptr = true; + pOperator->status = OP_NOT_OPENED; + pOperator->pExpr = pExprInfo; + pOperator->numOfOutput = numOfCols; + pOperator->info = pInfo; + pOperator->pTaskInfo = pTaskInfo; + pOperator->getNextFn = doMergeJoin; + pOperator->closeFn = destroyBasicOperatorInfo; + + int32_t code = appendDownstream(pOperator, pDownstream, numOfDownstream); + return pOperator; + + _error: + taosMemoryFree(pInfo); + taosMemoryFree(pOperator); + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + return NULL; +} \ No newline at end of file From 3b9e9772d013e4260efa5fecf1cc7f90c2940169 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 10:12:29 +0800 Subject: [PATCH 15/48] test: reopen dbTest --- .../dnode/mnode/impl/test/db/CMakeLists.txt | 8 +- source/dnode/mnode/impl/test/db/db.cpp | 143 +++--------------- 2 files changed, 27 insertions(+), 124 deletions(-) diff --git a/source/dnode/mnode/impl/test/db/CMakeLists.txt b/source/dnode/mnode/impl/test/db/CMakeLists.txt index 1a5b4d3936..3f6a80835f 100644 --- a/source/dnode/mnode/impl/test/db/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/db/CMakeLists.txt @@ -5,7 +5,7 @@ target_link_libraries( PUBLIC sut ) -#add_test( -# NAME mnode_test_db -# COMMAND mnode_test_db -#) +add_test( + NAME dbTest + COMMAND dbTest +) diff --git a/source/dnode/mnode/impl/test/db/db.cpp b/source/dnode/mnode/impl/test/db/db.cpp index 0282663b17..adba6ca434 100644 --- a/source/dnode/mnode/impl/test/db/db.cpp +++ b/source/dnode/mnode/impl/test/db/db.cpp @@ -26,29 +26,8 @@ class MndTestDb : public ::testing::Test { Testbase MndTestDb::test; TEST_F(MndTestDb, 01_ShowDb) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 17); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "ntables"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_SMALLINT, 2, "replica"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_SMALLINT, 2, "quorum"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_SMALLINT, 2, "days"); - CHECK_SCHEMA(7, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "keep0,keep1,keep2"); - CHECK_SCHEMA(8, TSDB_DATA_TYPE_INT, 4, "cache"); - CHECK_SCHEMA(9, TSDB_DATA_TYPE_INT, 4, "blocks"); - CHECK_SCHEMA(10, TSDB_DATA_TYPE_INT, 4, "minrows"); - CHECK_SCHEMA(11, TSDB_DATA_TYPE_INT, 4, "maxrows"); - CHECK_SCHEMA(12, TSDB_DATA_TYPE_TINYINT, 1, "wallevel"); - CHECK_SCHEMA(13, TSDB_DATA_TYPE_INT, 4, "fsync"); - CHECK_SCHEMA(14, TSDB_DATA_TYPE_TINYINT, 1, "comp"); - CHECK_SCHEMA(15, TSDB_DATA_TYPE_TINYINT, 1, "cachelast"); - CHECK_SCHEMA(16, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision"); -// CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update"); - - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 0); + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 2); } TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { @@ -58,7 +37,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; + createReq.daysPerFile = 1000; createReq.daysToKeep0 = 3650; createReq.daysToKeep1 = 3650; createReq.daysToKeep2 = 3650; @@ -66,6 +45,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { createReq.maxRows = 4096; createReq.commitTime = 3600; createReq.fsyncPeriod = 3000; + createReq.ttl = 0; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; @@ -74,6 +54,9 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { createReq.update = 0; createReq.cacheLastRow = 0; createReq.ignoreExist = 1; + createReq.streamMode = 0; + createReq.singleSTable = 0; + createReq.numOfRetensions = 0; int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); @@ -84,47 +67,11 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 17); + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 3); - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("d1", TSDB_DB_NAME_LEN - 1); - CheckTimestamp(); - CheckInt16(2); // vgroups - CheckInt32(0); // ntables - CheckInt16(1); // replica - CheckInt16(1); // quorum - CheckInt16(10); // days - CheckBinary("3650,3650,3650", 24); // days - CheckInt32(16); // cache - CheckInt32(10); // blocks - CheckInt32(100); // minrows - CheckInt32(4096); // maxrows - CheckInt8(1); // wallevel - CheckInt32(3000); // fsync - CheckInt8(2); // comp - CheckInt8(0); // cachelast - CheckBinary("ms", 3); // precision - CheckInt8(0); // update - - test.SendShowMetaReq(TSDB_MGMT_TABLE_VGROUP, "1.d1"); - CHECK_META("show vgroups", 4); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "vgId"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_INT, 4, "tables"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "v1_dnode"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, 9 + VARSTR_HEADER_SIZE, "v1_status"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_VGROUP, "vgroups", "1.d1"); EXPECT_EQ(test.GetShowRows(), 2); - CheckInt32(2); - CheckInt32(3); - IgnoreInt32(); - IgnoreInt32(); - CheckInt16(1); - CheckInt16(1); - CheckBinary("master", 9); - CheckBinary("master", 9); { SAlterDbReq alterdbReq = {0}; @@ -147,55 +94,14 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("d1", TSDB_DB_NAME_LEN - 1); - CheckTimestamp(); - CheckInt16(2); // vgroups - CheckInt32(0); // tables - CheckInt16(1); // replica - CheckInt16(2); // quorum - CheckInt16(10); // days - CheckBinary("300,400,500", 24); // days - CheckInt32(16); // cache - CheckInt32(12); // blocks - CheckInt32(100); // minrows - CheckInt32(4096); // maxrows - CheckInt8(2); // wallevel - CheckInt32(4000); // fsync - CheckInt8(2); // comp - CheckInt8(1); // cachelast - CheckBinary("ms", 3); // precision - CheckInt8(0); // update + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 3); // restart test.Restart(); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 17); - - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - - CheckBinary("d1", TSDB_DB_NAME_LEN - 1); - CheckTimestamp(); - CheckInt16(2); // vgroups - CheckInt32(0); // tables - CheckInt16(1); // replica - CheckInt16(2); // quorum - CheckInt16(10); // days - CheckBinary("300,400,500", 24); // days - CheckInt32(16); // cache - CheckInt32(12); // blocks - CheckInt32(100); // minrows - CheckInt32(4096); // maxrows - CheckInt8(2); // wallevel - CheckInt32(4000); // fsync - CheckInt8(2); // comp - CheckInt8(1); // cachelast - CheckBinary("ms", 3); // precision - CheckInt8(0); // update + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 3); { SDropDbReq dropdbReq = {0}; @@ -214,11 +120,8 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { EXPECT_STREQ(dropdbRsp.db, "1.d1"); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 17); - - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 0); + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 2); } TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { @@ -228,7 +131,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; + createReq.daysPerFile = 1000; createReq.daysToKeep0 = 3650; createReq.daysToKeep1 = 3650; createReq.daysToKeep2 = 3650; @@ -236,6 +139,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { createReq.maxRows = 4096; createReq.commitTime = 3600; createReq.fsyncPeriod = 3000; + createReq.ttl = 0; createReq.walLevel = 1; createReq.precision = 0; createReq.compression = 2; @@ -244,6 +148,9 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { createReq.update = 0; createReq.cacheLastRow = 0; createReq.ignoreExist = 1; + createReq.streamMode = 0; + createReq.singleSTable = 0; + createReq.numOfRetensions = 0; int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); @@ -254,12 +161,8 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 17); - - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("d2", TSDB_DB_NAME_LEN - 1); + test.SendShowReq(TSDB_MGMT_TABLE_DB, "user_databases", ""); + EXPECT_EQ(test.GetShowRows(), 3); uint64_t d2_uid = 0; From a1f69af4237edeb1121552ecd0e7f331455e8f3c Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 10:23:08 +0800 Subject: [PATCH 16/48] test: reopen dnodeTest --- .../mnode/impl/test/dnode/CMakeLists.txt | 8 +- source/dnode/mnode/impl/test/dnode/mdnode.cpp | 118 +----------------- 2 files changed, 9 insertions(+), 117 deletions(-) diff --git a/source/dnode/mnode/impl/test/dnode/CMakeLists.txt b/source/dnode/mnode/impl/test/dnode/CMakeLists.txt index 16e08d6c35..d064df90bc 100644 --- a/source/dnode/mnode/impl/test/dnode/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/dnode/CMakeLists.txt @@ -5,7 +5,7 @@ target_link_libraries( PUBLIC sut ) -#add_test( -# NAME mnode_test_dnode -# COMMAND mnode_test_dnode -#) +add_test( + NAME mdnodeTest + COMMAND mdnodeTest +) diff --git a/source/dnode/mnode/impl/test/dnode/mdnode.cpp b/source/dnode/mnode/impl/test/dnode/mdnode.cpp index f575556345..a4cbc201a9 100644 --- a/source/dnode/mnode/impl/test/dnode/mdnode.cpp +++ b/source/dnode/mnode/impl/test/dnode/mdnode.cpp @@ -51,27 +51,8 @@ TestServer MndTestDnode::server4; TestServer MndTestDnode::server5; TEST_F(MndTestDnode, 01_ShowDnode) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - CHECK_META("show dnodes", 7); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vnodes"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_SMALLINT, 2, "support_vnodes"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "status"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_BINARY, 24 + VARSTR_HEADER_SIZE, "offline_reason"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9023", TSDB_EP_LEN); - CheckInt16(0); - CheckInt16(16); - CheckBinary("ready", 10); - CheckTimestamp(); - CheckBinary("", 24); } TEST_F(MndTestDnode, 02_ConfigDnode) { @@ -162,25 +143,8 @@ TEST_F(MndTestDnode, 03_Create_Dnode) { taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - CHECK_META("show dnodes", 7); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckInt16(1); - CheckInt16(2); - CheckBinary("localhost:9023", TSDB_EP_LEN); - CheckBinary("localhost:9024", TSDB_EP_LEN); - CheckInt16(0); - CheckInt16(0); - CheckInt16(16); - CheckInt16(16); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("", 24); - CheckBinary("", 24); } TEST_F(MndTestDnode, 04_Drop_Dnode) { @@ -236,19 +200,9 @@ TEST_F(MndTestDnode, 04_Drop_Dnode) { ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DNODE_NOT_EXIST); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - CHECK_META("show dnodes", 7); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - CheckInt16(1); - CheckBinary("localhost:9023", TSDB_EP_LEN); - CheckInt16(0); - CheckInt16(16); - CheckBinary("ready", 10); - CheckTimestamp(); - CheckBinary("", 24); - taosMsleep(2000); server2.Stop(); server2.DoStart(); @@ -298,40 +252,9 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) { } taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - CHECK_META("show dnodes", 7); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 4); - CheckInt16(1); - CheckInt16(3); - CheckInt16(4); - CheckInt16(5); - CheckBinary("localhost:9023", TSDB_EP_LEN); - CheckBinary("localhost:9025", TSDB_EP_LEN); - CheckBinary("localhost:9026", TSDB_EP_LEN); - CheckBinary("localhost:9027", TSDB_EP_LEN); - CheckInt16(0); - CheckInt16(0); - CheckInt16(0); - CheckInt16(0); - CheckInt16(16); - CheckInt16(16); - CheckInt16(16); - CheckInt16(16); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("", 24); - CheckBinary("", 24); - CheckBinary("", 24); - CheckBinary("", 24); - // restart uInfo("stop all server"); test.Restart(); @@ -341,37 +264,6 @@ TEST_F(MndTestDnode, 05_Create_Drop_Restart_Dnode) { server5.Restart(); taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - CHECK_META("show dnodes", 7); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 4); - - CheckInt16(1); - CheckInt16(3); - CheckInt16(4); - CheckInt16(5); - CheckBinary("localhost:9023", TSDB_EP_LEN); - CheckBinary("localhost:9025", TSDB_EP_LEN); - CheckBinary("localhost:9026", TSDB_EP_LEN); - CheckBinary("localhost:9027", TSDB_EP_LEN); - CheckInt16(0); - CheckInt16(0); - CheckInt16(0); - CheckInt16(0); - CheckInt16(16); - CheckInt16(16); - CheckInt16(16); - CheckInt16(16); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckBinary("ready", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("", 24); - CheckBinary("", 24); - CheckBinary("", 24); - CheckBinary("", 24); } From e499587d64a9e03c3207917aae0615707e8ea895 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 15 Apr 2022 10:34:28 +0800 Subject: [PATCH 17/48] disable hb --- source/client/src/clientHb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index e65a3017d6..a6678b2ec0 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -655,7 +655,7 @@ int hbMgrInit() { } void hbMgrCleanUp() { - hbStopThread(); + //hbStopThread(); // destroy all appHbMgr int8_t old = atomic_val_compare_exchange_8(&clientHbMgr.inited, 1, 0); From f431cbe03a2190c1bec1c7a60ccb30a60731949b Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 10:39:42 +0800 Subject: [PATCH 18/48] test: reopen funcTest --- source/dnode/mnode/impl/src/mndInfoSchema.c | 10 +++-- .../dnode/mnode/impl/test/func/CMakeLists.txt | 10 ++--- source/dnode/mnode/impl/test/func/func.cpp | 43 +++---------------- 3 files changed, 16 insertions(+), 47 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index c21a6e61df..32c9847fea 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -94,11 +94,13 @@ static const SInfosTableSchema userDBSchema[] = { }; static const SInfosTableSchema userFuncSchema[] = { - {.name = "name", .bytes = 32, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "name", .bytes = TSDB_FUNC_NAME_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "comment", .bytes = PATH_MAX - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "aggregate", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "comment", .bytes = TSDB_TYPE_STR_MAX_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, - {.name = "ntables", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "precision", .bytes = 2, .type = TSDB_DATA_TYPE_VARCHAR}, - {.name = "status", .bytes = 10, .type = TSDB_DATA_TYPE_VARCHAR}, + {.name = "code_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, + {.name = "bufsize", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, }; static const SInfosTableSchema userIdxSchema[] = { diff --git a/source/dnode/mnode/impl/test/func/CMakeLists.txt b/source/dnode/mnode/impl/test/func/CMakeLists.txt index 26b0a60968..ecb4f851be 100644 --- a/source/dnode/mnode/impl/test/func/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/func/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. FUNC_SRC) -add_executable(mnode_test_func ${FUNC_SRC}) +aux_source_directory(. MNODE_FUNC_TEST_SRC) +add_executable(funcTest ${MNODE_FUNC_TEST_SRC}) target_link_libraries( - mnode_test_func + funcTest PUBLIC sut ) add_test( - NAME mnode_test_func - COMMAND mnode_test_func + NAME funcTest + COMMAND funcTest ) diff --git a/source/dnode/mnode/impl/test/func/func.cpp b/source/dnode/mnode/impl/test/func/func.cpp index f34f77de0c..6b9c410738 100644 --- a/source/dnode/mnode/impl/test/func/func.cpp +++ b/source/dnode/mnode/impl/test/func/func.cpp @@ -26,18 +26,7 @@ class MndTestFunc : public ::testing::Test { Testbase MndTestFunc::test; TEST_F(MndTestFunc, 01_Show_Func) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, ""); - CHECK_META("show functions", 7); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_FUNC_NAME_LEN + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, PATH_MAX + VARSTR_HEADER_SIZE, "comment"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "aggregate"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_TYPE_STR_MAX_LEN + VARSTR_HEADER_SIZE, "outputtype"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_INT, 4, "code_len"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_INT, 4, "bufsize"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -194,19 +183,8 @@ TEST_F(MndTestFunc, 02_Create_Func) { } } - test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, ""); - CHECK_META("show functions", 7); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckBinary("f1", TSDB_FUNC_NAME_LEN); - CheckBinaryByte('m', TSDB_FUNC_COMMENT_LEN); - CheckInt32(0); - CheckBinary("SMALLINT", TSDB_TYPE_STR_MAX_LEN); - CheckTimestamp(); - CheckInt32(TSDB_FUNC_CODE_LEN); - CheckInt32(4); } TEST_F(MndTestFunc, 03_Retrieve_Func) { @@ -331,10 +309,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, ""); - CHECK_META("show functions", 7); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -529,20 +504,12 @@ TEST_F(MndTestFunc, 04_Drop_Func) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, ""); - CHECK_META("show functions", 7); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 1); // restart test.Restart(); - test.SendShowMetaReq(TSDB_MGMT_TABLE_FUNC, ""); - CHECK_META("show functions", 7); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "user_functions", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckBinary("f2", TSDB_FUNC_NAME_LEN); } From 1a96baf3293cf2ef71ed6017cf8f6bc2feac8f49 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 10:42:44 +0800 Subject: [PATCH 19/48] test: reopen mnodeTest --- .../mnode/impl/test/mnode/CMakeLists.txt | 10 ++--- source/dnode/mnode/impl/test/mnode/mnode.cpp | 43 ++----------------- 2 files changed, 9 insertions(+), 44 deletions(-) diff --git a/source/dnode/mnode/impl/test/mnode/CMakeLists.txt b/source/dnode/mnode/impl/test/mnode/CMakeLists.txt index 4d9b473291..94c25281b2 100644 --- a/source/dnode/mnode/impl/test/mnode/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/mnode/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. MTEST_SRC) -add_executable(mnode_test_mnode ${MTEST_SRC}) +aux_source_directory(. MNODE_MNODE_TEST_SRC) +add_executable(mmnodeTest ${MNODE_MNODE_TEST_SRC}) target_link_libraries( - mnode_test_mnode + mmnodeTest PUBLIC sut ) add_test( - NAME mnode_test_mnode - COMMAND mnode_test_mnode + NAME mmnodeTest + COMMAND mmnodeTest ) diff --git a/source/dnode/mnode/impl/test/mnode/mnode.cpp b/source/dnode/mnode/impl/test/mnode/mnode.cpp index dd2867f7f9..20cbb28b72 100644 --- a/source/dnode/mnode/impl/test/mnode/mnode.cpp +++ b/source/dnode/mnode/impl/test/mnode/mnode.cpp @@ -39,23 +39,8 @@ Testbase MndTestMnode::test; TestServer MndTestMnode::server2; TEST_F(MndTestMnode, 01_ShowDnode) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, ""); - CHECK_META("show mnodes", 5); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, 12 + VARSTR_HEADER_SIZE, "role"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_TIMESTAMP, 8, "role_time"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes",""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9028", TSDB_EP_LEN); - CheckBinary("master", 12); - CheckTimestamp(); - IgnoreTimestamp(); } TEST_F(MndTestMnode, 02_Create_Mnode_Invalid_Id) { @@ -104,8 +89,7 @@ TEST_F(MndTestMnode, 04_Create_Mnode) { ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -122,20 +106,8 @@ TEST_F(MndTestMnode, 04_Create_Mnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes",""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckInt16(1); - CheckInt16(2); - CheckBinary("localhost:9028", TSDB_EP_LEN); - CheckBinary("localhost:9029", TSDB_EP_LEN); - CheckBinary("master", 12); - CheckBinary("slave", 12); - CheckTimestamp(); - CheckTimestamp(); - IgnoreTimestamp(); - IgnoreTimestamp(); } { @@ -151,15 +123,8 @@ TEST_F(MndTestMnode, 04_Create_Mnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_MNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes",""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9028", TSDB_EP_LEN); - CheckBinary("master", 12); - CheckTimestamp(); - IgnoreTimestamp(); } { From 2a4a536ce2f888d3bee469e2c797caa5e6e3afdc Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 10:47:00 +0800 Subject: [PATCH 20/48] test: reopen profileTest --- source/dnode/mnode/impl/test/mnode/mnode.cpp | 6 +-- .../mnode/impl/test/profile/CMakeLists.txt | 10 ++--- .../dnode/mnode/impl/test/profile/profile.cpp | 41 ++----------------- 3 files changed, 11 insertions(+), 46 deletions(-) diff --git a/source/dnode/mnode/impl/test/mnode/mnode.cpp b/source/dnode/mnode/impl/test/mnode/mnode.cpp index 20cbb28b72..444c674667 100644 --- a/source/dnode/mnode/impl/test/mnode/mnode.cpp +++ b/source/dnode/mnode/impl/test/mnode/mnode.cpp @@ -39,7 +39,7 @@ Testbase MndTestMnode::test; TestServer MndTestMnode::server2; TEST_F(MndTestMnode, 01_ShowDnode) { - test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes",""); + test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); } @@ -106,7 +106,7 @@ TEST_F(MndTestMnode, 04_Create_Mnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes",""); + test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -123,7 +123,7 @@ TEST_F(MndTestMnode, 04_Create_Mnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes",""); + test.SendShowReq(TSDB_MGMT_TABLE_MNODE, "mnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); } diff --git a/source/dnode/mnode/impl/test/profile/CMakeLists.txt b/source/dnode/mnode/impl/test/profile/CMakeLists.txt index 88d7366b7d..8b811ebfed 100644 --- a/source/dnode/mnode/impl/test/profile/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/profile/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. PROFILE_SRC) -add_executable(mnode_test_profile ${PROFILE_SRC}) +aux_source_directory(. MNODE_PROFILE_TEST_SRC) +add_executable(profileTest ${MNODE_PROFILE_TEST_SRC}) target_link_libraries( - mnode_test_profile + profileTest PUBLIC sut ) add_test( - NAME mnode_test_profile - COMMAND mnode_test_profile + NAME profileTest + COMMAND profileTest ) diff --git a/source/dnode/mnode/impl/test/profile/profile.cpp b/source/dnode/mnode/impl/test/profile/profile.cpp index 14b31e5282..f4be703d72 100644 --- a/source/dnode/mnode/impl/test/profile/profile.cpp +++ b/source/dnode/mnode/impl/test/profile/profile.cpp @@ -74,25 +74,8 @@ TEST_F(MndTestProfile, 02_ConnectMsg_InvalidDB) { } TEST_F(MndTestProfile, 03_ConnectMsg_Show) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_CONNS, ""); - CHECK_META("show connections", 7); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "connId"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "user"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE, "program"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "pid"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, "ip:port"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "login_time"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_TIMESTAMP, 8, "last_access"); - - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - CheckInt32(1); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("mnode_test_profile", TSDB_APP_NAME_LEN); - CheckInt32(1234); - IgnoreBinary(TSDB_IPv4ADDR_LEN + 6); - CheckTimestamp(); - CheckTimestamp(); + test.SendShowReq(TSDB_MGMT_TABLE_CONNS, "connections", ""); + EXPECT_EQ(test.GetShowRows(), 0); } TEST_F(MndTestProfile, 04_HeartBeatMsg) { @@ -311,24 +294,6 @@ TEST_F(MndTestProfile, 08_KillQueryMsg_InvalidConn) { } TEST_F(MndTestProfile, 09_KillQueryMsg) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_QUERIES, ""); - CHECK_META("show queries", 14); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "queryId"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_INT, 4, "connId"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "user"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE, "ip:port"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, 22 + VARSTR_HEADER_SIZE, "qid"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "created_time"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_BIGINT, 8, "time"); - CHECK_SCHEMA(7, TSDB_DATA_TYPE_BINARY, 18 + VARSTR_HEADER_SIZE, "sql_obj_id"); - CHECK_SCHEMA(8, TSDB_DATA_TYPE_INT, 4, "pid"); - CHECK_SCHEMA(9, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "ep"); - CHECK_SCHEMA(10, TSDB_DATA_TYPE_BOOL, 1, "stable_query"); - CHECK_SCHEMA(11, TSDB_DATA_TYPE_INT, 4, "sub_queries"); - CHECK_SCHEMA(12, TSDB_DATA_TYPE_BINARY, TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE, "sub_query_info"); - CHECK_SCHEMA(13, TSDB_DATA_TYPE_BINARY, TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, "sql"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QUERIES, "queries", ""); EXPECT_EQ(test.GetShowRows(), 0); } From 66ea2d6bdc45db3933922301b08c3a5dee8dd02b Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Fri, 15 Apr 2022 10:49:00 +0800 Subject: [PATCH 21/48] fix(os): .free func const ptr. --- include/os/osMemory.h | 4 ++-- source/libs/transport/src/transComm.c | 2 +- source/libs/transport/test/transportTests.cpp | 12 ++++++------ source/os/src/osMemory.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/os/osMemory.h b/include/os/osMemory.h index e516000c66..4efe69e204 100644 --- a/include/os/osMemory.h +++ b/include/os/osMemory.h @@ -33,13 +33,13 @@ void *taosMemoryMalloc(int32_t size); void *taosMemoryCalloc(int32_t num, int32_t size); void *taosMemoryRealloc(void *ptr, int32_t size); void *taosMemoryStrDup(void *ptr); -void taosMemoryFree(const void *ptr); +void taosMemoryFree(void *ptr); int32_t taosMemorySize(void *ptr); #define taosMemoryFreeClear(ptr) \ do { \ if (ptr) { \ - taosMemoryFree(ptr); \ + taosMemoryFree((void*)ptr); \ (ptr) = NULL; \ } \ } while (0) diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 3078324c6b..ef9cccccb7 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -292,7 +292,7 @@ void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) { void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) { queue->q = taosArrayInit(2, sizeof(void*)); - queue->freeFunc = freeFunc; + queue->freeFunc = (void (*)(const void*))freeFunc; } bool transQueuePush(STransQueue* queue, void* arg) { if (queue->q == NULL) { diff --git a/source/libs/transport/test/transportTests.cpp b/source/libs/transport/test/transportTests.cpp index ce795b1763..2488dda3f6 100644 --- a/source/libs/transport/test/transportTests.cpp +++ b/source/libs/transport/test/transportTests.cpp @@ -156,14 +156,14 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; } { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; @@ -176,14 +176,14 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; } { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryMalloc(12); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); key++; @@ -198,7 +198,7 @@ TEST_F(TransCtxEnv, mergeTest) { STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); transCtxInit(src); { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryCalloc(1, 11); memcpy(val1.val, val.c_str(), val.size()); @@ -206,7 +206,7 @@ TEST_F(TransCtxEnv, mergeTest) { key++; } { - STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = taosMemoryFree}; + STransCtxVal val1 = {.val = NULL, .clone = NULL, .freeFunc = (void (*)(const void*))taosMemoryFree}; val1.val = taosMemoryCalloc(1, 11); memcpy(val1.val, val.c_str(), val.size()); taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index 3545aabdca..cd756b45e2 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -156,7 +156,7 @@ void *taosMemoryStrDup(void *ptr) { } -void taosMemoryFree(const void *ptr) { +void taosMemoryFree(void *ptr) { if (ptr == NULL) return; #ifdef USE_TD_MEMORY @@ -166,10 +166,10 @@ void taosMemoryFree(const void *ptr) { // memset(pTdMemoryInfo, 0, sizeof(TdMemoryInfo)); free(pTdMemoryInfo); } else { - free((void*)ptr); + free(ptr); } #else - return free((void*)ptr); + return free(ptr); #endif } From a8ab69e6cbddb0a42dd6c1648867fa6a2e143b9d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 10:54:04 +0800 Subject: [PATCH 22/48] test: reopen snodeTest --- .../mnode/impl/test/snode/CMakeLists.txt | 10 ++--- source/dnode/mnode/impl/test/snode/snode.cpp | 37 +++---------------- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/source/dnode/mnode/impl/test/snode/CMakeLists.txt b/source/dnode/mnode/impl/test/snode/CMakeLists.txt index 44a5f35f94..9c60da364c 100644 --- a/source/dnode/mnode/impl/test/snode/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/snode/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. STEST_SRC) -add_executable(mnode_test_snode ${STEST_SRC}) +aux_source_directory(. MNODE_SNODE_TEST_SRC) +add_executable(msnodeTest ${MNODE_SNODE_TEST_SRC}) target_link_libraries( - mnode_test_snode + msnodeTest PUBLIC sut ) add_test( - NAME mnode_test_snode - COMMAND mnode_test_snode + NAME msnodeTest + COMMAND msnodeTest ) diff --git a/source/dnode/mnode/impl/test/snode/snode.cpp b/source/dnode/mnode/impl/test/snode/snode.cpp index 7d24d89154..3742c06b0a 100644 --- a/source/dnode/mnode/impl/test/snode/snode.cpp +++ b/source/dnode/mnode/impl/test/snode/snode.cpp @@ -39,14 +39,7 @@ Testbase MndTestSnode::test; TestServer MndTestSnode::server2; TEST_F(MndTestSnode, 01_Show_Snode) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); - CHECK_META("show snodes", 3); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -76,14 +69,8 @@ TEST_F(MndTestSnode, 02_Create_Snode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); - CHECK_META("show snodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9016", TSDB_EP_LEN); - CheckTimestamp(); } { @@ -115,8 +102,7 @@ TEST_F(MndTestSnode, 03_Drop_Snode) { ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -132,16 +118,8 @@ TEST_F(MndTestSnode, 03_Drop_Snode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckInt16(1); - CheckInt16(2); - CheckBinary("localhost:9016", TSDB_EP_LEN); - CheckBinary("localhost:9017", TSDB_EP_LEN); - CheckTimestamp(); - CheckTimestamp(); } { @@ -156,13 +134,8 @@ TEST_F(MndTestSnode, 03_Drop_Snode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_SNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_SNODE, "snodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9016", TSDB_EP_LEN); - CheckTimestamp(); } { From dbe44ff13671b677c1050d72036acbc0720565fa Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 10:54:15 +0800 Subject: [PATCH 23/48] test: reopen qnodeTest --- .../mnode/impl/test/qnode/CMakeLists.txt | 10 ++--- source/dnode/mnode/impl/test/qnode/qnode.cpp | 37 +++---------------- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/source/dnode/mnode/impl/test/qnode/CMakeLists.txt b/source/dnode/mnode/impl/test/qnode/CMakeLists.txt index 77ac39e409..8259f9f47d 100644 --- a/source/dnode/mnode/impl/test/qnode/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/qnode/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. QTEST_SRC) -add_executable(mnode_test_qnode ${QTEST_SRC}) +aux_source_directory(. MNODE_QNODE_TEST_SRC) +add_executable(mqnodeTest ${MNODE_QNODE_TEST_SRC}) target_link_libraries( - mnode_test_qnode + mqnodeTest PUBLIC sut ) add_test( - NAME mnode_test_qnode - COMMAND mnode_test_qnode + NAME mqnodeTest + COMMAND mqnodeTest ) diff --git a/source/dnode/mnode/impl/test/qnode/qnode.cpp b/source/dnode/mnode/impl/test/qnode/qnode.cpp index be214cacf2..7240e0f183 100644 --- a/source/dnode/mnode/impl/test/qnode/qnode.cpp +++ b/source/dnode/mnode/impl/test/qnode/qnode.cpp @@ -39,14 +39,7 @@ Testbase MndTestQnode::test; TestServer MndTestQnode::server2; TEST_F(MndTestQnode, 01_Show_Qnode) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - CHECK_META("show qnodes", 3); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -76,14 +69,8 @@ TEST_F(MndTestQnode, 02_Create_Qnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - CHECK_META("show qnodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9014", TSDB_EP_LEN); - CheckTimestamp(); } { @@ -115,8 +102,7 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) { ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -132,16 +118,8 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckInt16(1); - CheckInt16(2); - CheckBinary("localhost:9014", TSDB_EP_LEN); - CheckBinary("localhost:9015", TSDB_EP_LEN); - CheckTimestamp(); - CheckTimestamp(); } { @@ -156,13 +134,8 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckInt16(1); - CheckBinary("localhost:9014", TSDB_EP_LEN); - CheckTimestamp(); } { From d8b6afee985eac379291ddef565d658bcd4aef36 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 10:58:15 +0800 Subject: [PATCH 24/48] test: reopen smaTest --- source/dnode/mnode/impl/test/sma/CMakeLists.txt | 10 +++++----- source/dnode/mnode/impl/test/sma/sma.cpp | 15 ++++++--------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/source/dnode/mnode/impl/test/sma/CMakeLists.txt b/source/dnode/mnode/impl/test/sma/CMakeLists.txt index 943695abf3..3f9ec123a8 100644 --- a/source/dnode/mnode/impl/test/sma/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/sma/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. SMA_SRC) -add_executable(mnode_test_sma ${SMA_SRC}) +aux_source_directory(. MNODE_SMA_TEST_SRC) +add_executable(smaTest ${MNODE_SMA_TEST_SRC}) target_link_libraries( - mnode_test_sma + smaTest PUBLIC sut ) add_test( - NAME mnode_test_sma - COMMAND mnode_test_sma + NAME smaTest + COMMAND smaTest ) diff --git a/source/dnode/mnode/impl/test/sma/sma.cpp b/source/dnode/mnode/impl/test/sma/sma.cpp index 4b0e33a323..4f3b0d6e37 100644 --- a/source/dnode/mnode/impl/test/sma/sma.cpp +++ b/source/dnode/mnode/impl/test/sma/sma.cpp @@ -207,7 +207,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) { pReq = BuildCreateStbReq(stbname, &contLen); pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables",dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); } @@ -216,7 +216,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) { pReq = BuildCreateTSmaReq(smaname, stbname, 0, "expr", "tagsFilter", "sql", "ast", &contLen); pRsp = test.SendReq(TDMT_MND_CREATE_SMA, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_INDEX, dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); } @@ -225,7 +225,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) { test.Restart(); { - test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_INDEX, dbname); CHECK_META("show indexes", 3); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); @@ -239,7 +239,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) { pReq = BuildDropTSmaReq(smaname, 0, &contLen); pRsp = test.SendReq(TDMT_MND_DROP_SMA, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_INDEX, dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } @@ -263,10 +263,8 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) { pReq = BuildCreateBSmaStbReq(stbname, &contLen); pRsp = test.SendReq(TDMT_MND_CREATE_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables",dbname); EXPECT_EQ(test.GetShowRows(), 1); -// CheckBinary("bsmastb", TSDB_TABLE_NAME_LEN); } test.Restart(); @@ -281,8 +279,7 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) { pReq = BuildDropStbReq(stbname, &contLen); pRsp = test.SendReq(TDMT_MND_DROP_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables",dbname); EXPECT_EQ(test.GetShowRows(), 0); } From de121928070e2c8e30425192c25d838c2a4b4410 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 10:58:27 +0800 Subject: [PATCH 25/48] test: reopen showTest --- .../dnode/mnode/impl/test/show/CMakeLists.txt | 10 ++--- source/dnode/mnode/impl/test/show/show.cpp | 37 ++----------------- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/source/dnode/mnode/impl/test/show/CMakeLists.txt b/source/dnode/mnode/impl/test/show/CMakeLists.txt index cc0706ca50..69e93e7086 100644 --- a/source/dnode/mnode/impl/test/show/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/show/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. SHOW_SRC) -add_executable(mnode_test_show ${SHOW_SRC}) +aux_source_directory(. MNODE_SHOW_TEST_SRC) +add_executable(showTest ${MNODE_SHOW_TEST_SRC}) target_link_libraries( - mnode_test_show + showTest PUBLIC sut ) add_test( - NAME mnode_test_show - COMMAND mnode_test_show + NAME showTest + COMMAND showTest ) diff --git a/source/dnode/mnode/impl/test/show/show.cpp b/source/dnode/mnode/impl/test/show/show.cpp index a57d99a257..5b8c186ccf 100644 --- a/source/dnode/mnode/impl/test/show/show.cpp +++ b/source/dnode/mnode/impl/test/show/show.cpp @@ -67,42 +67,11 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_CONNS, ""); - - STableMetaRsp* pMeta = test.GetShowMeta(); - EXPECT_STREQ(pMeta->tbName, "show connections"); - EXPECT_EQ(pMeta->numOfTags, 0); - EXPECT_EQ(pMeta->numOfColumns, 7); - EXPECT_EQ(pMeta->precision, 0); - EXPECT_EQ(pMeta->tableType, 0); - EXPECT_EQ(pMeta->update, 0); - EXPECT_EQ(pMeta->sversion, 0); - EXPECT_EQ(pMeta->tversion, 0); - EXPECT_EQ(pMeta->tuid, 0); - EXPECT_EQ(pMeta->suid, 0); - - test.SendShowRetrieveReq(); - - SRetrieveTableRsp* pRetrieveRsp = test.GetRetrieveRsp(); - EXPECT_EQ(pRetrieveRsp->numOfRows, 1); - EXPECT_EQ(pRetrieveRsp->useconds, 0); - EXPECT_EQ(pRetrieveRsp->completed, 1); - EXPECT_EQ(pRetrieveRsp->precision, TSDB_TIME_PRECISION_MILLI); - EXPECT_EQ(pRetrieveRsp->compressed, 0); - EXPECT_EQ(pRetrieveRsp->compLen, 0); + test.SendShowReq(TSDB_MGMT_TABLE_CONNS, "connections", ""); + // EXPECT_EQ(test.GetShowRows(), 1); } TEST_F(MndTestShow, 04_ShowMsg_Cluster) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_CLUSTER, ""); - CHECK_META( "show cluster", 3); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BIGINT, 8, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_CLUSTER, "cluster", ""); EXPECT_EQ(test.GetShowRows(), 1); - - IgnoreInt64(); - IgnoreBinary(TSDB_CLUSTER_ID_LEN); - CheckTimestamp(); } \ No newline at end of file From b0f4a396d42eed4896b984a658357a67ccad7021 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 15 Apr 2022 03:48:51 +0000 Subject: [PATCH 26/48] refact vnode --- source/dnode/vnode/CMakeLists.txt | 2 +- source/dnode/vnode/src/inc/vnd.h | 8 ++- source/dnode/vnode/src/vnd/vnodeCfg.c | 93 +++++++++++++++++++++++++- source/dnode/vnode/src/vnd/vnodeOpen.c | 9 ++- 4 files changed, 101 insertions(+), 11 deletions(-) diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index f7a3f2f109..c0e458219c 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -4,13 +4,13 @@ target_sources( vnode PRIVATE # vnode + "src/vnd/vnodeOpen.c" "src/vnd/vnodeArenaMAImpl.c" "src/vnd/vnodeBufferPool.c" # "src/vnd/vnodeBufferPool2.c" "src/vnd/vnodeCfg.c" "src/vnd/vnodeCommit.c" "src/vnd/vnodeInt.c" - "src/vnd/vnodeOpen.c" "src/vnd/vnodeQuery.c" "src/vnd/vnodeStateMgr.c" "src/vnd/vnodeWrite.c" diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 1cdb38b650..55b69a9e6e 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -30,6 +30,10 @@ extern "C" { #define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0) // clang-format on +// vnodeCfg ==================== +int vnodeSaveCfg(const char* dir, const SVnodeCfg* pCfg); +int vnodeCommitCfg(const char* dir); + // vnodeModule ==================== int vnodeScheduleTask(int (*execute)(void*), void* arg); @@ -75,9 +79,9 @@ void vmaFree(SVMemAllocator* pVMA, void* ptr); bool vmaIsFull(SVMemAllocator* pVMA); // vnodeCfg.h -extern const SVnodeCfg defaultVnodeOptions; +extern const SVnodeCfg vnodeCfgDefault; -int vnodeValidateOptions(const SVnodeCfg*); +int vnodeCheckCfg(const SVnodeCfg*); void vnodeOptionsCopy(SVnodeCfg* pDest, const SVnodeCfg* pSrc); // For commit diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index ef417cabc6..8da9950aa7 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -15,14 +15,99 @@ #include "vnodeInt.h" -const SVnodeCfg defaultVnodeOptions = { - .wsize = 96 * 1024 * 1024, .ssize = 1 * 1024 * 1024, .lsize = 1024, .walCfg = {.level = TAOS_WAL_WRITE}}; /* TODO */ +#define VND_INFO_FNAME "vnode.json" +#define VND_INFO_FNAME_TMP "vnode_tmp.json" -int vnodeValidateOptions(const SVnodeCfg *pVnodeOptions) { +static int vnodeEncodeInfo(const SVnodeCfg *pCfg, uint8_t **ppData, int *len); +static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeCfg *pCfg); + +const SVnodeCfg vnodeCfgDefault = { + .wsize = 96 * 1024 * 1024, .ssize = 1 * 1024 * 1024, .lsize = 1024, .walCfg = {.level = TAOS_WAL_WRITE}}; + +int vnodeCheckCfg(const SVnodeCfg *pCfg) { // TODO return 0; } +int vnodeSaveCfg(const char *dir, const SVnodeCfg *pCfg) { + char fname[TSDB_FILENAME_LEN]; + TdFilePtr pFile; + uint8_t *data; + int len; + + snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP); + + // encode info + data = NULL; + len = 0; + + if (vnodeEncodeInfo(pCfg, &data, &len) < 0) { + return -1; + } + + // save info to a vnode_tmp.json + pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); + if (pFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + if (taosWriteFile(pFile, data, len) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + if (taosFsyncFile(pFile) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + taosCloseFile(&pFile); + + // free info binary + taosMemoryFree(data); + + vInfo("vgId: %d vnode info is saved, fname: %s", pCfg->vgId, fname); + + return 0; + +_err: + taosCloseFile(&pFile); + taosMemoryFree(data); + return -1; +} + +int vnodeCommitCfg(const char *dir) { + char fname[TSDB_FILENAME_LEN]; + char tfname[TSDB_FILENAME_LEN]; + + snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME); + snprintf(tfname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP); + + if (taosRenameFile(tfname, fname) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + return 0; +} + +int vnodeLoadCfg(const char *dir) { + // TODO + return 0; +} + +static int vnodeEncodeInfo(const SVnodeCfg *pCfg, uint8_t **ppData, int *len) { + // TODO + return 0; +} + +static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeCfg *pCfg) { + // TODO + return 0; +} + +#if 1 //====================================================================== void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) { memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg)); } @@ -46,3 +131,5 @@ int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) { return TSDB_CODE_SUCCESS; } + +#endif \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index f208857762..6729f7ce0c 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -21,8 +21,8 @@ static int vnodeOpenImpl(SVnode *pVnode); static void vnodeCloseImpl(SVnode *pVnode); int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { -#if 0 char dir[TSDB_FILENAME_LEN]; + // TODO: check if directory exists // check config @@ -34,12 +34,11 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { // create vnode env tfsMkdir(pTfs, path); snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); - if (vnodeSaveCfg(dir, pCfg) < 0) { + if (vnodeSaveCfg(dir, pCfg) < 0 || vnodeCommitCfg(dir) < 0) { vError("vgId: %d failed to save vnode config since %s", pCfg->vgId, tstrerror(terrno)); return -1; } -#endif return 0; } @@ -47,7 +46,7 @@ SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) { SVnode *pVnode = NULL; // Set default options - SVnodeCfg cfg = defaultVnodeOptions; + SVnodeCfg cfg = vnodeCfgDefault; if (pVnodeCfg != NULL) { cfg.vgId = pVnodeCfg->vgId; cfg.msgCb = pVnodeCfg->msgCb; @@ -59,7 +58,7 @@ SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) { } // Validate options - if (vnodeValidateOptions(&cfg) < 0) { + if (vnodeCheckCfg(&cfg) < 0) { // TODO return NULL; } From d2761b41145e50bb4ca4d640021e0b91753365df Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Apr 2022 12:09:27 +0800 Subject: [PATCH 27/48] ehn(query): refactor c driver codes. --- source/client/inc/clientInt.h | 35 +++------ source/client/src/clientEnv.c | 7 +- source/client/src/clientImpl.c | 14 ++++ source/client/src/clientMain.c | 4 +- source/client/src/clientMsgHandler.c | 97 +++---------------------- source/libs/executor/src/executorimpl.c | 23 +++--- source/libs/qworker/src/qworker.c | 2 +- 7 files changed, 55 insertions(+), 127 deletions(-) diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 0f12880272..32668356ee 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -43,13 +43,23 @@ extern "C" { } \ } while (0) +#define ERROR_MSG_BUF_DEFAULT_SIZE 512 #define HEARTBEAT_INTERVAL 1500 // ms +// todo refactor enum { CONN_TYPE__QUERY = 1, CONN_TYPE__TMQ, }; +enum { + RES_TYPE__QUERY = 1, + RES_TYPE__TMQ, +}; + +#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) +#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) + typedef struct SAppInstInfo SAppInstInfo; typedef struct { @@ -172,33 +182,15 @@ typedef struct SReqResultInfo { int32_t payloadLen; } SReqResultInfo; -typedef struct SShowReqInfo { - int64_t execId; // showId/queryId - int32_t vgId; - SArray* pArray; // SArray - int32_t currentIndex; // current accessed vgroup index. -} SShowReqInfo; - typedef struct SRequestSendRecvBody { tsem_t rspSem; // not used now void* fp; - SShowReqInfo showInfo; // todo this attribute will be removed after the query framework being completed. SDataBuf requestMsg; int64_t queryJob; // query job, created according to sql query DAG. struct SQueryPlan* pDag; // the query dag, generated according to the sql statement. SReqResultInfo resInfo; } SRequestSendRecvBody; -#define ERROR_MSG_BUF_DEFAULT_SIZE 512 - -enum { - RES_TYPE__QUERY = 1, - RES_TYPE__TMQ, -}; - -#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) -#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) - typedef struct { int8_t resType; char* topic; @@ -217,7 +209,6 @@ typedef struct SRequestObj { int32_t sqlLen; int64_t self; char* msgBuf; - void* pInfo; // sql parse info, generated by parser module int32_t code; SArray* dbList; SArray* tableList; @@ -252,7 +243,7 @@ extern int (*handleRequestRspFp[TDMT_MAX])(void*, const SDataBuf* pMsg, int32_t int genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code); SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pReqObj); -int taos_init(); +int taos_init(); void* createTscObj(const char* user, const char* auth, const char* db, SAppInstInfo* pAppInfo); void destroyTscObj(void* pObj); @@ -266,7 +257,6 @@ char* getDbOfConnection(STscObj* pObj); void setConnectionDB(STscObj* pTscObj, const char* db); void resetConnectDB(STscObj* pTscObj); -void taos_init_imp(void); int taos_options_imp(TSDB_OPTION option, const char* str); void* openTransporter(const char* user, const char* auth, int32_t numOfThreads); @@ -286,8 +276,7 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj* void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); void doSetOneRowPtr(SReqResultInfo* pResultInfo); -int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows, - bool convertUcs4); +int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows, bool convertUcs4); void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols); int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4); diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index fec6c8e5db..a258fd305e 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -33,7 +33,7 @@ SAppInfo appInfo; int32_t clientReqRefPool = -1; int32_t clientConnRefPool = -1; -static TdThreadOnce tscinit = PTHREAD_ONCE_INIT; +static TdThreadOnce tscinit = PTHREAD_ONCE_INIT; volatile int32_t tscInitRes = 0; static void registerRequest(SRequestObj *pRequest) { @@ -188,7 +188,6 @@ static void doDestroyRequest(void *p) { taosMemoryFreeClear(pRequest->msgBuf); taosMemoryFreeClear(pRequest->sqlstr); - taosMemoryFreeClear(pRequest->pInfo); taosMemoryFreeClear(pRequest->pDb); doFreeReqResultInfo(&pRequest->body.resInfo); @@ -198,10 +197,6 @@ static void doDestroyRequest(void *p) { schedulerFreeJob(pRequest->body.queryJob); } - if (pRequest->body.showInfo.pArray != NULL) { - taosArrayDestroy(pRequest->body.showInfo.pArray); - } - taosArrayDestroy(pRequest->tableList); taosArrayDestroy(pRequest->dbList); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 96a7230ff3..b3615c208c 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ #include "clientInt.h" #include "clientLog.h" diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 42d204284e..96ef8d0d21 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -193,7 +193,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { } } else { - // assert to avoid uninitialization error + // assert to avoid un-initialization error ASSERT(0); } return NULL; @@ -355,6 +355,7 @@ int taos_result_precision(TAOS_RES *res) { if (res == NULL) { return TSDB_TIME_PRECISION_MILLI; } + if (TD_RES_QUERY(res)) { SRequestObj *pRequest = (SRequestObj *)res; return pRequest->body.resInfo.precision; @@ -467,6 +468,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) { if (res == NULL) { return 0; } + if (TD_RES_TMQ(res)) { SReqResultInfo *pResultInfo = tmqGetNextResInfo(res); if (pResultInfo == NULL) { diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 67c5679cac..87a8e86415 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -117,10 +117,10 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { struct SCatalog *pCatalog = NULL; if (usedbRsp.vgVersion >= 0) { - int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); - if (code != TSDB_CODE_SUCCESS) { + int32_t code1 = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); + if (code1 != TSDB_CODE_SUCCESS) { tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId, - tstrerror(code)); + tstrerror(code1)); } else { catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid); } @@ -154,10 +154,10 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { } else { struct SCatalog* pCatalog = NULL; - int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); - if (code != TSDB_CODE_SUCCESS) { + int32_t code1 = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); + if (code1 != TSDB_CODE_SUCCESS) { tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId, - tstrerror(code)); + tstrerror(code1)); } else { catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup); } @@ -209,84 +209,9 @@ int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) { } void initMsgHandleFp() { -#if 0 - tscBuildMsg[TSDB_SQL_SELECT] = tscBuildQueryMsg; - tscBuildMsg[TSDB_SQL_INSERT] = tscBuildSubmitMsg; - tscBuildMsg[TSDB_SQL_FETCH] = tscBuildFetchMsg; - - tscBuildMsg[TSDB_SQL_CREATE_DB] = tscBuildCreateDbMsg; - tscBuildMsg[TSDB_SQL_CREATE_USER] = tscBuildUserMsg; - tscBuildMsg[TSDB_SQL_CREATE_FUNCTION] = tscBuildCreateFuncMsg; - - tscBuildMsg[TSDB_SQL_CREATE_ACCT] = tscBuildAcctMsg; - tscBuildMsg[TSDB_SQL_ALTER_ACCT] = tscBuildAcctMsg; - - tscBuildMsg[TSDB_SQL_CREATE_TABLE] = tscBuildCreateTableMsg; - tscBuildMsg[TSDB_SQL_DROP_USER] = tscBuildDropUserAcctMsg; - tscBuildMsg[TSDB_SQL_DROP_ACCT] = tscBuildDropUserAcctMsg; - tscBuildMsg[TSDB_SQL_DROP_DB] = tscBuildDropDbMsg; - tscBuildMsg[TSDB_SQL_DROP_FUNCTION] = tscBuildDropFuncMsg; - tscBuildMsg[TSDB_SQL_SYNC_DB_REPLICA] = tscBuildSyncDbReplicaMsg; - tscBuildMsg[TSDB_SQL_DROP_TABLE] = tscBuildDropTableMsg; - tscBuildMsg[TSDB_SQL_ALTER_USER] = tscBuildUserMsg; - tscBuildMsg[TSDB_SQL_CREATE_DNODE] = tscBuildCreateDnodeMsg; - tscBuildMsg[TSDB_SQL_DROP_DNODE] = tscBuildDropDnodeMsg; - tscBuildMsg[TSDB_SQL_CFG_DNODE] = tscBuildCfgDnodeMsg; - tscBuildMsg[TSDB_SQL_ALTER_TABLE] = tscBuildAlterTableMsg; - tscBuildMsg[TSDB_SQL_UPDATE_TAG_VAL] = tscBuildUpdateTagMsg; - tscBuildMsg[TSDB_SQL_ALTER_DB] = tscAlterDbMsg; - tscBuildMsg[TSDB_SQL_COMPACT_VNODE] = tscBuildCompactMsg; - - - tscBuildMsg[TSDB_SQL_USE_DB] = tscBuildUseDbMsg; - tscBuildMsg[TSDB_SQL_STABLEVGROUP] = tscBuildSTableVgroupMsg; - tscBuildMsg[TSDB_SQL_RETRIEVE_FUNC] = tscBuildRetrieveFuncMsg; - - tscBuildMsg[TSDB_SQL_HB] = tscBuildHeartBeatMsg; - tscBuildMsg[TSDB_SQL_SHOW] = tscBuildShowMsg; - tscBuildMsg[TSDB_SQL_RETRIEVE_MNODE] = tscBuildRetrieveFromMgmtMsg; - tscBuildMsg[TSDB_SQL_KILL_QUERY] = tscBuildKillMsg; - tscBuildMsg[TSDB_SQL_KILL_STREAM] = tscBuildKillMsg; - tscBuildMsg[TSDB_SQL_KILL_CONNECTION] = tscBuildKillMsg; - - tscProcessMsgRsp[TSDB_SQL_SELECT] = tscProcessQueryRsp; - tscProcessMsgRsp[TSDB_SQL_FETCH] = tscProcessRetrieveRspFromNode; - - tscProcessMsgRsp[TSDB_SQL_DROP_DB] = tscProcessDropDbRsp; - tscProcessMsgRsp[TSDB_SQL_DROP_TABLE] = tscProcessDropTableRsp; - - tscProcessMsgRsp[TSDB_SQL_USE_DB] = tscProcessUseDbRsp; - tscProcessMsgRsp[TSDB_SQL_META] = tscProcessTableMetaRsp; - tscProcessMsgRsp[TSDB_SQL_STABLEVGROUP] = tscProcessSTableVgroupRsp; - tscProcessMsgRsp[TSDB_SQL_MULTI_META] = tscProcessMultiTableMetaRsp; - tscProcessMsgRsp[TSDB_SQL_RETRIEVE_FUNC] = tscProcessRetrieveFuncRsp; - - tscProcessMsgRsp[TSDB_SQL_SHOW] = tscProcessShowRsp; - tscProcessMsgRsp[TSDB_SQL_RETRIEVE_MNODE] = tscProcessRetrieveRspFromNode; // rsp handled by same function. - tscProcessMsgRsp[TSDB_SQL_DESCRIBE_TABLE] = tscProcessDescribeTableRsp; - - tscProcessMsgRsp[TSDB_SQL_CURRENT_DB] = tscProcessLocalRetrieveRsp; - tscProcessMsgRsp[TSDB_SQL_CURRENT_USER] = tscProcessLocalRetrieveRsp; - tscProcessMsgRsp[TSDB_SQL_SERV_VERSION] = tscProcessLocalRetrieveRsp; - tscProcessMsgRsp[TSDB_SQL_CLI_VERSION] = tscProcessLocalRetrieveRsp; - tscProcessMsgRsp[TSDB_SQL_SERV_STATUS] = tscProcessLocalRetrieveRsp; - - tscProcessMsgRsp[TSDB_SQL_RETRIEVE_EMPTY_RESULT] = tscProcessEmptyResultRsp; - - tscProcessMsgRsp[TSDB_SQL_RETRIEVE_GLOBALMERGE] = tscProcessRetrieveGlobalMergeRsp; - - tscProcessMsgRsp[TSDB_SQL_ALTER_TABLE] = tscProcessAlterTableMsgRsp; - tscProcessMsgRsp[TSDB_SQL_ALTER_DB] = tscProcessAlterDbMsgRsp; - tscProcessMsgRsp[TSDB_SQL_COMPACT_VNODE] = tscProcessCompactRsp; - - tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_TABLE] = tscProcessShowCreateRsp; - tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_STABLE] = tscProcessShowCreateRsp; - tscProcessMsgRsp[TSDB_SQL_SHOW_CREATE_DATABASE] = tscProcessShowCreateRsp; -#endif - - handleRequestRspFp[TMSG_INDEX(TDMT_MND_CONNECT)] = processConnectRsp; - handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_DB)] = processCreateDbRsp; - handleRequestRspFp[TMSG_INDEX(TDMT_MND_USE_DB)] = processUseDbRsp; - handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_STB)] = processCreateTableRsp; - handleRequestRspFp[TMSG_INDEX(TDMT_MND_DROP_DB)] = processDropDbRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_CONNECT)] = processConnectRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_DB)] = processCreateDbRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_USE_DB)] = processUseDbRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_CREATE_STB)] = processCreateTableRsp; + handleRequestRspFp[TMSG_INDEX(TDMT_MND_DROP_DB)] = processDropDbRsp; } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 45674d31bc..20b7169895 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -6815,6 +6815,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo ops[i] = createOperatorTree(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo); } + SOperatorInfo* pOptr = NULL; if (QUERY_NODE_PHYSICAL_PLAN_PROJECT == type) { SProjectPhysiNode* pProjPhyNode = (SProjectPhysiNode*) pPhyNode; SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &num); @@ -6822,7 +6823,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); SLimit limit = {.limit = pProjPhyNode->limit, .offset = pProjPhyNode->offset}; SLimit slimit = {.limit = pProjPhyNode->slimit, .offset = pProjPhyNode->soffset}; - return createProjectOperatorInfo(ops[0], pExprInfo, num, pResBlock, &limit, &slimit, pTaskInfo); + pOptr = createProjectOperatorInfo(ops[0], pExprInfo, num, pResBlock, &limit, &slimit, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_AGG == type) { SAggPhysiNode* pAggNode = (SAggPhysiNode*)pPhyNode; SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); @@ -6836,9 +6837,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); } - return createGroupOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL); + pOptr = createGroupOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo, NULL); } else { - return createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo); + pOptr = createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo); } } else if (QUERY_NODE_PHYSICAL_PLAN_INTERVAL == type) { SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; @@ -6856,39 +6857,39 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo }; int32_t primaryTsSlotId = ((SColumnNode*) pIntervalPhyNode->window.pTspk)->slotId; - return createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, primaryTsSlotId, pTableGroupInfo, pTaskInfo); + pOptr = createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, primaryTsSlotId, pTableGroupInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) { SSortPhysiNode* pSortPhyNode = (SSortPhysiNode*)pPhyNode; SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); SArray* info = createSortInfo(pSortPhyNode->pSortKeys, pSortPhyNode->pTargets); SArray* slotMap = createIndexMap(pSortPhyNode->pTargets); - return createSortOperatorInfo(ops[0], pResBlock, info, slotMap, pTaskInfo); + pOptr = createSortOperatorInfo(ops[0], pResBlock, info, slotMap, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW == type) { SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode; SExprInfo* pExprInfo = createExprInfo(pSessionNode->window.pFuncs, NULL, &num); SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); - return createSessionAggOperatorInfo(ops[0], pExprInfo, num, pResBlock, pSessionNode->gap, pTaskInfo); + pOptr = createSessionAggOperatorInfo(ops[0], pExprInfo, num, pResBlock, pSessionNode->gap, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_PARTITION == type) { SPartitionPhysiNode* pPartNode = (SPartitionPhysiNode*) pPhyNode; SArray* pColList = extractPartitionColInfo(pPartNode->pPartitionKeys); SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &num); - return createPartitionOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pTaskInfo, NULL); + pOptr = createPartitionOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pTaskInfo, NULL); } else if (QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW == type) { SStateWinodwPhysiNode* pStateNode = (SStateWinodwPhysiNode*) pPhyNode; SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num); SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); - return createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo); + pOptr = createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_JOIN == type) { SJoinPhysiNode* pJoinNode = (SJoinPhysiNode*) pPhyNode; SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &num); - return createJoinOperatorInfo(ops, size, pExprInfo, num, pResBlock, pJoinNode->pOnConditions, pTaskInfo); + pOptr = createJoinOperatorInfo(ops, size, pExprInfo, num, pResBlock, pJoinNode->pOnConditions, pTaskInfo); } else { ASSERT(0); } /*else if (pPhyNode->info.type == OP_MultiTableAggregate) { @@ -6901,7 +6902,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return createMultiTableAggOperatorInfo(op, pPhyNode->pTargets, pTaskInfo, pTableGroupInfo); } }*/ - return NULL; + + taosMemoryFree(ops); + return pOptr; } static tsdbReaderT createDataReaderImpl(STableScanPhysiNode* pTableScanNode, STableGroupInfo* pGroupInfo, diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 67871dfe62..a9a360e03e 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -1020,7 +1020,7 @@ int32_t qwProcessReady(QW_FPARAMS_DEF, SQWMsg *qwMsg) { } if (ctx->phase == QW_PHASE_PRE_QUERY) { - ctx->ctrlConnInfo.handle == qwMsg->connInfo.handle; + ctx->ctrlConnInfo.handle = qwMsg->connInfo.handle; ctx->ctrlConnInfo.ahandle = qwMsg->connInfo.ahandle; QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_READY); needRsp = false; From 85496cbb4c74a2009b59a2be2d3fc873d7a0707f Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 15 Apr 2022 13:17:25 +0800 Subject: [PATCH 28/48] fix(connector): lua example compile for 3.0 (#11523) * [TD-13558]: taos shell refactor add taosTools as submodule * add tools/taos-tools * add more client interface for taosTools compile * update taos-tools * update taos-tools * refactor shell * [TD-13558]: taos shell test speed * [TD-13558]: taos -n startup works * taos -n rpc works * taos -n server works * cleanup code since no endPort in 3.0 * update taos-tools * [TD-13558]: taos -C works * improve taos shell -c WIP * update taos-tools * add demoapi.c * adjust show databases result for 3.0 * test: add platform logic * add nchar * adjust taos_fetch_lengths * print fields * remove show databases check from insert cases * fix lua example compile for 3.0 still not work --- examples/lua/build.sh | 2 +- examples/lua/lua_connector.c | 140 +++++------------------------------ 2 files changed, 19 insertions(+), 123 deletions(-) diff --git a/examples/lua/build.sh b/examples/lua/build.sh index 9d00c68425..1e6fef632c 100755 --- a/examples/lua/build.sh +++ b/examples/lua/build.sh @@ -4,5 +4,5 @@ if [ "$lua_header_installed" = "0" ]; then sudo apt install -y liblua5.3-dev fi -gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos -I/usr/include/lua5.3 +gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos -I/usr/include/lua5.3 -I../../include/client diff --git a/examples/lua/lua_connector.c b/examples/lua/lua_connector.c index 76634ed254..3c13b196b9 100644 --- a/examples/lua/lua_connector.c +++ b/examples/lua/lua_connector.c @@ -1,11 +1,11 @@ -#include -#include -#include +#include #include #include -#include #include -#include "../../../include/client/taos.h" +#include +#include +#include +#include "taos.h" struct cb_param{ lua_State* state; @@ -28,14 +28,14 @@ static int l_connect(lua_State *L){ luaL_checktype(L, 1, LUA_TTABLE); - lua_getfield(L,1,"host"); + lua_getfield(L, 1,"host"); if (lua_isstring(L,-1)){ host = lua_tostring(L, -1); // printf("host = %s\n", host); } lua_getfield(L, 1, "port"); - if (lua_isinteger(L,-1)){ + if (lua_isinteger(L, -1)){ port = lua_tointeger(L, -1); //printf("port = %d\n", port); } @@ -60,8 +60,6 @@ static int l_connect(lua_State *L){ lua_settop(L,0); - taos_init(); - lua_newtable(L); int table_index = lua_gettop(L); @@ -102,7 +100,7 @@ static int l_query(lua_State *L){ printf("failed, reason:%s\n", taos_errstr(result)); lua_pushinteger(L, -1); lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); + lua_pushstring(L, taos_errstr(result)); lua_setfield(L, table_index, "error"); return 1; @@ -113,7 +111,6 @@ static int l_query(lua_State *L){ int rows = 0; int num_fields = taos_field_count(result); const TAOS_FIELD *fields = taos_fetch_fields(result); - //char temp[256]; const int affectRows = taos_affected_rows(result); // printf(" affect rows:%d\r\n", affectRows); @@ -122,7 +119,7 @@ static int l_query(lua_State *L){ lua_pushinteger(L, affectRows); lua_setfield(L, table_index, "affected"); lua_newtable(L); - + while ((row = taos_fetch_row(result))) { //printf("row index:%d\n",rows); rows++; @@ -136,17 +133,21 @@ static int l_query(lua_State *L){ } lua_pushstring(L,fields[i].name); - + int32_t* length = taos_fetch_lengths(result); switch (fields[i].type) { + case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_TINYINT: lua_pushinteger(L,*((char *)row[i])); break; + case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_SMALLINT: lua_pushinteger(L,*((short *)row[i])); break; + case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_INT: lua_pushinteger(L,*((int *)row[i])); break; + case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_BIGINT: lua_pushinteger(L,*((int64_t *)row[i])); break; @@ -156,9 +157,11 @@ static int l_query(lua_State *L){ case TSDB_DATA_TYPE_DOUBLE: lua_pushnumber(L,*((double *)row[i])); break; + case TSDB_DATA_TYPE_JSON: case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); + //printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]); + lua_pushlstring(L,(char *)row[i], length[i]); break; case TSDB_DATA_TYPE_TIMESTAMP: lua_pushinteger(L,*((int64_t *)row[i])); @@ -166,6 +169,7 @@ static int l_query(lua_State *L){ case TSDB_DATA_TYPE_BOOL: lua_pushinteger(L,*((char *)row[i])); break; + case TSDB_DATA_TYPE_NULL: default: lua_pushnil(L); break; @@ -235,112 +239,6 @@ static int l_async_query(lua_State *L){ return 1; } -void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){ - struct cb_param* p = (struct cb_param*) param; - TAOS_FIELD *fields = taos_fetch_fields(result); - int numFields = taos_num_fields(result); - - // printf("\nnumfields:%d\n", numFields); - //printf("\n\r-----------------------------------------------------------------------------------\n"); - - lua_State *L = p->state; - lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback); - - lua_newtable(L); - - for (int i = 0; i < numFields; ++i) { - if (row[i] == NULL) { - continue; - } - - lua_pushstring(L,fields[i].name); - - switch (fields[i].type) { - case TSDB_DATA_TYPE_TINYINT: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_SMALLINT: - lua_pushinteger(L,*((short *)row[i])); - break; - case TSDB_DATA_TYPE_INT: - lua_pushinteger(L,*((int *)row[i])); - break; - case TSDB_DATA_TYPE_BIGINT: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_FLOAT: - lua_pushnumber(L,*((float *)row[i])); - break; - case TSDB_DATA_TYPE_DOUBLE: - lua_pushnumber(L,*((double *)row[i])); - break; - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); - break; - case TSDB_DATA_TYPE_TIMESTAMP: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_BOOL: - lua_pushinteger(L,*((char *)row[i])); - break; - default: - lua_pushnil(L); - break; - } - - lua_settable(L, -3); - } - - lua_call(L, 1, 0); - - // printf("-----------------------------------------------------------------------------------\n\r"); -} - -static int l_open_stream(lua_State *L){ - int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - int stime = luaL_checknumber(L,3); - - lua_newtable(L); - int table_index = lua_gettop(L); - - struct cb_param *p = malloc(sizeof(struct cb_param)); - p->state = L; - p->callback=r; - // printf("r:%d, L:%d\n",r,L); - void * s = taos_open_stream(taos,sqlstr,stream_cb,stime,p,NULL); - if (s == NULL) { - printf("failed to open stream, reason:%s\n", taos_errstr(taos)); - free(p); - lua_pushnumber(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,NULL); - lua_setfield(L, table_index, "stream"); - }else{ - // printf("success to open stream\n"); - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - p->stream = s; - lua_pushlightuserdata(L,p); - lua_setfield(L, table_index, "stream");//stream has different content in lua and c. - } - - return 1; -} - -static int l_close_stream(lua_State *L){ - //TODO:get stream and free cb_param - struct cb_param *p = lua_touserdata(L,1); - taos_close_stream(p->stream); - free(p); - return 0; -} static int l_close(lua_State *L){ TAOS *taos= (TAOS*)lua_topointer(L,1); @@ -367,8 +265,6 @@ static const struct luaL_Reg lib[] = { {"query", l_query}, {"query_a",l_async_query}, {"close", l_close}, - {"open_stream", l_open_stream}, - {"close_stream", l_close_stream}, {NULL, NULL} }; From 1e73923c4dd7fb1cbf404574d0bf1f70d6f58e94 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 13:31:08 +0800 Subject: [PATCH 29/48] test: reopen userTest --- .../dnode/mnode/impl/test/user/CMakeLists.txt | 10 +- source/dnode/mnode/impl/test/user/user.cpp | 121 ++---------------- 2 files changed, 17 insertions(+), 114 deletions(-) diff --git a/source/dnode/mnode/impl/test/user/CMakeLists.txt b/source/dnode/mnode/impl/test/user/CMakeLists.txt index c6aeef7221..b39ea0e73f 100644 --- a/source/dnode/mnode/impl/test/user/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/user/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. USER_SRC) -add_executable(mnode_test_user ${USER_SRC}) +aux_source_directory(. MNODE_USER_TEST_SRC) +add_executable(userTest ${MNODE_USER_TEST_SRC}) target_link_libraries( - mnode_test_user + userTest PUBLIC sut ) add_test( - NAME mnode_test_user - COMMAND mnode_test_user + NAME userTest + COMMAND userTest ) diff --git a/source/dnode/mnode/impl/test/user/user.cpp b/source/dnode/mnode/impl/test/user/user.cpp index 97a144fdee..4e7f3c0213 100644 --- a/source/dnode/mnode/impl/test/user/user.cpp +++ b/source/dnode/mnode/impl/test/user/user.cpp @@ -26,21 +26,8 @@ class MndTestUser : public ::testing::Test { Testbase MndTestUser::test; TEST_F(MndTestUser, 01_Show_User) { - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, 10 + VARSTR_HEADER_SIZE, "privilege"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN + VARSTR_HEADER_SIZE, "account"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); - - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("super", 10); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); } TEST_F(MndTestUser, 02_Create_User) { @@ -99,18 +86,8 @@ TEST_F(MndTestUser, 02_Create_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckBinary("u1", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("normal", 10); - CheckBinary("super", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); } { @@ -125,8 +102,7 @@ TEST_F(MndTestUser, 02_Create_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); } @@ -144,18 +120,8 @@ TEST_F(MndTestUser, 02_Create_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("u2", TSDB_USER_LEN); - CheckBinary("super", 10); - CheckBinary("super", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); } { @@ -170,8 +136,7 @@ TEST_F(MndTestUser, 02_Create_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); } } @@ -191,8 +156,7 @@ TEST_F(MndTestUser, 03_Alter_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -437,8 +401,7 @@ TEST_F(MndTestUser, 03_Alter_User) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); } } @@ -497,10 +460,7 @@ TEST_F(MndTestUser, 05_Drop_User) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); } @@ -533,25 +493,9 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 3); - CheckBinary("u1", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("u2", TSDB_USER_LEN); - CheckBinary("normal", 10); - CheckBinary("super", 10); - CheckBinary("normal", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - { SAlterUserReq alterReq = {0}; alterReq.alterType = TSDB_ALTER_USER_PASSWD; @@ -567,25 +511,8 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 3); - - CheckBinary("u1", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("u2", TSDB_USER_LEN); - CheckBinary("normal", 10); - CheckBinary("super", 10); - CheckBinary("normal", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - { SDropUserReq dropReq = {0}; strcpy(dropReq.user, "u1"); @@ -599,37 +526,13 @@ TEST_F(MndTestUser, 06_Create_Drop_Alter_User) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("u2", TSDB_USER_LEN); - CheckBinary("super", 10); - CheckBinary("normal", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - // restart test.Restart(); taosMsleep(1000); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("u2", TSDB_USER_LEN); - CheckBinary("super", 10); - CheckBinary("normal", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); } From 367064591a7401249baf98b4087cf07af5d56c56 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Apr 2022 13:40:50 +0800 Subject: [PATCH 30/48] refactor(driver): refactor c driver and remove redundant codes. --- include/libs/parser/parser.h | 1 + source/client/inc/clientInt.h | 6 +++--- source/client/src/client.c | 0 source/client/src/clientEnv.c | 10 +++++----- source/client/src/clientImpl.c | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 source/client/src/client.c diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index fef624288a..02cd073226 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -57,6 +57,7 @@ typedef struct SQuery { SNode* pRoot; int32_t numOfResCols; SSchema* pResSchema; + int8_t precision; SCmdMsgInfo* pCmdMsg; int32_t msgType; SArray* pDbList; diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 32668356ee..6af1fd6016 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -204,11 +204,11 @@ typedef struct SRequestObj { uint64_t requestId; int32_t type; // request type STscObj* pTscObj; - char* pDb; + char* pDb; // current database string char* sqlstr; // sql string int32_t sqlLen; int64_t self; - char* msgBuf; + char* msgBuf; // error msg buffer int32_t code; SArray* dbList; SArray* tableList; @@ -276,8 +276,8 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj* void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); void doSetOneRowPtr(SReqResultInfo* pResultInfo); -int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows, bool convertUcs4); void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols); +void setResPrecision(SReqResultInfo* pResInfo, int32_t precision); int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4); // --- heartbeat diff --git a/source/client/src/client.c b/source/client/src/client.c deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index a258fd305e..8efee9bffb 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -27,10 +27,10 @@ #include "ttime.h" #define TSC_VAR_NOT_RELEASE 1 -#define TSC_VAR_RELEASED 0 +#define TSC_VAR_RELEASED 0 SAppInfo appInfo; -int32_t clientReqRefPool = -1; +int32_t clientReqRefPool = -1; int32_t clientConnRefPool = -1; static TdThreadOnce tscinit = PTHREAD_ONCE_INIT; @@ -48,8 +48,8 @@ static void registerRequest(SRequestObj *pRequest) { if (pTscObj->pAppInfo) { SInstanceSummary *pSummary = &pTscObj->pAppInfo->summary; - int32_t total = atomic_add_fetch_64(&pSummary->totalRequests, 1); - int32_t currentInst = atomic_add_fetch_64(&pSummary->currentRequests, 1); + int32_t total = atomic_add_fetch_64((int64_t*)&pSummary->totalRequests, 1); + int32_t currentInst = atomic_add_fetch_64((int64_t*)&pSummary->currentRequests, 1); tscDebug("0x%" PRIx64 " new Request from connObj:0x%" PRIx64 ", current:%d, app current:%d, total:%d, reqId:0x%" PRIx64, pRequest->self, pRequest->pTscObj->id, num, currentInst, total, pRequest->requestId); @@ -62,7 +62,7 @@ static void deregisterRequest(SRequestObj *pRequest) { STscObj * pTscObj = pRequest->pTscObj; SInstanceSummary *pActivity = &pTscObj->pAppInfo->summary; - int32_t currentInst = atomic_sub_fetch_64(&pActivity->currentRequests, 1); + int32_t currentInst = atomic_sub_fetch_64((int64_t*)&pActivity->currentRequests, 1); int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1); int64_t duration = taosGetTimestampUs() - pRequest->metric.start; diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index b3615c208c..85e3979477 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -229,7 +229,7 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra } void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols) { - assert(pSchema != NULL && numOfCols > 0); + ASSERT(pSchema != NULL && numOfCols > 0); pResInfo->numOfCols = numOfCols; pResInfo->fields = taosMemoryCalloc(numOfCols, sizeof(TAOS_FIELD)); From eaa6cd56a68e91a28530a9e105553a2c82aff70c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Apr 2022 13:42:03 +0800 Subject: [PATCH 31/48] enh(query): add an new internal api to extract query result timestamp precision before the query response received from dnode. --- source/client/src/clientImpl.c | 9 +++++++++ source/libs/parser/src/parTranslater.c | 14 ++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 85e3979477..a64fa13dd8 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -175,6 +175,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery) { if (TSDB_CODE_SUCCESS == code) { if ((*pQuery)->haveResultSet) { setResSchemaInfo(&pRequest->body.resInfo, (*pQuery)->pResSchema, (*pQuery)->numOfResCols); + setResPrecision(&pRequest->body.resInfo, (*pQuery)->precision); } TSWAP(pRequest->dbList, (*pQuery)->pDbList, SArray*); @@ -253,6 +254,14 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t } } +void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) { + if (precision != TSDB_TIME_PRECISION_MILLI && precision != TSDB_TIME_PRECISION_MICRO && precision != TSDB_TIME_PRECISION_NANO) { + return; + } + + pResInfo->precision = precision; +} + int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) { void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 250c6c2fd1..f89f5fbb22 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2198,6 +2198,10 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu return TSDB_CODE_SUCCESS; } +static int8_t extractResultTsPrecision(const SSelectStmt* pSelect) { + return pSelect->precision; +} + static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema) { *numOfCols = 1; *pSchema = taosMemoryCalloc((*numOfCols), sizeof(SSchema)); @@ -2219,19 +2223,19 @@ static int32_t extractDescribeResultSchema(int32_t* numOfCols, SSchema** pSchema (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; (*pSchema)[0].bytes = DESCRIBE_RESULT_FIELD_LEN; - strcpy((*pSchema)[0].name, "Field"); + strcpy((*pSchema)[0].name, "field"); (*pSchema)[1].type = TSDB_DATA_TYPE_BINARY; (*pSchema)[1].bytes = DESCRIBE_RESULT_TYPE_LEN; - strcpy((*pSchema)[1].name, "Type"); + strcpy((*pSchema)[1].name, "type"); (*pSchema)[2].type = TSDB_DATA_TYPE_INT; (*pSchema)[2].bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes; - strcpy((*pSchema)[2].name, "Length"); + strcpy((*pSchema)[2].name, "length"); (*pSchema)[3].type = TSDB_DATA_TYPE_BINARY; (*pSchema)[3].bytes = DESCRIBE_RESULT_NOTE_LEN; - strcpy((*pSchema)[3].name, "Note"); + strcpy((*pSchema)[3].name, "note"); return TSDB_CODE_SUCCESS; } @@ -2912,6 +2916,8 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) { if (TSDB_CODE_SUCCESS != extractResultSchema(pQuery->pRoot, &pQuery->numOfResCols, &pQuery->pResSchema)) { return TSDB_CODE_OUT_OF_MEMORY; } + + pQuery->precision = extractResultTsPrecision((SSelectStmt*) pQuery->pRoot); } if (NULL != pCxt->pDbs) { From 1592ea69d5ab71f8cfc303359078dba429b526a1 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 15 Apr 2022 05:47:57 +0000 Subject: [PATCH 32/48] refact vnod --- source/dnode/vnode/src/inc/vnd.h | 6 +- source/dnode/vnode/src/inc/vnodeInt.h | 6 ++ source/dnode/vnode/src/vnd/vnodeCfg.c | 84 ----------------------- source/dnode/vnode/src/vnd/vnodeCommit.c | 87 +++++++++++++++++++++++- source/dnode/vnode/src/vnd/vnodeOpen.c | 13 +++- 5 files changed, 106 insertions(+), 90 deletions(-) diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 55b69a9e6e..913fec64ed 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -31,8 +31,6 @@ extern "C" { // clang-format on // vnodeCfg ==================== -int vnodeSaveCfg(const char* dir, const SVnodeCfg* pCfg); -int vnodeCommitCfg(const char* dir); // vnodeModule ==================== int vnodeScheduleTask(int (*execute)(void*), void* arg); @@ -42,6 +40,10 @@ int vnodeQueryOpen(SVnode* pVnode); void vnodeQueryClose(SVnode* pVnode); int vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg); +// vnodeCommit ==================== +int vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg); +int vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo); + #if 1 // SVBufPool int vnodeOpenBufPool(SVnode* pVnode); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index f988df01cb..b0b87665ed 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -43,6 +43,7 @@ extern "C" { #endif +typedef struct SVnodeInfo SVnodeInfo; typedef struct SMeta SMeta; typedef struct STsdb STsdb; typedef struct STQ STQ; @@ -72,6 +73,11 @@ struct SVState { int64_t applied; }; +struct SVnodeInfo { + SVnodeCfg config; + SVState state; +}; + struct SVnode { int32_t vgId; char* path; diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index 8da9950aa7..34b983c20c 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -15,12 +15,6 @@ #include "vnodeInt.h" -#define VND_INFO_FNAME "vnode.json" -#define VND_INFO_FNAME_TMP "vnode_tmp.json" - -static int vnodeEncodeInfo(const SVnodeCfg *pCfg, uint8_t **ppData, int *len); -static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeCfg *pCfg); - const SVnodeCfg vnodeCfgDefault = { .wsize = 96 * 1024 * 1024, .ssize = 1 * 1024 * 1024, .lsize = 1024, .walCfg = {.level = TAOS_WAL_WRITE}}; @@ -29,84 +23,6 @@ int vnodeCheckCfg(const SVnodeCfg *pCfg) { return 0; } -int vnodeSaveCfg(const char *dir, const SVnodeCfg *pCfg) { - char fname[TSDB_FILENAME_LEN]; - TdFilePtr pFile; - uint8_t *data; - int len; - - snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP); - - // encode info - data = NULL; - len = 0; - - if (vnodeEncodeInfo(pCfg, &data, &len) < 0) { - return -1; - } - - // save info to a vnode_tmp.json - pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); - if (pFile == NULL) { - terrno = TAOS_SYSTEM_ERROR(errno); - return -1; - } - - if (taosWriteFile(pFile, data, len) < 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - goto _err; - } - - if (taosFsyncFile(pFile) < 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - goto _err; - } - - taosCloseFile(&pFile); - - // free info binary - taosMemoryFree(data); - - vInfo("vgId: %d vnode info is saved, fname: %s", pCfg->vgId, fname); - - return 0; - -_err: - taosCloseFile(&pFile); - taosMemoryFree(data); - return -1; -} - -int vnodeCommitCfg(const char *dir) { - char fname[TSDB_FILENAME_LEN]; - char tfname[TSDB_FILENAME_LEN]; - - snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME); - snprintf(tfname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP); - - if (taosRenameFile(tfname, fname) < 0) { - terrno = TAOS_SYSTEM_ERROR(errno); - return -1; - } - - return 0; -} - -int vnodeLoadCfg(const char *dir) { - // TODO - return 0; -} - -static int vnodeEncodeInfo(const SVnodeCfg *pCfg, uint8_t **ppData, int *len) { - // TODO - return 0; -} - -static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeCfg *pCfg) { - // TODO - return 0; -} - #if 1 //====================================================================== void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) { memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg)); diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index b4c3725a5e..fc74ee9253 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -15,11 +15,86 @@ #include "vnodeInt.h" +#define VND_INFO_FNAME "vnode.json" +#define VND_INFO_FNAME_TMP "vnode_tmp.json" + +static int vnodeEncodeInfo(const SVnodeInfo *pInfo, uint8_t **ppData, int *len); +static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeInfo *pInfo); static int vnodeStartCommit(SVnode *pVnode); static int vnodeEndCommit(SVnode *pVnode); static int vnodeCommit(void *arg); static void vnodeWaitCommit(SVnode *pVnode); +int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) { + char fname[TSDB_FILENAME_LEN]; + TdFilePtr pFile; + uint8_t *data; + int len; + + snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP); + + // encode info + data = NULL; + len = 0; + + if (vnodeEncodeInfo(pInfo, &data, &len) < 0) { + return -1; + } + + // save info to a vnode_tmp.json + pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); + if (pFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + if (taosWriteFile(pFile, data, len) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + if (taosFsyncFile(pFile) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + taosCloseFile(&pFile); + + // free info binary + taosMemoryFree(data); + + vInfo("vgId: %d vnode info is saved, fname: %s", pInfo->config.vgId, fname); + + return 0; + +_err: + taosCloseFile(&pFile); + taosMemoryFree(data); + return -1; +} + +int vnodeCommitInfo(const char *dir, const SVnodeInfo *pInfo) { + char fname[TSDB_FILENAME_LEN]; + char tfname[TSDB_FILENAME_LEN]; + + snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME); + snprintf(tfname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP); + + if (taosRenameFile(tfname, fname) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + vInfo("vgId: %d vnode info is committed", pInfo->config.vgId); + + return 0; +} + +int vnodeLoadInfo(const char *dir) { + // TODO + return 0; +} + int vnodeAsyncCommit(SVnode *pVnode) { vnodeWaitCommit(pVnode); @@ -60,4 +135,14 @@ static int vnodeEndCommit(SVnode *pVnode) { return 0; } -static FORCE_INLINE void vnodeWaitCommit(SVnode *pVnode) { tsem_wait(&pVnode->canCommit); } \ No newline at end of file +static FORCE_INLINE void vnodeWaitCommit(SVnode *pVnode) { tsem_wait(&pVnode->canCommit); } + +static int vnodeEncodeInfo(const SVnodeInfo *pInfo, uint8_t **ppData, int *len) { + // TODO + return 0; +} + +static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeInfo *pInfo) { + // TODO + return 0; +} diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 6729f7ce0c..5fa14f6018 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -21,7 +21,8 @@ static int vnodeOpenImpl(SVnode *pVnode); static void vnodeCloseImpl(SVnode *pVnode); int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { - char dir[TSDB_FILENAME_LEN]; + SVnodeInfo info = {0}; + char dir[TSDB_FILENAME_LEN]; // TODO: check if directory exists @@ -32,9 +33,15 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { } // create vnode env - tfsMkdir(pTfs, path); + if (tfsMkdir(pTfs, path) < 0) { + vError("vgId: %d failed to create vnode since: %s", pCfg->vgId, tstrerror(terrno)); + return -1; + } + snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path); - if (vnodeSaveCfg(dir, pCfg) < 0 || vnodeCommitCfg(dir) < 0) { + info.config = *pCfg; + + if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) { vError("vgId: %d failed to save vnode config since %s", pCfg->vgId, tstrerror(terrno)); return -1; } From 2b7ec5743cc2ce3759b576b978bf0f61169bd42d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 13:57:32 +0800 Subject: [PATCH 33/48] test: reopen transTest --- source/dnode/mnode/impl/inc/mndDb.h | 2 +- source/dnode/mnode/impl/src/mndDb.c | 4 +- source/dnode/mnode/impl/src/mndShow.c | 9 ++- source/dnode/mnode/impl/src/mndTrans.c | 50 ++++++------- .../mnode/impl/test/trans/CMakeLists.txt | 10 +-- source/dnode/mnode/impl/test/trans/trans.cpp | 75 ++++--------------- 6 files changed, 56 insertions(+), 94 deletions(-) diff --git a/source/dnode/mnode/impl/inc/mndDb.h b/source/dnode/mnode/impl/inc/mndDb.h index c0b25d74d1..146c6e2523 100644 --- a/source/dnode/mnode/impl/inc/mndDb.h +++ b/source/dnode/mnode/impl/inc/mndDb.h @@ -27,7 +27,7 @@ void mndCleanupDb(SMnode *pMnode); SDbObj *mndAcquireDb(SMnode *pMnode, const char *db); void mndReleaseDb(SMnode *pMnode, SDbObj *pDb); int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen); -char *mnGetDbStr(char *src); +char *mndGetDbStr(char *src); int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq); #ifdef __cplusplus diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 3db4e9870e..2ea95f8f8d 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1340,7 +1340,7 @@ SYNC_DB_OVER: return code; } -char *mnGetDbStr(char *src) { +char *mndGetDbStr(char *src) { char *pos = strstr(src, TS_PATH_DELIMITER); if (pos != NULL) ++pos; @@ -1355,7 +1355,7 @@ static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, in int32_t cols = 0; char* buf = taosMemoryMalloc(pShow->bytes[cols]); - char *name = mnGetDbStr(pDb->name); + char *name = mndGetDbStr(pDb->name); if (name != NULL) { STR_WITH_MAXSIZE_TO_VARSTR(buf, name, pShow->bytes[cols]); } else { diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 617cebf61d..1a14c94640 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -131,6 +131,13 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { req.type = retrieveReq.type; strncpy(req.db, retrieveReq.db, tListLen(req.db)); + STableMetaRsp *pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb) + 1); + if (pMeta == NULL) { + terrno = TSDB_CODE_MND_INVALID_INFOS_TBL; + mError("failed to process show-retrieve req:%p since %s", pShow, terrstr()); + return -1; + } + pShow = mndCreateShowObj(pMnode, &req); if (pShow == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -138,7 +145,7 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) { return -1; } - pShow->pMeta = (STableMetaRsp *)taosHashGet(pMnode->infosMeta, retrieveReq.tb, strlen(retrieveReq.tb) + 1); + pShow->pMeta = pMeta; pShow->numOfColumns = pShow->pMeta->numOfColumns; int32_t offset = 0; diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 537ddc03c3..59fe7d16b9 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -58,7 +58,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans); static int32_t mndProcessTransReq(SNodeMsg *pReq); static int32_t mndProcessKillTransReq(SNodeMsg *pReq); -static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows); +static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextTrans(SMnode *pMnode, void *pIter); int32_t mndInitTrans(SMnode *pMnode) { @@ -73,7 +73,7 @@ int32_t mndInitTrans(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_MND_TRANS_TIMER, mndProcessTransReq); mndSetMsgHandle(pMnode, TDMT_MND_KILL_TRANS, mndProcessKillTransReq); -// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans); + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndCancelGetNextTrans); return sdbSetTable(pMnode->pSdb, table); } @@ -1259,7 +1259,7 @@ void mndTransPullup(SMnode *pMnode) { sdbWriteFile(pMnode->pSdb); } -static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int32_t rows) { +static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->pNode; SSdb *pSdb = pMnode->pSdb; int32_t numOfRows = 0; @@ -1273,34 +1273,34 @@ static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int cols = 0; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = pTrans->id; - cols++; + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->id, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = pTrans->createdTime; - cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_TO_VARSTR(pWrite, mndTransStr(pTrans->stage)); - cols++; + char stage[TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(stage, mndTransStr(pTrans->stage), pShow->bytes[cols]); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)stage, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - char *name = mnGetDbStr(pTrans->dbname); - STR_WITH_MAXSIZE_TO_VARSTR(pWrite, name, pShow->bytes[cols]); - cols++; + char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->bytes[cols]); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)dbname, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_TO_VARSTR(pWrite, mndTransType(pTrans->transType)); - cols++; + char transType[TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndTransType(pTrans->transType), pShow->bytes[cols]); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)transType, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int64_t *)pWrite = pTrans->lastExecTime; - cols++; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false); - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - STR_TO_VARSTR(pWrite, pTrans->lastError); - cols++; + char lastError[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(dbname, pTrans->lastError, pShow->bytes[cols]); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)lastError, false); numOfRows++; sdbRelease(pSdb, pTrans); diff --git a/source/dnode/mnode/impl/test/trans/CMakeLists.txt b/source/dnode/mnode/impl/test/trans/CMakeLists.txt index d7c9756794..fa0ef9f263 100644 --- a/source/dnode/mnode/impl/test/trans/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/trans/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. TRANS_SRC) -add_executable(mnode_test_trans ${TRANS_SRC}) +aux_source_directory(. MNODE_TRANS_TEST_SRC) +add_executable(transTest ${MNODE_TRANS_TEST_SRC}) target_link_libraries( - mnode_test_trans + transTest PUBLIC sut ) add_test( - NAME mnode_test_trans - COMMAND mnode_test_trans + NAME transTest + COMMAND transTest ) diff --git a/source/dnode/mnode/impl/test/trans/trans.cpp b/source/dnode/mnode/impl/test/trans/trans.cpp index 560b30d13c..bcf6fe8536 100644 --- a/source/dnode/mnode/impl/test/trans/trans.cpp +++ b/source/dnode/mnode/impl/test/trans/trans.cpp @@ -26,11 +26,11 @@ class MndTestTrans : public ::testing::Test { } static void KillThenRestartServer() { - char file[PATH_MAX] = "/tmp/mnode_test_trans/mnode/data/sdb.data"; + char file[PATH_MAX] = "/tmp/mnode_test_trans/mnode/data/sdb.data"; TdFilePtr pFile = taosOpenFile(file, TD_FILE_READ); - int32_t size = 3 * 1024 * 1024; - void* buffer = taosMemoryMalloc(size); - int32_t readLen = taosReadFile(pFile, buffer, size); + int32_t size = 3 * 1024 * 1024; + void* buffer = taosMemoryMalloc(size); + int32_t readLen = taosReadFile(pFile, buffer, size); if (readLen < 0 || readLen == size) { ASSERT(1); } @@ -65,18 +65,7 @@ TestServer MndTestTrans::server2; TEST_F(MndTestTrans, 00_Create_User_Crash) { { - test.SendShowMetaReq(TSDB_MGMT_TABLE_TRANS, ""); - CHECK_META("show trans", 7); - - CHECK_SCHEMA(0, TSDB_DATA_TYPE_INT, 4, "id"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_BINARY, TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE, "stage"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "db"); - CHECK_SCHEMA(4, TSDB_DATA_TYPE_BINARY, TSDB_TRANS_TYPE_LEN + VARSTR_HEADER_SIZE, "type"); - CHECK_SCHEMA(5, TSDB_DATA_TYPE_TIMESTAMP, 8, "last_exec_time"); - CHECK_SCHEMA(6, TSDB_DATA_TYPE_BINARY, TSDB_TRANS_ERROR_LEN - 1 + VARSTR_HEADER_SIZE, "last_error"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -109,26 +98,13 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) { ASSERT_EQ(pRsp->code, 0); } - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); KillThenRestartServer(); - test.SendShowMetaReq(TSDB_MGMT_TABLE_USER, ""); - CHECK_META("show users", 4); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 2); - - CheckBinary("u1", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("normal", 10); - CheckBinary("super", 10); - CheckTimestamp(); - CheckTimestamp(); - CheckBinary("root", TSDB_USER_LEN); - CheckBinary("root", TSDB_USER_LEN); } TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) { @@ -144,9 +120,7 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - CHECK_META("show qnodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); } @@ -163,9 +137,7 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_QNODE_ALREADY_EXIST); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - CHECK_META("show qnodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 1); } } @@ -185,8 +157,7 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { ASSERT_EQ(pRsp->code, 0); taosMsleep(1300); - test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_DNODE, "dnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } @@ -208,18 +179,8 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { { // show trans - test.SendShowMetaReq(TSDB_MGMT_TABLE_TRANS, ""); - CHECK_META("show trans", 7); - test.SendShowRetrieveReq(); - + test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", ""); EXPECT_EQ(test.GetShowRows(), 1); - CheckInt32(4); - CheckTimestamp(); - CheckBinary("undoAction", TSDB_TRANS_STAGE_LEN); - CheckBinary("", TSDB_DB_NAME_LEN - 1); - CheckBinary("create-qnode", TSDB_TRANS_TYPE_LEN); - CheckTimestamp(); - CheckBinary("Unable to establish connection", TSDB_TRANS_ERROR_LEN - 1); } // kill trans @@ -238,8 +199,7 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { // show trans { - test.SendShowMetaReq(TSDB_MGMT_TABLE_TRANS, ""); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_TRANS, "trans", ""); EXPECT_EQ(test.GetShowRows(), 0); } @@ -258,11 +218,9 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_NETWORK_UNAVAIL); } - uInfo("======== kill and restart server") - KillThenRestartServer(); + uInfo("======== kill and restart server") KillThenRestartServer(); - uInfo("======== server2 start") - server2.DoStart(); + uInfo("======== server2 start") server2.DoStart(); uInfo("======== server2 started") @@ -286,14 +244,11 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) { ASSERT_NE(retry, retryMax); - test.SendShowMetaReq(TSDB_MGMT_TABLE_QNODE, ""); - CHECK_META("show qnodes", 3); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_QNODE, "qnodes", ""); EXPECT_EQ(test.GetShowRows(), 2); } } - // create db // partial create stb // drop db failed From 81016a98cec04b8d61358455a1b7a9c74f2d88aa Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 13:58:08 +0800 Subject: [PATCH 34/48] test: reopen topicTest --- source/dnode/mnode/impl/test/topic/CMakeLists.txt | 10 +++++----- source/dnode/mnode/impl/test/topic/topic.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/dnode/mnode/impl/test/topic/CMakeLists.txt b/source/dnode/mnode/impl/test/topic/CMakeLists.txt index 63a77713d6..076228ec9d 100644 --- a/source/dnode/mnode/impl/test/topic/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/topic/CMakeLists.txt @@ -1,11 +1,11 @@ -aux_source_directory(. TOPIC_SRC) -add_executable(mnode_test_topic ${TOPIC_SRC}) +aux_source_directory(. MNODE_TOPIC_TEST_SRC) +add_executable(topicTest ${MNODE_TOPIC_TEST_SRC}) target_link_libraries( - mnode_test_topic + topicTest PUBLIC sut ) add_test( - NAME mnode_test_topic - COMMAND mnode_test_topic + NAME topicTest + COMMAND topicTest ) diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index 2111d61e3f..ee47a3c8b4 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -101,7 +101,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { ASSERT_EQ(pRsp->code, 0); } - { test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, ""); } + { test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, ""); } { int32_t contLen = 0; @@ -128,7 +128,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { } { - test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname); CHECK_META("show topics", 3); CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name"); @@ -145,7 +145,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { // restart test.Restart(); - test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); @@ -169,7 +169,7 @@ TEST_F(MndTestTopic, 01_Create_Topic) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, TSDB_CODE_MND_TOPIC_NOT_EXIST); - test.SendShowMetaReq(TSDB_MGMT_TABLE_TOPICS, dbname); + test.SendShowReq(TSDB_MGMT_TABLE_TOPICS, dbname); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); } From ef1a0683385bc4173c3089d936ac2caf3017db8e Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 14:00:59 +0800 Subject: [PATCH 35/48] test: reopen stbTest --- .../dnode/mnode/impl/test/stb/CMakeLists.txt | 8 +- source/dnode/mnode/impl/test/stb/stb.cpp | 78 +++---------------- 2 files changed, 15 insertions(+), 71 deletions(-) diff --git a/source/dnode/mnode/impl/test/stb/CMakeLists.txt b/source/dnode/mnode/impl/test/stb/CMakeLists.txt index 70e20d3411..d2fe387997 100644 --- a/source/dnode/mnode/impl/test/stb/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/stb/CMakeLists.txt @@ -5,7 +5,7 @@ target_link_libraries( PUBLIC sut ) -#add_test( -# NAME mnode_test_stb -# COMMAND mnode_test_stb -#) +add_test( + NAME stbTest + COMMAND stbTest +) diff --git a/source/dnode/mnode/impl/test/stb/stb.cpp b/source/dnode/mnode/impl/test/stb/stb.cpp index f45c0795cd..f8f8799c9f 100644 --- a/source/dnode/mnode/impl/test/stb/stb.cpp +++ b/source/dnode/mnode/impl/test/stb/stb.cpp @@ -43,7 +43,7 @@ void* MndTestStb::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; + createReq.daysPerFile = 1000; createReq.daysToKeep0 = 3650; createReq.daysToKeep1 = 3650; createReq.daysToKeep2 = 3650; @@ -314,19 +314,8 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { } { - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - CHECK_META("show stables", 4); - CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE, "name"); - CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); - CHECK_SCHEMA(2, TSDB_DATA_TYPE_INT, 4, "columns"); - CHECK_SCHEMA(3, TSDB_DATA_TYPE_INT, 4, "tags"); - - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } // ----- meta ------ @@ -407,15 +396,8 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { test.Restart(); { - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - CHECK_META("show stables", 4); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } { @@ -432,9 +414,7 @@ TEST_F(MndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) { } { - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - CHECK_META("show stables", 4); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 0); } @@ -496,13 +476,7 @@ TEST_F(MndTestStb, 02_Alter_Stb_AddTag) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); - EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(4); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); } { @@ -542,13 +516,8 @@ TEST_F(MndTestStb, 03_Alter_Stb_DropTag) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(2); } { @@ -611,13 +580,8 @@ TEST_F(MndTestStb, 04_Alter_Stb_AlterTagName) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } { @@ -668,13 +632,8 @@ TEST_F(MndTestStb, 05_Alter_Stb_AlterTagBytes) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } { @@ -734,13 +693,8 @@ TEST_F(MndTestStb, 06_Alter_Stb_AddColumn) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(3); - CheckInt32(3); } { @@ -799,13 +753,8 @@ TEST_F(MndTestStb, 07_Alter_Stb_DropColumn) { ASSERT_NE(pRsp, nullptr); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } { @@ -862,13 +811,8 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_STB, pReq, contLen); ASSERT_EQ(pRsp->code, 0); - test.SendShowMetaReq(TSDB_MGMT_TABLE_STB, dbname); - test.SendShowRetrieveReq(); + test.SendShowReq(TSDB_MGMT_TABLE_STB, "user_stables", dbname); EXPECT_EQ(test.GetShowRows(), 1); - CheckBinary("stb", TSDB_TABLE_NAME_LEN); - CheckTimestamp(); - CheckInt32(2); - CheckInt32(3); } { From 684db8eba818e8f735d7cf1b8ab0193a1982dbe6 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Apr 2022 14:01:43 +0800 Subject: [PATCH 36/48] refactor(query): refactor some variable name and macro definitions. --- include/libs/function/function.h | 9 ++--- source/client/inc/clientInt.h | 8 ++++ source/libs/executor/src/executorimpl.c | 53 ++++++++----------------- source/libs/executor/src/scanoperator.c | 6 +-- source/libs/function/src/taggfunction.c | 38 +++++++++--------- 5 files changed, 50 insertions(+), 64 deletions(-) diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 9fa89f0415..1303a1fb6a 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -110,7 +110,6 @@ typedef struct SFileBlockInfo { #define FUNCTION_COV 38 typedef struct SResultRowEntryInfo { -// int8_t hasResult:6; // result generated, not NULL value bool initialized:1; // output buffer has been initialized bool complete:1; // query has completed uint8_t isNullRes:6; // the result is null @@ -119,10 +118,10 @@ typedef struct SResultRowEntryInfo { // determine the real data need to calculated the result enum { - BLK_DATA_NO_NEEDED = 0x0, - BLK_DATA_STATIS_NEEDED = 0x1, - BLK_DATA_ALL_NEEDED = 0x3, - BLK_DATA_DISCARD = 0x4, // discard current data block since it is not qualified for filter + BLK_DATA_NOT_LOAD = 0x0, + BLK_DATA_SMA_LOAD = 0x1, + BLK_DATA_DATA_LOAD = 0x3, + BLK_DATA_FILTEROUT = 0x4, // discard current data block since it is not qualified for filter }; enum { diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 5f99af5460..772ff5e69a 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -46,6 +46,14 @@ extern "C" { #define ERROR_MSG_BUF_DEFAULT_SIZE 512 #define HEARTBEAT_INTERVAL 1500 // ms +enum { + RES_TYPE__QUERY = 1, + RES_TYPE__TMQ, +}; + +#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) +#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) + typedef struct SAppInstInfo SAppInstInfo; typedef struct { diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 20b7169895..c911aef45f 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -2004,7 +2004,7 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) { bool hasFirstLastFunc = false; bool hasOtherFunc = false; - if (status == BLK_DATA_ALL_NEEDED || status == BLK_DATA_DISCARD) { + if (status == BLK_DATA_DATA_LOAD || status == BLK_DATA_FILTEROUT) { return status; } @@ -2023,11 +2023,11 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) { } } - if (hasFirstLastFunc && status == BLK_DATA_NO_NEEDED) { + if (hasFirstLastFunc && status == BLK_DATA_NOT_LOAD) { if (!hasOtherFunc) { - return BLK_DATA_DISCARD; + return BLK_DATA_FILTEROUT; } else { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } } @@ -2360,7 +2360,7 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, SVarian static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock) { SqlFunctionCtx* pCtx = pTableScanInfo->pCtx; - uint32_t status = BLK_DATA_NO_NEEDED; + uint32_t status = BLK_DATA_NOT_LOAD; int32_t numOfOutput = pTableScanInfo->numOfOutput; for (int32_t i = 0; i < numOfOutput; ++i) { @@ -2369,11 +2369,11 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData // group by + first/last should not apply the first/last block filter if (functionId < 0) { - status |= BLK_DATA_ALL_NEEDED; + status |= BLK_DATA_DATA_LOAD; return status; } else { // status |= aAggs[functionId].dataReqFunc(&pTableScanInfo->pCtx[i], &pBlock->info.window, colId); - // if ((status & BLK_DATA_ALL_NEEDED) == BLK_DATA_ALL_NEEDED) { + // if ((status & BLK_DATA_DATA_LOAD) == BLK_DATA_DATA_LOAD) { // return status; // } } @@ -2384,7 +2384,7 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) { - *status = BLK_DATA_NO_NEEDED; + *status = BLK_DATA_NOT_LOAD; pBlock->pDataBlock = NULL; pBlock->pBlockAgg = NULL; @@ -2397,36 +2397,15 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc pCost->totalBlocks += 1; pCost->totalRows += pBlock->info.rows; #if 0 - if (pRuntimeEnv->pTsBuf != NULL) { - (*status) = BLK_DATA_ALL_NEEDED; - - if (pQueryAttr->stableQuery) { // todo refactor - SExprInfo* pExprInfo = &pTableScanInfo->pExpr[0]; - int16_t tagId = (int16_t)pExprInfo->base.param[0].i; - SColumnInfo* pColInfo = doGetTagColumnInfoById(pQueryAttr->tagColList, pQueryAttr->numOfTags, tagId); - - // compare tag first - SVariant t = {0}; - doSetTagValueInParam(pRuntimeEnv->current->pTable, tagId, &t, pColInfo->type, pColInfo->bytes); - setTimestampListJoinInfo(pRuntimeEnv, &t, pRuntimeEnv->current); - - STSElem elem = tsBufGetElem(pRuntimeEnv->pTsBuf); - if (!tsBufIsValidElem(&elem) || (tsBufIsValidElem(&elem) && (taosVariantCompare(&t, elem.tag) != 0))) { - (*status) = BLK_DATA_DISCARD; - return TSDB_CODE_SUCCESS; - } - } - } - // Calculate all time windows that are overlapping or contain current data block. // If current data block is contained by all possible time window, do not load current data block. if (/*pQueryAttr->pFilters || */pQueryAttr->groupbyColumn || pQueryAttr->sw.gap > 0 || (QUERY_IS_INTERVAL_QUERY(pQueryAttr) && overlapWithTimeWindow(pTaskInfo, &pBlock->info))) { - (*status) = BLK_DATA_ALL_NEEDED; + (*status) = BLK_DATA_DATA_LOAD; } // check if this data block is required to load - if ((*status) != BLK_DATA_ALL_NEEDED) { + if ((*status) != BLK_DATA_DATA_LOAD) { bool needFilter = true; // the pCtx[i] result is belonged to previous time window since the outputBuf has not been set yet, @@ -2458,18 +2437,18 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc if (needFilter) { (*status) = doFilterByBlockTimeWindow(pTableScanInfo, pBlock); } else { - (*status) = BLK_DATA_ALL_NEEDED; + (*status) = BLK_DATA_DATA_LOAD; } } SDataBlockInfo* pBlockInfo = &pBlock->info; // *status = updateBlockLoadStatus(pRuntimeEnv->pQueryAttr, *status); - if ((*status) == BLK_DATA_NO_NEEDED || (*status) == BLK_DATA_DISCARD) { + if ((*status) == BLK_DATA_NOT_LOAD || (*status) == BLK_DATA_FILTEROUT) { //qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, // pBlockInfo->window.ekey, pBlockInfo->rows); pCost->discardBlocks += 1; - } else if ((*status) == BLK_DATA_STATIS_NEEDED) { + } else if ((*status) == BLK_DATA_SMA_LOAD) { // this function never returns error? pCost->loadBlockStatis += 1; // tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg); @@ -2479,7 +2458,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc pCost->totalCheckedRows += pBlock->info.rows; } } else { - assert((*status) == BLK_DATA_ALL_NEEDED); + assert((*status) == BLK_DATA_DATA_LOAD); // load the data block statistics to perform further filter pCost->loadBlockStatis += 1; @@ -2511,7 +2490,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc pCost->discardBlocks += 1; //qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, // pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); - (*status) = BLK_DATA_DISCARD; + (*status) = BLK_DATA_FILTEROUT; return TSDB_CODE_SUCCESS; } } @@ -2523,7 +2502,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc // pCost->discardBlocks += 1; // qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, // pBlockInfo->window.ekey, pBlockInfo->rows); -// (*status) = BLK_DATA_DISCARD; +// (*status) = BLK_DATA_FILTEROUT; // return TSDB_CODE_SUCCESS; // } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 0286b6e6e9..901bfde6a4 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -73,7 +73,7 @@ int32_t loadDataBlock(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, pCost->totalCheckedRows += pBlock->info.rows; pCost->loadBlocks += 1; - *status = BLK_DATA_ALL_NEEDED; + *status = BLK_DATA_DATA_LOAD; SArray* pCols = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL); if (pCols == NULL) { @@ -138,7 +138,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) { // } // this function never returns error? - uint32_t status = BLK_DATA_ALL_NEEDED; + uint32_t status = BLK_DATA_DATA_LOAD; int32_t code = loadDataBlock(pTaskInfo, pTableScanInfo, pBlock, &status); // int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { @@ -146,7 +146,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) { } // current block is ignored according to filter result by block statistics data, continue load the next block - if (status == BLK_DATA_DISCARD || pBlock->info.rows == 0) { + if (status == BLK_DATA_FILTEROUT || pBlock->info.rows == 0) { continue; } diff --git a/source/libs/function/src/taggfunction.c b/source/libs/function/src/taggfunction.c index 60566d00d8..e001ef4071 100644 --- a/source/libs/function/src/taggfunction.c +++ b/source/libs/function/src/taggfunction.c @@ -557,14 +557,14 @@ static void count_func_merge(SqlFunctionCtx *pCtx) { */ int32_t countRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { if (colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } else { - return BLK_DATA_STATIS_NEEDED; + return BLK_DATA_SMA_LOAD; } } int32_t noDataRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } #define LIST_ADD_N_DOUBLE_FLOAT(x, ctx, p, t, numOfElem, tsdbType) \ do { \ @@ -743,76 +743,76 @@ static void sum_func_merge(SqlFunctionCtx *pCtx) { } static int32_t statisRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { - return BLK_DATA_STATIS_NEEDED; + return BLK_DATA_SMA_LOAD; } static int32_t dataBlockRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } // todo: if column in current data block are null, opt for this case static int32_t firstFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { if (pCtx->order == TSDB_ORDER_DESC) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } // no result for first query, data block is required if (GET_RES_INFO(pCtx) == NULL || GET_RES_INFO(pCtx)->numOfRes <= 0) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } else { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } } static int32_t lastFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { if (pCtx->order != pCtx->param[0].i) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } if (GET_RES_INFO(pCtx) == NULL || GET_RES_INFO(pCtx)->numOfRes <= 0) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } else { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } } static int32_t firstDistFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { if (pCtx->order == TSDB_ORDER_DESC) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } // not initialized yet, it is the first block, load it. if (pCtx->pOutput == NULL) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } // the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->pOutput is // the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->pOutput + pCtx->inputBytes); if (pInfo->hasResult != DATA_SET_FLAG) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } else { // data in current block is not earlier than current result - return (pInfo->ts <= w->skey) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED; + return (pInfo->ts <= w->skey) ? BLK_DATA_NOT_LOAD : BLK_DATA_DATA_LOAD; } } static int32_t lastDistFuncRequired(SqlFunctionCtx *pCtx, STimeWindow* w, int32_t colId) { if (pCtx->order != pCtx->param[0].i) { - return BLK_DATA_NO_NEEDED; + return BLK_DATA_NOT_LOAD; } // not initialized yet, it is the first block, load it. if (pCtx->pOutput == NULL) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } // the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->pOutput is // the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->pOutput + pCtx->inputBytes); if (pInfo->hasResult != DATA_SET_FLAG) { - return BLK_DATA_ALL_NEEDED; + return BLK_DATA_DATA_LOAD; } else { - return (pInfo->ts > w->ekey) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED; + return (pInfo->ts > w->ekey) ? BLK_DATA_NOT_LOAD : BLK_DATA_DATA_LOAD; } } From ad3675daed5c826e7ba77698f5c7be621b785fad Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Apr 2022 14:13:29 +0800 Subject: [PATCH 37/48] test: fix an typo in session.sim script. --- tests/script/tsim/query/session.sim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/script/tsim/query/session.sim b/tests/script/tsim/query/session.sim index 3aee838625..d4920ea255 100644 --- a/tests/script/tsim/query/session.sim +++ b/tests/script/tsim/query/session.sim @@ -288,7 +288,7 @@ endi print ================> syntax error check not active ================> reactive sql_error select * from dev_001 session(ts,1w) -sql select count(*) from st session(ts,1w) +sql_error select count(*) from st session(ts,1w) sql_error select count(*) from dev_001 group by tagtype session(ts,1w) sql select count(*) from dev_001 session(ts,1n) sql select count(*) from dev_001 session(ts,1y) From 6e753618fb736ef90664b10818c43f2bb86c239f Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 14:20:50 +0800 Subject: [PATCH 38/48] test: reopen mnode unitest --- source/dnode/mnode/impl/test/CMakeLists.txt | 26 ++++++++++----------- source/dnode/mnode/impl/test/show/show.cpp | 8 +++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/source/dnode/mnode/impl/test/CMakeLists.txt b/source/dnode/mnode/impl/test/CMakeLists.txt index 9b669b303a..15f2aed22a 100644 --- a/source/dnode/mnode/impl/test/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/CMakeLists.txt @@ -1,17 +1,17 @@ enable_testing() -#add_subdirectory(user) add_subdirectory(acct) -#add_subdirectory(trans) -#add_subdirectory(qnode) -#add_subdirectory(snode) add_subdirectory(bnode) -#add_subdirectory(show) -#add_subdirectory(profile) -#add_subdirectory(dnode) -#add_subdirectory(mnode) -#add_subdirectory(db) -#add_subdirectory(stb) -#add_subdirectory(sma) -#add_subdirectory(func) -#add_subdirectory(topic) +add_subdirectory(db) +add_subdirectory(dnode) +add_subdirectory(func) +add_subdirectory(mnode) +add_subdirectory(profile) +add_subdirectory(qnode) +add_subdirectory(show) +add_subdirectory(sma) +add_subdirectory(snode) +add_subdirectory(stb) +add_subdirectory(topic) +add_subdirectory(trans) +add_subdirectory(user) diff --git a/source/dnode/mnode/impl/test/show/show.cpp b/source/dnode/mnode/impl/test/show/show.cpp index 5b8c186ccf..201a42e3ef 100644 --- a/source/dnode/mnode/impl/test/show/show.cpp +++ b/source/dnode/mnode/impl/test/show/show.cpp @@ -34,9 +34,9 @@ TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) { tSerializeSShowReq(pReq, contLen, &showReq); tFreeSShowReq(&showReq); - SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE); + ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_MSG); } TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) { @@ -48,9 +48,9 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) { tSerializeSShowReq(pReq, contLen, &showReq); tFreeSShowReq(&showReq); - SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen); + SRpcMsg* pRsp = test.SendReq(TDMT_MND_SYSTABLE_RETRIEVE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_MSG_TYPE); + ASSERT_EQ(pRsp->code, TSDB_CODE_INVALID_MSG); } TEST_F(MndTestShow, 03_ShowMsg_Conn) { From 694df11ff101ccd4ce2736c600e2c8ec0e90512c Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 15 Apr 2022 06:27:04 +0000 Subject: [PATCH 39/48] refact vnode --- source/dnode/vnode/src/inc/vnodeInt.h | 1 + source/dnode/vnode/src/vnd/vnodeCommit.c | 137 +++++++++++++++++++++-- source/dnode/vnode/src/vnd/vnodeOpen.c | 2 + 3 files changed, 130 insertions(+), 10 deletions(-) diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index b0b87665ed..e95878b04e 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -27,6 +27,7 @@ #include "tdbInt.h" #include "tfs.h" #include "tglobal.h" +#include "tjson.h" #include "tlist.h" #include "tlockfree.h" #include "tlosertree.h" diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index fc74ee9253..b4bce9e350 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -18,7 +18,7 @@ #define VND_INFO_FNAME "vnode.json" #define VND_INFO_FNAME_TMP "vnode_tmp.json" -static int vnodeEncodeInfo(const SVnodeInfo *pInfo, uint8_t **ppData, int *len); +static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData); static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeInfo *pInfo); static int vnodeStartCommit(SVnode *pVnode); static int vnodeEndCommit(SVnode *pVnode); @@ -28,16 +28,14 @@ static void vnodeWaitCommit(SVnode *pVnode); int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) { char fname[TSDB_FILENAME_LEN]; TdFilePtr pFile; - uint8_t *data; - int len; + char *data; snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME_TMP); // encode info data = NULL; - len = 0; - if (vnodeEncodeInfo(pInfo, &data, &len) < 0) { + if (vnodeEncodeInfo(pInfo, &data) < 0) { return -1; } @@ -48,7 +46,7 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) { return -1; } - if (taosWriteFile(pFile, data, len) < 0) { + if (taosWriteFile(pFile, data, strlen(data)) < 0) { terrno = TAOS_SYSTEM_ERROR(errno); goto _err; } @@ -137,12 +135,131 @@ static int vnodeEndCommit(SVnode *pVnode) { static FORCE_INLINE void vnodeWaitCommit(SVnode *pVnode) { tsem_wait(&pVnode->canCommit); } -static int vnodeEncodeInfo(const SVnodeInfo *pInfo, uint8_t **ppData, int *len) { - // TODO +static int vnodeEncodeConfig(const void *pObj, SJson *pJson) { + const SVnodeCfg *pCfg = (SVnodeCfg *)pObj; + + if (tjsonAddIntegerToObject(pJson, "vgId", pCfg->vgId) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "dbId", pCfg->dbId) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "wsize", pCfg->wsize) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "ssize", pCfg->ssize) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "lsize", pCfg->lsize) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "isHeap", pCfg->isHeapAllocator) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "ttl", pCfg->ttl) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep", pCfg->keep) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "streamMode", pCfg->streamMode) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "isWeak", pCfg->isWeak) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "compression", pCfg->tsdbCfg.compression) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "daysPerFile", pCfg->tsdbCfg.daysPerFile) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "minRows", pCfg->tsdbCfg.minRowsPerFileBlock) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "maxRows", pCfg->tsdbCfg.maxRowsPerFileBlock) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1; + return 0; } -static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeInfo *pInfo) { - // TODO +static int vnodeDecodeConfig(const SJson *pJson, void *pObj) { + SVnodeCfg *pCfg = (SVnodeCfg *)pObj; + + if (tjsonGetNumberValue(pJson, "vgId", pCfg->vgId) < 0) return -1; + if (tjsonGetNumberValue(pJson, "dbId", pCfg->dbId) < 0) return -1; + if (tjsonGetNumberValue(pJson, "wsize", pCfg->wsize) < 0) return -1; + if (tjsonGetNumberValue(pJson, "ssize", pCfg->ssize) < 0) return -1; + if (tjsonGetNumberValue(pJson, "lsize", pCfg->lsize) < 0) return -1; + if (tjsonGetNumberValue(pJson, "isHeap", pCfg->isHeapAllocator) < 0) return -1; + if (tjsonGetNumberValue(pJson, "ttl", pCfg->ttl) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep", pCfg->keep) < 0) return -1; + if (tjsonGetNumberValue(pJson, "streamMode", pCfg->streamMode) < 0) return -1; + if (tjsonGetNumberValue(pJson, "isWeak", pCfg->isWeak) < 0) return -1; + if (tjsonGetNumberValue(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1; + if (tjsonGetNumberValue(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1; + if (tjsonGetNumberValue(pJson, "compression", pCfg->tsdbCfg.compression) < 0) return -1; + if (tjsonGetNumberValue(pJson, "daysPerFile", pCfg->tsdbCfg.daysPerFile) < 0) return -1; + if (tjsonGetNumberValue(pJson, "minRows", pCfg->tsdbCfg.minRowsPerFileBlock) < 0) return -1; + if (tjsonGetNumberValue(pJson, "maxRows", pCfg->tsdbCfg.maxRowsPerFileBlock) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; + if (tjsonGetNumberValue(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1; + return 0; } + +static int vnodeEncodeState(const void *pObj, SJson *pJson) { + const SVState *pState = (SVState *)pObj; + + if (tjsonAddIntegerToObject(pJson, "commit version", pState->committed) < 0) return -1; + + return 0; +} + +static int vnodeDecodeState(const SJson *pJson, void *pObj) { + SVState *pState = (SVState *)pObj; + + if (tjsonGetNumberValue(pJson, "commit version", pState->committed) < 0) return -1; + + return 0; +} + +static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData) { + SJson *pJson; + char *pData; + + *ppData = NULL; + + pJson = tjsonCreateObject(); + if (pJson == NULL) { + return -1; + } + + if (tjsonAddObject(pJson, "config", vnodeEncodeConfig, (void *)&pInfo->config) < 0) { + goto _err; + } + + if (tjsonAddObject(pJson, "state", vnodeEncodeState, (void *)&pInfo->state) < 0) { + goto _err; + } + + pData = tjsonToString(pJson); + if (pData == NULL) { + goto _err; + } + + tjsonDelete(pJson); + + *ppData = pData; + return 0; + +_err: + tjsonDelete(pJson); + return -1; +} + +static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeInfo *pInfo) { + SJson *pJson = NULL; + + pJson = tjsonCreateObject(); + if (pJson == NULL) { + return -1; + } + + if (tjsonToObject(pJson, "config", vnodeDecodeConfig, (void *)&pInfo->config) < 0) { + goto _err; + } + + if (tjsonToObject(pJson, "state", vnodeDecodeState, (void *)&pInfo->state) < 0) { + goto _err; + } + + tjsonDelete(pJson); + + return 0; + +_err: + tjsonDelete(pJson); + return -1; +} diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 5fa14f6018..241c26ab1c 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -46,6 +46,8 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) { return -1; } + vInfo("vgId: %d vnode is created", pCfg->vgId); + return 0; } From e96f0fa42935d6aff7cb24d2c362f4a20e3b214f Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 15 Apr 2022 14:31:54 +0800 Subject: [PATCH 40/48] fix: the bug found by CI --- source/dnode/mnode/impl/test/profile/profile.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/dnode/mnode/impl/test/profile/profile.cpp b/source/dnode/mnode/impl/test/profile/profile.cpp index b9b21ebed9..2c3be2135b 100644 --- a/source/dnode/mnode/impl/test/profile/profile.cpp +++ b/source/dnode/mnode/impl/test/profile/profile.cpp @@ -46,7 +46,7 @@ TEST_F(MndTestProfile, 01_ConnectMsg) { EXPECT_EQ(connectRsp.acctId, 1); EXPECT_GT(connectRsp.clusterId, 0); - EXPECT_EQ(connectRsp.connId, 1); + EXPECT_NE(connectRsp.connId, 0); EXPECT_EQ(connectRsp.superUser, 1); EXPECT_EQ(connectRsp.epSet.inUse, 0); @@ -82,7 +82,8 @@ TEST_F(MndTestProfile, 04_HeartBeatMsg) { SClientHbBatchReq batchReq = {0}; batchReq.reqs = taosArrayInit(0, sizeof(SClientHbReq)); SClientHbReq req = {0}; - req.connKey = {.connId = 123, .hbType = CONN_TYPE__TMQ}; + req.connKey.tscRid = 123; + req.connKey.connType = CONN_TYPE__TMQ; req.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK); SKv kv = {0}; kv.key = 123; From 83c8be30880f81471a1e737450b5db6f3061e16c Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 15 Apr 2022 06:38:18 +0000 Subject: [PATCH 41/48] refact --- source/dnode/vnode/inc/vnode.h | 6 ++--- source/dnode/vnode/src/tsdb/tsdbCommit.c | 31 +++++++++++----------- source/dnode/vnode/src/tsdb/tsdbFS.c | 2 +- source/dnode/vnode/src/tsdb/tsdbMemTable.c | 24 ++++++++--------- source/dnode/vnode/src/tsdb/tsdbOptions.c | 6 ++--- source/dnode/vnode/src/tsdb/tsdbRead.c | 10 +++---- source/dnode/vnode/src/tsdb/tsdbReadImpl.c | 14 +++++----- source/dnode/vnode/src/tsdb/tsdbSma.c | 10 ++++--- source/dnode/vnode/src/vnd/vnodeCommit.c | 12 ++++----- 9 files changed, 59 insertions(+), 56 deletions(-) diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 25c6ffc1ad..e42311fa9c 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -124,9 +124,9 @@ struct STsdbCfg { int8_t precision; int8_t update; int8_t compression; - int32_t daysPerFile; - int32_t minRowsPerFileBlock; - int32_t maxRowsPerFileBlock; + int32_t days; + int32_t minRows; + int32_t maxRows; int32_t keep; int32_t keep1; int32_t keep2; diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index eb32663387..8cbe3c9005 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -55,7 +55,7 @@ typedef struct { #define TSDB_COMMIT_BUF(ch) TSDB_READ_BUF(&((ch)->readh)) #define TSDB_COMMIT_COMP_BUF(ch) TSDB_READ_COMP_BUF(&((ch)->readh)) #define TSDB_COMMIT_EXBUF(ch) TSDB_READ_EXBUF(&((ch)->readh)) -#define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->config.maxRowsPerFileBlock) +#define TSDB_COMMIT_DEFAULT_ROWS(ch) TSDB_DEFAULT_BLOCK_ROWS(TSDB_COMMIT_REPO(ch)->config.maxRows) #define TSDB_COMMIT_TXN_VERSION(ch) FS_TXN_VERSION(REPO_FS(TSDB_COMMIT_REPO(ch))) static void tsdbStartCommit(STsdb *pRepo); @@ -222,9 +222,9 @@ void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) { maxKey = now - pCfg->keep1 * tsTickPerDay[pCfg->precision]; pRtn->minKey = minKey; - pRtn->minFid = (int)(TSDB_KEY_FID(minKey, pCfg->daysPerFile, pCfg->precision)); - pRtn->midFid = (int)(TSDB_KEY_FID(midKey, pCfg->daysPerFile, pCfg->precision)); - pRtn->maxFid = (int)(TSDB_KEY_FID(maxKey, pCfg->daysPerFile, pCfg->precision)); + pRtn->minFid = (int)(TSDB_KEY_FID(minKey, pCfg->days, pCfg->precision)); + pRtn->midFid = (int)(TSDB_KEY_FID(midKey, pCfg->days, pCfg->precision)); + pRtn->maxFid = (int)(TSDB_KEY_FID(maxKey, pCfg->days, pCfg->precision)); tsdbDebug("vgId:%d now:%" PRId64 " minKey:%" PRId64 " minFid:%d, midFid:%d, maxFid:%d", REPO_ID(pRepo), now, minKey, pRtn->minFid, pRtn->midFid, pRtn->maxFid); } @@ -286,7 +286,7 @@ static int tsdbInitCommitH(SCommitH *pCommith, STsdb *pRepo) { return -1; } - pCommith->pDataCols = tdNewDataCols(0, pCfg->maxRowsPerFileBlock); + pCommith->pDataCols = tdNewDataCols(0, pCfg->maxRows); if (pCommith->pDataCols == NULL) { terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; tsdbDestroyCommitH(pCommith); @@ -319,7 +319,7 @@ static int tsdbNextCommitFid(SCommitH *pCommith) { if (nextKey == TSDB_DATA_TIMESTAMP_NULL) { continue; } else { - int tfid = (int)(TSDB_KEY_FID(nextKey, pCfg->daysPerFile, pCfg->precision)); + int tfid = (int)(TSDB_KEY_FID(nextKey, pCfg->days, pCfg->precision)); if (fid == TSDB_IVLD_FID || fid > tfid) { fid = tfid; } @@ -346,7 +346,7 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) { ASSERT(pSet == NULL || pSet->fid == fid); tsdbResetCommitFile(pCommith); - tsdbGetFidKeyRange(pCfg->daysPerFile, pCfg->precision, fid, &(pCommith->minKey), &(pCommith->maxKey)); + tsdbGetFidKeyRange(pCfg->days, pCfg->precision, fid, &(pCommith->minKey), &(pCommith->maxKey)); // Set and open files if (tsdbSetAndOpenCommitFile(pCommith, pSet, fid) < 0) { @@ -1210,8 +1210,8 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF int64_t offset = 0, offsetAggr = 0; int rowsToWrite = pDataCols->numOfRows; - ASSERT(rowsToWrite > 0 && rowsToWrite <= pCfg->maxRowsPerFileBlock); - ASSERT((!isLast) || rowsToWrite < pCfg->minRowsPerFileBlock); + ASSERT(rowsToWrite > 0 && rowsToWrite <= pCfg->maxRows); + ASSERT((!isLast) || rowsToWrite < pCfg->minRows); // Make buffer space if (tsdbMakeRoom(ppBuf, tsdbBlockStatisSize(pDataCols->numOfCols, SBlockVerLatest)) < 0) { @@ -1460,7 +1460,7 @@ static int tsdbCommitMemData(SCommitH *pCommith, SCommitIter *pIter, TSKEY keyLi if (pCommith->pDataCols->numOfRows <= 0) break; - if (toData || pCommith->pDataCols->numOfRows >= pCfg->minRowsPerFileBlock) { + if (toData || pCommith->pDataCols->numOfRows >= pCfg->minRows) { pDFile = TSDB_COMMIT_DATA_FILE(pCommith); isLast = false; } else { @@ -1619,7 +1619,7 @@ static int tsdbMergeBlockData(SCommitH *pCommith, SCommitIter *pIter, SDataCols if (pCommith->pDataCols->numOfRows == 0) break; if (isLastOneBlock) { - if (pCommith->pDataCols->numOfRows < pCfg->minRowsPerFileBlock) { + if (pCommith->pDataCols->numOfRows < pCfg->minRows) { pDFile = TSDB_COMMIT_LAST_FILE(pCommith); isLast = true; } else { @@ -1667,7 +1667,8 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt if (tdGetColDataOfRow(&sVal, pDataCols->cols + i, *iter, pDataCols->bitmapMode) < 0) { TASSERT(0); } - tdAppendValToDataCol(pTarget->cols + i, sVal.valType, sVal.val, pTarget->numOfRows, pTarget->maxPoints, pTarget->bitmapMode); + tdAppendValToDataCol(pTarget->cols + i, sVal.valType, sVal.val, pTarget->numOfRows, pTarget->maxPoints, + pTarget->bitmapMode); } ++pTarget->numOfRows; @@ -1774,11 +1775,11 @@ static bool tsdbCanAddSubBlock(SCommitH *pCommith, SBlock *pBlock, SMergeInfo *p ASSERT(mergeRows > 0); - if (pBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && pInfo->nOperations <= pCfg->maxRowsPerFileBlock) { + if (pBlock->numOfSubBlocks < TSDB_MAX_SUBBLOCKS && pInfo->nOperations <= pCfg->maxRows) { if (pBlock->last) { - if (pCommith->isLFileSame && mergeRows < pCfg->minRowsPerFileBlock) return true; + if (pCommith->isLFileSame && mergeRows < pCfg->minRows) return true; } else { - if (pCommith->isDFileSame && mergeRows <= pCfg->maxRowsPerFileBlock) return true; + if (pCommith->isDFileSame && mergeRows <= pCfg->maxRows) return true; } } diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index bd3888864d..ca363fdc1f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -191,7 +191,7 @@ static int tsdbAddDFileSetToStatus(SFSStatus *pStatus, const SDFileSet *pSet) { // ================== STsdbFS STsdbFS *tsdbNewFS(const STsdbCfg *pCfg) { int keep = pCfg->keep; - int days = pCfg->daysPerFile; + int days = pCfg->days; int maxFSet = TSDB_MAX_FSETS(keep, days); STsdbFS *pfs; diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index 5a477e646c..a682715c2c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -19,9 +19,9 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg); static int tsdbMemTableInsertTbData(STsdb *pRepo, SSubmitBlk *pBlock, int32_t *pAffectedRows); static STbData *tsdbNewTbData(tb_uid_t uid); static void tsdbFreeTbData(STbData *pTbData); -static char * tsdbGetTsTupleKey(const void *data); +static char *tsdbGetTsTupleKey(const void *data); static int tsdbTbDataComp(const void *arg1, const void *arg2); -static char * tsdbTbDataGetUid(const void *arg); +static char *tsdbTbDataGetUid(const void *arg); static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema **ppSchema, STSRow *row); STsdbMemTable *tsdbNewMemTable(STsdb *pTsdb) { @@ -74,7 +74,7 @@ void tsdbFreeMemTable(STsdb *pTsdb, STsdbMemTable *pMemTable) { } int tsdbMemTableInsert(STsdb *pTsdb, STsdbMemTable *pMemTable, SSubmitReq *pMsg, SSubmitRsp *pRsp) { - SSubmitBlk * pBlock = NULL; + SSubmitBlk *pBlock = NULL; SSubmitMsgIter msgIter = {0}; int32_t affectedrows = 0, numOfRows = 0; @@ -119,12 +119,12 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo) { ASSERT(maxRowsToRead > 0 && nFilterKeys >= 0); if (pIter == NULL) return 0; - STSchema * pSchema = NULL; + STSchema *pSchema = NULL; TSKEY rowKey = 0; TSKEY fKey = 0; bool isRowDel = false; int filterIter = 0; - STSRow * row = NULL; + STSRow *row = NULL; SMergeInfo mInfo; if (pMergeInfo == NULL) pMergeInfo = &mInfo; @@ -259,12 +259,12 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) { ASSERT(pMsg != NULL); // STsdbMeta * pMeta = pTsdb->tsdbMeta; SSubmitMsgIter msgIter = {0}; - SSubmitBlk * pBlock = NULL; + SSubmitBlk *pBlock = NULL; SSubmitBlkIter blkIter = {0}; - STSRow * row = NULL; + STSRow *row = NULL; TSKEY now = taosGetTimestamp(pTsdb->config.precision); TSKEY minKey = now - tsTickPerDay[pTsdb->config.precision] * pTsdb->config.keep; - TSKEY maxKey = now + tsTickPerDay[pTsdb->config.precision] * pTsdb->config.daysPerFile; + TSKEY maxKey = now + tsTickPerDay[pTsdb->config.precision] * pTsdb->config.days; terrno = TSDB_CODE_SUCCESS; pMsg->length = htonl(pMsg->length); @@ -332,9 +332,9 @@ static int tsdbMemTableInsertTbData(STsdb *pTsdb, SSubmitBlk *pBlock, int32_t *p // STable *pTable = NULL; SSubmitBlkIter blkIter = {0}; STsdbMemTable *pMemTable = pTsdb->mem; - void * tptr; - STbData * pTbData; - STSRow * row; + void *tptr; + STbData *pTbData; + STSRow *row; TSKEY keyMin; TSKEY keyMax; @@ -504,7 +504,7 @@ int tsdbInsertDataToMemTable(STsdbMemTable *pMemTable, SSubmitReq *pMsg) { #include "tskiplist.h" #define TSDB_DATA_SKIPLIST_LEVEL 5 -#define TSDB_MAX_INSERT_BATCH 512 +#define TSDB_MAX_INSERT_BATCH 512 typedef struct { int32_t totalLen; diff --git a/source/dnode/vnode/src/tsdb/tsdbOptions.c b/source/dnode/vnode/src/tsdb/tsdbOptions.c index 2c57a7406e..c3555cc835 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOptions.c +++ b/source/dnode/vnode/src/tsdb/tsdbOptions.c @@ -17,9 +17,9 @@ const STsdbCfg defautlTsdbOptions = {.precision = 0, .lruCacheSize = 0, - .daysPerFile = 10, - .minRowsPerFileBlock = 100, - .maxRowsPerFileBlock = 4096, + .days = 10, + .minRows = 100, + .maxRows = 4096, .keep = 3650, .keep1 = 3650, .keep2 = 3650, diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 9509dfa462..e5da0e3c37 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -404,7 +404,7 @@ static STsdbReadHandle* tsdbQueryTablesImpl(STsdb* tsdb, STsdbQueryCond* pCond, pReadHandle->defaultLoadColumn = getDefaultLoadColumns(pReadHandle, true); } - pReadHandle->pDataCols = tdNewDataCols(1000, pReadHandle->pTsdb->config.maxRowsPerFileBlock); + pReadHandle->pDataCols = tdNewDataCols(1000, pReadHandle->pTsdb->config.maxRows); if (pReadHandle->pDataCols == NULL) { tsdbError("%p failed to malloc buf for pDataCols, %s", pReadHandle, pReadHandle->idStr); terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; @@ -2199,7 +2199,7 @@ static int32_t getFirstFileDataBlock(STsdbReadHandle* pTsdbReadHandle, bool* exi break; } - tsdbGetFidKeyRange(pCfg->daysPerFile, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey); + tsdbGetFidKeyRange(pCfg->days, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey); // current file are not overlapped with query time window, ignore remain files if ((ASCENDING_TRAVERSE(pTsdbReadHandle->order) && win.skey > pTsdbReadHandle->window.ekey) || @@ -2295,7 +2295,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo* // find the start data block in file pTsdbReadHandle->locateStart = true; STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config; - int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->daysPerFile, pCfg->precision); + int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->days, pCfg->precision); tsdbRLockFS(pFileHandle); tsdbFSIterInit(&pTsdbReadHandle->fileIter, pFileHandle, pTsdbReadHandle->order); @@ -2321,7 +2321,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT* queryHandle, STableBlockDistInfo* break; } - tsdbGetFidKeyRange(pCfg->daysPerFile, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey); + tsdbGetFidKeyRange(pCfg->days, pCfg->precision, pTsdbReadHandle->pFileGroup->fid, &win.skey, &win.ekey); // current file are not overlapped with query time window, ignore remain files if ((ascTraverse && win.skey > pTsdbReadHandle->window.ekey) || @@ -2396,7 +2396,7 @@ static int32_t getDataBlocksInFiles(STsdbReadHandle* pTsdbReadHandle, bool* exis if (!pTsdbReadHandle->locateStart) { pTsdbReadHandle->locateStart = true; STsdbCfg* pCfg = &pTsdbReadHandle->pTsdb->config; - int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->daysPerFile, pCfg->precision); + int32_t fid = getFileIdFromKey(pTsdbReadHandle->window.skey, pCfg->days, pCfg->precision); tsdbRLockFS(pFileHandle); tsdbFSIterInit(&pTsdbReadHandle->fileIter, pFileHandle, pTsdbReadHandle->order); diff --git a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c index e31ede09cc..0b5a53dd9c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c @@ -43,14 +43,14 @@ int tsdbInitReadH(SReadH *pReadh, STsdb *pRepo) { return -1; } - pReadh->pDCols[0] = tdNewDataCols(0, pCfg->maxRowsPerFileBlock); + pReadh->pDCols[0] = tdNewDataCols(0, pCfg->maxRows); if (pReadh->pDCols[0] == NULL) { terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; tsdbDestroyReadH(pReadh); return -1; } - pReadh->pDCols[1] = tdNewDataCols(0, pCfg->maxRowsPerFileBlock); + pReadh->pDCols[1] = tdNewDataCols(0, pCfg->maxRows); if (pReadh->pDCols[1] == NULL) { terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; tsdbDestroyReadH(pReadh); @@ -276,8 +276,8 @@ int tsdbLoadBlockData(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo) { return 0; } -int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, const int16_t *colIds, - int numOfColsIds, bool mergeBitmap) { +int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, const int16_t *colIds, int numOfColsIds, + bool mergeBitmap) { ASSERT(pBlock->numOfSubBlocks > 0); int8_t update = pReadh->pRepo->config.update; @@ -513,7 +513,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat tdResetDataCols(pDataCols); - if(tsdbIsSupBlock(pBlock)) { + if (tsdbIsSupBlock(pBlock)) { tdDataColsSetBitmapI(pDataCols); } @@ -710,7 +710,7 @@ static int tsdbLoadBlockDataColsImpl(SReadH *pReadh, SBlock *pBlock, SDataCols * tdResetDataCols(pDataCols); - if(tsdbIsSupBlock(pBlock)) { + if (tsdbIsSupBlock(pBlock)) { tdDataColsSetBitmapI(pDataCols); } @@ -836,7 +836,7 @@ static int tsdbLoadColData(SReadH *pReadh, SDFile *pDFile, SBlock *pBlock, SBloc } if (tsdbCheckAndDecodeColumnData(pDataCol, pReadh->pBuf, pBlockCol->len, pBlockCol->blen, pBlock->algorithm, - pBlock->numOfRows, tLenBitmap, pCfg->maxRowsPerFileBlock, pReadh->pCBuf, + pBlock->numOfRows, tLenBitmap, pCfg->maxRows, pReadh->pCBuf, (int32_t)taosTSizeof(pReadh->pCBuf)) < 0) { tsdbError("vgId:%d file %s is broken at column %d offset %" PRId64, REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pDFile), pBlockCol->colId, offset); diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 7de5a0d5a9..7abdf22073 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -106,7 +106,8 @@ struct SSmaStat { // expired window static int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t version); -static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, int64_t version); +static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, + int64_t version); static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat); static void *tsdbFreeSmaStatItem(SSmaStatItem *pSmaStatItem); static int32_t tsdbDestroySmaState(SSmaStat *pSmaStat); @@ -197,7 +198,7 @@ static SPoolMem *openPool() { static void clearPool(SPoolMem *pPool) { if (!pPool) return; - + SPoolMem *pMem; do { @@ -544,7 +545,8 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { return TSDB_CODE_SUCCESS; }; -static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, int64_t version) { +static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t indexUid, int64_t winSKey, + int64_t version) { SSmaStatItem *pItem = taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); if (pItem == NULL) { // TODO: use TSDB_SMA_STAT_EXPIRED and update by stream computing later @@ -946,7 +948,7 @@ static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, int64_t indexUid, int32_t */ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLevel) { STsdbCfg *pCfg = REPO_CFG(pTsdb); - int32_t daysPerFile = pCfg->daysPerFile; + int32_t daysPerFile = pCfg->days; if (storageLevel == SMA_STORAGE_LEVEL_TSDB) { int32_t days = SMA_STORAGE_TSDB_TIMES * (interval / tsTickPerDay[pCfg->precision]); diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index b4bce9e350..c8323c30b9 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -151,9 +151,9 @@ static int vnodeEncodeConfig(const void *pObj, SJson *pJson) { if (tjsonAddIntegerToObject(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "compression", pCfg->tsdbCfg.compression) < 0) return -1; - if (tjsonAddIntegerToObject(pJson, "daysPerFile", pCfg->tsdbCfg.daysPerFile) < 0) return -1; - if (tjsonAddIntegerToObject(pJson, "minRows", pCfg->tsdbCfg.minRowsPerFileBlock) < 0) return -1; - if (tjsonAddIntegerToObject(pJson, "maxRows", pCfg->tsdbCfg.maxRowsPerFileBlock) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; @@ -178,9 +178,9 @@ static int vnodeDecodeConfig(const SJson *pJson, void *pObj) { if (tjsonGetNumberValue(pJson, "precision", pCfg->tsdbCfg.precision) < 0) return -1; if (tjsonGetNumberValue(pJson, "update", pCfg->tsdbCfg.update) < 0) return -1; if (tjsonGetNumberValue(pJson, "compression", pCfg->tsdbCfg.compression) < 0) return -1; - if (tjsonGetNumberValue(pJson, "daysPerFile", pCfg->tsdbCfg.daysPerFile) < 0) return -1; - if (tjsonGetNumberValue(pJson, "minRows", pCfg->tsdbCfg.minRowsPerFileBlock) < 0) return -1; - if (tjsonGetNumberValue(pJson, "maxRows", pCfg->tsdbCfg.maxRowsPerFileBlock) < 0) return -1; + if (tjsonGetNumberValue(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1; + if (tjsonGetNumberValue(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1; + if (tjsonGetNumberValue(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1; if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep) < 0) return -1; if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; From aa266dea4170a4ad0fb48911f19e420bf2cd44dc Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 15 Apr 2022 06:47:39 +0000 Subject: [PATCH 42/48] refact vnode --- source/dnode/mgmt/mgmt_vnode/src/vmHandle.c | 4 ++-- source/dnode/vnode/inc/vnode.h | 4 ++-- source/dnode/vnode/src/tsdb/tsdbCommit.c | 6 +++--- source/dnode/vnode/src/tsdb/tsdbFS.c | 2 +- source/dnode/vnode/src/tsdb/tsdbMemTable.c | 2 +- source/dnode/vnode/src/tsdb/tsdbOptions.c | 4 ++-- source/dnode/vnode/src/tsdb/tsdbRead.c | 2 +- source/dnode/vnode/src/vnd/vnodeCommit.c | 12 ++++++------ 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 484b6646b5..bebb437cfe 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -91,9 +91,9 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->keep = pCreate->daysToKeep0; pCfg->streamMode = pCreate->streamMode; pCfg->isWeak = true; - pCfg->tsdbCfg.keep = pCreate->daysToKeep0; - pCfg->tsdbCfg.keep1 = pCreate->daysToKeep2; pCfg->tsdbCfg.keep2 = pCreate->daysToKeep0; + pCfg->tsdbCfg.keep0 = pCreate->daysToKeep2; + pCfg->tsdbCfg.keep1 = pCreate->daysToKeep0; pCfg->tsdbCfg.lruCacheSize = pCreate->cacheBlockSize; pCfg->tsdbCfg.retentions = pCreate->pRetensions; pCfg->metaCfg.lruSize = pCreate->cacheBlockSize; diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index e42311fa9c..303376dba4 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -127,9 +127,9 @@ struct STsdbCfg { int32_t days; int32_t minRows; int32_t maxRows; - int32_t keep; - int32_t keep1; int32_t keep2; + int32_t keep0; + int32_t keep1; uint64_t lruCacheSize; SArray *retentions; }; diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 8cbe3c9005..a1edb7cd9c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -217,9 +217,9 @@ void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) { TSKEY minKey, midKey, maxKey, now; now = taosGetTimestamp(pCfg->precision); - minKey = now - pCfg->keep * tsTickPerDay[pCfg->precision]; - midKey = now - pCfg->keep2 * tsTickPerDay[pCfg->precision]; - maxKey = now - pCfg->keep1 * tsTickPerDay[pCfg->precision]; + minKey = now - pCfg->keep2 * tsTickPerDay[pCfg->precision]; + midKey = now - pCfg->keep1 * tsTickPerDay[pCfg->precision]; + maxKey = now - pCfg->keep0 * tsTickPerDay[pCfg->precision]; pRtn->minKey = minKey; pRtn->minFid = (int)(TSDB_KEY_FID(minKey, pCfg->days, pCfg->precision)); diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index ca363fdc1f..866c02cbb3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -190,7 +190,7 @@ static int tsdbAddDFileSetToStatus(SFSStatus *pStatus, const SDFileSet *pSet) { // ================== STsdbFS STsdbFS *tsdbNewFS(const STsdbCfg *pCfg) { - int keep = pCfg->keep; + int keep = pCfg->keep2; int days = pCfg->days; int maxFSet = TSDB_MAX_FSETS(keep, days); STsdbFS *pfs; diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index a682715c2c..5f401c9b2b 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -263,7 +263,7 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) { SSubmitBlkIter blkIter = {0}; STSRow *row = NULL; TSKEY now = taosGetTimestamp(pTsdb->config.precision); - TSKEY minKey = now - tsTickPerDay[pTsdb->config.precision] * pTsdb->config.keep; + TSKEY minKey = now - tsTickPerDay[pTsdb->config.precision] * pTsdb->config.keep2; TSKEY maxKey = now + tsTickPerDay[pTsdb->config.precision] * pTsdb->config.days; terrno = TSDB_CODE_SUCCESS; diff --git a/source/dnode/vnode/src/tsdb/tsdbOptions.c b/source/dnode/vnode/src/tsdb/tsdbOptions.c index c3555cc835..3560c9feaa 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOptions.c +++ b/source/dnode/vnode/src/tsdb/tsdbOptions.c @@ -20,9 +20,9 @@ const STsdbCfg defautlTsdbOptions = {.precision = 0, .days = 10, .minRows = 100, .maxRows = 4096, - .keep = 3650, - .keep1 = 3650, .keep2 = 3650, + .keep0 = 3650, + .keep1 = 3650, .update = 0, .compression = TWO_STAGE_COMP}; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index e5da0e3c37..1314ef7d1e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -314,7 +314,7 @@ static int64_t getEarliestValidTimestamp(STsdb* pTsdb) { STsdbCfg* pCfg = &pTsdb->config; int64_t now = taosGetTimestamp(pCfg->precision); - return now - (tsTickPerDay[pCfg->precision] * pCfg->keep) + 1; // needs to add one tick + return now - (tsTickPerDay[pCfg->precision] * pCfg->keep2) + 1; // needs to add one tick } static void setQueryTimewindow(STsdbReadHandle* pTsdbReadHandle, STsdbQueryCond* pCond) { diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index c8323c30b9..ec071c44e3 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -154,9 +154,9 @@ static int vnodeEncodeConfig(const void *pObj, SJson *pJson) { if (tjsonAddIntegerToObject(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1; - if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep) < 0) return -1; - if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; - if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep2) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep0) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep1) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1; return 0; @@ -181,9 +181,9 @@ static int vnodeDecodeConfig(const SJson *pJson, void *pObj) { if (tjsonGetNumberValue(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1; if (tjsonGetNumberValue(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1; if (tjsonGetNumberValue(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1; - if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep) < 0) return -1; - if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; - if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep2) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep0) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep1) < 0) return -1; if (tjsonGetNumberValue(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1; return 0; From 98b98c8b851cb07a5e83208083dc714a10c1f891 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 15 Apr 2022 07:07:44 +0000 Subject: [PATCH 43/48] refact vnode --- source/dnode/mgmt/mgmt_vnode/src/vmHandle.c | 10 ++++ source/dnode/vnode/src/inc/vnd.h | 1 + source/dnode/vnode/src/vnd/vnodeCommit.c | 64 +++++++++++++++++---- 3 files changed, 65 insertions(+), 10 deletions(-) diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index bebb437cfe..925197d708 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -121,6 +121,8 @@ static void vmGenerateWrapperCfg(SVnodesMgmt *pMgmt, SCreateVnodeReq *pCreate, S int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { SRpcMsg *pReq = &pMsg->rpcMsg; SCreateVnodeReq createReq = {0}; + char path[TSDB_FILENAME_LEN]; + if (tDeserializeSCreateVnodeReq(pReq->pCont, pReq->contLen, &createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; return -1; @@ -143,6 +145,14 @@ int32_t vmProcessCreateVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) { return -1; } + // create vnode + snprintf(path, TSDB_FILENAME_LEN, "vnode%svnode%d", TD_DIRSEP, vnodeCfg.vgId); + if (vnodeCreate(path, &vnodeCfg, pMgmt->pTfs) < 0) { + tFreeSCreateVnodeReq(&createReq); + dError("vgId:%d, failed to create vnode since %s", createReq.vgId, terrstr()); + return -1; + } + SMsgCb msgCb = pMgmt->pDnode->data.msgCb; msgCb.pWrapper = pMgmt->pWrapper; msgCb.queueFps[QUERY_QUEUE] = vmPutMsgToQueryQueue; diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 913fec64ed..cb40900e81 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -43,6 +43,7 @@ int vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg); // vnodeCommit ==================== int vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg); int vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo); +int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo); #if 1 // SVBufPool diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index ec071c44e3..fa249d3ba1 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -19,7 +19,7 @@ #define VND_INFO_FNAME_TMP "vnode_tmp.json" static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData); -static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeInfo *pInfo); +static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo); static int vnodeStartCommit(SVnode *pVnode); static int vnodeEndCommit(SVnode *pVnode); static int vnodeCommit(void *arg); @@ -88,9 +88,53 @@ int vnodeCommitInfo(const char *dir, const SVnodeInfo *pInfo) { return 0; } -int vnodeLoadInfo(const char *dir) { - // TODO +int vnodeLoadInfo(const char *dir, SVnodeInfo *pInfo) { + char fname[TSDB_FILENAME_LEN]; + TdFilePtr pFile = NULL; + char *pData = NULL; + int64_t size; + + snprintf(fname, TSDB_FILENAME_LEN, "%s%s%s", dir, TD_DIRSEP, VND_INFO_FNAME); + + // read info + pFile = taosOpenFile(fname, TD_FILE_READ); + if (pFile == NULL) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + if (taosFStatFile(pFile, &size, NULL) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + pData = taosMemoryMalloc(size); + if (pData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + + if (taosReadFile(pFile, pData, size) < 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + taosCloseFile(&pFile); + + // decode info + if (vnodeDecodeInfo(pData, pInfo) < 0) { + taosMemoryFree(pData); + return -1; + } + + taosMemoryFree(pData); + return 0; + +_err: + taosCloseFile(&pFile); + taosMemoryFree(pData); + return -1; } int vnodeAsyncCommit(SVnode *pVnode) { @@ -154,9 +198,9 @@ static int vnodeEncodeConfig(const void *pObj, SJson *pJson) { if (tjsonAddIntegerToObject(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1; - if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep2) < 0) return -1; - if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep0) < 0) return -1; - if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep1) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; + if (tjsonAddIntegerToObject(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; if (tjsonAddIntegerToObject(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1; return 0; @@ -181,9 +225,9 @@ static int vnodeDecodeConfig(const SJson *pJson, void *pObj) { if (tjsonGetNumberValue(pJson, "daysPerFile", pCfg->tsdbCfg.days) < 0) return -1; if (tjsonGetNumberValue(pJson, "minRows", pCfg->tsdbCfg.minRows) < 0) return -1; if (tjsonGetNumberValue(pJson, "maxRows", pCfg->tsdbCfg.maxRows) < 0) return -1; - if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep2) < 0) return -1; - if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep0) < 0) return -1; - if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep1) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep0", pCfg->tsdbCfg.keep0) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep1", pCfg->tsdbCfg.keep1) < 0) return -1; + if (tjsonGetNumberValue(pJson, "keep2", pCfg->tsdbCfg.keep2) < 0) return -1; if (tjsonGetNumberValue(pJson, "lruCacheSize", pCfg->tsdbCfg.lruCacheSize) < 0) return -1; return 0; @@ -239,7 +283,7 @@ _err: return -1; } -static int vnodeDecodeInfo(uint8_t *pData, int len, SVnodeInfo *pInfo) { +static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo) { SJson *pJson = NULL; pJson = tjsonCreateObject(); From bc178c247df5c1a6fe1fdb38375c7aeafee82288 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 15 Apr 2022 07:49:33 +0000 Subject: [PATCH 44/48] fix a bug --- source/libs/scheduler/src/scheduler.c | 75 +++++++++++++-------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 93bc16a7a2..9b652f2795 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -14,12 +14,12 @@ */ #include "catalog.h" +#include "command.h" #include "query.h" #include "schedulerInt.h" #include "tmsg.h" #include "tref.h" #include "trpc.h" -#include "command.h" SSchedulerMgmt schMgmt = {0}; @@ -68,8 +68,8 @@ int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel * } int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *transport, SArray *pNodeList, const char *sql, - int64_t startTs, bool syncSchedule) { - int32_t code = 0; + int64_t startTs, bool syncSchedule) { + int32_t code = 0; SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob)); if (NULL == pJob) { qError("QID:%" PRIx64 " calloc %d failed", pDag->queryId, (int32_t)sizeof(SSchJob)); @@ -141,7 +141,6 @@ _return: SCH_RET(code); } - void schFreeRpcCtx(SRpcCtx *pCtx) { if (NULL == pCtx) { return; @@ -1047,12 +1046,12 @@ _return: int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRsp *pRsp) { SCH_TASK_DLOG("got explain rsp, rows:%d, complete:%d", htonl(pRsp->numOfRows), pRsp->completed); - + atomic_store_32(&pJob->resNumOfRows, htonl(pRsp->numOfRows)); atomic_store_ptr(&pJob->resData, pRsp); SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_SUCCEED); - + schProcessOnDataFetched(pJob); return TSDB_CODE_SUCCESS; @@ -1146,7 +1145,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch if (NULL == msg) { SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } - + if (!SCH_IS_EXPLAIN_JOB(pJob)) { SCH_TASK_ELOG("invalid msg received for none explain query, msg type:%s", TMSG_INFO(msgType)); SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); @@ -1180,13 +1179,13 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch } if (SCH_IS_EXPLAIN_JOB(pJob)) { - if (rsp->completed) { + if (rsp->completed) { SRetrieveTableRsp *pRsp = NULL; SCH_ERR_JRET(qExecExplainEnd(pJob->explainCtx, &pRsp)); if (pRsp) { SCH_ERR_JRET(schProcessOnExplainDone(pJob, pTask, pRsp)); } - + return TSDB_CODE_SUCCESS; } @@ -1238,23 +1237,24 @@ _return: } int32_t schGetTaskFromTaskList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask) { - int32_t s = taosHashGetSize(pTaskList); - if (s <= 0) { - return TSDB_CODE_SUCCESS; - } - - SSchTask **task = taosHashGet(pTaskList, &taskId, sizeof(taskId)); - if (NULL == task || NULL == (*task)) { - return TSDB_CODE_SUCCESS; - } + int32_t s = taosHashGetSize(pTaskList); + if (s <= 0) { + return TSDB_CODE_SUCCESS; + } - *pTask = *task; + SSchTask **task = taosHashGet(pTaskList, &taskId, sizeof(taskId)); + if (NULL == task || NULL == (*task)) { + return TSDB_CODE_SUCCESS; + } - return TSDB_CODE_SUCCESS; + *pTask = *task; + + return TSDB_CODE_SUCCESS; } int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCode) { - if (rspCode || NULL == pTask->execNodes || taosArrayGetSize(pTask->execNodes) > 1 || taosArrayGetSize(pTask->execNodes) <= 0) { + if (rspCode || NULL == pTask->execNodes || taosArrayGetSize(pTask->execNodes) > 1 || + taosArrayGetSize(pTask->execNodes) <= 0) { return TSDB_CODE_SUCCESS; } @@ -1264,7 +1264,6 @@ int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCo return TSDB_CODE_SUCCESS; } - int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode) { int32_t code = 0; SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; @@ -1282,13 +1281,15 @@ int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, in if (TDMT_VND_EXPLAIN_RSP == msgType) { schGetTaskFromTaskList(pJob->succTasks, pParam->taskId, &pTask); } else { - SCH_JOB_ELOG("task not found in execTask list, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId, pParam->taskId); + SCH_JOB_ELOG("task not found in execTask list, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId, + pParam->taskId); SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR); } } - + if (NULL == pTask) { - SCH_JOB_ELOG("task not found in execList & succList, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId, pParam->taskId); + SCH_JOB_ELOG("task not found in execList & succList, refId:%" PRIx64 ", taskId:%" PRIx64, pParam->refId, + pParam->taskId); SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR); } @@ -1444,7 +1445,7 @@ int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) { } int32_t schGenerateTaskCallBackAHandle(SSchJob *pJob, SSchTask *pTask, int32_t msgType, SMsgSendInfo **pMsgSendInfo) { - int32_t code = 0; + int32_t code = 0; SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == msgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); @@ -1565,7 +1566,7 @@ _return: } int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { - int32_t code = 0; + int32_t code = 0; SMsgSendInfo *pReadyMsgSendInfo = NULL; SMsgSendInfo *pExplainMsgSendInfo = NULL; @@ -1578,7 +1579,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SCH_ERR_JRET(schGenerateTaskCallBackAHandle(pJob, pTask, TDMT_VND_RES_READY, &pReadyMsgSendInfo)); SCH_ERR_JRET(schGenerateTaskCallBackAHandle(pJob, pTask, TDMT_VND_EXPLAIN, &pExplainMsgSendInfo)); - int32_t msgType = TDMT_VND_RES_READY_RSP; + int32_t msgType = TDMT_VND_RES_READY_RSP; SRpcCtxVal ctxVal = {.val = pReadyMsgSendInfo, .clone = schCloneSMsgSendInfo, .freeFunc = schFreeRpcCtxVal}; if (taosHashPut(pCtx->args, &msgType, sizeof(msgType), &ctxVal, sizeof(ctxVal))) { SCH_TASK_ELOG("taosHashPut msg %d to rpcCtx failed", msgType); @@ -1599,7 +1600,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { _return: taosHashCleanup(pCtx->args); - + if (pReadyMsgSendInfo) { taosMemoryFreeClear(pReadyMsgSendInfo->param); taosMemoryFreeClear(pReadyMsgSendInfo); @@ -1818,7 +1819,7 @@ _return: taosMemoryFreeClear(pMsgSendInfo->param); taosMemoryFreeClear(pMsgSendInfo); } - + SCH_RET(code); } @@ -2319,7 +2320,7 @@ _return: } int32_t schExecStaticExplain(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, - bool syncSchedule) { + bool syncSchedule) { qDebug("QID:0x%" PRIx64 " job started", pDag->queryId); int32_t code = 0; @@ -2608,7 +2609,7 @@ int32_t schedulerFetchRows(int64_t job, void **pData) { if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) { SCH_ERR_JRET(schFetchFromRemote(pJob)); tsem_wait(&pJob->rspSem); - } + } } else { SCH_JOB_ELOG("job status error for fetch, status:%s", jobTaskStatusStr(status)); SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR); @@ -2670,11 +2671,11 @@ int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub) { for (int32_t i = pJob->levelNum - 1; i >= 0; --i) { SSchLevel *pLevel = taosArrayGet(pJob->levels, i); - + for (int32_t m = 0; m < pLevel->taskNum; ++m) { - SSchTask *pTask = taosArrayGet(pLevel->subTasks, m); + SSchTask *pTask = taosArrayGet(pLevel->subTasks, m); SQuerySubDesc subDesc = {.tid = pTask->taskId, .status = pTask->status}; - + taosArrayPush(pSub, &subDesc); } } @@ -2682,7 +2683,6 @@ int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub) { return TSDB_CODE_SUCCESS; } - int32_t scheduleCancelJob(int64_t job) { SSchJob *pJob = schAcquireJob(job); if (NULL == pJob) { @@ -2738,11 +2738,10 @@ void schedulerDestroy(void) { while (pJob) { taosRemoveRef(schMgmt.jobRef, pJob->refId); - pJob = taosIterateRef(schMgmt.jobRef, pJob->refId); + pJob = taosIterateRef(schMgmt.jobRef, pJob); } taosCloseRef(schMgmt.jobRef); schMgmt.jobRef = 0; } } - From e61d176305593323a950b35e0b26bec68a8550cd Mon Sep 17 00:00:00 2001 From: cpwu Date: Fri, 15 Apr 2022 16:48:19 +0800 Subject: [PATCH 45/48] fix stddev.case --- tests/script/tsim/query/stddev.sim | 515 +++++++++++++++++++++++------ 1 file changed, 408 insertions(+), 107 deletions(-) diff --git a/tests/script/tsim/query/stddev.sim b/tests/script/tsim/query/stddev.sim index 70a9719b40..74bc444da2 100644 --- a/tests/script/tsim/query/stddev.sim +++ b/tests/script/tsim/query/stddev.sim @@ -1,17 +1,16 @@ system sh/stop_dnodes.sh - system sh/deploy.sh -n dnode1 -i 1 -system sh/cfg.sh -n dnode1 -c walLevel -v 1 system sh/exec.sh -n dnode1 -s start $loop_cnt = 0 check_dnode_ready: - $loop_cnt = $loop_cnt + 1 - sleep 200 - if $loop_cnt == 10 then - print ====> dnode not ready! - return -1 - endi + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + sql show dnodes print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 if $data00 != 1 then @@ -23,108 +22,410 @@ endi sql connect -$dbPrefix = db -$tbPrefix = ctb -$mtPrefix = stb -$tbNum = 10 -$rowNum = 20 -$totalNum = 200 - -print =============== step1 -$i = 0 -$db = $dbPrefix . $i -$mt = $mtPrefix . $i - -sql drop database $db -x step1 -step1: -sql create database $db -sql use $db -sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) - -$i = 0 -while $i < $tbNum - $tb = $tbPrefix . $i - sql create table $tb using $mt tags( $i ) - - $x = 0 - while $x < $rowNum - $cc = $x * 60000 - $ms = 1601481600000 + $cc - - sql insert into $tb values ($ms , $x ) - $x = $x + 1 - endw - - $i = $i + 1 -endw - -sleep 100 - -print =============== step2 -$i = 1 -$tb = $tbPrefix . $i - -sql select stddev(tbcol) from $tb -print ===> $data00 -if $data00 != 5.766281297 then - return -1 -endi - -print =============== step3 -$cc = 4 * 60000 -$ms = 1601481600000 + $cc - -print ===> select stddev(tbcol) from $tb where ts <= $ms -sql select stddev(tbcol) from $tb where ts <= $ms -print ====> $data00 $data01 $data02 $data03 $data04 $data05 -if $data00 != 1.414213562 then - return -1 -endi - -print =============== step4 -sql select stddev(tbcol) as b from $tb -print ===> $data00 -if $data00 != 5.766281297 then - return -1 -endi - -print =============== step5 -sql select _wstartts, stddev(tbcol) as b from $tb interval(1m) -print ===> $data01 -if $data01 != 0.000000000 then - print expect 0.000000000, actual: $data01 - return -1 -endi - -sql select _wstartts, stddev(tbcol) as b from $tb interval(1d) -print ===> $data01 -if $data01 != 5.766281297 then - return -1 -endi - -print =============== step6 -$cc = 4 * 60000 -$ms = 1601481600000 + $cc - -print select _wstartts, stddev(tbcol) as b from $tb where ts <= $ms interval(1m) -sql select _wstartts, stddev(tbcol) as b from $tb where ts <= $ms interval(1m) -print ===> $data01 -if $data01 != 0.000000000 then - return -1 -endi - -print $data00 , $data10 , $data20 , $data30 , $data40 , $data50 , $data60 - -if $rows != 5 then - print expect 5, actual: $rows - return -1 -endi - -print =============== clear -sql drop database $db +print =============== create database +sql create database db sql show databases +if $rows != 3 then + return -1 +endi + +sql use db + +print =============== create super table and child table +sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int) +sql show stables +print $rows $data00 $data01 $data02 if $rows != 1 then return -1 endi +sql create table ct1 using stb1 tags ( 1 ) +sql create table ct2 using stb1 tags ( 2 ) +sql create table ct3 using stb1 tags ( 3 ) +sql create table ct4 using stb1 tags ( 4 ) +sql show tables +print $rows $data00 $data10 $data20 +if $rows != 4 then + return -1 +endi + +sql create table t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + +print =============== insert data into child table ct1 (s) +sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a ) +sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a ) + +print =============== insert data into child table ct4 (y) +sql insert into ct4 values ( '2019-01-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) +sql insert into ct4 values ( '2019-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into ct4 values ( '2019-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into ct4 values ( '2020-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into ct4 values ( '2020-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into ct4 values ( '2020-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into ct4 values ( '2020-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) +sql insert into ct4 values ( '2021-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into ct4 values ( '2021-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into ct4 values ( '2021-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) +sql insert into ct4 values ( '2022-02-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) +sql insert into ct4 values ( '2022-05-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + +print =============== insert data into child table t1 +sql insert into t1 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a ) +sql insert into t1 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a ) +sql insert into t1 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a ) +sql insert into t1 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a ) +sql insert into t1 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a ) +sql insert into t1 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a ) +sql insert into t1 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) +sql insert into t1 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) +sql insert into t1 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + +print ================ start query ====================== + +print =============== step1 +print =====sql : select stddev(c1) as b from ct4 +sql select stddev(c1) as b from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1) as b from t1 +sql select stddev(c1) as b from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select _wstartts, stddev(c1) as b from ct4 interval(1y) +sql select _wstartts, stddev(c1) as b from ct4 interval(1y) +print ===> $rows +if $rows != 4 then + return -1 +endi + +print =====sql : select _wstartts, stddev(c1) as b from t1 interval(1y) +sql select _wstartts, stddev(c1) as b from t1 interval(1y) +print ===> $rows +if $rows != 3 then + return -1 +endi + +print =====select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) +sql select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) +# print ===> $rows +# if $rows != 3 then +# return -1 +# endi + +print =====select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) +sql select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) +# print ===> $rows +# if $rows != 3 then +# return -1 +# endi + +print =====sql : select stddev(c1) a1, sum(c1) b1 from ct4 +sql select stddev(c1) a1, sum(c1) b1 from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1) a1, sum(c1) b1 from t1 +sql select stddev(c1) a1, sum(c1) b1 from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1)+sum(c1) b1 from ct4 +sql select stddev(c1)+sum(c1) b1 from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1)+sum(c1) b1 from t1 +sql select stddev(c1)+sum(c1) b1 from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c2) from ct4 +sql select stddev(c2) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c2) from t1 +sql select stddev(c2) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c3) from ct4 +sql select stddev(c3) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c3) from t1 +sql select stddev(c3) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c4) from ct4 +sql select stddev(c4) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c4) from t1 +sql select stddev(c4) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c5) from ct4 +sql select stddev(c5) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c5) from t1 +sql select stddev(c5) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c6) from ct4 +sql select stddev(c6) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c6) from t1 +sql select stddev(c6) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c7) from ct4 +sql_error select stddev(c7) from ct4 +# print ===> $rows +# if $rows != 1 then +# return -1 +# endi + +print =====sql : select stddev(c7) from t1 +sql_error select stddev(c7) from t1 +# print ===> $rows +# if $rows != 1 then +# return -1 +# endi + +#================================================= +print =============== stop and restart taosd system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready_0: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready_0 +endi + +print =============== step2 after wal +print =====sql : select stddev(c1) as b from ct4 +sql select stddev(c1) as b from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1) as b from t1 +sql select stddev(c1) as b from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select _wstartts, stddev(c1) as b from ct4 interval(1y) +sql select _wstartts, stddev(c1) as b from ct4 interval(1y) +print ===> $rows +if $rows != 4 then + return -1 +endi + +print =====sql : select _wstartts, stddev(c1) as b from t1 interval(1y) +sql select _wstartts, stddev(c1) as b from t1 interval(1y) +print ===> $rows +if $rows != 3 then + return -1 +endi + +print =====select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) +sql select _wstartts, stddev(c1) as b from ct4 where c1 <= 6 interval(180d) +print ===> $rows +if $rows != 3 then + return -1 +endi + +print =====select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) +sql select _wstartts, stddev(c1) as b from t1 where c1 <= 6 interval(180d) +print ===> $rows +if $rows != 3 then + return -1 +endi + +print =====sql : select stddev(c1) a1, sum(c1) b1 from ct4 +sql select stddev(c1) a1, sum(c1) b1 from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1) a1, sum(c1) b1 from t1 +sql select stddev(c1) a1, sum(c1) b1 from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1)+sum(c1) b1 from ct4 +sql select stddev(c1)+sum(c1) b1 from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c1)+sum(c1) b1 from t1 +sql select stddev(c1)+sum(c1) b1 from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c2) from ct4 +sql select stddev(c2) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c2) from t1 +sql select stddev(c2) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c3) from ct4 +sql select stddev(c3) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c3) from t1 +sql select stddev(c3) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c4) from ct4 +sql select stddev(c4) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c4) from t1 +sql select stddev(c4) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c5) from ct4 +sql select stddev(c5) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c5) from t1 +sql select stddev(c5) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c6) from ct4 +sql select stddev(c6) from ct4 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c6) from t1 +sql select stddev(c6) from t1 +print ===> $rows +if $rows != 1 then + return -1 +endi + +print =====sql : select stddev(c7) from ct4 +sql_error select stddev(c7) from ct4 +# print ===> $rows +# if $rows != 1 then +# return -1 +# endi + +print =====sql : select stddev(c7) from t1 +sql_error select stddev(c7) from t1 +# print ===> $rows +# if $rows != 1 then +# return -1 +# endi + +print =============== clear +sql drop database db +sql show databases +if $rows != 2 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From 911c81d230cd8c622c8018284d6797965baf6cd9 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 15 Apr 2022 17:12:31 +0800 Subject: [PATCH 46/48] fix scheduler quit issue --- source/libs/scheduler/src/scheduler.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 9b652f2795..4e59e1bea6 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -2734,11 +2734,14 @@ void schedulerFreeTaskList(SArray *taskList) { void schedulerDestroy(void) { if (schMgmt.jobRef) { SSchJob *pJob = taosIterateRef(schMgmt.jobRef, 0); - + int64_t refId = 0; + while (pJob) { + refId = pJob->refId; + taosRemoveRef(schMgmt.jobRef, pJob->refId); - pJob = taosIterateRef(schMgmt.jobRef, pJob); + pJob = taosIterateRef(schMgmt.jobRef, refId); } taosCloseRef(schMgmt.jobRef); From 5029cd67b2275789b9a79682b30785bd1fa19b22 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Apr 2022 18:06:49 +0800 Subject: [PATCH 47/48] ehn(query): add the file data block load optimization check. --- include/libs/function/functionMgt.h | 8 +++--- source/libs/executor/inc/executil.h | 4 --- source/libs/executor/inc/executorimpl.h | 10 ++------ source/libs/executor/src/executorimpl.c | 30 ++++++++++------------ source/libs/executor/src/scanoperator.c | 14 ++++++---- source/libs/function/src/builtinsimpl.c | 4 +-- source/libs/function/src/functionMgt.c | 4 +-- source/libs/planner/src/planLogicCreater.c | 2 +- source/libs/planner/src/planOptimizer.c | 14 +++++----- 9 files changed, 41 insertions(+), 49 deletions(-) diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index a471de3147..992b99df60 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -139,10 +139,10 @@ bool fmIsSpecialDataRequiredFunc(int32_t funcId); bool fmIsDynamicScanOptimizedFunc(int32_t funcId); typedef enum EFuncDataRequired { - FUNC_DATA_REQUIRED_ALL_NEEDED = 1, - FUNC_DATA_REQUIRED_STATIS_NEEDED, - FUNC_DATA_REQUIRED_NO_NEEDED, - FUNC_DATA_REQUIRED_DISCARD + FUNC_DATA_REQUIRED_DATA_LOAD = 1, + FUNC_DATA_REQUIRED_STATIS_LOAD, + FUNC_DATA_REQUIRED_NOT_LOAD, + FUNC_DATA_REQUIRED_FILTEROUT, } EFuncDataRequired; EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow); diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index 8d88b94d6c..1f3c003dfb 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -42,10 +42,6 @@ #define curTimeWindowIndex(_winres) ((_winres)->curIndex) -struct SColumnFilterElem; - -typedef bool (*__filter_func_t)(struct SColumnFilterElem* pFilter, const char* val1, const char* val2, int16_t type); - typedef struct SGroupResInfo { int32_t totalGroup; int32_t currentGroup; diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 78bc6947cd..ea2939055e 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -38,8 +38,6 @@ extern "C" { #include "tpagedbuf.h" #include "tmsg.h" -struct SColumnFilterElem; - typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order); #define IS_QUERY_KILLED(_q) ((_q)->code == TSDB_CODE_TSC_QUERY_CANCELLED) @@ -225,8 +223,6 @@ typedef struct STaskRuntimeEnv { void* qinfo; uint8_t scanFlag; // denotes reversed scan of data or not void* pTsdbReadHandle; - - int32_t prevGroupId; // previous executed group id bool enableGroupData; SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file SHashObj* pResultRowHashTable; // quick locate the window object for each result @@ -241,8 +237,6 @@ typedef struct STaskRuntimeEnv { char* tagVal; // tag value of current data block struct SScalarFunctionSupport* scalarSup; - - SSDataBlock* outputBuf; STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray structure struct SOperatorInfo* proot; SGroupResInfo groupResInfo; @@ -250,7 +244,6 @@ typedef struct STaskRuntimeEnv { STableQueryInfo* current; SResultInfo resultInfo; - SHashObj* pTableRetrieveTsMap; struct SUdfInfo* pUdfInfo; } STaskRuntimeEnv; @@ -350,6 +343,7 @@ typedef struct STableScanInfo { int64_t elapsedTime; int32_t prevGroupId; // previous table group id int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan + int32_t dataBlockLoadFlag; } STableScanInfo; typedef struct STagScanInfo { @@ -616,7 +610,7 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock); SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset); SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t repeatTime, +SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfCols, int32_t dataLoadFlag, int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition, SExecTaskInfo* pTaskInfo); SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index c911aef45f..cfa17ecd3c 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -271,7 +271,7 @@ static int compareRowData(const void* a, const void* b, const void* userData) { } // setup the output buffer for each operator -SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) { +SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) { int32_t numOfCols = LIST_LENGTH(pNode->pSlots); SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); @@ -6518,8 +6518,6 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator, bool* newgroup) { SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput) { STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo)); - // pInfo->pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->capacity); - size_t numOfGroup = GET_NUM_OF_TABLEGROUP(pRuntimeEnv); assert(numOfGroup == 0 || numOfGroup == 1); @@ -6747,13 +6745,13 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); - SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc); - return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pScanPhyNode->count, + return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, dataLoadFlag, pScanPhyNode->count, pScanPhyNode->reverse, pColList, pResBlock, pScanPhyNode->node.pConditions, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) { SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode; - SSDataBlock* pResBlock = createOutputBuf_rv1(pExchange->node.pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pExchange->node.pOutputDataBlockDesc); return createExchangeOperatorInfo(pExchange->pSrcEndPoints, pResBlock, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) { SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; // simple child table. @@ -6761,7 +6759,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo int32_t code = doCreateTableGroup(pHandle->meta, pScanPhyNode->tableType, pScanPhyNode->uid, pTableGroupInfo, queryId, taskId); SArray* tableIdList = extractTableIdList(pTableGroupInfo); - SSDataBlock* pResBlock = createOutputBuf_rv1(pScanPhyNode->node.pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc); int32_t numOfCols = 0; SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); @@ -6770,7 +6768,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return pOperator; } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) { SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode; - SSDataBlock* pResBlock = createOutputBuf_rv1(pSysScanPhyNode->scan.node.pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pSysScanPhyNode->scan.node.pOutputDataBlockDesc); struct SScanPhysiNode* pScanNode = &pSysScanPhyNode->scan; SArray* colList = extractScanColumnId(pScanNode->pScanCols); @@ -6799,14 +6797,14 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SProjectPhysiNode* pProjPhyNode = (SProjectPhysiNode*) pPhyNode; SExprInfo* pExprInfo = createExprInfo(pProjPhyNode->pProjections, NULL, &num); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SLimit limit = {.limit = pProjPhyNode->limit, .offset = pProjPhyNode->offset}; SLimit slimit = {.limit = pProjPhyNode->slimit, .offset = pProjPhyNode->soffset}; pOptr = createProjectOperatorInfo(ops[0], pExprInfo, num, pResBlock, &limit, &slimit, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_AGG == type) { SAggPhysiNode* pAggNode = (SAggPhysiNode*)pPhyNode; SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SExprInfo* pScalarExprInfo = NULL; int32_t numOfScalarExpr = 0; @@ -6824,7 +6822,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &num); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SInterval interval = { .interval = pIntervalPhyNode->interval, @@ -6840,7 +6838,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } else if (QUERY_NODE_PHYSICAL_PLAN_SORT == type) { SSortPhysiNode* pSortPhyNode = (SSortPhysiNode*)pPhyNode; - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SArray* info = createSortInfo(pSortPhyNode->pSortKeys, pSortPhyNode->pTargets); SArray* slotMap = createIndexMap(pSortPhyNode->pTargets); pOptr = createSortOperatorInfo(ops[0], pResBlock, info, slotMap, pTaskInfo); @@ -6848,12 +6846,12 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode; SExprInfo* pExprInfo = createExprInfo(pSessionNode->window.pFuncs, NULL, &num); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); pOptr = createSessionAggOperatorInfo(ops[0], pExprInfo, num, pResBlock, pSessionNode->gap, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_PARTITION == type) { SPartitionPhysiNode* pPartNode = (SPartitionPhysiNode*) pPhyNode; SArray* pColList = extractPartitionColInfo(pPartNode->pPartitionKeys); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &num); pOptr = createPartitionOperatorInfo(ops[0], pExprInfo, num, pResBlock, pColList, pTaskInfo, NULL); @@ -6861,11 +6859,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SStateWinodwPhysiNode* pStateNode = (SStateWinodwPhysiNode*) pPhyNode; SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num); - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); pOptr = createStatewindowOperatorInfo(ops[0], pExprInfo, num, pResBlock, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_JOIN == type) { SJoinPhysiNode* pJoinNode = (SJoinPhysiNode*) pPhyNode; - SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); SExprInfo* pExprInfo = createExprInfo(pJoinNode->pTargets, NULL, &num); pOptr = createJoinOperatorInfo(ops, size, pExprInfo, num, pResBlock, pJoinNode->pOnConditions, pTaskInfo); diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 901bfde6a4..a2e68e34f1 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -64,16 +64,19 @@ static void setupQueryRangeForReverseScan(STableScanInfo* pTableScanInfo) { #endif } -int32_t loadDataBlock(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) { +int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, uint32_t* status) { + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + STableScanInfo* pInfo = pOperator->info; + STaskCostInfo* pCost = &pTaskInfo->cost; pCost->totalBlocks += 1; + pCost->loadBlocks += 1; + pCost->totalRows += pBlock->info.rows; - pCost->totalCheckedRows += pBlock->info.rows; - pCost->loadBlocks += 1; - *status = BLK_DATA_DATA_LOAD; + *status = pInfo->dataBlockLoadFlag; SArray* pCols = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL); if (pCols == NULL) { @@ -217,7 +220,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator, bool* newgroup) { return p; } -SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, +SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, int32_t dataLoadFlag, int32_t repeatTime, int32_t reverseTime, SArray* pColMatchInfo, SSDataBlock* pResBlock, SNode* pCondition, SExecTaskInfo* pTaskInfo) { assert(repeatTime > 0); @@ -232,6 +235,7 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, return NULL; } + pInfo->dataBlockLoadFlag= dataLoadFlag; pInfo->pResBlock = pResBlock; pInfo->pFilterNode = pCondition; pInfo->dataReader = pTsdbReadHandle; diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 50c65439c0..71e8bcc842 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -58,9 +58,9 @@ void functionFinalize(SqlFunctionCtx *pCtx) { EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) { SNode* pParam = nodesListGetNode(pFunc->pParameterList, 0); if (QUERY_NODE_COLUMN == nodeType(pParam) && PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pParam)->colId) { - return FUNC_DATA_REQUIRED_NO_NEEDED; + return FUNC_DATA_REQUIRED_NOT_LOAD; } - return FUNC_DATA_REQUIRED_STATIS_NEEDED; + return FUNC_DATA_REQUIRED_STATIS_LOAD; } bool getCountFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index aec75a0365..d0af3487ce 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -78,10 +78,10 @@ int32_t fmGetFuncResultType(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow) { if (pFunc->funcId < 0 || pFunc->funcId >= funcMgtBuiltinsNum) { - return FUNC_DATA_REQUIRED_ALL_NEEDED; + return FUNC_DATA_REQUIRED_DATA_LOAD; } if (NULL == funcMgtBuiltins[pFunc->funcId].dataRequiredFunc) { - return FUNC_DATA_REQUIRED_ALL_NEEDED; + return FUNC_DATA_REQUIRED_DATA_LOAD; } return funcMgtBuiltins[pFunc->funcId].dataRequiredFunc(pFunc, pTimeWindow); } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 3c60b62434..fd0d2758bf 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -200,7 +200,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect strcpy(pScan->tableName.tname, pRealTable->table.tableName); pScan->showRewrite = pCxt->pPlanCxt->showRewrite; pScan->ratio = pRealTable->ratio; - pScan->dataRequired = FUNC_DATA_REQUIRED_ALL_NEEDED; + pScan->dataRequired = FUNC_DATA_REQUIRED_DATA_LOAD; // set columns to scan SNodeList* pCols = NULL; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 19e6718fe8..a8513bf376 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -125,12 +125,12 @@ static int32_t osdMatch(SOptimizeContext* pCxt, SLogicNode* pLogicNode, SOsdInfo static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l , EFuncDataRequired r) { switch (l) { - case FUNC_DATA_REQUIRED_ALL_NEEDED: + case FUNC_DATA_REQUIRED_DATA_LOAD: return l; - case FUNC_DATA_REQUIRED_STATIS_NEEDED: - return FUNC_DATA_REQUIRED_ALL_NEEDED == r ? r : l; - case FUNC_DATA_REQUIRED_NO_NEEDED: - return FUNC_DATA_REQUIRED_DISCARD == r ? l : r; + case FUNC_DATA_REQUIRED_STATIS_LOAD: + return FUNC_DATA_REQUIRED_DATA_LOAD == r ? r : l; + case FUNC_DATA_REQUIRED_NOT_LOAD: + return FUNC_DATA_REQUIRED_FILTEROUT == r ? l : r; default: break; } @@ -139,9 +139,9 @@ static EFuncDataRequired osdPromoteDataRequired(EFuncDataRequired l , EFuncDataR static int32_t osdGetDataRequired(SNodeList* pFuncs) { if (NULL == pFuncs) { - return FUNC_DATA_REQUIRED_ALL_NEEDED; + return FUNC_DATA_REQUIRED_DATA_LOAD; } - EFuncDataRequired dataRequired = FUNC_DATA_REQUIRED_DISCARD; + EFuncDataRequired dataRequired = FUNC_DATA_REQUIRED_FILTEROUT; SNode* pFunc = NULL; FOREACH(pFunc, pFuncs) { dataRequired = osdPromoteDataRequired(dataRequired, fmFuncDataRequired((SFunctionNode*)pFunc, NULL)); From 078c48a50a7ff449f21ab8604250a2eed3154e78 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Apr 2022 18:25:24 +0800 Subject: [PATCH 48/48] other:fix syntax error. --- source/libs/executor/src/executorimpl.c | 5 +++-- source/libs/executor/src/scanoperator.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index cfa17ecd3c..3e2f95a27c 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -6737,9 +6737,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo int32_t type = nodeType(pPhyNode); if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) { SScanPhysiNode* pScanPhyNode = (SScanPhysiNode*)pPhyNode; + STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode* ) pPhyNode; int32_t numOfCols = 0; - tsdbReaderT pDataReader = doCreateDataReader((STableScanPhysiNode*)pPhyNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId); + tsdbReaderT pDataReader = doCreateDataReader(pTableScanNode, pHandle, pTableGroupInfo, (uint64_t)queryId, taskId); if (pDataReader == NULL) { return NULL; } @@ -6747,7 +6748,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo SArray* pColList = extractColMatchInfo(pScanPhyNode->pScanCols, pScanPhyNode->node.pOutputDataBlockDesc, &numOfCols); SSDataBlock* pResBlock = createResDataBlock(pScanPhyNode->node.pOutputDataBlockDesc); - return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, dataLoadFlag, pScanPhyNode->count, + return createTableScanOperatorInfo(pDataReader, pScanPhyNode->order, numOfCols, pTableScanNode->dataRequired, pScanPhyNode->count, pScanPhyNode->reverse, pColList, pResBlock, pScanPhyNode->node.pConditions, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_EXCHANGE == type) { SExchangePhysiNode* pExchange = (SExchangePhysiNode*)pPhyNode; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index a2e68e34f1..3de9d9020e 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -142,7 +142,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) { // this function never returns error? uint32_t status = BLK_DATA_DATA_LOAD; - int32_t code = loadDataBlock(pTaskInfo, pTableScanInfo, pBlock, &status); + int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status); // int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { longjmp(pOperator->pTaskInfo->env, code);