diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index a9d7b0a01fdc06898bbf76c49d774ccda65230b3..da51961d0ce8cd1a73cbef3272bc4d4471858cdc 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -398,7 +398,7 @@ static int32_t tscSCreateBuildResultFields(SSqlObj *pSql, BuildType type, const TAOS_FIELD f; if (type == SCREATE_BUILD_TABLE) { f.type = TSDB_DATA_TYPE_BINARY; - f.bytes = (TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE; + f.bytes = (TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE; tstrncpy(f.name, "Table", sizeof(f.name)); } else { f.type = TSDB_DATA_TYPE_BINARY; diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 21ac5e0b7e5a1b17c939ec3f9ce57dc248ae7f07..4f0e640b755e43ce02df7b82ed407f4bbe583ec5 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -309,8 +309,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { char * fname = NULL; bool printMode = false; - if ((sptr = strstr(command, ">>")) != NULL) { - cptr = strstr(command, ";"); + if ((sptr = tstrstr(command, ">>", true)) != NULL) { + cptr = tstrstr(command, ";", true); if (cptr != NULL) { *cptr = '\0'; } @@ -323,8 +323,8 @@ void shellRunCommandOnServer(TAOS *con, char command[]) { fname = full_path.we_wordv[0]; } - if ((sptr = strstr(command, "\\G")) != NULL) { - cptr = strstr(command, ";"); + if ((sptr = tstrstr(command, "\\G", true)) != NULL) { + cptr = tstrstr(command, ";", true); if (cptr != NULL) { *cptr = '\0'; } diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index 4e2609eb28376546fa64d53cead98a47ceee8282..4443716bca3ea280f50eb0402034dc60ee8b5dc8 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -29,6 +29,7 @@ int32_t strdequote(char *src); int32_t strRmquote(char *z, int32_t len); int32_t strRmquoteEscape(char *z, int32_t len); size_t strtrim(char *src); +char * tstrstr(char *src, char *dst, bool ignoreInEsc); char * strnchr(char *haystack, char needle, int32_t len, bool skipquote); char ** strsplit(char *src, const char *delim, int32_t *num); char * strtolower(char *dst, const char *src); diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index 8ae93c5402ebf4f12b12e8832e7e56dc2c296cd6..24cea245719dd25015d0d7b854170278307a2669 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -179,6 +179,43 @@ char *strnchr(char *haystack, char needle, int32_t len, bool skipquote) { return NULL; } +char *tstrstr(char *src, char *dst, bool ignoreInEsc) { + if (!ignoreInEsc) { + return strstr(src, dst); + } + + int32_t len = strlen(src); + bool inEsc = false; + char escChar = 0; + char *str = src, *res = NULL; + + for (int32_t i = 0; i < len; ++i) { + if (src[i] == TS_ESCAPE_CHAR || src[i] == '\'' || src[i] == '\"') { + if (!inEsc) { + escChar = src[i]; + src[i] = 0; + res = strstr(str, dst); + src[i] = escChar; + if (res) { + return res; + } + str = NULL; + } else { + if (src[i] != escChar) { + continue; + } + + str = src + i + 1; + } + + inEsc = !inEsc; + continue; + } + } + + return str ? strstr(str, dst) : NULL; +} + char* strtolower(char *dst, const char *src) {