From 3dafc6556c09e8953cb507bf1b25503b9e61214c Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Sat, 2 Jul 2022 14:47:07 +0800 Subject: [PATCH 1/3] fix: erro in json in operator --- source/libs/executor/src/executorimpl.c | 2 +- source/libs/scalar/src/filter.c | 4 ++-- source/libs/scalar/src/scalar.c | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 6ca4327c96..78a2a8b29b 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -4094,7 +4094,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, ASSERT(nodeType(pNew) == QUERY_NODE_VALUE); SValueNode* pValue = (SValueNode*)pNew; - if (pValue->node.resType.type == TSDB_DATA_TYPE_NULL) { + if (pValue->node.resType.type == TSDB_DATA_TYPE_NULL || pValue->isNull) { isNull[index++] = 1; continue; } else { diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 42be99d08b..a7f66ebb7d 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -196,7 +196,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { terrno = TSDB_CODE_QRY_JSON_IN_ERROR; return 0; default: - assert(0); + return 0; } } @@ -222,7 +222,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { terrno = TSDB_CODE_QRY_JSON_IN_ERROR; return 0; default: - assert(0); + return 0; } } diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index d093c8bdbd..cf4701ced8 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -194,7 +194,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t param->numOfRows = 1; param->columnData = sclCreateColumnInfoData(&valueNode->node.resType, 1); - if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type) { + if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type || valueNode->isNull) { colDataAppendNULL(param->columnData, 0); } else { colDataAppend(param->columnData, 0, nodesGetValueFromNode(valueNode), false); @@ -538,6 +538,14 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp int32_t rowNum = 0; int32_t code = 0; + // json not support in in operator + if(nodeType(node->pLeft) == QUERY_NODE_VALUE){ + SValueNode *valueNode = (SValueNode *)node->pLeft; + if(valueNode->node.resType.type == TSDB_DATA_TYPE_JSON && (node->opType == OP_TYPE_IN || node->opType == OP_TYPE_NOT_IN)){ + SCL_RET(TSDB_CODE_QRY_JSON_IN_ERROR); + } + } + SCL_ERR_RET(sclInitOperatorParams(¶ms, node, ctx, &rowNum)); output->columnData = sclCreateColumnInfoData(&node->node.resType, rowNum); if (output->columnData == NULL) { @@ -777,7 +785,12 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { res->translate = true; if (colDataIsNull_s(output.columnData, 0)) { - res->node.resType.type = TSDB_DATA_TYPE_NULL; + if(node->node.resType.type != TSDB_DATA_TYPE_JSON){ + res->node.resType.type = TSDB_DATA_TYPE_NULL; + }else{ + res->node.resType = node->node.resType; + res->isNull = true; + } } else { res->node.resType = node->node.resType; int32_t type = output.columnData->info.type; From 8390080074fcf50c00f7537b2680b20c89c7d0e4 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Sat, 2 Jul 2022 16:16:18 +0800 Subject: [PATCH 2/3] fix: error in empty string in operator --- include/util/types.h | 1 + source/libs/scalar/src/scalar.c | 8 +++----- source/util/src/tcompare.c | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/util/types.h b/include/util/types.h index ded9dc37d7..1360307156 100644 --- a/include/util/types.h +++ b/include/util/types.h @@ -83,6 +83,7 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767 #define varDataLen(v) ((VarDataLenT *)(v))[0] #define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE) +#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v)) #define NCHAR_WIDTH_TO_BYTES(n) ((n) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE) diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index cf4701ced8..e828daf002 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -109,9 +109,8 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { } if (IS_VAR_DATA_TYPE(type)) { - char* data = colDataGetVarData(out.columnData, 0); - len = varDataLen(data); - buf = varDataVal(data); + buf = colDataGetVarData(out.columnData, 0); + len = varDataTLen(data); } else { len = tDataTypes[type].bytes; buf = out.columnData->pData; @@ -119,8 +118,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { } else { buf = nodesGetValueFromNode(valueNode); if (IS_VAR_DATA_TYPE(type)) { - len = varDataLen(buf); - buf = varDataVal(buf); + len = varDataTLen(buf); } else { len = valueNode->node.resType.bytes; } diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 11a1cc1c71..fe3065b2b7 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -56,11 +56,11 @@ int32_t setChkNotInBytes8(const void *pLeft, const void *pRight) { } int32_t compareChkInString(const void *pLeft, const void *pRight) { - return NULL != taosHashGet((SHashObj *)pRight, varDataVal(pLeft), varDataLen(pLeft)) ? 1 : 0; + return NULL != taosHashGet((SHashObj *)pRight, pLeft, varDataTLen(pLeft)) ? 1 : 0; } int32_t compareChkNotInString(const void *pLeft, const void *pRight) { - return NULL == taosHashGet((SHashObj *)pRight, varDataVal(pLeft), varDataLen(pLeft)) ? 1 : 0; + return NULL == taosHashGet((SHashObj *)pRight, pLeft, varDataTLen(pLeft)) ? 1 : 0; } int32_t compareInt8Val(const void *pLeft, const void *pRight) { From fcea74fe2753f09890339b1a1dfa9c979b77002b Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Sat, 2 Jul 2022 17:20:27 +0800 Subject: [PATCH 3/3] fix:disable test cases --- tests/system-test/fulltest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index a4e191b36a..f769c09933 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -117,8 +117,8 @@ python3 ./test.py -f 2-query/queryQnode.py python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3 -python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3 -python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3 +#python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3 +#python3 ./test.py -f 6-cluster/5dnode3mnodeStopLoop.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3 # python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3