diff --git a/src/connector/odbc/src/todbc_conv.c b/src/connector/odbc/src/todbc_conv.c index 695201af5338977b302dc2fa2e4ae3b70e8acb69..c6ce6a29f60fb3d3ba7d8443325b7c4f24526f64 100644 --- a/src/connector/odbc/src/todbc_conv.c +++ b/src/connector/odbc/src/todbc_conv.c @@ -14,9 +14,10 @@ */ #include "todbc_conv.h" - #include "todbc_util.h" +#include "os.h" + #include #include #include diff --git a/src/connector/odbc/src/todbc_conv.h b/src/connector/odbc/src/todbc_conv.h index 4b326230f0d47b730472e4a92a9ddf62923de3dc..9753620ee21526572dd55573da3c5b8311cf178b 100644 --- a/src/connector/odbc/src/todbc_conv.h +++ b/src/connector/odbc/src/todbc_conv.h @@ -16,8 +16,7 @@ #ifndef _todbc_conv_h_ #define _todbc_conv_h_ -#include -#include +#include "todbc_flex_workaround.h" #include #include "iconv.h" diff --git a/src/connector/odbc/src/todbc_flex_workaround.h b/src/connector/odbc/src/todbc_flex_workaround.h new file mode 100644 index 0000000000000000000000000000000000000000..d6c79cf19a4cbc6dd155120f5b827d554a930421 --- /dev/null +++ b/src/connector/odbc/src/todbc_flex_workaround.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _todbc_flex_workaround_h_ +#define _todbc_flex_workaround_h_ + +#ifdef _MSC_VER +#include +#include +#endif +#ifndef INT8_MIN +#include +#endif +#include +#include + +#endif // _todbc_flex_workaround_h_ + diff --git a/src/connector/odbc/src/todbc_scanner.l b/src/connector/odbc/src/todbc_scanner.l index 8e178aa366c94d3037d42fa25f0c0b0d1298c70a..4c7aa74f2cca315ac2bf1bc3a5721597b2533383 100644 --- a/src/connector/odbc/src/todbc_scanner.l +++ b/src/connector/odbc/src/todbc_scanner.l @@ -1,8 +1,18 @@ %{ +#include +#include +#include + #include "todbc_util.h" #include +#ifdef _MSC_VER +#include "msvcLibgen.h" +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#endif + typedef struct params_s params_t; struct params_s { char *key; @@ -68,6 +78,8 @@ do { \ %option prefix="todbc_yy" %option extra-type="struct params_s *" +%option nounistd +%option never-interactive %option reentrant %option noyywrap %option noinput nounput diff --git a/src/connector/odbc/src/todbc_util.c b/src/connector/odbc/src/todbc_util.c index d462b37c1e531a960440b6961c65eb40d6f8fc5e..35f02bedd5d3c1e69a19f68f753f990e610cdc1f 100644 --- a/src/connector/odbc/src/todbc_util.c +++ b/src/connector/odbc/src/todbc_util.c @@ -17,9 +17,6 @@ #include "iconv.h" -#include -#include -#include #include #include diff --git a/src/connector/odbc/src/todbc_util.h b/src/connector/odbc/src/todbc_util.h index 5f58ff13cefed71ca0e988cd45683876aed256a6..b987c633a22852593906c1d91559ab2ae8b555fe 100644 --- a/src/connector/odbc/src/todbc_util.h +++ b/src/connector/odbc/src/todbc_util.h @@ -16,10 +16,9 @@ #ifndef _TODBC_UTIL_H_ #define _TODBC_UTIL_H_ +#include "todbc_flex_workaround.h" #include "todbc_log.h" -#include -#include const char* sql_sql_type(int type); const char* sql_c_type(int type); diff --git a/src/connector/odbc/tests/CMakeLists.txt b/src/connector/odbc/tests/CMakeLists.txt index 1649b45e02fd8474ea1964434d7417c4d186d897..d998527dc81398d590caf3e4a9eaa0e3d44f1dd3 100644 --- a/src/connector/odbc/tests/CMakeLists.txt +++ b/src/connector/odbc/tests/CMakeLists.txt @@ -9,5 +9,5 @@ ENDIF () IF (TD_WINDOWS_64) AUX_SOURCE_DIRECTORY(. SRC) ADD_EXECUTABLE(tcodbc main.c) - TARGET_LINK_LIBRARIES(tcodbc odbc) + # TARGET_LINK_LIBRARIES(tcodbc odbc) ENDIF () diff --git a/src/connector/odbc/tests/main.c b/src/connector/odbc/tests/main.c index 1321ade328c2c8aae2c93c72923ec2ec091a7108..2a0dca7a4d7e300773f7c77f8ab30302075efba8 100644 --- a/src/connector/odbc/tests/main.c +++ b/src/connector/odbc/tests/main.c @@ -1,4 +1,4 @@ -#include +#include "os.h" #include #include @@ -423,7 +423,12 @@ int test_sqls_in_stmt(SQLHENV env, SQLHDBC conn, SQLHSTMT stmt, const char *sqls char *line = NULL; size_t len = 0; - ssize_t n = getline(&line, &len, f); + ssize_t n = 0; +#ifdef _MSC_VER + n = taosGetlineImp(&line, &len, f); +#else + n = getline(&line, &len, f); +#endif if (n==-1) break; const char *p = NULL;