From d2cd274e783dcb78923e0488bd3828d518f5fb2a Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Wed, 13 Jan 2021 09:49:14 +0800 Subject: [PATCH] fix null tag and empty tag issue when having two autocreate table in one sql --- src/client/src/tscParseInsert.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index dbb807ad06..7151c33393 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -762,6 +762,8 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { char *sql = *sqlstr; + pSql->cmd.autoCreated = false; + // get the token of specified table index = 0; tableToken = tStrGetToken(sql, &index, false, 0, NULL); @@ -945,11 +947,15 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) { SKVRow row = tdGetKVRowFromBuilder(&kvRowBuilder); tdDestroyKVRowBuilder(&kvRowBuilder); if (row == NULL) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return tscInvalidSQLErrMsg(pCmd->payload, "tag value expected", NULL); } tdSortKVRowByColIdx(row); pCmd->tagData.dataLen = kvRowLen(row); + if (pCmd->tagData.dataLen <= 0){ + return tscInvalidSQLErrMsg(pCmd->payload, "tag value expected", NULL); + } + char* pTag = realloc(pCmd->tagData.data, pCmd->tagData.dataLen); if (pTag == NULL) { return TSDB_CODE_TSC_OUT_OF_MEMORY;