提交 7cb90161 编写于 作者: wmmhello's avatar wmmhello

TD-6129<feature> match/nmatch support for nchar

上级 bcd662cb
......@@ -4453,7 +4453,6 @@ static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_
const char* msg1 = "regular expression string should be less than %d characters";
const char* msg2 = "illegal column type for match/nmatch";
const char* msg3 = "invalid regular expression";
const char* msg4 = "json column type must encode by binary for match/nmatch";
tSqlExpr* pLeft = pExpr->pLeft;
tSqlExpr* pRight = pExpr->pRight;
......@@ -4466,15 +4465,10 @@ static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_
}
SSchema* pSchema = tscGetTableSchema(pTableMeta);
if ((pLeft->tokenId != TK_ARROW) && (!isTablenameToken(&pLeft->columnName))
&& (pSchema[index].type != TSDB_DATA_TYPE_BINARY)) {
if ((!isTablenameToken(&pLeft->columnName)) && (pSchema[index].type != TSDB_DATA_TYPE_BINARY)) {
return invalidOperationMsg(msgBuf, msg2);
}
if(pLeft->tokenId == TK_ARROW && pSchema[index].type == TSDB_DATA_TYPE_JSON){
return invalidOperationMsg(msgBuf, msg4);
}
if (!(pRight->type == SQL_NODE_VALUE && pRight->value.nType == TSDB_DATA_TYPE_BINARY)) {
return invalidOperationMsg(msgBuf, msg3);
}
......
......@@ -2989,8 +2989,18 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, int8_t** p, SDataStat
all = false;
continue;
}
// match nchar
(*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData);
if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_NCHAR && (info->cunits[uidx].optr == TSDB_RELATION_MATCH || info->cunits[uidx].optr == TSDB_RELATION_NMATCH)){
char newColData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE] = {0};
char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE] = {0};
taosUcs4ToMbs(varDataVal(colData), varDataLen(colData), newColData);
taosUcs4ToMbs(varDataVal(info->cunits[uidx].valData), varDataLen(info->cunits[uidx].valData), newValData);
(*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, newValData);
}else{
(*p)[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData);
}
if ((*p)[i] == 0) {
all = false;
......@@ -3038,7 +3048,16 @@ bool filterExecuteImpl(void *pinfo, int32_t numOfRows, int8_t** p, SDataStatis *
} else if (cunit->rfunc >= 0) {
(*p)[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]);
} else {
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData);
if(cunit->dataType == TSDB_DATA_TYPE_NCHAR && (cunit->optr == TSDB_RELATION_MATCH || cunit->optr == TSDB_RELATION_NMATCH)){
char newColData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE] = {0};
char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE] = {0};
taosUcs4ToMbs(varDataVal(colData), varDataLen(colData), newColData);
taosUcs4ToMbs(varDataVal(cunit->valData), varDataLen(cunit->valData), newValData);
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, newValData);
}else{
(*p)[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData);
}
}
//FILTER_UNIT_SET_R(info, uidx, p[i]);
......
......@@ -4088,7 +4088,8 @@ static FORCE_INLINE int32_t tsdbGetJsonTagDataFromId(void *param, int32_t id, ch
*data = TABLE_NAME(pTable);
} else {
void* jsonData = getJsonTagValue(pTable, name, TSDB_MAX_JSON_KEY_MD5_LEN, NULL);
if (jsonData != NULL) jsonData += CHAR_BYTES; // jump type
assert(jsonData != NULL);
jsonData += CHAR_BYTES; // jump type
*data = jsonData;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册