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

fix not remove escape character in insert into table

上级 4fcf6b18
...@@ -1065,6 +1065,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -1065,6 +1065,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
// Remove quotation marks // Remove quotation marks
if (TK_STRING == sToken.type) { if (TK_STRING == sToken.type) {
sToken.z = strndup(sToken.z, sToken.n);
sToken.n = strRmquote(sToken.z, sToken.n); sToken.n = strRmquote(sToken.z, sToken.n);
} }
...@@ -1073,33 +1074,29 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC ...@@ -1073,33 +1074,29 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
tdDestroyKVRowBuilder(&kvRowBuilder); tdDestroyKVRowBuilder(&kvRowBuilder);
tscDestroyBoundColumnInfo(&spd); tscDestroyBoundColumnInfo(&spd);
if (TK_STRING == sToken.type) free(sToken.z);
return code; return code;
} }
tdAddColToKVRow(&kvRowBuilder, pSchema->colId, pSchema->type, tagVal, false); tdAddColToKVRow(&kvRowBuilder, pSchema->colId, pSchema->type, tagVal, false);
}
// encode json tag string if(pSchema->type == TSDB_DATA_TYPE_JSON){
if(spd.numOfBound == 1 && pTagSchema[spd.boundedColumns[0]].type == TSDB_DATA_TYPE_JSON){ assert(spd.numOfBound == 1);
char tmp = sToken.z[sToken.n]; if(sToken.n > TSDB_MAX_TAGS_LEN/TSDB_NCHAR_SIZE){
sToken.z[sToken.n] = 0; tdDestroyKVRowBuilder(&kvRowBuilder);
// if(sToken.type != TK_STRING) { tscDestroyBoundColumnInfo(&spd);
// tdDestroyKVRowBuilder(&kvRowBuilder); if (TK_STRING == sToken.type) free(sToken.z);
// tscDestroyBoundColumnInfo(&spd); return tscSQLSyntaxErrMsg(pInsertParam->msg, "json tag too long", NULL);
// return tscSQLSyntaxErrMsg(pInsertParam->msg, "json type error, should be string", NULL); }
// } code = parseJsontoTagData(sToken.z, &kvRowBuilder, pInsertParam->msg, pTagSchema[spd.boundedColumns[0]].colId);
if(sToken.n > TSDB_MAX_TAGS_LEN/TSDB_NCHAR_SIZE){ if (code != TSDB_CODE_SUCCESS) {
tdDestroyKVRowBuilder(&kvRowBuilder); tdDestroyKVRowBuilder(&kvRowBuilder);
tscDestroyBoundColumnInfo(&spd); tscDestroyBoundColumnInfo(&spd);
return tscSQLSyntaxErrMsg(pInsertParam->msg, "json tag too long", NULL); if (TK_STRING == sToken.type) free(sToken.z);
} return code;
code = parseJsontoTagData(sToken.z, &kvRowBuilder, pInsertParam->msg, pTagSchema[spd.boundedColumns[0]].colId); }
if (code != TSDB_CODE_SUCCESS) { if (TK_STRING == sToken.type) free(sToken.z);
tdDestroyKVRowBuilder(&kvRowBuilder);
tscDestroyBoundColumnInfo(&spd);
return code;
} }
sToken.z[sToken.n] = tmp;
} }
SKVRow row = tdGetKVRowFromBuilder(&kvRowBuilder); SKVRow row = tdGetKVRowFromBuilder(&kvRowBuilder);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册