Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/TD-30837

This commit is contained in:
54liuyao 2024-07-30 19:13:59 +08:00
commit 8b182cac9b
13 changed files with 348 additions and 85 deletions

View File

@ -87,7 +87,7 @@ int32_t getJsonValueLen(const char* data) {
}
int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull) {
if (isNull) {
if (isNull || pData == NULL) {
// There is a placehold for each NULL value of binary or nchar type.
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
pColumnInfoData->varmeta.offset[rowIndex] = -1; // it is a null value of VAR type.

View File

@ -1020,10 +1020,10 @@ static int32_t doSetCheckpointAction(SMnode *pMnode, STrans *pTrans, SStreamTask
static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStream, int64_t checkpointId,
int8_t mndTrigger, bool lock) {
int32_t code = -1;
int32_t code = TSDB_CODE_SUCCESS;
int64_t ts = taosGetTimestampMs();
if (mndTrigger == 1 && (ts - pStream->checkpointFreq < tsStreamCheckpointInterval * 1000)) {
return TSDB_CODE_SUCCESS;
return code;
}
bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHECKPOINT_NAME, lock);
@ -1087,13 +1087,11 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre
goto _ERR;
}
if ((code = mndTransPrepare(pMnode, pTrans)) != TSDB_CODE_SUCCESS) {
code = terrno;
code = mndTransPrepare(pMnode, pTrans);
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("failed to prepare checkpoint trans since %s", terrstr());
goto _ERR;
}
code = 0;
_ERR:
mndTransDrop(pTrans);
return code;
@ -1458,7 +1456,8 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
return -1;
}
if (mndTransPrepare(pMnode, pTrans) != 0) {
code = mndTransPrepare(pMnode, pTrans);
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, terrstr());
sdbRelease(pMnode->pSdb, pStream);
mndTransDrop(pTrans);
@ -2179,7 +2178,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) {
taosWUnLockLatch(&pStream->lock);
code = mndTransPrepare(pMnode, pTrans);
if (code) {
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("trans:%d, failed to prepare pause stream trans since %s", pTrans->id, terrstr());
sdbRelease(pMnode->pSdb, pStream);
mndTransDrop(pTrans);
@ -2273,7 +2272,8 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
}
taosWUnLockLatch(&pStream->lock);
if (mndTransPrepare(pMnode, pTrans) != 0) {
code = mndTransPrepare(pMnode, pTrans);
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("trans:%d, failed to prepare pause stream trans since %s", pTrans->id, terrstr());
sdbRelease(pMnode->pSdb, pStream);
mndTransDrop(pTrans);
@ -2434,7 +2434,7 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange
}
code = mndTransPrepare(pMnode, pTrans);
if (code) {
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr());
sdbRelease(pMnode->pSdb, pStream);
mndTransDrop(pTrans);
@ -3129,7 +3129,7 @@ int32_t mndCreateStreamChkptInfoUpdateTrans(SMnode *pMnode, SStreamObj *pStream,
}
code = mndTransPrepare(pMnode, pTrans);
if (code) {
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("trans:%d, failed to prepare update checkpoint-info meta trans since %s", pTrans->id, terrstr());
sdbRelease(pMnode->pSdb, pStream);
mndTransDrop(pTrans);

View File

@ -94,7 +94,7 @@ int32_t mndCreateStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream) {
}
code = mndTransPrepare(pMnode, pTrans);
if (code != 0) {
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("trans:%d, failed to prepare update stream trans since %s", pTrans->id, terrstr());
sdbRelease(pMnode->pSdb, pStream);
mndTransDrop(pTrans);
@ -197,7 +197,8 @@ int32_t mndDropOrphanTasks(SMnode *pMnode, SArray *pList) {
return code;
}
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
code = mndTransPrepare(pMnode, pTrans);
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, terrstr());
mndTransDrop(pTrans);
return code;

View File

@ -1132,7 +1132,7 @@ int32_t mndCreateSetConsensusChkptIdTrans(SMnode *pMnode, SStreamObj *pStream, i
}
code = mndTransPrepare(pMnode, pTrans);
if (code) {
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) {
mError("trans:%d, failed to prepare set consensus-chkptId trans since %s", pTrans->id, terrstr());
sdbRelease(pMnode->pSdb, pStream);
mndTransDrop(pTrans);

View File

@ -301,8 +301,10 @@ static int32_t binarySearchForStartRowIndex(uint64_t *uidList, int32_t num, uint
static int32_t extractSttBlockInfo(SLDataIter *pIter, const TSttBlkArray *pArray, SSttBlockLoadInfo *pBlockLoadInfo,
uint64_t suid) {
void *px = NULL;
int32_t code = TSDB_CODE_SUCCESS;
if (TARRAY2_SIZE(pArray) <= 0) {
return TSDB_CODE_SUCCESS;
return code;
}
SSttBlk *pStart = &pArray->data[0];
@ -316,10 +318,17 @@ static int32_t extractSttBlockInfo(SLDataIter *pIter, const TSttBlkArray *pArray
return TSDB_CODE_SUCCESS;
} else { // all blocks are qualified
taosArrayClear(pBlockLoadInfo->aSttBlk);
taosArrayAddBatch(pBlockLoadInfo->aSttBlk, pArray->data, pArray->size);
px = taosArrayAddBatch(pBlockLoadInfo->aSttBlk, pArray->data, pArray->size);
if (px == NULL){
return terrno;
}
}
} else {
SArray *pTmp = taosArrayInit(TARRAY2_SIZE(pArray), sizeof(SSttBlk));
if (pTmp == NULL) {
return terrno;
}
for (int32_t i = 0; i < TARRAY2_SIZE(pArray); ++i) {
SSttBlk *p = &pArray->data[i];
if (p->suid < suid) {
@ -327,7 +336,11 @@ static int32_t extractSttBlockInfo(SLDataIter *pIter, const TSttBlkArray *pArray
}
if (p->suid == suid) {
taosArrayPush(pTmp, p);
void* px = taosArrayPush(pTmp, p);
if (px == NULL) {
code = terrno;
break;
}
} else if (p->suid > suid) {
break;
}
@ -337,7 +350,7 @@ static int32_t extractSttBlockInfo(SLDataIter *pIter, const TSttBlkArray *pArray
pBlockLoadInfo->aSttBlk = pTmp;
}
return TSDB_CODE_SUCCESS;
return code;
}
static int32_t tValueDupPayload(SValue *pVal) {
@ -357,9 +370,11 @@ static int32_t tValueDupPayload(SValue *pVal) {
static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBlockLoadInfo *pBlockLoadInfo,
TStatisBlkArray *pStatisBlkArray, uint64_t suid, const char *id) {
int32_t code = TSDB_CODE_SUCCESS;
void* px = NULL;
int32_t numOfBlocks = TARRAY2_SIZE(pStatisBlkArray);
if (numOfBlocks <= 0) {
return 0;
return code;
}
int32_t startIndex = 0;
@ -385,7 +400,10 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
int64_t st = taosGetTimestampUs();
for (int32_t k = startIndex; k < endIndex; ++k) {
tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[k], &block);
code = tsdbSttFileReadStatisBlock(pSttFileReader, &pStatisBlkArray->data[k], &block);
if (code) {
return code;
}
int32_t i = 0;
int32_t rows = block.numOfRecords;
@ -409,21 +427,43 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
int32_t size = rows - i;
int32_t offset = i * sizeof(int64_t);
taosArrayAddBatch(pBlockLoadInfo->info.pUid, tBufferGetDataAt(&block.uids, offset), size);
taosArrayAddBatch(pBlockLoadInfo->info.pFirstTs, tBufferGetDataAt(&block.firstKeyTimestamps, offset), size);
taosArrayAddBatch(pBlockLoadInfo->info.pLastTs, tBufferGetDataAt(&block.lastKeyTimestamps, offset), size);
taosArrayAddBatch(pBlockLoadInfo->info.pCount, tBufferGetDataAt(&block.counts, offset), size);
px = taosArrayAddBatch(pBlockLoadInfo->info.pUid, tBufferGetDataAt(&block.uids, offset), size);
if (px == NULL) {
return terrno;
}
px = taosArrayAddBatch(pBlockLoadInfo->info.pFirstTs, tBufferGetDataAt(&block.firstKeyTimestamps, offset), size);
if (px == NULL){
return terrno;
}
px = taosArrayAddBatch(pBlockLoadInfo->info.pLastTs, tBufferGetDataAt(&block.lastKeyTimestamps, offset), size);
if (px == NULL){
return terrno;
}
px = taosArrayAddBatch(pBlockLoadInfo->info.pCount, tBufferGetDataAt(&block.counts, offset), size);
if (px == NULL){
return terrno;
}
if (block.numOfPKs > 0) {
SValue vFirst = {0}, vLast = {0};
for (int32_t f = i; f < rows; ++f) {
int32_t code = tValueColumnGet(&block.firstKeyPKs[0], f, &vFirst);
code = tValueColumnGet(&block.firstKeyPKs[0], f, &vFirst);
if (code) {
break;
}
tValueDupPayload(&vFirst);
taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst);
code = tValueDupPayload(&vFirst);
if (code) {
break;
}
px = taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst);
if (px == NULL) {
return terrno;
}
// todo add api to clone the original data
code = tValueColumnGet(&block.lastKeyPKs[0], f, &vLast);
@ -431,14 +471,28 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
break;
}
tValueDupPayload(&vLast);
taosArrayPush(pBlockLoadInfo->info.pLastKey, &vLast);
code = tValueDupPayload(&vLast);
if (code) {
break;
}
px = taosArrayPush(pBlockLoadInfo->info.pLastKey, &vLast);
if (px == NULL) {
return terrno;
}
}
} else {
SValue vFirst = {0};
for (int32_t j = 0; j < size; ++j) {
taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst);
taosArrayPush(pBlockLoadInfo->info.pLastKey, &vFirst);
px = taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst);
if (px == NULL) {
return terrno;
}
px = taosArrayPush(pBlockLoadInfo->info.pLastKey, &vFirst);
if (px == NULL) {
return terrno;
}
}
}
} else {
@ -450,24 +504,59 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
break;
}
taosArrayPush(pBlockLoadInfo->info.pUid, &record.uid);
taosArrayPush(pBlockLoadInfo->info.pCount, &record.count);
px = taosArrayPush(pBlockLoadInfo->info.pUid, &record.uid);
if (px == NULL) {
return terrno;
}
taosArrayPush(pBlockLoadInfo->info.pFirstTs, &record.firstKey.ts);
taosArrayPush(pBlockLoadInfo->info.pLastTs, &record.lastKey.ts);
px = taosArrayPush(pBlockLoadInfo->info.pCount, &record.count);
if (px == NULL) {
return terrno;
}
px = taosArrayPush(pBlockLoadInfo->info.pFirstTs, &record.firstKey.ts);
if (px == NULL) {
return terrno;
}
px = taosArrayPush(pBlockLoadInfo->info.pLastTs, &record.lastKey.ts);
if (px == NULL) {
return terrno;
}
if (record.firstKey.numOfPKs > 0) {
SValue s = record.firstKey.pks[0];
tValueDupPayload(&s);
taosArrayPush(pBlockLoadInfo->info.pFirstKey, &s);
code = tValueDupPayload(&s);
if (code) {
return code;
}
px = taosArrayPush(pBlockLoadInfo->info.pFirstKey, &s);
if (px == NULL) {
return terrno;
}
s = record.lastKey.pks[0];
tValueDupPayload(&s);
taosArrayPush(pBlockLoadInfo->info.pLastKey, &s);
code = tValueDupPayload(&s);
if (code) {
return code;
}
px = taosArrayPush(pBlockLoadInfo->info.pLastKey, &s);
if (px == NULL) {
return terrno;
}
} else {
SValue v = {0};
taosArrayPush(pBlockLoadInfo->info.pFirstKey, &v);
taosArrayPush(pBlockLoadInfo->info.pLastKey, &v);
px = taosArrayPush(pBlockLoadInfo->info.pFirstKey, &v);
if (px == NULL) {
return terrno;
}
px = taosArrayPush(pBlockLoadInfo->info.pLastKey, &v);
if (px == NULL) {
return terrno;
}
}
i += 1;
@ -482,7 +571,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl
pBlockLoadInfo->cost.statisElapsedTime += el;
tsdbDebug("%s load %d statis blocks into buf, elapsed time:%.2fms", id, num, el);
return TSDB_CODE_SUCCESS;
return code;
}
static int32_t doLoadSttFilesBlk(SSttBlockLoadInfo *pBlockLoadInfo, SLDataIter *pIter, int64_t suid,
@ -617,7 +706,7 @@ int32_t tLDataIterOpen2(SLDataIter *pIter, SSttFileReader *pSttFileReader, int32
}
void tLDataIterClose2(SLDataIter *pIter) {
tsdbSttFileReaderClose(&pIter->pReader);
(void) tsdbSttFileReaderClose(&pIter->pReader); // always return 0
pIter->pReader = NULL;
}
@ -890,7 +979,10 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoF
goto _end;
}
adjustSttDataIters(pConf->pSttFileBlockIterArray, pConf->pCurrentFileset);
code = adjustSttDataIters(pConf->pSttFileBlockIterArray, pConf->pCurrentFileset);
if (code) {
goto _end;
}
for (int32_t j = 0; j < numOfLevels; ++j) {
SSttLvl *pSttLevel = ((STFileSet *)pConf->pCurrentFileset)->lvlArr->data[j];
@ -940,7 +1032,10 @@ int32_t tMergeTreeOpen2(SMergeTree *pMTree, SMergeTreeConf *pConf, SSttDataInfoF
// let's record the time window for current table of uid in the stt files
if (pSttDataInfo != NULL && numOfRows > 0) {
taosArrayPush(pSttDataInfo->pKeyRangeList, &range);
void* px = taosArrayPush(pSttDataInfo->pKeyRangeList, &range);
if (px == NULL) {
return terrno;
}
pSttDataInfo->numOfRows += numOfRows;
}
} else {
@ -958,7 +1053,7 @@ _end:
return code;
}
void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter) { tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pIter); }
void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter) { (void) tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pIter); }
bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree) { return pMTree->ignoreEarlierTs; }
@ -1035,7 +1130,7 @@ bool tMergeTreeNext(SMergeTree *pMTree) {
if (pMTree->pIter && pIter) {
int32_t c = pMTree->rbt.cmprFn(&pMTree->pIter->node, &pIter->node);
if (c > 0) {
tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter);
(void) tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter);
pMTree->pIter = NULL;
} else {
ASSERT(c);

View File

@ -101,7 +101,10 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t
return terrno;
}
taosArrayPush(pBucket->pPageIdList, &newPageId);
void* px = taosArrayPush(pBucket->pPageIdList, &newPageId);
if (px == NULL) {
return terrno;
}
doCopyObject(pNewPage->data, key, keyLen, data, size);
pNewPage->num = sizeof(SFilePage) + nodeSize;
@ -127,7 +130,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
char* p = (char*)pNode + len;
char* pEnd = (char*)pPage + pPage->num;
memmove(pNode, p, (pEnd - p));
(void) memmove(pNode, p, (pEnd - p));
pPage->num -= len;
if (pPage->num == 0) {
@ -189,7 +192,7 @@ static void doTrimBucketPages(SLHashObj* pHashObj, SLHashBucket* pBucket) {
nodeSize = GET_LHASH_NODE_LEN(pStart);
} else { // move to the front of pLast page
if (pStart != pLast->data) {
memmove(pLast->data, pStart, (((char*)pLast) + pLast->num - pStart));
(void) memmove(pLast->data, pStart, (((char*)pLast) + pLast->num - pStart));
setBufPageDirty(pLast, true);
}
@ -235,7 +238,10 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) {
setBufPageDirty(p, true);
releaseBufPage(pHashObj->pBuf, p);
taosArrayPush(pBucket->pPageIdList, &pageId);
void* px = taosArrayPush(pBucket->pPageIdList, &pageId);
if (px == NULL) {
return terrno;
}
pHashObj->numOfBuckets += 1;
// printf("---------------add new bucket, id:0x%x, total:%d\n", pHashObj->numOfBuckets - 1, pHashObj->numOfBuckets);
@ -251,7 +257,7 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
if (!osTempSpaceAvailable()) {
terrno = TSDB_CODE_NO_DISKSPACE;
printf("tHash Init failed since %s, tempDir:%s", terrstr(), tsTempDir);
(void) printf("tHash Init failed since %s, tempDir:%s", terrstr(), tsTempDir);
taosMemoryFree(pHashObj);
return NULL;
}
@ -301,9 +307,10 @@ void* tHashCleanup(SLHashObj* pHashObj) {
}
int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data, size_t size) {
int32_t code = 0;
if (pHashObj->bits == 0) {
SLHashBucket* pBucket = pHashObj->pBucket[0];
doAddToBucket(pHashObj, pBucket, 0, key, keyLen, data, size);
code = doAddToBucket(pHashObj, pBucket, 0, key, keyLen, data, size);
} else {
int32_t hashVal = pHashObj->hashFn(key, keyLen);
int32_t v = doGetBucketIdFromHashVal(hashVal, pHashObj->bits);
@ -315,10 +322,11 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data
}
SLHashBucket* pBucket = pHashObj->pBucket[v];
int32_t code = doAddToBucket(pHashObj, pBucket, v, key, keyLen, data, size);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
code = doAddToBucket(pHashObj, pBucket, v, key, keyLen, data, size);
}
if (code) {
return code;
}
pHashObj->size += 1;
@ -327,7 +335,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data
if ((pHashObj->numOfBuckets * LHASH_CAP_RATIO * pHashObj->tuplesPerPage) < pHashObj->size) {
int32_t newBucketId = pHashObj->numOfBuckets;
int32_t code = doAddNewBucket(pHashObj);
code = doAddNewBucket(pHashObj);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
@ -362,7 +370,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data
ASSERT(v1 == newBucketId);
// printf("move key:%d to 0x%x bucket, remain items:%d\n", *(int32_t*)k, v1, pBucket->size - 1);
SLHashBucket* pNewBucket = pHashObj->pBucket[newBucketId];
doAddToBucket(pHashObj, pNewBucket, newBucketId, (void*)GET_LHASH_NODE_KEY(pNode), pNode->keyLen,
code = doAddToBucket(pHashObj, pNewBucket, newBucketId, (void*)GET_LHASH_NODE_KEY(pNode), pNode->keyLen,
GET_LHASH_NODE_KEY(pNode), pNode->dataLen);
doRemoveFromBucket(p, pNode, pBucket);
} else {
@ -377,7 +385,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data
doTrimBucketPages(pHashObj, pBucket);
}
return TSDB_CODE_SUCCESS;
return code;
}
char* tHashGet(SLHashObj* pHashObj, const void* key, size_t keyLen) {
@ -420,8 +428,8 @@ int32_t tHashRemove(SLHashObj* pHashObj, const void* key, size_t keyLen) {
}
void tHashPrint(const SLHashObj* pHashObj, int32_t type) {
printf("==================== linear hash ====================\n");
printf("total bucket:%d, size:%" PRId64 ", ratio:%.2f\n", pHashObj->numOfBuckets, pHashObj->size, LHASH_CAP_RATIO);
(void) printf("==================== linear hash ====================\n");
(void) printf("total bucket:%d, size:%" PRId64 ", ratio:%.2f\n", pHashObj->numOfBuckets, pHashObj->size, LHASH_CAP_RATIO);
dBufSetPrintInfo(pHashObj->pBuf);

View File

@ -1176,27 +1176,6 @@ EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
}
}
if (node->pRight && (QUERY_NODE_NODE_LIST == nodeType(node->pRight))) {
SNodeListNode *listNode = (SNodeListNode *)node->pRight;
SNode *tnode = NULL;
WHERE_EACH(tnode, listNode->pNodeList) {
if (SCL_IS_NULL_VALUE_NODE(tnode)) {
if (node->opType == OP_TYPE_IN) {
ERASE_NODE(listNode->pNodeList);
continue;
} else { // OP_TYPE_NOT_IN
return sclRewriteNullInOptr(pNode, ctx, node->opType);
}
}
WHERE_NEXT;
}
if (listNode->pNodeList->length <= 0) {
return sclRewriteNullInOptr(pNode, ctx, node->opType);
}
}
return DEAL_RES_CONTINUE;
}
@ -1334,6 +1313,27 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
return DEAL_RES_ERROR;
}
if (node->pRight && (QUERY_NODE_NODE_LIST == nodeType(node->pRight))) {
SNodeListNode *listNode = (SNodeListNode *)node->pRight;
SNode *tnode = NULL;
WHERE_EACH(tnode, listNode->pNodeList) {
if (SCL_IS_NULL_VALUE_NODE(tnode)) {
if (node->opType == OP_TYPE_IN) {
ERASE_NODE(listNode->pNodeList);
continue;
} else { // OP_TYPE_NOT_IN
return sclRewriteNullInOptr(pNode, ctx, node->opType);
}
}
WHERE_NEXT;
}
if (listNode->pNodeList->length <= 0) {
return sclRewriteNullInOptr(pNode, ctx, node->opType);
}
}
if ((!SCL_IS_CONST_NODE(node->pLeft)) || (!SCL_IS_CONST_NODE(node->pRight))) {
return sclRewriteNonConstOperator(pNode, ctx);
}

