提交 7eeea8a2 编写于 作者: H Haojun Liao

fix(query): fix the invalid access, and do some internal refactor.

上级 f970dd24
......@@ -131,7 +131,10 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
varDataCopy(val, src);
break;
default: {
if (len > 0) {
memcpy(val, src, len);
}
break;
}
}
......
......@@ -338,7 +338,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
__compar_fn_t filterGetCompFunc(int32_t type, int32_t optr) { return gDataCompare[filterGetCompFuncIdx(type, optr)]; }
__compar_fn_t filterGetCompFuncEx(int32_t lType, int32_t rType, int32_t optr) {
if (TSDB_DATA_TYPE_NULL == rType) {
if (TSDB_DATA_TYPE_NULL == rType || TSDB_DATA_TYPE_JSON == rType) {
return NULL;
}
......
......@@ -1723,18 +1723,8 @@ void vectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *
param2 = pRight;
} else {
vectorConvertCols(pLeft, pRight, &pLeftOut, &pRightOut, startIndex, numOfRows);
if (pLeftOut.columnData != NULL) {
param1 = &pLeftOut;
} else {
param1 = pLeft;
}
if (pRightOut.columnData != NULL) {
param2 = &pRightOut;
} else {
param2 = pRight;
}
param1 = (pLeftOut.columnData != NULL) ? &pLeftOut : pLeft;
param2 = (pRightOut.columnData != NULL) ? &pRightOut : pRight;
}
doVectorCompare(param1, param2, pOut, startIndex, numOfRows, _ord, optr);
......
......@@ -344,7 +344,7 @@ TEST(constantTest, int_or_binary) {
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
SValueNode *v = (SValueNode *)res;
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT);
ASSERT_EQ(v->datum.b, scltLeftV | scltRightV);
ASSERT_EQ(v->datum.i, scltLeftV | scltRightV);
nodesDestroyNode(res);
}
......@@ -1101,7 +1101,8 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do
opType == OP_TYPE_LIKE || opType == OP_TYPE_NOT_LIKE || opType == OP_TYPE_MATCH ||
opType == OP_TYPE_NMATCH) {
printf("op:%s,3result:%d,except:%f\n", operatorTypeStr(opType), *((bool *)colDataGetData(column, 0)), exceptValue);
ASSERT_EQ(*((bool *)colDataGetData(column, 0)), exceptValue);
assert(*(bool *)colDataGetData(column, 0) == exceptValue);
// ASSERT_EQ((int) *((bool *)colDataGetData(column, 0)), (int)exceptValue);
}
taosArrayDestroyEx(blockList, scltFreeDataBlock);
......@@ -1426,7 +1427,7 @@ TEST(columnTest, json_column_logic_op) {
printf("--------------------json string-- 6.6hello {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
key = "k9";
bool eRes8[len + len1] = {false, false, false, false, false, false, false, true, true, false, true, false, true};
bool eRes8[len + len1] = {false, false, false, false, false, false, false, true, true, false, true, true, true};
for (int i = 0; i < len; i++) {
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes8[i], op[i], false);
}
......@@ -1437,6 +1438,9 @@ TEST(columnTest, json_column_logic_op) {
for (int i = len; i < len + len1; i++) {
void *rightData = prepareNchar(inputNchar[i - len]);
if (i == 11) {
printf("abc\n");
}
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes8[i], op[i], false);
taosMemoryFree(rightData);
}
......
......@@ -1161,7 +1161,8 @@ static int32_t doExecRegexMatch(const char *pString, const char *pPattern) {
return 1;
}
ret = regexec(&regex, pString, 0, NULL, 0);
regmatch_t pmatch[1];
ret = regexec(&regex, pString, 1, pmatch, 0);
if (ret != 0 && ret != REG_NOMATCH) {
regerror(ret, &regex, msgbuf, sizeof(msgbuf));
uDebug("Failed to match %s with pattern %s, reason %s", pString, pPattern, msgbuf)
......@@ -1192,7 +1193,7 @@ int32_t comparestrRegexMatch(const void *pLeft, const void *pRight) {
int32_t comparewcsRegexMatch(const void* pString, const void* pPattern) {
size_t len = varDataLen(pPattern);
char *pattern = taosMemoryMalloc(len + TSDB_NCHAR_SIZE);
char *pattern = taosMemoryMalloc(len + 1);
int convertLen = taosUcs4ToMbs((TdUcs4 *)varDataVal(pPattern), len, pattern);
if (convertLen < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册