Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion source/libs/parser/src/parInsertSql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,13 @@ static int parseOneRow(SInsertParseContext* pCxt, const char** pSql, STableDataC
if (TSDB_CODE_SUCCESS == code && i < pCols->numOfBound - 1) {
NEXT_VALID_TOKEN(*pSql, *pToken);
if (TK_NK_COMMA != pToken->type) {
code = buildSyntaxErrMsg(&pCxt->msg, ", expected", pToken->z);
if (!pCxt->forceUpdate) {
code = TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER;
parserWarn("QID:0x%" PRIx64 ", column number is smaller than %d, need retry", pCxt->pComCxt->requestId,
pCols->numOfBound);
} else {
code = buildSyntaxErrMsg(&pCxt->msg, ", expected", pToken->z);
}
Comment on lines +2399 to +2405
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current logic for retrying on schema changes is a bit too broad. It triggers a retry for any token that is not a comma, which includes genuine syntax errors like a missing comma between values (e.g., VALUES(1 2)). This leads to an unnecessary retry cycle for what is a clear syntax error.

To make the retry mechanism more precise, we should only trigger it when we encounter a closing parenthesis ) prematurely, as this is a clear signal that the client is providing fewer columns than the server expects due to a stale schema. Other cases should be treated as syntax errors immediately.

        if (pToken->type == TK_NK_RP && !pCxt->forceUpdate) {
          code = TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER;
          parserWarn("QID:0x%" PRIx64 ", column number is smaller than %d, need retry", pCxt->pComCxt->requestId,
                     pCols->numOfBound);
        } else {
          code = buildSyntaxErrMsg(&pCxt->msg, ", expected", pToken->z);
        }

}
}
}
Expand Down
Loading