View File

@ -793,7 +793,7 @@ int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut,
return vectorConvertFromVarData(&cCtx, overflow);
}
if (overflow) {
if (overflow && TSDB_DATA_TYPE_NULL != cCtx.inType) {
if (1 != pIn->numOfRows) {
sclError("invalid numOfRows %d", pIn->numOfRows);
return TSDB_CODE_APP_ERROR;

View File

@ -560,6 +560,8 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -R
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Now.py
@ -739,6 +741,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 2
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 2
@ -837,6 +840,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 3
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 3
@ -934,6 +938,7 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/Today.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/normal.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/mode.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count.py -Q 4
,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 4

View File

@ -0,0 +1,143 @@
from wsgiref.headers import tspecials
from util.log import *
from util.cases import *
from util.sql import *
import numpy as np
class TDTestCase:
def init(self, conn, logSql, replicaVar=1):
self.replicaVar = int(replicaVar)
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor())
self.dbname = "db"
self.rowNum = 10
self.ts = 1537146000000
def inAndNotinTest(self):
dbname = self.dbname
tdSql.query(f"select 1 in (1, 2)")
tdSql.checkRows(1)
tdSql.checkData(0, 0, True)
tdSql.query(f"select 1 in (2, 3)")
tdSql.checkRows(1)
tdSql.checkData(0, 0, False)
tdSql.query(f"select 1 not in (2, 3)")
tdSql.checkRows(1)
tdSql.checkData(0, 0, True)
tdSql.query(f"select 1 not in (1)")
tdSql.checkRows(1)
tdSql.checkData(0, 0, False)
tdSql.query(f"select 1 in (1, null)")
tdSql.checkRows(1)
tdSql.checkData(0, 0, True)
tdSql.query(f"select 1 in (2, null)")
tdSql.checkRows(1)
tdSql.checkData(0, 0, False) # 1 not in (2, null) is NULL?
tdSql.query(f"select 1 not in (1, null)")
tdSql.checkRows(1)
tdSql.checkData(0, 0, False)
tdSql.query(f"select 1 not in (2, null)")
tdSql.checkRows(1)
tdSql.checkData(0, 0, False) # 1 not in (2, null) is NULL?
tdSql.query(f"select 1 not in (null)")
tdSql.checkRows(1)
tdSql.checkData(0, 0, False) # 1 not in (null) is NULL?
tdSql.execute(f'''create table {dbname}.stb(ts timestamp, col1 int, col2 nchar(20)) tags(loc nchar(20))''')
tdSql.execute(f"create table {dbname}.stb_1 using {dbname}.stb tags('beijing')")
tdSql.execute(f"create table {dbname}.stb_2 using {dbname}.stb tags('shanghai')")
for i in range(self.rowNum):
tdSql.execute(f"insert into {dbname}.stb_1 values({self.ts + i + 1}, {i+1}, 'taosdata_{i+1}')" )
for i in range(self.rowNum):
tdSql.execute(f"insert into {dbname}.stb_2 values({self.ts + i + 1}, {i+1}, 'taosdata_{i+1}')" )
tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 2) order by ts")
tdSql.checkRows(2)
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 2)
tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 9, 3) order by ts")
tdSql.checkRows(3)
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 3)
tdSql.checkData(2, 1, 9)
tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 9, 3, 'xy') order by ts")
tdSql.checkRows(3)
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 3)
tdSql.checkData(2, 1, 9)
tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, '9', 3) order by ts")
tdSql.checkRows(3)
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 3)
tdSql.checkData(2, 1, 9)
tdSql.query(f"select * from {dbname}.stb_1 where col1 in (1, 9, 3, null) order by ts")
tdSql.checkRows(3)
tdSql.checkData(0, 1, 1)
tdSql.checkData(1, 1, 3)
tdSql.checkData(2, 1, 9)
tdSql.query(f"select * from {dbname}.stb_1 where col2 in (1, 'taosdata_1', 3, null) order by ts")
tdSql.checkRows(1)
tdSql.checkData(0, 1, 1)
tdSql.query(f"select * from {dbname}.stb_1 where col2 not in (1, 'taosdata_1', 3, null) order by ts")
tdSql.checkRows(0)
tdSql.execute(f"insert into {dbname}.stb_1 values({self.ts + self.rowNum + 1}, {self.rowNum+1}, null)" )
tdSql.execute(f"insert into {dbname}.stb_2 values({self.ts + self.rowNum + 1}, {self.rowNum+1}, null)" )
tdSql.query(f"select * from {dbname}.stb_1 where col2 in (1, 'taosdata_1', 3, null) order by ts")
tdSql.checkRows(1)
tdSql.checkData(0, 1, 1)
tdSql.query(f"select * from {dbname}.stb_1 where col2 not in (1, 'taosdata_1', 3, null) order by ts")
tdSql.checkRows(0)
tdSql.query(f"select * from {dbname}.stb where loc in ('beijing', null)")
tdSql.checkRows(11)
tdSql.query(f"select * from {dbname}.stb where loc in ('shanghai', null)")
tdSql.checkRows(11)
tdSql.query(f"select * from {dbname}.stb where loc in ('shanghai', 'shanghai', null)")
tdSql.checkRows(11)
tdSql.query(f"select * from {dbname}.stb where loc in ('beijing', 'shanghai', null)")
tdSql.checkRows(22)
tdSql.query(f"select * from {dbname}.stb where loc not in ('beijing', null)")
tdSql.checkRows(0)
tdSql.query(f"select * from {dbname}.stb where loc not in ('shanghai', 'shanghai', null)")
tdSql.checkRows(0)
def run(self):
dbname = "db"
tdSql.prepare()
self.inAndNotinTest()
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -243,6 +243,8 @@ python3 ./test.py -f 2-query/max.py -P
python3 ./test.py -f 2-query/max.py -P -R
python3 ./test.py -f 2-query/min.py -P
python3 ./test.py -f 2-query/min.py -P -R
python3 ./test.py -f 2-query/normal.py -P
python3 ./test.py -f 2-query/normal.py -P -R
python3 ./test.py -f 2-query/mode.py -P
python3 ./test.py -f 2-query/mode.py -P -R
python3 ./test.py -f 2-query/Now.py -P
@ -424,6 +426,7 @@ python3 ./test.py -f 2-query/Now.py -P -Q 2
python3 ./test.py -f 2-query/Today.py -P -Q 2
python3 ./test.py -f 2-query/max.py -P -Q 2
python3 ./test.py -f 2-query/min.py -P -Q 2
python3 ./test.py -f 2-query/normal.py -P -Q 2
python3 ./test.py -f 2-query/mode.py -P -Q 2
python3 ./test.py -f 2-query/count.py -P -Q 2
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 2
@ -522,6 +525,7 @@ python3 ./test.py -f 2-query/Now.py -P -Q 3
python3 ./test.py -f 2-query/Today.py -P -Q 3
python3 ./test.py -f 2-query/max.py -P -Q 3
python3 ./test.py -f 2-query/min.py -P -Q 3
python3 ./test.py -f 2-query/normal.py -P -Q 3
python3 ./test.py -f 2-query/mode.py -P -Q 3
python3 ./test.py -f 2-query/count.py -P -Q 3
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 3
@ -619,6 +623,7 @@ python3 ./test.py -f 2-query/Now.py -P -Q 4
python3 ./test.py -f 2-query/Today.py -P -Q 4
python3 ./test.py -f 2-query/max.py -P -Q 4
python3 ./test.py -f 2-query/min.py -P -Q 4
python3 ./test.py -f 2-query/normal.py -P -Q 4
python3 ./test.py -f 2-query/mode.py -P -Q 4
python3 ./test.py -f 2-query/count.py -P -Q 4
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -P -Q 4

