提交 db796f9e 编写于 作者: L Liu Jicong

merge from 3.0

...@@ -57,6 +57,8 @@ typedef enum { ...@@ -57,6 +57,8 @@ typedef enum {
TD_ROW_PARTIAL_UPDATE = 2, TD_ROW_PARTIAL_UPDATE = 2,
} TDUpdateConfig; } TDUpdateConfig;
#define TD_SUPPORT_UPDATE(u) ((u) > 0)
typedef enum { typedef enum {
TSDB_STATIS_OK = 0, // statis part exist and load successfully TSDB_STATIS_OK = 0, // statis part exist and load successfully
TSDB_STATIS_NONE = 1, // statis part not exist TSDB_STATIS_NONE = 1, // statis part not exist
......
...@@ -482,7 +482,7 @@ void tdResetDataCols(SDataCols *pCols); ...@@ -482,7 +482,7 @@ void tdResetDataCols(SDataCols *pCols);
int32_t tdInitDataCols(SDataCols *pCols, STSchema *pSchema); int32_t tdInitDataCols(SDataCols *pCols, STSchema *pSchema);
SDataCols *tdDupDataCols(SDataCols *pCols, bool keepData); SDataCols *tdDupDataCols(SDataCols *pCols, bool keepData);
SDataCols *tdFreeDataCols(SDataCols *pCols); SDataCols *tdFreeDataCols(SDataCols *pCols);
int32_t tdMergeDataCols(SDataCols *target, SDataCols *source, int32_t rowsToMerge, int32_t *pOffset, bool forceSetNull); int32_t tdMergeDataCols(SDataCols *target, SDataCols *source, int32_t rowsToMerge, int32_t *pOffset, bool forceSetNull, TDRowVerT maxVer);
// ----------------- K-V data row structure // ----------------- K-V data row structure
/* |<-------------------------------------- len -------------------------------------------->| /* |<-------------------------------------- len -------------------------------------------->|
......
...@@ -230,7 +230,7 @@ static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowVa ...@@ -230,7 +230,7 @@ static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowVa
static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val, static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val,
bool isCopyVarData, int8_t colType, int16_t colIdx, int32_t offset, bool isCopyVarData, int8_t colType, int16_t colIdx, int32_t offset,
col_id_t colId); col_id_t colId);
int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols, bool forceSetNull); int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols);
/** /**
* @brief * @brief
......
...@@ -27,6 +27,7 @@ extern "C" { ...@@ -27,6 +27,7 @@ extern "C" {
typedef int32_t VarDataOffsetT; typedef int32_t VarDataOffsetT;
typedef uint32_t TDRowLenT; typedef uint32_t TDRowLenT;
typedef uint8_t TDRowValT; typedef uint8_t TDRowValT;
typedef uint64_t TDRowVerT;
typedef int16_t col_id_t; typedef int16_t col_id_t;
typedef int8_t col_type_t; typedef int8_t col_type_t;
typedef int32_t col_bytes_t; typedef int32_t col_bytes_t;
......
...@@ -22,7 +22,7 @@ typedef struct SExplainCtx SExplainCtx; ...@@ -22,7 +22,7 @@ typedef struct SExplainCtx SExplainCtx;
int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp); int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp);
int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp); int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp);
int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int32_t startTs); int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs);
int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp); int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp);
int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t groupId, SRetrieveTableRsp **pRsp); int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t groupId, SRetrieveTableRsp **pRsp);
void qExplainFreeCtx(SExplainCtx *pCtx); void qExplainFreeCtx(SExplainCtx *pCtx);
......
...@@ -84,6 +84,7 @@ typedef struct SVnodeModifLogicNode { ...@@ -84,6 +84,7 @@ typedef struct SVnodeModifLogicNode {
typedef struct SExchangeLogicNode { typedef struct SExchangeLogicNode {
SLogicNode node; SLogicNode node;
int32_t srcGroupId; int32_t srcGroupId;
uint8_t precision;
} SExchangeLogicNode; } SExchangeLogicNode;
typedef enum EWindowType { typedef enum EWindowType {
...@@ -163,7 +164,7 @@ typedef struct SDataBlockDescNode { ...@@ -163,7 +164,7 @@ typedef struct SDataBlockDescNode {
SNodeList* pSlots; SNodeList* pSlots;
int32_t totalRowSize; int32_t totalRowSize;
int32_t outputRowSize; int32_t outputRowSize;
int16_t precision; uint8_t precision;
} SDataBlockDescNode; } SDataBlockDescNode;
typedef struct SPhysiNode { typedef struct SPhysiNode {
...@@ -253,11 +254,11 @@ typedef struct SWinodwPhysiNode { ...@@ -253,11 +254,11 @@ typedef struct SWinodwPhysiNode {
SPhysiNode node; SPhysiNode node;
SNodeList* pExprs; // these are expression list of parameter expression of function SNodeList* pExprs; // these are expression list of parameter expression of function
SNodeList* pFuncs; SNodeList* pFuncs;
SNode* pTspk; // timestamp primary key
} SWinodwPhysiNode; } SWinodwPhysiNode;
typedef struct SIntervalPhysiNode { typedef struct SIntervalPhysiNode {
SWinodwPhysiNode window; SWinodwPhysiNode window;
SNode* pTspk; // timestamp primary key
int64_t interval; int64_t interval;
int64_t offset; int64_t offset;
int64_t sliding; int64_t sliding;
...@@ -274,7 +275,7 @@ typedef struct SMultiTableIntervalPhysiNode { ...@@ -274,7 +275,7 @@ typedef struct SMultiTableIntervalPhysiNode {
typedef struct SSessionWinodwPhysiNode { typedef struct SSessionWinodwPhysiNode {
SWinodwPhysiNode window; SWinodwPhysiNode window;
int64_t gap; int64_t gap;
} SSessionWinodwPhysiNode; } SSessionWinodwPhysiNode;
typedef struct SStateWinodwPhysiNode { typedef struct SStateWinodwPhysiNode {
......
...@@ -190,6 +190,7 @@ typedef struct SLimitNode { ...@@ -190,6 +190,7 @@ typedef struct SLimitNode {
typedef struct SStateWindowNode { typedef struct SStateWindowNode {
ENodeType type; // QUERY_NODE_STATE_WINDOW ENodeType type; // QUERY_NODE_STATE_WINDOW
SNode* pCol; // timestamp primary key
SNode* pExpr; SNode* pExpr;
} SStateWindowNode; } SStateWindowNode;
......
...@@ -44,7 +44,7 @@ extern "C" { ...@@ -44,7 +44,7 @@ extern "C" {
typedef struct TdFile *TdFilePtr; typedef struct TdFile *TdFilePtr;
#define TD_FILE_CTEATE 0x0001 #define TD_FILE_CREATE 0x0001
#define TD_FILE_WRITE 0x0002 #define TD_FILE_WRITE 0x0002
#define TD_FILE_READ 0x0004 #define TD_FILE_READ 0x0004
#define TD_FILE_TRUNC 0x0008 #define TD_FILE_TRUNC 0x0008
......
...@@ -84,10 +84,10 @@ typedef struct { ...@@ -84,10 +84,10 @@ typedef struct {
} SClientHbMgr; } SClientHbMgr;
typedef struct SQueryExecMetric { typedef struct SQueryExecMetric {
int64_t start; // start timestamp int64_t start; // start timestamp, us
int64_t parsed; // start to parse int64_t parsed; // start to parse, us
int64_t send; // start to send to server int64_t send; // start to send to server, us
int64_t rsp; // receive response from server int64_t rsp; // receive response from server, us
} SQueryExecMetric; } SQueryExecMetric;
typedef struct SInstanceSummary { typedef struct SInstanceSummary {
...@@ -276,14 +276,13 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, ...@@ -276,14 +276,13 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
uint16_t port); uint16_t port);
int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery); int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery);
int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList); int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList);
int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest); int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest);
void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr); void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4);
void doSetOneRowPtr(SReqResultInfo* pResultInfo); void doSetOneRowPtr(SReqResultInfo* pResultInfo);
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows); 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 setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp); int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp);
......
...@@ -65,10 +65,10 @@ static void deregisterRequest(SRequestObj *pRequest) { ...@@ -65,10 +65,10 @@ static void deregisterRequest(SRequestObj *pRequest) {
int32_t currentInst = atomic_sub_fetch_64(&pActivity->currentRequests, 1); int32_t currentInst = atomic_sub_fetch_64(&pActivity->currentRequests, 1);
int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1); int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1);
int64_t duration = taosGetTimestampMs() - pRequest->metric.start; int64_t duration = taosGetTimestampUs() - pRequest->metric.start;
tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%" PRIu64 tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%" PRIu64
" ms, current:%d, app current:%d", " ms, current:%d, app current:%d",
pRequest->self, pTscObj->id, pRequest->requestId, duration, num, currentInst); pRequest->self, pTscObj->id, pRequest->requestId, duration/1000, num, currentInst);
taosReleaseRef(clientConnRefPool, pTscObj->id); taosReleaseRef(clientConnRefPool, pTscObj->id);
} }
...@@ -152,7 +152,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty ...@@ -152,7 +152,7 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
pRequest->resType = RES_TYPE__QUERY; pRequest->resType = RES_TYPE__QUERY;
pRequest->pDb = getDbOfConnection(pObj); pRequest->pDb = getDbOfConnection(pObj);
pRequest->requestId = generateRequestId(); pRequest->requestId = generateRequestId();
pRequest->metric.start = taosGetTimestampMs(); pRequest->metric.start = taosGetTimestampUs();
pRequest->type = type; pRequest->type = type;
pRequest->pTscObj = pObj; pRequest->pTscObj = pObj;
......
...@@ -435,11 +435,11 @@ static int32_t hbCreateThread() { ...@@ -435,11 +435,11 @@ static int32_t hbCreateThread() {
taosThreadAttrInit(&thAttr); taosThreadAttrInit(&thAttr);
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
// if (taosThreadCreate(&clientHbMgr.thread, &thAttr, hbThreadFunc, NULL) != 0) { if (taosThreadCreate(&clientHbMgr.thread, &thAttr, hbThreadFunc, NULL) != 0) {
// terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
// return -1; return -1;
// } }
// taosThreadAttrDestroy(&thAttr); taosThreadAttrDestroy(&thAttr);
return 0; return 0;
} }
...@@ -500,8 +500,6 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) { ...@@ -500,8 +500,6 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
} }
void appHbMgrCleanup(void) { void appHbMgrCleanup(void) {
taosThreadMutexLock(&clientHbMgr.lock);
int sz = taosArrayGetSize(clientHbMgr.appHbMgrs); int sz = taosArrayGetSize(clientHbMgr.appHbMgrs);
for (int i = 0; i < sz; i++) { for (int i = 0; i < sz; i++) {
SAppHbMgr *pTarget = taosArrayGetP(clientHbMgr.appHbMgrs, i); SAppHbMgr *pTarget = taosArrayGetP(clientHbMgr.appHbMgrs, i);
...@@ -510,8 +508,6 @@ void appHbMgrCleanup(void) { ...@@ -510,8 +508,6 @@ void appHbMgrCleanup(void) {
taosHashCleanup(pTarget->connInfo); taosHashCleanup(pTarget->connInfo);
pTarget->connInfo = NULL; pTarget->connInfo = NULL;
} }
taosThreadMutexUnlock(&clientHbMgr.lock);
} }
int hbMgrInit() { int hbMgrInit() {
...@@ -532,7 +528,6 @@ int hbMgrInit() { ...@@ -532,7 +528,6 @@ int hbMgrInit() {
} }
void hbMgrCleanUp() { void hbMgrCleanUp() {
#if 0
hbStopThread(); hbStopThread();
// destroy all appHbMgr // destroy all appHbMgr
...@@ -545,7 +540,6 @@ void hbMgrCleanUp() { ...@@ -545,7 +540,6 @@ void hbMgrCleanUp() {
taosThreadMutexUnlock(&clientHbMgr.lock); taosThreadMutexUnlock(&clientHbMgr.lock);
clientHbMgr.appHbMgrs = NULL; clientHbMgr.appHbMgrs = NULL;
#endif
} }
int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo *info) { int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo *info) {
......
...@@ -41,7 +41,7 @@ static char* getClusterKey(const char* user, const char* auth, const char* ip, i ...@@ -41,7 +41,7 @@ static char* getClusterKey(const char* user, const char* auth, const char* ip, i
static STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __taos_async_fn_t fp, void* param, static STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __taos_async_fn_t fp, void* param,
SAppInstInfo* pAppInfo); SAppInstInfo* pAppInfo);
static void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols);
TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db, TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db,
uint16_t port) { uint16_t port) {
...@@ -175,7 +175,7 @@ int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { ...@@ -175,7 +175,7 @@ int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
SRetrieveTableRsp* pRsp = NULL; SRetrieveTableRsp* pRsp = NULL;
int32_t code = qExecCommand(pQuery->pRoot, &pRsp); int32_t code = qExecCommand(pQuery->pRoot, &pRsp);
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) { if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp); code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, false);
} }
return code; return code;
} }
...@@ -519,7 +519,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { ...@@ -519,7 +519,7 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId); SRequestObj* pRequest = (SRequestObj*)taosAcquireRef(clientReqRefPool, pSendInfo->requestObjRefId);
assert(pRequest->self == pSendInfo->requestObjRefId); assert(pRequest->self == pSendInfo->requestObjRefId);
pRequest->metric.rsp = taosGetTimestampMs(); pRequest->metric.rsp = taosGetTimestampUs();
STscObj* pTscObj = pRequest->pTscObj; STscObj* pTscObj = pRequest->pTscObj;
if (pEpSet) { if (pEpSet) {
...@@ -535,10 +535,10 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { ...@@ -535,10 +535,10 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
int32_t elapsed = pRequest->metric.rsp - pRequest->metric.start; int32_t elapsed = pRequest->metric.rsp - pRequest->metric.start;
if (pMsg->code == TSDB_CODE_SUCCESS) { if (pMsg->code == TSDB_CODE_SUCCESS) {
tscDebug("0x%" PRIx64 " message:%s, code:%s rspLen:%d, elapsed:%d ms, reqId:0x%" PRIx64, pRequest->self, tscDebug("0x%" PRIx64 " message:%s, code:%s rspLen:%d, elapsed:%d ms, reqId:0x%" PRIx64, pRequest->self,
TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed, pRequest->requestId); TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed/1000, pRequest->requestId);
} else { } else {
tscError("0x%" PRIx64 " SQL cmd:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%" PRIx64, pRequest->self, tscError("0x%" PRIx64 " SQL cmd:%s, code:%s rspLen:%d, elapsed time:%d ms, reqId:0x%" PRIx64, pRequest->self,
TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed, pRequest->requestId); TMSG_INFO(pMsg->msgType), tstrerror(pMsg->code), pMsg->contLen, elapsed/1000, pRequest->requestId);
} }
taosReleaseRef(clientReqRefPool, pSendInfo->requestObjRefId); taosReleaseRef(clientReqRefPool, pSendInfo->requestObjRefId);
...@@ -615,7 +615,7 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) { ...@@ -615,7 +615,7 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
} }
} }
void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr) { void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4) {
assert(pRequest != NULL); assert(pRequest != NULL);
SReqResultInfo* pResultInfo = &pRequest->body.resInfo; SReqResultInfo* pResultInfo = &pRequest->body.resInfo;
...@@ -636,7 +636,7 @@ void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr) { ...@@ -636,7 +636,7 @@ void* doFetchRow(SRequestObj* pRequest, bool setupOneRowPtr) {
return NULL; return NULL;
} }
pRequest->code = setQueryResultFromRsp(&pRequest->body.resInfo, (SRetrieveTableRsp*)pResInfo->pData); pRequest->code = setQueryResultFromRsp(&pRequest->body.resInfo, (SRetrieveTableRsp*)pResInfo->pData, convertUcs4);
if (pRequest->code != TSDB_CODE_SUCCESS) { if (pRequest->code != TSDB_CODE_SUCCESS) {
pResultInfo->numOfRows = 0; pResultInfo->numOfRows = 0;
return NULL; return NULL;
...@@ -734,7 +734,42 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) { ...@@ -734,7 +734,42 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows) { static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int32_t numOfCols, int32_t* colLength) {
for (int32_t i = 0; i < numOfCols; ++i) {
int32_t type = pResultInfo->fields[i].type;
int32_t bytes = pResultInfo->fields[i].bytes;
if (type == TSDB_DATA_TYPE_NCHAR) {
char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]);
if (p == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
}
pResultInfo->convertBuf[i] = p;
SResultColumn* pCol = &pResultInfo->pCol[i];
for (int32_t j = 0; j < numOfRows; ++j) {
if (pCol->offset[j] != -1) {
char* pStart = pCol->offset[j] + pCol->pData;
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p));
ASSERT(len <= bytes);
varDataSetLen(p, len);
pCol->offset[j] = (p - pResultInfo->convertBuf[i]);
p += (len + VARSTR_HEADER_SIZE);
}
}
pResultInfo->pCol[i].pData = pResultInfo->convertBuf[i];
pResultInfo->row[i] = pResultInfo->pCol[i].pData;
}
}
return TSDB_CODE_SUCCESS;
}
int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t numOfCols, int32_t numOfRows, bool convertUcs4) {
assert(numOfCols > 0 && pFields != NULL && pResultInfo != NULL); assert(numOfCols > 0 && pFields != NULL && pResultInfo != NULL);
if (numOfRows == 0) { if (numOfRows == 0) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
...@@ -766,37 +801,11 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32 ...@@ -766,37 +801,11 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32
} }
// convert UCS4-LE encoded character to native multi-bytes character in current data block. // convert UCS4-LE encoded character to native multi-bytes character in current data block.
for (int32_t i = 0; i < numOfCols; ++i) { if (convertUcs4) {
int32_t type = pResultInfo->fields[i].type; code = doConvertUCS4(pResultInfo, numOfRows, numOfCols, colLength);
int32_t bytes = pResultInfo->fields[i].bytes;
if (type == TSDB_DATA_TYPE_NCHAR) {
char* p = taosMemoryRealloc(pResultInfo->convertBuf[i], colLength[i]);
if (p == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
}
pResultInfo->convertBuf[i] = p;
SResultColumn* pCol = &pResultInfo->pCol[i];
for (int32_t j = 0; j < numOfRows; ++j) {
if (pCol->offset[j] != -1) {
pStart = pCol->offset[j] + pCol->pData;
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(pStart), varDataLen(pStart), varDataVal(p));
ASSERT(len <= bytes);
varDataSetLen(p, len);
pCol->offset[j] = (p - pResultInfo->convertBuf[i]);
p += (len + VARSTR_HEADER_SIZE);
}
}
pResultInfo->pCol[i].pData = pResultInfo->convertBuf[i];
pResultInfo->row[i] = pResultInfo->pCol[i].pData;
}
} }
return TSDB_CODE_SUCCESS; return code;
} }
char* getDbOfConnection(STscObj* pObj) { char* getDbOfConnection(STscObj* pObj) {
...@@ -828,7 +837,7 @@ void resetConnectDB(STscObj* pTscObj) { ...@@ -828,7 +837,7 @@ void resetConnectDB(STscObj* pTscObj) {
taosThreadMutexUnlock(&pTscObj->mutex); taosThreadMutexUnlock(&pTscObj->mutex);
} }
int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp) { int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4) {
assert(pResultInfo != NULL && pRsp != NULL); assert(pResultInfo != NULL && pRsp != NULL);
pResultInfo->pRspMsg = (const char*)pRsp; pResultInfo->pRspMsg = (const char*)pRsp;
...@@ -841,5 +850,5 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR ...@@ -841,5 +850,5 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR
// TODO handle the compressed case // TODO handle the compressed case
pResultInfo->totalRows += pResultInfo->numOfRows; pResultInfo->totalRows += pResultInfo->numOfRows;
return setResultDataPtr(pResultInfo, pResultInfo->fields, pResultInfo->numOfCols, pResultInfo->numOfRows); return setResultDataPtr(pResultInfo, pResultInfo->fields, pResultInfo->numOfCols, pResultInfo->numOfRows, convertUcs4);
} }
...@@ -191,7 +191,7 @@ int32_t processRetrieveMnodeRsp(void* param, const SDataBuf* pMsg, int32_t code) ...@@ -191,7 +191,7 @@ int32_t processRetrieveMnodeRsp(void* param, const SDataBuf* pMsg, int32_t code)
pResInfo->completed = pRetrieve->completed; pResInfo->completed = pRetrieve->completed;
pResInfo->current = 0; pResInfo->current = 0;
setResultDataPtr(pResInfo, pResInfo->fields, pResInfo->numOfCols, pResInfo->numOfRows); // setResultDataPtr(pResInfo, pResInfo->fields, pResInfo->numOfCols, pResInfo->numOfRows);
tscDebug("0x%"PRIx64" numOfRows:%d, complete:%d, qId:0x%"PRIx64, pRequest->self, pRetrieve->numOfRows, tscDebug("0x%"PRIx64" numOfRows:%d, complete:%d, qId:0x%"PRIx64, pRequest->self, pRetrieve->numOfRows,
pRetrieve->completed, pRequest->body.showInfo.execId); pRetrieve->completed, pRequest->body.showInfo.execId);
...@@ -225,7 +225,7 @@ int32_t processRetrieveVndRsp(void* param, const SDataBuf* pMsg, int32_t code) { ...@@ -225,7 +225,7 @@ int32_t processRetrieveVndRsp(void* param, const SDataBuf* pMsg, int32_t code) {
pResInfo->pData = pFetchRsp->data; pResInfo->pData = pFetchRsp->data;
pResInfo->current = 0; pResInfo->current = 0;
setResultDataPtr(pResInfo, pResInfo->fields, pResInfo->numOfCols, pResInfo->numOfRows); // setResultDataPtr(pResInfo, pResInfo->fields, pResInfo->numOfCols, pResInfo->numOfRows);
tscDebug("0x%"PRIx64" numOfRows:%d, complete:%d, qId:0x%"PRIx64, pRequest->self, pFetchRsp->numOfRows, tscDebug("0x%"PRIx64" numOfRows:%d, complete:%d, qId:0x%"PRIx64, pRequest->self, pFetchRsp->numOfRows,
pFetchRsp->completed, pRequest->body.showInfo.execId); pFetchRsp->completed, pRequest->body.showInfo.execId);
......
...@@ -400,7 +400,7 @@ TEST(testCase, show_vgroup_Test) { ...@@ -400,7 +400,7 @@ TEST(testCase, show_vgroup_Test) {
taos_free_result(pRes); taos_free_result(pRes);
taos_close(pConn); taos_close(pConn);
} }
#endif
TEST(testCase, create_multiple_tables) { TEST(testCase, create_multiple_tables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
...@@ -653,6 +653,7 @@ TEST(testCase, projection_query_stables) { ...@@ -653,6 +653,7 @@ TEST(testCase, projection_query_stables) {
taos_free_result(pRes); taos_free_result(pRes);
taos_close(pConn); taos_close(pConn);
} }
#endif
TEST(testCase, agg_query_tables) { TEST(testCase, agg_query_tables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
...@@ -661,7 +662,7 @@ TEST(testCase, agg_query_tables) { ...@@ -661,7 +662,7 @@ TEST(testCase, agg_query_tables) {
TAOS_RES* pRes = taos_query(pConn, "use abc1"); TAOS_RES* pRes = taos_query(pConn, "use abc1");
taos_free_result(pRes); taos_free_result(pRes);
pRes = taos_query(pConn, "select count(*) from tu"); pRes = taos_query(pConn, "select length('abc') from tu");
if (taos_errno(pRes) != 0) { if (taos_errno(pRes) != 0) {
printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
taos_free_result(pRes); taos_free_result(pRes);
......
...@@ -411,6 +411,7 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) { ...@@ -411,6 +411,7 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) {
#endif #endif
pCols->numOfRows = 0; pCols->numOfRows = 0;
pCols->bitmapMode = 0;
pCols->numOfCols = schemaNCols(pSchema); pCols->numOfCols = schemaNCols(pSchema);
for (i = 0; i < schemaNCols(pSchema); ++i) { for (i = 0; i < schemaNCols(pSchema); ++i) {
......
...@@ -1960,7 +1960,7 @@ int32_t tDeserializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pR ...@@ -1960,7 +1960,7 @@ int32_t tDeserializeSUseDbBatchRsp(void *buf, int32_t bufLen, SUseDbBatchRsp *pR
int32_t numOfBatch = taosArrayGetSize(pRsp->pArray); int32_t numOfBatch = taosArrayGetSize(pRsp->pArray);
if (tDecodeI32(&decoder, &numOfBatch) < 0) return -1; if (tDecodeI32(&decoder, &numOfBatch) < 0) return -1;
pRsp->pArray = taosArrayInit(numOfBatch, sizeof(SUseDbBatchRsp)); pRsp->pArray = taosArrayInit(numOfBatch, sizeof(SUseDbRsp));
if (pRsp->pArray == NULL) { if (pRsp->pArray == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
......
...@@ -385,7 +385,6 @@ int tdAppendValToDataCol(SDataCol *pCol, TDRowValT valType, const void *val, int ...@@ -385,7 +385,6 @@ int tdAppendValToDataCol(SDataCol *pCol, TDRowValT valType, const void *val, int
pCol->len += pCol->bytes; pCol->len += pCol->bytes;
} }
#ifdef TD_SUPPORT_BITMAP #ifdef TD_SUPPORT_BITMAP
tdSetBitmapValType(pCol->pBitmap, numOfRows, valType, bitmapMode); tdSetBitmapValType(pCol->pBitmap, numOfRows, valType, bitmapMode);
#endif #endif
return 0; return 0;
...@@ -486,7 +485,7 @@ static int32_t tdAppendKvRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols ...@@ -486,7 +485,7 @@ static int32_t tdAppendKvRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols
* @param pCols * @param pCols
* @param forceSetNull * @param forceSetNull
*/ */
int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols, bool forceSetNull) { int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCols) {
if (TD_IS_TP_ROW(pRow)) { if (TD_IS_TP_ROW(pRow)) {
return tdAppendTpRowToDataCol(pRow, pSchema, pCols); return tdAppendTpRowToDataCol(pRow, pSchema, pCols);
} else if (TD_IS_KV_ROW(pRow)) { } else if (TD_IS_KV_ROW(pRow)) {
...@@ -497,7 +496,7 @@ int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCol ...@@ -497,7 +496,7 @@ int32_t tdAppendSTSRowToDataCol(STSRow *pRow, STSchema *pSchema, SDataCols *pCol
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge, int *pOffset, bool forceSetNull) { int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge, int *pOffset, bool forceSetNull, TDRowVerT maxVer) {
ASSERT(rowsToMerge > 0 && rowsToMerge <= source->numOfRows); ASSERT(rowsToMerge > 0 && rowsToMerge <= source->numOfRows);
ASSERT(target->numOfCols == source->numOfCols); ASSERT(target->numOfCols == source->numOfCols);
int offset = 0; int offset = 0;
...@@ -510,6 +509,7 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge, int * ...@@ -510,6 +509,7 @@ int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge, int *
if ((target->numOfRows == 0) || (dataColsKeyLast(target) < dataColsKeyAtRow(source, *pOffset))) { // No overlap if ((target->numOfRows == 0) || (dataColsKeyLast(target) < dataColsKeyAtRow(source, *pOffset))) { // No overlap
ASSERT(target->numOfRows + rowsToMerge <= target->maxPoints); ASSERT(target->numOfRows + rowsToMerge <= target->maxPoints);
// TODO: filter the maxVer
for (int i = 0; i < rowsToMerge; i++) { for (int i = 0; i < rowsToMerge; i++) {
for (int j = 0; j < source->numOfCols; j++) { for (int j = 0; j < source->numOfCols; j++) {
if (source->cols[j].len > 0 || target->cols[j].len > 0) { if (source->cols[j].len > 0 || target->cols[j].len > 0) {
...@@ -555,9 +555,9 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i ...@@ -555,9 +555,9 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i
// TKEY tkey2 = (*iter2 >= limit2) ? TKEY_NULL : dataColsTKeyAt(src2, *iter2); // TKEY tkey2 = (*iter2 >= limit2) ? TKEY_NULL : dataColsTKeyAt(src2, *iter2);
ASSERT(tkey1 == TKEY_NULL || (!TKEY_IS_DELETED(tkey1))); ASSERT(tkey1 == TKEY_NULL || (!TKEY_IS_DELETED(tkey1)));
// TODO: filter the maxVer
if (key1 < key2) { if (key1 < key2) {
for (int i = 0; i < src1->numOfCols; i++) { for (int i = 0; i < src1->numOfCols; ++i) {
ASSERT(target->cols[i].type == src1->cols[i].type); ASSERT(target->cols[i].type == src1->cols[i].type);
if (src1->cols[i].len > 0 || target->cols[i].len > 0) { if (src1->cols[i].len > 0 || target->cols[i].len > 0) {
SCellVal sVal = {0}; SCellVal sVal = {0};
...@@ -568,12 +568,12 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i ...@@ -568,12 +568,12 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i
} }
} }
target->numOfRows++; ++target->numOfRows;
(*iter1)++; ++(*iter1);
} else if (key1 >= key2) { } else if (key1 >= key2) {
// if ((key1 > key2) || (key1 == key2 && !TKEY_IS_DELETED(tkey2))) { // TODO: filter the maxVer
if ((key1 > key2) || (key1 == key2)) { if ((key1 > key2) || ((key1 == key2) && !TKEY_IS_DELETED(key2))) {
for (int i = 0; i < src2->numOfCols; i++) { for (int i = 0; i < src2->numOfCols; ++i) {
SCellVal sVal = {0}; SCellVal sVal = {0};
ASSERT(target->cols[i].type == src2->cols[i].type); ASSERT(target->cols[i].type == src2->cols[i].type);
if (tdGetColDataOfRow(&sVal, src2->cols + i, *iter2, src2->bitmapMode) < 0) { if (tdGetColDataOfRow(&sVal, src2->cols + i, *iter2, src2->bitmapMode) < 0) {
...@@ -590,11 +590,11 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i ...@@ -590,11 +590,11 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i
dataColSetNullAt(&target->cols[i], target->numOfRows, true, target->bitmapMode); dataColSetNullAt(&target->cols[i], target->numOfRows, true, target->bitmapMode);
} }
} }
target->numOfRows++; ++target->numOfRows;
} }
(*iter2)++; ++(*iter2);
if (key1 == key2) (*iter1)++; if (key1 == key2) ++(*iter1);
} }
ASSERT(target->numOfRows <= target->maxPoints); ASSERT(target->numOfRows <= target->maxPoints);
......
...@@ -39,7 +39,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) { ...@@ -39,7 +39,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
taosGetTmpfilePath(tsTempDir, "join", pTSBuf->path); taosGetTmpfilePath(tsTempDir, "join", pTSBuf->path);
// pTSBuf->pFile = fopen(pTSBuf->path, "wb+"); // pTSBuf->pFile = fopen(pTSBuf->path, "wb+");
pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC); pTSBuf->pFile = taosOpenFile(pTSBuf->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC);
if (pTSBuf->pFile == NULL) { if (pTSBuf->pFile == NULL) {
taosMemoryFree(pTSBuf); taosMemoryFree(pTSBuf);
return NULL; return NULL;
......
...@@ -162,7 +162,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) { ...@@ -162,7 +162,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) {
char file[PATH_MAX]; char file[PATH_MAX];
snprintf(file, sizeof(file), "%s%sdnode.json.bak", pMgmt->path, TD_DIRSEP); snprintf(file, sizeof(file), "%s%sdnode.json.bak", pMgmt->path, TD_DIRSEP);
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) { if (pFile == NULL) {
dError("failed to write %s since %s", file, strerror(errno)); dError("failed to write %s since %s", file, strerror(errno));
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
......
...@@ -75,7 +75,7 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) { ...@@ -75,7 +75,7 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
snprintf(file, sizeof(file), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name); snprintf(file, sizeof(file), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name);
snprintf(realfile, sizeof(realfile), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name); snprintf(realfile, sizeof(realfile), "%s%s%s.json", pWrapper->path, TD_DIRSEP, pWrapper->name);
pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) { if (pFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
dError("failed to write %s since %s", file, terrstr()); dError("failed to write %s since %s", file, terrstr());
...@@ -121,7 +121,7 @@ TdFilePtr dndCheckRunning(const char *dataDir) { ...@@ -121,7 +121,7 @@ TdFilePtr dndCheckRunning(const char *dataDir) {
char filepath[PATH_MAX] = {0}; char filepath[PATH_MAX] = {0};
snprintf(filepath, sizeof(filepath), "%s%s.running", dataDir, TD_DIRSEP); snprintf(filepath, sizeof(filepath), "%s%s.running", dataDir, TD_DIRSEP);
TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) { if (pFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
dError("failed to lock file:%s since %s", filepath, terrstr()); dError("failed to lock file:%s since %s", filepath, terrstr());
...@@ -218,7 +218,7 @@ int32_t dndWriteShmFile(SDnode *pDnode) { ...@@ -218,7 +218,7 @@ int32_t dndWriteShmFile(SDnode *pDnode) {
snprintf(file, sizeof(file), "%s%s.shmfile.bak", pDnode->dataDir, TD_DIRSEP); snprintf(file, sizeof(file), "%s%s.shmfile.bak", pDnode->dataDir, TD_DIRSEP);
snprintf(realfile, sizeof(realfile), "%s%s.shmfile", pDnode->dataDir, TD_DIRSEP); snprintf(realfile, sizeof(realfile), "%s%s.shmfile", pDnode->dataDir, TD_DIRSEP);
pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) { if (pFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
dError("failed to open file:%s since %s", file, terrstr()); dError("failed to open file:%s since %s", file, terrstr());
......
...@@ -158,7 +158,7 @@ SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndType ntype) { ...@@ -158,7 +158,7 @@ SMgmtWrapper *dndAcquireWrapper(SDnode *pDnode, EDndType ntype) {
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
dTrace("node:%s, is acquired, refCount:%d", pWrapper->name, refCount); dTrace("node:%s, is acquired, refCount:%d", pWrapper->name, refCount);
} else { } else {
terrno = TSDB_CODE_NODE_REDIRECT; terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
pRetWrapper = NULL; pRetWrapper = NULL;
} }
taosRUnLockLatch(&pWrapper->latch); taosRUnLockLatch(&pWrapper->latch);
...@@ -174,7 +174,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) { ...@@ -174,7 +174,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) {
int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1);
dTrace("node:%s, is marked, refCount:%d", pWrapper->name, refCount); dTrace("node:%s, is marked, refCount:%d", pWrapper->name, refCount);
} else { } else {
terrno = TSDB_CODE_NODE_REDIRECT; terrno = TSDB_CODE_NODE_NOT_DEPLOYED;
code = -1; code = -1;
} }
taosRUnLockLatch(&pWrapper->latch); taosRUnLockLatch(&pWrapper->latch);
......
...@@ -53,8 +53,9 @@ static void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpS ...@@ -53,8 +53,9 @@ static void dndProcessRpcMsg(SMgmtWrapper *pWrapper, SRpcMsg *pRpc, SEpSet *pEpS
int32_t code = -1; int32_t code = -1;
SNodeMsg *pMsg = NULL; SNodeMsg *pMsg = NULL;
NodeMsgFp msgFp = NULL; NodeMsgFp msgFp = NULL;
uint16_t msgType = pRpc->msgType;
if (pEpSet && pEpSet->numOfEps > 0 && pRpc->msgType == TDMT_MND_STATUS_RSP) { if (pEpSet && pEpSet->numOfEps > 0 && msgType == TDMT_MND_STATUS_RSP) {
dndUpdateMnodeEpSet(pWrapper->pDnode, pEpSet); dndUpdateMnodeEpSet(pWrapper->pDnode, pEpSet);
} }
...@@ -84,9 +85,15 @@ _OVER: ...@@ -84,9 +85,15 @@ _OVER:
} }
} else { } else {
dError("msg:%p, failed to process since 0x%04x:%s", pMsg, code & 0XFFFF, terrstr()); dError("msg:%p, failed to process since 0x%04x:%s", pMsg, code & 0XFFFF, terrstr());
if (pRpc->msgType & 1U) { if (msgType & 1U) {
if (terrno != 0) code = terrno; if (terrno != 0) code = terrno;
SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = terrno}; if (code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_NODE_OFFLINE) {
if (msgType > TDMT_MND_MSG && msgType < TDMT_VND_MSG) {
code = TSDB_CODE_NODE_REDIRECT;
}
}
SRpcMsg rsp = {.handle = pRpc->handle, .ahandle = pRpc->ahandle, .code = code};
tmsgSendRsp(&rsp); tmsgSendRsp(&rsp);
} }
dTrace("msg:%p, is freed", pMsg); dTrace("msg:%p, is freed", pMsg);
...@@ -348,8 +355,7 @@ static int32_t dndSendRpcReq(STransMgmt *pMgmt, const SEpSet *pEpSet, SRpcMsg *p ...@@ -348,8 +355,7 @@ static int32_t dndSendRpcReq(STransMgmt *pMgmt, const SEpSet *pEpSet, SRpcMsg *p
} }
static void dndSendRpcRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) { static void dndSendRpcRsp(SMgmtWrapper *pWrapper, const SRpcMsg *pRsp) {
if (pRsp->code == TSDB_CODE_APP_NOT_READY || pRsp->code == TSDB_CODE_NODE_REDIRECT || if (pRsp->code == TSDB_CODE_NODE_REDIRECT) {
pRsp->code == TSDB_CODE_NODE_OFFLINE) {
dmSendRedirectRsp(pWrapper->pMgmt, pRsp); dmSendRedirectRsp(pWrapper->pMgmt, pRsp);
} else { } else {
rpcSendResponse(pRsp); rpcSendResponse(pRsp);
...@@ -442,7 +448,8 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t ...@@ -442,7 +448,8 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int16_t
static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen, static void dndConsumeParentQueue(SMgmtWrapper *pWrapper, SRpcMsg *pMsg, int16_t msgLen, void *pCont, int32_t contLen,
ProcFuncType ftype) { ProcFuncType ftype) {
pMsg->pCont = pCont; pMsg->pCont = pCont;
dTrace("msg:%p, get from parent queue, ftype:%d handle:%p, app:%p", pMsg, ftype, pMsg->handle, pMsg->ahandle); dTrace("msg:%p, get from parent queue, ftype:%d handle:%p code:0x%04x mtype:%d, app:%p", pMsg, ftype, pMsg->handle,
pMsg->code & 0xFFFF, pMsg->msgType, pMsg->ahandle);
switch (ftype) { switch (ftype) {
case PROC_REGIST: case PROC_REGIST:
......
...@@ -109,7 +109,7 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, bool deployed) { ...@@ -109,7 +109,7 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, bool deployed) {
char file[PATH_MAX]; char file[PATH_MAX];
snprintf(file, sizeof(file), "%s%smnode.json.bak", pMgmt->path, TD_DIRSEP); snprintf(file, sizeof(file), "%s%smnode.json.bak", pMgmt->path, TD_DIRSEP);
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) { if (pFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
dError("failed to write %s since %s", file, terrstr()); dError("failed to write %s since %s", file, terrstr());
......
...@@ -96,7 +96,7 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) { ...@@ -96,7 +96,7 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
if (alterReq.dnodeId != pDnode->dnodeId) { if (alterReq.dnodeId != pDnode->dnodeId) {
terrno = TSDB_CODE_INVALID_OPTION; terrno = TSDB_CODE_INVALID_OPTION;
dError("failed to alter mnode since %s", terrstr()); dError("failed to alter mnode since %s, dnodeId:%d input:%d", terrstr(), pDnode->dnodeId, alterReq.dnodeId);
return -1; return -1;
} else { } else {
return mmAlter(pMgmt, &alterReq); return mmAlter(pMgmt, &alterReq);
......
...@@ -112,6 +112,9 @@ static int32_t mmOpenImp(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pReq) { ...@@ -112,6 +112,9 @@ static int32_t mmOpenImp(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pReq) {
if (!deployed) { if (!deployed) {
dInfo("mnode start to deploy"); dInfo("mnode start to deploy");
if (pMgmt->pWrapper->procType == PROC_CHILD) {
pMgmt->pDnode->dnodeId = 1;
}
mmBuildOptionForDeploy(pMgmt, &option); mmBuildOptionForDeploy(pMgmt, &option);
} else { } else {
dInfo("mnode start to open"); dInfo("mnode start to open");
......
...@@ -188,7 +188,7 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) { ...@@ -188,7 +188,7 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) {
SRpcMsg* pRsp = test.SendReq(TDMT_DND_ALTER_MNODE, pReq, contLen); SRpcMsg* pRsp = test.SendReq(TDMT_DND_ALTER_MNODE, pReq, contLen);
ASSERT_NE(pRsp, nullptr); ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, TSDB_CODE_RPC_REDIRECT); ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED);
} }
{ {
......
...@@ -154,7 +154,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) { ...@@ -154,7 +154,7 @@ int32_t vmWriteVnodesToFile(SVnodesMgmt *pMgmt) {
snprintf(file, sizeof(file), "%s%svnodes.json.bak", pMgmt->path, TD_DIRSEP); snprintf(file, sizeof(file), "%s%svnodes.json.bak", pMgmt->path, TD_DIRSEP);
snprintf(realfile, sizeof(file), "%s%svnodes.json", pMgmt->path, TD_DIRSEP); snprintf(realfile, sizeof(file), "%s%svnodes.json", pMgmt->path, TD_DIRSEP);
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) { if (pFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
dError("failed to write %s since %s", file, terrstr()); dError("failed to write %s since %s", file, terrstr());
......
...@@ -38,7 +38,7 @@ class MndTestTrans : public ::testing::Test { ...@@ -38,7 +38,7 @@ class MndTestTrans : public ::testing::Test {
test.ServerStop(); test.ServerStop();
pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
int32_t writeLen = taosWriteFile(pFile, buffer, readLen); int32_t writeLen = taosWriteFile(pFile, buffer, readLen);
if (writeLen < 0 || writeLen == readLen) { if (writeLen < 0 || writeLen == readLen) {
ASSERT(1); ASSERT(1);
......
...@@ -232,7 +232,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { ...@@ -232,7 +232,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
mDebug("start to write file:%s, current ver:%" PRId64 ", commit ver:%" PRId64, curfile, pSdb->curVer, mDebug("start to write file:%s, current ver:%" PRId64 ", commit ver:%" PRId64, curfile, pSdb->curVer,
pSdb->lastCommitVer); pSdb->lastCommitVer);
TdFilePtr pFile = taosOpenFile(tmpfile, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(tmpfile, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) { if (pFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
mError("failed to open file:%s for write since %s", tmpfile, terrstr()); mError("failed to open file:%s for write since %s", tmpfile, terrstr());
......
...@@ -95,7 +95,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F ...@@ -95,7 +95,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
tqError("failed to create dir:%s since %s ", name, terrstr()); tqError("failed to create dir:%s since %s ", name, terrstr());
} }
strcat(name, "/" TQ_IDX_NAME); strcat(name, "/" TQ_IDX_NAME);
TdFilePtr pIdxFile = taosOpenFile(name, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ); TdFilePtr pIdxFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ);
if (pIdxFile == NULL) { if (pIdxFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
tqError("failed to open file:%s since %s ", name, terrstr()); tqError("failed to open file:%s since %s ", name, terrstr());
...@@ -113,7 +113,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F ...@@ -113,7 +113,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
strcpy(name, path); strcpy(name, path);
strcat(name, "/" TQ_META_NAME); strcat(name, "/" TQ_META_NAME);
TdFilePtr pFile = taosOpenFile(name, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ); TdFilePtr pFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ);
if (pFile == NULL) { if (pFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
tqError("failed to open file:%s since %s", name, terrstr()); tqError("failed to open file:%s since %s", name, terrstr());
......
...@@ -1298,7 +1298,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF ...@@ -1298,7 +1298,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
int32_t tBitmaps = 0; int32_t tBitmaps = 0;
int32_t tBitmapsLen = 0; int32_t tBitmapsLen = 0;
if ((ncol != 0) && !TD_COL_ROWS_NORM(pBlockCol)) { if ((ncol != 0) && !TD_COL_ROWS_NORM(pBlockCol)) {
tBitmaps = sBitmaps; tBitmaps = isSuper ? sBitmaps : nBitmaps;
} }
#endif #endif
...@@ -1678,10 +1678,11 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt ...@@ -1678,10 +1678,11 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
ASSERT(pSchema != NULL); ASSERT(pSchema != NULL);
} }
tdAppendSTSRowToDataCol(row, pSchema, pTarget, true); tdAppendSTSRowToDataCol(row, pSchema, pTarget);
tSkipListIterNext(pCommitIter->pIter); tSkipListIterNext(pCommitIter->pIter);
} else { } else {
#if 0
if (update != TD_ROW_OVERWRITE_UPDATE) { if (update != TD_ROW_OVERWRITE_UPDATE) {
// copy disk data // copy disk data
for (int i = 0; i < pDataCols->numOfCols; ++i) { for (int i = 0; i < pDataCols->numOfCols; ++i) {
...@@ -1706,6 +1707,43 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt ...@@ -1706,6 +1707,43 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt
} }
++(*iter); ++(*iter);
tSkipListIterNext(pCommitIter->pIter); tSkipListIterNext(pCommitIter->pIter);
#endif
// copy disk data
for (int i = 0; i < pDataCols->numOfCols; ++i) {
SCellVal sVal = {0};
if (tdGetColDataOfRow(&sVal, pDataCols->cols + i, *iter, pDataCols->bitmapMode) < 0) {
TASSERT(0);
}
// TODO: tdAppendValToDataCol may fail
tdAppendValToDataCol(pTarget->cols + i, sVal.valType, sVal.val, pTarget->numOfRows, pTarget->maxPoints,
pTarget->bitmapMode);
}
if (TD_SUPPORT_UPDATE(update)) {
// copy mem data(Multi-Version)
if (pSchema == NULL || schemaVersion(pSchema) != TD_ROW_SVER(row)) {
pSchema = tsdbGetTableSchemaImpl(pCommitIter->pTable, false, false, TD_ROW_SVER(row));
ASSERT(pSchema != NULL);
}
// TODO: merge with Multi-Version
STSRow *curRow = row;
++(*iter);
tSkipListIterNext(pCommitIter->pIter);
STSRow *nextRow = tsdbNextIterRow(pCommitIter->pIter);
if (key2 < TD_ROW_KEY(nextRow)) {
tdAppendSTSRowToDataCol(row, pSchema, pTarget);
} else {
tdAppendSTSRowToDataCol(row, pSchema, pTarget);
}
// TODO: merge with Multi-Version
} else {
++pTarget->numOfRows;
++(*iter);
tSkipListIterNext(pCommitIter->pIter);
}
} }
if (pTarget->numOfRows >= maxRows) break; if (pTarget->numOfRows >= maxRows) break;
......
...@@ -416,7 +416,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) { ...@@ -416,7 +416,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
tsdbGetTxnFname(pRepo, TSDB_TXN_TEMP_FILE, tfname); tsdbGetTxnFname(pRepo, TSDB_TXN_TEMP_FILE, tfname);
tsdbGetTxnFname(pRepo, TSDB_TXN_CURR_FILE, cfname); tsdbGetTxnFname(pRepo, TSDB_TXN_CURR_FILE, cfname);
TdFilePtr pFile = taosOpenFile(tfname, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(tfname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) { if (pFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
return -1; return -1;
......
...@@ -360,7 +360,7 @@ static void *tsdbDecodeSDFileEx(void *buf, SDFile *pDFile) { ...@@ -360,7 +360,7 @@ static void *tsdbDecodeSDFileEx(void *buf, SDFile *pDFile) {
int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T fType) { int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T fType) {
ASSERT(pDFile->info.size == 0 && pDFile->info.magic == TSDB_FILE_INIT_MAGIC); ASSERT(pDFile->info.size == 0 && pDFile->info.magic == TSDB_FILE_INIT_MAGIC);
pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pDFile->pFile == NULL) { if (pDFile->pFile == NULL) {
if (errno == ENOENT) { if (errno == ENOENT) {
// Try to create directory recursively // Try to create directory recursively
...@@ -371,7 +371,7 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T ...@@ -371,7 +371,7 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T
} }
taosMemoryFreeClear(s); taosMemoryFreeClear(s);
pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pDFile->pFile == NULL) { if (pDFile->pFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
return -1; return -1;
......
...@@ -475,7 +475,7 @@ static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema * ...@@ -475,7 +475,7 @@ static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema *
} }
} }
tdAppendSTSRowToDataCol(row, *ppSchema, pCols, true); tdAppendSTSRowToDataCol(row, *ppSchema, pCols);
} }
return 0; return 0;
......
...@@ -761,6 +761,7 @@ static TSKEY extractFirstTraverseKey(STableCheckInfo* pCheckInfo, int32_t order, ...@@ -761,6 +761,7 @@ static TSKEY extractFirstTraverseKey(STableCheckInfo* pCheckInfo, int32_t order,
TSKEY r2 = TD_ROW_KEY(rimem); TSKEY r2 = TD_ROW_KEY(rimem);
if (r1 == r2) { if (r1 == r2) {
#if 0
if(update == TD_ROW_DISCARD_UPDATE){ if(update == TD_ROW_DISCARD_UPDATE){
pCheckInfo->chosen = CHECKINFO_CHOSEN_IMEM; pCheckInfo->chosen = CHECKINFO_CHOSEN_IMEM;
tSkipListIterNext(pCheckInfo->iter); tSkipListIterNext(pCheckInfo->iter);
...@@ -771,6 +772,13 @@ static TSKEY extractFirstTraverseKey(STableCheckInfo* pCheckInfo, int32_t order, ...@@ -771,6 +772,13 @@ static TSKEY extractFirstTraverseKey(STableCheckInfo* pCheckInfo, int32_t order,
} else { } else {
pCheckInfo->chosen = CHECKINFO_CHOSEN_BOTH; pCheckInfo->chosen = CHECKINFO_CHOSEN_BOTH;
} }
#endif
if (TD_SUPPORT_UPDATE(update)) {
pCheckInfo->chosen = CHECKINFO_CHOSEN_BOTH;
} else {
pCheckInfo->chosen = CHECKINFO_CHOSEN_IMEM;
tSkipListIterNext(pCheckInfo->iter);
}
return r1; return r1;
} else if (r1 < r2 && ASCENDING_TRAVERSE(order)) { } else if (r1 < r2 && ASCENDING_TRAVERSE(order)) {
pCheckInfo->chosen = CHECKINFO_CHOSEN_MEM; pCheckInfo->chosen = CHECKINFO_CHOSEN_MEM;
......
...@@ -263,8 +263,9 @@ int tsdbLoadBlockData(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo) { ...@@ -263,8 +263,9 @@ int tsdbLoadBlockData(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo) {
for (int i = 1; i < pBlock->numOfSubBlocks; i++) { for (int i = 1; i < pBlock->numOfSubBlocks; i++) {
iBlock++; iBlock++;
if (tsdbLoadBlockDataImpl(pReadh, iBlock, pReadh->pDCols[1]) < 0) return -1; if (tsdbLoadBlockDataImpl(pReadh, iBlock, pReadh->pDCols[1]) < 0) return -1;
// TODO: use the real maxVersion to replace the UINT64_MAX to support Multi-Version
if (tdMergeDataCols(pReadh->pDCols[0], pReadh->pDCols[1], pReadh->pDCols[1]->numOfRows, NULL, if (tdMergeDataCols(pReadh->pDCols[0], pReadh->pDCols[1], pReadh->pDCols[1]->numOfRows, NULL,
update != TD_ROW_PARTIAL_UPDATE) < 0) update != TD_ROW_PARTIAL_UPDATE, UINT64_MAX) < 0)
return -1; return -1;
} }
...@@ -293,8 +294,9 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, ...@@ -293,8 +294,9 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo,
for (int i = 1; i < pBlock->numOfSubBlocks; i++) { for (int i = 1; i < pBlock->numOfSubBlocks; i++) {
iBlock++; iBlock++;
if (tsdbLoadBlockDataColsImpl(pReadh, iBlock, pReadh->pDCols[1], colIds, numOfColsIds) < 0) return -1; if (tsdbLoadBlockDataColsImpl(pReadh, iBlock, pReadh->pDCols[1], colIds, numOfColsIds) < 0) return -1;
// TODO: use the real maxVersion to replace the UINT64_MAX to support Multi-Version
if (tdMergeDataCols(pReadh->pDCols[0], pReadh->pDCols[1], pReadh->pDCols[1]->numOfRows, NULL, if (tdMergeDataCols(pReadh->pDCols[0], pReadh->pDCols[1], pReadh->pDCols[1]->numOfRows, NULL,
update != TD_ROW_PARTIAL_UPDATE) < 0) update != TD_ROW_PARTIAL_UPDATE, UINT64_MAX) < 0)
return -1; return -1;
} }
...@@ -304,6 +306,7 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo, ...@@ -304,6 +306,7 @@ int tsdbLoadBlockDataCols(SReadH *pReadh, SBlock *pBlock, SBlockInfo *pBlkInfo,
if (pDataCol->bitmap) { if (pDataCol->bitmap) {
ASSERT(pDataCol->colId != PRIMARYKEY_TIMESTAMP_COL_ID); ASSERT(pDataCol->colId != PRIMARYKEY_TIMESTAMP_COL_ID);
tdMergeBitmap(pDataCol->pBitmap, TD_BITMAP_BYTES(pReadh->pDCols[0]->numOfRows), pDataCol->pBitmap); tdMergeBitmap(pDataCol->pBitmap, TD_BITMAP_BYTES(pReadh->pDCols[0]->numOfRows), pDataCol->pBitmap);
tdDataColsSetBitmapI(pReadh->pDCols[0]);
} }
} }
} }
......
...@@ -44,6 +44,9 @@ extern "C" { ...@@ -44,6 +44,9 @@ extern "C" {
#define EXPLAIN_OUTPUT_FORMAT "Output: " #define EXPLAIN_OUTPUT_FORMAT "Output: "
#define EXPLAIN_TIME_WINDOWS_FORMAT "Time Window: interval=%" PRId64 "%c offset=%" PRId64 "%c sliding=%" PRId64 "%c" #define EXPLAIN_TIME_WINDOWS_FORMAT "Time Window: interval=%" PRId64 "%c offset=%" PRId64 "%c sliding=%" PRId64 "%c"
#define EXPLAIN_WINDOW_FORMAT "Window: gap=%" PRId64 #define EXPLAIN_WINDOW_FORMAT "Window: gap=%" PRId64
#define EXPLAIN_RATIO_TIME_FORMAT "Ratio: %f"
#define EXPLAIN_PLANNING_TIME_FORMAT "Planning Time: %.3f ms"
#define EXPLAIN_EXEC_TIME_FORMAT "Execution Time: %.3f ms"
//append area //append area
#define EXPLAIN_LEFT_PARENTHESIS_FORMAT " (" #define EXPLAIN_LEFT_PARENTHESIS_FORMAT " ("
...@@ -108,16 +111,19 @@ typedef struct SExplainCtx { ...@@ -108,16 +111,19 @@ typedef struct SExplainCtx {
#define EXPLAIN_ROW_NEW(level, ...) \ #define EXPLAIN_ROW_NEW(level, ...) \
do { \ do { \
if (isVerboseLine) { \ if (isVerboseLine) { \
tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s", (level) * 2 + 3, ""); \ tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE, "%*s", (level) * 2 + 3, ""); \
} else { \ } else { \
tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s%s", (level) * 2, "", "-> "); \ tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE, "%*s%s", (level) * 2, "", "-> "); \
} \ } \
tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__); \ tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE - tlen, __VA_ARGS__); \
} while (0) } while (0)
#define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__) #define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE - tlen, __VA_ARGS__)
#define EXPLAIN_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; isVerboseLine = true; } while (0) #define EXPLAIN_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; isVerboseLine = true; } while (0)
#define EXPLAIN_SUM_ROW_NEW(...) tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE - VARSTR_HEADER_SIZE, __VA_ARGS__)
#define EXPLAIN_SUM_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; } while (0)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -52,16 +52,14 @@ void qExplainFreeCtx(SExplainCtx *pCtx) { ...@@ -52,16 +52,14 @@ void qExplainFreeCtx(SExplainCtx *pCtx) {
void *pIter = taosHashIterate(pCtx->groupHash, NULL); void *pIter = taosHashIterate(pCtx->groupHash, NULL);
while (pIter) { while (pIter) {
SExplainGroup *group = (SExplainGroup *)pIter; SExplainGroup *group = (SExplainGroup *)pIter;
if (NULL == group->nodeExecInfo) { if (group->nodeExecInfo) {
continue; int32_t num = taosArrayGetSize(group->nodeExecInfo);
for (int32_t i = 0; i < num; ++i) {
SExplainRsp *rsp = taosArrayGet(group->nodeExecInfo, i);
taosMemoryFreeClear(rsp->subplanInfo);
}
} }
int32_t num = taosArrayGetSize(group->nodeExecInfo);
for (int32_t i = 0; i < num; ++i) {
SExplainRsp *rsp = taosArrayGet(group->nodeExecInfo, i);
taosMemoryFreeClear(rsp->subplanInfo);
}
pIter = taosHashIterate(pCtx->groupHash, pIter); pIter = taosHashIterate(pCtx->groupHash, pIter);
} }
} }
...@@ -641,7 +639,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i ...@@ -641,7 +639,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
} }
case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{ case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{
SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode; SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode;
EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, nodesGetNameFromColumnNode(pIntNode->pTspk)); EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, nodesGetNameFromColumnNode(pIntNode->window.pTspk));
EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT);
if (pResNode->pExecInfo) { if (pResNode->pExecInfo) {
QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen));
...@@ -896,9 +894,33 @@ _return: ...@@ -896,9 +894,33 @@ _return:
QRY_RET(code); QRY_RET(code);
} }
int32_t qExplainAppendPlanRows(SExplainCtx *pCtx) {
if (EXPLAIN_MODE_ANALYZE != pCtx->mode) {
return TSDB_CODE_SUCCESS;
}
int32_t tlen = 0;
char *tbuf = pCtx->tbuf;
EXPLAIN_SUM_ROW_NEW(EXPLAIN_RATIO_TIME_FORMAT, pCtx->ratio);
EXPLAIN_SUM_ROW_END();
QRY_ERR_RET(qExplainResAppendRow(pCtx, tbuf, tlen, 0));
EXPLAIN_SUM_ROW_NEW(EXPLAIN_PLANNING_TIME_FORMAT, (double)(pCtx->jobStartTs - pCtx->reqStartTs) / 1000.0);
EXPLAIN_SUM_ROW_END();
QRY_ERR_RET(qExplainResAppendRow(pCtx, tbuf, tlen, 0));
EXPLAIN_SUM_ROW_NEW(EXPLAIN_EXEC_TIME_FORMAT, (double)(pCtx->jobDoneTs - pCtx->jobStartTs) / 1000.0);
EXPLAIN_SUM_ROW_END();
QRY_ERR_RET(qExplainResAppendRow(pCtx, tbuf, tlen, 0));
return TSDB_CODE_SUCCESS;
}
int32_t qExplainGenerateRsp(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp) { int32_t qExplainGenerateRsp(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp) {
QRY_ERR_RET(qExplainAppendGroupResRows(pCtx, pCtx->rootGroupId, 0)); QRY_ERR_RET(qExplainAppendGroupResRows(pCtx, pCtx->rootGroupId, 0));
QRY_ERR_RET(qExplainAppendPlanRows(pCtx));
QRY_ERR_RET(qExplainGetRspFromCtx(pCtx, pRsp)); QRY_ERR_RET(qExplainGetRspFromCtx(pCtx, pRsp));
...@@ -979,18 +1001,18 @@ _return: ...@@ -979,18 +1001,18 @@ _return:
QRY_RET(code); QRY_RET(code);
} }
int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int32_t startTs) { int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs) {
QRY_ERR_RET(qExplainPrepareCtx(pDag, pCtx)); QRY_ERR_RET(qExplainPrepareCtx(pDag, pCtx));
(*pCtx)->reqStartTs = startTs; (*pCtx)->reqStartTs = startTs;
(*pCtx)->jobStartTs = taosGetTimestampMs(); (*pCtx)->jobStartTs = taosGetTimestampUs();
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp) { int32_t qExecExplainEnd(SExplainCtx *pCtx, SRetrieveTableRsp **pRsp) {
int32_t code = 0; int32_t code = 0;
pCtx->jobDoneTs = taosGetTimestampMs(); pCtx->jobDoneTs = taosGetTimestampUs();
atomic_store_8((int8_t *)&pCtx->execDone, true); atomic_store_8((int8_t *)&pCtx->execDone, true);
......
...@@ -232,9 +232,11 @@ typedef struct STaskAttr { ...@@ -232,9 +232,11 @@ typedef struct STaskAttr {
} STaskAttr; } STaskAttr;
struct SOperatorInfo; struct SOperatorInfo;
struct SAggSupporter;
struct SOptrBasicInfo;
typedef void (*__optr_encode_fn_t)(struct SOperatorInfo* pOperator, char **result, int32_t *length); typedef void (*__optr_encode_fn_t)(struct SOperatorInfo* pOperator, struct SAggSupporter *pSup, struct SOptrBasicInfo *pInfo, char **result, int32_t *length);
typedef bool (*__optr_decode_fn_t)(struct SOperatorInfo* pOperator, char *result, int32_t length); typedef bool (*__optr_decode_fn_t)(struct SOperatorInfo* pOperator, struct SAggSupporter *pSup, struct SOptrBasicInfo *pInfo, char *result, int32_t length);
typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* pOptr); typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* pOptr);
typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* pOptr, bool* newgroup); typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* pOptr, bool* newgroup);
...@@ -609,6 +611,12 @@ typedef struct SSessionAggOperatorInfo { ...@@ -609,6 +611,12 @@ typedef struct SSessionAggOperatorInfo {
SColumnInfoData timeWindowData; // query time window info for scalar function execution. SColumnInfoData timeWindowData; // query time window info for scalar function execution.
} SSessionAggOperatorInfo; } SSessionAggOperatorInfo;
typedef struct STimeSliceOperatorInfo {
SOptrBasicInfo binfo;
SInterval interval;
SGroupResInfo groupResInfo; // multiple results build supporter
} STimeSliceOperatorInfo;
typedef struct SStateWindowOperatorInfo { typedef struct SStateWindowOperatorInfo {
SOptrBasicInfo binfo; SOptrBasicInfo binfo;
SAggSupporter aggSup; SAggSupporter aggSup;
...@@ -665,7 +673,7 @@ int32_t operatorDummyOpenFn(SOperatorInfo* pOperator); ...@@ -665,7 +673,7 @@ int32_t operatorDummyOpenFn(SOperatorInfo* pOperator);
void operatorDummyCloseFn(void* param, int32_t numOfCols); void operatorDummyCloseFn(void* param, int32_t numOfCols);
int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num); int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num);
int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols,
int32_t numOfRows, SSDataBlock* pResultBlock, const char* pkey); int32_t numOfRows, SSDataBlock* pResultBlock, size_t keyBufSize, const char* pkey);
void toSDatablock(SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf, SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset); void toSDatablock(SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf, SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset);
void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset); void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset);
void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order); void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order);
...@@ -707,16 +715,15 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf ...@@ -707,16 +715,15 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList, SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SArray* pGroupColList,
SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo);
SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo);
#if 0 #if 0
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv); SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SExprInfo* pExpr, int32_t numOfOutput); SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SExprInfo* pExpr, int32_t numOfOutput); SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createTagScanOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SExprInfo* pExpr, int32_t numOfOutput); SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOfDownstream, SSchema* pSchema, SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOfDownstream, SSchema* pSchema,
int32_t numOfOutput); int32_t numOfOutput);
...@@ -748,6 +755,9 @@ void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status); ...@@ -748,6 +755,9 @@ void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status);
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, EOPTR_EXEC_MODEL model); int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, EOPTR_EXEC_MODEL model);
int32_t getOperatorExplainExecInfo(SOperatorInfo *operatorInfo, SExplainExecInfo **pRes, int32_t *capacity, int32_t *resNum); int32_t getOperatorExplainExecInfo(SOperatorInfo *operatorInfo, SExplainExecInfo **pRes, int32_t *capacity, int32_t *resNum);
bool aggDecodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasicInfo *pInfo, char* result, int32_t length);
void aggEncodeResultRow(SOperatorInfo* pOperator, SAggSupporter *pSup, SOptrBasicInfo *pInfo, char **result, int32_t *length);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -46,7 +46,7 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** ...@@ -46,7 +46,7 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char**
int32_t numOfGroupCols = taosArrayGetSize(pGroupColList); int32_t numOfGroupCols = taosArrayGetSize(pGroupColList);
for (int32_t i = 0; i < numOfGroupCols; ++i) { for (int32_t i = 0; i < numOfGroupCols; ++i) {
SColumn* pCol = taosArrayGet(pGroupColList, i); SColumn* pCol = taosArrayGet(pGroupColList, i);
(*keyLen) += pCol->bytes; (*keyLen) += pCol->bytes; // actual data + null_flag
SGroupKeys key = {0}; SGroupKeys key = {0};
key.bytes = pCol->bytes; key.bytes = pCol->bytes;
...@@ -61,8 +61,9 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char** ...@@ -61,8 +61,9 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char**
} }
int32_t nullFlagSize = sizeof(int8_t) * numOfGroupCols; int32_t nullFlagSize = sizeof(int8_t) * numOfGroupCols;
(*keyLen) += nullFlagSize;
(*keyBuf) = taosMemoryCalloc(1, (*keyLen) + nullFlagSize); (*keyBuf) = taosMemoryCalloc(1, (*keyLen));
if ((*keyBuf) == NULL) { if ((*keyBuf) == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -165,15 +166,20 @@ static int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) { ...@@ -165,15 +166,20 @@ static int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) {
// assign the group keys or user input constant values if required // assign the group keys or user input constant values if required
static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t totalRows, int32_t rowIndex) { static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t totalRows, int32_t rowIndex) {
for (int32_t i = 0; i < numOfOutput; ++i) { for (int32_t i = 0; i < numOfOutput; ++i) {
if (pCtx[i].functionId == -1) { if (pCtx[i].functionId == -1) { // select count(*),key from t group by key.
SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[i]); SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[i]);
SColumnInfoData* pColInfoData = pCtx[i].input.pData[0]; SColumnInfoData* pColInfoData = pCtx[i].input.pData[0];
// todo OPT all/all not NULL
if (!colDataIsNull(pColInfoData, totalRows, rowIndex, NULL)) { if (!colDataIsNull(pColInfoData, totalRows, rowIndex, NULL)) {
char* dest = GET_ROWCELL_INTERBUF(pEntryInfo); char* dest = GET_ROWCELL_INTERBUF(pEntryInfo);
char* data = colDataGetData(pColInfoData, rowIndex); char* data = colDataGetData(pColInfoData, rowIndex);
memcpy(dest, data, pColInfoData->info.bytes); if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
varDataCopy(dest, data);
} else {
memcpy(dest, data, pColInfoData->info.bytes);
}
} else { // it is a NULL value } else { // it is a NULL value
pEntryInfo->isNullRes = 1; pEntryInfo->isNullRes = 1;
} }
...@@ -326,18 +332,19 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx ...@@ -326,18 +332,19 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
pInfo->pGroupCols = pGroupColList; pInfo->pGroupCols = pGroupColList;
pInfo->pCondition = pCondition; pInfo->pCondition = pCondition;
initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, 4096, pResultBlock, pTaskInfo->id.str);
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
int32_t code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pGroupColList); int32_t code = initGroupOptrInfo(&pInfo->pGroupColVals, &pInfo->groupKeyLen, &pInfo->keyBuf, pGroupColList);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
goto _error; goto _error;
} }
initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, 4096, pResultBlock, pInfo->groupKeyLen, pTaskInfo->id.str);
initResultRowInfo(&pInfo->binfo.resultRowInfo, 8);
pOperator->name = "GroupbyAggOperator"; pOperator->name = "GroupbyAggOperator";
pOperator->blockingOptr = true; pOperator->blockingOptr = true;
pOperator->status = OP_NOT_OPENED; pOperator->status = OP_NOT_OPENED;
// pOperator->operatorType = OP_Groupby; // pOperator->operatorType = OP_Groupby;
pOperator->pExpr = pExprInfo; pOperator->pExpr = pExprInfo;
pOperator->numOfOutput = numOfCols; pOperator->numOfOutput = numOfCols;
pOperator->info = pInfo; pOperator->info = pInfo;
...@@ -345,6 +352,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx ...@@ -345,6 +352,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
pOperator->_openFn = operatorDummyOpenFn; pOperator->_openFn = operatorDummyOpenFn;
pOperator->getNextFn = hashGroupbyAggregate; pOperator->getNextFn = hashGroupbyAggregate;
pOperator->closeFn = destroyGroupOperatorInfo; pOperator->closeFn = destroyGroupOperatorInfo;
pOperator->encodeResultRow = aggEncodeResultRow;
pOperator->decodeResultRow = aggDecodeResultRow;
code = appendDownstream(pOperator, &downstream, 1); code = appendDownstream(pOperator, &downstream, 1);
return pOperator; return pOperator;
......
...@@ -26,15 +26,17 @@ extern "C" { ...@@ -26,15 +26,17 @@ extern "C" {
#define FUNC_MGT_FUNC_CLASSIFICATION_MASK(n) (1 << n) #define FUNC_MGT_FUNC_CLASSIFICATION_MASK(n) (1 << n)
#define FUNC_MGT_AGG_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(0) #define FUNC_MGT_AGG_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(0)
#define FUNC_MGT_SCALAR_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(1) #define FUNC_MGT_SCALAR_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(1)
#define FUNC_MGT_NONSTANDARD_SQL_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(2) #define FUNC_MGT_NONSTANDARD_SQL_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(2)
#define FUNC_MGT_STRING_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(3) #define FUNC_MGT_STRING_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(3)
#define FUNC_MGT_DATETIME_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(4) #define FUNC_MGT_DATETIME_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(4)
#define FUNC_MGT_TIMELINE_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(5) #define FUNC_MGT_TIMELINE_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(5)
#define FUNC_MGT_TIMEORDER_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(6) #define FUNC_MGT_TIMEORDER_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(6)
#define FUNC_MGT_PSEUDO_COLUMN_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(7) #define FUNC_MGT_PSEUDO_COLUMN_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(7)
#define FUNC_MGT_WINDOW_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(8) #define FUNC_MGT_WINDOW_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(8)
#define FUNC_MGT_SPECIAL_DATA_REQUIRED FUNC_MGT_FUNC_CLASSIFICATION_MASK(9)
#define FUNC_MGT_DYNAMIC_SCAN_OPTIMIZED FUNC_MGT_FUNC_CLASSIFICATION_MASK(10)
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
......
...@@ -19,14 +19,14 @@ ...@@ -19,14 +19,14 @@
#include "taoserror.h" #include "taoserror.h"
#include "tdatablock.h" #include "tdatablock.h"
int32_t stubCheckAndGetResultType(SFunctionNode* pFunc); int32_t checkAndGetResultType(SFunctionNode* pFunc);
const SBuiltinFuncDefinition funcMgtBuiltins[] = { const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{ {
.name = "count", .name = "count",
.type = FUNCTION_TYPE_COUNT, .type = FUNCTION_TYPE_COUNT,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getCountFuncEnv, .getEnvFunc = getCountFuncEnv,
.initFunc = functionSetup, .initFunc = functionSetup,
.processFunc = countFunction, .processFunc = countFunction,
...@@ -36,7 +36,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -36,7 +36,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "sum", .name = "sum",
.type = FUNCTION_TYPE_SUM, .type = FUNCTION_TYPE_SUM,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getSumFuncEnv, .getEnvFunc = getSumFuncEnv,
.initFunc = functionSetup, .initFunc = functionSetup,
.processFunc = sumFunction, .processFunc = sumFunction,
...@@ -46,7 +46,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -46,7 +46,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "min", .name = "min",
.type = FUNCTION_TYPE_MIN, .type = FUNCTION_TYPE_MIN,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getMinmaxFuncEnv, .getEnvFunc = getMinmaxFuncEnv,
.initFunc = minFunctionSetup, .initFunc = minFunctionSetup,
.processFunc = minFunction, .processFunc = minFunction,
...@@ -56,7 +56,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -56,7 +56,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "max", .name = "max",
.type = FUNCTION_TYPE_MAX, .type = FUNCTION_TYPE_MAX,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getMinmaxFuncEnv, .getEnvFunc = getMinmaxFuncEnv,
.initFunc = maxFunctionSetup, .initFunc = maxFunctionSetup,
.processFunc = maxFunction, .processFunc = maxFunction,
...@@ -66,7 +66,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -66,7 +66,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "stddev", .name = "stddev",
.type = FUNCTION_TYPE_STDDEV, .type = FUNCTION_TYPE_STDDEV,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getStddevFuncEnv, .getEnvFunc = getStddevFuncEnv,
.initFunc = stddevFunctionSetup, .initFunc = stddevFunctionSetup,
.processFunc = stddevFunction, .processFunc = stddevFunction,
...@@ -76,7 +76,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -76,7 +76,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "percentile", .name = "percentile",
.type = FUNCTION_TYPE_PERCENTILE, .type = FUNCTION_TYPE_PERCENTILE,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getPercentileFuncEnv, .getEnvFunc = getPercentileFuncEnv,
.initFunc = percentileFunctionSetup, .initFunc = percentileFunctionSetup,
.processFunc = percentileFunction, .processFunc = percentileFunction,
...@@ -86,7 +86,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -86,7 +86,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "apercentile", .name = "apercentile",
.type = FUNCTION_TYPE_APERCENTILE, .type = FUNCTION_TYPE_APERCENTILE,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getMinmaxFuncEnv, .getEnvFunc = getMinmaxFuncEnv,
.initFunc = maxFunctionSetup, .initFunc = maxFunctionSetup,
.processFunc = maxFunction, .processFunc = maxFunction,
...@@ -96,7 +96,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -96,7 +96,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "top", .name = "top",
.type = FUNCTION_TYPE_TOP, .type = FUNCTION_TYPE_TOP,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getMinmaxFuncEnv, .getEnvFunc = getMinmaxFuncEnv,
.initFunc = maxFunctionSetup, .initFunc = maxFunctionSetup,
.processFunc = maxFunction, .processFunc = maxFunction,
...@@ -106,7 +106,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -106,7 +106,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "bottom", .name = "bottom",
.type = FUNCTION_TYPE_BOTTOM, .type = FUNCTION_TYPE_BOTTOM,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getMinmaxFuncEnv, .getEnvFunc = getMinmaxFuncEnv,
.initFunc = maxFunctionSetup, .initFunc = maxFunctionSetup,
.processFunc = maxFunction, .processFunc = maxFunction,
...@@ -116,7 +116,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -116,7 +116,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "spread", .name = "spread",
.type = FUNCTION_TYPE_SPREAD, .type = FUNCTION_TYPE_SPREAD,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getMinmaxFuncEnv, .getEnvFunc = getMinmaxFuncEnv,
.initFunc = maxFunctionSetup, .initFunc = maxFunctionSetup,
.processFunc = maxFunction, .processFunc = maxFunction,
...@@ -126,7 +126,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -126,7 +126,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "last_row", .name = "last_row",
.type = FUNCTION_TYPE_LAST_ROW, .type = FUNCTION_TYPE_LAST_ROW,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getMinmaxFuncEnv, .getEnvFunc = getMinmaxFuncEnv,
.initFunc = maxFunctionSetup, .initFunc = maxFunctionSetup,
.processFunc = maxFunction, .processFunc = maxFunction,
...@@ -136,7 +136,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -136,7 +136,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "first", .name = "first",
.type = FUNCTION_TYPE_FIRST, .type = FUNCTION_TYPE_FIRST,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getFirstLastFuncEnv, .getEnvFunc = getFirstLastFuncEnv,
.initFunc = functionSetup, .initFunc = functionSetup,
.processFunc = firstFunction, .processFunc = firstFunction,
...@@ -146,7 +146,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -146,7 +146,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "last", .name = "last",
.type = FUNCTION_TYPE_LAST, .type = FUNCTION_TYPE_LAST,
.classification = FUNC_MGT_AGG_FUNC, .classification = FUNC_MGT_AGG_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getFirstLastFuncEnv, .getEnvFunc = getFirstLastFuncEnv,
.initFunc = functionSetup, .initFunc = functionSetup,
.processFunc = lastFunction, .processFunc = lastFunction,
...@@ -156,7 +156,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -156,7 +156,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "diff", .name = "diff",
.type = FUNCTION_TYPE_DIFF, .type = FUNCTION_TYPE_DIFF,
.classification = FUNC_MGT_NONSTANDARD_SQL_FUNC, .classification = FUNC_MGT_NONSTANDARD_SQL_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getDiffFuncEnv, .getEnvFunc = getDiffFuncEnv,
.initFunc = diffFunctionSetup, .initFunc = diffFunctionSetup,
.processFunc = diffFunction, .processFunc = diffFunction,
...@@ -166,7 +166,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -166,7 +166,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "abs", .name = "abs",
.type = FUNCTION_TYPE_ABS, .type = FUNCTION_TYPE_ABS,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = absFunction, .sprocessFunc = absFunction,
...@@ -176,7 +176,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -176,7 +176,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "log", .name = "log",
.type = FUNCTION_TYPE_LOG, .type = FUNCTION_TYPE_LOG,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = logFunction, .sprocessFunc = logFunction,
...@@ -186,7 +186,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -186,7 +186,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "pow", .name = "pow",
.type = FUNCTION_TYPE_POW, .type = FUNCTION_TYPE_POW,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = powFunction, .sprocessFunc = powFunction,
...@@ -196,7 +196,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -196,7 +196,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "sqrt", .name = "sqrt",
.type = FUNCTION_TYPE_SQRT, .type = FUNCTION_TYPE_SQRT,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = sqrtFunction, .sprocessFunc = sqrtFunction,
...@@ -206,7 +206,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -206,7 +206,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "ceil", .name = "ceil",
.type = FUNCTION_TYPE_CEIL, .type = FUNCTION_TYPE_CEIL,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = ceilFunction, .sprocessFunc = ceilFunction,
...@@ -216,7 +216,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -216,7 +216,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "floor", .name = "floor",
.type = FUNCTION_TYPE_FLOOR, .type = FUNCTION_TYPE_FLOOR,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = floorFunction, .sprocessFunc = floorFunction,
...@@ -226,7 +226,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -226,7 +226,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "round", .name = "round",
.type = FUNCTION_TYPE_ROUND, .type = FUNCTION_TYPE_ROUND,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = roundFunction, .sprocessFunc = roundFunction,
...@@ -236,7 +236,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -236,7 +236,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "sin", .name = "sin",
.type = FUNCTION_TYPE_SIN, .type = FUNCTION_TYPE_SIN,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = sinFunction, .sprocessFunc = sinFunction,
...@@ -246,7 +246,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -246,7 +246,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "cos", .name = "cos",
.type = FUNCTION_TYPE_COS, .type = FUNCTION_TYPE_COS,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = cosFunction, .sprocessFunc = cosFunction,
...@@ -256,7 +256,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -256,7 +256,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "tan", .name = "tan",
.type = FUNCTION_TYPE_TAN, .type = FUNCTION_TYPE_TAN,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = tanFunction, .sprocessFunc = tanFunction,
...@@ -266,7 +266,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -266,7 +266,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "asin", .name = "asin",
.type = FUNCTION_TYPE_ASIN, .type = FUNCTION_TYPE_ASIN,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = asinFunction, .sprocessFunc = asinFunction,
...@@ -276,7 +276,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -276,7 +276,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "acos", .name = "acos",
.type = FUNCTION_TYPE_ACOS, .type = FUNCTION_TYPE_ACOS,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = acosFunction, .sprocessFunc = acosFunction,
...@@ -286,7 +286,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -286,7 +286,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "atan", .name = "atan",
.type = FUNCTION_TYPE_ATAN, .type = FUNCTION_TYPE_ATAN,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = atanFunction, .sprocessFunc = atanFunction,
...@@ -296,7 +296,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -296,7 +296,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "length", .name = "length",
.type = FUNCTION_TYPE_LENGTH, .type = FUNCTION_TYPE_LENGTH,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = lengthFunction, .sprocessFunc = lengthFunction,
...@@ -306,7 +306,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -306,7 +306,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "char_length", .name = "char_length",
.type = FUNCTION_TYPE_CHAR_LENGTH, .type = FUNCTION_TYPE_CHAR_LENGTH,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = charLengthFunction, .sprocessFunc = charLengthFunction,
...@@ -316,7 +316,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -316,7 +316,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "concat", .name = "concat",
.type = FUNCTION_TYPE_CONCAT, .type = FUNCTION_TYPE_CONCAT,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = concatFunction, .sprocessFunc = concatFunction,
...@@ -326,7 +326,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -326,7 +326,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "concat_ws", .name = "concat_ws",
.type = FUNCTION_TYPE_CONCAT_WS, .type = FUNCTION_TYPE_CONCAT_WS,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = concatWsFunction, .sprocessFunc = concatWsFunction,
...@@ -336,7 +336,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -336,7 +336,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "lower", .name = "lower",
.type = FUNCTION_TYPE_LOWER, .type = FUNCTION_TYPE_LOWER,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = lowerFunction, .sprocessFunc = lowerFunction,
...@@ -346,7 +346,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -346,7 +346,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "upper", .name = "upper",
.type = FUNCTION_TYPE_UPPER, .type = FUNCTION_TYPE_UPPER,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = upperFunction, .sprocessFunc = upperFunction,
...@@ -356,7 +356,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -356,7 +356,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "ltrim", .name = "ltrim",
.type = FUNCTION_TYPE_LTRIM, .type = FUNCTION_TYPE_LTRIM,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = ltrimFunction, .sprocessFunc = ltrimFunction,
...@@ -366,7 +366,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -366,7 +366,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "rtrim", .name = "rtrim",
.type = FUNCTION_TYPE_RTRIM, .type = FUNCTION_TYPE_RTRIM,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = rtrimFunction, .sprocessFunc = rtrimFunction,
...@@ -376,7 +376,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -376,7 +376,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "substr", .name = "substr",
.type = FUNCTION_TYPE_SUBSTR, .type = FUNCTION_TYPE_SUBSTR,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_STRING_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = substrFunction, .sprocessFunc = substrFunction,
...@@ -386,7 +386,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -386,7 +386,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "cast", .name = "cast",
.type = FUNCTION_TYPE_CAST, .type = FUNCTION_TYPE_CAST,
.classification = FUNC_MGT_SCALAR_FUNC, .classification = FUNC_MGT_SCALAR_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = NULL, .sprocessFunc = NULL,
...@@ -396,7 +396,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -396,7 +396,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "_rowts", .name = "_rowts",
.type = FUNCTION_TYPE_ROWTS, .type = FUNCTION_TYPE_ROWTS,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = getTimePseudoFuncEnv,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = NULL, .sprocessFunc = NULL,
...@@ -406,7 +406,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -406,7 +406,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "tbname", .name = "tbname",
.type = FUNCTION_TYPE_TBNAME, .type = FUNCTION_TYPE_TBNAME,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = NULL, .getEnvFunc = NULL,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = NULL, .sprocessFunc = NULL,
...@@ -416,7 +416,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -416,7 +416,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "_qstartts", .name = "_qstartts",
.type = FUNCTION_TYPE_QSTARTTS, .type = FUNCTION_TYPE_QSTARTTS,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = getTimePseudoFuncEnv,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = qStartTsFunction, .sprocessFunc = qStartTsFunction,
...@@ -426,7 +426,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -426,7 +426,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "_qendts", .name = "_qendts",
.type = FUNCTION_TYPE_QENDTS, .type = FUNCTION_TYPE_QENDTS,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = getTimePseudoFuncEnv,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = qEndTsFunction, .sprocessFunc = qEndTsFunction,
...@@ -436,7 +436,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -436,7 +436,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "_wstartts", .name = "_wstartts",
.type = FUNCTION_TYPE_WSTARTTS, .type = FUNCTION_TYPE_WSTARTTS,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = getTimePseudoFuncEnv,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = winStartTsFunction, .sprocessFunc = winStartTsFunction,
...@@ -446,7 +446,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -446,7 +446,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "_wendts", .name = "_wendts",
.type = FUNCTION_TYPE_QENDTS, .type = FUNCTION_TYPE_QENDTS,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = getTimePseudoFuncEnv,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = winEndTsFunction, .sprocessFunc = winEndTsFunction,
...@@ -456,7 +456,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -456,7 +456,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "_wduration", .name = "_wduration",
.type = FUNCTION_TYPE_WDURATION, .type = FUNCTION_TYPE_WDURATION,
.classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC, .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_WINDOW_PC_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = getTimePseudoFuncEnv,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = winDurFunction, .sprocessFunc = winDurFunction,
...@@ -466,7 +466,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -466,7 +466,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.name = "now", .name = "now",
.type = FUNCTION_TYPE_NOW, .type = FUNCTION_TYPE_NOW,
.classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC, .classification = FUNC_MGT_SCALAR_FUNC | FUNC_MGT_DATETIME_FUNC,
.checkFunc = stubCheckAndGetResultType, .checkFunc = checkAndGetResultType,
.getEnvFunc = getTimePseudoFuncEnv, .getEnvFunc = getTimePseudoFuncEnv,
.initFunc = NULL, .initFunc = NULL,
.sprocessFunc = winDurFunction, .sprocessFunc = winDurFunction,
...@@ -476,7 +476,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { ...@@ -476,7 +476,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFuncDefinition)); const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFuncDefinition));
int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) { int32_t checkAndGetResultType(SFunctionNode* pFunc) {
switch(pFunc->funcType) { switch(pFunc->funcType) {
case FUNCTION_TYPE_WDURATION: case FUNCTION_TYPE_WDURATION:
case FUNCTION_TYPE_COUNT: { case FUNCTION_TYPE_COUNT: {
...@@ -489,7 +489,7 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) { ...@@ -489,7 +489,7 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
int32_t paraType = pParam->node.resType.type; int32_t paraType = pParam->node.resType.type;
int32_t resType = 0; int32_t resType = 0;
if (IS_SIGNED_NUMERIC_TYPE(paraType)) { if (IS_SIGNED_NUMERIC_TYPE(paraType) || paraType == TSDB_DATA_TYPE_BOOL) {
resType = TSDB_DATA_TYPE_BIGINT; resType = TSDB_DATA_TYPE_BIGINT;
} else if (IS_UNSIGNED_NUMERIC_TYPE(paraType)) { } else if (IS_UNSIGNED_NUMERIC_TYPE(paraType)) {
resType = TSDB_DATA_TYPE_UBIGINT; resType = TSDB_DATA_TYPE_UBIGINT;
......
...@@ -138,8 +138,8 @@ int32_t sumFunction(SqlFunctionCtx *pCtx) { ...@@ -138,8 +138,8 @@ int32_t sumFunction(SqlFunctionCtx *pCtx) {
int32_t start = pInput->startRowIndex; int32_t start = pInput->startRowIndex;
int32_t numOfRows = pInput->numOfRows; int32_t numOfRows = pInput->numOfRows;
if (IS_SIGNED_NUMERIC_TYPE(type)) { if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) {
if (type == TSDB_DATA_TYPE_TINYINT) { if (type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_BOOL) {
LIST_ADD_N(pSumRes->isum, pCol, start, numOfRows, int8_t, numOfElem); LIST_ADD_N(pSumRes->isum, pCol, start, numOfRows, int8_t, numOfElem);
} else if (type == TSDB_DATA_TYPE_SMALLINT) { } else if (type == TSDB_DATA_TYPE_SMALLINT) {
LIST_ADD_N(pSumRes->isum, pCol, start, numOfRows, int16_t, numOfElem); LIST_ADD_N(pSumRes->isum, pCol, start, numOfRows, int16_t, numOfElem);
...@@ -212,6 +212,9 @@ bool maxFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) { ...@@ -212,6 +212,9 @@ bool maxFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_UTINYINT:
*((uint8_t *)buf) = 0; *((uint8_t *)buf) = 0;
break; break;
case TSDB_DATA_TYPE_BOOL:
*((int8_t*)buf) = 0;
break;
default: default:
assert(0); assert(0);
} }
...@@ -255,6 +258,9 @@ bool minFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) { ...@@ -255,6 +258,9 @@ bool minFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
SET_DOUBLE_VAL(((double *)buf), DBL_MAX); SET_DOUBLE_VAL(((double *)buf), DBL_MAX);
break; break;
case TSDB_DATA_TYPE_BOOL:
*((int8_t*)buf) = 1;
break;
default: default:
assert(0); assert(0);
} }
...@@ -385,8 +391,8 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) { ...@@ -385,8 +391,8 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
int32_t start = pInput->startRowIndex; int32_t start = pInput->startRowIndex;
int32_t numOfRows = pInput->numOfRows; int32_t numOfRows = pInput->numOfRows;
if (IS_SIGNED_NUMERIC_TYPE(type)) { if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) {
if (type == TSDB_DATA_TYPE_TINYINT) { if (type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_BOOL) {
LOOPCHECK_N(*(int8_t*)buf, pCol, pCtx, int8_t, numOfRows, start, isMinFunc, numOfElems); LOOPCHECK_N(*(int8_t*)buf, pCol, pCtx, int8_t, numOfRows, start, isMinFunc, numOfElems);
} else if (type == TSDB_DATA_TYPE_SMALLINT) { } else if (type == TSDB_DATA_TYPE_SMALLINT) {
LOOPCHECK_N(*(int16_t*) buf, pCol, pCtx, int16_t, numOfRows, start, isMinFunc, numOfElems); LOOPCHECK_N(*(int16_t*) buf, pCol, pCtx, int16_t, numOfRows, start, isMinFunc, numOfElems);
......
...@@ -92,7 +92,7 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int ...@@ -92,7 +92,7 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
ctx->file.readOnly = readOnly; ctx->file.readOnly = readOnly;
if (readOnly == false) { if (readOnly == false) {
// ctx->file.pFile = open(path, O_WRONLY | O_CREAT | O_APPEND, S_IRWXU | S_IRWXG | S_IRWXO); // ctx->file.pFile = open(path, O_WRONLY | O_CREAT | O_APPEND, S_IRWXU | S_IRWXG | S_IRWXO);
ctx->file.pFile = taosOpenFile(path, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); ctx->file.pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
taosFtruncateFile(ctx->file.pFile, 0); taosFtruncateFile(ctx->file.pFile, 0);
int64_t file_size; int64_t file_size;
taosStatFile(path, &file_size, NULL); taosStatFile(path, &file_size, NULL);
......
...@@ -65,7 +65,7 @@ const char* nodesNodeName(ENodeType type) { ...@@ -65,7 +65,7 @@ const char* nodesNodeName(ENodeType type) {
case QUERY_NODE_TARGET: case QUERY_NODE_TARGET:
return "Target"; return "Target";
case QUERY_NODE_DATABLOCK_DESC: case QUERY_NODE_DATABLOCK_DESC:
return "TupleDesc"; return "DataBlockDesc";
case QUERY_NODE_SLOT_DESC: case QUERY_NODE_SLOT_DESC:
return "SlotDesc"; return "SlotDesc";
case QUERY_NODE_COLUMN_DEF: case QUERY_NODE_COLUMN_DEF:
...@@ -1060,6 +1060,7 @@ static int32_t jsonToPhysiSortNode(const SJson* pJson, void* pObj) { ...@@ -1060,6 +1060,7 @@ static int32_t jsonToPhysiSortNode(const SJson* pJson, void* pObj) {
static const char* jkWindowPhysiPlanExprs = "Exprs"; static const char* jkWindowPhysiPlanExprs = "Exprs";
static const char* jkWindowPhysiPlanFuncs = "Funcs"; static const char* jkWindowPhysiPlanFuncs = "Funcs";
static const char* jkWindowPhysiPlanTsPk = "TsPk";
static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) { static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
const SWinodwPhysiNode* pNode = (const SWinodwPhysiNode*)pObj; const SWinodwPhysiNode* pNode = (const SWinodwPhysiNode*)pObj;
...@@ -1071,6 +1072,9 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) { ...@@ -1071,6 +1072,9 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = nodeListToJson(pJson, jkWindowPhysiPlanFuncs, pNode->pFuncs); code = nodeListToJson(pJson, jkWindowPhysiPlanFuncs, pNode->pFuncs);
} }
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkWindowPhysiPlanTsPk, nodeToJson, pNode->pTspk);
}
return code; return code;
} }
...@@ -1085,6 +1089,9 @@ static int32_t jsonToPhysiWindowNode(const SJson* pJson, void* pObj) { ...@@ -1085,6 +1089,9 @@ static int32_t jsonToPhysiWindowNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeList(pJson, jkWindowPhysiPlanFuncs, &pNode->pFuncs); code = jsonToNodeList(pJson, jkWindowPhysiPlanFuncs, &pNode->pFuncs);
} }
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkWindowPhysiPlanTsPk, (SNode**)&pNode->pTspk);
}
return code; return code;
} }
...@@ -1095,7 +1102,6 @@ static const char* jkIntervalPhysiPlanSliding = "Sliding"; ...@@ -1095,7 +1102,6 @@ static const char* jkIntervalPhysiPlanSliding = "Sliding";
static const char* jkIntervalPhysiPlanIntervalUnit = "intervalUnit"; static const char* jkIntervalPhysiPlanIntervalUnit = "intervalUnit";
static const char* jkIntervalPhysiPlanSlidingUnit = "slidingUnit"; static const char* jkIntervalPhysiPlanSlidingUnit = "slidingUnit";
static const char* jkIntervalPhysiPlanFill = "Fill"; static const char* jkIntervalPhysiPlanFill = "Fill";
static const char* jkIntervalPhysiPlanTsPk = "TsPk";
static const char* jkIntervalPhysiPlanPrecision = "Precision"; static const char* jkIntervalPhysiPlanPrecision = "Precision";
static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) { static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
...@@ -1120,9 +1126,6 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) { ...@@ -1120,9 +1126,6 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkIntervalPhysiPlanFill, nodeToJson, pNode->pFill); code = tjsonAddObject(pJson, jkIntervalPhysiPlanFill, nodeToJson, pNode->pFill);
} }
if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddObject(pJson, jkIntervalPhysiPlanTsPk, nodeToJson, pNode->pTspk);
}
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanPrecision, pNode->precision); code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanPrecision, pNode->precision);
} }
...@@ -1152,9 +1155,6 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) { ...@@ -1152,9 +1155,6 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkIntervalPhysiPlanFill, (SNode**)&pNode->pFill); code = jsonToNodeObject(pJson, jkIntervalPhysiPlanFill, (SNode**)&pNode->pFill);
} }
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkIntervalPhysiPlanTsPk, (SNode**)&pNode->pTspk);
}
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetUTinyIntValue(pJson, jkIntervalPhysiPlanPrecision, &pNode->precision); code = tjsonGetUTinyIntValue(pJson, jkIntervalPhysiPlanPrecision, &pNode->precision);
} }
...@@ -2291,7 +2291,7 @@ static int32_t jsonToDataBlockDescNode(const SJson* pJson, void* pObj) { ...@@ -2291,7 +2291,7 @@ static int32_t jsonToDataBlockDescNode(const SJson* pJson, void* pObj) {
code = jsonToNodeList(pJson, jkDataBlockDescSlots, &pNode->pSlots); code = jsonToNodeList(pJson, jkDataBlockDescSlots, &pNode->pSlots);
} }
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetSmallIntValue(pJson, jkDataBlockPrecision, &pNode->precision); code = tjsonGetUTinyIntValue(pJson, jkDataBlockPrecision, &pNode->precision);
} }
return code; return code;
......
...@@ -77,9 +77,14 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker ...@@ -77,9 +77,14 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
case QUERY_NODE_ORDER_BY_EXPR: case QUERY_NODE_ORDER_BY_EXPR:
res = walkNode(((SOrderByExprNode*)pNode)->pExpr, order, walker, pContext); res = walkNode(((SOrderByExprNode*)pNode)->pExpr, order, walker, pContext);
break; break;
case QUERY_NODE_STATE_WINDOW: case QUERY_NODE_STATE_WINDOW: {
res = walkNode(((SStateWindowNode*)pNode)->pExpr, order, walker, pContext); SStateWindowNode* pState = (SStateWindowNode*)pNode;
res = walkNode(pState->pExpr, order, walker, pContext);
if (DEAL_RES_ERROR != res) {
res = walkNode(pState->pCol, order, walker, pContext);
}
break; break;
}
case QUERY_NODE_SESSION_WINDOW: { case QUERY_NODE_SESSION_WINDOW: {
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode; SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
res = walkNode(pSession->pCol, order, walker, pContext); res = walkNode(pSession->pCol, order, walker, pContext);
...@@ -211,12 +216,22 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit ...@@ -211,12 +216,22 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
case QUERY_NODE_ORDER_BY_EXPR: case QUERY_NODE_ORDER_BY_EXPR:
res = rewriteNode(&(((SOrderByExprNode*)pNode)->pExpr), order, rewriter, pContext); res = rewriteNode(&(((SOrderByExprNode*)pNode)->pExpr), order, rewriter, pContext);
break; break;
case QUERY_NODE_STATE_WINDOW: case QUERY_NODE_STATE_WINDOW: {
res = rewriteNode(&(((SStateWindowNode*)pNode)->pExpr), order, rewriter, pContext); SStateWindowNode* pState = (SStateWindowNode*)pNode;
res = rewriteNode(&pState->pExpr, order, rewriter, pContext);
if (DEAL_RES_ERROR != res) {
res = rewriteNode(&pState->pCol, order, rewriter, pContext);
}
break; break;
case QUERY_NODE_SESSION_WINDOW: }
res = rewriteNode(&(((SSessionWindowNode*)pNode)->pCol), order, rewriter, pContext); case QUERY_NODE_SESSION_WINDOW: {
SSessionWindowNode* pSession = (SSessionWindowNode*)pNode;
res = rewriteNode(&pSession->pCol, order, rewriter, pContext);
if (DEAL_RES_ERROR != res) {
res = rewriteNode(&pSession->pGap, order, rewriter, pContext);
}
break; break;
}
case QUERY_NODE_INTERVAL_WINDOW: { case QUERY_NODE_INTERVAL_WINDOW: {
SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pNode; SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pNode;
res = rewriteNode(&(pInterval->pInterval), order, rewriter, pContext); res = rewriteNode(&(pInterval->pInterval), order, rewriter, pContext);
......
...@@ -252,6 +252,7 @@ static void destroyWinodwPhysiNode(SWinodwPhysiNode* pNode) { ...@@ -252,6 +252,7 @@ static void destroyWinodwPhysiNode(SWinodwPhysiNode* pNode) {
destroyPhysiNode((SPhysiNode*)pNode); destroyPhysiNode((SPhysiNode*)pNode);
nodesDestroyList(pNode->pExprs); nodesDestroyList(pNode->pExprs);
nodesDestroyList(pNode->pFuncs); nodesDestroyList(pNode->pFuncs);
nodesDestroyNode(pNode->pTspk);
} }
static void destroyScanPhysiNode(SScanPhysiNode* pNode) { static void destroyScanPhysiNode(SScanPhysiNode* pNode) {
...@@ -593,7 +594,6 @@ void nodesDestroyNode(SNodeptr pNode) { ...@@ -593,7 +594,6 @@ void nodesDestroyNode(SNodeptr pNode) {
SIntervalPhysiNode* pPhyNode = (SIntervalPhysiNode*)pNode; SIntervalPhysiNode* pPhyNode = (SIntervalPhysiNode*)pNode;
destroyWinodwPhysiNode((SWinodwPhysiNode*)pPhyNode); destroyWinodwPhysiNode((SWinodwPhysiNode*)pPhyNode);
nodesDestroyNode(pPhyNode->pFill); nodesDestroyNode(pPhyNode->pFill);
nodesDestroyNode(pPhyNode->pTspk);
break; break;
} }
case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW: case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW:
......
...@@ -207,7 +207,9 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { ...@@ -207,7 +207,9 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
CHECK_RAW_EXPR_NODE(pNode); CHECK_RAW_EXPR_NODE(pNode);
SRawExprNode* pRawExpr = (SRawExprNode*)pNode; SRawExprNode* pRawExpr = (SRawExprNode*)pNode;
SNode* pExpr = pRawExpr->pNode; SNode* pExpr = pRawExpr->pNode;
strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, pRawExpr->n); if (nodesIsExprNode(pExpr)) {
strncpy(((SExprNode*)pExpr)->aliasName, pRawExpr->p, pRawExpr->n);
}
taosMemoryFreeClear(pNode); taosMemoryFreeClear(pNode);
return pExpr; return pExpr;
} }
...@@ -456,6 +458,13 @@ SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap ...@@ -456,6 +458,13 @@ SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap
SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) { SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) {
SStateWindowNode* state = (SStateWindowNode*)nodesMakeNode(QUERY_NODE_STATE_WINDOW); SStateWindowNode* state = (SStateWindowNode*)nodesMakeNode(QUERY_NODE_STATE_WINDOW);
CHECK_OUT_OF_MEM(state); CHECK_OUT_OF_MEM(state);
state->pCol = nodesMakeNode(QUERY_NODE_COLUMN);
if (NULL == state->pCol) {
nodesDestroyNode(state);
CHECK_OUT_OF_MEM(state->pCol);
}
((SColumnNode*)state->pCol)->colId = PRIMARYKEY_TIMESTAMP_COL_ID;
strcpy(((SColumnNode*)state->pCol)->colName, PK_TS_COL_INTERNAL_NAME);
state->pExpr = pExpr; state->pExpr = pExpr;
return (SNode*)state; return (SNode*)state;
} }
...@@ -498,8 +507,9 @@ SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* p ...@@ -498,8 +507,9 @@ SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* p
if (NULL == pNode || !pCxt->valid) { if (NULL == pNode || !pCxt->valid) {
return pNode; return pNode;
} }
uint32_t maxLen = sizeof(((SExprNode*)pNode)->aliasName); int32_t len = TMIN(sizeof(((SExprNode*)pNode)->aliasName) - 1, pAlias->n);
strncpy(((SExprNode*)pNode)->aliasName, pAlias->z, pAlias->n > maxLen ? maxLen : pAlias->n); strncpy(((SExprNode*)pNode)->aliasName, pAlias->z, len);
((SExprNode*)pNode)->aliasName[len] = '\0';
return pNode; return pNode;
} }
...@@ -584,34 +594,6 @@ SNode* createDatabaseOptions(SAstCreateContext* pCxt) { ...@@ -584,34 +594,6 @@ SNode* createDatabaseOptions(SAstCreateContext* pCxt) {
return (SNode*)pOptions; return (SNode*)pOptions;
} }
static bool checkAndSetKeepOption(SAstCreateContext* pCxt, SNodeList* pKeep, int32_t* pKeep0, int32_t* pKeep1, int32_t* pKeep2) {
int32_t numOfKeep = LIST_LENGTH(pKeep);
if (numOfKeep > 3 || numOfKeep < 1) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid number of keep options");
return false;
}
int32_t daysToKeep0 = strtol(((SValueNode*)nodesListGetNode(pKeep, 0))->literal, NULL, 10);
int32_t daysToKeep1 = numOfKeep > 1 ? strtol(((SValueNode*)nodesListGetNode(pKeep, 1))->literal, NULL, 10) : daysToKeep0;
int32_t daysToKeep2 = numOfKeep > 2 ? strtol(((SValueNode*)nodesListGetNode(pKeep, 2))->literal, NULL, 10) : daysToKeep1;
if (daysToKeep0 < TSDB_MIN_KEEP || daysToKeep1 < TSDB_MIN_KEEP || daysToKeep2 < TSDB_MIN_KEEP ||
daysToKeep0 > TSDB_MAX_KEEP || daysToKeep1 > TSDB_MAX_KEEP || daysToKeep2 > TSDB_MAX_KEEP) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen,
"invalid option keep: %d, %d, %d valid range: [%d, %d]", daysToKeep0, daysToKeep1, daysToKeep2, TSDB_MIN_KEEP, TSDB_MAX_KEEP);
return false;
}
if (!((daysToKeep0 <= daysToKeep1) && (daysToKeep1 <= daysToKeep2))) {
snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid keep value, should be keep0 <= keep1 <= keep2");
return false;
}
*pKeep0 = daysToKeep0;
*pKeep1 = daysToKeep1;
*pKeep2 = daysToKeep2;
return true;
}
SNode* setDatabaseAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) { SNode* setDatabaseAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) {
switch (pAlterOption->type) { switch (pAlterOption->type) {
case DB_OPTION_BLOCKS: case DB_OPTION_BLOCKS:
......
...@@ -45,7 +45,7 @@ static EDealRes calcConstOperator(SOperatorNode** pNode, void* pContext) { ...@@ -45,7 +45,7 @@ static EDealRes calcConstOperator(SOperatorNode** pNode, void* pContext) {
static EDealRes calcConstFunction(SFunctionNode** pNode, void* pContext) { static EDealRes calcConstFunction(SFunctionNode** pNode, void* pContext) {
SFunctionNode* pFunc = *pNode; SFunctionNode* pFunc = *pNode;
if (fmIsPseudoColumnFunc(pFunc->funcId)) { if (!fmIsScalarFunc(pFunc->funcId)) {
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
SNode* pParam = NULL; SNode* pParam = NULL;
...@@ -61,6 +61,7 @@ static EDealRes calcConstLogicCond(SLogicConditionNode** pNode, void* pContext) ...@@ -61,6 +61,7 @@ static EDealRes calcConstLogicCond(SLogicConditionNode** pNode, void* pContext)
SLogicConditionNode* pCond = *pNode; SLogicConditionNode* pCond = *pNode;
SNode* pParam = NULL; SNode* pParam = NULL;
FOREACH(pParam, pCond->pParameterList) { FOREACH(pParam, pCond->pParameterList) {
// todo calc "true and c1 > 10"
if (QUERY_NODE_VALUE != nodeType(pParam)) { if (QUERY_NODE_VALUE != nodeType(pParam)) {
return DEAL_RES_CONTINUE; return DEAL_RES_CONTINUE;
} }
......
...@@ -605,6 +605,12 @@ typedef struct SMemParam { ...@@ -605,6 +605,12 @@ typedef struct SMemParam {
static FORCE_INLINE int32_t MemRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param) { static FORCE_INLINE int32_t MemRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param) {
SMemParam* pa = (SMemParam*)param; SMemParam* pa = (SMemParam*)param;
SRowBuilder* rb = pa->rb; SRowBuilder* rb = pa->rb;
if (value == NULL) { // it is a null data
tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NULL, value, false, pa->toffset, pa->colIdx);
return TSDB_CODE_SUCCESS;
}
if (TSDB_DATA_TYPE_BINARY == pa->schema->type) { if (TSDB_DATA_TYPE_BINARY == pa->schema->type) {
const char* rowEnd = tdRowEnd(rb->pBuf); const char* rowEnd = tdRowEnd(rb->pBuf);
STR_WITH_SIZE_TO_VARSTR(rowEnd, value, len); STR_WITH_SIZE_TO_VARSTR(rowEnd, value, len);
...@@ -621,14 +627,9 @@ static FORCE_INLINE int32_t MemRowAppend(SMsgBuf* pMsgBuf, const void* value, in ...@@ -621,14 +627,9 @@ static FORCE_INLINE int32_t MemRowAppend(SMsgBuf* pMsgBuf, const void* value, in
varDataSetLen(rowEnd, output); varDataSetLen(rowEnd, output);
tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx);
} else { } else {
if (value == NULL) { // it is a null data tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, false, pa->toffset, pa->colIdx);
tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NULL, value, false, pa->toffset,
pa->colIdx);
} else {
tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, false, pa->toffset,
pa->colIdx);
}
} }
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -488,6 +488,12 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo ...@@ -488,6 +488,12 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo
pWindow->winType = WINDOW_TYPE_STATE; pWindow->winType = WINDOW_TYPE_STATE;
pWindow->pStateExpr = nodesCloneNode(pState->pExpr); pWindow->pStateExpr = nodesCloneNode(pState->pExpr);
pWindow->pTspk = nodesCloneNode(pState->pCol);
if (NULL == pWindow->pTspk) {
nodesDestroyNode(pWindow);
return TSDB_CODE_OUT_OF_MEMORY;
}
return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode); return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode);
} }
...@@ -500,6 +506,12 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW ...@@ -500,6 +506,12 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW
pWindow->winType = WINDOW_TYPE_SESSION; pWindow->winType = WINDOW_TYPE_SESSION;
pWindow->sessionGap = ((SValueNode*)pSession->pGap)->datum.i; pWindow->sessionGap = ((SValueNode*)pSession->pGap)->datum.i;
pWindow->pTspk = nodesCloneNode(pSession->pCol);
if (NULL == pWindow->pTspk) {
nodesDestroyNode(pWindow);
return TSDB_CODE_OUT_OF_MEMORY;
}
return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode); return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode);
} }
......
...@@ -316,7 +316,18 @@ static int32_t setListSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, i ...@@ -316,7 +316,18 @@ static int32_t setListSlotId(SPhysiPlanContext* pCxt, int16_t leftDataBlockId, i
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode, ENodeType type) { static uint8_t getPrecision(SNodeList* pChildren) {
if (1 == LIST_LENGTH(pChildren)) {
return (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc)->precision;
} else if (2 == LIST_LENGTH(pChildren)) {
uint8_t lp = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc)->precision;
uint8_t rp = (((SPhysiNode*)nodesListGetNode(pChildren, 1))->pOutputDataBlockDesc)->precision;
return (lp > rp ? rp : lp);
}
return 0;
}
static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, uint8_t precision, SLogicNode* pLogicNode, ENodeType type) {
SPhysiNode* pPhysiNode = (SPhysiNode*)nodesMakeNode(type); SPhysiNode* pPhysiNode = (SPhysiNode*)nodesMakeNode(type);
if (NULL == pPhysiNode) { if (NULL == pPhysiNode) {
return NULL; return NULL;
...@@ -327,6 +338,7 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode ...@@ -327,6 +338,7 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode
nodesDestroyNode(pPhysiNode); nodesDestroyNode(pPhysiNode);
return NULL; return NULL;
} }
pPhysiNode->pOutputDataBlockDesc->precision = precision;
return pPhysiNode; return pPhysiNode;
} }
...@@ -405,7 +417,7 @@ static void vgroupInfoToNodeAddr(const SVgroupInfo* vg, SQueryNodeAddr* pNodeAdd ...@@ -405,7 +417,7 @@ static void vgroupInfoToNodeAddr(const SVgroupInfo* vg, SQueryNodeAddr* pNodeAdd
} }
static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) { static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
STagScanPhysiNode* pTagScan = (STagScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN); STagScanPhysiNode* pTagScan = (STagScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN);
if (NULL == pTagScan) { if (NULL == pTagScan) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -413,7 +425,7 @@ static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* p ...@@ -413,7 +425,7 @@ static int32_t createTagScanPhysiNode(SPhysiPlanContext* pCxt, SScanLogicNode* p
} }
static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) { static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
STableScanPhysiNode* pTableScan = (STableScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN); STableScanPhysiNode* pTableScan = (STableScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN);
if (NULL == pTableScan) { if (NULL == pTableScan) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -430,7 +442,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp ...@@ -430,7 +442,7 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
} }
static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) { static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
SSystemTableScanPhysiNode* pScan = (SSystemTableScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN); SSystemTableScanPhysiNode* pScan = (SSystemTableScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN);
if (NULL == pScan) { if (NULL == pScan) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -451,7 +463,7 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* ...@@ -451,7 +463,7 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
} }
static int32_t createStreamScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) { static int32_t createStreamScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) {
SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN); SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, pScanLogicNode->pMeta->tableInfo.precision, (SLogicNode*)pScanLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN);
if (NULL == pScan) { if (NULL == pScan) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -515,7 +527,7 @@ static int32_t createJoinOutputCols(SPhysiPlanContext* pCxt, SDataBlockDescNode* ...@@ -515,7 +527,7 @@ static int32_t createJoinOutputCols(SPhysiPlanContext* pCxt, SDataBlockDescNode*
} }
static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode, SPhysiNode** pPhyNode) { static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SJoinLogicNode* pJoinLogicNode, SPhysiNode** pPhyNode) {
SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_JOIN); SJoinPhysiNode* pJoin = (SJoinPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pJoinLogicNode, QUERY_NODE_PHYSICAL_PLAN_JOIN);
if (NULL == pJoin) { if (NULL == pJoin) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -656,7 +668,7 @@ static int32_t rewritePrecalcExpr(SPhysiPlanContext* pCxt, SNode* pNode, SNodeLi ...@@ -656,7 +668,7 @@ static int32_t rewritePrecalcExpr(SPhysiPlanContext* pCxt, SNode* pNode, SNodeLi
} }
static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SAggLogicNode* pAggLogicNode, SPhysiNode** pPhyNode) { static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SAggLogicNode* pAggLogicNode, SPhysiNode** pPhyNode) {
SAggPhysiNode* pAgg = (SAggPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pAggLogicNode, QUERY_NODE_PHYSICAL_PLAN_AGG); SAggPhysiNode* pAgg = (SAggPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pAggLogicNode, QUERY_NODE_PHYSICAL_PLAN_AGG);
if (NULL == pAgg) { if (NULL == pAgg) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -710,7 +722,7 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, ...@@ -710,7 +722,7 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
} }
static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SProjectLogicNode* pProjectLogicNode, SPhysiNode** pPhyNode) { static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SProjectLogicNode* pProjectLogicNode, SPhysiNode** pPhyNode) {
SProjectPhysiNode* pProject = (SProjectPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pProjectLogicNode, QUERY_NODE_PHYSICAL_PLAN_PROJECT); SProjectPhysiNode* pProject = (SProjectPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pProjectLogicNode, QUERY_NODE_PHYSICAL_PLAN_PROJECT);
if (NULL == pProject) { if (NULL == pProject) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -738,18 +750,18 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild ...@@ -738,18 +750,18 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild
} }
static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, SPhysiNode** pPhyNode) { static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, SPhysiNode** pPhyNode) {
SExchangePhysiNode* pExchange = (SExchangePhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_EXCHANGE); SExchangePhysiNode* pExchange = (SExchangePhysiNode*)makePhysiNode(pCxt, pExchangeLogicNode->precision, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_EXCHANGE);
if (NULL == pExchange) { if (NULL == pExchange) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
pExchange->srcGroupId = pExchangeLogicNode->srcGroupId; pExchange->srcGroupId = pExchangeLogicNode->srcGroupId;
*pPhyNode = (SPhysiNode*)pExchange; *pPhyNode = (SPhysiNode*)pExchange;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, SPhysiNode** pPhyNode) { static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, SPhysiNode** pPhyNode) {
SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN); SStreamScanPhysiNode* pScan = (SStreamScanPhysiNode*)makePhysiNode(pCxt, pExchangeLogicNode->precision, (SLogicNode*)pExchangeLogicNode, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN);
if (NULL == pScan) { if (NULL == pScan) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -803,6 +815,10 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* ...@@ -803,6 +815,10 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
} }
} }
if (TSDB_CODE_SUCCESS == code) {
code = setNodeSlotId(pCxt, pChildTupe->dataBlockId, -1, pWindowLogicNode->pTspk, &pWindow->pTspk);
}
if (TSDB_CODE_SUCCESS == code && NULL != pFuncs) { if (TSDB_CODE_SUCCESS == code && NULL != pFuncs) {
code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pFuncs, &pWindow->pFuncs); code = setListSlotId(pCxt, pChildTupe->dataBlockId, -1, pFuncs, &pWindow->pFuncs);
if (TSDB_CODE_SUCCESS == code) { if (TSDB_CODE_SUCCESS == code) {
...@@ -820,7 +836,7 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList* ...@@ -820,7 +836,7 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
} }
static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) { static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_INTERVAL); SIntervalPhysiNode* pInterval = (SIntervalPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_INTERVAL);
if (NULL == pInterval) { if (NULL == pInterval) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -838,18 +854,11 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil ...@@ -838,18 +854,11 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
SDataBlockDescNode* pChildTupe = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc);
int32_t code = setNodeSlotId(pCxt, pChildTupe->dataBlockId, -1, pWindowLogicNode->pTspk, &pInterval->pTspk);
if (TSDB_CODE_SUCCESS != code) {
nodesDestroyNode(pInterval);
return code;
}
return createWindowPhysiNodeFinalize(pCxt, pChildren, &pInterval->window, pWindowLogicNode, pPhyNode); return createWindowPhysiNodeFinalize(pCxt, pChildren, &pInterval->window, pWindowLogicNode, pPhyNode);
} }
static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) { static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
SSessionWinodwPhysiNode* pSession = (SSessionWinodwPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW); SSessionWinodwPhysiNode* pSession = (SSessionWinodwPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW);
if (NULL == pSession) { if (NULL == pSession) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -860,7 +869,7 @@ static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* ...@@ -860,7 +869,7 @@ static int32_t createSessionWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList*
} }
static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) { static int32_t createStateWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) {
SStateWinodwPhysiNode* pState = (SStateWinodwPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW); SStateWinodwPhysiNode* pState = (SStateWinodwPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pWindowLogicNode, QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW);
if (NULL == pState) { if (NULL == pState) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -908,7 +917,7 @@ static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildr ...@@ -908,7 +917,7 @@ static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildr
} }
static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SSortLogicNode* pSortLogicNode, SPhysiNode** pPhyNode) { static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SSortLogicNode* pSortLogicNode, SPhysiNode** pPhyNode) {
SSortPhysiNode* pSort = (SSortPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pSortLogicNode, QUERY_NODE_PHYSICAL_PLAN_SORT); SSortPhysiNode* pSort = (SSortPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pSortLogicNode, QUERY_NODE_PHYSICAL_PLAN_SORT);
if (NULL == pSort) { if (NULL == pSort) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -947,7 +956,7 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren ...@@ -947,7 +956,7 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
} }
static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) { static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) {
SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pPartLogicNode, QUERY_NODE_PHYSICAL_PLAN_PARTITION); SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)makePhysiNode(pCxt, getPrecision(pChildren), (SLogicNode*)pPartLogicNode, QUERY_NODE_PHYSICAL_PLAN_PARTITION);
if (NULL == pPart) { if (NULL == pPart) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
...@@ -1229,6 +1238,7 @@ static void setExplainInfo(SPlanContext* pCxt, SQueryPlan* pPlan) { ...@@ -1229,6 +1238,7 @@ static void setExplainInfo(SPlanContext* pCxt, SQueryPlan* pPlan) {
SExplainStmt* pStmt = (SExplainStmt*)pCxt->pAstRoot; SExplainStmt* pStmt = (SExplainStmt*)pCxt->pAstRoot;
pPlan->explainInfo.mode = pStmt->analyze ? EXPLAIN_MODE_ANALYZE : EXPLAIN_MODE_STATIC; pPlan->explainInfo.mode = pStmt->analyze ? EXPLAIN_MODE_ANALYZE : EXPLAIN_MODE_STATIC;
pPlan->explainInfo.verbose = pStmt->pOptions->verbose; pPlan->explainInfo.verbose = pStmt->pOptions->verbose;
pPlan->explainInfo.ratio = pStmt->pOptions->ratio;
} else { } else {
pPlan->explainInfo.mode = EXPLAIN_MODE_DISABLE; pPlan->explainInfo.mode = EXPLAIN_MODE_DISABLE;
} }
......
...@@ -103,6 +103,7 @@ static int32_t stsCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla ...@@ -103,6 +103,7 @@ static int32_t stsCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
pExchange->srcGroupId = pCxt->groupId; pExchange->srcGroupId = pCxt->groupId;
pExchange->precision = pScan->pMeta->tableInfo.precision;
pExchange->node.pTargets = nodesCloneList(pScan->node.pTargets); pExchange->node.pTargets = nodesCloneList(pScan->node.pTargets);
if (NULL == pExchange->node.pTargets) { if (NULL == pExchange->node.pTargets) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
......
...@@ -79,6 +79,7 @@ typedef struct SQWConnInfo { ...@@ -79,6 +79,7 @@ typedef struct SQWConnInfo {
typedef struct SQWMsg { typedef struct SQWMsg {
void *node; void *node;
int32_t code;
char *msg; char *msg;
int32_t msgLen; int32_t msgLen;
SQWConnInfo connInfo; SQWConnInfo connInfo;
......
...@@ -536,6 +536,8 @@ int32_t qwDropTask(QW_FPARAMS_DEF) { ...@@ -536,6 +536,8 @@ int32_t qwDropTask(QW_FPARAMS_DEF) {
QW_ERR_RET(qwDropTaskStatus(QW_FPARAMS())); QW_ERR_RET(qwDropTaskStatus(QW_FPARAMS()));
QW_ERR_RET(qwDropTaskCtx(QW_FPARAMS())); QW_ERR_RET(qwDropTaskCtx(QW_FPARAMS()));
QW_TASK_DLOG_E("task is dropped");
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -1239,8 +1241,10 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) { ...@@ -1239,8 +1241,10 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
QW_ERR_JRET(qwKillTaskHandle(QW_FPARAMS(), ctx)); QW_ERR_JRET(qwKillTaskHandle(QW_FPARAMS(), ctx));
qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_DROPPING); qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_DROPPING);
} else if (ctx->phase > 0) { } else if (ctx->phase > 0) {
qwBuildAndSendDropRsp(&qwMsg->connInfo, code); if (0 == qwMsg->code) {
QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", qwMsg->connInfo.handle, code, tstrerror(code)); qwBuildAndSendDropRsp(&qwMsg->connInfo, code);
QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", qwMsg->connInfo.handle, code, tstrerror(code));
}
QW_ERR_JRET(qwDropTask(QW_FPARAMS())); QW_ERR_JRET(qwDropTask(QW_FPARAMS()));
rsped = true; rsped = true;
...@@ -1273,7 +1277,7 @@ _return: ...@@ -1273,7 +1277,7 @@ _return:
qwReleaseTaskCtx(mgmt, ctx); qwReleaseTaskCtx(mgmt, ctx);
} }
if (TSDB_CODE_SUCCESS != code) { if ((TSDB_CODE_SUCCESS != code) && (0 == qwMsg->code)) {
qwBuildAndSendDropRsp(&qwMsg->connInfo, code); qwBuildAndSendDropRsp(&qwMsg->connInfo, code);
QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", qwMsg->connInfo.handle, code, tstrerror(code)); QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", qwMsg->connInfo.handle, code, tstrerror(code));
} }
......
...@@ -549,7 +549,7 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) { ...@@ -549,7 +549,7 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg) {
uint64_t tId = msg->taskId; uint64_t tId = msg->taskId;
int64_t rId = msg->refId; int64_t rId = msg->refId;
SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0}; SQWMsg qwMsg = {.node = node, .msg = NULL, .msgLen = 0, .code = pMsg->code};
qwMsg.connInfo.handle = pMsg->handle; qwMsg.connInfo.handle = pMsg->handle;
qwMsg.connInfo.ahandle = pMsg->ahandle; qwMsg.connInfo.ahandle = pMsg->ahandle;
......
...@@ -1748,7 +1748,6 @@ int32_t fltInitValFieldData(SFilterInfo *info) { ...@@ -1748,7 +1748,6 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
SFilterField* fi = right; SFilterField* fi = right;
SValueNode* var = (SValueNode *)fi->desc; SValueNode* var = (SValueNode *)fi->desc;
if (var == NULL) { if (var == NULL) {
assert(fi->data != NULL); assert(fi->data != NULL);
continue; continue;
...@@ -1767,13 +1766,18 @@ int32_t fltInitValFieldData(SFilterInfo *info) { ...@@ -1767,13 +1766,18 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
} }
SDataType *dType = &var->node.resType; SDataType *dType = &var->node.resType;
size_t bytes = 0;
if (type == TSDB_DATA_TYPE_BINARY) { if (type == TSDB_DATA_TYPE_BINARY) {
size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes : MAX_NUM_STR_SIZE; size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes : MAX_NUM_STR_SIZE;
fi->data = taosMemoryCalloc(1, len + 1 + VARSTR_HEADER_SIZE); bytes = len + 1 + VARSTR_HEADER_SIZE;
fi->data = taosMemoryCalloc(1, bytes);
} else if (type == TSDB_DATA_TYPE_NCHAR) { } else if (type == TSDB_DATA_TYPE_NCHAR) {
size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes : MAX_NUM_STR_SIZE; size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes : MAX_NUM_STR_SIZE;
fi->data = taosMemoryCalloc(1, (len + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); bytes = (len + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE;
fi->data = taosMemoryCalloc(1, bytes);
} else if (type != TSDB_DATA_TYPE_JSON){ } else if (type != TSDB_DATA_TYPE_JSON){
if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) { //TIME RANGE if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) { //TIME RANGE
/* /*
...@@ -1797,8 +1801,11 @@ int32_t fltInitValFieldData(SFilterInfo *info) { ...@@ -1797,8 +1801,11 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
} else { } else {
SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))};
out.columnData->info.type = type; out.columnData->info.type = type;
out.columnData->info.bytes = tDataTypes[type].bytes; if (IS_VAR_DATA_TYPE(type)) {
ASSERT(!IS_VAR_DATA_TYPE(type)); out.columnData->info.bytes = bytes;
} else {
out.columnData->info.bytes = tDataTypes[type].bytes;
}
// todo refactor the convert // todo refactor the convert
int32_t code = doConvertDataType(var, &out); int32_t code = doConvertDataType(var, &out);
...@@ -2985,13 +2992,13 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa ...@@ -2985,13 +2992,13 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SColumnDa
for (int32_t i = 0; i < numOfRows; ++i) { for (int32_t i = 0; i < numOfRows; ++i) {
uint32_t uidx = info->groups[0].unitIdxs[0]; uint32_t uidx = info->groups[0].unitIdxs[0];
void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i);
if (colData == NULL || colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL)) { if (colData == NULL || colDataIsNull_s((SColumnInfoData *)info->cunits[uidx].colData, i)) {
(*p)[i] = 0; (*p)[i] = 0;
all = false; all = false;
continue; continue;
} }
// match/nmatch for nchar type need convert from ucs4 to mbs
// match/nmatch for nchar type need convert from ucs4 to mbs
if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_NCHAR && (info->cunits[uidx].optr == OP_TYPE_MATCH || info->cunits[uidx].optr == OP_TYPE_NMATCH)){ if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_NCHAR && (info->cunits[uidx].optr == OP_TYPE_MATCH || info->cunits[uidx].optr == OP_TYPE_NMATCH)){
char *newColData = taosMemoryCalloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); char *newColData = taosMemoryCalloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1);
int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(colData), varDataLen(colData), varDataVal(newColData));
...@@ -3222,19 +3229,13 @@ int32_t fltInitFromNode(SNode* tree, SFilterInfo *info, uint32_t options) { ...@@ -3222,19 +3229,13 @@ int32_t fltInitFromNode(SNode* tree, SFilterInfo *info, uint32_t options) {
info->unitFlags = taosMemoryMalloc(info->unitNum * sizeof(*info->unitFlags)); info->unitFlags = taosMemoryMalloc(info->unitNum * sizeof(*info->unitFlags));
filterDumpInfoToString(info, "Final", 0); filterDumpInfoToString(info, "Final", 0);
return code; return code;
_return: _return:
qInfo("init from node failed, code:%d", code); qInfo("init from node failed, code:%d", code);
return code; return code;
} }
bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows) { bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows) {
if (FILTER_EMPTY_RES(info)) { if (FILTER_EMPTY_RES(info)) {
return false; return false;
......
...@@ -46,7 +46,6 @@ int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out) { ...@@ -46,7 +46,6 @@ int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out) {
colDataAppend(in.columnData, 0, nodesGetValueFromNode(pValueNode), false); colDataAppend(in.columnData, 0, nodesGetValueFromNode(pValueNode), false);
colInfoDataEnsureCapacity(out->columnData, 1); colInfoDataEnsureCapacity(out->columnData, 1);
int32_t code = vectorConvertImpl(&in, out); int32_t code = vectorConvertImpl(&in, out);
sclFreeParam(&in); sclFreeParam(&in);
......
...@@ -177,9 +177,24 @@ static FORCE_INLINE void varToBool(char *buf, SScalarParam* pOut, int32_t rowInd ...@@ -177,9 +177,24 @@ static FORCE_INLINE void varToBool(char *buf, SScalarParam* pOut, int32_t rowInd
colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*) &v); colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*) &v);
} }
static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIndex) {
int32_t len = 0;
int32_t inputLen = varDataLen(buf);
char* t = taosMemoryCalloc(1,(inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE);
/*int32_t resLen = */taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4*) varDataVal(t), pOut->columnData->info.bytes, &len);
varDataSetLen(t, len);
colDataAppend(pOut->columnData, rowIndex, t, false);
taosMemoryFree(t);
}
//TODO opt performance, tmp is not needed.
int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType) { int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType) {
int32_t bufSize = pIn->columnData->info.bytes; int32_t bufSize = pIn->columnData->info.bytes;
char *tmp = taosMemoryMalloc(bufSize); char *tmp = taosMemoryMalloc(bufSize + VARSTR_HEADER_SIZE);
bool vton = false;
_bufConverteFunc func = NULL; _bufConverteFunc func = NULL;
if (TSDB_DATA_TYPE_BOOL == outType) { if (TSDB_DATA_TYPE_BOOL == outType) {
...@@ -190,6 +205,9 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in ...@@ -190,6 +205,9 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
func = varToUnsigned; func = varToUnsigned;
} else if (IS_FLOAT_TYPE(outType)) { } else if (IS_FLOAT_TYPE(outType)) {
func = varToFloat; func = varToFloat;
} else if (outType == TSDB_DATA_TYPE_NCHAR) {
func = varToNchar;
vton = true;
} else { } else {
sclError("invalid convert outType:%d", outType); sclError("invalid convert outType:%d", outType);
return TSDB_CODE_QRY_APP_ERROR; return TSDB_CODE_QRY_APP_ERROR;
...@@ -197,26 +215,30 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in ...@@ -197,26 +215,30 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
pOut->numOfRows = pIn->numOfRows; pOut->numOfRows = pIn->numOfRows;
for (int32_t i = 0; i < pIn->numOfRows; ++i) { for (int32_t i = 0; i < pIn->numOfRows; ++i) {
if (colDataIsNull(pIn->columnData, pIn->numOfRows, i, NULL)) { if (colDataIsNull_s(pIn->columnData, i)) {
colDataAppendNULL(pOut->columnData, i); colDataAppendNULL(pOut->columnData, i);
continue; continue;
} }
char* data = colDataGetData(pIn->columnData, i); char* data = colDataGetData(pIn->columnData, i);
if (TSDB_DATA_TYPE_BINARY == inType) { if (vton) {
memcpy(tmp, varDataVal(data), varDataLen(data)); memcpy(tmp, data, varDataTLen(data));
tmp[varDataLen(data)] = 0;
} else { } else {
ASSERT (varDataLen(data) <= bufSize); if (TSDB_DATA_TYPE_VARCHAR == inType) {
memcpy(tmp, varDataVal(data), varDataLen(data));
int len = taosUcs4ToMbs((TdUcs4*)varDataVal(data), varDataLen(data), tmp); tmp[varDataLen(data)] = 0;
if (len < 0){ } else {
sclError("castConvert taosUcs4ToMbs error 1"); ASSERT(varDataLen(data) <= bufSize);
taosMemoryFreeClear(tmp);
return TSDB_CODE_QRY_APP_ERROR; int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp);
if (len < 0) {
sclError("castConvert taosUcs4ToMbs error 1");
taosMemoryFreeClear(tmp);
return TSDB_CODE_QRY_APP_ERROR;
}
tmp[len] = 0;
} }
tmp[len] = 0;
} }
(*func)(tmp, pOut, i); (*func)(tmp, pOut, i);
......
...@@ -57,7 +57,7 @@ SRaftStore *raftStoreOpen(const char *path) { ...@@ -57,7 +57,7 @@ SRaftStore *raftStoreOpen(const char *path) {
static int32_t raftStoreInit(SRaftStore *pRaftStore) { static int32_t raftStoreInit(SRaftStore *pRaftStore) {
assert(pRaftStore != NULL); assert(pRaftStore != NULL);
pRaftStore->pFile = taosOpenFile(pRaftStore->path, TD_FILE_CTEATE | TD_FILE_WRITE); pRaftStore->pFile = taosOpenFile(pRaftStore->path, TD_FILE_CREATE | TD_FILE_WRITE);
assert(pRaftStore->pFile != NULL); assert(pRaftStore->pFile != NULL);
pRaftStore->currentTerm = 0; pRaftStore->currentTerm = 0;
......
...@@ -37,7 +37,7 @@ extern "C" { ...@@ -37,7 +37,7 @@ extern "C" {
/* file */ /* file */
typedef TdFilePtr tdb_fd_t; typedef TdFilePtr tdb_fd_t;
#define TDB_O_CREAT TD_FILE_CTEATE #define TDB_O_CREAT TD_FILE_CREATE
#define TDB_O_WRITE TD_FILE_WRITE #define TDB_O_WRITE TD_FILE_WRITE
#define TDB_O_READ TD_FILE_READ #define TDB_O_READ TD_FILE_READ
#define TDB_O_TRUNC TD_FILE_TRUNC #define TDB_O_TRUNC TD_FILE_TRUNC
......
...@@ -231,7 +231,7 @@ TEST_F(TfsTest, 04_File) { ...@@ -231,7 +231,7 @@ TEST_F(TfsTest, 04_File) {
EXPECT_EQ(tfsMkdir(pTfs, "t3"), 0); EXPECT_EQ(tfsMkdir(pTfs, "t3"), 0);
// FILE *fp = fopen(f1.aname, "w"); // FILE *fp = fopen(f1.aname, "w");
TdFilePtr pFile = taosOpenFile(f1.aname, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(f1.aname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
ASSERT_NE(pFile, nullptr); ASSERT_NE(pFile, nullptr);
taosWriteFile(pFile, "12345678", 5); taosWriteFile(pFile, "12345678", 5);
taosCloseFile(&pFile); taosCloseFile(&pFile);
...@@ -640,7 +640,7 @@ TEST_F(TfsTest, 05_MultiDisk) { ...@@ -640,7 +640,7 @@ TEST_F(TfsTest, 05_MultiDisk) {
EXPECT_EQ(tfsMkdir(pTfs, "t3"), 0); EXPECT_EQ(tfsMkdir(pTfs, "t3"), 0);
// FILE *fp = fopen(f1.aname, "w"); // FILE *fp = fopen(f1.aname, "w");
TdFilePtr pFile = taosOpenFile(f1.aname, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(f1.aname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
ASSERT_NE(pFile, nullptr); ASSERT_NE(pFile, nullptr);
taosWriteFile(pFile, "12345678", 5); taosWriteFile(pFile, "12345678", 5);
taosCloseFile(&pFile); taosCloseFile(&pFile);
......
...@@ -129,6 +129,12 @@ static void transDestroyConnCtx(STransConnCtx* ctx); ...@@ -129,6 +129,12 @@ static void transDestroyConnCtx(STransConnCtx* ctx);
static SCliThrdObj* createThrdObj(); static SCliThrdObj* createThrdObj();
static void destroyThrdObj(SCliThrdObj* pThrd); static void destroyThrdObj(SCliThrdObj* pThrd);
// snprintf may cause performance problem
#define CONN_CONSTRUCT_HASH_KEY(key, ip, port) \
do { \
snprintf(key, sizeof(key), "%s:%d", ip, (int)port); \
} while (0)
#define CONN_HOST_THREAD_INDEX(conn) (conn ? ((SCliConn*)conn)->hThrdIdx : -1) #define CONN_HOST_THREAD_INDEX(conn) (conn ? ((SCliConn*)conn)->hThrdIdx : -1)
#define CONN_PERSIST_TIME(para) (para * 1000 * 10) #define CONN_PERSIST_TIME(para) (para * 1000 * 10)
#define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL) #define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL)
...@@ -206,8 +212,10 @@ static void destroyThrdObj(SCliThrdObj* pThrd); ...@@ -206,8 +212,10 @@ static void destroyThrdObj(SCliThrdObj* pThrd);
} \ } \
} while (0) } while (0)
#define CONN_NO_PERSIST_BY_APP(conn) (((conn)->status == ConnNormal || (conn)->status == ConnInPool) && T_REF_VAL_GET(conn) == 1) #define CONN_NO_PERSIST_BY_APP(conn) \
#define CONN_RELEASE_BY_SERVER(conn) (((conn)->status == ConnRelease || (conn)->status == ConnInPool) && T_REF_VAL_GET(conn) == 1) (((conn)->status == ConnNormal || (conn)->status == ConnInPool) && T_REF_VAL_GET(conn) == 1)
#define CONN_RELEASE_BY_SERVER(conn) \
(((conn)->status == ConnRelease || (conn)->status == ConnInPool) && T_REF_VAL_GET(conn) == 1)
#define REQUEST_NO_RESP(msg) ((msg)->noResp == 1) #define REQUEST_NO_RESP(msg) ((msg)->noResp == 1)
#define REQUEST_PERSIS_HANDLE(msg) ((msg)->persistHandle == 1) #define REQUEST_PERSIS_HANDLE(msg) ((msg)->persistHandle == 1)
...@@ -282,8 +290,9 @@ void cliHandleResp(SCliConn* conn) { ...@@ -282,8 +290,9 @@ void cliHandleResp(SCliConn* conn) {
tDebug("%s cli conn %p ref by app", CONN_GET_INST_LABEL(conn), conn); tDebug("%s cli conn %p ref by app", CONN_GET_INST_LABEL(conn), conn);
} }
tDebug("%s cli conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pTransInst->label, conn, TMSG_INFO(pHead->msgType), tDebug("%s cli conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pTransInst->label, conn,
taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port), taosInetNtoa(conn->locaddr.sin_addr), ntohs(conn->locaddr.sin_port), transMsg.contLen); TMSG_INFO(pHead->msgType), taosInetNtoa(conn->addr.sin_addr), ntohs(conn->addr.sin_port),
taosInetNtoa(conn->locaddr.sin_addr), ntohs(conn->locaddr.sin_port), transMsg.contLen);
conn->secured = pHead->secured; conn->secured = pHead->secured;
...@@ -349,10 +358,12 @@ void cliHandleExcept(SCliConn* pConn) { ...@@ -349,10 +358,12 @@ void cliHandleExcept(SCliConn* pConn) {
if (pMsg == NULL && !CONN_NO_PERSIST_BY_APP(pConn)) { if (pMsg == NULL && !CONN_NO_PERSIST_BY_APP(pConn)) {
transMsg.ahandle = transCtxDumpVal(&pConn->ctx, transMsg.msgType); transMsg.ahandle = transCtxDumpVal(&pConn->ctx, transMsg.msgType);
tDebug("%s cli conn %p construct ahandle %p by %s", CONN_GET_INST_LABEL(pConn), pConn, transMsg.ahandle, TMSG_INFO(transMsg.msgType)); tDebug("%s cli conn %p construct ahandle %p by %s", CONN_GET_INST_LABEL(pConn), pConn, transMsg.ahandle,
TMSG_INFO(transMsg.msgType));
if (transMsg.ahandle == NULL) { if (transMsg.ahandle == NULL) {
transMsg.ahandle = transCtxDumpBrokenlinkVal(&pConn->ctx, (int32_t*)&(transMsg.msgType)); transMsg.ahandle = transCtxDumpBrokenlinkVal(&pConn->ctx, (int32_t*)&(transMsg.msgType));
tDebug("%s cli conn %p construct ahandle %p due to brokenlink", CONN_GET_INST_LABEL(pConn), pConn, transMsg.ahandle); tDebug("%s cli conn %p construct ahandle %p due to brokenlink", CONN_GET_INST_LABEL(pConn), pConn,
transMsg.ahandle);
} }
} else { } else {
transMsg.ahandle = pCtx ? pCtx->ahandle : NULL; transMsg.ahandle = pCtx ? pCtx->ahandle : NULL;
...@@ -423,8 +434,7 @@ void* destroyConnPool(void* pool) { ...@@ -423,8 +434,7 @@ void* destroyConnPool(void* pool) {
static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) {
char key[128] = {0}; char key[128] = {0};
tstrncpy(key, ip, strlen(ip)); CONN_CONSTRUCT_HASH_KEY(key, ip, port);
tstrncpy(key + strlen(key), (char*)(&port), sizeof(port));
SHashObj* pPool = pool; SHashObj* pPool = pool;
SConnList* plist = taosHashGet(pPool, key, strlen(key)); SConnList* plist = taosHashGet(pPool, key, strlen(key));
...@@ -456,8 +466,7 @@ static void addConnToPool(void* pool, SCliConn* conn) { ...@@ -456,8 +466,7 @@ static void addConnToPool(void* pool, SCliConn* conn) {
conn->status = ConnInPool; conn->status = ConnInPool;
char key[128] = {0}; char key[128] = {0};
tstrncpy(key, conn->ip, strlen(conn->ip)); CONN_CONSTRUCT_HASH_KEY(key, conn->ip, conn->port);
tstrncpy(key + strlen(key), (char*)(&conn->port), sizeof(conn->port));
tTrace("cli conn %p added to conn pool, read buf cap: %d", conn, conn->readBuf.cap); tTrace("cli conn %p added to conn pool, read buf cap: %d", conn, conn->readBuf.cap);
SConnList* plist = taosHashGet((SHashObj*)pool, key, strlen(key)); SConnList* plist = taosHashGet((SHashObj*)pool, key, strlen(key));
...@@ -626,8 +635,9 @@ void cliSend(SCliConn* pConn) { ...@@ -626,8 +635,9 @@ void cliSend(SCliConn* pConn) {
pHead->release = REQUEST_RELEASE_HANDLE(pCliMsg) ? 1 : 0; pHead->release = REQUEST_RELEASE_HANDLE(pCliMsg) ? 1 : 0;
uv_buf_t wb = uv_buf_init((char*)pHead, msgLen); uv_buf_t wb = uv_buf_init((char*)pHead, msgLen);
tDebug("%s cli conn %p %s is send to %s:%d, local info %s:%d", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pHead->msgType), tDebug("%s cli conn %p %s is send to %s:%d, local info %s:%d", CONN_GET_INST_LABEL(pConn), pConn,
taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); TMSG_INFO(pHead->msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port),
taosInetNtoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port));
if (pHead->persist == 1) { if (pHead->persist == 1) {
CONN_SET_PERSIST_BY_APP(pConn); CONN_SET_PERSIST_BY_APP(pConn);
......
...@@ -181,7 +181,7 @@ int main(int argc, char *argv[]) { ...@@ -181,7 +181,7 @@ int main(int argc, char *argv[]) {
tInfo("RPC server is running, ctrl-c to exit"); tInfo("RPC server is running, ctrl-c to exit");
if (commit) { if (commit) {
pDataFile = taosOpenFile(dataName, TD_FILE_APPEND | TD_FILE_CTEATE | TD_FILE_WRITE); pDataFile = taosOpenFile(dataName, TD_FILE_APPEND | TD_FILE_CREATE | TD_FILE_WRITE);
if (pDataFile == NULL) tInfo("failed to open data file, reason:%s", strerror(errno)); if (pDataFile == NULL) tInfo("failed to open data file, reason:%s", strerror(errno));
} }
qhandle = taosOpenQueue(); qhandle = taosOpenQueue();
......
...@@ -177,7 +177,7 @@ int main(int argc, char *argv[]) { ...@@ -177,7 +177,7 @@ int main(int argc, char *argv[]) {
tInfo("RPC server is running, ctrl-c to exit"); tInfo("RPC server is running, ctrl-c to exit");
if (commit) { if (commit) {
pDataFile = taosOpenFile(dataName, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); pDataFile = taosOpenFile(dataName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
if (pDataFile == NULL) tInfo("failed to open data file, reason:%s", strerror(errno)); if (pDataFile == NULL) tInfo("failed to open data file, reason:%s", strerror(errno));
} }
qhandle = taosOpenQueue(); qhandle = taosOpenQueue();
......
...@@ -360,7 +360,7 @@ int walSaveMeta(SWal* pWal) { ...@@ -360,7 +360,7 @@ int walSaveMeta(SWal* pWal) {
int metaVer = walFindCurMetaVer(pWal); int metaVer = walFindCurMetaVer(pWal);
char fnameStr[WAL_FILE_LEN]; char fnameStr[WAL_FILE_LEN];
walBuildMetaName(pWal, metaVer + 1, fnameStr); walBuildMetaName(pWal, metaVer + 1, fnameStr);
TdFilePtr pMataFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE); TdFilePtr pMataFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE);
if (pMataFile == NULL) { if (pMataFile == NULL) {
return -1; return -1;
} }
......
...@@ -56,13 +56,13 @@ int walSetWrite(SWal* pWal) { ...@@ -56,13 +56,13 @@ int walSetWrite(SWal* pWal) {
char fnameStr[WAL_FILE_LEN]; char fnameStr[WAL_FILE_LEN];
walBuildIdxName(pWal, fileFirstVer, fnameStr); walBuildIdxName(pWal, fileFirstVer, fnameStr);
pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
if (pIdxTFile == NULL) { if (pIdxTFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
return -1; return -1;
} }
walBuildLogName(pWal, fileFirstVer, fnameStr); walBuildLogName(pWal, fileFirstVer, fnameStr);
pLogTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); pLogTFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
if (pLogTFile == NULL) { if (pLogTFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
return -1; return -1;
...@@ -102,14 +102,14 @@ int walChangeWrite(SWal* pWal, int64_t ver) { ...@@ -102,14 +102,14 @@ int walChangeWrite(SWal* pWal, int64_t ver) {
int64_t fileFirstVer = pFileInfo->firstVer; int64_t fileFirstVer = pFileInfo->firstVer;
walBuildIdxName(pWal, fileFirstVer, fnameStr); walBuildIdxName(pWal, fileFirstVer, fnameStr);
pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
if (pIdxTFile == NULL) { if (pIdxTFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
pWal->pWriteIdxTFile = NULL; pWal->pWriteIdxTFile = NULL;
return -1; return -1;
} }
walBuildLogName(pWal, fileFirstVer, fnameStr); walBuildLogName(pWal, fileFirstVer, fnameStr);
pLogTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); pLogTFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
if (pLogTFile == NULL) { if (pLogTFile == NULL) {
taosCloseFile(&pIdxTFile); taosCloseFile(&pIdxTFile);
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
......
...@@ -216,13 +216,13 @@ int walRoll(SWal *pWal) { ...@@ -216,13 +216,13 @@ int walRoll(SWal *pWal) {
int64_t newFileFirstVersion = pWal->vers.lastVer + 1; int64_t newFileFirstVersion = pWal->vers.lastVer + 1;
char fnameStr[WAL_FILE_LEN]; char fnameStr[WAL_FILE_LEN];
walBuildIdxName(pWal, newFileFirstVersion, fnameStr); walBuildIdxName(pWal, newFileFirstVersion, fnameStr);
pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
if (pIdxTFile == NULL) { if (pIdxTFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
return -1; return -1;
} }
walBuildLogName(pWal, newFileFirstVersion, fnameStr); walBuildLogName(pWal, newFileFirstVersion, fnameStr);
pLogTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); pLogTFile = taosOpenFile(fnameStr, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
if (pLogTFile == NULL) { if (pLogTFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
return -1; return -1;
......
...@@ -129,7 +129,7 @@ int64_t taosCopyFile(const char *from, const char *to) { ...@@ -129,7 +129,7 @@ int64_t taosCopyFile(const char *from, const char *to) {
if (pFileFrom == NULL) goto _err; if (pFileFrom == NULL) goto _err;
// fidto = open(to, O_WRONLY | O_CREAT | O_EXCL, 0755); // fidto = open(to, O_WRONLY | O_CREAT | O_EXCL, 0755);
TdFilePtr pFileTo = taosOpenFile(to, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_EXCL); TdFilePtr pFileTo = taosOpenFile(to, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_EXCL);
if (pFileTo == NULL) goto _err; if (pFileTo == NULL) goto _err;
while (true) { while (true) {
...@@ -246,7 +246,7 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { ...@@ -246,7 +246,7 @@ TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) {
} }
} else { } else {
int access = O_BINARY; int access = O_BINARY;
access |= (tdFileOptions & TD_FILE_CTEATE) ? O_CREAT : 0; access |= (tdFileOptions & TD_FILE_CREATE) ? O_CREAT : 0;
if ((tdFileOptions & TD_FILE_WRITE) && (tdFileOptions & TD_FILE_READ)) { if ((tdFileOptions & TD_FILE_WRITE) && (tdFileOptions & TD_FILE_READ)) {
access |= O_RDWR; access |= O_RDWR;
} else if (tdFileOptions & TD_FILE_WRITE) { } else if (tdFileOptions & TD_FILE_WRITE) {
......
...@@ -199,7 +199,7 @@ static void *taosThreadToOpenNewFile(void *param) { ...@@ -199,7 +199,7 @@ static void *taosThreadToOpenNewFile(void *param) {
taosUmaskFile(0); taosUmaskFile(0);
TdFilePtr pFile = taosOpenFile(name, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) { if (pFile == NULL) {
tsLogObj.openInProgress = 0; tsLogObj.openInProgress = 0;
tsLogObj.lines = tsLogObj.maxLines - 1000; tsLogObj.lines = tsLogObj.maxLines - 1000;
...@@ -348,7 +348,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) { ...@@ -348,7 +348,7 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
taosThreadMutexInit(&tsLogObj.logMutex, NULL); taosThreadMutexInit(&tsLogObj.logMutex, NULL);
taosUmaskFile(0); taosUmaskFile(0);
tsLogObj.logHandle->pFile = taosOpenFile(fileName, TD_FILE_CTEATE | TD_FILE_WRITE); tsLogObj.logHandle->pFile = taosOpenFile(fileName, TD_FILE_CREATE | TD_FILE_WRITE);
if (tsLogObj.logHandle->pFile == NULL) { if (tsLogObj.logHandle->pFile == NULL) {
printf("\nfailed to open log file:%s, reason:%s\n", fileName, strerror(errno)); printf("\nfailed to open log file:%s, reason:%s\n", fileName, strerror(errno));
...@@ -699,7 +699,7 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) { ...@@ -699,7 +699,7 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) {
goto cmp_end; goto cmp_end;
} }
TdFilePtr pFile = taosOpenFile(destFileName, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(destFileName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) { if (pFile == NULL) {
ret = -2; ret = -2;
goto cmp_end; goto cmp_end;
......
...@@ -48,7 +48,7 @@ struct SDiskbasedBuf { ...@@ -48,7 +48,7 @@ struct SDiskbasedBuf {
}; };
static int32_t createDiskFile(SDiskbasedBuf* pBuf) { static int32_t createDiskFile(SDiskbasedBuf* pBuf) {
pBuf->pFile = taosOpenFile(pBuf->path, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL); pBuf->pFile = taosOpenFile(pBuf->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL);
if (pBuf->pFile == NULL) { if (pBuf->pFile == NULL) {
return TAOS_SYSTEM_ERROR(errno); return TAOS_SYSTEM_ERROR(errno);
} }
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
./test.sh -f tsim/query/interval-offset.sim ./test.sh -f tsim/query/interval-offset.sim
./test.sh -f tsim/query/scalarFunction.sim ./test.sh -f tsim/query/scalarFunction.sim
./test.sh -f tsim/query/charScalarFunction.sim ./test.sh -f tsim/query/charScalarFunction.sim
./test.sh -f tsim/query/explain.sim
./test.sh -f tsim/query/session.sim
# ---- qnode # ---- qnode
./test.sh -f tsim/qnode/basic1.sim ./test.sh -f tsim/qnode/basic1.sim
...@@ -43,7 +45,7 @@ ...@@ -43,7 +45,7 @@
./test.sh -f tsim/bnode/basic1.sim ./test.sh -f tsim/bnode/basic1.sim
# ---- mnode # ---- mnode
./test.sh -f tsim/bnode/basic1.sim ./test.sh -f tsim/mnode/basic1.sim
# ---- show # ---- show
./test.sh -f tsim/show/basic.sim ./test.sh -f tsim/show/basic.sim
...@@ -69,7 +71,13 @@ ...@@ -69,7 +71,13 @@
# --- for multi process mode # --- for multi process mode
./test.sh -f tsim/user/basic1.sim -m ./test.sh -f tsim/user/basic1.sim -m
./test.sh -f tsim/stable/vnode3.sim -m ./test.sh -f tsim/db/basic3.sim -m
./test.sh -f tsim/insert/backquote.sim
./test.sh -f tsim/parser/fourArithmetic-basic.sim -m
./test.sh -f tsim/query/interval-offset.sim -m
./test.sh -f tsim/tmq/basic.sim -m ./test.sh -f tsim/tmq/basic.sim -m
./test.sh -f tsim/stable/vnode3.sim -m
./test.sh -f tsim/qnode/basic1.sim -m
./test.sh -f tsim/mnode/basic1.sim -m
#======================b1-end=============== #======================b1-end===============
...@@ -75,7 +75,6 @@ if $data02 != master then ...@@ -75,7 +75,6 @@ if $data02 != master then
return -1 return -1
endi endi
return
print =============== create drop mnode 1 print =============== create drop mnode 1
sql_error create mnode on dnode 1 sql_error create mnode on dnode 1
sql_error drop mnode on dnode 1 sql_error drop mnode on dnode 1
......
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 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
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
endi
sql connect
print =============== create database
sql create database db
sql show databases
if $rows != 2 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
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 ct2 (d)
sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+6a )
sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+7a )
print =============== insert data into child table ct3 (n)
sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
print =============== insert data into child table ct4 (y)
sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct4 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 ct4 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 ct4 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 ================ query 1 group by filter
sql select count(*) from ct3 group by c1
print ====> sql : select count(*) from ct3 group by c1
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c2
print ====> sql : select count(*) from ct3 group by c2
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c3
print ====> sql : select count(*) from ct3 group by c3
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c4
print ====> sql : select count(*) from ct3 group by c4
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c5
print ====> sql : select count(*) from ct3 group by c5
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c6
print ====> sql : select count(*) from ct3 group by c6
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c7
print ====> sql : select count(*) from ct3 group by c7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select count(*) from ct3 group by c8
print ====> sql : select count(*) from ct3 group by c8
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c9
print ====> sql : select count(*) from ct3 group by c9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c10
print ====> sql : select count(*) from ct3 group by c10
print ====> rows: $rows
if $rows != 8 then
return -1
endi
print ================ query 2 complex with group by
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
print =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 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 =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 then
return -1
endi
print ================ query 1 group by filter
sql select count(*) from ct3 group by c1
print ====> sql : select count(*) from ct3 group by c1
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c2
print ====> sql : select count(*) from ct3 group by c2
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c3
print ====> sql : select count(*) from ct3 group by c3
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c4
print ====> sql : select count(*) from ct3 group by c4
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c5
print ====> sql : select count(*) from ct3 group by c5
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c6
print ====> sql : select count(*) from ct3 group by c6
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c7
print ====> sql : select count(*) from ct3 group by c7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select count(*) from ct3 group by c8
print ====> sql : select count(*) from ct3 group by c8
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c9
print ====> sql : select count(*) from ct3 group by c9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c10
print ====> sql : select count(*) from ct3 group by c10
print ====> rows: $rows
if $rows != 8 then
return -1
endi
print ================ query 2 complex with group by
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 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
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
endi
sql connect
print =============== create database
sql create database db
sql show databases
if $rows != 2 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
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 ct2 (d)
sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+6a )
sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+7a )
print =============== insert data into child table ct3 (n)
sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
print =============== insert data into child table ct4 (y)
sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct4 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 ct4 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 ct4 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 ================ query 1 limit/offset
sql select * from ct1 limit 1
print ====> sql : select * from ct1 limit 1
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
sql select * from ct1 limit 9
print ====> sql : select * from ct1 limit 9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct1 limit 1 offset 2
print ====> sql : select * from ct1 limit 1 offset 2
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
sql select * from ct1 limit 2 offset 1
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
if $data01 != 8 then
return -1
endi
sql select * from ct1 limit 2 offset 7
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 3 then
return -1
endi
sql select * from ct1 limit 2 offset 10
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 0 then
return -1
endi
sql select c1 from stb1 limit 1
print ====> sql : select c1 from stb1 limit 1
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 50
print ====> sql : select c1 from stb1 limit 50
print ====> rows: $rows
if $rows != 33 then
return -1
endi
sql select c1 from stb1 limit 1 offset 2
print ====> sql : select c1 from stb1 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 1
print ====> sql : select c1 from stb1 limit 2 offset 1
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select c1 from stb1 limit 2 offset 32
print ====> sql : select c1 from stb1 limit 2 offset 32
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 40
print ====> sql : select c1 from stb1 limit 2 offset 40
print ====> rows: $rows
if $rows != 0 then
return -1
endi
print ================ query 2 complex with limit
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
print =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 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 =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 then
return -1
endi
print ================ query 1 limit/offset
sql select * from ct1 limit 1
print ====> sql : select * from ct1 limit 1
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
sql select * from ct1 limit 9
print ====> sql : select * from ct1 limit 9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct1 limit 1 offset 2
print ====> sql : select * from ct1 limit 1 offset 2
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
sql select * from ct1 limit 2 offset 1
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
if $data01 != 8 then
return -1
endi
sql select * from ct1 limit 2 offset 7
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 3 then
return -1
endi
sql select * from ct1 limit 2 offset 10
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 0 then
return -1
endi
sql select c1 from stb1 limit 1
print ====> sql : select c1 from stb1 limit 1
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 50
print ====> sql : select c1 from stb1 limit 50
print ====> rows: $rows
if $rows != 33 then
return -1
endi
sql select c1 from stb1 limit 1 offset 2
print ====> sql : select c1 from stb1 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 1
print ====> sql : select c1 from stb1 limit 2 offset 1
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select c1 from stb1 limit 2 offset 32
print ====> sql : select c1 from stb1 limit 2 offset 32
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 40
print ====> sql : select c1 from stb1 limit 2 offset 40
print ====> rows: $rows
if $rows != 0 then
return -1
endi
print ================ query 2 complex with limit
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 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
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
endi
sql connect
print =============== create database
sql create database db
sql show databases
if $rows != 2 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
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 ct2 (d)
sql insert into ct2 values ( '2022-01-01 01:00:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct2 values ( '2022-01-01 10:00:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct2 values ( '2022-01-01 20:00:01.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct2 values ( '2022-01-02 10:00:01.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct2 values ( '2022-01-02 20:00:01.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct2 values ( '2022-01-03 10:00:01.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+6a )
sql insert into ct2 values ( '2022-01-03 20:00:01.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+7a )
print =============== insert data into child table ct3 (n)
sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
print =============== insert data into child table ct4 (y)
sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct4 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 ct4 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 ct4 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 ================ query 1 limit/offset
sql select * from ct1 limit 1
print ====> sql : select * from ct1 limit 1
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
sql select * from ct1 limit 9
print ====> sql : select * from ct1 limit 9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct1 limit 1 offset 2
print ====> sql : select * from ct1 limit 1 offset 2
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
sql select * from ct1 limit 2 offset 1
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
if $data01 != 8 then
return -1
endi
sql select * from ct1 limit 2 offset 7
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 2 then
return -1
endi
if $data11 != 3 then
return -1
endi
sql select * from ct1 limit 2 offset 10
print ====> sql : select * from ct1 limit 2 offset 7
print ====> rows: $rows
if $rows != 0 then
return -1
endi
sql select c1 from stb1 limit 1
print ====> sql : select c1 from stb1 limit 1
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 50
print ====> sql : select c1 from stb1 limit 50
print ====> rows: $rows
if $rows != 33 then
return -1
endi
sql select c1 from stb1 limit 1 offset 2
print ====> sql : select c1 from stb1 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 1
print ====> sql : select c1 from stb1 limit 2 offset 1
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select c1 from stb1 limit 2 offset 32
print ====> sql : select c1 from stb1 limit 2 offset 32
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select c1 from stb1 limit 2 offset 40
print ====> sql : select c1 from stb1 limit 2 offset 40
print ====> rows: $rows
if $rows != 0 then
return -1
endi
print ================ query 2 where condition
sql select * from ct3 where c1 < 5
print ====> sql : select * from ct3 where c1 < 5
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 4 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql select * from ct3 where c1 > 5 and c1 <= 6
print ====> sql : select * from ct3 where c1 > 5 and c1 <= 6
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 1 then
return -1
endi
if $data01 != 6 then
return -1
endi
sql select * from ct3 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2
print ====> sql : select * from ct3 where c1 > 5 and c1 <= 6
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 8 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql select * from ct3 where c1 >= 5 and c1 is not NULL
print ====> sql : select * from ct3 where c1 >= 5 and c1 is not NULL
print ====> rows: $rows
print ====> rows0: $data00, $data01, $data02, $data03, $data04, $data05, $data06, $data07, $data08, $data09
if $rows != 4 then
return -1
endi
if $data01 != 5 then
return -1
endi
sql_error select ts from ct3 where ts != 0
sql select * from ct3 where ts <> 0
print ====> sql : select * from ct3 where ts <> 0
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct3 where c1 between 1 and 3
print ====> sql : select * from ct3 where c1 between 1 and 3
print ====> rows: $rows
if $rows != 3 then
return -1
endi
sql_error select * from ct3 where c7 between false and true
sql select * from ct3 where c1 in (1,2,3)
print ====> sql : select * from ct3 where c1 in (1,2,3)
print ====> rows: $rows
if $rows != 3 then
return -1
endi
sql select * from ct3 where c1 in (‘true','false')
print ====> sql : select * from ct3 where c1 in (‘true','false')
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct3 where c9 like "_char_"
print ====> sql : select * from ct3 where c1 in (1,2,3)
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select * from ct3 where c8 like "bi%"
print ====> sql : select * from ct3 where c1 in (1,2,3)
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select c1 from stb1 where c1 < 5
print ====> sql : select c1 from stb1 where c1 < 5
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 16 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql select c1 from stb1 where stb1 > 5 and c1 <= 6
print ====> sql : select c1 from stb1 where c1 > 5 and c1 <= 6
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 4 then
return -1
endi
if $data01 != 6 then
return -1
endi
sql select c1 from stb1 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2
print ====> sql : sselect c1 from stb1 where c1 >= 5 or c1 != 4 or c1 <> 3 or c1 = 2
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 32 then
return -1
endi
if $data01 != 1 then
return -1
endi
sql select c1 from stb1 where c1 >= 5 and c1 is not NULL
print ====> sql : select c1 from stb1 where c1 >= 5 and c1 is not NULL
print ====> rows: $rows
print ====> rows0: $data00
if $rows != 17 then
return -1
endi
if $data01 != 5 then
return -1
endi
sql_error select ts from stb1 where ts != 0
sql select c1 from stb1 where ts <> 0
print ====> sql : select c1 from stb1 where ts <> 0
print ====> rows: $rows
if $rows != 32 then
return -1
endi
sql select c1 from stb1 where c1 between 1 and 3
print ====> sql : select c1 from stb1 where c1 between 1 and 3
print ====> rows: $rows
if $rows != 12 then
return -1
endi
sql_error select c1 from stb1 where c7 between false and true
sql select c1 from stb1 where c1 in (1,2,3)
print ====> sql : select c1 from stb1 where c1 in (1,2,3)
print ====> rows: $rows
if $rows != 12 then
return -1
endi
sql select c1 from stb1 where c1 in (‘true','false')
print ====> sql : select c1 from stb1 where c1 in (‘true','false')
print ====> rows: $rows
if $rows != 32 then
return -1
endi
sql select c1 from stb1 where c9 like "_char_"
print ====> sql : select c1 from stb1 where c9 like "_char_"
print ====> rows: $rows
if $rows != 32 then
return -1
endi
sql select c1 from stb1 where c8 like "bi%"
print ====> sql : select c1 from stb1 where c8 like "bi%"
print ====> rows: $rows
if $rows != 32 then
return -1
endi
print ================ query 3 group by filter
sql select count(*) from ct3 group by c1
print ====> sql : select count(*) from ct3 group by c1
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c2
print ====> sql : select count(*) from ct3 group by c2
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c3
print ====> sql : select count(*) from ct3 group by c3
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c4
print ====> sql : select count(*) from ct3 group by c4
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c5
print ====> sql : select count(*) from ct3 group by c5
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c6
print ====> sql : select count(*) from ct3 group by c6
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c7
print ====> sql : select count(*) from ct3 group by c7
print ====> rows: $rows
if $rows != 2 then
return -1
endi
sql select count(*) from ct3 group by c8
print ====> sql : select count(*) from ct3 group by c8
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c9
print ====> sql : select count(*) from ct3 group by c9
print ====> rows: $rows
if $rows != 8 then
return -1
endi
sql select count(*) from ct3 group by c10
print ====> sql : select count(*) from ct3 group by c10
print ====> rows: $rows
if $rows != 8 then
return -1
endi
print ================ query 4 scalar function + where + group by + limit/offset
sql select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select count(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select abs(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select acos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select asin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select atan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select ceil(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select cos(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select floor(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select log(c1,10) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select pow(c1,3) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select round(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sqrt(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select sin(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
sql select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 1
print ====> sql : select tan(c1) from ct3 where c1 > 2 group by c7 limit 1 offset 2
print ====> rows: $rows
if $rows != 1 then
return -1
endi
print =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 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 =================== count all rows
sql select count(c1) from stb1
print ====> sql : select count(c1) from stb1
print ====> rows: $data00
if $data00 != 33 then
return -1
endi
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
此差异已折叠。
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 2
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
print ========= start dnode1 as master
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ======== step1
sql create database db1 vgroups 3;
sql use db1;
sql show databases;
sql create stable st1 (ts timestamp, f1 int, f2 binary(200)) tags(t1 int);
sql create stable st2 (ts timestamp, f1 int, f2 binary(200)) tags(t1 int);
sql create table tb1 using st1 tags(1);
sql insert into tb1 values (now, 1, "Hash Join (cost=230.47..713.98 rows=101 width=488) (actual time=0.711..7.427 rows=100 loops=1)");
sql create table tb2 using st1 tags(2);
sql insert into tb2 values (now, 2, "Seq Scan on tenk2 t2 (cost=0.00..445.00 rows=10000 width=244) (actual time=0.007..2.583 rows=10000 loops=1)");
sql create table tb3 using st1 tags(3);
sql insert into tb3 values (now, 3, "Hash (cost=229.20..229.20 rows=101 width=244) (actual time=0.659..0.659 rows=100 loops=1)");
sql create table tb4 using st1 tags(4);
sql insert into tb4 values (now, 4, "Bitmap Heap Scan on tenk1 t1 (cost=5.07..229.20 rows=101 width=244) (actual time=0.080..0.526 rows=100 loops=1)");
sql create table tb1 using st2 tags(1);
sql insert into tb1 values (now, 1, "Hash Join (cost=230.47..713.98 rows=101 width=488) (actual time=0.711..7.427 rows=100 loops=1)");
sql create table tb2 using st2 tags(2);
sql insert into tb2 values (now, 2, "Seq Scan on tenk2 t2 (cost=0.00..445.00 rows=10000 width=244) (actual time=0.007..2.583 rows=10000 loops=1)");
sql create table tb3 using st2 tags(3);
sql insert into tb3 values (now, 3, "Hash (cost=229.20..229.20 rows=101 width=244) (actual time=0.659..0.659 rows=100 loops=1)");
sql create table tb4 using st2 tags(4);
sql insert into tb4 values (now, 4, "Bitmap Heap Scan on tenk1 t1 (cost=5.07..229.20 rows=101 width=244) (actual time=0.080..0.526 rows=100 loops=1)");
print ======== step2
sql explain select * from st1 where -2;
sql explain select ts from tb1;
sql explain select * from st1;
sql explain select * from st1 order by ts;
sql explain select * from information_schema.user_stables;
sql explain select count(*),sum(f1) from tb1;
sql explain select count(*),sum(f1) from st1;
sql explain select count(*),sum(f1) from st1 group by f1;
sql explain select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev);
sql explain select min(f1) from st1 interval(1m, 2a) sliding(3n);
print ======== step3
sql explain verbose true select * from st1 where -2;
sql explain verbose true select ts from tb1 where f1 > 0;
sql explain verbose true select * from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
sql explain verbose true select * from information_schema.user_stables where db_name='db2';
sql explain verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0;
print ======== step4
sql explain analyze select ts from st1 where -2;
sql explain analyze select ts from tb1;
sql explain analyze select ts from st1;
sql explain analyze select ts from st1;
sql explain analyze select ts from st1 order by ts;
sql explain analyze select * from information_schema.user_stables;
sql explain analyze select count(*),sum(f1) from tb1;
sql explain analyze select count(*),sum(f1) from st1;
sql explain analyze select count(*),sum(f1) from st1 group by f1;
sql explain analyze select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev);
sql explain analyze select min(f1) from st1 interval(3n, 2a) sliding(1n);
print ======== step5
sql explain analyze verbose true select ts from st1 where -2;
sql explain analyze verbose true select ts from tb1;
sql explain analyze verbose true select ts from st1;
sql explain analyze verbose true select ts from st1;
sql explain analyze verbose true select ts from st1 order by ts;
sql explain analyze verbose true select * from information_schema.user_stables;
sql explain analyze verbose true select count(*),sum(f1) from tb1;
sql explain analyze verbose true select count(*),sum(f1) from st1;
sql explain analyze verbose true select count(*),sum(f1) from st1 group by f1;
sql explain analyze verbose true select count(f1) from tb1 interval(1s, 2d) sliding(3s) fill(prev);
sql explain analyze verbose true select ts from tb1 where f1 > 0;
sql explain analyze verbose true select f1 from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2';
sql explain analyze verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0;
sql explain analyze verbose true select min(f1) from st1 interval(3n, 2a) sliding(1n);
sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0;
#not pass case
#sql explain verbose true select count(*),sum(f1) as aa from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by aa;
#sql explain verbose true select * from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
#sql explain verbose true select count(*),sum(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
#sql explain verbose true select count(f1) from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1s, 2d) sliding(3s) order by ts;
#sql explain verbose true select min(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1m, 2a) sliding(3n) fill(linear) order by ts;
#sql explain select max(f1) from tb1 SESSION(ts, 1s);
#sql explain select max(f1) from st1 SESSION(ts, 1s);
#sql explain select * from tb1, tb2 where tb1.ts=tb2.ts;
#sql explain select * from st1, st2 where tb1.ts=tb2.ts;
#sql explain analyze verbose true select sum(a+b) from (select _rowts, min(f1) b,count(*) a from st1 where f1 > 0 interval(1a)) where a < 0 interval(1s);
system sh/exec.sh -n dnode1 -s stop -x SIGINT
...@@ -77,6 +77,8 @@ sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.51', 7) ...@@ -77,6 +77,8 @@ sql INSERT INTO dev_002 VALUES('2020-05-13 10:00:00.51', 7)
$loop_test = 0 $loop_test = 0
loop_test_pos: loop_test_pos:
sql use $dbNamme
# session(ts,5a) # session(ts,5a)
print ====> select count(*) from dev_001 session(ts,5a) print ====> select count(*) from dev_001 session(ts,5a)
sql select _wstartts, count(*) from dev_001 session(ts,5a) sql select _wstartts, count(*) from dev_001 session(ts,5a)
...@@ -98,15 +100,15 @@ if $data01 != 2 then ...@@ -98,15 +100,15 @@ if $data01 != 2 then
return -1 return -1
endi endi
#
print ====> select count(*) from (select * from dev_001) session(ts,5a) #print ====> select count(*) from (select * from dev_001) session(ts,5a)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,5a) #sql select _wstartts, count(*) from (select * from dev_001) session(ts,5a)
if $rows != 15 then #if $rows != 15 then
return -1 # return -1
endi #endi
if $data01 != 2 then #if $data01 != 2 then
return -1 # return -1
endi #endi
print ====> select count(*) from dev_001 session(ts,1s) print ====> select count(*) from dev_001 session(ts,1s)
sql select _wstartts, count(*) from dev_001 session(ts,1s) sql select _wstartts, count(*) from dev_001 session(ts,1s)
...@@ -117,14 +119,14 @@ if $data01 != 5 then ...@@ -117,14 +119,14 @@ if $data01 != 5 then
return -1 return -1
endi endi
print ====> select count(*) from (select * from dev_001) session(ts,1s) #print ====> select count(*) from (select * from dev_001) session(ts,1s)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1s) #sql select _wstartts, count(*) from (select * from dev_001) session(ts,1s)
if $rows != 12 then #if $rows != 12 then
return -1 # return -1
endi #endi
if $data01 != 5 then #if $data01 != 5 then
return -1 # return -1
endi #endi
print ====> select count(*) from dev_001 session(ts,1000a) print ====> select count(*) from dev_001 session(ts,1000a)
sql select _wstartts, count(*) from dev_001 session(ts,1000a) sql select _wstartts, count(*) from dev_001 session(ts,1000a)
...@@ -135,14 +137,14 @@ if $data01 != 5 then ...@@ -135,14 +137,14 @@ if $data01 != 5 then
return -1 return -1
endi endi
print ====> select count(*) from (select * from dev_001) session(ts,1000a) #print ====> select count(*) from (select * from dev_001) session(ts,1000a)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1000a) #sql select _wstartts, count(*) from (select * from dev_001) session(ts,1000a)
if $rows != 12 then #if $rows != 12 then
return -1 # return -1
endi #endi
if $data01 != 5 then #if $data01 != 5 then
return -1 # return -1
endi #endi
print ====> select count(*) from dev_001 session(ts,1m) print ====> select count(*) from dev_001 session(ts,1m)
sql select _wstartts, count(*) from dev_001 session(ts,1m) sql select _wstartts, count(*) from dev_001 session(ts,1m)
...@@ -153,14 +155,14 @@ if $data01 != 8 then ...@@ -153,14 +155,14 @@ if $data01 != 8 then
return -1 return -1
endi endi
print ====> select count(*) from (select * from dev_001) session(ts,1m) #print ====> select count(*) from (select * from dev_001) session(ts,1m)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1m) #sql select _wstartts, count(*) from (select * from dev_001) session(ts,1m)
if $rows != 9 then #if $rows != 9 then
return -1 # return -1
endi #endi
if $data01 != 8 then #if $data01 != 8 then
return -1 # return -1
endi #endi
print ====> select count(*) from dev_001 session(ts,1h) print ====> select count(*) from dev_001 session(ts,1h)
sql select _wstartts, count(*) from dev_001 session(ts,1h) sql select _wstartts, count(*) from dev_001 session(ts,1h)
...@@ -171,14 +173,14 @@ if $data01 != 11 then ...@@ -171,14 +173,14 @@ if $data01 != 11 then
return -1 return -1
endi endi
print ====> select count(*) from (select * from dev_001) session(ts,1h) #print ====> select count(*) from (select * from dev_001) session(ts,1h)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1h) #sql select _wstartts, count(*) from (select * from dev_001) session(ts,1h)
if $rows != 6 then #if $rows != 6 then
return -1 # return -1
endi #endi
if $data01 != 11 then #if $data01 != 11 then
return -1 # return -1
endi #endi
print ====> select count(*) from dev_001 session(ts,1d) print ====> select count(*) from dev_001 session(ts,1d)
sql select _wstartts, count(*) from dev_001 session(ts,1d) sql select _wstartts, count(*) from dev_001 session(ts,1d)
...@@ -189,14 +191,14 @@ if $data01 != 13 then ...@@ -189,14 +191,14 @@ if $data01 != 13 then
return -1 return -1
endi endi
print ====> select count(*) from (select * from dev_001) session(ts,1d) #print ====> select count(*) from (select * from dev_001) session(ts,1d)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1d) #sql select _wstartts, count(*) from (select * from dev_001) session(ts,1d)
if $rows != 4 then #if $rows != 4 then
return -1 # return -1
endi #endi
if $data01 != 13 then #if $data01 != 13 then
return -1 # return -1
endi #endi
print ====> select count(*) from dev_001 session(ts,1w) print ====> select count(*) from dev_001 session(ts,1w)
sql select _wstartts, count(*) from dev_001 session(ts,1w) sql select _wstartts, count(*) from dev_001 session(ts,1w)
...@@ -207,18 +209,18 @@ if $data01 != 15 then ...@@ -207,18 +209,18 @@ if $data01 != 15 then
return -1 return -1
endi endi
print ====> select count(*) from (select * from dev_001) session(ts,1w) #print ====> select count(*) from (select * from dev_001) session(ts,1w)
sql select _wstartts, count(*) from (select * from dev_001) session(ts,1w) #sql select _wstartts, count(*) from (select * from dev_001) session(ts,1w)
if $rows != 2 then #if $rows != 2 then
return -1 # return -1
endi #endi
if $data01 != 15 then #if $data01 != 15 then
return -1 # return -1
endi #endi
print ====> leastsquares not supported yet. #print ====> leastsquares not supported yet.
print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d) #print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d)
#sql select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d) #sql select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtype),min(tagtype),max(tagtype),leastsquares(tagtype, 1, 1),spread(tagtype),stddev(tagtype),percentile(tagtype,0) from dev_001 where ts <'2020-05-20 0:0:0' session(ts,1d)
#if $rows != 2 then #if $rows != 2 then
# return -1 # return -1
...@@ -285,14 +287,14 @@ print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtyp ...@@ -285,14 +287,14 @@ print ====> select count(*),first(tagtype),last(tagtype),avg(tagtype),sum(tagtyp
#endi #endi
print ================> syntax error check not active ================> reactive print ================> syntax error check not active ================> reactive
#sql_error select * from dev_001 session(ts,1w) sql_error select * from dev_001 session(ts,1w)
#sql_error select count(*) from st session(ts,1w) sql select count(*) from st session(ts,1w)
#sql_error select count(*) from dev_001 group by tagtype session(ts,1w) sql_error select count(*) from dev_001 group by tagtype session(ts,1w)
#sql_error select count(*) from dev_001 session(ts,1n) sql select count(*) from dev_001 session(ts,1n)
#sql_error select count(*) from dev_001 session(ts,1y) sql select count(*) from dev_001 session(ts,1y)
#sql_error select count(*) from dev_001 session(ts,0s) sql select count(*) from dev_001 session(ts,0s)
#sql_error select count(*) from dev_001 session(i,1y) sql_error select count(*) from dev_001 session(i,1y)
#sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0' sql_error select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'
print ====> create database d1 precision 'us' print ====> create database d1 precision 'us'
sql create database d1 precision 'us' sql create database d1 precision 'us'
...@@ -301,17 +303,22 @@ sql create table dev_001 (ts timestamp ,i timestamp ,j int) ...@@ -301,17 +303,22 @@ sql create table dev_001 (ts timestamp ,i timestamp ,j int)
sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4) sql insert into dev_001 values(1623046993681000,now,1)(1623046993681001,now+1s,2)(1623046993681002,now+2s,3)(1623046993681004,now+5s,4)
print ====> select count(*) from dev_001 session(ts,1u) print ====> select count(*) from dev_001 session(ts,1u)
sql select _wstartts, count(*) from dev_001 session(ts,1u) sql select _wstartts, count(*) from dev_001 session(ts,1u)
if $rows != 2 then print rows: $rows
print $data00 $data01 $data02 $data03
print $data10 $data11 $data12 $data13
print $data20 $data21 $data22 $data23
print $data30 $data31 $data32 $data33
if $rows != 4 then
print expect 2, actual: $rows print expect 2, actual: $rows
return -1 return -1
endi endi
if $data01 != 3 then if $data01 != 1 then
return -1 return -1
endi endi
#sql_error select count(*) from dev_001 session(i,1s) #sql_error select count(*) from dev_001 session(i,1s)
#sql create table secondts(ts timestamp,t2 timestamp,i int) sql create table secondts(ts timestamp,t2 timestamp,i int)
#sql_error select count(*) from secondts session(t2,2s) #sql_error select count(*) from secondts session(t2,2s)
if $loop_test == 0 then if $loop_test == 0 then
......
...@@ -588,7 +588,7 @@ int32_t syncWriteDataByRatio() { ...@@ -588,7 +588,7 @@ int32_t syncWriteDataByRatio() {
void printParaIntoFile() { void printParaIntoFile() {
// FILE *fp = fopen(g_stConfInfo.resultFileName, "a"); // FILE *fp = fopen(g_stConfInfo.resultFileName, "a");
TdFilePtr pFile = taosOpenFile(g_stConfInfo.resultFileName, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_STREAM); TdFilePtr pFile = taosOpenFile(g_stConfInfo.resultFileName, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_STREAM);
if (NULL == pFile) { if (NULL == pFile) {
fprintf(stderr, "Failed to open %s for save result\n", g_stConfInfo.resultFileName); fprintf(stderr, "Failed to open %s for save result\n", g_stConfInfo.resultFileName);
exit -1; exit -1;
......
...@@ -22,7 +22,7 @@ void simLogSql(char *sql, bool useSharp) { ...@@ -22,7 +22,7 @@ void simLogSql(char *sql, bool useSharp) {
sprintf(filename, "%s/sim.sql", simScriptDir); sprintf(filename, "%s/sim.sql", simScriptDir);
if (pFile == NULL) { if (pFile == NULL) {
// fp = fopen(filename, "w"); // fp = fopen(filename, "w");
pFile = taosOpenFile(filename, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); pFile = taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
if (pFile == NULL) { if (pFile == NULL) {
fprintf(stderr, "ERROR: failed to open file: %s\n", filename); fprintf(stderr, "ERROR: failed to open file: %s\n", filename);
return; return;
...@@ -773,7 +773,7 @@ bool simExecuteRestfulCmd(SScript *script, char *rest) { ...@@ -773,7 +773,7 @@ bool simExecuteRestfulCmd(SScript *script, char *rest) {
char filename[256]; char filename[256];
sprintf(filename, "%s/tmp.sql", simScriptDir); sprintf(filename, "%s/tmp.sql", simScriptDir);
// fp = fopen(filename, "w"); // fp = fopen(filename, "w");
pFile = taosOpenFile(filename, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); pFile = taosOpenFile(filename, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
if (pFile == NULL) { if (pFile == NULL) {
fprintf(stderr, "ERROR: failed to open file: %s\n", filename); fprintf(stderr, "ERROR: failed to open file: %s\n", filename);
return false; return false;
......
...@@ -116,7 +116,7 @@ static void *shellCheckThreadFp(void *arg) { ...@@ -116,7 +116,7 @@ static void *shellCheckThreadFp(void *arg) {
char file[32] = {0}; char file[32] = {0};
snprintf(file, 32, "tb%d.txt", pThread->threadIndex); snprintf(file, 32, "tb%d.txt", pThread->threadIndex);
TdFilePtr pFile = taosOpenFile(file, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); TdFilePtr pFile = taosOpenFile(file, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (!fp) { if (!fp) {
fprintf(stdout, "failed to open %s, reason:%s", file, strerror(errno)); fprintf(stdout, "failed to open %s, reason:%s", file, strerror(errno));
return NULL; return NULL;
......
...@@ -518,7 +518,7 @@ static int dumpResultToFile(const char *fname, TAOS_RES *tres) { ...@@ -518,7 +518,7 @@ static int dumpResultToFile(const char *fname, TAOS_RES *tres) {
} }
// FILE *fp = fopen(full_path.we_wordv[0], "w"); // FILE *fp = fopen(full_path.we_wordv[0], "w");
TdFilePtr pFile = taosOpenFile(full_path.we_wordv[0], TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); TdFilePtr pFile = taosOpenFile(full_path.we_wordv[0], TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
if (pFile == NULL) { if (pFile == NULL) {
fprintf(stderr, "ERROR: failed to open file: %s\n", full_path.we_wordv[0]); fprintf(stderr, "ERROR: failed to open file: %s\n", full_path.we_wordv[0]);
wordfree(&full_path); wordfree(&full_path);
...@@ -935,7 +935,7 @@ void write_history() { ...@@ -935,7 +935,7 @@ void write_history() {
get_history_path(f_history); get_history_path(f_history);
// FILE *f = fopen(f_history, "w"); // FILE *f = fopen(f_history, "w");
TdFilePtr pFile = taosOpenFile(f_history, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); TdFilePtr pFile = taosOpenFile(f_history, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
if (pFile == NULL) { if (pFile == NULL) {
#ifndef WINDOWS #ifndef WINDOWS
fprintf(stderr, "Failed to open file %s for write, reason:%s\n", f_history, strerror(errno)); fprintf(stderr, "Failed to open file %s for write, reason:%s\n", f_history, strerror(errno));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册