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