fix td-804
This commit is contained in:
parent
ab625d55c1
commit
89d87300d3
|
@ -416,7 +416,7 @@ void tscRestoreSQLFuncForSTableQuery(SQueryInfo *pQueryInfo);
|
||||||
int32_t tscCreateResPointerInfo(SSqlRes *pRes, SQueryInfo *pQueryInfo);
|
int32_t tscCreateResPointerInfo(SSqlRes *pRes, SQueryInfo *pQueryInfo);
|
||||||
void tscDestroyResPointerInfo(SSqlRes *pRes);
|
void tscDestroyResPointerInfo(SSqlRes *pRes);
|
||||||
|
|
||||||
void tscResetSqlCmdObj(SSqlCmd *pCmd);
|
void tscResetSqlCmdObj(SSqlCmd *pCmd, bool removeFromCache);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* free query result of the sql object
|
* free query result of the sql object
|
||||||
|
|
|
@ -482,7 +482,7 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
|
||||||
if (pCmd->command == TSDB_SQL_INSERT || pCmd->command == TSDB_SQL_SELECT) {
|
if (pCmd->command == TSDB_SQL_INSERT || pCmd->command == TSDB_SQL_SELECT) {
|
||||||
tscDebug("%p redo parse sql string and proceed", pSql);
|
tscDebug("%p redo parse sql string and proceed", pSql);
|
||||||
pCmd->parseFinished = false;
|
pCmd->parseFinished = false;
|
||||||
tscResetSqlCmdObj(pCmd);
|
tscResetSqlCmdObj(pCmd, false);
|
||||||
|
|
||||||
code = tsParseSql(pSql, true);
|
code = tsParseSql(pSql, true);
|
||||||
|
|
||||||
|
|
|
@ -1328,14 +1328,30 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
|
||||||
pSql->fp = (void(*)())tscHandleMultivnodeInsert;
|
pSql->fp = (void(*)())tscHandleMultivnodeInsert;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initial && ((ret = tsInsertInitialCheck(pSql)) != TSDB_CODE_SUCCESS)) {
|
for (int i = 0; true; i++) {
|
||||||
return ret;
|
if (initial && ((ret = tsInsertInitialCheck(pSql)) != TSDB_CODE_SUCCESS)) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make a backup as tsParseInsertSql may modify the string
|
||||||
|
char* sqlstr = strdup(pSql->sqlstr);
|
||||||
|
ret = tsParseInsertSql(pSql);
|
||||||
|
if (sqlstr == NULL || i >= 2 || ret != TSDB_CODE_TSC_INVALID_SQL) {
|
||||||
|
free(sqlstr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tscResetSqlCmdObj(pCmd, true);
|
||||||
|
pCmd->pQueryInfo = NULL;
|
||||||
|
free(pSql->sqlstr);
|
||||||
|
pSql->sqlstr = sqlstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = tsParseInsertSql(pSql);
|
|
||||||
} else {
|
} else {
|
||||||
SSqlInfo SQLInfo = qSQLParse(pSql->sqlstr);
|
SSqlInfo SQLInfo = qSQLParse(pSql->sqlstr);
|
||||||
ret = tscToSQLCmd(pSql, &SQLInfo);
|
ret = tscToSQLCmd(pSql, &SQLInfo);
|
||||||
|
if (ret == TSDB_CODE_TSC_INVALID_SQL) {
|
||||||
|
tscResetSqlCmdObj(pCmd, true);
|
||||||
|
ret = tscToSQLCmd(pSql, &SQLInfo);
|
||||||
|
}
|
||||||
SQLInfoDestroy(&SQLInfo);
|
SQLInfoDestroy(&SQLInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -817,7 +817,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
|
||||||
|
|
||||||
static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t tblListLen) {
|
static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t tblListLen) {
|
||||||
// must before clean the sqlcmd object
|
// must before clean the sqlcmd object
|
||||||
tscResetSqlCmdObj(&pSql->cmd);
|
tscResetSqlCmdObj(&pSql->cmd, false);
|
||||||
|
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
static void freeQueryInfoImpl(SQueryInfo* pQueryInfo);
|
static void freeQueryInfoImpl(SQueryInfo* pQueryInfo);
|
||||||
static void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool removeFromCache);
|
static void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool removeFromCache);
|
||||||
|
|
||||||
SCond* tsGetSTableQueryCond(STagCond* pTagCond, uint64_t uid) {
|
SCond* tsGetSTableQueryCond(STagCond* pTagCond, uint64_t uid) {
|
||||||
if (pTagCond->pCond == NULL) {
|
if (pTagCond->pCond == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ void tscDestroyResPointerInfo(SSqlRes* pRes) {
|
||||||
pRes->data = NULL; // pRes->data points to the buffer of pRsp, no need to free
|
pRes->data = NULL; // pRes->data points to the buffer of pRsp, no need to free
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tscFreeQueryInfo(SSqlCmd* pCmd) {
|
static void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeFromCache) {
|
||||||
if (pCmd == NULL || pCmd->numOfClause == 0) {
|
if (pCmd == NULL || pCmd->numOfClause == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ static void tscFreeQueryInfo(SSqlCmd* pCmd) {
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, i);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, i);
|
||||||
|
|
||||||
freeQueryInfoImpl(pQueryInfo);
|
freeQueryInfoImpl(pQueryInfo);
|
||||||
clearAllTableMetaInfo(pQueryInfo, (const char*)addr, false);
|
clearAllTableMetaInfo(pQueryInfo, (const char*)addr, removeFromCache);
|
||||||
taosTFree(pQueryInfo);
|
taosTFree(pQueryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ static void tscFreeQueryInfo(SSqlCmd* pCmd) {
|
||||||
taosTFree(pCmd->pQueryInfo);
|
taosTFree(pCmd->pQueryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscResetSqlCmdObj(SSqlCmd* pCmd) {
|
void tscResetSqlCmdObj(SSqlCmd* pCmd, bool removeFromCache) {
|
||||||
pCmd->command = 0;
|
pCmd->command = 0;
|
||||||
pCmd->numOfCols = 0;
|
pCmd->numOfCols = 0;
|
||||||
pCmd->count = 0;
|
pCmd->count = 0;
|
||||||
|
@ -328,7 +328,7 @@ void tscResetSqlCmdObj(SSqlCmd* pCmd) {
|
||||||
|
|
||||||
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
||||||
|
|
||||||
tscFreeQueryInfo(pCmd);
|
tscFreeQueryInfo(pCmd, removeFromCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscFreeSqlResult(SSqlObj* pSql) {
|
void tscFreeSqlResult(SSqlObj* pSql) {
|
||||||
|
@ -366,7 +366,7 @@ void tscPartiallyFreeSqlObj(SSqlObj* pSql) {
|
||||||
taosTFree(pSql->pSubs);
|
taosTFree(pSql->pSubs);
|
||||||
pSql->numOfSubs = 0;
|
pSql->numOfSubs = 0;
|
||||||
|
|
||||||
tscResetSqlCmdObj(pCmd);
|
tscResetSqlCmdObj(pCmd, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscFreeSqlObj(SSqlObj* pSql) {
|
void tscFreeSqlObj(SSqlObj* pSql) {
|
||||||
|
|
Loading…
Reference in New Issue