diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 767fbf26eae4e9ae3455a5ea6b7d609de0fd6f04..24562e7890ed13914dcd55d7df505a59ac191881 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1098,30 +1098,19 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC if (TK_STRING == sToken.type) free(sToken.z); } } + tscDestroyBoundColumnInfo(&spd); SKVRow row = tdGetKVRowFromBuilder(&kvRowBuilder); tdDestroyKVRowBuilder(&kvRowBuilder); if (row == NULL) { - tscDestroyBoundColumnInfo(&spd); return tscSQLSyntaxErrMsg(pInsertParam->msg, "tag value expected", NULL); } tdSortKVRowByColIdx(row); pInsertParam->tagData.dataLen = kvRowLen(row); if (pInsertParam->tagData.dataLen <= 0){ - tscDestroyBoundColumnInfo(&spd); return tscSQLSyntaxErrMsg(pInsertParam->msg, "tag value expected", NULL); } - // encode json tag string - if(spd.numOfBound == 1 && pTagSchema[spd.boundedColumns[0]].type == TSDB_DATA_TYPE_JSON){ - if(kvRowLen(row) >= pTagSchema[spd.boundedColumns[0]].bytes){ // reserve 1 byte for select - char tmp[128]= {0}; - sprintf(tmp, "tag value is too small, can not contain encoded json tag:%d|%d", kvRowLen(row), pTagSchema[spd.boundedColumns[0]].bytes); - tscDestroyBoundColumnInfo(&spd); - return tscInvalidOperationMsg(pInsertParam->msg, tmp, NULL); - } - } - tscDestroyBoundColumnInfo(&spd); char* pTag = realloc(pInsertParam->tagData.data, pInsertParam->tagData.dataLen); if (pTag == NULL) { diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 7a22be880cec77c0cc0e09a495f4f6ada1184562..18aa629906793799fff838c0125f9cb4ed0f8162 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -7745,11 +7745,6 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { } else if (pItem->pVar.nType == TSDB_DATA_TYPE_TIMESTAMP) { pItem->pVar.i64 = convertTimePrecision(pItem->pVar.i64, TSDB_TIME_PRECISION_NANO, tinfo.precision); } - } else if (pSchema->type == TSDB_DATA_TYPE_JSON) { - if (pItem->pVar.nLen > pSchema->bytes) { - tdDestroyKVRowBuilder(&kvRowBuilder); - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); - } } ret = tVariantDump(&(pItem->pVar), tagVal, pSchema->type, true); @@ -7802,14 +7797,6 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { } tdSortKVRowByColIdx(row); pTag->dataLen = kvRowLen(row); - if(schemaSize == 1 && pTagSchema[0].type == TSDB_DATA_TYPE_JSON){ - if(kvRowLen(row) >= pTagSchema[0].bytes){ // reserve 1 byte for select - char tmp[128]= {0}; - sprintf(tmp, "tag value is too small, can not contain encoded json tag:%d|%d", kvRowLen(row), pTagSchema[0].bytes); - free(row); - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), tmp); - } - } if (pTag->data == NULL) { pTag->data = malloc(pTag->dataLen); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 32c683445abca6d25312a766795549021aae328e..31759e6b9a8f4506a24a69fcda6d8693a453737a 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -5191,10 +5191,10 @@ void getJsonTagValueAll(void* data, void* dst, int16_t bytes) { return; } - assert(strlen(json) <= bytes); int32_t length = 0; taosMbsToUcs4(json, strlen(json), varDataVal(dst), bytes - VARSTR_HEADER_SIZE, &length); varDataSetLen(dst, length); + assert(length <= bytes); tfree(json); }