fix(TD-30864): taos crashed at parInsertSql.c

This commit is contained in:
xjzhou 2024-07-02 16:28:30 +08:00
parent 2f970dbc03
commit c851049d7c
2 changed files with 18 additions and 7 deletions

View File

@ -2429,17 +2429,18 @@ static int32_t checkTableClauseFirstToken(SInsertParseContext* pCxt, SVnodeModif
}
// db.? situationensure that the only thing following the '.' mark is '?'
char *tbNameAfterDbName = strchr(pTbName->z, '.');
if ((tbNameAfterDbName != NULL) && (tbNameAfterDbName + 1 - pTbName->z == pTbName->n - 1) &&
(*(tbNameAfterDbName + 1) == '?')) {
char *tbNameAfterDbName = strnchr(pTbName->z, '.', pTbName->n, true);
if ((tbNameAfterDbName != NULL) && (*(tbNameAfterDbName + 1) == '?')) {
char *tbName = NULL;
if (NULL == pCxt->pComCxt->pStmtCb) {
return buildSyntaxErrMsg(&pCxt->msg, "? only used in stmt", pTbName->z);
}
int32_t code = (*pCxt->pComCxt->pStmtCb->getTbNameFn)(pCxt->pComCxt->pStmtCb->pStmt, &tbName);
if (TSDB_CODE_SUCCESS == code) {
pTbName->z = tbName;
pTbName->n = strlen(tbName);
} else {
if (code != TSDB_CODE_SUCCESS) {
return code;
}
pTbName->z = tbName;
pTbName->n = strlen(tbName);
}
*pHasData = true;

View File

@ -790,6 +790,16 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr, bool* pIgnoreC
return t0;
}
// check the table name is '?', db.?asf is not valid.
if (TK_NK_QUESTION == type) {
tGetToken(&str[*i + t0.n + 2], &type);
if (TK_NK_SPACE != type) {
t0.type = TK_NK_ILLEGAL;
t0.n = 0;
return t0;
}
}
t0.n += len + 1;
} else {