提交 cd3a40e5 编写于 作者: D dapan1121

fix shell sql convertion issue

上级 1288e4b4
......@@ -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;
......
......@@ -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';
}
......
......@@ -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);
......
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册