View File

@ -46,6 +46,7 @@ python3 .\test.py -f 2-query\between.py
@REM python3 .\test.py -f 2-query\Today.py
@REM python3 .\test.py -f 2-query\max.py
@REM python3 .\test.py -f 2-query\min.py
@REM python3 .\test.py -f 2-query\normal.py
@REM python3 .\test.py -f 2-query\count.py
@REM python3 .\test.py -f 2-query\last.py
@REM python3 .\test.py -f 2-query\first.py

View File

@ -382,6 +382,8 @@ python3 ./test.py -f 2-query/max.py
python3 ./test.py -f 2-query/max.py -R
python3 ./test.py -f 2-query/min.py
python3 ./test.py -f 2-query/min.py -R
python3 ./test.py -f 2-query/normal.py
python3 ./test.py -f 2-query/normal.py -R
python3 ./test.py -f 2-query/mode.py
python3 ./test.py -f 2-query/mode.py -R
python3 ./test.py -f 2-query/Now.py
@ -550,6 +552,7 @@ python3 ./test.py -f 2-query/Now.py -Q 2
python3 ./test.py -f 2-query/Today.py -Q 2
python3 ./test.py -f 2-query/max.py -Q 2
python3 ./test.py -f 2-query/min.py -Q 2
python3 ./test.py -f 2-query/normal.py -Q 2
python3 ./test.py -f 2-query/mode.py -Q 2
python3 ./test.py -f 2-query/count.py -Q 2
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 2
@ -646,6 +649,7 @@ python3 ./test.py -f 2-query/Now.py -Q 3
python3 ./test.py -f 2-query/Today.py -Q 3
python3 ./test.py -f 2-query/max.py -Q 3
python3 ./test.py -f 2-query/min.py -Q 3
python3 ./test.py -f 2-query/normal.py -Q 3
python3 ./test.py -f 2-query/mode.py -Q 3
python3 ./test.py -f 2-query/count.py -Q 3
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 3
@ -742,6 +746,7 @@ python3 ./test.py -f 2-query/Now.py -Q 4
python3 ./test.py -f 2-query/Today.py -Q 4
python3 ./test.py -f 2-query/max.py -Q 4
python3 ./test.py -f 2-query/min.py -Q 4
python3 ./test.py -f 2-query/normal.py -Q 4
python3 ./test.py -f 2-query/mode.py -Q 4
python3 ./test.py -f 2-query/count.py -Q 4
python3 ./test.py -f 2-query/countAlwaysReturnValue.py -Q 4