Merge pull request #26376 from xinjiempolde/fix/TD-30864-3.0

fix(TD-30864): taos crashed at parInsertSql.c
This commit is contained in:
Hongze Cheng 2024-07-03 09:35:53 +08:00 committed by GitHub
commit 71af880554
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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 '?' // db.? situationensure that the only thing following the '.' mark is '?'
char *tbNameAfterDbName = strchr(pTbName->z, '.'); char *tbNameAfterDbName = strnchr(pTbName->z, '.', pTbName->n, true);
if ((tbNameAfterDbName != NULL) && (tbNameAfterDbName + 1 - pTbName->z == pTbName->n - 1) && if ((tbNameAfterDbName != NULL) && (*(tbNameAfterDbName + 1) == '?')) {
(*(tbNameAfterDbName + 1) == '?')) {
char *tbName = NULL; 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); int32_t code = (*pCxt->pComCxt->pStmtCb->getTbNameFn)(pCxt->pComCxt->pStmtCb->pStmt, &tbName);
if (TSDB_CODE_SUCCESS == code) { if (code != TSDB_CODE_SUCCESS) {
pTbName->z = tbName;
pTbName->n = strlen(tbName);
} else {
return code; return code;
} }
pTbName->z = tbName;
pTbName->n = strlen(tbName);
} }
*pHasData = true; *pHasData = true;

View File

@ -790,6 +790,16 @@ SToken tStrGetToken(const char* str, int32_t* i, bool isPrevOptr, bool* pIgnoreC
return t0; 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; t0.n += len + 1;
} else { } else {