Merge remote-tracking branch 'origin/3.0' into enh/TD-19463_2
This commit is contained in:
commit
ea4ae8a960
|
@ -16,10 +16,10 @@ You can use the SHOW CONNECTIONS statement to find the conn_id.
|
||||||
## Terminate a Query
|
## Terminate a Query
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SHOW QUERY query_id;
|
KILL QUERY kill_id;
|
||||||
```
|
```
|
||||||
|
|
||||||
You can use the SHOW QUERIES statement to find the query_id.
|
You can use the SHOW QUERIES statement to find the kill_id.
|
||||||
|
|
||||||
## Terminate a Transaction
|
## Terminate a Transaction
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ LTRIM(expr)
|
||||||
#### RTRIM
|
#### RTRIM
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
LTRIM(expr)
|
RTRIM(expr)
|
||||||
```
|
```
|
||||||
|
|
||||||
**功能说明**:返回清除右边空格后的字符串。
|
**功能说明**:返回清除右边空格后的字符串。
|
||||||
|
|
|
@ -17,10 +17,10 @@ conn_id 可以通过 `SHOW CONNECTIONS` 获取。
|
||||||
## 终止查询
|
## 终止查询
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SHOW QUERY query_id;
|
KILL QUERY kill_id;
|
||||||
```
|
```
|
||||||
|
|
||||||
query_id 可以通过 `SHOW QUERIES` 获取。
|
kill_id 可以通过 `SHOW QUERIES` 获取。
|
||||||
|
|
||||||
## 终止事务
|
## 终止事务
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000
|
||||||
|
|
||||||
## 数据模式映射规则
|
## 数据模式映射规则
|
||||||
|
|
||||||
本节将说明行协议的数据如何映射成为具有模式的数据。每个行协议中数据 measurement 映射为
|
本节将说明 InfluxDB 行协议(Line Protocol)的数据如何映射成为具有模式的数据。每个行协议中数据 measurement 映射为
|
||||||
超级表名称。tag_set 中的 标签名称为 数据模式中的标签名,field_set 中的名称为列名称。以如下数据为例,说明映射规则:
|
超级表名称。tag_set 中的 标签名称为 数据模式中的标签名,field_set 中的名称为列名称。以如下数据为例,说明映射规则:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|
|
@ -74,7 +74,12 @@ static void prepare_data(TAOS* taos) {
|
||||||
res = taos_query(taos, "create database test;");
|
res = taos_query(taos, "create database test;");
|
||||||
taos_free_result(res);
|
taos_free_result(res);
|
||||||
taosMsleep(100);
|
taosMsleep(100);
|
||||||
taos_select_db(taos, "test");
|
if (taos_select_db(taos, "test")) {
|
||||||
|
errorPrint("%s() LN%d: error no: %d, reason: %s\n",
|
||||||
|
__func__, __LINE__, taos_errno(res), taos_errstr(res));
|
||||||
|
taos_free_result(res);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char command[1024] = {0};
|
char command[1024] = {0};
|
||||||
sprintf(command, "%s", "create table meters(ts timestamp, f float, n int, bin1 binary(20), c nchar(20), bin2 binary(20)) tags(area int, city binary(20), dist nchar(20), street binary(20));");
|
sprintf(command, "%s", "create table meters(ts timestamp, f float, n int, bin1 binary(20), c nchar(20), bin2 binary(20)) tags(area int, city binary(20), dist nchar(20), street binary(20));");
|
||||||
|
|
|
@ -43,7 +43,7 @@ int32_t scalarGetOperatorParamNum(EOperatorType type);
|
||||||
int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type);
|
int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type);
|
||||||
|
|
||||||
int32_t vectorGetConvertType(int32_t type1, int32_t type2);
|
int32_t vectorGetConvertType(int32_t type1, int32_t type2);
|
||||||
int32_t vectorConvertImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *overflow);
|
int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *overflow, int32_t startIndex, int32_t numOfRows);
|
||||||
|
|
||||||
/* Math functions */
|
/* Math functions */
|
||||||
int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||||
|
|
|
@ -26,7 +26,7 @@ typedef struct SRBTree SRBTree;
|
||||||
typedef struct SRBTreeNode SRBTreeNode;
|
typedef struct SRBTreeNode SRBTreeNode;
|
||||||
typedef struct SRBTreeIter SRBTreeIter;
|
typedef struct SRBTreeIter SRBTreeIter;
|
||||||
|
|
||||||
typedef int32_t (*tRBTreeCmprFn)(const void *, const void *);
|
typedef int32_t (*tRBTreeCmprFn)(const SRBTreeNode *, const SRBTreeNode *);
|
||||||
|
|
||||||
// SRBTree =============================================
|
// SRBTree =============================================
|
||||||
#define tRBTreeMin(T) ((T)->min == ((T)->NIL) ? NULL : (T)->min)
|
#define tRBTreeMin(T) ((T)->min == ((T)->NIL) ? NULL : (T)->min)
|
||||||
|
@ -36,7 +36,7 @@ void tRBTreeCreate(SRBTree *pTree, tRBTreeCmprFn cmprFn);
|
||||||
SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z);
|
SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z);
|
||||||
void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *z);
|
void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *z);
|
||||||
SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey);
|
SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey);
|
||||||
SRBTreeNode *tRBTreeGet(SRBTree *pTree, void *pKey);
|
SRBTreeNode *tRBTreeGet(SRBTree *pTree, const SRBTreeNode *pKeyNode);
|
||||||
|
|
||||||
// SRBTreeIter =============================================
|
// SRBTreeIter =============================================
|
||||||
#define tRBTreeIterCreate(tree, ascend) \
|
#define tRBTreeIterCreate(tree, ascend) \
|
||||||
|
@ -53,8 +53,6 @@ struct SRBTreeNode {
|
||||||
SRBTreeNode *right;
|
SRBTreeNode *right;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RBTREE_NODE_PAYLOAD(N) ((const void *)&(N)[1])
|
|
||||||
|
|
||||||
struct SRBTree {
|
struct SRBTree {
|
||||||
tRBTreeCmprFn cmprFn;
|
tRBTreeCmprFn cmprFn;
|
||||||
int64_t n;
|
int64_t n;
|
||||||
|
|
|
@ -222,7 +222,9 @@ void taos_kill_query(TAOS *taos) {
|
||||||
|
|
||||||
int64_t rid = *(int64_t *)taos;
|
int64_t rid = *(int64_t *)taos;
|
||||||
STscObj *pTscObj = acquireTscObj(rid);
|
STscObj *pTscObj = acquireTscObj(rid);
|
||||||
stopAllRequests(pTscObj->pRequests);
|
if (pTscObj) {
|
||||||
|
stopAllRequests(pTscObj->pRequests);
|
||||||
|
}
|
||||||
releaseTscObj(rid);
|
releaseTscObj(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -972,6 +972,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
|
||||||
req.topicNames = taosArrayInit(sz, sizeof(void*));
|
req.topicNames = taosArrayInit(sz, sizeof(void*));
|
||||||
if (req.topicNames == NULL) goto FAIL;
|
if (req.topicNames == NULL) goto FAIL;
|
||||||
|
|
||||||
|
tscDebug("call tmq subscribe, consumer: %ld, topic num %d", tmq->consumerId, sz);
|
||||||
|
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
char* topic = taosArrayGetP(container, i);
|
char* topic = taosArrayGetP(container, i);
|
||||||
|
|
||||||
|
@ -1297,7 +1299,8 @@ int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
|
|
||||||
pParam->code = code;
|
pParam->code = code;
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
tscError("consumer:%" PRId64 ", get topic endpoint error, not ready, wait:%d", tmq->consumerId, pParam->async);
|
tscError("consumer:%" PRId64 ", get topic endpoint error, not ready, wait:%d, code %x", tmq->consumerId,
|
||||||
|
pParam->async, code);
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,11 +171,11 @@ int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) {
|
||||||
ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0);
|
ASSERT(taosArrayGetSize(pRsp->blockSchema) == 0);
|
||||||
|
|
||||||
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
|
if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) {
|
||||||
if (pRsp->blockNum > 0) {
|
/*if (pRsp->blockNum > 0) {*/
|
||||||
ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);
|
/*ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);*/
|
||||||
} else {
|
/*} else {*/
|
||||||
ASSERT(pRsp->rspOffset.version >= pRsp->reqOffset.version);
|
ASSERT(pRsp->rspOffset.version > pRsp->reqOffset.version);
|
||||||
}
|
/*}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
|
|
|
@ -245,7 +245,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
||||||
tqDebug("vgId:%d cannot find handle %s", pTq->pVnode->config.vgId, pPushEntry->subKey);
|
tqDebug("vgId:%d cannot find handle %s", pTq->pVnode->config.vgId, pPushEntry->subKey);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (pPushEntry->dataRsp.reqOffset.version > ver) {
|
if (pPushEntry->dataRsp.reqOffset.version >= ver) {
|
||||||
tqDebug("vgId:%d push entry req version %ld, while push version %ld, skip", pTq->pVnode->config.vgId,
|
tqDebug("vgId:%d push entry req version %ld, while push version %ld, skip", pTq->pVnode->config.vgId,
|
||||||
pPushEntry->dataRsp.reqOffset.version, ver);
|
pPushEntry->dataRsp.reqOffset.version, ver);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -396,12 +396,19 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t tDataIterCmprFn(const SRBTreeNode *n1, const SRBTreeNode *n2) {
|
||||||
|
SDataIter *pIter1 = (SDataIter *)((uint8_t *)n1 - offsetof(SDataIter, n));
|
||||||
|
SDataIter *pIter2 = (SDataIter *)((uint8_t *)n2 - offsetof(SDataIter, n));
|
||||||
|
|
||||||
|
return tRowInfoCmprFn(&pIter1->r, &pIter2->r);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
|
static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
pCommitter->pIter = NULL;
|
pCommitter->pIter = NULL;
|
||||||
tRBTreeCreate(&pCommitter->rbt, tRowInfoCmprFn);
|
tRBTreeCreate(&pCommitter->rbt, tDataIterCmprFn);
|
||||||
|
|
||||||
// memory
|
// memory
|
||||||
TSDBKEY tKey = {.ts = pCommitter->minKey, .version = VERSION_MIN};
|
TSDBKEY tKey = {.ts = pCommitter->minKey, .version = VERSION_MIN};
|
||||||
|
|
|
@ -610,9 +610,6 @@ int32_t tsdbFSRollback(STsdbFS *pFS) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFSUpsertDelFile(STsdbFS *pFS, SDelFile *pDelFile) {
|
int32_t tsdbFSUpsertDelFile(STsdbFS *pFS, SDelFile *pDelFile) {
|
||||||
|
@ -866,7 +863,7 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
|
||||||
nRef = atomic_sub_fetch_32(&fSet.pSmaF->nRef, 1);
|
nRef = atomic_sub_fetch_32(&fSet.pSmaF->nRef, 1);
|
||||||
if (nRef == 0) {
|
if (nRef == 0) {
|
||||||
tsdbSmaFileName(pTsdb, pSetOld->diskId, pSetOld->fid, fSet.pSmaF, fname);
|
tsdbSmaFileName(pTsdb, pSetOld->diskId, pSetOld->fid, fSet.pSmaF, fname);
|
||||||
taosRemoveFile(fname);
|
(void)taosRemoveFile(fname);
|
||||||
taosMemoryFree(fSet.pSmaF);
|
taosMemoryFree(fSet.pSmaF);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -877,7 +874,7 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
|
||||||
// stt
|
// stt
|
||||||
if (sameDisk) {
|
if (sameDisk) {
|
||||||
if (pSetNew->nSttF > pSetOld->nSttF) {
|
if (pSetNew->nSttF > pSetOld->nSttF) {
|
||||||
ASSERT(pSetNew->nSttF = pSetOld->nSttF + 1);
|
ASSERT(pSetNew->nSttF == pSetOld->nSttF + 1);
|
||||||
pSetOld->aSttF[pSetOld->nSttF] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
|
pSetOld->aSttF[pSetOld->nSttF] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
|
||||||
if (pSetOld->aSttF[pSetOld->nSttF] == NULL) {
|
if (pSetOld->aSttF[pSetOld->nSttF] == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -1104,7 +1101,7 @@ void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS) {
|
||||||
ASSERT(nRef >= 0);
|
ASSERT(nRef >= 0);
|
||||||
if (nRef == 0) {
|
if (nRef == 0) {
|
||||||
tsdbDelFileName(pTsdb, pFS->pDelFile, fname);
|
tsdbDelFileName(pTsdb, pFS->pDelFile, fname);
|
||||||
taosRemoveFile(fname);
|
(void)taosRemoveFile(fname);
|
||||||
taosMemoryFree(pFS->pDelFile);
|
taosMemoryFree(pFS->pDelFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -559,6 +559,8 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
|
||||||
|
|
||||||
// backward put first data
|
// backward put first data
|
||||||
row.pTSRow = tGetSubmitBlkNext(&blkIter);
|
row.pTSRow = tGetSubmitBlkNext(&blkIter);
|
||||||
|
if (row.pTSRow == NULL) return code;
|
||||||
|
|
||||||
key.ts = row.pTSRow->ts;
|
key.ts = row.pTSRow->ts;
|
||||||
nRow++;
|
nRow++;
|
||||||
tbDataMovePosTo(pTbData, pos, &key, SL_MOVE_BACKWARD);
|
tbDataMovePosTo(pTbData, pos, &key, SL_MOVE_BACKWARD);
|
||||||
|
|
|
@ -504,9 +504,9 @@ _exit:
|
||||||
SRowInfo *tLDataIterGet(SLDataIter *pIter) { return &pIter->rInfo; }
|
SRowInfo *tLDataIterGet(SLDataIter *pIter) { return &pIter->rInfo; }
|
||||||
|
|
||||||
// SMergeTree =================================================
|
// SMergeTree =================================================
|
||||||
static FORCE_INLINE int32_t tLDataIterCmprFn(const void *p1, const void *p2) {
|
static FORCE_INLINE int32_t tLDataIterCmprFn(const SRBTreeNode *p1, const SRBTreeNode *p2) {
|
||||||
SLDataIter *pIter1 = (SLDataIter *)(((uint8_t *)p1) - sizeof(SRBTreeNode));
|
SLDataIter *pIter1 = (SLDataIter *)(((uint8_t *)p1) - offsetof(SLDataIter, node));
|
||||||
SLDataIter *pIter2 = (SLDataIter *)(((uint8_t *)p2) - sizeof(SRBTreeNode));
|
SLDataIter *pIter2 = (SLDataIter *)(((uint8_t *)p2) - offsetof(SLDataIter, node));
|
||||||
|
|
||||||
TSDBKEY key1 = TSDBROW_KEY(&pIter1->rInfo.row);
|
TSDBKEY key1 = TSDBROW_KEY(&pIter1->rInfo.row);
|
||||||
TSDBKEY key2 = TSDBROW_KEY(&pIter2->rInfo.row);
|
TSDBKEY key2 = TSDBROW_KEY(&pIter2->rInfo.row);
|
||||||
|
@ -583,7 +583,7 @@ bool tMergeTreeNext(SMergeTree *pMTree) {
|
||||||
// compare with min in RB Tree
|
// compare with min in RB Tree
|
||||||
pIter = (SLDataIter *)tRBTreeMin(&pMTree->rbt);
|
pIter = (SLDataIter *)tRBTreeMin(&pMTree->rbt);
|
||||||
if (pMTree->pIter && pIter) {
|
if (pMTree->pIter && pIter) {
|
||||||
int32_t c = pMTree->rbt.cmprFn(RBTREE_NODE_PAYLOAD(&pMTree->pIter->node), RBTREE_NODE_PAYLOAD(&pIter->node));
|
int32_t c = pMTree->rbt.cmprFn(&pMTree->pIter->node, &pIter->node);
|
||||||
if (c > 0) {
|
if (c > 0) {
|
||||||
tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter);
|
tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter);
|
||||||
pMTree->pIter = NULL;
|
pMTree->pIter = NULL;
|
||||||
|
|
|
@ -87,9 +87,13 @@ _err:
|
||||||
|
|
||||||
int tsdbClose(STsdb **pTsdb) {
|
int tsdbClose(STsdb **pTsdb) {
|
||||||
if (*pTsdb) {
|
if (*pTsdb) {
|
||||||
taosThreadRwlockDestroy(&(*pTsdb)->rwLock);
|
taosThreadRwlockWrlock(&(*pTsdb)->rwLock);
|
||||||
tsdbMemTableDestroy((*pTsdb)->mem);
|
tsdbMemTableDestroy((*pTsdb)->mem);
|
||||||
(*pTsdb)->mem = NULL;
|
(*pTsdb)->mem = NULL;
|
||||||
|
taosThreadRwlockUnlock(&(*pTsdb)->rwLock);
|
||||||
|
|
||||||
|
taosThreadRwlockDestroy(&(*pTsdb)->rwLock);
|
||||||
|
|
||||||
tsdbFSClose(*pTsdb);
|
tsdbFSClose(*pTsdb);
|
||||||
tsdbCloseCache(*pTsdb);
|
tsdbCloseCache(*pTsdb);
|
||||||
taosMemoryFreeClear(*pTsdb);
|
taosMemoryFreeClear(*pTsdb);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
// =============== PAGE-WISE FILE ===============
|
// =============== PAGE-WISE FILE ===============
|
||||||
static int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsdbFD **ppFD) {
|
static int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsdbFD **ppFD) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STsdbFD *pFD;
|
STsdbFD *pFD = NULL;
|
||||||
|
|
||||||
*ppFD = NULL;
|
*ppFD = NULL;
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ static int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsd
|
||||||
pFD->pFD = taosOpenFile(path, flag);
|
pFD->pFD = taosOpenFile(path, flag);
|
||||||
if (pFD->pFD == NULL) {
|
if (pFD->pFD == NULL) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
taosMemoryFree(pFD);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
pFD->szPage = szPage;
|
pFD->szPage = szPage;
|
||||||
|
@ -42,11 +43,15 @@ static int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsd
|
||||||
pFD->pBuf = taosMemoryCalloc(1, szPage);
|
pFD->pBuf = taosMemoryCalloc(1, szPage);
|
||||||
if (pFD->pBuf == NULL) {
|
if (pFD->pBuf == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
taosCloseFile(&pFD->pFD);
|
||||||
taosMemoryFree(pFD);
|
taosMemoryFree(pFD);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
if (taosStatFile(path, &pFD->szFile, NULL) < 0) {
|
if (taosStatFile(path, &pFD->szFile, NULL) < 0) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
code = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
taosMemoryFree(pFD->pBuf);
|
||||||
|
taosCloseFile(&pFD->pFD);
|
||||||
|
taosMemoryFree(pFD);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
ASSERT(pFD->szFile % szPage == 0);
|
ASSERT(pFD->szFile % szPage == 0);
|
||||||
|
@ -59,10 +64,12 @@ _exit:
|
||||||
|
|
||||||
static void tsdbCloseFile(STsdbFD **ppFD) {
|
static void tsdbCloseFile(STsdbFD **ppFD) {
|
||||||
STsdbFD *pFD = *ppFD;
|
STsdbFD *pFD = *ppFD;
|
||||||
taosMemoryFree(pFD->pBuf);
|
if (pFD) {
|
||||||
taosCloseFile(&pFD->pFD);
|
taosMemoryFree(pFD->pBuf);
|
||||||
taosMemoryFree(pFD);
|
taosCloseFile(&pFD->pFD);
|
||||||
*ppFD = NULL;
|
taosMemoryFree(pFD);
|
||||||
|
*ppFD = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tsdbWriteFilePage(STsdbFD *pFD) {
|
static int32_t tsdbWriteFilePage(STsdbFD *pFD) {
|
||||||
|
@ -443,7 +450,7 @@ int32_t tsdbWriteDataBlk(SDataFWriter *pWriter, SMapData *mDataBlk, SBlockIdx *p
|
||||||
pBlockIdx->size = size;
|
pBlockIdx->size = size;
|
||||||
pHeadFile->size += size;
|
pHeadFile->size += size;
|
||||||
|
|
||||||
tsdbTrace("vgId:%d, write block, file ID:%d commit ID:%d suid:%" PRId64 " uid:%" PRId64 " offset:%" PRId64
|
tsdbTrace("vgId:%d, write block, file ID:%d commit ID:%" PRId64 " suid:%" PRId64 " uid:%" PRId64 " offset:%" PRId64
|
||||||
" size:%" PRId64 " nItem:%d",
|
" size:%" PRId64 " nItem:%d",
|
||||||
TD_VID(pWriter->pTsdb->pVnode), pWriter->wSet.fid, pHeadFile->commitID, pBlockIdx->suid, pBlockIdx->uid,
|
TD_VID(pWriter->pTsdb->pVnode), pWriter->wSet.fid, pHeadFile->commitID, pBlockIdx->suid, pBlockIdx->uid,
|
||||||
pBlockIdx->offset, pBlockIdx->size, mDataBlk->nItem);
|
pBlockIdx->offset, pBlockIdx->size, mDataBlk->nItem);
|
||||||
|
@ -457,7 +464,7 @@ _err:
|
||||||
int32_t tsdbWriteSttBlk(SDataFWriter *pWriter, SArray *aSttBlk) {
|
int32_t tsdbWriteSttBlk(SDataFWriter *pWriter, SArray *aSttBlk) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSttFile *pSttFile = &pWriter->fStt[pWriter->wSet.nSttF - 1];
|
SSttFile *pSttFile = &pWriter->fStt[pWriter->wSet.nSttF - 1];
|
||||||
int64_t size;
|
int64_t size = 0;
|
||||||
int64_t n;
|
int64_t n;
|
||||||
|
|
||||||
// check
|
// check
|
||||||
|
@ -906,10 +913,6 @@ int32_t tsdbDataFReaderClose(SDataFReader **ppReader) {
|
||||||
taosMemoryFree(*ppReader);
|
taosMemoryFree(*ppReader);
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
|
||||||
tsdbError("vgId:%d, data file reader close failed since %s", TD_VID((*ppReader)->pTsdb->pVnode), tstrerror(code));
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
|
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
|
||||||
|
@ -1289,16 +1292,17 @@ _exit:
|
||||||
// SDelFWriter ====================================================
|
// SDelFWriter ====================================================
|
||||||
int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb) {
|
int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
char fname[TSDB_FILENAME_LEN];
|
char fname[TSDB_FILENAME_LEN];
|
||||||
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
uint8_t hdr[TSDB_FHDR_SIZE] = {0};
|
||||||
SDelFWriter *pDelFWriter;
|
SDelFWriter *pDelFWriter = NULL;
|
||||||
int64_t n;
|
int64_t n;
|
||||||
|
|
||||||
// alloc
|
// alloc
|
||||||
pDelFWriter = (SDelFWriter *)taosMemoryCalloc(1, sizeof(*pDelFWriter));
|
pDelFWriter = (SDelFWriter *)taosMemoryCalloc(1, sizeof(*pDelFWriter));
|
||||||
if (pDelFWriter == NULL) {
|
if (pDelFWriter == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
pDelFWriter->pTsdb = pTsdb;
|
pDelFWriter->pTsdb = pTsdb;
|
||||||
pDelFWriter->fDel = *pFile;
|
pDelFWriter->fDel = *pFile;
|
||||||
|
@ -1306,21 +1310,28 @@ int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb
|
||||||
tsdbDelFileName(pTsdb, pFile, fname);
|
tsdbDelFileName(pTsdb, pFile, fname);
|
||||||
code = tsdbOpenFile(fname, pTsdb->pVnode->config.tsdbPageSize, TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE,
|
code = tsdbOpenFile(fname, pTsdb->pVnode->config.tsdbPageSize, TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE,
|
||||||
&pDelFWriter->pWriteH);
|
&pDelFWriter->pWriteH);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// update header
|
// update header
|
||||||
code = tsdbWriteFile(pDelFWriter->pWriteH, 0, hdr, TSDB_FHDR_SIZE);
|
code = tsdbWriteFile(pDelFWriter->pWriteH, 0, hdr, TSDB_FHDR_SIZE);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
pDelFWriter->fDel.size = TSDB_FHDR_SIZE;
|
pDelFWriter->fDel.size = TSDB_FHDR_SIZE;
|
||||||
pDelFWriter->fDel.offset = 0;
|
pDelFWriter->fDel.offset = 0;
|
||||||
|
|
||||||
*ppWriter = pDelFWriter;
|
*ppWriter = pDelFWriter;
|
||||||
return code;
|
|
||||||
|
|
||||||
_err:
|
_exit:
|
||||||
tsdbError("vgId:%d, failed to open del file writer since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
if (code) {
|
||||||
*ppWriter = NULL;
|
if (pDelFWriter) {
|
||||||
|
taosMemoryFree(pDelFWriter);
|
||||||
|
tsdbCloseFile(&pDelFWriter->pWriteH);
|
||||||
|
}
|
||||||
|
*ppWriter = NULL;
|
||||||
|
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(errno));
|
||||||
|
} else {
|
||||||
|
*ppWriter = pDelFWriter;
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1456,15 +1467,15 @@ struct SDelFReader {
|
||||||
|
|
||||||
int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb) {
|
int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
char fname[TSDB_FILENAME_LEN];
|
char fname[TSDB_FILENAME_LEN];
|
||||||
SDelFReader *pDelFReader;
|
SDelFReader *pDelFReader = NULL;
|
||||||
int64_t n;
|
|
||||||
|
|
||||||
// alloc
|
// alloc
|
||||||
pDelFReader = (SDelFReader *)taosMemoryCalloc(1, sizeof(*pDelFReader));
|
pDelFReader = (SDelFReader *)taosMemoryCalloc(1, sizeof(*pDelFReader));
|
||||||
if (pDelFReader == NULL) {
|
if (pDelFReader == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// open impl
|
// open impl
|
||||||
|
@ -1473,14 +1484,18 @@ int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb
|
||||||
|
|
||||||
tsdbDelFileName(pTsdb, pFile, fname);
|
tsdbDelFileName(pTsdb, pFile, fname);
|
||||||
code = tsdbOpenFile(fname, pTsdb->pVnode->config.tsdbPageSize, TD_FILE_READ, &pDelFReader->pReadH);
|
code = tsdbOpenFile(fname, pTsdb->pVnode->config.tsdbPageSize, TD_FILE_READ, &pDelFReader->pReadH);
|
||||||
if (code) goto _err;
|
if (code) {
|
||||||
|
taosMemoryFree(pDelFReader);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
*ppReader = pDelFReader;
|
_exit:
|
||||||
return code;
|
if (code) {
|
||||||
|
*ppReader = NULL;
|
||||||
_err:
|
tsdbError("vgId:%d %s failed at %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
tsdbError("vgId:%d, del file reader open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
|
} else {
|
||||||
*ppReader = NULL;
|
*ppReader = pDelFReader;
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,13 @@ extern int32_t tRowInfoCmprFn(const void* p1, const void* p2);
|
||||||
extern int32_t tsdbReadDataBlockEx(SDataFReader* pReader, SDataBlk* pDataBlk, SBlockData* pBlockData);
|
extern int32_t tsdbReadDataBlockEx(SDataFReader* pReader, SDataBlk* pDataBlk, SBlockData* pBlockData);
|
||||||
extern int32_t tsdbUpdateTableSchema(SMeta* pMeta, int64_t suid, int64_t uid, SSkmInfo* pSkmInfo);
|
extern int32_t tsdbUpdateTableSchema(SMeta* pMeta, int64_t suid, int64_t uid, SSkmInfo* pSkmInfo);
|
||||||
|
|
||||||
|
static int32_t tFDataIterCmprFn(const SRBTreeNode* pNode1, const SRBTreeNode* pNode2) {
|
||||||
|
SFDataIter* pIter1 = (SFDataIter*)(((uint8_t*)pNode1) - offsetof(SFDataIter, n));
|
||||||
|
SFDataIter* pIter2 = (SFDataIter*)(((uint8_t*)pNode2) - offsetof(SFDataIter, n));
|
||||||
|
|
||||||
|
return tRowInfoCmprFn(&pIter1->rInfo, &pIter2->rInfo);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) {
|
static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -79,7 +86,7 @@ static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) {
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
|
|
||||||
pReader->pIter = NULL;
|
pReader->pIter = NULL;
|
||||||
tRBTreeCreate(&pReader->rbt, tRowInfoCmprFn);
|
tRBTreeCreate(&pReader->rbt, tFDataIterCmprFn);
|
||||||
|
|
||||||
// .data file
|
// .data file
|
||||||
SFDataIter* pIter = &pReader->aFDataIter[0];
|
SFDataIter* pIter = &pReader->aFDataIter[0];
|
||||||
|
@ -421,7 +428,7 @@ static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) {
|
||||||
n += tPutDelData((*ppData) + n, pDelData);
|
n += tPutDelData((*ppData) + n, pDelData);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbInfo("vgId:%d, vnode snapshot tsdb read del data for %s, suid:%" PRId64 " uid:%d" PRId64 " size:%d",
|
tsdbInfo("vgId:%d, vnode snapshot tsdb read del data for %s, suid:%" PRId64 " uid:%" PRId64 " size:%d",
|
||||||
TD_VID(pTsdb->pVnode), pTsdb->path, pDelIdx->suid, pDelIdx->uid, size);
|
TD_VID(pTsdb->pVnode), pTsdb->path, pDelIdx->suid, pDelIdx->uid, size);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -431,7 +438,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("vgId:%d, vnode snapshot tsdb read del for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->pVnode,
|
tsdbError("vgId:%d, vnode snapshot tsdb read del for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1247,20 +1254,21 @@ _err:
|
||||||
// APIs
|
// APIs
|
||||||
int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter) {
|
int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
int32_t lino = 0;
|
||||||
STsdbSnapWriter* pWriter = NULL;
|
STsdbSnapWriter* pWriter = NULL;
|
||||||
|
|
||||||
// alloc
|
// alloc
|
||||||
pWriter = (STsdbSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
pWriter = (STsdbSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||||
if (pWriter == NULL) {
|
if (pWriter == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
pWriter->pTsdb = pTsdb;
|
pWriter->pTsdb = pTsdb;
|
||||||
pWriter->sver = sver;
|
pWriter->sver = sver;
|
||||||
pWriter->ever = ever;
|
pWriter->ever = ever;
|
||||||
|
|
||||||
code = tsdbFSCopy(pTsdb, &pWriter->fs);
|
code = tsdbFSCopy(pTsdb, &pWriter->fs);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// config
|
// config
|
||||||
pWriter->minutes = pTsdb->keepCfg.days;
|
pWriter->minutes = pTsdb->keepCfg.days;
|
||||||
|
@ -1272,7 +1280,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
||||||
|
|
||||||
// SNAP_DATA_TSDB
|
// SNAP_DATA_TSDB
|
||||||
code = tBlockDataCreate(&pWriter->bData);
|
code = tBlockDataCreate(&pWriter->bData);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
pWriter->fid = INT32_MIN;
|
pWriter->fid = INT32_MIN;
|
||||||
pWriter->id = (TABLEID){0};
|
pWriter->id = (TABLEID){0};
|
||||||
|
@ -1280,53 +1288,67 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
|
||||||
pWriter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
pWriter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
||||||
if (pWriter->dReader.aBlockIdx == NULL) {
|
if (pWriter->dReader.aBlockIdx == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
code = tBlockDataCreate(&pWriter->dReader.bData);
|
code = tBlockDataCreate(&pWriter->dReader.bData);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// Writer
|
// Writer
|
||||||
pWriter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
pWriter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
|
||||||
if (pWriter->dWriter.aBlockIdx == NULL) {
|
if (pWriter->dWriter.aBlockIdx == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
pWriter->dWriter.aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
|
pWriter->dWriter.aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
|
||||||
if (pWriter->dWriter.aSttBlk == NULL) {
|
if (pWriter->dWriter.aSttBlk == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
code = tBlockDataCreate(&pWriter->dWriter.bData);
|
code = tBlockDataCreate(&pWriter->dWriter.bData);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
code = tBlockDataCreate(&pWriter->dWriter.sData);
|
code = tBlockDataCreate(&pWriter->dWriter.sData);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
// SNAP_DATA_DEL
|
// SNAP_DATA_DEL
|
||||||
pWriter->aDelIdxR = taosArrayInit(0, sizeof(SDelIdx));
|
pWriter->aDelIdxR = taosArrayInit(0, sizeof(SDelIdx));
|
||||||
if (pWriter->aDelIdxR == NULL) {
|
if (pWriter->aDelIdxR == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
pWriter->aDelData = taosArrayInit(0, sizeof(SDelData));
|
pWriter->aDelData = taosArrayInit(0, sizeof(SDelData));
|
||||||
if (pWriter->aDelData == NULL) {
|
if (pWriter->aDelData == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
pWriter->aDelIdxW = taosArrayInit(0, sizeof(SDelIdx));
|
pWriter->aDelIdxW = taosArrayInit(0, sizeof(SDelIdx));
|
||||||
if (pWriter->aDelIdxW == NULL) {
|
if (pWriter->aDelIdxW == NULL) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto _err;
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppWriter = pWriter;
|
_exit:
|
||||||
|
if (code) {
|
||||||
|
tsdbError("vgId:%d %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||||
|
*ppWriter = NULL;
|
||||||
|
|
||||||
tsdbInfo("vgId:%d, tsdb snapshot writer open for %s succeed", TD_VID(pTsdb->pVnode), pTsdb->path);
|
if (pWriter) {
|
||||||
return code;
|
if (pWriter->aDelIdxW) taosArrayDestroy(pWriter->aDelIdxW);
|
||||||
|
if (pWriter->aDelData) taosArrayDestroy(pWriter->aDelData);
|
||||||
_err:
|
if (pWriter->aDelIdxR) taosArrayDestroy(pWriter->aDelIdxR);
|
||||||
tsdbError("vgId:%d, tsdb snapshot writer open for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path,
|
tBlockDataDestroy(&pWriter->dWriter.sData, 1);
|
||||||
tstrerror(code));
|
tBlockDataDestroy(&pWriter->dWriter.bData, 1);
|
||||||
*ppWriter = NULL;
|
if (pWriter->dWriter.aSttBlk) taosArrayDestroy(pWriter->dWriter.aSttBlk);
|
||||||
|
if (pWriter->dWriter.aBlockIdx) taosArrayDestroy(pWriter->dWriter.aBlockIdx);
|
||||||
|
tBlockDataDestroy(&pWriter->dReader.bData, 1);
|
||||||
|
if (pWriter->dReader.aBlockIdx) taosArrayDestroy(pWriter->dReader.aBlockIdx);
|
||||||
|
tBlockDataDestroy(&pWriter->bData, 1);
|
||||||
|
tsdbFSDestroy(&pWriter->fs);
|
||||||
|
taosMemoryFree(pWriter);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tsdbDebug("vgId:%d, tsdb snapshot writer open for %s succeed", TD_VID(pTsdb->pVnode), pTsdb->path);
|
||||||
|
*ppWriter = pWriter;
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,9 @@ int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop to insert
|
// loop to insert
|
||||||
tInitSubmitMsgIter(pMsg, &msgIter);
|
if (tInitSubmitMsgIter(pMsg, &msgIter) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
SSubmitBlkRsp r = {0};
|
SSubmitBlkRsp r = {0};
|
||||||
tGetSubmitMsgNext(&msgIter, &pBlock);
|
tGetSubmitMsgNext(&msgIter, &pBlock);
|
||||||
|
|
|
@ -141,17 +141,17 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeBufPoolFree(SVBufPool *pPool, void *p) {
|
void vnodeBufPoolFree(SVBufPool *pPool, void *p) {
|
||||||
uint8_t *ptr = (uint8_t *)p;
|
// uint8_t *ptr = (uint8_t *)p;
|
||||||
SVBufPoolNode *pNode;
|
// SVBufPoolNode *pNode;
|
||||||
|
|
||||||
if (ptr < pPool->node.data || ptr >= pPool->node.data + pPool->node.size) {
|
// if (ptr < pPool->node.data || ptr >= pPool->node.data + pPool->node.size) {
|
||||||
pNode = &((SVBufPoolNode *)p)[-1];
|
// pNode = &((SVBufPoolNode *)p)[-1];
|
||||||
*pNode->pnext = pNode->prev;
|
// *pNode->pnext = pNode->prev;
|
||||||
pNode->prev->pnext = pNode->pnext;
|
// pNode->prev->pnext = pNode->pnext;
|
||||||
|
|
||||||
pPool->size = pPool->size - sizeof(*pNode) - pNode->size;
|
// pPool->size = pPool->size - sizeof(*pNode) - pNode->size;
|
||||||
taosMemoryFree(pNode);
|
// taosMemoryFree(pNode);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void vnodeBufPoolRef(SVBufPool *pPool) {
|
void vnodeBufPoolRef(SVBufPool *pPool) {
|
||||||
|
|
|
@ -46,11 +46,17 @@ int vnodeInit(int nthreads) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vnodeGlobal.stop = 0;
|
taosThreadMutexInit(&vnodeGlobal.mutex, NULL);
|
||||||
|
taosThreadCondInit(&vnodeGlobal.hasTask, NULL);
|
||||||
|
|
||||||
|
taosThreadMutexLock(&vnodeGlobal.mutex);
|
||||||
|
|
||||||
|
vnodeGlobal.stop = 0;
|
||||||
vnodeGlobal.queue.next = &vnodeGlobal.queue;
|
vnodeGlobal.queue.next = &vnodeGlobal.queue;
|
||||||
vnodeGlobal.queue.prev = &vnodeGlobal.queue;
|
vnodeGlobal.queue.prev = &vnodeGlobal.queue;
|
||||||
|
|
||||||
|
taosThreadMutexUnlock(&(vnodeGlobal.mutex));
|
||||||
|
|
||||||
vnodeGlobal.nthreads = nthreads;
|
vnodeGlobal.nthreads = nthreads;
|
||||||
vnodeGlobal.threads = taosMemoryCalloc(nthreads, sizeof(TdThread));
|
vnodeGlobal.threads = taosMemoryCalloc(nthreads, sizeof(TdThread));
|
||||||
if (vnodeGlobal.threads == NULL) {
|
if (vnodeGlobal.threads == NULL) {
|
||||||
|
@ -59,9 +65,6 @@ int vnodeInit(int nthreads) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosThreadMutexInit(&vnodeGlobal.mutex, NULL);
|
|
||||||
taosThreadCondInit(&vnodeGlobal.hasTask, NULL);
|
|
||||||
|
|
||||||
for (int i = 0; i < nthreads; i++) {
|
for (int i = 0; i < nthreads; i++) {
|
||||||
taosThreadCreate(&(vnodeGlobal.threads[i]), NULL, loop, NULL);
|
taosThreadCreate(&(vnodeGlobal.threads[i]), NULL, loop, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
||||||
if (taosMkDir(path)) {
|
if (taosMkDir(path)) {
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
}
|
}
|
||||||
strcpy(dir, path);
|
snprintf(dir, TSDB_FILENAME_LEN, "%s", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCfg) {
|
if (pCfg) {
|
||||||
|
@ -51,7 +51,7 @@ int vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
|
||||||
info.state.commitID = 0;
|
info.state.commitID = 0;
|
||||||
|
|
||||||
if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) {
|
if (vnodeSaveInfo(dir, &info) < 0 || vnodeCommitInfo(dir, &info) < 0) {
|
||||||
vError("vgId:%d, failed to save vnode config since %s", pCfg->vgId, tstrerror(terrno));
|
vError("vgId:%d, failed to save vnode config since %s", pCfg ? pCfg->vgId : 0, tstrerror(terrno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
|
||||||
if (*ppData) {
|
if (*ppData) {
|
||||||
goto _exit;
|
goto _exit;
|
||||||
} else {
|
} else {
|
||||||
pReader->tqHandleDone = 1;
|
pReader->tqOffsetDone = 1;
|
||||||
code = tqOffsetReaderClose(&pReader->pTqOffsetReader);
|
code = tqOffsetReaderClose(&pReader->pTqOffsetReader);
|
||||||
if (code) goto _err;
|
if (code) goto _err;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
vError("vgId:% vnode snapshot read failed since %s", TD_VID(pReader->pVnode), tstrerror(code));
|
vError("vgId:%d vnode snapshot read failed since %s", TD_VID(pReader->pVnode), tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,10 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr
|
||||||
|
|
||||||
// commit it
|
// commit it
|
||||||
code = vnodeCommit(pVnode);
|
code = vnodeCommit(pVnode);
|
||||||
if (code) goto _err;
|
if (code) {
|
||||||
|
taosMemoryFree(pWriter);
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
// inc commit ID
|
// inc commit ID
|
||||||
pVnode->state.commitID++;
|
pVnode->state.commitID++;
|
||||||
|
|
|
@ -68,7 +68,10 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||||
int64_t ctime = taosGetTimestampMs();
|
int64_t ctime = taosGetTimestampMs();
|
||||||
tb_uid_t uid;
|
tb_uid_t uid;
|
||||||
|
|
||||||
tInitSubmitMsgIter(pSubmitReq, &msgIter);
|
if (tInitSubmitMsgIter(pSubmitReq, &msgIter) < 0) {
|
||||||
|
code = terrno;
|
||||||
|
goto _err;
|
||||||
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
tGetSubmitMsgNext(&msgIter, &pBlock);
|
tGetSubmitMsgNext(&msgIter, &pBlock);
|
||||||
|
|
|
@ -479,6 +479,7 @@ typedef struct SStreamScanInfo {
|
||||||
SExprInfo* pPseudoExpr;
|
SExprInfo* pPseudoExpr;
|
||||||
int32_t numOfPseudoExpr;
|
int32_t numOfPseudoExpr;
|
||||||
SExprSupp tbnameCalSup;
|
SExprSupp tbnameCalSup;
|
||||||
|
SExprSupp tagCalSup;
|
||||||
int32_t primaryTsIndex; // primary time stamp slot id
|
int32_t primaryTsIndex; // primary time stamp slot id
|
||||||
SReadHandle readHandle;
|
SReadHandle readHandle;
|
||||||
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here.
|
SInterval interval; // if the upstream is an interval operator, the interval info is also kept here.
|
||||||
|
@ -775,6 +776,7 @@ typedef struct SStreamPartitionOperatorInfo {
|
||||||
SPartitionBySupporter partitionSup;
|
SPartitionBySupporter partitionSup;
|
||||||
SExprSupp scalarSup;
|
SExprSupp scalarSup;
|
||||||
SExprSupp tbnameCalSup;
|
SExprSupp tbnameCalSup;
|
||||||
|
SExprSupp tagCalSup;
|
||||||
SHashObj* pPartitions;
|
SHashObj* pPartitions;
|
||||||
void* parIte;
|
void* parIte;
|
||||||
SSDataBlock* pInputDataBlock;
|
SSDataBlock* pInputDataBlock;
|
||||||
|
|
|
@ -1250,6 +1250,17 @@ void createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) {
|
||||||
pExp->base.resSchema =
|
pExp->base.resSchema =
|
||||||
createResSchema(pType->type, pType->bytes, slotId, pType->scale, pType->precision, pOpNode->node.aliasName);
|
createResSchema(pType->type, pType->bytes, slotId, pType->scale, pType->precision, pOpNode->node.aliasName);
|
||||||
pExp->pExpr->_optrRoot.pRootNode = pNode;
|
pExp->pExpr->_optrRoot.pRootNode = pNode;
|
||||||
|
} else if (type == QUERY_NODE_CASE_WHEN) {
|
||||||
|
pExp->pExpr->nodeType = QUERY_NODE_OPERATOR;
|
||||||
|
SCaseWhenNode* pCaseNode = (SCaseWhenNode*)pNode;
|
||||||
|
|
||||||
|
pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
|
||||||
|
pExp->base.numOfParams = 1;
|
||||||
|
|
||||||
|
SDataType* pType = &pCaseNode->node.resType;
|
||||||
|
pExp->base.resSchema = createResSchema(pType->type, pType->bytes, slotId, pType->scale,
|
||||||
|
pType->precision, pCaseNode->node.aliasName);
|
||||||
|
pExp->pExpr->_optrRoot.pRootNode = pNode;
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -991,6 +991,8 @@ static void destroyStreamPartitionOperatorInfo(void* param) {
|
||||||
|
|
||||||
taosMemoryFree(pInfo->partitionSup.keyBuf);
|
taosMemoryFree(pInfo->partitionSup.keyBuf);
|
||||||
cleanupExprSupp(&pInfo->scalarSup);
|
cleanupExprSupp(&pInfo->scalarSup);
|
||||||
|
cleanupExprSupp(&pInfo->tbnameCalSup);
|
||||||
|
cleanupExprSupp(&pInfo->tagCalSup);
|
||||||
blockDataDestroy(pInfo->pDelRes);
|
blockDataDestroy(pInfo->pDelRes);
|
||||||
taosMemoryFreeClear(param);
|
taosMemoryFreeClear(param);
|
||||||
}
|
}
|
||||||
|
@ -1037,6 +1039,19 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pPartNode->pTags != NULL) {
|
||||||
|
int32_t numOfTags;
|
||||||
|
SExprInfo* pTagExpr = createExprInfo(pPartNode->pTags, NULL, &numOfTags);
|
||||||
|
if (pTagExpr == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
if (initExprSupp(&pInfo->tagCalSup, pTagExpr, numOfTags) != 0) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t keyLen = 0;
|
int32_t keyLen = 0;
|
||||||
code = initGroupOptrInfo(&pInfo->partitionSup.pGroupColVals, &keyLen, &pInfo->partitionSup.keyBuf,
|
code = initGroupOptrInfo(&pInfo->partitionSup.pGroupColVals, &keyLen, &pInfo->partitionSup.keyBuf,
|
||||||
pInfo->partitionSup.pGroupCols);
|
pInfo->partitionSup.pGroupCols);
|
||||||
|
|
|
@ -1311,10 +1311,15 @@ static void calBlockTag(SExprSupp* pTagCalSup, SSDataBlock* pBlock, SSDataBlock*
|
||||||
|
|
||||||
blockDataEnsureCapacity(pResBlock, 1);
|
blockDataEnsureCapacity(pResBlock, 1);
|
||||||
|
|
||||||
projectApplyFunctions(pTagCalSup->pExprInfo, pResBlock, pSrcBlock, pTagCalSup->pCtx, 1, NULL);
|
projectApplyFunctions(pTagCalSup->pExprInfo, pResBlock, pSrcBlock, pTagCalSup->pCtx, pTagCalSup->numOfExprs, NULL);
|
||||||
ASSERT(pResBlock->info.rows == 1);
|
ASSERT(pResBlock->info.rows == 1);
|
||||||
|
|
||||||
// build tagArray
|
// build tagArray
|
||||||
|
/*SArray* tagArray = taosArrayInit(0, sizeof(void*));*/
|
||||||
|
/*STagVal tagVal = {*/
|
||||||
|
/*.cid = 0,*/
|
||||||
|
/*.type = 0,*/
|
||||||
|
/*};*/
|
||||||
// build STag
|
// build STag
|
||||||
// set STag
|
// set STag
|
||||||
|
|
||||||
|
@ -2110,6 +2115,9 @@ static void destroyStreamScanOperatorInfo(void* param) {
|
||||||
taosMemoryFree(pStreamScan->pPseudoExpr);
|
taosMemoryFree(pStreamScan->pPseudoExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanupExprSupp(&pStreamScan->tbnameCalSup);
|
||||||
|
cleanupExprSupp(&pStreamScan->tagCalSup);
|
||||||
|
|
||||||
updateInfoDestroy(pStreamScan->pUpdateInfo);
|
updateInfoDestroy(pStreamScan->pUpdateInfo);
|
||||||
blockDataDestroy(pStreamScan->pRes);
|
blockDataDestroy(pStreamScan->pRes);
|
||||||
blockDataDestroy(pStreamScan->pUpdateRes);
|
blockDataDestroy(pStreamScan->pUpdateRes);
|
||||||
|
@ -2164,6 +2172,19 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pTableScanNode->pTags != NULL) {
|
||||||
|
int32_t numOfTags;
|
||||||
|
SExprInfo* pTagExpr = createExprInfo(pTableScanNode->pTags, NULL, &numOfTags);
|
||||||
|
if (pTagExpr == NULL) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
if (initExprSupp(&pInfo->tagCalSup, pTagExpr, numOfTags) != 0) {
|
||||||
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pInfo->pBlockLists = taosArrayInit(4, POINTER_BYTES);
|
pInfo->pBlockLists = taosArrayInit(4, POINTER_BYTES);
|
||||||
if (pInfo->pBlockLists == NULL) {
|
if (pInfo->pBlockLists == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -131,7 +131,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
|
||||||
COPY_SCALAR_FIELD(placeholderNo);
|
COPY_SCALAR_FIELD(placeholderNo);
|
||||||
COPY_SCALAR_FIELD(typeData);
|
COPY_SCALAR_FIELD(typeData);
|
||||||
COPY_SCALAR_FIELD(unit);
|
COPY_SCALAR_FIELD(unit);
|
||||||
if (!pSrc->translate) {
|
if (!pSrc->translate || pSrc->isNull) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
switch (pSrc->node.resType.type) {
|
switch (pSrc->node.resType.type) {
|
||||||
|
|
|
@ -3011,7 +3011,7 @@ static int32_t valueNodeToJson(const void* pObj, SJson* pJson) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonAddBoolToObject(pJson, jkValueIsNull, pNode->isNull);
|
code = tjsonAddBoolToObject(pJson, jkValueIsNull, pNode->isNull);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && pNode->translate) {
|
if (TSDB_CODE_SUCCESS == code && pNode->translate && !pNode->isNull) {
|
||||||
code = datumToJson(pNode, pJson);
|
code = datumToJson(pNode, pJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3161,7 +3161,7 @@ static int32_t jsonToValueNode(const SJson* pJson, void* pObj) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = tjsonGetBoolValue(pJson, jkValueIsNull, &pNode->isNull);
|
code = tjsonGetBoolValue(pJson, jkValueIsNull, &pNode->isNull);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && pNode->translate) {
|
if (TSDB_CODE_SUCCESS == code && pNode->translate && !pNode->isNull) {
|
||||||
code = jsonToDatum(pJson, pNode);
|
code = jsonToDatum(pJson, pNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -478,7 +478,10 @@ static int32_t tlvDecodeValueEnum(STlvDecoder* pDecoder, void* pValue, int16_t l
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t tlvDecodeCStr(STlv* pTlv, char* pValue) {
|
static int32_t tlvDecodeCStr(STlv* pTlv, char* pValue, int32_t size) {
|
||||||
|
if (pTlv->len > size - 1) {
|
||||||
|
return TSDB_CODE_FAILED;
|
||||||
|
}
|
||||||
memcpy(pValue, pTlv->value, pTlv->len);
|
memcpy(pValue, pTlv->value, pTlv->len);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -919,9 +922,14 @@ static int32_t msgToDatum(STlv* pTlv, void* pObj) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_JSON:
|
case TSDB_DATA_TYPE_JSON: {
|
||||||
|
if (pTlv->len <= 0 || pTlv->len > TSDB_MAX_JSON_TAG_LEN) {
|
||||||
|
code = TSDB_CODE_FAILED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
code = tlvDecodeDynBinary(pTlv, (void**)&pNode->datum.p);
|
code = tlvDecodeDynBinary(pTlv, (void**)&pNode->datum.p);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case TSDB_DATA_TYPE_DECIMAL:
|
case TSDB_DATA_TYPE_DECIMAL:
|
||||||
case TSDB_DATA_TYPE_BLOB:
|
case TSDB_DATA_TYPE_BLOB:
|
||||||
// todo
|
// todo
|
||||||
|
@ -1097,7 +1105,7 @@ static int32_t msgToFunctionNode(STlvDecoder* pDecoder, void* pObj) {
|
||||||
code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
|
code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
|
||||||
break;
|
break;
|
||||||
case FUNCTION_CODE_FUNCTION_NAME:
|
case FUNCTION_CODE_FUNCTION_NAME:
|
||||||
code = tlvDecodeCStr(pTlv, pNode->functionName);
|
code = tlvDecodeCStr(pTlv, pNode->functionName, sizeof(pNode->functionName));
|
||||||
break;
|
break;
|
||||||
case FUNCTION_CODE_FUNCTION_ID:
|
case FUNCTION_CODE_FUNCTION_ID:
|
||||||
code = tlvDecodeI32(pTlv, &pNode->funcId);
|
code = tlvDecodeI32(pTlv, &pNode->funcId);
|
||||||
|
@ -1226,10 +1234,10 @@ static int32_t msgToName(STlvDecoder* pDecoder, void* pObj) {
|
||||||
code = tlvDecodeI32(pTlv, &pNode->acctId);
|
code = tlvDecodeI32(pTlv, &pNode->acctId);
|
||||||
break;
|
break;
|
||||||
case NAME_CODE_DB_NAME:
|
case NAME_CODE_DB_NAME:
|
||||||
code = tlvDecodeCStr(pTlv, pNode->dbname);
|
code = tlvDecodeCStr(pTlv, pNode->dbname, sizeof(pNode->dbname));
|
||||||
break;
|
break;
|
||||||
case NAME_CODE_TABLE_NAME:
|
case NAME_CODE_TABLE_NAME:
|
||||||
code = tlvDecodeCStr(pTlv, pNode->tname);
|
code = tlvDecodeCStr(pTlv, pNode->tname, sizeof(pNode->tname));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1538,7 +1546,7 @@ static int32_t msgToEp(STlvDecoder* pDecoder, void* pObj) {
|
||||||
tlvForEach(pDecoder, pTlv, code) {
|
tlvForEach(pDecoder, pTlv, code) {
|
||||||
switch (pTlv->type) {
|
switch (pTlv->type) {
|
||||||
case EP_CODE_FQDN:
|
case EP_CODE_FQDN:
|
||||||
code = tlvDecodeCStr(pTlv, pNode->fqdn);
|
code = tlvDecodeCStr(pTlv, pNode->fqdn, sizeof(pNode->fqdn));
|
||||||
break;
|
break;
|
||||||
case EP_CODE_port:
|
case EP_CODE_port:
|
||||||
code = tlvDecodeU16(pTlv, &pNode->port);
|
code = tlvDecodeU16(pTlv, &pNode->port);
|
||||||
|
@ -3207,7 +3215,7 @@ static int32_t msgToPhysiQueryInsertNode(STlvDecoder* pDecoder, void* pObj) {
|
||||||
code = tlvDecodeI8(pTlv, &pNode->tableType);
|
code = tlvDecodeI8(pTlv, &pNode->tableType);
|
||||||
break;
|
break;
|
||||||
case PHY_QUERY_INSERT_CODE_TABLE_NAME:
|
case PHY_QUERY_INSERT_CODE_TABLE_NAME:
|
||||||
code = tlvDecodeCStr(pTlv, pNode->tableName);
|
code = tlvDecodeCStr(pTlv, pNode->tableName, sizeof(pNode->tableName));
|
||||||
break;
|
break;
|
||||||
case PHY_QUERY_INSERT_CODE_VG_ID:
|
case PHY_QUERY_INSERT_CODE_VG_ID:
|
||||||
code = tlvDecodeI32(pTlv, &pNode->vgId);
|
code = tlvDecodeI32(pTlv, &pNode->vgId);
|
||||||
|
@ -3284,10 +3292,10 @@ static int32_t msgToPhysiDeleteNode(STlvDecoder* pDecoder, void* pObj) {
|
||||||
code = tlvDecodeI8(pTlv, &pNode->tableType);
|
code = tlvDecodeI8(pTlv, &pNode->tableType);
|
||||||
break;
|
break;
|
||||||
case PHY_DELETER_CODE_TABLE_FNAME:
|
case PHY_DELETER_CODE_TABLE_FNAME:
|
||||||
code = tlvDecodeCStr(pTlv, pNode->tableFName);
|
code = tlvDecodeCStr(pTlv, pNode->tableFName, sizeof(pNode->tableFName));
|
||||||
break;
|
break;
|
||||||
case PHY_DELETER_CODE_TS_COL_NAME:
|
case PHY_DELETER_CODE_TS_COL_NAME:
|
||||||
code = tlvDecodeCStr(pTlv, pNode->tsColName);
|
code = tlvDecodeCStr(pTlv, pNode->tsColName, sizeof(pNode->tsColName));
|
||||||
break;
|
break;
|
||||||
case PHY_DELETER_CODE_DELETE_TIME_RANGE:
|
case PHY_DELETER_CODE_DELETE_TIME_RANGE:
|
||||||
code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, &pNode->deleteTimeRange);
|
code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, &pNode->deleteTimeRange);
|
||||||
|
|
|
@ -209,6 +209,10 @@ int64_t nodesMakeAllocatorWeakRef(int64_t allocatorId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeAllocator* pAllocator = taosAcquireRef(g_allocatorReqRefPool, allocatorId);
|
SNodeAllocator* pAllocator = taosAcquireRef(g_allocatorReqRefPool, allocatorId);
|
||||||
|
if (NULL == pAllocator) {
|
||||||
|
nodesError("allocator id %" PRIx64 " weak reference failed", allocatorId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return pAllocator->self;
|
return pAllocator->self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1604,7 +1608,7 @@ char* nodesGetStrValueFromNode(SValueNode* pNode) {
|
||||||
bool nodesIsExprNode(const SNode* pNode) {
|
bool nodesIsExprNode(const SNode* pNode) {
|
||||||
ENodeType type = nodeType(pNode);
|
ENodeType type = nodeType(pNode);
|
||||||
return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type ||
|
return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type ||
|
||||||
QUERY_NODE_FUNCTION == type || QUERY_NODE_LOGIC_CONDITION == type);
|
QUERY_NODE_FUNCTION == type || QUERY_NODE_LOGIC_CONDITION == type || QUERY_NODE_CASE_WHEN == type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nodesIsUnaryOp(const SOperatorNode* pOp) {
|
bool nodesIsUnaryOp(const SOperatorNode* pOp) {
|
||||||
|
@ -1716,9 +1720,10 @@ static EDealRes doCollect(SCollectColumnsCxt* pCxt, SColumnNode* pCol, SNode* pN
|
||||||
char name[TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN];
|
char name[TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN];
|
||||||
int32_t len = 0;
|
int32_t len = 0;
|
||||||
if ('\0' == pCol->tableAlias[0]) {
|
if ('\0' == pCol->tableAlias[0]) {
|
||||||
len = sprintf(name, "%s", pCol->colName);
|
len = snprintf(name, sizeof(name), "%s", pCol->colName);
|
||||||
|
} else {
|
||||||
|
len = snprintf(name, sizeof(name), "%s.%s", pCol->tableAlias, pCol->colName);
|
||||||
}
|
}
|
||||||
len = sprintf(name, "%s.%s", pCol->tableAlias, pCol->colName);
|
|
||||||
if (NULL == taosHashGet(pCxt->pColHash, name, len)) {
|
if (NULL == taosHashGet(pCxt->pColHash, name, len)) {
|
||||||
pCxt->errCode = taosHashPut(pCxt->pColHash, name, len, NULL, 0);
|
pCxt->errCode = taosHashPut(pCxt->pColHash, name, len, NULL, 0);
|
||||||
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
if (TSDB_CODE_SUCCESS == pCxt->errCode) {
|
||||||
|
|
|
@ -175,8 +175,6 @@ _end:
|
||||||
|
|
||||||
void taosCleanupKeywordsTable();
|
void taosCleanupKeywordsTable();
|
||||||
|
|
||||||
SToken tscReplaceStrToken(char **str, SToken *token, const char *newToken);
|
|
||||||
|
|
||||||
SToken taosTokenDup(SToken *pToken, char *buf, int32_t len);
|
SToken taosTokenDup(SToken *pToken, char *buf, int32_t len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -518,7 +518,7 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTa
|
||||||
if (NULL != pDbName) {
|
if (NULL != pDbName) {
|
||||||
COPY_STRING_FORM_ID_TOKEN(realTable->table.dbName, pDbName);
|
COPY_STRING_FORM_ID_TOKEN(realTable->table.dbName, pDbName);
|
||||||
} else {
|
} else {
|
||||||
strcpy(realTable->table.dbName, pCxt->pQueryCxt->db);
|
snprintf(realTable->table.dbName, sizeof(realTable->table.dbName), "%s", pCxt->pQueryCxt->db);
|
||||||
}
|
}
|
||||||
if (NULL != pTableAlias && TK_NK_NIL != pTableAlias->type) {
|
if (NULL != pTableAlias && TK_NK_NIL != pTableAlias->type) {
|
||||||
COPY_STRING_FORM_ID_TOKEN(realTable->table.tableAlias, pTableAlias);
|
COPY_STRING_FORM_ID_TOKEN(realTable->table.tableAlias, pTableAlias);
|
||||||
|
@ -599,7 +599,7 @@ SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) {
|
||||||
state->pCol = createPrimaryKeyCol(pCxt, NULL);
|
state->pCol = createPrimaryKeyCol(pCxt, NULL);
|
||||||
if (NULL == state->pCol) {
|
if (NULL == state->pCol) {
|
||||||
nodesDestroyNode((SNode*)state);
|
nodesDestroyNode((SNode*)state);
|
||||||
CHECK_OUT_OF_MEM(state->pCol);
|
CHECK_OUT_OF_MEM(NULL);
|
||||||
}
|
}
|
||||||
state->pExpr = pExpr;
|
state->pExpr = pExpr;
|
||||||
return (SNode*)state;
|
return (SNode*)state;
|
||||||
|
@ -613,7 +613,7 @@ SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode
|
||||||
interval->pCol = createPrimaryKeyCol(pCxt, NULL);
|
interval->pCol = createPrimaryKeyCol(pCxt, NULL);
|
||||||
if (NULL == interval->pCol) {
|
if (NULL == interval->pCol) {
|
||||||
nodesDestroyNode((SNode*)interval);
|
nodesDestroyNode((SNode*)interval);
|
||||||
CHECK_OUT_OF_MEM(interval->pCol);
|
CHECK_OUT_OF_MEM(NULL);
|
||||||
}
|
}
|
||||||
interval->pInterval = pInterval;
|
interval->pInterval = pInterval;
|
||||||
interval->pOffset = pOffset;
|
interval->pOffset = pOffset;
|
||||||
|
@ -631,7 +631,7 @@ SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) {
|
||||||
fill->pWStartTs = nodesMakeNode(QUERY_NODE_FUNCTION);
|
fill->pWStartTs = nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
if (NULL == fill->pWStartTs) {
|
if (NULL == fill->pWStartTs) {
|
||||||
nodesDestroyNode((SNode*)fill);
|
nodesDestroyNode((SNode*)fill);
|
||||||
CHECK_OUT_OF_MEM(fill->pWStartTs);
|
CHECK_OUT_OF_MEM(NULL);
|
||||||
}
|
}
|
||||||
strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstart");
|
strcpy(((SFunctionNode*)fill->pWStartTs)->functionName, "_wstart");
|
||||||
return (SNode*)fill;
|
return (SNode*)fill;
|
||||||
|
@ -1495,10 +1495,10 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->indexType = type;
|
pStmt->indexType = type;
|
||||||
pStmt->ignoreExists = ignoreExists;
|
pStmt->ignoreExists = ignoreExists;
|
||||||
strcpy(pStmt->indexDbName, ((SRealTableNode*)pIndexName)->table.dbName);
|
snprintf(pStmt->indexDbName, sizeof(pStmt->indexDbName), "%s", ((SRealTableNode*)pIndexName)->table.dbName);
|
||||||
strcpy(pStmt->indexName, ((SRealTableNode*)pIndexName)->table.tableName);
|
snprintf(pStmt->indexName, sizeof(pStmt->indexName), "%s", ((SRealTableNode*)pIndexName)->table.tableName);
|
||||||
strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName);
|
snprintf(pStmt->dbName, sizeof(pStmt->dbName), "%s", ((SRealTableNode*)pRealTable)->table.dbName);
|
||||||
strcpy(pStmt->tableName, ((SRealTableNode*)pRealTable)->table.tableName);
|
snprintf(pStmt->tableName, sizeof(pStmt->tableName), "%s", ((SRealTableNode*)pRealTable)->table.tableName);
|
||||||
nodesDestroyNode(pIndexName);
|
nodesDestroyNode(pIndexName);
|
||||||
nodesDestroyNode(pRealTable);
|
nodesDestroyNode(pRealTable);
|
||||||
pStmt->pCols = pCols;
|
pStmt->pCols = pCols;
|
||||||
|
@ -1524,8 +1524,8 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode*
|
||||||
SDropIndexStmt* pStmt = (SDropIndexStmt*)nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT);
|
SDropIndexStmt* pStmt = (SDropIndexStmt*)nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT);
|
||||||
CHECK_OUT_OF_MEM(pStmt);
|
CHECK_OUT_OF_MEM(pStmt);
|
||||||
pStmt->ignoreNotExists = ignoreNotExists;
|
pStmt->ignoreNotExists = ignoreNotExists;
|
||||||
strcpy(pStmt->indexDbName, ((SRealTableNode*)pIndexName)->table.dbName);
|
snprintf(pStmt->indexDbName, sizeof(pStmt->indexDbName), "%s", ((SRealTableNode*)pIndexName)->table.dbName);
|
||||||
strcpy(pStmt->indexName, ((SRealTableNode*)pIndexName)->table.tableName);
|
snprintf(pStmt->indexName, sizeof(pStmt->indexName), "%s", ((SRealTableNode*)pIndexName)->table.tableName);
|
||||||
nodesDestroyNode(pIndexName);
|
nodesDestroyNode(pIndexName);
|
||||||
return (SNode*)pStmt;
|
return (SNode*)pStmt;
|
||||||
}
|
}
|
||||||
|
@ -1818,7 +1818,7 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb
|
||||||
SNode* createFuncForDelete(SAstCreateContext* pCxt, const char* pFuncName) {
|
SNode* createFuncForDelete(SAstCreateContext* pCxt, const char* pFuncName) {
|
||||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||||
CHECK_OUT_OF_MEM(pFunc);
|
CHECK_OUT_OF_MEM(pFunc);
|
||||||
strcpy(pFunc->functionName, pFuncName);
|
snprintf(pFunc->functionName, sizeof(pFunc->functionName), "%s", pFuncName);
|
||||||
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pFunc->pParameterList, createPrimaryKeyCol(pCxt, NULL))) {
|
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pFunc->pParameterList, createPrimaryKeyCol(pCxt, NULL))) {
|
||||||
nodesDestroyNode((SNode*)pFunc);
|
nodesDestroyNode((SNode*)pFunc);
|
||||||
CHECK_OUT_OF_MEM(NULL);
|
CHECK_OUT_OF_MEM(NULL);
|
||||||
|
|
|
@ -378,7 +378,9 @@ static int parseTime(char** end, SToken* pToken, int16_t timePrec, int64_t* time
|
||||||
} else if (pToken->type == TK_TODAY) {
|
} else if (pToken->type == TK_TODAY) {
|
||||||
ts = taosGetTimestampToday(timePrec);
|
ts = taosGetTimestampToday(timePrec);
|
||||||
} else if (pToken->type == TK_NK_INTEGER) {
|
} else if (pToken->type == TK_NK_INTEGER) {
|
||||||
toInteger(pToken->z, pToken->n, 10, &ts);
|
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &ts)) {
|
||||||
|
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
|
||||||
|
}
|
||||||
} else { // parse the RFC-3339/ISO-8601 timestamp format string
|
} else { // parse the RFC-3339/ISO-8601 timestamp format string
|
||||||
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
|
if (taosParseTime(pToken->z, time, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z);
|
||||||
|
@ -591,8 +593,6 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
|
||||||
case TSDB_DATA_TYPE_BIGINT: {
|
case TSDB_DATA_TYPE_BIGINT: {
|
||||||
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv)) {
|
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid bigint data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid bigint data", pToken->z);
|
||||||
} else if (!IS_VALID_BIGINT(iv)) {
|
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "bigint data overflow", pToken->z);
|
|
||||||
}
|
}
|
||||||
return func(pMsgBuf, &iv, pSchema->bytes, param);
|
return func(pMsgBuf, &iv, pSchema->bytes, param);
|
||||||
}
|
}
|
||||||
|
@ -894,10 +894,7 @@ static int32_t parseTagToken(char** end, SToken* pToken, SSchema* pSchema, int16
|
||||||
case TSDB_DATA_TYPE_BIGINT: {
|
case TSDB_DATA_TYPE_BIGINT: {
|
||||||
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv)) {
|
if (TSDB_CODE_SUCCESS != toInteger(pToken->z, pToken->n, 10, &iv)) {
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "invalid bigint data", pToken->z);
|
return buildSyntaxErrMsg(pMsgBuf, "invalid bigint data", pToken->z);
|
||||||
} else if (!IS_VALID_BIGINT(iv)) {
|
|
||||||
return buildSyntaxErrMsg(pMsgBuf, "bigint data overflow", pToken->z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val->i64 = iv;
|
val->i64 = iv;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1173,7 +1170,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, int32_t tbNo, SName*
|
||||||
NEXT_TOKEN(pCxt->pSql, sToken);
|
NEXT_TOKEN(pCxt->pSql, sToken);
|
||||||
|
|
||||||
SName sname;
|
SName sname;
|
||||||
createSName(&sname, &sToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg);
|
CHECK_CODE(createSName(&sname, &sToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg));
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
tNameGetFullDbName(&sname, dbFName);
|
tNameGetFullDbName(&sname, dbFName);
|
||||||
strcpy(pCxt->sTableName, sname.tname);
|
strcpy(pCxt->sTableName, sname.tname);
|
||||||
|
@ -1605,7 +1602,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
if (!pCxt->pComCxt->needMultiParse) {
|
if (!pCxt->pComCxt->needMultiParse) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
parserInfo("0x%" PRIx64 " insert from csv. File is too large, do it in batches.", pCxt->pComCxt->requestId);
|
parserDebug("0x%" PRIx64 " insert from csv. File is too large, do it in batches.", pCxt->pComCxt->requestId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1613,7 +1610,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
|
||||||
return buildSyntaxErrMsg(&pCxt->msg, "keyword VALUES or FILE is expected", sToken.z);
|
return buildSyntaxErrMsg(&pCxt->msg, "keyword VALUES or FILE is expected", sToken.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
parserInfo("0x%" PRIx64 " insert input rows: %d", pCxt->pComCxt->requestId, pCxt->totalNum);
|
parserDebug("0x%" PRIx64 " insert input rows: %d", pCxt->pComCxt->requestId, pCxt->totalNum);
|
||||||
|
|
||||||
if (TSDB_QUERY_HAS_TYPE(pCxt->pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT)) {
|
if (TSDB_QUERY_HAS_TYPE(pCxt->pOutput->insertType, TSDB_QUERY_TYPE_STMT_INSERT)) {
|
||||||
SParsedDataColInfo* tags = taosMemoryMalloc(sizeof(pCxt->tags));
|
SParsedDataColInfo* tags = taosMemoryMalloc(sizeof(pCxt->tags));
|
||||||
|
@ -1650,7 +1647,7 @@ static int32_t parseInsertBodyAgain(SInsertParseContext* pCxt) {
|
||||||
pCxt->pComCxt->needMultiParse = false;
|
pCxt->pComCxt->needMultiParse = false;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
parserInfo("0x%" PRIx64 " insert again input rows: %d", pCxt->pComCxt->requestId, pCxt->totalNum);
|
parserDebug("0x%" PRIx64 " insert again input rows: %d", pCxt->pComCxt->requestId, pCxt->totalNum);
|
||||||
// merge according to vgId
|
// merge according to vgId
|
||||||
if (taosHashGetSize(pCxt->pTableBlockHashObj) > 0) {
|
if (taosHashGetSize(pCxt->pTableBlockHashObj) > 0) {
|
||||||
CHECK_CODE(mergeTableDataBlocks(pCxt->pTableBlockHashObj, pCxt->pOutput->payloadType, &pCxt->pVgDataBlocks));
|
CHECK_CODE(mergeTableDataBlocks(pCxt->pTableBlockHashObj, pCxt->pOutput->payloadType, &pCxt->pVgDataBlocks));
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
// clang-format off
|
|
||||||
#include "parInsertData.h"
|
#include "parInsertData.h"
|
||||||
|
|
||||||
#include "catalog.h"
|
#include "catalog.h"
|
||||||
|
@ -25,8 +25,8 @@
|
||||||
(((int)(t)) == PAYLOAD_TYPE_RAW) // 0: K-V payload for non-prepare insert, 1: rawPayload for prepare insert
|
(((int)(t)) == PAYLOAD_TYPE_RAW) // 0: K-V payload for non-prepare insert, 1: rawPayload for prepare insert
|
||||||
|
|
||||||
typedef struct SBlockKeyTuple {
|
typedef struct SBlockKeyTuple {
|
||||||
TSKEY skey;
|
TSKEY skey;
|
||||||
void* payloadAddr;
|
void* payloadAddr;
|
||||||
int16_t index;
|
int16_t index;
|
||||||
} SBlockKeyTuple;
|
} SBlockKeyTuple;
|
||||||
|
|
||||||
|
@ -194,8 +194,8 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star
|
||||||
|
|
||||||
int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq) {
|
int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq) {
|
||||||
SEncoder coder = {0};
|
SEncoder coder = {0};
|
||||||
char* pBuf;
|
char* pBuf;
|
||||||
int32_t len;
|
int32_t len;
|
||||||
|
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
tEncodeSize(tEncodeSVCreateTbReq, pCreateTbReq, len, ret);
|
tEncodeSize(tEncodeSVCreateTbReq, pCreateTbReq, len, ret);
|
||||||
|
@ -211,19 +211,19 @@ int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pBuf= pBlocks->pData + pBlocks->size;
|
pBuf = pBlocks->pData + pBlocks->size;
|
||||||
|
|
||||||
tEncoderInit(&coder, pBuf, len);
|
tEncoderInit(&coder, pBuf, len);
|
||||||
tEncodeSVCreateTbReq(&coder, pCreateTbReq);
|
int32_t code = tEncodeSVCreateTbReq(&coder, pCreateTbReq);
|
||||||
tEncoderClear(&coder);
|
tEncoderClear(&coder);
|
||||||
|
|
||||||
pBlocks->size += len;
|
pBlocks->size += len;
|
||||||
pBlocks->createTbReqLen = len;
|
pBlocks->createTbReqLen = len;
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, int32_t size, int32_t startOffset, int32_t rowSize,
|
int32_t getDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, int32_t size, int32_t startOffset,
|
||||||
STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList,
|
int32_t rowSize, STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList,
|
||||||
SVCreateTbReq* pCreateTbReq) {
|
SVCreateTbReq* pCreateTbReq) {
|
||||||
*dataBlocks = NULL;
|
*dataBlocks = NULL;
|
||||||
STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pHashList, (const char*)id, idLen);
|
STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pHashList, (const char*)id, idLen);
|
||||||
|
@ -272,12 +272,12 @@ static void destroyDataBlock(STableDataBlocks* pDataBlock) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosMemoryFreeClear(pDataBlock->pData);
|
taosMemoryFreeClear(pDataBlock->pData);
|
||||||
// if (!pDataBlock->cloned) {
|
// if (!pDataBlock->cloned) {
|
||||||
// free the refcount for metermeta
|
// free the refcount for metermeta
|
||||||
taosMemoryFreeClear(pDataBlock->pTableMeta);
|
taosMemoryFreeClear(pDataBlock->pTableMeta);
|
||||||
|
|
||||||
destroyBoundColumnInfo(&pDataBlock->boundColumnInfo);
|
destroyBoundColumnInfo(&pDataBlock->boundColumnInfo);
|
||||||
// }
|
// }
|
||||||
taosMemoryFreeClear(pDataBlock);
|
taosMemoryFreeClear(pDataBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,16 +687,16 @@ int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** p
|
||||||
STableDataBlocks** p = taosHashIterate(pHashObj, NULL);
|
STableDataBlocks** p = taosHashIterate(pHashObj, NULL);
|
||||||
STableDataBlocks* pOneTableBlock = *p;
|
STableDataBlocks* pOneTableBlock = *p;
|
||||||
SBlockKeyInfo blkKeyInfo = {0}; // share by pOneTableBlock
|
SBlockKeyInfo blkKeyInfo = {0}; // share by pOneTableBlock
|
||||||
SBlockRowMerger *pBlkRowMerger = NULL;
|
SBlockRowMerger* pBlkRowMerger = NULL;
|
||||||
|
|
||||||
while (pOneTableBlock) {
|
while (pOneTableBlock) {
|
||||||
SSubmitBlk* pBlocks = (SSubmitBlk*)pOneTableBlock->pData;
|
SSubmitBlk* pBlocks = (SSubmitBlk*)pOneTableBlock->pData;
|
||||||
if (pBlocks->numOfRows > 0) {
|
if (pBlocks->numOfRows > 0) {
|
||||||
STableDataBlocks* dataBuf = NULL;
|
STableDataBlocks* dataBuf = NULL;
|
||||||
pOneTableBlock->pTableMeta->vgId = pOneTableBlock->vgId; // for schemaless, restore origin vgId
|
pOneTableBlock->pTableMeta->vgId = pOneTableBlock->vgId; // for schemaless, restore origin vgId
|
||||||
int32_t ret =
|
int32_t ret = getDataBlockFromList(pVnodeDataBlockHashList, &pOneTableBlock->vgId, sizeof(pOneTableBlock->vgId),
|
||||||
getDataBlockFromList(pVnodeDataBlockHashList, &pOneTableBlock->vgId, sizeof(pOneTableBlock->vgId), TSDB_PAYLOAD_SIZE, INSERT_HEAD_SIZE, 0,
|
TSDB_PAYLOAD_SIZE, INSERT_HEAD_SIZE, 0, pOneTableBlock->pTableMeta, &dataBuf,
|
||||||
pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList, NULL);
|
pVnodeDataBlockList, NULL);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
tdFreeSBlockRowMerger(pBlkRowMerger);
|
tdFreeSBlockRowMerger(pBlkRowMerger);
|
||||||
taosHashCleanup(pVnodeDataBlockHashList);
|
taosHashCleanup(pVnodeDataBlockHashList);
|
||||||
|
@ -708,7 +708,8 @@ int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** p
|
||||||
// the maximum expanded size in byte when a row-wise data is converted to SDataRow format
|
// the maximum expanded size in byte when a row-wise data is converted to SDataRow format
|
||||||
int32_t expandSize = isRawPayload ? getRowExpandSize(pOneTableBlock->pTableMeta) : 0;
|
int32_t expandSize = isRawPayload ? getRowExpandSize(pOneTableBlock->pTableMeta) : 0;
|
||||||
int64_t destSize = dataBuf->size + pOneTableBlock->size + pBlocks->numOfRows * expandSize +
|
int64_t destSize = dataBuf->size + pOneTableBlock->size + pBlocks->numOfRows * expandSize +
|
||||||
sizeof(STColumn) * getNumOfColumns(pOneTableBlock->pTableMeta) + pOneTableBlock->createTbReqLen;
|
sizeof(STColumn) * getNumOfColumns(pOneTableBlock->pTableMeta) +
|
||||||
|
pOneTableBlock->createTbReqLen;
|
||||||
|
|
||||||
if (dataBuf->nAllocSize < destSize) {
|
if (dataBuf->nAllocSize < destSize) {
|
||||||
dataBuf->nAllocSize = (uint32_t)(destSize * 1.5);
|
dataBuf->nAllocSize = (uint32_t)(destSize * 1.5);
|
||||||
|
@ -861,7 +862,7 @@ int32_t qCloneStmtDataBlock(void** pDst, void* pSrc) {
|
||||||
|
|
||||||
STableDataBlocks* pBlock = (STableDataBlocks*)(*pDst);
|
STableDataBlocks* pBlock = (STableDataBlocks*)(*pDst);
|
||||||
if (pBlock->pTableMeta) {
|
if (pBlock->pTableMeta) {
|
||||||
void *pNewMeta = taosMemoryMalloc(TABLE_META_SIZE(pBlock->pTableMeta));
|
void* pNewMeta = taosMemoryMalloc(TABLE_META_SIZE(pBlock->pTableMeta));
|
||||||
if (NULL == pNewMeta) {
|
if (NULL == pNewMeta) {
|
||||||
taosMemoryFreeClear(*pDst);
|
taosMemoryFreeClear(*pDst);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -898,9 +899,7 @@ int32_t qRebuildStmtDataBlock(void** pDst, void* pSrc, uint64_t uid, int32_t vgI
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMeta *qGetTableMetaInDataBlock(void* pDataBlock) {
|
STableMeta* qGetTableMetaInDataBlock(void* pDataBlock) { return ((STableDataBlocks*)pDataBlock)->pTableMeta; }
|
||||||
return ((STableDataBlocks*)pDataBlock)->pTableMeta;
|
|
||||||
}
|
|
||||||
|
|
||||||
void qFreeStmtDataBlock(void* pDataBlock) {
|
void qFreeStmtDataBlock(void* pDataBlock) {
|
||||||
if (pDataBlock == NULL) {
|
if (pDataBlock == NULL) {
|
||||||
|
|
|
@ -613,27 +613,6 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SToken tscReplaceStrToken(char** str, SToken* token, const char* newToken) {
|
|
||||||
char* src = *str;
|
|
||||||
size_t nsize = strlen(newToken);
|
|
||||||
int32_t size = (int32_t)strlen(*str) - token->n + (int32_t)nsize + 1;
|
|
||||||
int32_t bsize = (int32_t)((uint64_t)token->z - (uint64_t)src);
|
|
||||||
SToken ntoken;
|
|
||||||
|
|
||||||
*str = taosMemoryCalloc(1, size);
|
|
||||||
|
|
||||||
strncpy(*str, src, bsize);
|
|
||||||
strcat(*str, newToken);
|
|
||||||
strcat(*str, token->z + token->n);
|
|
||||||
|
|
||||||
ntoken.n = (uint32_t)nsize;
|
|
||||||
ntoken.z = *str + bsize;
|
|
||||||
|
|
||||||
taosMemoryFreeClear(src);
|
|
||||||
|
|
||||||
return ntoken;
|
|
||||||
}
|
|
||||||
|
|
||||||
SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) {
|
SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr) {
|
||||||
SToken t0 = {0};
|
SToken t0 = {0};
|
||||||
|
|
||||||
|
|
|
@ -292,9 +292,13 @@ static int32_t addNamespace(STranslateContext* pCxt, void* pTable) {
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
SArray* pTables = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES);
|
SArray* pTables = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES);
|
||||||
|
if (NULL == pTables) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
if (pCxt->currLevel == currTotalLevel) {
|
if (pCxt->currLevel == currTotalLevel) {
|
||||||
taosArrayPush(pTables, &pTable);
|
taosArrayPush(pTables, &pTable);
|
||||||
if (hasSameTableAlias(pTables)) {
|
if (hasSameTableAlias(pTables)) {
|
||||||
|
taosArrayDestroy(pTables);
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS,
|
||||||
"Not unique table/alias: '%s'", ((STableNode*)pTable)->tableAlias);
|
"Not unique table/alias: '%s'", ((STableNode*)pTable)->tableAlias);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +312,7 @@ static int32_t addNamespace(STranslateContext* pCxt, void* pTable) {
|
||||||
|
|
||||||
static int32_t collectUseDatabaseImpl(const char* pFullDbName, SHashObj* pDbs) {
|
static int32_t collectUseDatabaseImpl(const char* pFullDbName, SHashObj* pDbs) {
|
||||||
SFullDatabaseName name = {0};
|
SFullDatabaseName name = {0};
|
||||||
strcpy(name.fullDbName, pFullDbName);
|
snprintf(name.fullDbName, sizeof(name.fullDbName), "%s", pFullDbName);
|
||||||
return taosHashPut(pDbs, pFullDbName, strlen(pFullDbName), &name, sizeof(SFullDatabaseName));
|
return taosHashPut(pDbs, pFullDbName, strlen(pFullDbName), &name, sizeof(SFullDatabaseName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,15 +544,17 @@ static int32_t getTableIndex(STranslateContext* pCxt, const SName* pName, SArray
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = collectUseTable(pName, pCxt->pTables);
|
code = collectUseTable(pName, pCxt->pTables);
|
||||||
}
|
}
|
||||||
if (pParCxt->async) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = getTableIndexFromCache(pCxt->pMetaCache, pName, pIndexes);
|
if (pParCxt->async) {
|
||||||
} else {
|
code = getTableIndexFromCache(pCxt->pMetaCache, pName, pIndexes);
|
||||||
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
} else {
|
||||||
.requestId = pParCxt->requestId,
|
SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter,
|
||||||
.requestObjRefId = pParCxt->requestRid,
|
.requestId = pParCxt->requestId,
|
||||||
.mgmtEps = pParCxt->mgmtEpSet};
|
.requestObjRefId = pParCxt->requestRid,
|
||||||
|
.mgmtEps = pParCxt->mgmtEpSet};
|
||||||
|
|
||||||
code = catalogGetTableIndex(pParCxt->pCatalog, &conn, pName, pIndexes);
|
code = catalogGetTableIndex(pParCxt->pCatalog, &conn, pName, pIndexes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
parserError("0x%" PRIx64 " getTableIndex error, code:%s, dbName:%s, tbName:%s", pCxt->pParseCxt->requestId,
|
parserError("0x%" PRIx64 " getTableIndex error, code:%s, dbName:%s, tbName:%s", pCxt->pParseCxt->requestId,
|
||||||
|
@ -990,9 +996,9 @@ static int32_t parseTimeFromValueNode(STranslateContext* pCxt, SValueNode* pVal)
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
if (IS_UNSIGNED_NUMERIC_TYPE(pVal->node.resType.type)) {
|
if (IS_UNSIGNED_NUMERIC_TYPE(pVal->node.resType.type)) {
|
||||||
pVal->datum.i = pVal->datum.u;
|
pVal->datum.i = (int64_t)pVal->datum.u;
|
||||||
} else if (IS_FLOAT_TYPE(pVal->node.resType.type)) {
|
} else if (IS_FLOAT_TYPE(pVal->node.resType.type)) {
|
||||||
pVal->datum.i = pVal->datum.d;
|
pVal->datum.i = (int64_t)pVal->datum.d;
|
||||||
} else if (TSDB_DATA_TYPE_BOOL == pVal->node.resType.type) {
|
} else if (TSDB_DATA_TYPE_BOOL == pVal->node.resType.type) {
|
||||||
pVal->datum.i = pVal->datum.b;
|
pVal->datum.i = pVal->datum.b;
|
||||||
}
|
}
|
||||||
|
@ -1069,7 +1075,7 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_BIGINT: {
|
case TSDB_DATA_TYPE_BIGINT: {
|
||||||
code = toInteger(pVal->literal, strlen(pVal->literal), 10, &pVal->datum.i);
|
code = toInteger(pVal->literal, strlen(pVal->literal), 10, &pVal->datum.i);
|
||||||
if (strict && (TSDB_CODE_SUCCESS != code || !IS_VALID_BIGINT(pVal->datum.i))) {
|
if (strict && TSDB_CODE_SUCCESS != code) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
}
|
}
|
||||||
*(int64_t*)&pVal->typeData = pVal->datum.i;
|
*(int64_t*)&pVal->typeData = pVal->datum.i;
|
||||||
|
@ -1888,6 +1894,7 @@ static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseW
|
||||||
pWhenThen->pWhen = pIsTrue;
|
pWhenThen->pWhen = pIsTrue;
|
||||||
}
|
}
|
||||||
if (first) {
|
if (first) {
|
||||||
|
first = false;
|
||||||
pCaseWhen->node.resType = ((SExprNode*)pNode)->resType;
|
pCaseWhen->node.resType = ((SExprNode*)pNode)->resType;
|
||||||
} else if (!dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType)) {
|
} else if (!dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType)) {
|
||||||
SNode* pCastFunc = NULL;
|
SNode* pCastFunc = NULL;
|
||||||
|
@ -3429,10 +3436,10 @@ static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pCol->node.resType = ((SExprNode*)pNode)->resType;
|
pCol->node.resType = ((SExprNode*)pNode)->resType;
|
||||||
strcpy(pCol->tableAlias, pTableAlias);
|
snprintf(pCol->tableAlias, sizeof(pCol->tableAlias), "%s", pTableAlias);
|
||||||
strcpy(pCol->colName, ((SExprNode*)pNode)->aliasName);
|
snprintf(pCol->colName, sizeof(pCol->colName), "%s", ((SExprNode*)pNode)->aliasName);
|
||||||
strcpy(pCol->node.aliasName, pCol->colName);
|
snprintf(pCol->node.aliasName, sizeof(pCol->node.aliasName), "%s", pCol->colName);
|
||||||
strcpy(pCol->node.userAlias, ((SExprNode*)pNode)->userAlias);
|
snprintf(pCol->node.userAlias, sizeof(pCol->node.userAlias), "%s", ((SExprNode*)pNode)->userAlias);
|
||||||
return (SNode*)pCol;
|
return (SNode*)pCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3739,8 +3746,8 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
|
||||||
static int32_t checkRangeOption(STranslateContext* pCxt, int32_t code, const char* pName, int32_t val, int32_t minVal,
|
static int32_t checkRangeOption(STranslateContext* pCxt, int32_t code, const char* pName, int32_t val, int32_t minVal,
|
||||||
int32_t maxVal) {
|
int32_t maxVal) {
|
||||||
if (val >= 0 && (val < minVal || val > maxVal)) {
|
if (val >= 0 && (val < minVal || val > maxVal)) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "Invalid option %s: %" PRId64 " valid range: [%d, %d]", pName,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, code, "Invalid option %s: %d valid range: [%d, %d]", pName, val,
|
||||||
val, minVal, maxVal);
|
minVal, maxVal);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -3877,7 +3884,7 @@ static int32_t checkDbStrictOption(STranslateContext* pCxt, SDatabaseOptions* pO
|
||||||
static int32_t checkDbEnumOption(STranslateContext* pCxt, const char* pName, int32_t val, int32_t v1, int32_t v2) {
|
static int32_t checkDbEnumOption(STranslateContext* pCxt, const char* pName, int32_t val, int32_t v1, int32_t v2) {
|
||||||
if (val >= 0 && val != v1 && val != v2) {
|
if (val >= 0 && val != v1 && val != v2) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION,
|
||||||
"Invalid option %s: %" PRId64 ", only %d, %d allowed", pName, val, v1, v2);
|
"Invalid option %s: %d, only %d, %d allowed", pName, val, v1, v2);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -4462,8 +4469,8 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch
|
||||||
nodesDestroyNode((SNode*)pSelect);
|
nodesDestroyNode((SNode*)pSelect);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strcpy(pTable->table.dbName, pInfo->pDbName);
|
snprintf(pTable->table.dbName, sizeof(pTable->table.dbName), "%s", pInfo->pDbName);
|
||||||
strcpy(pTable->table.tableName, pInfo->pTableName);
|
snprintf(pTable->table.tableName, sizeof(pTable->table.tableName), "%s", pInfo->pTableName);
|
||||||
TSWAP(pTable->pMeta, pInfo->pRollupTableMeta);
|
TSWAP(pTable->pMeta, pInfo->pRollupTableMeta);
|
||||||
pSelect->pFromTable = (SNode*)pTable;
|
pSelect->pFromTable = (SNode*)pTable;
|
||||||
|
|
||||||
|
@ -4939,9 +4946,9 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt
|
||||||
alterReq.superUser = 0;
|
alterReq.superUser = 0;
|
||||||
alterReq.enable = pStmt->enable;
|
alterReq.enable = pStmt->enable;
|
||||||
alterReq.sysInfo = pStmt->sysinfo;
|
alterReq.sysInfo = pStmt->sysinfo;
|
||||||
strcpy(alterReq.pass, pStmt->password);
|
snprintf(alterReq.pass, sizeof(alterReq.pass), "%s", pStmt->password);
|
||||||
if (NULL != pCxt->pParseCxt->db) {
|
if (NULL != pCxt->pParseCxt->db) {
|
||||||
strcpy(alterReq.dbname, pCxt->pParseCxt->db);
|
snprintf(alterReq.dbname, sizeof(alterReq.dbname), "%s", pCxt->pParseCxt->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &alterReq);
|
return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &alterReq);
|
||||||
|
@ -6048,7 +6055,7 @@ static SNode* createProjectCol(const char* pProjCol) {
|
||||||
if (NULL == pCol) {
|
if (NULL == pCol) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(pCol->colName, pProjCol);
|
snprintf(pCol->colName, sizeof(pCol->colName), "%s", pProjCol);
|
||||||
return (SNode*)pCol;
|
return (SNode*)pCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6081,9 +6088,9 @@ static int32_t createSimpleSelectStmt(const char* pDb, const char* pTable, int32
|
||||||
nodesDestroyNode((SNode*)pSelect);
|
nodesDestroyNode((SNode*)pSelect);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strcpy(pRealTable->table.dbName, pDb);
|
snprintf(pRealTable->table.dbName, sizeof(pRealTable->table.dbName), "%s", pDb);
|
||||||
strcpy(pRealTable->table.tableName, pTable);
|
snprintf(pRealTable->table.tableName, sizeof(pRealTable->table.tableName), "%s", pTable);
|
||||||
strcpy(pRealTable->table.tableAlias, pTable);
|
snprintf(pRealTable->table.tableAlias, sizeof(pRealTable->table.tableAlias), "%s", pTable);
|
||||||
pSelect->pFromTable = (SNode*)pRealTable;
|
pSelect->pFromTable = (SNode*)pRealTable;
|
||||||
|
|
||||||
if (numOfProjs >= 0) {
|
if (numOfProjs >= 0) {
|
||||||
|
@ -7124,8 +7131,9 @@ static int32_t buildUpdateOptionsReq(STranslateContext* pCxt, SAlterTableStmt* p
|
||||||
pReq->newComment = strdup(pStmt->pOptions->comment);
|
pReq->newComment = strdup(pStmt->pOptions->comment);
|
||||||
if (NULL == pReq->newComment) {
|
if (NULL == pReq->newComment) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
} else {
|
||||||
|
pReq->newCommentLen = strlen(pReq->newComment);
|
||||||
}
|
}
|
||||||
pReq->newCommentLen = strlen(pReq->newComment);
|
|
||||||
} else {
|
} else {
|
||||||
pReq->newCommentLen = -1;
|
pReq->newCommentLen = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,6 +381,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
|
||||||
uError("charset:%s to %s. val:%s, errno:%s, convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, jsonValue,
|
uError("charset:%s to %s. val:%s, errno:%s, convert failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, jsonValue,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
retCode = buildSyntaxErrMsg(pMsgBuf, "charset convert json error", jsonValue);
|
retCode = buildSyntaxErrMsg(pMsgBuf, "charset convert json error", jsonValue);
|
||||||
|
taosMemoryFree(tmp);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
val.nData = valLen;
|
val.nData = valLen;
|
||||||
|
@ -652,8 +653,8 @@ static int32_t buildCatalogReqForInsert(SParseContext* pCxt, const SParseMetaCac
|
||||||
}
|
}
|
||||||
|
|
||||||
SUserAuthInfo auth = {0};
|
SUserAuthInfo auth = {0};
|
||||||
strcpy(auth.user, pCxt->pUser);
|
snprintf(auth.user, sizeof(auth.user), "%s", pCxt->pUser);
|
||||||
strcpy(auth.dbFName, p->dbFName);
|
snprintf(auth.dbFName, sizeof(auth.dbFName), "%s", p->dbFName);
|
||||||
auth.type = AUTH_TYPE_WRITE;
|
auth.type = AUTH_TYPE_WRITE;
|
||||||
taosArrayPush(pCatalogReq->pUser, &auth);
|
taosArrayPush(pCatalogReq->pUser, &auth);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,8 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) {
|
||||||
switch (nodeType(*pNode)) {
|
switch (nodeType(*pNode)) {
|
||||||
case QUERY_NODE_OPERATOR:
|
case QUERY_NODE_OPERATOR:
|
||||||
case QUERY_NODE_LOGIC_CONDITION:
|
case QUERY_NODE_LOGIC_CONDITION:
|
||||||
case QUERY_NODE_FUNCTION: {
|
case QUERY_NODE_FUNCTION:
|
||||||
|
case QUERY_NODE_CASE_WHEN: {
|
||||||
SRewriteExprCxt* pCxt = (SRewriteExprCxt*)pContext;
|
SRewriteExprCxt* pCxt = (SRewriteExprCxt*)pContext;
|
||||||
SNode* pExpr;
|
SNode* pExpr;
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
|
@ -118,6 +119,17 @@ static EDealRes doNameExpr(SNode* pNode, void* pContext) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteExprForSelect(SNode* pExpr, SSelectStmt* pSelect, ESqlClause clause) {
|
||||||
|
nodesWalkExpr(pExpr, doNameExpr, NULL);
|
||||||
|
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = NULL};
|
||||||
|
cxt.errCode = nodesListMakeAppend(&cxt.pExprs, pExpr);
|
||||||
|
if (TSDB_CODE_SUCCESS == cxt.errCode) {
|
||||||
|
nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt);
|
||||||
|
nodesClearList(cxt.pExprs);
|
||||||
|
}
|
||||||
|
return cxt.errCode;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t rewriteExprsForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ESqlClause clause) {
|
static int32_t rewriteExprsForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ESqlClause clause) {
|
||||||
nodesWalkExprs(pExprs, doNameExpr, NULL);
|
nodesWalkExprs(pExprs, doNameExpr, NULL);
|
||||||
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs};
|
SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs};
|
||||||
|
@ -459,9 +471,9 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pCol->node.resType = pExpr->resType;
|
pCol->node.resType = pExpr->resType;
|
||||||
strcpy(pCol->colName, pExpr->aliasName);
|
snprintf(pCol->colName, sizeof(pCol->colName), "%s", pExpr->aliasName);
|
||||||
if (NULL != pStmtName) {
|
if (NULL != pStmtName) {
|
||||||
strcpy(pCol->tableAlias, pStmtName);
|
snprintf(pCol->tableAlias, sizeof(pCol->tableAlias), "%s", pStmtName);
|
||||||
}
|
}
|
||||||
return pCol;
|
return pCol;
|
||||||
}
|
}
|
||||||
|
@ -711,8 +723,13 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo
|
||||||
nodesDestroyNode((SNode*)pWindow);
|
nodesDestroyNode((SNode*)pWindow);
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
// rewrite the expression in subsequent clauses
|
||||||
|
int32_t code = rewriteExprForSelect(pWindow->pStateExpr, pSelect, SQL_CLAUSE_WINDOW);
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode);
|
||||||
|
}
|
||||||
|
|
||||||
return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode);
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession,
|
static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession,
|
||||||
|
|
|
@ -1124,7 +1124,7 @@ static int32_t sortPriKeyOptGetSequencingNodes(SLogicNode* pNode, SNodeList** pS
|
||||||
bool notOptimize = false;
|
bool notOptimize = false;
|
||||||
int32_t code = sortPriKeyOptGetSequencingNodesImpl(pNode, ¬Optimize, pSequencingNodes);
|
int32_t code = sortPriKeyOptGetSequencingNodesImpl(pNode, ¬Optimize, pSequencingNodes);
|
||||||
if (TSDB_CODE_SUCCESS != code || notOptimize) {
|
if (TSDB_CODE_SUCCESS != code || notOptimize) {
|
||||||
nodesClearList(*pSequencingNodes);
|
NODES_CLEAR_LIST(*pSequencingNodes);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1361,74 +1361,6 @@ static int32_t smaIndexOptCouldApplyIndex(SScanLogicNode* pScan, STableIndexInfo
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SNode* smaIndexOptCreateWStartTs() {
|
|
||||||
SFunctionNode* pWStart = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
|
||||||
if (NULL == pWStart) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
strcpy(pWStart->functionName, "_wstart");
|
|
||||||
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
|
|
||||||
if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pWStart, NULL, 0)) {
|
|
||||||
nodesDestroyNode((SNode*)pWStart);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return (SNode*)pWStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t smaIndexOptCreateMergeKey(SNode* pCol, SNodeList** pMergeKeys) {
|
|
||||||
SOrderByExprNode* pMergeKey = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR);
|
|
||||||
if (NULL == pMergeKey) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
pMergeKey->pExpr = nodesCloneNode(pCol);
|
|
||||||
if (NULL == pMergeKey->pExpr) {
|
|
||||||
nodesDestroyNode((SNode*)pMergeKey);
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
pMergeKey->order = ORDER_ASC;
|
|
||||||
pMergeKey->nullOrder = NULL_ORDER_FIRST;
|
|
||||||
return nodesListMakeStrictAppend(pMergeKeys, (SNode*)pMergeKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t smaIndexOptRewriteInterval(SWindowLogicNode* pInterval, int32_t wstrartIndex, SNodeList** pMergeKeys) {
|
|
||||||
if (wstrartIndex < 0) {
|
|
||||||
SNode* pWStart = smaIndexOptCreateWStartTs();
|
|
||||||
if (NULL == pWStart) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
int32_t code = createColumnByRewriteExpr(pWStart, &pInterval->node.pTargets);
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
|
||||||
nodesDestroyNode(pWStart);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
wstrartIndex = LIST_LENGTH(pInterval->node.pTargets) - 1;
|
|
||||||
}
|
|
||||||
return smaIndexOptCreateMergeKey(nodesListGetNode(pInterval->node.pTargets, wstrartIndex), pMergeKeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t smaIndexOptApplyIndexExt(SLogicSubplan* pLogicSubplan, SScanLogicNode* pScan, STableIndexInfo* pIndex,
|
|
||||||
SNodeList* pSmaCols, int32_t wstrartIndex) {
|
|
||||||
SWindowLogicNode* pInterval = (SWindowLogicNode*)pScan->node.pParent;
|
|
||||||
SNodeList* pMergeTargets = nodesCloneList(pInterval->node.pTargets);
|
|
||||||
if (NULL == pMergeTargets) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
SLogicNode* pSmaScan = NULL;
|
|
||||||
SLogicNode* pMerge = NULL;
|
|
||||||
SNodeList* pMergeKeys = NULL;
|
|
||||||
int32_t code = smaIndexOptRewriteInterval(pInterval, wstrartIndex, &pMergeKeys);
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = smaIndexOptCreateSmaScan(pScan, pIndex, pSmaCols, &pSmaScan);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = smaIndexOptCreateMerge(pScan->node.pParent, pMergeKeys, pMergeTargets, &pMerge);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = smaIndexOptRecombinationNode(pLogicSubplan, pScan->node.pParent, pMerge, pSmaScan);
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t smaIndexOptApplyIndex(SLogicSubplan* pLogicSubplan, SScanLogicNode* pScan, STableIndexInfo* pIndex,
|
static int32_t smaIndexOptApplyIndex(SLogicSubplan* pLogicSubplan, SScanLogicNode* pScan, STableIndexInfo* pIndex,
|
||||||
SNodeList* pSmaCols, int32_t wstrartIndex) {
|
SNodeList* pSmaCols, int32_t wstrartIndex) {
|
||||||
SLogicNode* pSmaScan = NULL;
|
SLogicNode* pSmaScan = NULL;
|
||||||
|
@ -1559,7 +1491,7 @@ static SNode* partTagsCreateWrapperFunc(const char* pFuncName, SNode* pNode) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pFunc->functionName, pFuncName);
|
snprintf(pFunc->functionName, sizeof(pFunc->functionName), "%s", pFuncName);
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode) && COLUMN_TYPE_TBNAME != ((SColumnNode*)pNode)->colType) {
|
if (QUERY_NODE_COLUMN == nodeType(pNode) && COLUMN_TYPE_TBNAME != ((SColumnNode*)pNode)->colType) {
|
||||||
SColumnNode* pCol = (SColumnNode*)pNode;
|
SColumnNode* pCol = (SColumnNode*)pNode;
|
||||||
partTagsSetAlias(pFunc->node.aliasName, sizeof(pFunc->node.aliasName), pCol->tableAlias, pCol->colName);
|
partTagsSetAlias(pFunc->node.aliasName, sizeof(pFunc->node.aliasName), pCol->tableAlias, pCol->colName);
|
||||||
|
@ -2028,7 +1960,7 @@ static SNode* rewriteUniqueOptCreateFirstFunc(SFunctionNode* pSelectValue, SNode
|
||||||
if (NULL != pSelectValue) {
|
if (NULL != pSelectValue) {
|
||||||
strcpy(pFunc->node.aliasName, pSelectValue->node.aliasName);
|
strcpy(pFunc->node.aliasName, pSelectValue->node.aliasName);
|
||||||
} else {
|
} else {
|
||||||
snprintf(pFunc->node.aliasName, sizeof(pFunc->node.aliasName), "%s.%p", pFunc->functionName, pFunc);
|
snprintf(pFunc->node.aliasName, sizeof(pFunc->node.aliasName), "%s.%p", pFunc->functionName, (void*)pFunc);
|
||||||
}
|
}
|
||||||
int32_t code = nodesListMakeStrictAppend(&pFunc->pParameterList, nodesCloneNode(pCol));
|
int32_t code = nodesListMakeStrictAppend(&pFunc->pParameterList, nodesCloneNode(pCol));
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ static SNode* createSlotDesc(SPhysiPlanContext* pCxt, const char* pName, const S
|
||||||
if (NULL == pSlot) {
|
if (NULL == pSlot) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(pSlot->name, pName);
|
snprintf(pSlot->name, sizeof(pSlot->name), "%s", pName);
|
||||||
pSlot->slotId = slotId;
|
pSlot->slotId = slotId;
|
||||||
pSlot->dataType = ((SExprNode*)pNode)->resType;
|
pSlot->dataType = ((SExprNode*)pNode)->resType;
|
||||||
pSlot->reserve = reserve;
|
pSlot->reserve = reserve;
|
||||||
|
@ -663,13 +663,17 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
||||||
code = addDataBlockSlots(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc);
|
code = addDataBlockSlots(pCxt, pJoin->pTargets, pJoin->node.pOutputDataBlockDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
SNodeList* condCols = nodesMakeList();
|
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pOnConditions) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pOnConditions) {
|
||||||
code = nodesCollectColumnsFromNode(pJoinLogicNode->pOnConditions, NULL, COLLECT_COL_TYPE_ALL, &condCols);
|
SNodeList* pCondCols = nodesMakeList();
|
||||||
}
|
if (NULL == pCondCols) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
code = addDataBlockSlots(pCxt, condCols, pJoin->node.pOutputDataBlockDesc);
|
} else {
|
||||||
nodesDestroyList(condCols);
|
code = nodesCollectColumnsFromNode(pJoinLogicNode->pOnConditions, NULL, COLLECT_COL_TYPE_ALL, &pCondCols);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = addDataBlockSlots(pCxt, pCondCols, pJoin->node.pOutputDataBlockDesc);
|
||||||
|
}
|
||||||
|
nodesDestroyList(pCondCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pOnConditions) {
|
if (TSDB_CODE_SUCCESS == code && NULL != pJoinLogicNode->pOnConditions) {
|
||||||
|
@ -761,7 +765,8 @@ static EDealRes doRewritePrecalcExprs(SNode** pNode, void* pContext) {
|
||||||
return collectAndRewrite(pCxt, pNode);
|
return collectAndRewrite(pCxt, pNode);
|
||||||
}
|
}
|
||||||
case QUERY_NODE_OPERATOR:
|
case QUERY_NODE_OPERATOR:
|
||||||
case QUERY_NODE_LOGIC_CONDITION: {
|
case QUERY_NODE_LOGIC_CONDITION:
|
||||||
|
case QUERY_NODE_CASE_WHEN: {
|
||||||
return collectAndRewrite(pCxt, pNode);
|
return collectAndRewrite(pCxt, pNode);
|
||||||
}
|
}
|
||||||
case QUERY_NODE_FUNCTION: {
|
case QUERY_NODE_FUNCTION: {
|
||||||
|
@ -1633,7 +1638,7 @@ static SSubplan* makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubpl
|
||||||
pSubplan->subplanType = pLogicSubplan->subplanType;
|
pSubplan->subplanType = pLogicSubplan->subplanType;
|
||||||
pSubplan->level = pLogicSubplan->level;
|
pSubplan->level = pLogicSubplan->level;
|
||||||
if (NULL != pCxt->pPlanCxt->pUser) {
|
if (NULL != pCxt->pPlanCxt->pUser) {
|
||||||
strcpy(pSubplan->user, pCxt->pPlanCxt->pUser);
|
snprintf(pSubplan->user, sizeof(pSubplan->user), "%s", pCxt->pPlanCxt->pUser);
|
||||||
}
|
}
|
||||||
return pSubplan;
|
return pSubplan;
|
||||||
}
|
}
|
||||||
|
@ -1824,7 +1829,7 @@ static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNode* pSubplan, int32_t lev
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nodesListStrictAppend(pGroup->pNodeList, (SNode*)pSubplan);
|
return nodesListAppend(pGroup->pNodeList, (SNode*)pSubplan);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan* pParent,
|
static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubplan, SSubplan* pParent,
|
||||||
|
|
|
@ -342,7 +342,7 @@ static int32_t stbSplAppendWStart(SNodeList* pFuncs, int32_t* pIndex) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strcpy(pWStart->functionName, "_wstart");
|
strcpy(pWStart->functionName, "_wstart");
|
||||||
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, pWStart);
|
snprintf(pWStart->node.aliasName, sizeof(pWStart->node.aliasName), "%s.%p", pWStart->functionName, (void*)pWStart);
|
||||||
int32_t code = fmGetFuncInfo(pWStart, NULL, 0);
|
int32_t code = fmGetFuncInfo(pWStart, NULL, 0);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListStrictAppend(pFuncs, (SNode*)pWStart);
|
code = nodesListStrictAppend(pFuncs, (SNode*)pWStart);
|
||||||
|
@ -367,7 +367,7 @@ static int32_t stbSplAppendWEnd(SWindowLogicNode* pWin, int32_t* pIndex) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
strcpy(pWEnd->functionName, "_wend");
|
strcpy(pWEnd->functionName, "_wend");
|
||||||
snprintf(pWEnd->node.aliasName, sizeof(pWEnd->node.aliasName), "%s.%p", pWEnd->functionName, pWEnd);
|
snprintf(pWEnd->node.aliasName, sizeof(pWEnd->node.aliasName), "%s.%p", pWEnd->functionName, (void*)pWEnd);
|
||||||
int32_t code = fmGetFuncInfo(pWEnd, NULL, 0);
|
int32_t code = fmGetFuncInfo(pWEnd, NULL, 0);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListStrictAppend(pWin->pFuncs, (SNode*)pWEnd);
|
code = nodesListStrictAppend(pWin->pFuncs, (SNode*)pWEnd);
|
||||||
|
@ -389,22 +389,19 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic
|
||||||
SNode* pConditions = pMergeWindow->node.pConditions;
|
SNode* pConditions = pMergeWindow->node.pConditions;
|
||||||
pMergeWindow->node.pConditions = NULL;
|
pMergeWindow->node.pConditions = NULL;
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
|
||||||
SWindowLogicNode* pPartWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow);
|
SWindowLogicNode* pPartWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow);
|
||||||
if (NULL == pPartWin) {
|
if (NULL == pPartWin) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pPartWin->node.groupAction = GROUP_ACTION_KEEP;
|
pPartWin->node.groupAction = GROUP_ACTION_KEEP;
|
||||||
|
pMergeWindow->node.pTargets = pTargets;
|
||||||
|
pMergeWindow->node.pConditions = pConditions;
|
||||||
|
pPartWin->node.pChildren = pChildren;
|
||||||
|
splSetParent((SLogicNode*)pPartWin);
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
pMergeWindow->node.pTargets = pTargets;
|
|
||||||
pMergeWindow->node.pConditions = pConditions;
|
|
||||||
pPartWin->node.pChildren = pChildren;
|
|
||||||
splSetParent((SLogicNode*)pPartWin);
|
|
||||||
code = stbSplRewriteFuns(pFunc, &pPartWin->pFuncs, &pMergeWindow->pFuncs);
|
|
||||||
}
|
|
||||||
int32_t index = 0;
|
int32_t index = 0;
|
||||||
|
int32_t code = stbSplRewriteFuns(pFunc, &pPartWin->pFuncs, &pMergeWindow->pFuncs);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = stbSplAppendWStart(pPartWin->pFuncs, &index);
|
code = stbSplAppendWStart(pPartWin->pFuncs, &index);
|
||||||
}
|
}
|
||||||
|
@ -721,15 +718,16 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO
|
||||||
SNode* pConditions = pMergeAgg->node.pConditions;
|
SNode* pConditions = pMergeAgg->node.pConditions;
|
||||||
pMergeAgg->node.pConditions = NULL;
|
pMergeAgg->node.pConditions = NULL;
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
|
||||||
SAggLogicNode* pPartAgg = (SAggLogicNode*)nodesCloneNode((SNode*)pMergeAgg);
|
SAggLogicNode* pPartAgg = (SAggLogicNode*)nodesCloneNode((SNode*)pMergeAgg);
|
||||||
if (NULL == pPartAgg) {
|
if (NULL == pPartAgg) {
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
pPartAgg->node.groupAction = GROUP_ACTION_KEEP;
|
pPartAgg->node.groupAction = GROUP_ACTION_KEEP;
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL != pGroupKeys) {
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
if (NULL != pGroupKeys) {
|
||||||
pPartAgg->pGroupKeys = pGroupKeys;
|
pPartAgg->pGroupKeys = pGroupKeys;
|
||||||
code = createColumnByRewriteExprs(pPartAgg->pGroupKeys, &pPartAgg->node.pTargets);
|
code = createColumnByRewriteExprs(pPartAgg->pGroupKeys, &pPartAgg->node.pTargets);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,8 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
|
||||||
}
|
}
|
||||||
case QUERY_NODE_OPERATOR:
|
case QUERY_NODE_OPERATOR:
|
||||||
case QUERY_NODE_LOGIC_CONDITION:
|
case QUERY_NODE_LOGIC_CONDITION:
|
||||||
case QUERY_NODE_FUNCTION: {
|
case QUERY_NODE_FUNCTION:
|
||||||
|
case QUERY_NODE_CASE_WHEN: {
|
||||||
SExprNode* pExpr = (SExprNode*)pNode;
|
SExprNode* pExpr = (SExprNode*)pNode;
|
||||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||||
if (NULL == pCol) {
|
if (NULL == pCol) {
|
||||||
|
|
|
@ -86,7 +86,7 @@ typedef struct SScalarCtx {
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow);
|
int32_t sclConvertValueToSclParam(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow);
|
||||||
int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarParam* pParam);
|
int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarParam* pParam);
|
||||||
int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode);
|
int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode);
|
||||||
|
|
||||||
|
@ -95,6 +95,11 @@ int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode);
|
||||||
#define GET_PARAM_PRECISON(_c) ((_c)->columnData->info.precision)
|
#define GET_PARAM_PRECISON(_c) ((_c)->columnData->info.precision)
|
||||||
|
|
||||||
void sclFreeParam(SScalarParam* param);
|
void sclFreeParam(SScalarParam* param);
|
||||||
|
void doVectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows,
|
||||||
|
int32_t _ord, int32_t optr);
|
||||||
|
void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows,
|
||||||
|
int32_t _ord, int32_t optr);
|
||||||
|
void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,15 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct SSclVectorConvCtx {
|
||||||
|
const SScalarParam* pIn;
|
||||||
|
SScalarParam* pOut;
|
||||||
|
int32_t startIndex;
|
||||||
|
int32_t endIndex;
|
||||||
|
int16_t inType;
|
||||||
|
int16_t outType;
|
||||||
|
} SSclVectorConvCtx;
|
||||||
|
|
||||||
typedef double (*_getDoubleValue_fn_t)(void *src, int32_t index);
|
typedef double (*_getDoubleValue_fn_t)(void *src, int32_t index);
|
||||||
|
|
||||||
static FORCE_INLINE double getVectorDoubleValue_TINYINT(void *src, int32_t index) {
|
static FORCE_INLINE double getVectorDoubleValue_TINYINT(void *src, int32_t index) {
|
||||||
|
|
|
@ -1165,7 +1165,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
|
||||||
SValueNode *valueNode = (SValueNode *)cell->pNode;
|
SValueNode *valueNode = (SValueNode *)cell->pNode;
|
||||||
if (valueNode->node.resType.type != type) {
|
if (valueNode->node.resType.type != type) {
|
||||||
int32_t overflow = 0;
|
int32_t overflow = 0;
|
||||||
code = doConvertDataType(valueNode, &out, &overflow);
|
code = sclConvertValueToSclParam(valueNode, &out, &overflow);
|
||||||
if (code) {
|
if (code) {
|
||||||
// fltError("convert from %d to %d failed", in.type, out.type);
|
// fltError("convert from %d to %d failed", in.type, out.type);
|
||||||
FLT_ERR_RET(code);
|
FLT_ERR_RET(code);
|
||||||
|
@ -1973,7 +1973,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo refactor the convert
|
// todo refactor the convert
|
||||||
int32_t code = doConvertDataType(var, &out, NULL);
|
int32_t code = sclConvertValueToSclParam(var, &out, NULL);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
qError("convert value to type[%d] failed", type);
|
qError("convert value to type[%d] failed", type);
|
||||||
return TSDB_CODE_TSC_INVALID_OPERATION;
|
return TSDB_CODE_TSC_INVALID_OPERATION;
|
||||||
|
@ -3792,6 +3792,11 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (QUERY_NODE_CASE_WHEN == nodeType(*pNode) || QUERY_NODE_WHEN_THEN == nodeType(*pNode)) {
|
||||||
|
stat->scalarMode = true;
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (QUERY_NODE_OPERATOR == nodeType(*pNode)) {
|
if (QUERY_NODE_OPERATOR == nodeType(*pNode)) {
|
||||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||||
if (!FLT_IS_COMPARISON_OPERATOR(node->opType)) {
|
if (!FLT_IS_COMPARISON_OPERATOR(node->opType)) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarPara
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doConvertDataType(SValueNode *pValueNode, SScalarParam *out, int32_t *overflow) {
|
int32_t sclConvertValueToSclParam(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow) {
|
||||||
SScalarParam in = {.numOfRows = 1};
|
SScalarParam in = {.numOfRows = 1};
|
||||||
int32_t code = sclCreateColumnInfoData(&pValueNode->node.resType, 1, &in);
|
int32_t code = sclCreateColumnInfoData(&pValueNode->node.resType, 1, &in);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -71,12 +71,34 @@ int32_t doConvertDataType(SValueNode *pValueNode, SScalarParam *out, int32_t *ov
|
||||||
colDataAppend(in.columnData, 0, nodesGetValueFromNode(pValueNode), false);
|
colDataAppend(in.columnData, 0, nodesGetValueFromNode(pValueNode), false);
|
||||||
|
|
||||||
colInfoDataEnsureCapacity(out->columnData, 1);
|
colInfoDataEnsureCapacity(out->columnData, 1);
|
||||||
code = vectorConvertImpl(&in, out, overflow);
|
code = vectorConvertSingleColImpl(&in, out, overflow, -1, -1);
|
||||||
sclFreeParam(&in);
|
sclFreeParam(&in);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockList) {
|
||||||
|
SSDataBlock* pb = taosArrayGetP(pBlockList, 0);
|
||||||
|
SScalarParam *pLeft = taosMemoryCalloc(1, sizeof(SScalarParam));
|
||||||
|
if (NULL == pLeft) {
|
||||||
|
sclError("calloc %d failed", (int32_t)sizeof(SScalarParam));
|
||||||
|
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
pLeft->numOfRows = pb->info.rows;
|
||||||
|
|
||||||
|
if (pDst->numOfRows < pb->info.rows) {
|
||||||
|
colInfoDataEnsureCapacity(pDst->columnData, pb->info.rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
_bin_scalar_fn_t OperatorFn = getBinScalarOperatorFn(OP_TYPE_ASSIGN);
|
||||||
|
OperatorFn(pLeft, pSrc, pDst, TSDB_ORDER_ASC);
|
||||||
|
|
||||||
|
taosMemoryFree(pLeft);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
||||||
SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(type), true, false);
|
SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(type), true, false);
|
||||||
if (NULL == pObj) {
|
if (NULL == pObj) {
|
||||||
|
@ -110,7 +132,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t overflow = 0;
|
int32_t overflow = 0;
|
||||||
code = doConvertDataType(valueNode, &out, &overflow);
|
code = sclConvertValueToSclParam(valueNode, &out, &overflow);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
// sclError("convert data from %d to %d failed", in.type, out.type);
|
// sclError("convert data from %d to %d failed", in.type, out.type);
|
||||||
SCL_ERR_JRET(code);
|
SCL_ERR_JRET(code);
|
||||||
|
@ -178,7 +200,7 @@ void sclFreeRes(SHashObj *res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sclFreeParam(SScalarParam *param) {
|
void sclFreeParam(SScalarParam *param) {
|
||||||
if (!param->colAlloced) {
|
if (NULL == param || !param->colAlloced) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +408,8 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
||||||
}
|
}
|
||||||
case QUERY_NODE_FUNCTION:
|
case QUERY_NODE_FUNCTION:
|
||||||
case QUERY_NODE_OPERATOR:
|
case QUERY_NODE_OPERATOR:
|
||||||
case QUERY_NODE_LOGIC_CONDITION: {
|
case QUERY_NODE_LOGIC_CONDITION:
|
||||||
|
case QUERY_NODE_CASE_WHEN: {
|
||||||
SScalarParam *res = (SScalarParam *)taosHashGet(ctx->pRes, &node, POINTER_BYTES);
|
SScalarParam *res = (SScalarParam *)taosHashGet(ctx->pRes, &node, POINTER_BYTES);
|
||||||
if (NULL == res) {
|
if (NULL == res) {
|
||||||
sclError("no result for node, type:%d, node:%p", nodeType(node), node);
|
sclError("no result for node, type:%d, node:%p", nodeType(node), node);
|
||||||
|
@ -540,6 +563,135 @@ _return:
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t sclGetNodeRes(SNode* node, SScalarCtx *ctx, SScalarParam **res) {
|
||||||
|
if (NULL == node) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t rowNum = 0;
|
||||||
|
*res = taosMemoryCalloc(1, sizeof(**res));
|
||||||
|
if (NULL == *res) {
|
||||||
|
SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
SCL_ERR_RET(sclInitParam(node, *res, ctx, &rowNum));
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t sclWalkCaseWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCell, SScalarParam *pCase, SScalarParam *pElse, SScalarParam *pComp, SScalarParam *output, int32_t rowIdx, int32_t totalRows, bool *complete) {
|
||||||
|
SNode *node = NULL;
|
||||||
|
SWhenThenNode* pWhenThen = NULL;
|
||||||
|
SScalarParam *pWhen = NULL;
|
||||||
|
SScalarParam *pThen = NULL;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
for (SListCell* cell = pCell; (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext) {
|
||||||
|
pWhenThen = (SWhenThenNode*)node;
|
||||||
|
|
||||||
|
SCL_ERR_RET(sclGetNodeRes(pWhenThen->pWhen, ctx, &pWhen));
|
||||||
|
SCL_ERR_RET(sclGetNodeRes(pWhenThen->pThen, ctx, &pThen));
|
||||||
|
|
||||||
|
vectorCompareImpl(pCase, pWhen, pComp, rowIdx, 1, TSDB_ORDER_ASC, OP_TYPE_EQUAL);
|
||||||
|
|
||||||
|
bool *equal = (bool*)colDataGetData(pComp->columnData, rowIdx);
|
||||||
|
if (*equal) {
|
||||||
|
colDataAppend(output->columnData, rowIdx, colDataGetData(pThen->columnData, (pThen->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pThen->columnData, (pThen->numOfRows > 1 ? rowIdx : 0)));
|
||||||
|
|
||||||
|
if (0 == rowIdx && 1 == pCase->numOfRows && 1 == pWhen->numOfRows && 1 == pThen->numOfRows && totalRows > 1) {
|
||||||
|
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
|
||||||
|
*complete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pElse) {
|
||||||
|
colDataAppend(output->columnData, rowIdx, colDataGetData(pElse->columnData, (pElse->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pElse->columnData, (pElse->numOfRows > 1 ? rowIdx : 0)));
|
||||||
|
|
||||||
|
if (0 == rowIdx && 1 == pCase->numOfRows && 1 == pElse->numOfRows && totalRows > 1) {
|
||||||
|
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
|
||||||
|
*complete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
colDataAppend(output->columnData, rowIdx, NULL, true);
|
||||||
|
|
||||||
|
if (0 == rowIdx && 1 == pCase->numOfRows && totalRows > 1) {
|
||||||
|
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
|
||||||
|
*complete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
sclFreeParam(pWhen);
|
||||||
|
sclFreeParam(pThen);
|
||||||
|
|
||||||
|
SCL_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCell, SScalarParam *pElse, SScalarParam *output,
|
||||||
|
int32_t rowIdx, int32_t totalRows, bool *complete, bool preSingle) {
|
||||||
|
SNode *node = NULL;
|
||||||
|
SWhenThenNode* pWhenThen = NULL;
|
||||||
|
SScalarParam *pWhen = NULL;
|
||||||
|
SScalarParam *pThen = NULL;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
for (SListCell* cell = pCell; (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext) {
|
||||||
|
pWhenThen = (SWhenThenNode*)node;
|
||||||
|
pWhen = NULL;
|
||||||
|
pThen = NULL;
|
||||||
|
|
||||||
|
SCL_ERR_JRET(sclGetNodeRes(pWhenThen->pWhen, ctx, &pWhen));
|
||||||
|
SCL_ERR_JRET(sclGetNodeRes(pWhenThen->pThen, ctx, &pThen));
|
||||||
|
|
||||||
|
bool *whenValue = (bool*)colDataGetData(pWhen->columnData, (pWhen->numOfRows > 1 ? rowIdx : 0));
|
||||||
|
|
||||||
|
if (*whenValue) {
|
||||||
|
colDataAppend(output->columnData, rowIdx, colDataGetData(pThen->columnData, (pThen->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pThen->columnData, (pThen->numOfRows > 1 ? rowIdx : 0)));
|
||||||
|
|
||||||
|
if (preSingle && 0 == rowIdx && 1 == pWhen->numOfRows && 1 == pThen->numOfRows && totalRows > 1) {
|
||||||
|
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
|
||||||
|
*complete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sclFreeParam(pWhen);
|
||||||
|
sclFreeParam(pThen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pElse) {
|
||||||
|
colDataAppend(output->columnData, rowIdx, colDataGetData(pElse->columnData, (pElse->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pElse->columnData, (pElse->numOfRows > 1 ? rowIdx : 0)));
|
||||||
|
|
||||||
|
if (preSingle && 0 == rowIdx && 1 == pElse->numOfRows && totalRows > 1) {
|
||||||
|
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
|
||||||
|
*complete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto _return;
|
||||||
|
}
|
||||||
|
|
||||||
|
colDataAppend(output->columnData, rowIdx, NULL, true);
|
||||||
|
|
||||||
|
if (preSingle && 0 == rowIdx && totalRows > 1) {
|
||||||
|
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
|
||||||
|
*complete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
sclFreeParam(pWhen);
|
||||||
|
sclFreeParam(pThen);
|
||||||
|
|
||||||
|
SCL_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t sclExecFunction(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *output) {
|
int32_t sclExecFunction(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *output) {
|
||||||
SScalarParam *params = NULL;
|
SScalarParam *params = NULL;
|
||||||
int32_t rowNum = 0;
|
int32_t rowNum = 0;
|
||||||
|
@ -698,6 +850,101 @@ _return:
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *output) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SScalarParam *pCase = NULL;
|
||||||
|
SScalarParam *pElse = NULL;
|
||||||
|
SScalarParam *pWhen = NULL;
|
||||||
|
SScalarParam *pThen = NULL;
|
||||||
|
SScalarParam comp = {0};
|
||||||
|
int32_t rowNum = 1;
|
||||||
|
bool complete = false;
|
||||||
|
|
||||||
|
if (NULL == node->pWhenThenList || node->pWhenThenList->length <= 0) {
|
||||||
|
sclError("invalid whenThen list");
|
||||||
|
SCL_ERR_RET(TSDB_CODE_INVALID_PARA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->pBlockList) {
|
||||||
|
SSDataBlock* pb = taosArrayGetP(ctx->pBlockList, 0);
|
||||||
|
rowNum = pb->info.rows;
|
||||||
|
output->numOfRows = pb->info.rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCL_ERR_JRET(sclCreateColumnInfoData(&node->node.resType, rowNum, output));
|
||||||
|
|
||||||
|
SCL_ERR_JRET(sclGetNodeRes(node->pCase, ctx, &pCase));
|
||||||
|
SCL_ERR_JRET(sclGetNodeRes(node->pElse, ctx, &pElse));
|
||||||
|
|
||||||
|
SDataType compType = {0};
|
||||||
|
compType.type = TSDB_DATA_TYPE_BOOL;
|
||||||
|
compType.bytes = tDataTypes[compType.type].bytes;
|
||||||
|
|
||||||
|
SCL_ERR_JRET(sclCreateColumnInfoData(&compType, rowNum, &comp));
|
||||||
|
|
||||||
|
SNode* tnode = NULL;
|
||||||
|
SWhenThenNode* pWhenThen = (SWhenThenNode*)node->pWhenThenList->pHead->pNode;
|
||||||
|
|
||||||
|
SCL_ERR_JRET(sclGetNodeRes(pWhenThen->pWhen, ctx, &pWhen));
|
||||||
|
SCL_ERR_JRET(sclGetNodeRes(pWhenThen->pThen, ctx, &pThen));
|
||||||
|
|
||||||
|
if (pCase) {
|
||||||
|
vectorCompare(pCase, pWhen, &comp, TSDB_ORDER_ASC, OP_TYPE_EQUAL);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < rowNum; ++i) {
|
||||||
|
bool *equal = (bool*)colDataGetData(comp.columnData, (comp.numOfRows > 1 ? i : 0));
|
||||||
|
if (*equal) {
|
||||||
|
colDataAppend(output->columnData, i, colDataGetData(pThen->columnData, (pThen->numOfRows > 1 ? i : 0)), colDataIsNull_s(pThen->columnData, (pThen->numOfRows > 1 ? i : 0)));
|
||||||
|
if (0 == i && 1 == pCase->numOfRows && 1 == pWhen->numOfRows && 1 == pThen->numOfRows && rowNum > 1) {
|
||||||
|
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SCL_ERR_JRET(sclWalkCaseWhenList(ctx, node->pWhenThenList, node->pWhenThenList->pHead->pNext, pCase, pElse, &comp, output, i, rowNum, &complete));
|
||||||
|
if (complete) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int32_t i = 0; i < rowNum; ++i) {
|
||||||
|
bool *whenValue = (bool*)colDataGetData(pWhen->columnData, (pWhen->numOfRows > 1 ? i : 0));
|
||||||
|
if (*whenValue) {
|
||||||
|
colDataAppend(output->columnData, i, colDataGetData(pThen->columnData, (pThen->numOfRows > 1 ? i : 0)), colDataIsNull_s(pThen->columnData, (pThen->numOfRows > 1 ? i : 0)));
|
||||||
|
if (0 == i && 1 == pWhen->numOfRows && 1 == pThen->numOfRows && rowNum > 1) {
|
||||||
|
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
SCL_ERR_JRET(sclWalkWhenList(ctx, node->pWhenThenList, node->pWhenThenList->pHead->pNext, pElse, output, i, rowNum, &complete, (pWhen->numOfRows == 1 && pThen->numOfRows == 1)));
|
||||||
|
if (complete) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sclFreeParam(pCase);
|
||||||
|
sclFreeParam(pElse);
|
||||||
|
sclFreeParam(&comp);
|
||||||
|
sclFreeParam(pWhen);
|
||||||
|
sclFreeParam(pThen);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_return:
|
||||||
|
|
||||||
|
sclFreeParam(pCase);
|
||||||
|
sclFreeParam(pElse);
|
||||||
|
sclFreeParam(&comp);
|
||||||
|
sclFreeParam(pWhen);
|
||||||
|
sclFreeParam(pThen);
|
||||||
|
sclFreeParam(output);
|
||||||
|
|
||||||
|
SCL_RET(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EDealRes sclRewriteNullInOptr(SNode **pNode, SScalarCtx *ctx, EOperatorType opType) {
|
EDealRes sclRewriteNullInOptr(SNode **pNode, SScalarCtx *ctx, EOperatorType opType) {
|
||||||
if (opType <= OP_TYPE_CALC_MAX) {
|
if (opType <= OP_TYPE_CALC_MAX) {
|
||||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||||
|
@ -960,9 +1207,66 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EDealRes sclRewriteCaseWhen(SNode** pNode, SScalarCtx *ctx) {
|
||||||
|
SCaseWhenNode *node = (SCaseWhenNode *)*pNode;
|
||||||
|
|
||||||
|
if ((!SCL_IS_CONST_NODE(node->pCase)) || (!SCL_IS_CONST_NODE(node->pElse))) {
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SNode* tnode = NULL;
|
||||||
|
FOREACH(tnode, node->pWhenThenList) {
|
||||||
|
SWhenThenNode* pWhenThen = (SWhenThenNode*)tnode;
|
||||||
|
if (!SCL_IS_CONST_NODE(pWhenThen->pWhen) || !SCL_IS_CONST_NODE(pWhenThen->pThen)) {
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SScalarParam output = {0};
|
||||||
|
ctx->code = sclExecCaseWhen(node, ctx, &output);
|
||||||
|
if (ctx->code) {
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||||
|
if (NULL == res) {
|
||||||
|
sclError("make value node failed");
|
||||||
|
sclFreeParam(&output);
|
||||||
|
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
res->translate = true;
|
||||||
|
|
||||||
|
res->node.resType = node->node.resType;
|
||||||
|
if (colDataIsNull_s(output.columnData, 0)) {
|
||||||
|
res->isNull = true;
|
||||||
|
res->node.resType = node->node.resType;
|
||||||
|
} else {
|
||||||
|
int32_t type = output.columnData->info.type;
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) { // todo refactor
|
||||||
|
res->datum.p = output.columnData->pData;
|
||||||
|
output.columnData->pData = NULL;
|
||||||
|
} else {
|
||||||
|
nodesSetValueNodeValue(res, output.columnData->pData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nodesDestroyNode(*pNode);
|
||||||
|
*pNode = (SNode*)res;
|
||||||
|
|
||||||
|
sclFreeParam(&output);
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EDealRes sclConstantsRewriter(SNode **pNode, void *pContext) {
|
EDealRes sclConstantsRewriter(SNode **pNode, void *pContext) {
|
||||||
SScalarCtx *ctx = (SScalarCtx *)pContext;
|
SScalarCtx *ctx = (SScalarCtx *)pContext;
|
||||||
|
|
||||||
|
if (QUERY_NODE_OPERATOR == nodeType(*pNode)) {
|
||||||
|
return sclRewriteOperator(pNode, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(*pNode)) {
|
if (QUERY_NODE_FUNCTION == nodeType(*pNode)) {
|
||||||
return sclRewriteFunction(pNode, ctx);
|
return sclRewriteFunction(pNode, ctx);
|
||||||
}
|
}
|
||||||
|
@ -971,8 +1275,8 @@ EDealRes sclConstantsRewriter(SNode **pNode, void *pContext) {
|
||||||
return sclRewriteLogic(pNode, ctx);
|
return sclRewriteLogic(pNode, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QUERY_NODE_OPERATOR == nodeType(*pNode)) {
|
if (QUERY_NODE_CASE_WHEN == nodeType(*pNode)) {
|
||||||
return sclRewriteOperator(pNode, ctx);
|
return sclRewriteCaseWhen(pNode, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
|
@ -1082,13 +1386,36 @@ EDealRes sclWalkTarget(SNode *pNode, SScalarCtx *ctx) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EDealRes sclWalkCaseWhen(SNode* pNode, SScalarCtx *ctx) {
|
||||||
|
SCaseWhenNode *node = (SCaseWhenNode *)pNode;
|
||||||
|
SScalarParam output = {0};
|
||||||
|
|
||||||
|
ctx->code = sclExecCaseWhen(node, ctx, &output);
|
||||||
|
if (ctx->code) {
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) {
|
||||||
|
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DEAL_RES_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EDealRes sclCalcWalker(SNode *pNode, void *pContext) {
|
EDealRes sclCalcWalker(SNode *pNode, void *pContext) {
|
||||||
if (QUERY_NODE_VALUE == nodeType(pNode) || QUERY_NODE_NODE_LIST == nodeType(pNode) ||
|
if (QUERY_NODE_VALUE == nodeType(pNode) || QUERY_NODE_NODE_LIST == nodeType(pNode)
|
||||||
QUERY_NODE_COLUMN == nodeType(pNode) || QUERY_NODE_LEFT_VALUE == nodeType(pNode)) {
|
|| QUERY_NODE_COLUMN == nodeType(pNode) || QUERY_NODE_LEFT_VALUE == nodeType(pNode)
|
||||||
|
|| QUERY_NODE_WHEN_THEN == nodeType(pNode)) {
|
||||||
return DEAL_RES_CONTINUE;
|
return DEAL_RES_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SScalarCtx *ctx = (SScalarCtx *)pContext;
|
SScalarCtx *ctx = (SScalarCtx *)pContext;
|
||||||
|
if (QUERY_NODE_OPERATOR == nodeType(pNode)) {
|
||||||
|
return sclWalkOperator(pNode, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
if (QUERY_NODE_FUNCTION == nodeType(pNode)) {
|
if (QUERY_NODE_FUNCTION == nodeType(pNode)) {
|
||||||
return sclWalkFunction(pNode, ctx);
|
return sclWalkFunction(pNode, ctx);
|
||||||
}
|
}
|
||||||
|
@ -1097,38 +1424,19 @@ EDealRes sclCalcWalker(SNode *pNode, void *pContext) {
|
||||||
return sclWalkLogic(pNode, ctx);
|
return sclWalkLogic(pNode, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QUERY_NODE_OPERATOR == nodeType(pNode)) {
|
|
||||||
return sclWalkOperator(pNode, ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (QUERY_NODE_TARGET == nodeType(pNode)) {
|
if (QUERY_NODE_TARGET == nodeType(pNode)) {
|
||||||
return sclWalkTarget(pNode, ctx);
|
return sclWalkTarget(pNode, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (QUERY_NODE_CASE_WHEN == nodeType(pNode)) {
|
||||||
|
return sclWalkCaseWhen(pNode, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
sclError("invalid node type for scalar calculating, type:%d", nodeType(pNode));
|
sclError("invalid node type for scalar calculating, type:%d", nodeType(pNode));
|
||||||
ctx->code = TSDB_CODE_QRY_INVALID_INPUT;
|
ctx->code = TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockList) {
|
|
||||||
SSDataBlock *pb = taosArrayGetP(pBlockList, 0);
|
|
||||||
SScalarParam *pLeft = taosMemoryCalloc(1, sizeof(SScalarParam));
|
|
||||||
if (NULL == pLeft) {
|
|
||||||
sclError("calloc %d failed", (int32_t)sizeof(SScalarParam));
|
|
||||||
SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
pLeft->numOfRows = pb->info.rows;
|
|
||||||
colInfoDataEnsureCapacity(pDst->columnData, pb->info.rows);
|
|
||||||
|
|
||||||
_bin_scalar_fn_t OperatorFn = getBinScalarOperatorFn(OP_TYPE_ASSIGN);
|
|
||||||
OperatorFn(pLeft, pSrc, pDst, TSDB_ORDER_ASC);
|
|
||||||
|
|
||||||
taosMemoryFree(pLeft);
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t sclCalcConstants(SNode *pNode, bool dual, SNode **pRes) {
|
int32_t sclCalcConstants(SNode *pNode, bool dual, SNode **pRes) {
|
||||||
if (NULL == pNode) {
|
if (NULL == pNode) {
|
||||||
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
|
|
@ -367,46 +367,45 @@ static FORCE_INLINE void ncharToVar(char *buf, SScalarParam *pOut, int32_t rowIn
|
||||||
taosMemoryFree(t);
|
taosMemoryFree(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO opt performance, tmp is not needed.
|
//TODO opt performance, tmp is not needed.
|
||||||
int32_t vectorConvertFromVarData(const SScalarParam *pIn, SScalarParam *pOut, int32_t inType, int32_t outType,
|
int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t* overflow) {
|
||||||
int32_t *overflow) {
|
|
||||||
bool vton = false;
|
bool vton = false;
|
||||||
|
|
||||||
_bufConverteFunc func = NULL;
|
_bufConverteFunc func = NULL;
|
||||||
if (TSDB_DATA_TYPE_BOOL == outType) {
|
if (TSDB_DATA_TYPE_BOOL == pCtx->outType) {
|
||||||
func = varToBool;
|
func = varToBool;
|
||||||
} else if (IS_SIGNED_NUMERIC_TYPE(outType)) {
|
} else if (IS_SIGNED_NUMERIC_TYPE(pCtx->outType)) {
|
||||||
func = varToSigned;
|
func = varToSigned;
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(outType)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(pCtx->outType)) {
|
||||||
func = varToUnsigned;
|
func = varToUnsigned;
|
||||||
} else if (IS_FLOAT_TYPE(outType)) {
|
} else if (IS_FLOAT_TYPE(pCtx->outType)) {
|
||||||
func = varToFloat;
|
func = varToFloat;
|
||||||
} else if (outType == TSDB_DATA_TYPE_BINARY) { // nchar -> binary
|
} else if (pCtx->outType == TSDB_DATA_TYPE_BINARY) { // nchar -> binary
|
||||||
ASSERT(inType == TSDB_DATA_TYPE_NCHAR);
|
ASSERT(pCtx->inType == TSDB_DATA_TYPE_NCHAR);
|
||||||
func = ncharToVar;
|
func = ncharToVar;
|
||||||
vton = true;
|
vton = true;
|
||||||
} else if (outType == TSDB_DATA_TYPE_NCHAR) { // binary -> nchar
|
} else if (pCtx->outType == TSDB_DATA_TYPE_NCHAR) { // binary -> nchar
|
||||||
ASSERT(inType == TSDB_DATA_TYPE_VARCHAR);
|
ASSERT(pCtx->inType == TSDB_DATA_TYPE_VARCHAR);
|
||||||
func = varToNchar;
|
func = varToNchar;
|
||||||
vton = true;
|
vton = true;
|
||||||
} else if (TSDB_DATA_TYPE_TIMESTAMP == outType) {
|
} else if (TSDB_DATA_TYPE_TIMESTAMP == pCtx->outType) {
|
||||||
func = varToTimestamp;
|
func = varToTimestamp;
|
||||||
} else {
|
} else {
|
||||||
sclError("invalid convert outType:%d", outType);
|
sclError("invalid convert outType:%d", pCtx->outType);
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
pOut->numOfRows = pIn->numOfRows;
|
pCtx->pOut->numOfRows = pCtx->pIn->numOfRows;
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) {
|
||||||
if (IS_HELPER_NULL(pIn->columnData, i)) {
|
if (IS_HELPER_NULL(pCtx->pIn->columnData, i)) {
|
||||||
colDataAppendNULL(pOut->columnData, i);
|
colDataAppendNULL(pCtx->pOut->columnData, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *data = colDataGetVarData(pIn->columnData, i);
|
char* data = colDataGetVarData(pCtx->pIn->columnData, i);
|
||||||
int32_t convertType = inType;
|
int32_t convertType = pCtx->inType;
|
||||||
if (inType == TSDB_DATA_TYPE_JSON) {
|
if(pCtx->inType == TSDB_DATA_TYPE_JSON){
|
||||||
if (*data == TSDB_DATA_TYPE_NULL) {
|
if(*data == TSDB_DATA_TYPE_NULL) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
} else if (*data == TSDB_DATA_TYPE_NCHAR) {
|
} else if (*data == TSDB_DATA_TYPE_NCHAR) {
|
||||||
data += CHAR_BYTES;
|
data += CHAR_BYTES;
|
||||||
|
@ -415,13 +414,13 @@ int32_t vectorConvertFromVarData(const SScalarParam *pIn, SScalarParam *pOut, in
|
||||||
terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR;
|
terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR;
|
||||||
return terrno;
|
return terrno;
|
||||||
} else {
|
} else {
|
||||||
convertNumberToNumber(data + CHAR_BYTES, colDataGetNumData(pOut->columnData, i), *data, outType);
|
convertNumberToNumber(data+CHAR_BYTES, colDataGetNumData(pCtx->pOut->columnData, i), *data, pCtx->outType);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int32_t bufSize = pIn->columnData->info.bytes;
|
int32_t bufSize = pCtx->pIn->columnData->info.bytes;
|
||||||
char *tmp = taosMemoryMalloc(varDataTLen(data));
|
char *tmp = taosMemoryMalloc(varDataTLen(data));
|
||||||
if (!tmp) {
|
if(!tmp){
|
||||||
sclError("out of memory in vectorConvertFromVarData");
|
sclError("out of memory in vectorConvertFromVarData");
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -445,7 +444,7 @@ int32_t vectorConvertFromVarData(const SScalarParam *pIn, SScalarParam *pOut, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(*func)(tmp, pOut, i, overflow);
|
(*func)(tmp, pCtx->pOut, i, overflow);
|
||||||
taosMemoryFreeClear(tmp);
|
taosMemoryFreeClear(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,64 +580,64 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vectorConvertToVarData(const SScalarParam *pIn, SScalarParam *pOut, int16_t inType, int16_t outType) {
|
int32_t vectorConvertToVarData(SSclVectorConvCtx *pCtx) {
|
||||||
SColumnInfoData *pInputCol = pIn->columnData;
|
SColumnInfoData* pInputCol = pCtx->pIn->columnData;
|
||||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
SColumnInfoData* pOutputCol = pCtx->pOut->columnData;
|
||||||
char tmp[128] = {0};
|
char tmp[128] = {0};
|
||||||
|
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(inType) || inType == TSDB_DATA_TYPE_BOOL || inType == TSDB_DATA_TYPE_TIMESTAMP) {
|
if (IS_SIGNED_NUMERIC_TYPE(pCtx->inType) || pCtx->inType == TSDB_DATA_TYPE_BOOL || pCtx->inType == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t value = 0;
|
int64_t value = 0;
|
||||||
GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, int64_t, pCtx->inType, colDataGetData(pInputCol, i));
|
||||||
int32_t len = sprintf(varDataVal(tmp), "%" PRId64, value);
|
int32_t len = sprintf(varDataVal(tmp), "%" PRId64, value);
|
||||||
varDataLen(tmp) = len;
|
varDataLen(tmp) = len;
|
||||||
if (outType == TSDB_DATA_TYPE_NCHAR) {
|
if (pCtx->outType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
varToNchar(tmp, pOut, i, NULL);
|
varToNchar(tmp, pCtx->pOut, i, NULL);
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(pOutputCol, i, (char *)tmp, false);
|
colDataAppend(pOutputCol, i, (char *)tmp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(inType)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(pCtx->inType)) {
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t value = 0;
|
uint64_t value = 0;
|
||||||
GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, uint64_t, pCtx->inType, colDataGetData(pInputCol, i));
|
||||||
int32_t len = sprintf(varDataVal(tmp), "%" PRIu64, value);
|
int32_t len = sprintf(varDataVal(tmp), "%" PRIu64, value);
|
||||||
varDataLen(tmp) = len;
|
varDataLen(tmp) = len;
|
||||||
if (outType == TSDB_DATA_TYPE_NCHAR) {
|
if (pCtx->outType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
varToNchar(tmp, pOut, i, NULL);
|
varToNchar(tmp, pCtx->pOut, i, NULL);
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(pOutputCol, i, (char *)tmp, false);
|
colDataAppend(pOutputCol, i, (char *)tmp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (IS_FLOAT_TYPE(inType)) {
|
} else if (IS_FLOAT_TYPE(pCtx->inType)) {
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, double, pCtx->inType, colDataGetData(pInputCol, i));
|
||||||
int32_t len = sprintf(varDataVal(tmp), "%lf", value);
|
int32_t len = sprintf(varDataVal(tmp), "%lf", value);
|
||||||
varDataLen(tmp) = len;
|
varDataLen(tmp) = len;
|
||||||
if (outType == TSDB_DATA_TYPE_NCHAR) {
|
if (pCtx->outType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
varToNchar(tmp, pOut, i, NULL);
|
varToNchar(tmp, pCtx->pOut, i, NULL);
|
||||||
} else {
|
} else {
|
||||||
colDataAppend(pOutputCol, i, (char *)tmp, false);
|
colDataAppend(pOutputCol, i, (char *)tmp, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sclError("not supported input type:%d", inType);
|
sclError("not supported input type:%d", pCtx->inType);
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,20 +645,21 @@ int32_t vectorConvertToVarData(const SScalarParam *pIn, SScalarParam *pOut, int1
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO opt performance
|
// TODO opt performance
|
||||||
int32_t vectorConvertImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *overflow) {
|
int32_t vectorConvertSingleColImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* overflow, int32_t startIndex, int32_t numOfRows) {
|
||||||
SColumnInfoData *pInputCol = pIn->columnData;
|
SColumnInfoData* pInputCol = pIn->columnData;
|
||||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
SColumnInfoData* pOutputCol = pOut->columnData;
|
||||||
|
|
||||||
if (NULL == pInputCol) {
|
if (NULL == pInputCol) {
|
||||||
sclError("input column is NULL, hashFilter %p", pIn->pHashFilter);
|
sclError("input column is NULL, hashFilter %p", pIn->pHashFilter);
|
||||||
return TSDB_CODE_APP_ERROR;
|
return TSDB_CODE_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t inType = pInputCol->info.type;
|
int32_t rstart = startIndex >= 0 ? startIndex : 0;
|
||||||
int16_t outType = pOutputCol->info.type;
|
int32_t rend = numOfRows > 0 ? rstart + numOfRows - 1 : rstart + pIn->numOfRows - 1;
|
||||||
|
SSclVectorConvCtx cCtx = {pIn, pOut, rstart, rend, pInputCol->info.type, pOutputCol->info.type};
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(inType)) {
|
if (IS_VAR_DATA_TYPE(cCtx.inType)) {
|
||||||
return vectorConvertFromVarData(pIn, pOut, inType, outType, overflow);
|
return vectorConvertFromVarData(&cCtx, overflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overflow) {
|
if (overflow) {
|
||||||
|
@ -667,12 +667,12 @@ int32_t vectorConvertImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *
|
||||||
|
|
||||||
pOut->numOfRows = 0;
|
pOut->numOfRows = 0;
|
||||||
|
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(outType)) {
|
if (IS_SIGNED_NUMERIC_TYPE(cCtx.outType)) {
|
||||||
int64_t minValue = tDataTypes[outType].minValue;
|
int64_t minValue = tDataTypes[cCtx.outType].minValue;
|
||||||
int64_t maxValue = tDataTypes[outType].maxValue;
|
int64_t maxValue = tDataTypes[cCtx.outType].maxValue;
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0));
|
GET_TYPED_DATA(value, double, cCtx.inType, colDataGetData(pInputCol, 0));
|
||||||
|
|
||||||
if (value > maxValue) {
|
if (value > maxValue) {
|
||||||
*overflow = 1;
|
*overflow = 1;
|
||||||
|
@ -683,12 +683,12 @@ int32_t vectorConvertImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *
|
||||||
} else {
|
} else {
|
||||||
*overflow = 0;
|
*overflow = 0;
|
||||||
}
|
}
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(outType)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(cCtx.outType)) {
|
||||||
uint64_t minValue = (uint64_t)tDataTypes[outType].minValue;
|
uint64_t minValue = (uint64_t)tDataTypes[cCtx.outType].minValue;
|
||||||
uint64_t maxValue = (uint64_t)tDataTypes[outType].maxValue;
|
uint64_t maxValue = (uint64_t)tDataTypes[cCtx.outType].maxValue;
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0));
|
GET_TYPED_DATA(value, double, cCtx.inType, colDataGetData(pInputCol, 0));
|
||||||
|
|
||||||
if (value > maxValue) {
|
if (value > maxValue) {
|
||||||
*overflow = 1;
|
*overflow = 1;
|
||||||
|
@ -703,157 +703,157 @@ int32_t vectorConvertImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *
|
||||||
}
|
}
|
||||||
|
|
||||||
pOut->numOfRows = pIn->numOfRows;
|
pOut->numOfRows = pIn->numOfRows;
|
||||||
switch (outType) {
|
switch (cCtx.outType) {
|
||||||
case TSDB_DATA_TYPE_BOOL: {
|
case TSDB_DATA_TYPE_BOOL: {
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool value = 0;
|
bool value = 0;
|
||||||
GET_TYPED_DATA(value, bool, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, bool, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendInt8(pOutputCol, i, (int8_t *)&value);
|
colDataAppendInt8(pOutputCol, i, (int8_t *)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_TINYINT: {
|
case TSDB_DATA_TYPE_TINYINT: {
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t value = 0;
|
int8_t value = 0;
|
||||||
GET_TYPED_DATA(value, int8_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, int8_t, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendInt8(pOutputCol, i, (int8_t *)&value);
|
colDataAppendInt8(pOutputCol, i, (int8_t *)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_SMALLINT: {
|
case TSDB_DATA_TYPE_SMALLINT:{
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t value = 0;
|
int16_t value = 0;
|
||||||
GET_TYPED_DATA(value, int16_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, int16_t, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendInt16(pOutputCol, i, (int16_t *)&value);
|
colDataAppendInt16(pOutputCol, i, (int16_t *)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_INT: {
|
case TSDB_DATA_TYPE_INT:{
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t value = 0;
|
int32_t value = 0;
|
||||||
GET_TYPED_DATA(value, int32_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, int32_t, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendInt32(pOutputCol, i, (int32_t *)&value);
|
colDataAppendInt32(pOutputCol, i, (int32_t *)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
case TSDB_DATA_TYPE_TIMESTAMP: {
|
case TSDB_DATA_TYPE_TIMESTAMP: {
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t value = 0;
|
int64_t value = 0;
|
||||||
GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, int64_t, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendInt64(pOutputCol, i, (int64_t *)&value);
|
colDataAppendInt64(pOutputCol, i, (int64_t *)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UTINYINT: {
|
case TSDB_DATA_TYPE_UTINYINT:{
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t value = 0;
|
uint8_t value = 0;
|
||||||
GET_TYPED_DATA(value, uint8_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, uint8_t, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendInt8(pOutputCol, i, (int8_t *)&value);
|
colDataAppendInt8(pOutputCol, i, (int8_t *)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_USMALLINT: {
|
case TSDB_DATA_TYPE_USMALLINT:{
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t value = 0;
|
uint16_t value = 0;
|
||||||
GET_TYPED_DATA(value, uint16_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, uint16_t, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendInt16(pOutputCol, i, (int16_t *)&value);
|
colDataAppendInt16(pOutputCol, i, (int16_t *)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UINT: {
|
case TSDB_DATA_TYPE_UINT:{
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t value = 0;
|
uint32_t value = 0;
|
||||||
GET_TYPED_DATA(value, uint32_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, uint32_t, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendInt32(pOutputCol, i, (int32_t *)&value);
|
colDataAppendInt32(pOutputCol, i, (int32_t *)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UBIGINT: {
|
case TSDB_DATA_TYPE_UBIGINT: {
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t value = 0;
|
uint64_t value = 0;
|
||||||
GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, uint64_t, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendInt64(pOutputCol, i, (int64_t *)&value);
|
colDataAppendInt64(pOutputCol, i, (int64_t*)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
case TSDB_DATA_TYPE_FLOAT:{
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
float value = 0;
|
float value = 0;
|
||||||
GET_TYPED_DATA(value, float, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, float, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendFloat(pOutputCol, i, (float *)&value);
|
colDataAppendFloat(pOutputCol, i, (float*)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) {
|
||||||
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
||||||
colDataAppendNULL(pOutputCol, i);
|
colDataAppendNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i));
|
GET_TYPED_DATA(value, double, cCtx.inType, colDataGetData(pInputCol, i));
|
||||||
colDataAppendDouble(pOutputCol, i, (double *)&value);
|
colDataAppendDouble(pOutputCol, i, (double*)&value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
case TSDB_DATA_TYPE_BINARY:
|
||||||
case TSDB_DATA_TYPE_NCHAR: {
|
case TSDB_DATA_TYPE_NCHAR: {
|
||||||
return vectorConvertToVarData(pIn, pOut, inType, outType);
|
return vectorConvertToVarData(&cCtx);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
sclError("invalid convert output type:%d", outType);
|
sclError("invalid convert output type:%d", cCtx.outType);
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
return TSDB_CODE_QRY_APP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,7 +894,7 @@ int32_t vectorGetConvertType(int32_t type1, int32_t type2) {
|
||||||
return gConvertTypes[type2][type1];
|
return gConvertTypes[type2][type1];
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vectorConvertScalarParam(SScalarParam *input, SScalarParam *output, int32_t type) {
|
int32_t vectorConvertSingleCol(SScalarParam *input, SScalarParam *output, int32_t type, int32_t startIndex, int32_t numOfRows) {
|
||||||
SDataType t = {.type = type, .bytes = tDataTypes[type].bytes};
|
SDataType t = {.type = type, .bytes = tDataTypes[type].bytes};
|
||||||
output->numOfRows = input->numOfRows;
|
output->numOfRows = input->numOfRows;
|
||||||
|
|
||||||
|
@ -903,17 +903,16 @@ int32_t vectorConvertScalarParam(SScalarParam *input, SScalarParam *output, int3
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = vectorConvertImpl(input, output, NULL);
|
code = vectorConvertSingleColImpl(input, output, NULL, startIndex, numOfRows);
|
||||||
if (code) {
|
if (code) {
|
||||||
// taosMemoryFreeClear(paramOut1->data);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t vectorConvert(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pLeftOut, SScalarParam *pRightOut) {
|
int32_t vectorConvertCols(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* pLeftOut, SScalarParam* pRightOut, int32_t startIndex, int32_t numOfRows) {
|
||||||
int32_t leftType = GET_PARAM_TYPE(pLeft);
|
int32_t leftType = GET_PARAM_TYPE(pLeft);
|
||||||
int32_t rightType = GET_PARAM_TYPE(pRight);
|
int32_t rightType = GET_PARAM_TYPE(pRight);
|
||||||
if (leftType == rightType) {
|
if (leftType == rightType) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -941,14 +940,14 @@ int32_t vectorConvert(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *p
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != GET_PARAM_TYPE(param1)) {
|
if (type != GET_PARAM_TYPE(param1)) {
|
||||||
code = vectorConvertScalarParam(param1, paramOut1, type);
|
code = vectorConvertSingleCol(param1, paramOut1, type, startIndex, numOfRows);
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != GET_PARAM_TYPE(param2)) {
|
if (type != GET_PARAM_TYPE(param2)) {
|
||||||
code = vectorConvertScalarParam(param2, paramOut2, type);
|
code = vectorConvertSingleCol(param2, paramOut2, type, startIndex, numOfRows);
|
||||||
if (code) {
|
if (code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -962,31 +961,6 @@ enum {
|
||||||
VECTOR_UN_CONVERT = 0x2,
|
VECTOR_UN_CONVERT = 0x2,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t doConvertHelper(SScalarParam *pDest, int32_t *convert, const SScalarParam *pParam, int32_t type) {
|
|
||||||
SColumnInfoData *pCol = pParam->columnData;
|
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pCol->info.type) && pCol->info.type != TSDB_DATA_TYPE_JSON) {
|
|
||||||
pDest->numOfRows = pParam->numOfRows;
|
|
||||||
|
|
||||||
SDataType t = {.type = type, .bytes = tDataTypes[type].bytes};
|
|
||||||
int32_t code = sclCreateColumnInfoData(&t, pParam->numOfRows, pDest);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = vectorConvertImpl(pParam, pDest, NULL);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
*convert = VECTOR_DO_CONVERT;
|
|
||||||
} else {
|
|
||||||
*convert = VECTOR_UN_CONVERT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO not correct for descending order scan
|
// TODO not correct for descending order scan
|
||||||
static void vectorMathAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
|
static void vectorMathAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
|
||||||
int32_t numOfRows, int32_t step, int32_t i) {
|
int32_t numOfRows, int32_t step, int32_t i) {
|
||||||
|
@ -1030,20 +1004,25 @@ static void vectorMathTsAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static SColumnInfoData *doVectorConvert(SScalarParam *pInput, int32_t *doConvert) {
|
static SColumnInfoData* vectorConvertVarToDouble(SScalarParam* pInput, int32_t* converted) {
|
||||||
SScalarParam convertParam = {0};
|
SScalarParam output = {0};
|
||||||
|
SColumnInfoData* pCol = pInput->columnData;
|
||||||
|
|
||||||
int32_t code = doConvertHelper(&convertParam, doConvert, pInput, TSDB_DATA_TYPE_DOUBLE);
|
if (IS_VAR_DATA_TYPE(pCol->info.type) && pCol->info.type != TSDB_DATA_TYPE_JSON) {
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
int32_t code = vectorConvertSingleCol(pInput, &output, TSDB_DATA_TYPE_DOUBLE, -1, -1);
|
||||||
terrno = code;
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
terrno = code;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*converted = VECTOR_DO_CONVERT;
|
||||||
|
|
||||||
|
return output.columnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*doConvert == VECTOR_DO_CONVERT) {
|
*converted = VECTOR_UN_CONVERT;
|
||||||
return convertParam.columnData;
|
|
||||||
} else {
|
return pInput->columnData;
|
||||||
return pInput->columnData;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doReleaseVec(SColumnInfoData *pCol, int32_t type) {
|
static void doReleaseVec(SColumnInfoData *pCol, int32_t type) {
|
||||||
|
@ -1061,9 +1040,9 @@ void vectorMathAdd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut
|
||||||
|
|
||||||
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||||
|
|
||||||
int32_t leftConvert = 0, rightConvert = 0;
|
int32_t leftConvert = 0, rightConvert = 0;
|
||||||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert);
|
||||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert);
|
||||||
|
|
||||||
if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && IS_INTEGER_TYPE(GET_PARAM_TYPE(pRight))) ||
|
if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && IS_INTEGER_TYPE(GET_PARAM_TYPE(pRight))) ||
|
||||||
(GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && IS_INTEGER_TYPE(GET_PARAM_TYPE(pLeft))) ||
|
(GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && IS_INTEGER_TYPE(GET_PARAM_TYPE(pLeft))) ||
|
||||||
|
@ -1168,9 +1147,9 @@ void vectorMathSub(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut
|
||||||
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
||||||
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
||||||
|
|
||||||
int32_t leftConvert = 0, rightConvert = 0;
|
int32_t leftConvert = 0, rightConvert = 0;
|
||||||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert);
|
||||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert);
|
||||||
|
|
||||||
if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_BIGINT) ||
|
if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_BIGINT) ||
|
||||||
(GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP &&
|
(GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP &&
|
||||||
|
@ -1246,9 +1225,9 @@ void vectorMathMultiply(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam
|
||||||
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
||||||
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
||||||
|
|
||||||
int32_t leftConvert = 0, rightConvert = 0;
|
int32_t leftConvert = 0, rightConvert = 0;
|
||||||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert);
|
||||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert);
|
||||||
|
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
||||||
|
@ -1279,9 +1258,9 @@ void vectorMathDivide(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *p
|
||||||
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
||||||
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
||||||
|
|
||||||
int32_t leftConvert = 0, rightConvert = 0;
|
int32_t leftConvert = 0, rightConvert = 0;
|
||||||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert);
|
||||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert);
|
||||||
|
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
||||||
|
@ -1333,9 +1312,9 @@ void vectorMathRemainder(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam
|
||||||
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
||||||
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
||||||
|
|
||||||
int32_t leftConvert = 0, rightConvert = 0;
|
int32_t leftConvert = 0, rightConvert = 0;
|
||||||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert);
|
||||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert);
|
||||||
|
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
||||||
|
@ -1412,8 +1391,8 @@ void vectorMathMinus(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pO
|
||||||
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : (pLeft->numOfRows - 1);
|
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : (pLeft->numOfRows - 1);
|
||||||
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
||||||
|
|
||||||
int32_t leftConvert = 0;
|
int32_t leftConvert = 0;
|
||||||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert);
|
||||||
|
|
||||||
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
|
||||||
|
|
||||||
|
@ -1525,9 +1504,9 @@ void vectorBitAnd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut,
|
||||||
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
||||||
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
||||||
|
|
||||||
int32_t leftConvert = 0, rightConvert = 0;
|
int32_t leftConvert = 0, rightConvert = 0;
|
||||||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert);
|
||||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert);
|
||||||
|
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||||
|
@ -1579,9 +1558,9 @@ void vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut,
|
||||||
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
||||||
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
||||||
|
|
||||||
int32_t leftConvert = 0, rightConvert = 0;
|
int32_t leftConvert = 0, rightConvert = 0;
|
||||||
SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert);
|
SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert);
|
||||||
SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert);
|
SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert);
|
||||||
|
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||||
|
@ -1605,8 +1584,8 @@ void vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut,
|
||||||
doReleaseVec(pRightCol, rightConvert);
|
doReleaseVec(pRightCol, rightConvert);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t doVectorCompareImpl(int32_t numOfRows, SScalarParam *pOut, int32_t startIndex, int32_t step, __compar_fn_t fp,
|
int32_t doVectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows,
|
||||||
SScalarParam *pLeft, SScalarParam *pRight, int32_t optr) {
|
int32_t step, __compar_fn_t fp, int32_t optr) {
|
||||||
int32_t num = 0;
|
int32_t num = 0;
|
||||||
|
|
||||||
for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) {
|
for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) {
|
||||||
|
@ -1659,12 +1638,14 @@ int32_t doVectorCompareImpl(int32_t numOfRows, SScalarParam *pOut, int32_t start
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) {
|
void doVectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows,
|
||||||
int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
int32_t _ord, int32_t optr) {
|
||||||
|
int32_t i = 0;
|
||||||
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1;
|
||||||
int32_t lType = GET_PARAM_TYPE(pLeft);
|
int32_t lType = GET_PARAM_TYPE(pLeft);
|
||||||
int32_t rType = GET_PARAM_TYPE(pRight);
|
int32_t rType = GET_PARAM_TYPE(pRight);
|
||||||
__compar_fn_t fp = NULL;
|
__compar_fn_t fp = NULL;
|
||||||
|
int32_t compRows = 0;
|
||||||
|
|
||||||
if (lType == rType) {
|
if (lType == rType) {
|
||||||
fp = filterGetCompFunc(lType, optr);
|
fp = filterGetCompFunc(lType, optr);
|
||||||
|
@ -1672,7 +1653,14 @@ void vectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *
|
||||||
fp = filterGetCompFuncEx(lType, rType, optr);
|
fp = filterGetCompFuncEx(lType, rType, optr);
|
||||||
}
|
}
|
||||||
|
|
||||||
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
if (startIndex < 0) {
|
||||||
|
i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1;
|
||||||
|
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||||
|
compRows = pOut->numOfRows;
|
||||||
|
} else {
|
||||||
|
compRows = startIndex + numOfRows;
|
||||||
|
i = startIndex;
|
||||||
|
}
|
||||||
|
|
||||||
if (pRight->pHashFilter != NULL) {
|
if (pRight->pHashFilter != NULL) {
|
||||||
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
||||||
|
@ -1690,13 +1678,14 @@ void vectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // normal compare
|
} else { // normal compare
|
||||||
pOut->numOfQualified = doVectorCompareImpl(pOut->numOfRows, pOut, i, step, fp, pLeft, pRight, optr);
|
pOut->numOfQualified = doVectorCompareImpl(pLeft, pRight, pOut, i, compRows, step, fp, optr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vectorCompare(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) {
|
void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows,
|
||||||
SScalarParam pLeftOut = {0};
|
int32_t _ord, int32_t optr) {
|
||||||
SScalarParam pRightOut = {0};
|
SScalarParam pLeftOut = {0};
|
||||||
|
SScalarParam pRightOut = {0};
|
||||||
SScalarParam *param1 = NULL;
|
SScalarParam *param1 = NULL;
|
||||||
SScalarParam *param2 = NULL;
|
SScalarParam *param2 = NULL;
|
||||||
|
|
||||||
|
@ -1704,7 +1693,7 @@ void vectorCompare(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut
|
||||||
param1 = pLeft;
|
param1 = pLeft;
|
||||||
param2 = pRight;
|
param2 = pRight;
|
||||||
} else {
|
} else {
|
||||||
vectorConvert(pLeft, pRight, &pLeftOut, &pRightOut);
|
vectorConvertCols(pLeft, pRight, &pLeftOut, &pRightOut, startIndex, numOfRows);
|
||||||
|
|
||||||
if (pLeftOut.columnData != NULL) {
|
if (pLeftOut.columnData != NULL) {
|
||||||
param1 = &pLeftOut;
|
param1 = &pLeftOut;
|
||||||
|
@ -1719,12 +1708,17 @@ void vectorCompare(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vectorCompareImpl(param1, param2, pOut, _ord, optr);
|
doVectorCompare(param1, param2, pOut, startIndex, numOfRows, _ord, optr);
|
||||||
|
|
||||||
sclFreeParam(&pLeftOut);
|
sclFreeParam(&pLeftOut);
|
||||||
sclFreeParam(&pRightOut);
|
sclFreeParam(&pRightOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vectorGreater(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) {
|
void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) {
|
||||||
|
vectorCompareImpl(pLeft, pRight, pOut, -1, -1, _ord, optr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void vectorGreater(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
||||||
vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_GREATER_THAN);
|
vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_GREATER_THAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1788,10 +1782,10 @@ void vectorNotNull(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut
|
||||||
pOut->numOfRows = pLeft->numOfRows;
|
pOut->numOfRows = pLeft->numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vectorIsTrue(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) {
|
void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
||||||
vectorConvertImpl(pLeft, pOut, NULL);
|
vectorConvertSingleColImpl(pLeft, pOut, NULL, -1, -1);
|
||||||
for (int32_t i = 0; i < pOut->numOfRows; ++i) {
|
for(int32_t i = 0; i < pOut->numOfRows; ++i) {
|
||||||
if (colDataIsNull_s(pOut->columnData, i)) {
|
if(colDataIsNull_s(pOut->columnData, i)) {
|
||||||
int8_t v = 0;
|
int8_t v = 0;
|
||||||
colDataAppendInt8(pOut->columnData, i, &v);
|
colDataAppendInt8(pOut->columnData, i, &v);
|
||||||
colDataSetNotNull_f(pOut->columnData->nullbitmap, i);
|
colDataSetNotNull_f(pOut->columnData->nullbitmap, i);
|
||||||
|
|
|
@ -67,7 +67,11 @@ void streamSchedByTimer(void* param, void* tmrId) {
|
||||||
|
|
||||||
atomic_store_8(&pTask->triggerStatus, TASK_TRIGGER_STATUS__INACTIVE);
|
atomic_store_8(&pTask->triggerStatus, TASK_TRIGGER_STATUS__INACTIVE);
|
||||||
|
|
||||||
streamTaskInput(pTask, (SStreamQueueItem*)trigger);
|
if (streamTaskInput(pTask, (SStreamQueueItem*)trigger) < 0) {
|
||||||
|
taosFreeQitem(trigger);
|
||||||
|
taosTmrReset(streamSchedByTimer, (int32_t)pTask->triggerParam, pTask, streamEnv.timer, &pTask->timer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
streamSchedExec(pTask);
|
streamSchedExec(pTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
|
||||||
sprintf(streamPath, "%s/%s", path, "stream");
|
sprintf(streamPath, "%s/%s", path, "stream");
|
||||||
pMeta->path = strdup(streamPath);
|
pMeta->path = strdup(streamPath);
|
||||||
if (tdbOpen(pMeta->path, 16 * 1024, 1, &pMeta->db) < 0) {
|
if (tdbOpen(pMeta->path, 16 * 1024, 1, &pMeta->db) < 0) {
|
||||||
|
taosMemoryFree(streamPath);
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
|
||||||
return pMeta;
|
return pMeta;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
if (pMeta->path) taosMemoryFree(pMeta->path);
|
taosMemoryFree(pMeta->path);
|
||||||
if (pMeta->pTasks) taosHashCleanup(pMeta->pTasks);
|
if (pMeta->pTasks) taosHashCleanup(pMeta->pTasks);
|
||||||
if (pMeta->pTaskDb) tdbTbClose(pMeta->pTaskDb);
|
if (pMeta->pTaskDb) tdbTbClose(pMeta->pTaskDb);
|
||||||
if (pMeta->pCheckpointDb) tdbTbClose(pMeta->pCheckpointDb);
|
if (pMeta->pCheckpointDb) tdbTbClose(pMeta->pCheckpointDb);
|
||||||
|
@ -250,6 +251,8 @@ int32_t streamLoadTasks(SStreamMeta* pMeta) {
|
||||||
while (tdbTbcNext(pCur, &pKey, &kLen, &pVal, &vLen) == 0) {
|
while (tdbTbcNext(pCur, &pKey, &kLen, &pVal, &vLen) == 0) {
|
||||||
SStreamTask* pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
|
SStreamTask* pTask = taosMemoryCalloc(1, sizeof(SStreamTask));
|
||||||
if (pTask == NULL) {
|
if (pTask == NULL) {
|
||||||
|
tdbFree(pKey);
|
||||||
|
tdbFree(pVal);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
tDecoderInit(&decoder, (uint8_t*)pVal, vLen);
|
||||||
|
@ -257,10 +260,14 @@ int32_t streamLoadTasks(SStreamMeta* pMeta) {
|
||||||
tDecoderClear(&decoder);
|
tDecoderClear(&decoder);
|
||||||
|
|
||||||
if (pMeta->expandFunc(pMeta->ahandle, pTask) < 0) {
|
if (pMeta->expandFunc(pMeta->ahandle, pTask) < 0) {
|
||||||
|
tdbFree(pKey);
|
||||||
|
tdbFree(pVal);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosHashPut(pMeta->pTasks, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void*)) < 0) {
|
if (taosHashPut(pMeta->pTasks, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void*)) < 0) {
|
||||||
|
tdbFree(pKey);
|
||||||
|
tdbFree(pVal);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int
|
||||||
sprintf(statePath, "%s/%d", path, pTask->taskId);
|
sprintf(statePath, "%s/%d", path, pTask->taskId);
|
||||||
} else {
|
} else {
|
||||||
memset(statePath, 0, 300);
|
memset(statePath, 0, 300);
|
||||||
strncpy(statePath, path, 300);
|
tstrncpy(statePath, path, 300);
|
||||||
}
|
}
|
||||||
if (tdbOpen(statePath, szPage, pages, &pState->db) < 0) {
|
if (tdbOpen(statePath, szPage, pages, &pState->db) < 0) {
|
||||||
goto _err;
|
goto _err;
|
||||||
|
|
|
@ -174,14 +174,9 @@ bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) {
|
||||||
if (res == TSDB_CODE_SUCCESS) {
|
if (res == TSDB_CODE_SUCCESS) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
qDebug("===stream===Update close window sbf. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64
|
|
||||||
", ts:%" PRIu64,
|
|
||||||
tableId, maxTs, *pMapMaxTs, ts);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug("===stream===Update close window. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64,
|
|
||||||
tableId, maxTs, *pMapMaxTs, ts);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,14 +198,10 @@ bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ts < pInfo->minTS) {
|
if (ts < pInfo->minTS) {
|
||||||
qDebug("===stream===Update min ts. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64,
|
|
||||||
tableId, maxTs, *pMapMaxTs, ts);
|
|
||||||
return true;
|
return true;
|
||||||
} else if (res == TSDB_CODE_SUCCESS) {
|
} else if (res == TSDB_CODE_SUCCESS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qDebug("===stream===Update. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64, tableId,
|
|
||||||
maxTs, *pMapMaxTs, ts);
|
|
||||||
// check from tsdb api
|
// check from tsdb api
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,9 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage
|
||||||
static int tdbPagerWritePageToJournal(SPager *pPager, SPage *pPage);
|
static int tdbPagerWritePageToJournal(SPager *pPager, SPage *pPage);
|
||||||
static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage);
|
static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage);
|
||||||
|
|
||||||
static FORCE_INLINE int32_t pageCmpFn(const void *lhs, const void *rhs) {
|
static FORCE_INLINE int32_t pageCmpFn(const SRBTreeNode *lhs, const SRBTreeNode *rhs) {
|
||||||
SPage *pPageL = (SPage *)(((uint8_t *)lhs) - sizeof(SRBTreeNode));
|
SPage *pPageL = (SPage *)(((uint8_t *)lhs) - offsetof(SPage, node));
|
||||||
SPage *pPageR = (SPage *)(((uint8_t *)rhs) - sizeof(SRBTreeNode));
|
SPage *pPageR = (SPage *)(((uint8_t *)rhs) - offsetof(SPage, node));
|
||||||
|
|
||||||
SPgno pgnoL = TDB_PAGE_PGNO(pPageL);
|
SPgno pgnoL = TDB_PAGE_PGNO(pPageL);
|
||||||
SPgno pgnoR = TDB_PAGE_PGNO(pPageR);
|
SPgno pgnoR = TDB_PAGE_PGNO(pPageR);
|
||||||
|
|
|
@ -351,7 +351,10 @@ int walCheckAndRepairIdx(SWal* pWal) {
|
||||||
taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry));
|
taosWriteFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
taosLSeekFile(pIdxFile, offset, SEEK_SET);
|
if (taosLSeekFile(pIdxFile, offset, SEEK_SET) < 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
wError("vgId:%d cannot seek offset %ld when repair idx since %s", pWal->cfg.vgId, offset, terrstr());
|
||||||
|
}
|
||||||
int64_t contLen = taosReadFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry));
|
int64_t contLen = taosReadFile(pIdxFile, &idxEntry, sizeof(SWalIdxEntry));
|
||||||
if (contLen < 0 || contLen != sizeof(SWalIdxEntry)) {
|
if (contLen < 0 || contLen != sizeof(SWalIdxEntry)) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
@ -636,6 +639,5 @@ int walRemoveMeta(SWal* pWal) {
|
||||||
if (metaVer == -1) return 0;
|
if (metaVer == -1) return 0;
|
||||||
char fnameStr[WAL_FILE_LEN];
|
char fnameStr[WAL_FILE_LEN];
|
||||||
walBuildMetaName(pWal, metaVer, fnameStr);
|
walBuildMetaName(pWal, metaVer, fnameStr);
|
||||||
taosRemoveFile(fnameStr);
|
return taosRemoveFile(fnameStr);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -514,7 +514,6 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
||||||
pReader->pHead->head.version, ver);
|
pReader->pHead->head.version, ver);
|
||||||
pReader->curInvalid = 1;
|
pReader->curInvalid = 1;
|
||||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||||
ASSERT(0);
|
|
||||||
taosThreadMutexUnlock(&pReader->mutex);
|
taosThreadMutexUnlock(&pReader->mutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +527,6 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) {
|
||||||
wError("checksum written into log:%u, checksum calculated:%u", logCkSum, readCkSum);
|
wError("checksum written into log:%u, checksum calculated:%u", logCkSum, readCkSum);
|
||||||
pReader->curInvalid = 1;
|
pReader->curInvalid = 1;
|
||||||
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
|
||||||
ASSERT(0);
|
|
||||||
taosThreadMutexUnlock(&pReader->mutex);
|
taosThreadMutexUnlock(&pReader->mutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,20 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) {
|
||||||
SWalFileInfo *pFileInfo = taosArrayGet(pWal->fileInfoSet, i);
|
SWalFileInfo *pFileInfo = taosArrayGet(pWal->fileInfoSet, i);
|
||||||
char fnameStr[WAL_FILE_LEN];
|
char fnameStr[WAL_FILE_LEN];
|
||||||
walBuildLogName(pWal, pFileInfo->firstVer, fnameStr);
|
walBuildLogName(pWal, pFileInfo->firstVer, fnameStr);
|
||||||
taosRemoveFile(fnameStr);
|
if (taosRemoveFile(fnameStr) < 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
wError("vgId:%d restore from snapshot, cannot remove file %s since %s", pWal->cfg.vgId, fnameStr, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
wInfo("vgId:%d restore from snapshot, remove file %s", pWal->cfg.vgId, fnameStr);
|
||||||
|
|
||||||
walBuildIdxName(pWal, pFileInfo->firstVer, fnameStr);
|
walBuildIdxName(pWal, pFileInfo->firstVer, fnameStr);
|
||||||
taosRemoveFile(fnameStr);
|
if (taosRemoveFile(fnameStr) < 0) {
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
wError("vgId:%d cannot remove file %s since %s", pWal->cfg.vgId, fnameStr, terrstr());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
wInfo("vgId:%d restore from snapshot, remove file %s", pWal->cfg.vgId, fnameStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
walRemoveMeta(pWal);
|
walRemoveMeta(pWal);
|
||||||
|
|
|
@ -219,7 +219,7 @@ SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z) {
|
||||||
while (temp != pTree->NIL) {
|
while (temp != pTree->NIL) {
|
||||||
y = temp;
|
y = temp;
|
||||||
|
|
||||||
int32_t c = pTree->cmprFn(RBTREE_NODE_PAYLOAD(z), RBTREE_NODE_PAYLOAD(temp));
|
int32_t c = pTree->cmprFn(z, temp);
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
temp = temp->left;
|
temp = temp->left;
|
||||||
} else if (c > 0) {
|
} else if (c > 0) {
|
||||||
|
@ -232,7 +232,7 @@ SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z) {
|
||||||
|
|
||||||
if (y == pTree->NIL) {
|
if (y == pTree->NIL) {
|
||||||
pTree->root = z;
|
pTree->root = z;
|
||||||
} else if (pTree->cmprFn(RBTREE_NODE_PAYLOAD(z), RBTREE_NODE_PAYLOAD(y)) < 0) {
|
} else if (pTree->cmprFn(z, y) < 0) {
|
||||||
y->left = z;
|
y->left = z;
|
||||||
} else {
|
} else {
|
||||||
y->right = z;
|
y->right = z;
|
||||||
|
@ -245,10 +245,10 @@ SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z) {
|
||||||
tRBTreePutFix(pTree, z);
|
tRBTreePutFix(pTree, z);
|
||||||
|
|
||||||
// update min/max node
|
// update min/max node
|
||||||
if (pTree->min == pTree->NIL || pTree->cmprFn(RBTREE_NODE_PAYLOAD(pTree->min), RBTREE_NODE_PAYLOAD(z)) > 0) {
|
if (pTree->min == pTree->NIL || pTree->cmprFn(pTree->min, z) > 0) {
|
||||||
pTree->min = z;
|
pTree->min = z;
|
||||||
}
|
}
|
||||||
if (pTree->max == pTree->NIL || pTree->cmprFn(RBTREE_NODE_PAYLOAD(pTree->max), RBTREE_NODE_PAYLOAD(z)) < 0) {
|
if (pTree->max == pTree->NIL || pTree->cmprFn(pTree->max, z) < 0) {
|
||||||
pTree->max = z;
|
pTree->max = z;
|
||||||
}
|
}
|
||||||
pTree->n++;
|
pTree->n++;
|
||||||
|
@ -309,11 +309,11 @@ SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey) {
|
||||||
return pNode;
|
return pNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRBTreeNode *tRBTreeGet(SRBTree *pTree, void *pKey) {
|
SRBTreeNode *tRBTreeGet(SRBTree *pTree, const SRBTreeNode *pKeyNode) {
|
||||||
SRBTreeNode *pNode = pTree->root;
|
SRBTreeNode *pNode = pTree->root;
|
||||||
|
|
||||||
while (pNode != pTree->NIL) {
|
while (pNode != pTree->NIL) {
|
||||||
int32_t c = pTree->cmprFn(pKey, RBTREE_NODE_PAYLOAD(pNode));
|
int32_t c = pTree->cmprFn(pKeyNode, pNode);
|
||||||
|
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
pNode = pNode->left;
|
pNode = pNode->left;
|
||||||
|
|
|
@ -145,7 +145,10 @@ void tSkipListPutBatchByIter(SSkipList *pSkipList, void *iter, iter_next_fn_t it
|
||||||
tSkipListWLock(pSkipList);
|
tSkipListWLock(pSkipList);
|
||||||
|
|
||||||
void *pData = iterate(iter);
|
void *pData = iterate(iter);
|
||||||
if (pData == NULL) return;
|
if (pData == NULL) {
|
||||||
|
tSkipListUnlock(pSkipList);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// backward to put the first data
|
// backward to put the first data
|
||||||
hasDup = tSkipListGetPosToPut(pSkipList, backward, pData);
|
hasDup = tSkipListGetPosToPut(pSkipList, backward, pData);
|
||||||
|
|
|
@ -352,6 +352,7 @@
|
||||||
./test.sh -f tsim/scalar/in.sim
|
./test.sh -f tsim/scalar/in.sim
|
||||||
./test.sh -f tsim/scalar/scalar.sim
|
./test.sh -f tsim/scalar/scalar.sim
|
||||||
./test.sh -f tsim/scalar/filter.sim
|
./test.sh -f tsim/scalar/filter.sim
|
||||||
|
./test.sh -f tsim/scalar/caseWhen.sim
|
||||||
|
|
||||||
# ---- alter ----
|
# ---- alter ----
|
||||||
./test.sh -f tsim/alter/cached_schema_after_alter.sim
|
./test.sh -f tsim/alter/cached_schema_after_alter.sim
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -302,7 +302,7 @@ python3 ./test.py -f 7-tmq/tmqCheckData.py
|
||||||
python3 ./test.py -f 7-tmq/tmqCheckData1.py
|
python3 ./test.py -f 7-tmq/tmqCheckData1.py
|
||||||
#python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5
|
#python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 5
|
||||||
python3 ./test.py -f 7-tmq/tmqConsumerGroup.py
|
python3 ./test.py -f 7-tmq/tmqConsumerGroup.py
|
||||||
python3 ./test.py -f 7-tmq/tmqShow.py
|
#python3 ./test.py -f 7-tmq/tmqShow.py
|
||||||
python3 ./test.py -f 7-tmq/tmqAlterSchema.py
|
python3 ./test.py -f 7-tmq/tmqAlterSchema.py
|
||||||
python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py
|
||||||
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py
|
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py
|
||||||
|
|
|
@ -998,7 +998,9 @@ void *shellCancelHandler(void *arg) {
|
||||||
shell.stop_query = true;
|
shell.stop_query = true;
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
taos_kill_query(shell.conn);
|
if (shell.conn) {
|
||||||
|
taos_kill_query(shell.conn);
|
||||||
|
}
|
||||||
#ifdef WEBSOCKET
|
#ifdef WEBSOCKET
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue