提交 f45fde3c 编写于 作者: wmmhello's avatar wmmhello

[TS-165]<fix> fix space error when parse sql

上级 1ae48765
......@@ -114,7 +114,7 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
}
for (int k = pToken->n; pToken->z[k] != '\0'; k++) {
if (pToken->z[k] == ' ' || pToken->z[k] == '\t') continue;
if (isspace(pToken->z[k])) continue;
if (pToken->z[k] == ',') {
*next = pTokenEnd;
*time = useconds;
......@@ -1589,7 +1589,8 @@ int tsParseSql(SSqlObj *pSql, bool initial) {
ret = tsParseInsertSql(pSql);
if (pSql->parseRetry < 1 && (ret == TSDB_CODE_TSC_SQL_SYNTAX_ERROR || ret == TSDB_CODE_TSC_INVALID_OPERATION)) {
tscDebug("0x%"PRIx64 " parse insert sql statement failed, code:%s, clear meta cache and retry ", pSql->self, tstrerror(ret));
SInsertStatementParam* pInsertParam = &pCmd->insertParam;
tscDebug("0x%"PRIx64 " parse insert sql statement failed, code:%s, msg:%s, clear meta cache and retry ", pSql->self, pInsertParam->msg, tstrerror(ret));
tscResetSqlCmd(pCmd, true);
pSql->parseRetry++;
......
......@@ -2684,7 +2684,7 @@ void tscDequoteAndTrimToken(SStrToken* pToken) {
// trim leading spaces
while (first < last) {
char c = pToken->z[first];
if (c != ' ' && c != '\t') {
if (isspace(c)) {
break;
}
first++;
......@@ -2693,7 +2693,7 @@ void tscDequoteAndTrimToken(SStrToken* pToken) {
// trim ending spaces
while (first < last) {
char c = pToken->z[last - 1];
if (c != ' ' && c != '\t') {
if (isspace(c)) {
break;
}
last--;
......
......@@ -147,7 +147,7 @@ TAOS *shellInit(SShellArguments *_args) {
static bool isEmptyCommand(const char* cmd) {
for (char c = *cmd++; c != 0; c = *cmd++) {
if (c != ' ' && c != '\t' && c != ';') {
if (isspace(c) && c != ';') {
return false;
}
}
......
......@@ -663,7 +663,7 @@ static int32_t httpParserOnTarget(HttpParser *parser, HTTP_PARSER_STATE state, c
HttpContext *pContext = parser->pContext;
int32_t ok = 0;
do {
if (!isspace(c) && c != '\r' && c != '\n') {
if (!isspace(c)) {
if (httpAppendString(&parser->str, &c, 1)) {
httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c);
ok = -1;
......
......@@ -608,7 +608,7 @@ SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr) {
int32_t numOfComma = 0;
char t = str[*i];
while (t == ' ' || t == '\n' || t == '\r' || t == '\t' || t == '\f' || t == ',') {
while (isspace(t) || t == ',') {
if (t == ',' && (++numOfComma > 1)) { // comma only allowed once
t0.n = 0;
return t0;
......
......@@ -223,7 +223,7 @@ char *paGetToken(char *string, char **token, int32_t *tokenLen) {
char quote = 0;
while (*string != 0) {
if (*string == ' ' || *string == '\t') {
if (isspace(*string)) {
++string;
} else {
break;
......@@ -244,12 +244,12 @@ char *paGetToken(char *string, char **token, int32_t *tokenLen) {
break;
}
if (*string == '#' || *string == '\n' || *string == '\r') {
if (*string == '#' || isspace(*string)) {
*string = 0;
break;
}
if ((*string == ' ' || *string == '\t') && !quote) {
if (isspace(*string) && !quote) {
break;
} else {
++string;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册