From 61729d6805386b82f1baced563a1c36185fcb6c8 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Sat, 14 May 2022 10:43:00 +0800 Subject: [PATCH 1/3] fix(os): update windows compile error --- include/os/osString.h | 3 +++ source/client/src/clientSml.c | 4 ++-- source/os/src/osString.c | 23 +++++++++++++++++++++++ tools/shell/src/shellEngine.c | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/os/osString.h b/include/os/osString.h index 026cb33ad9..5f65f97bec 100644 --- a/include/os/osString.h +++ b/include/os/osString.h @@ -37,6 +37,7 @@ typedef int32_t TdUcs4; #define wcstombs WCSTOMBS_FUNC_TAOS_FORBID #define wcsncpy WCSNCPY_FUNC_TAOS_FORBID #define wchar_t WCHAR_T_TYPE_TAOS_FORBID + #define strcasestr STR_CASE_STR_FORBID #endif #ifdef WINDOWS @@ -69,6 +70,8 @@ int32_t taosMbsToWchars(TdWchar *pWchars, const char *pStrs, int32_t size); int32_t taosWcharToMb(char *pStr, TdWchar wchar); int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size); +char *taosStrCaseStr(const char *str, const char *pattern); + #ifdef __cplusplus } #endif diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 605d71ffed..47ac15a141 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -439,7 +439,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { code = catalogGetSTableMeta(info->pCatalog, info->taos->pAppInfo->pTransporter, &ep, &pName, &pTableMeta); if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_INVALID_STB) { - SSchemaAction schemaAction = { .action = SCHEMA_ACTION_CREATE_STABLE, .createSTable = {0}}; + SSchemaAction schemaAction = { SCHEMA_ACTION_CREATE_STABLE, {0}}; memcpy(schemaAction.createSTable.sTableName, superTable, superTableLen); schemaAction.createSTable.tags = sTableData->tags; schemaAction.createSTable.fields = sTableData->cols; @@ -455,7 +455,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { taosHashPut(hashTmp, pTableMeta->schema[i].name, strlen(pTableMeta->schema[i].name), &i, SHORT_BYTES); } - SSchemaAction schemaAction = {.alterSTable = {0}}; + SSchemaAction schemaAction = { 0 }; memcpy(schemaAction.createSTable.sTableName, superTable, superTableLen); code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->tags, &schemaAction, true); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/os/src/osString.c b/source/os/src/osString.c index 375c5001f4..357de4417b 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -236,3 +236,26 @@ int32_t taosMbsToWchars(TdWchar *pWchars, const char *pStrs, int32_t size) { ret int32_t taosWcharToMb(char *pStr, TdWchar wchar) { return wctomb(pStr, wchar); } int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size) { return wcstombs(pStrs, pWchars, size); } + +char *taosStrCaseStr(const char *str, const char *pattern) { +#ifdef WINDOWS + size_t i; + + if (!*pattern) + return (char*)str; + + for (; *str; str++) { + if (toupper(*str) == toupper(*pattern)) { + for (i = 1;; i++) { + if (!pattern[i]) + return (char*)str; + if (toupper(str[i]) != toupper(pattern[i])) + break; + } + } + } + return NULL; +#else + return strcasestr(str, pattern); +#endif +} \ No newline at end of file diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 1e832c0c46..39b97004ff 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -509,7 +509,7 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t bool shellIsLimitQuery(const char *sql) { //todo refactor - if (strcasestr(sql, " limit ") != NULL) { + if (taosStrCaseStr(sql, " limit ") != NULL) { return true; } From 2e3a64a569ba640653cd3bc9f68c10aab47c6acd Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Sat, 14 May 2022 11:15:21 +0800 Subject: [PATCH 2/3] fix(os): update windows compile error --- source/os/src/osString.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/source/os/src/osString.c b/source/os/src/osString.c index 357de4417b..7dbd301913 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -238,24 +238,20 @@ int32_t taosWcharToMb(char *pStr, TdWchar wchar) { return wctomb(pStr, wchar); } int32_t taosWcharsToMbs(char *pStrs, TdWchar *pWchars, int32_t size) { return wcstombs(pStrs, pWchars, size); } char *taosStrCaseStr(const char *str, const char *pattern) { -#ifdef WINDOWS - size_t i; + size_t i; - if (!*pattern) - return (char*)str; + if (!*pattern) + return (char*)str; - for (; *str; str++) { - if (toupper(*str) == toupper(*pattern)) { - for (i = 1;; i++) { - if (!pattern[i]) - return (char*)str; - if (toupper(str[i]) != toupper(pattern[i])) - break; - } - } + for (; *str; str++) { + if (toupper(*str) == toupper(*pattern)) { + for (i = 1;; i++) { + if (!pattern[i]) + return (char*)str; + if (toupper(str[i]) != toupper(pattern[i])) + break; } - return NULL; -#else - return strcasestr(str, pattern); -#endif + } + } + return NULL; } \ No newline at end of file From 38dfa18750815e5690b8c5d703b4a5725ce53739 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Sat, 14 May 2022 11:18:50 +0800 Subject: [PATCH 3/3] fix(os): update windows compile error --- source/client/src/clientSml.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 47ac15a141..fc909cb0a3 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -439,7 +439,9 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { code = catalogGetSTableMeta(info->pCatalog, info->taos->pAppInfo->pTransporter, &ep, &pName, &pTableMeta); if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_INVALID_STB) { - SSchemaAction schemaAction = { SCHEMA_ACTION_CREATE_STABLE, {0}}; + SSchemaAction schemaAction; + schemaAction.action = SCHEMA_ACTION_CREATE_STABLE; + memset(&schemaAction.createSTable, 0, sizeof(SCreateSTableActionInfo)); memcpy(schemaAction.createSTable.sTableName, superTable, superTableLen); schemaAction.createSTable.tags = sTableData->tags; schemaAction.createSTable.fields = sTableData->cols; @@ -455,7 +457,8 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) { taosHashPut(hashTmp, pTableMeta->schema[i].name, strlen(pTableMeta->schema[i].name), &i, SHORT_BYTES); } - SSchemaAction schemaAction = { 0 }; + SSchemaAction schemaAction; + memset(&schemaAction, 0, sizeof(SSchemaAction)); memcpy(schemaAction.createSTable.sTableName, superTable, superTableLen); code = smlProcessSchemaAction(info, pTableMeta->schema, hashTmp, sTableData->tags, &schemaAction, true); if (code != TSDB_CODE_SUCCESS) {