提交 81461138 编写于 作者: G Ganlin Zhao

fix asserts in sclvector.c

上级 5e4b1393
...@@ -383,18 +383,18 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { ...@@ -383,18 +383,18 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
func = varToUnsigned; func = varToUnsigned;
} else if (IS_FLOAT_TYPE(pCtx->outType)) { } else if (IS_FLOAT_TYPE(pCtx->outType)) {
func = varToFloat; func = varToFloat;
} else if (pCtx->outType == TSDB_DATA_TYPE_BINARY) { // nchar -> binary } else if (pCtx->outType == TSDB_DATA_TYPE_VARCHAR &&
ASSERT(pCtx->inType == TSDB_DATA_TYPE_NCHAR); pCtx->inType == TSDB_DATA_TYPE_NCHAR) { // nchar -> binary
func = ncharToVar; func = ncharToVar;
vton = true; vton = true;
} else if (pCtx->outType == TSDB_DATA_TYPE_NCHAR) { // binary -> nchar } else if (pCtx->outType == TSDB_DATA_TYPE_NCHAR &&
ASSERT(pCtx->inType == TSDB_DATA_TYPE_VARCHAR); pCtx->inType == TSDB_DATA_TYPE_VARCHAR) { // binary -> nchar
func = varToNchar; func = varToNchar;
vton = true; vton = true;
} else if (TSDB_DATA_TYPE_TIMESTAMP == pCtx->outType) { } else if (TSDB_DATA_TYPE_TIMESTAMP == pCtx->outType) {
func = varToTimestamp; func = varToTimestamp;
} else { } else {
sclError("invalid convert outType:%d", pCtx->outType); sclError("invalid convert outType:%d, inType:%d", pCtx->outType, pCtx->inType);
return TSDB_CODE_APP_ERROR; return TSDB_CODE_APP_ERROR;
} }
...@@ -408,12 +408,10 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { ...@@ -408,12 +408,10 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
char *data = colDataGetVarData(pCtx->pIn->columnData, i); char *data = colDataGetVarData(pCtx->pIn->columnData, i);
int32_t convertType = pCtx->inType; int32_t convertType = pCtx->inType;
if (pCtx->inType == TSDB_DATA_TYPE_JSON) { if (pCtx->inType == TSDB_DATA_TYPE_JSON) {
if (*data == TSDB_DATA_TYPE_NULL) { if (*data == TSDB_DATA_TYPE_NCHAR) {
ASSERT(0);
} else if (*data == TSDB_DATA_TYPE_NCHAR) {
data += CHAR_BYTES; data += CHAR_BYTES;
convertType = TSDB_DATA_TYPE_NCHAR; convertType = TSDB_DATA_TYPE_NCHAR;
} else if (tTagIsJson(data)) { } else if (tTagIsJson(data) || *data == TSDB_DATA_TYPE_NULL) {
terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR;
return terrno; return terrno;
} else { } else {
...@@ -434,7 +432,11 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { ...@@ -434,7 +432,11 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
memcpy(tmp, varDataVal(data), varDataLen(data)); memcpy(tmp, varDataVal(data), varDataLen(data));
tmp[varDataLen(data)] = 0; tmp[varDataLen(data)] = 0;
} else if (TSDB_DATA_TYPE_NCHAR == convertType) { } else if (TSDB_DATA_TYPE_NCHAR == convertType) {
ASSERT(varDataLen(data) <= bufSize); if (varDataLen(data) > bufSize) {
sclError("castConvert convert buffer size too small");
taosMemoryFreeClear(tmp);
return TSDB_CODE_APP_ERROR;
}
int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp); int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp);
if (len < 0) { if (len < 0) {
...@@ -542,27 +544,17 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t ...@@ -542,27 +544,17 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
*fp = filterGetCompFunc(type, optr); *fp = filterGetCompFunc(type, optr);
if (IS_NUMERIC_TYPE(type)) { if (IS_NUMERIC_TYPE(type)) {
if (typeLeft == TSDB_DATA_TYPE_NCHAR) { if (typeLeft == TSDB_DATA_TYPE_NCHAR ||
ASSERT(0); typeLeft == TSDB_DATA_TYPE_VARCHAR) {
// convertNcharToDouble(*pLeftData, pLeftOut); return false;
// *pLeftData = pLeftOut;
} else if (typeLeft == TSDB_DATA_TYPE_BINARY) {
ASSERT(0);
// convertBinaryToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut;
} else if (typeLeft != type) { } else if (typeLeft != type) {
convertNumberToNumber(*pLeftData, pLeftOut, typeLeft, type); convertNumberToNumber(*pLeftData, pLeftOut, typeLeft, type);
*pLeftData = pLeftOut; *pLeftData = pLeftOut;
} }
if (typeRight == TSDB_DATA_TYPE_NCHAR) { if (typeRight == TSDB_DATA_TYPE_NCHAR ||
ASSERT(0); typeRight == TSDB_DATA_TYPE_VARCHAR) {
// convertNcharToDouble(*pRightData, pRightOut); return false;
// *pRightData = pRightOut;
} else if (typeRight == TSDB_DATA_TYPE_BINARY) {
ASSERT(0);
// convertBinaryToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut;
} else if (typeRight != type) { } else if (typeRight != type) {
convertNumberToNumber(*pRightData, pRightOut, typeRight, type); convertNumberToNumber(*pRightData, pRightOut, typeRight, type);
*pRightData = pRightOut; *pRightData = pRightOut;
...@@ -577,7 +569,7 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t ...@@ -577,7 +569,7 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
*freeRight = true; *freeRight = true;
} }
} else { } else {
ASSERT(0); return false;
} }
return true; return true;
...@@ -668,7 +660,10 @@ int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut, ...@@ -668,7 +660,10 @@ int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut,
} }
if (overflow) { if (overflow) {
ASSERT(1 == pIn->numOfRows); if (1 != pIn->numOfRows) {
sclError("invalid numOfRows %d", pIn->numOfRows);
return TSDB_CODE_APP_ERROR;
}
pOut->numOfRows = 0; pOut->numOfRows = 0;
...@@ -1913,7 +1908,6 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) { ...@@ -1913,7 +1908,6 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) {
case OP_TYPE_JSON_CONTAINS: case OP_TYPE_JSON_CONTAINS:
return vectorJsonContains; return vectorJsonContains;
default: default:
ASSERT(0);
return NULL; return NULL;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册