diff --git a/src/connector/odbc/CMakeLists.txt b/src/connector/odbc/CMakeLists.txt index 3a179fc175620347ba58eccacca55630ca450cf4..3d6564c230805030ef5bf7b16dda6213bf49ed54 100644 --- a/src/connector/odbc/CMakeLists.txt +++ b/src/connector/odbc/CMakeLists.txt @@ -17,6 +17,8 @@ IF (TD_LINUX_64) if(NOT FLEX_FOUND) message(FATAL_ERROR "you need to install flex first") else () + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wconversion") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wconversion") ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(tests) endif() @@ -26,3 +28,20 @@ IF (TD_LINUX_64) ENDIF () ENDIF () +IF (TD_WINDOWS_64) + find_package(ODBC) + if (NOT ODBC_FOUND) + message(FATAL_ERROR "you need to install ODBC first") + else () + message(STATUS "ODBC_INCLUDE_DIRS: ${ODBC_INCLUDE_DIRS}") + message(STATUS "ODBC_LIBRARIES: ${ODBC_LIBRARIES}") + message(STATUS "ODBC_CONFIG: ${ODBC_CONFIG}") + endif () + find_package(FLEX) + if(NOT FLEX_FOUND) + message(FATAL_ERROR "you need to install flex first") + else () + ADD_SUBDIRECTORY(src) + ADD_SUBDIRECTORY(tests) + endif() +ENDIF () diff --git a/src/connector/odbc/src/CMakeLists.txt b/src/connector/odbc/src/CMakeLists.txt index d8438e981786d0d020c71c54d15cc172dac6fa9f..7249e2d1de5e54b86c6205c7342f3306a6a8b18a 100644 --- a/src/connector/odbc/src/CMakeLists.txt +++ b/src/connector/odbc/src/CMakeLists.txt @@ -16,9 +16,35 @@ IF (TD_LINUX_64) SET_TARGET_PROPERTIES(todbc PROPERTIES CLEAN_DIRECT_OUTPUT 1) SET_TARGET_PROPERTIES(todbc PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1) TARGET_LINK_LIBRARIES(todbc taos) - target_include_directories(todbc PUBLIC - .) + target_include_directories(todbc PUBLIC .) install(CODE "execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/install.sh ${CMAKE_BINARY_DIR})") ENDIF () +IF (TD_WINDOWS_64) + FLEX_TARGET(todbcFlexScanner + todbc_scanner.l + ${CMAKE_CURRENT_BINARY_DIR}/todbc_scanner.c + ) + set(todbc_flex_scanner_src + ${FLEX_todbcFlexScanner_OUTPUTS} + ) + AUX_SOURCE_DIRECTORY(. SRC) + + # generate dynamic library (*.dll) + ADD_LIBRARY(todbc SHARED + ${SRC} + ${todbc_flex_scanner_src} + ${CMAKE_CURRENT_BINARY_DIR}/todbc.rc + todbc.def) + TARGET_LINK_LIBRARIES(todbc taos_static) + target_include_directories(todbc PUBLIC .) + target_compile_definitions(todbc PRIVATE "todbc_EXPORT") + + CONFIGURE_FILE("todbc.rc.in" + "${CMAKE_CURRENT_BINARY_DIR}/todbc.rc") + SET_TARGET_PROPERTIES(todbc PROPERTIES LINK_FLAGS + /DEF:todbc.def) + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /GL") + SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GL") +ENDIF () diff --git a/src/connector/odbc/src/todbc.c b/src/connector/odbc/src/todbc.c index 0a2a552fa3d7687fc95e21ebc62cc64c66836b39..618681aa5168735d99583946598de1bfd78bfd83 100644 --- a/src/connector/odbc/src/todbc.c +++ b/src/connector/odbc/src/todbc.c @@ -17,19 +17,17 @@ #define _XOPEN_SOURCE #define _DEFAULT_SOURCE +#include "todbc_log.h" +#include "todbc_flex.h" + #include "taos.h" -#include "os.h" #include "taoserror.h" #include "todbc_util.h" #include "todbc_conv.h" -#include #include -#include - - #define GET_REF(obj) atomic_load_64(&obj->refcount) #define INC_REF(obj) atomic_add_fetch_64(&obj->refcount, 1) #define DEC_REF(obj) atomic_sub_fetch_64(&obj->refcount, 1) @@ -47,10 +45,10 @@ do { basename((char*)__FILE__), __LINE__, \ ##__VA_ARGS__); \ if (n<0) break; \ - char *err_str = (char*)realloc(obj->err.err_str, n+1); \ + char *err_str = (char*)realloc(obj->err.err_str, (size_t)n+1); \ if (!err_str) break; \ obj->err.err_str = err_str; \ - snprintf(obj->err.err_str, n+1, "[TSDB:%x]%s: @%s[%d]" err_fmt "", \ + snprintf(obj->err.err_str, (size_t)n+1, "[TSDB:%x]%s: @%s[%d]" err_fmt "", \ eno, estr, \ basename((char*)__FILE__), __LINE__, \ ##__VA_ARGS__); \ @@ -64,14 +62,14 @@ do { obj->err.sql_state[0] = '\0'; \ } while (0) -#define FILL_ERROR(obj) \ -do { \ - size_t n = sizeof(obj->err.sql_state); \ - if (Sqlstate) strncpy((char*)Sqlstate, (char*)obj->err.sql_state, n); \ - if (NativeError) *NativeError = obj->err.err_no; \ - snprintf((char*)MessageText, BufferLength, "%s", obj->err.err_str); \ - if (TextLength && obj->err.err_str) *TextLength = strlen(obj->err.err_str); \ - if (TextLength && obj->err.err_str) *TextLength = utf8_chars(obj->err.err_str); \ +#define FILL_ERROR(obj) \ +do { \ + size_t n = sizeof(obj->err.sql_state); \ + if (Sqlstate) strncpy((char*)Sqlstate, (char*)obj->err.sql_state, n); \ + if (NativeError) *NativeError = obj->err.err_no; \ + snprintf((char*)MessageText, (size_t)BufferLength, "%s", obj->err.err_str); \ + if (TextLength && obj->err.err_str) *TextLength = (SQLSMALLINT)strlen(obj->err.err_str); \ + if (TextLength && obj->err.err_str) *TextLength = (SQLSMALLINT)utf8_chars(obj->err.err_str); \ } while (0) #define FREE_ERROR(obj) \ @@ -94,7 +92,7 @@ do { SET_ERROR(obj, sqlstate, TSDB_CODE_QRY_INVALID_QHANDLE, err_fmt, ##__VA_ARGS__); \ } while (0); -#define SDUP(s,n) (s ? (s[n] ? (const char*)strndup((const char*)s,n) : (const char*)s) : strdup("")) +#define SDUP(s,n) (s ? (s[(size_t)n] ? (const char*)strndup((const char*)s,(size_t)n) : (const char*)s) : strdup("")) #define SFRE(x,s,n) \ do { \ if (x==(const char*)s) break; \ @@ -145,7 +143,7 @@ do { \ gettimeofday(&tv1, NULL); \ double delta = difftime(tv1.tv_sec, tv0.tv_sec); \ delta *= 1000000; \ - delta += (tv1.tv_usec-tv0.tv_usec); \ + delta += (double)(tv1.tv_usec-tv0.tv_usec); \ delta /= 1000000; \ D("%s: elapsed: [%.6f]s", #statement, delta); \ } while (0) @@ -259,7 +257,7 @@ struct c_target_s { static pthread_once_t init_once = PTHREAD_ONCE_INIT; static void init_routine(void); -static int do_field_display_size(TAOS_FIELD *field); +static size_t do_field_display_size(TAOS_FIELD *field); static iconv_t sql_get_w2c(sql_t *sql) { if (sql->w2c == (iconv_t)-1) { sql->w2c = iconv_open("UTF-8", "UCS-2LE"); @@ -416,9 +414,9 @@ static SQLRETURN doSQLConnect(SQLHDBC ConnectionHandle, return SQL_ERROR; } - NameLength1 = (NameLength1==SQL_NTS) ? strlen((const char*)ServerName) : NameLength1; - NameLength2 = (NameLength2==SQL_NTS) ? strlen((const char*)UserName) : NameLength2; - NameLength3 = (NameLength3==SQL_NTS) ? strlen((const char*)Authentication) : NameLength3; + NameLength1 = (NameLength1==SQL_NTS) ? (SQLSMALLINT)strlen((const char*)ServerName) : NameLength1; + NameLength2 = (NameLength2==SQL_NTS) ? (SQLSMALLINT)strlen((const char*)UserName) : NameLength2; + NameLength3 = (NameLength3==SQL_NTS) ? (SQLSMALLINT)strlen((const char*)Authentication) : NameLength3; if (NameLength1 < 0 || NameLength2 < 0 || NameLength3 < 0) { SET_ERROR(conn, "HY090", TSDB_CODE_ODBC_BAD_ARG, ""); @@ -678,8 +676,8 @@ SQLRETURN SQL_API SQLExecDirect(SQLHSTMT StatementHandle, SQLRETURN SQL_API SQLExecDirectW(SQLHSTMT hstmt, SQLWCHAR *szSqlStr, SQLINTEGER cbSqlStr) { size_t bytes = 0; - SQLCHAR *utf8 = wchars_to_chars(szSqlStr, cbSqlStr, &bytes); - SQLRETURN r = SQLExecDirect(hstmt, utf8, bytes); + SQLCHAR *utf8 = wchars_to_chars(szSqlStr, (size_t)cbSqlStr, &bytes); + SQLRETURN r = SQLExecDirect(hstmt, utf8, (SQLINTEGER)bytes); if (utf8) free(utf8); return r; } @@ -707,7 +705,7 @@ static SQLRETURN doSQLNumResultCols(SQLHSTMT StatementHandle, int fields = taos_field_count(sql->rs); if (ColumnCount) { - *ColumnCount = fields; + *ColumnCount = (SQLSMALLINT)fields; } return SQL_SUCCESS; @@ -788,11 +786,11 @@ static SQLRETURN doSQLColAttribute(SQLHSTMT StatementHandle, switch (FieldIdentifier) { case SQL_COLUMN_DISPLAY_SIZE: { - *NumericAttribute = do_field_display_size(field); + *NumericAttribute = (SQLLEN)do_field_display_size(field); } break; case SQL_COLUMN_LABEL: { size_t n = sizeof(field->name); - strncpy(CharacterAttribute, field->name, (n>BufferLength ? BufferLength : n)); + strncpy(CharacterAttribute, field->name, (n>BufferLength ? (size_t)BufferLength : n)); } break; case SQL_COLUMN_UNSIGNED: { *NumericAttribute = SQL_FALSE; @@ -910,7 +908,7 @@ static SQLRETURN doSQLGetData(SQLHSTMT StatementHandle, CHK_CONV(0, tsdb_int64_to_double(v, TargetValue)); } break; case SQL_C_CHAR: { - CHK_CONV(0, tsdb_int64_to_char(v, TargetValue, BufferLength)); + CHK_CONV(0, tsdb_int64_to_char(v, TargetValue, (size_t)BufferLength)); } break; default: { SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, @@ -932,7 +930,7 @@ static SQLRETURN doSQLGetData(SQLHSTMT StatementHandle, return SQL_SUCCESS; } break; case SQL_C_CHAR: { - CHK_CONV(0, tsdb_double_to_char(v, TargetValue, BufferLength)); + CHK_CONV(0, tsdb_double_to_char(v, TargetValue, (size_t)BufferLength)); } break; default: { SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, @@ -950,7 +948,7 @@ static SQLRETURN doSQLGetData(SQLHSTMT StatementHandle, return SQL_SUCCESS; } break; case SQL_C_CHAR: { - CHK_CONV(0, tsdb_double_to_char(v, TargetValue, BufferLength)); + CHK_CONV(0, tsdb_double_to_char(v, TargetValue, (size_t)BufferLength)); } break; default: { SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, @@ -964,22 +962,22 @@ static SQLRETURN doSQLGetData(SQLHSTMT StatementHandle, SQL_TIMESTAMP_STRUCT ts = {0}; int64_t v = *(int64_t*)row; time_t t = v/1000; - struct tm tm = {0}; - localtime_r(&t, &tm); - ts.year = tm.tm_year + 1900; - ts.month = tm.tm_mon + 1; - ts.day = tm.tm_mday; - ts.hour = tm.tm_hour; - ts.minute = tm.tm_min; - ts.second = tm.tm_sec; - ts.fraction = v%1000 * 1000000; + struct tm vtm = {0}; + localtime_r(&t, &vtm); + ts.year = (SQLSMALLINT)(vtm.tm_year + 1900); + ts.month = (SQLUSMALLINT)(vtm.tm_mon + 1); + ts.day = (SQLUSMALLINT)(vtm.tm_mday); + ts.hour = (SQLUSMALLINT)(vtm.tm_hour); + ts.minute = (SQLUSMALLINT)(vtm.tm_min); + ts.second = (SQLUSMALLINT)(vtm.tm_sec); + ts.fraction = (SQLUINTEGER)(v%1000 * 1000000); switch (target.ct) { case SQL_C_SBIGINT: { *(int64_t*)TargetValue = v; return SQL_SUCCESS; } break; case SQL_C_CHAR: { - CHK_CONV(0, tsdb_timestamp_to_char(ts, TargetValue, BufferLength)); + CHK_CONV(0, tsdb_timestamp_to_char(ts, TargetValue, (size_t)BufferLength)); } break; case SQL_C_TYPE_TIMESTAMP: case SQL_C_TIMESTAMP: { @@ -995,11 +993,11 @@ static SQLRETURN doSQLGetData(SQLHSTMT StatementHandle, } } break; case TSDB_DATA_TYPE_BINARY: { - size_t field_bytes = field->bytes; + size_t field_bytes = (size_t)field->bytes; field_bytes -= VARSTR_HEADER_SIZE; switch (target.ct) { case SQL_C_CHAR: { - CHK_CONV(0, tsdb_chars_to_char((const char*)row, field_bytes, TargetValue, BufferLength)); + CHK_CONV(0, tsdb_chars_to_char((const char*)row, field_bytes, TargetValue, (size_t)BufferLength)); } break; default: { SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, @@ -1010,11 +1008,11 @@ static SQLRETURN doSQLGetData(SQLHSTMT StatementHandle, } } break; case TSDB_DATA_TYPE_NCHAR: { - size_t field_bytes = field->bytes; + size_t field_bytes = (size_t)field->bytes; field_bytes -= VARSTR_HEADER_SIZE; switch (target.ct) { case SQL_C_CHAR: { - CHK_CONV(0, tsdb_chars_to_char((const char*)row, field_bytes, TargetValue, BufferLength)); + CHK_CONV(0, tsdb_chars_to_char((const char*)row, field_bytes, TargetValue, (size_t)BufferLength)); } break; default: { SET_ERROR(sql, "HYC00", TSDB_CODE_ODBC_NOT_SUPPORT, @@ -1106,7 +1104,7 @@ static SQLRETURN doSQLPrepare(SQLHSTMT StatementHandle, int ok = 0; do { - int r = taos_stmt_prepare(sql->stmt, (const char *)StatementText, TextLength); + int r = taos_stmt_prepare(sql->stmt, (const char *)StatementText, (unsigned long)TextLength); if (r) { SET_ERROR(sql, "HY000", r, "failed to prepare a TAOS statement"); break; @@ -1130,7 +1128,7 @@ static SQLRETURN doSQLPrepare(SQLHSTMT StatementHandle, DASSERT(params>=0); if (params>0) { - param_bind_t *ar = (param_bind_t*)calloc(1, params * sizeof(*ar)); + param_bind_t *ar = (param_bind_t*)calloc(1, ((size_t)params) * sizeof(*ar)); if (!ar) { SET_ERROR(sql, "HY001", TSDB_CODE_ODBC_OOM, ""); break; @@ -1173,11 +1171,11 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin return SQL_ERROR; } - SQLPOINTER paramValue = param->ParameterValue; - SQLSMALLINT valueType = param->ValueType; - SQLLEN *soi = param->StrLen_or_Ind; + unsigned char *paramValue = param->ParameterValue; + SQLSMALLINT valueType = param->ValueType; + SQLLEN *soi = param->StrLen_or_Ind; - size_t offset = idx_row * sql->rowlen + sql->ptr_offset; + size_t offset = ((size_t)idx_row) * sql->rowlen + sql->ptr_offset; if (paramValue) paramValue += offset; if (soi) soi = (SQLLEN*)((char*)soi + offset); @@ -1271,10 +1269,10 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin CHK_CONV(1, tsdb_double_to_bit(*(double*)paramValue, &bind->u.b)); } break; case SQL_C_CHAR: { - CHK_CONV(1, tsdb_chars_to_bit((const char *)paramValue, *soi, &bind->u.b)); + CHK_CONV(1, tsdb_chars_to_bit((const char *)paramValue, (size_t)*soi, &bind->u.b)); } break; case SQL_C_WCHAR: { - CHK_CONV(1, tsdb_wchars_to_bit(sql_get_w2c(sql), (const unsigned char*)paramValue, *soi, &bind->u.b)); + CHK_CONV(1, tsdb_wchars_to_bit(sql_get_w2c(sql), (const unsigned char*)paramValue, (size_t)*soi, &bind->u.b)); } break; case SQL_C_USHORT: case SQL_C_ULONG: @@ -1323,10 +1321,10 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin CHK_CONV(1, tsdb_int64_to_tinyint(*(int64_t*)paramValue, &bind->u.v1)); } break; case SQL_C_CHAR: { - CHK_CONV(1, tsdb_chars_to_tinyint((const char*)paramValue, *soi, &bind->u.v1)); + CHK_CONV(1, tsdb_chars_to_tinyint((const char*)paramValue, (size_t)*soi, &bind->u.v1)); } break; case SQL_C_WCHAR: { - CHK_CONV(1, tsdb_wchars_to_tinyint(sql_get_w2c(sql), (const unsigned char*)paramValue, *soi, &bind->u.v1)); + CHK_CONV(1, tsdb_wchars_to_tinyint(sql_get_w2c(sql), (const unsigned char*)paramValue, (size_t)*soi, &bind->u.v1)); } break; case SQL_C_USHORT: case SQL_C_ULONG: @@ -1377,10 +1375,10 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin CHK_CONV(1, tsdb_int64_to_smallint(*(int64_t*)paramValue, &bind->u.v2)); } break; case SQL_C_CHAR: { - CHK_CONV(1, tsdb_chars_to_smallint((const char*)paramValue, *soi, &bind->u.v2)); + CHK_CONV(1, tsdb_chars_to_smallint((const char*)paramValue, (size_t)*soi, &bind->u.v2)); } break; case SQL_C_WCHAR: { - CHK_CONV(1, tsdb_wchars_to_smallint(sql_get_w2c(sql), (const unsigned char*)paramValue, *soi, &bind->u.v2)); + CHK_CONV(1, tsdb_wchars_to_smallint(sql_get_w2c(sql), (const unsigned char*)paramValue, (size_t)*soi, &bind->u.v2)); } break; case SQL_C_USHORT: case SQL_C_ULONG: @@ -1431,10 +1429,10 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin CHK_CONV(1, tsdb_int64_to_int(*(int64_t*)paramValue, &bind->u.v4)); } break; case SQL_C_CHAR: { - CHK_CONV(1, tsdb_chars_to_int((const char*)paramValue, *soi, &bind->u.v4)); + CHK_CONV(1, tsdb_chars_to_int((const char*)paramValue, (size_t)*soi, &bind->u.v4)); } break; case SQL_C_WCHAR: { - CHK_CONV(1, tsdb_wchars_to_int(sql_get_w2c(sql), (const unsigned char*)paramValue, *soi, &bind->u.v4)); + CHK_CONV(1, tsdb_wchars_to_int(sql_get_w2c(sql), (const unsigned char*)paramValue, (size_t)*soi, &bind->u.v4)); } break; case SQL_C_USHORT: case SQL_C_ULONG: @@ -1485,10 +1483,10 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin CHK_CONV(1, tsdb_int64_to_bigint(*(int64_t*)paramValue, &bind->u.v8)); } break; case SQL_C_CHAR: { - CHK_CONV(1, tsdb_chars_to_bigint((const char*)paramValue, *soi, &bind->u.v8)); + CHK_CONV(1, tsdb_chars_to_bigint((const char*)paramValue, (size_t)*soi, &bind->u.v8)); } break; case SQL_C_WCHAR: { - CHK_CONV(1, tsdb_wchars_to_bigint(sql_get_w2c(sql), (const unsigned char*)paramValue, *soi, &bind->u.v8)); + CHK_CONV(1, tsdb_wchars_to_bigint(sql_get_w2c(sql), (const unsigned char*)paramValue, (size_t)*soi, &bind->u.v8)); } break; case SQL_C_USHORT: case SQL_C_ULONG: @@ -1545,10 +1543,10 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin bind->u.f4 = (float)*(double*)paramValue; } break; case SQL_C_CHAR: { - CHK_CONV(1, tsdb_chars_to_float((const char*)paramValue, *soi, &bind->u.f4)); + CHK_CONV(1, tsdb_chars_to_float((const char*)paramValue, (size_t)*soi, &bind->u.f4)); } break; case SQL_C_WCHAR: { - CHK_CONV(1, tsdb_wchars_to_float(sql_get_w2c(sql), (const unsigned char*)paramValue, *soi, &bind->u.f4)); + CHK_CONV(1, tsdb_wchars_to_float(sql_get_w2c(sql), (const unsigned char*)paramValue, (size_t)*soi, &bind->u.f4)); } break; case SQL_C_USHORT: case SQL_C_ULONG: @@ -1603,10 +1601,10 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin bind->u.f8 = *(double*)paramValue; } break; case SQL_C_CHAR: { - CHK_CONV(1, tsdb_chars_to_double((const char*)paramValue, *soi, &bind->u.f8)); + CHK_CONV(1, tsdb_chars_to_double((const char*)paramValue, (size_t)*soi, &bind->u.f8)); } break; case SQL_C_WCHAR: { - CHK_CONV(1, tsdb_wchars_to_double(sql_get_w2c(sql), (const unsigned char*)paramValue, *soi, &bind->u.f8)); + CHK_CONV(1, tsdb_wchars_to_double(sql_get_w2c(sql), (const unsigned char*)paramValue, (size_t)*soi, &bind->u.f8)); } break; case SQL_C_USHORT: case SQL_C_ULONG: @@ -1638,7 +1636,7 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin DASSERT(soi); DASSERT(*soi != SQL_NTS); size_t bytes = 0; - SQLCHAR *utf8 = wchars_to_chars(paramValue, *soi/2, &bytes); + SQLCHAR *utf8 = wchars_to_chars((const SQLWCHAR*)paramValue, (size_t)*soi/2, &bytes); bind->allocated = 1; bind->u.bin = utf8; bind->buffer_length = bytes; @@ -1649,7 +1647,7 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin if (*soi == SQL_NTS) { bind->buffer_length = strlen((const char*)paramValue); } else { - bind->buffer_length = *soi; + bind->buffer_length = (uintptr_t)*soi; } bind->buffer = bind->u.bin; } break; @@ -1697,9 +1695,9 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin size_t bytes = 0; int r = 0; int64_t t = 0; - SQLCHAR *utf8 = wchars_to_chars(paramValue, *soi/2, &bytes); + SQLCHAR *utf8 = wchars_to_chars((const SQLWCHAR*)paramValue, (size_t)*soi/2, &bytes); // why cast utf8 to 'char*' ? - r = taosParseTime((char*)utf8, &t, strlen((const char*)utf8), TSDB_TIME_PRECISION_MILLI, 0); + r = taosParseTime((char*)utf8, &t, (int)strlen((const char*)utf8), TSDB_TIME_PRECISION_MILLI, 0); bind->u.v8 = t; free(utf8); if (r) { @@ -1753,7 +1751,7 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin DASSERT(soi); DASSERT(*soi != SQL_NTS); size_t bytes = 0; - SQLCHAR *utf8 = wchars_to_chars(paramValue, *soi/2, &bytes); + SQLCHAR *utf8 = wchars_to_chars((const SQLWCHAR*)paramValue, (size_t)(*soi/2), &bytes); bind->allocated = 1; bind->u.nchar = (char*)utf8; bind->buffer_length = bytes; @@ -1764,7 +1762,7 @@ static SQLRETURN do_bind_param_value(sql_t *sql, int idx_row, int idx, param_bin if (*soi == SQL_NTS) { bind->buffer_length = strlen((const char*)paramValue); } else { - bind->buffer_length = *soi; + bind->buffer_length = (uintptr_t)*soi; } bind->buffer = bind->u.nchar; } break; @@ -1845,7 +1843,7 @@ static SQLRETURN do_execute(sql_t *sql) for (int i=0; in_rows; ++i) { TAOS_BIND *binds = NULL; if (sql->n_params>0) { - binds = (TAOS_BIND*)calloc(sql->n_params, sizeof(*binds)); + binds = (TAOS_BIND*)calloc((size_t)sql->n_params, sizeof(*binds)); if (!binds) { SET_ERROR(sql, "HY001", TSDB_CODE_ODBC_OOM, ""); return SQL_ERROR; @@ -1921,7 +1919,7 @@ static SQLRETURN doSQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT *StringLength) { // if this function is not exported, isql will never call SQLGetDiagRec - return SQL_ERROR; + return SQL_SUCCESS; } SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle, @@ -2117,14 +2115,14 @@ static SQLRETURN doSQLDriverConnect( if (host) { char *p = strchr(host, ':'); if (p) { - ip = strndup(host, p-host); + ip = strndup(host, (size_t)(p-host)); port = atoi(p+1); } } // TODO: data-race // TODO: shall receive ip/port from odbc.ini - conn->taos = taos_connect(ip ? ip : "localhost", userName, auth, NULL, port); + conn->taos = taos_connect(ip ? ip : "localhost", userName, auth, NULL, (uint16_t)port); free(ip); ip = NULL; if (!conn->taos) { SET_ERROR(conn, "HY000", terrno, "failed to connect to data source"); @@ -2132,7 +2130,7 @@ static SQLRETURN doSQLDriverConnect( } if (szConnStrOut) { - snprintf((char*)szConnStrOut, cbConnStrOutMax, "%s", connStr); + snprintf((char*)szConnStrOut, (size_t)cbConnStrOutMax, "%s", connStr); } if (pcbConnStrOut) { *pcbConnStrOut = cbConnStrIn; @@ -2220,13 +2218,13 @@ static SQLRETURN doSQLDescribeCol(SQLHSTMT StatementHandle, TAOS_FIELD *field = fields + ColumnNumber - 1; if (ColumnName) { size_t n = sizeof(field->name); - if (n>BufferLength) n = BufferLength; + if (n>BufferLength) n = (size_t)BufferLength; strncpy((char*)ColumnName, field->name, n); } if (NameLength) { - *NameLength = strnlen(field->name, sizeof(field->name)); + *NameLength = (SQLSMALLINT)strnlen(field->name, sizeof(field->name)); } - if (ColumnSize) *ColumnSize = field->bytes; + if (ColumnSize) *ColumnSize = (SQLULEN)field->bytes; if (DecimalDigits) *DecimalDigits = 0; if (DataType) { @@ -2334,7 +2332,7 @@ static SQLRETURN doSQLNumParams(SQLHSTMT hstmt, SQLSMALLINT *pcpar) return SQL_ERROR; } - if (pcpar) *pcpar = params; + if (pcpar) *pcpar = (SQLSMALLINT)params; return SQL_SUCCESS; } @@ -2420,7 +2418,7 @@ static void init_routine(void) { taos_init(); } -static int do_field_display_size(TAOS_FIELD *field) { +static size_t do_field_display_size(TAOS_FIELD *field) { switch (field->type) { case TSDB_DATA_TYPE_TINYINT: return 5; @@ -2448,7 +2446,7 @@ static int do_field_display_size(TAOS_FIELD *field) { case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: { - return 3*(field->bytes - VARSTR_HEADER_SIZE) + 2; + return 3*((size_t)field->bytes - VARSTR_HEADER_SIZE) + 2; } break; case TSDB_DATA_TYPE_TIMESTAMP: diff --git a/src/connector/odbc/src/todbc.def b/src/connector/odbc/src/todbc.def new file mode 100644 index 0000000000000000000000000000000000000000..3d34eef86b7d1bcb09069d4ae0b44e5b2de55cbd --- /dev/null +++ b/src/connector/odbc/src/todbc.def @@ -0,0 +1,28 @@ +EXPORTS +SQLAllocEnv +SQLFreeEnv +SQLAllocConnect +SQLFreeConnect +SQLConnect +SQLDisconnect +SQLAllocStmt +SQLAllocHandle +SQLFreeStmt +SQLExecDirect +SQLExecDirectW +SQLNumResultCols +SQLRowCount +SQLColAttribute +SQLGetData +SQLFetch +SQLPrepare +SQLExecute +SQLGetDiagField +SQLGetDiagRec +SQLBindParameter +SQLDriverConnect +SQLSetConnectAttr +SQLDescribeCol +SQLNumParams +SQLSetStmtAttr + diff --git a/src/connector/odbc/src/todbc.rc.in b/src/connector/odbc/src/todbc.rc.in new file mode 100644 index 0000000000000000000000000000000000000000..cf0b21145456eb20097ed3dda1e582cee1e343d2 --- /dev/null +++ b/src/connector/odbc/src/todbc.rc.in @@ -0,0 +1,31 @@ +1 VERSIONINFO + FILEVERSION ${TD_VER_NUMBER} + PRODUCTVERSION ${TD_VER_NUMBER} + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "ODBC Driver for TDengine" + VALUE "FileVersion", "${TD_VER_NUMBER}" + VALUE "InternalName", "todbc.dll(${TD_VER_CPUTYPE})" + VALUE "LegalCopyright", "Copyright (C) 2020 TAOS Data" + VALUE "OriginalFilename", "" + VALUE "ProductName", "todbc.dll(${TD_VER_CPUTYPE})" + VALUE "ProductVersion", "${TD_VER_NUMBER}" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END \ No newline at end of file diff --git a/src/connector/odbc/src/todbc.rsp b/src/connector/odbc/src/todbc.rsp new file mode 100644 index 0000000000000000000000000000000000000000..f5e511565872e51a6afa838ad6cb3d1774c2c422 --- /dev/null +++ b/src/connector/odbc/src/todbc.rsp @@ -0,0 +1,5 @@ +INSTALLDRIVER "TAOS ODBC|Driver=todbc.dll|FileUsage=0|ConnectFunctions=YYN" + + + + diff --git a/src/connector/odbc/src/todbc_conv.c b/src/connector/odbc/src/todbc_conv.c index bbb59c53adeb0216e559764c1986a555905f5874..d9ed708a5da51d51a48588d56f94f84a885e6261 100644 --- a/src/connector/odbc/src/todbc_conv.c +++ b/src/connector/odbc/src/todbc_conv.c @@ -15,8 +15,6 @@ #include "todbc_conv.h" -#include "todbc_util.h" - #include #include #include @@ -74,7 +72,7 @@ TSDB_CONV_CODE tsdb_iconv_conv(iconv_t cnv, const unsigned char *src, size_t *sl size_t sl = *slen; size_t dl = *dlen; - int n = iconv(cnv, &s, &sl, &d, &dl); + size_t n = iconv(cnv, &s, &sl, &d, &dl); int e = errno; if (dl) *d = '\0'; // what if all consumed? diff --git a/src/connector/odbc/src/todbc_conv.h b/src/connector/odbc/src/todbc_conv.h index 4b326230f0d47b730472e4a92a9ddf62923de3dc..21c74b5474593bb2d0063baf940a3343982e5a90 100644 --- a/src/connector/odbc/src/todbc_conv.h +++ b/src/connector/odbc/src/todbc_conv.h @@ -16,11 +16,9 @@ #ifndef _todbc_conv_h_ #define _todbc_conv_h_ -#include -#include -#include - -#include "iconv.h" +#include "os.h" +#include +#include typedef enum { diff --git a/src/connector/odbc/src/todbc_flex.h b/src/connector/odbc/src/todbc_flex.h new file mode 100644 index 0000000000000000000000000000000000000000..5ee5b5367606bb731ed1fc92366d659a9a422006 --- /dev/null +++ b/src/connector/odbc/src/todbc_flex.h @@ -0,0 +1,22 @@ +/* + * 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_H_ +#define _TODBC_FLEX_H_ + +int todbc_parse_conn_string(const char *conn, char **dsn, char **uid, char **pwd, char **host); + +#endif // _TODBC_FLEX_H_ + diff --git a/src/connector/odbc/src/todbc_log.h b/src/connector/odbc/src/todbc_log.h index ff0409fef6ccc01fb2173905208833983c7833f9..391a690cccb0954736cac76af3354cc8a39754a8 100644 --- a/src/connector/odbc/src/todbc_log.h +++ b/src/connector/odbc/src/todbc_log.h @@ -16,9 +16,7 @@ #ifndef _todbc_log_h_ #define _todbc_log_h_ -#include -#include -#include +#include "os.h" #define D(fmt, ...) \ fprintf(stderr, \ diff --git a/src/connector/odbc/src/todbc_scanner.l b/src/connector/odbc/src/todbc_scanner.l index 8e178aa366c94d3037d42fa25f0c0b0d1298c70a..25a46e03cfed0bdf3b40843f9b388a3b246eb978 100644 --- a/src/connector/odbc/src/todbc_scanner.l +++ b/src/connector/odbc/src/todbc_scanner.l @@ -1,8 +1,12 @@ %{ -#include "todbc_util.h" - +#include "todbc_flex.h" #include +#ifdef _MSC_VER +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#endif + typedef struct params_s params_t; struct params_s { char *key; @@ -68,6 +72,8 @@ do { \ %option prefix="todbc_yy" %option extra-type="struct params_s *" +%option nounistd +%option never-interactive %option reentrant %option noyywrap %option noinput nounput @@ -98,8 +104,7 @@ do { \ [{] { CHG_STATE(BRACE1); } .|\n { return -1; } -[[:space:]]+ { } -[^{}\n[:space:]]+ { set_val(); CHG_STATE(BRACE2); } +[^{}\n]+ { set_val(); CHG_STATE(BRACE2); } .|\n { return -1; } [[:space:]]+ { } diff --git a/src/connector/odbc/src/todbc_util.c b/src/connector/odbc/src/todbc_util.c index 378a2e1b754c7b3e2396b714a0a383c1bb3af1e2..34008a83556caec3366b651d81f886a5279a936e 100644 --- a/src/connector/odbc/src/todbc_util.c +++ b/src/connector/odbc/src/todbc_util.c @@ -14,14 +14,10 @@ */ #include "todbc_util.h" - -#include "iconv.h" - -#include -#include +#include "todbc_log.h" +#include #include -#include -#include + const char* sql_sql_type(int type) { switch (type) { @@ -125,7 +121,7 @@ int string_conv(const char *fromcode, const char *tocode, iconv_t conv = iconv_open(tocode, fromcode); if (!conv) return -1; - int r = 0; + size_t r = 0; do { char *s = (char*)src; char *d = (char*)dst; @@ -141,7 +137,7 @@ int string_conv(const char *fromcode, const char *tocode, } while (0); iconv_close(conv); - return r; + return (int)r; } int utf8_chars(const char *src) @@ -161,7 +157,7 @@ int utf8_chars(const char *src) size_t chars = (sizeof(buf) - dlen) / 2; iconv_close(conv); - return chars; + return (int)chars; } unsigned char* utf8_to_ucs4le(const char *utf8, size_t *chars) @@ -240,7 +236,7 @@ size_t wchars_to_chars2(const SQLWCHAR *src, size_t slen, SQLCHAR *dst, size_t d { size_t consumed=0, generated=0; int n = string_conv("UCS-2LE", "UTF-8", (const unsigned char*)src, slen, dst, dlen, &consumed, &generated); - if (n) return -1; + if (n) return (size_t)-1; return generated; } @@ -248,7 +244,7 @@ size_t chars_to_wchars2(const SQLCHAR *src, size_t slen, SQLWCHAR *dst, size_t d { size_t consumed=0, generated=0; int n = string_conv("UTF-8", "UCS-2LE", (const unsigned char*)src, slen, (unsigned char*)dst, dlen, &consumed, &generated); - if (n) return -1; + if (n) return (size_t)-1; return generated; } diff --git a/src/connector/odbc/src/todbc_util.h b/src/connector/odbc/src/todbc_util.h index 5f58ff13cefed71ca0e988cd45683876aed256a6..f9339f939633842cc441609656d099d28160384d 100644 --- a/src/connector/odbc/src/todbc_util.h +++ b/src/connector/odbc/src/todbc_util.h @@ -16,10 +16,10 @@ #ifndef _TODBC_UTIL_H_ #define _TODBC_UTIL_H_ -#include "todbc_log.h" +#include "os.h" -#include #include +#include const char* sql_sql_type(int type); const char* sql_c_type(int type); @@ -27,8 +27,6 @@ const char* sql_c_type(int type); int is_valid_sql_c_type(int type); int is_valid_sql_sql_type(int type); -int todbc_parse_conn_string(const char *conn, char **dsn, char **uid, char **pwd, char **host); - int string_conv(const char *fromcode, const char *tocode, const unsigned char *src, size_t sbytes, unsigned char *dst, size_t dbytes, diff --git a/src/connector/odbc/tests/CMakeLists.txt b/src/connector/odbc/tests/CMakeLists.txt index ac57a5647fce8bd036e133936284f3f4c847d8c8..2edf45a852a2f36bbbc60bb03686a2f90ee6979c 100644 --- a/src/connector/odbc/tests/CMakeLists.txt +++ b/src/connector/odbc/tests/CMakeLists.txt @@ -5,3 +5,9 @@ IF (TD_LINUX) ADD_EXECUTABLE(tcodbc main.c) TARGET_LINK_LIBRARIES(tcodbc odbc) ENDIF () + +IF (TD_WINDOWS_64) + AUX_SOURCE_DIRECTORY(. SRC) + ADD_EXECUTABLE(tcodbc main.c) + TARGET_LINK_LIBRARIES(tcodbc odbc32 os) +ENDIF () diff --git a/src/connector/odbc/tests/main.c b/src/connector/odbc/tests/main.c index 0d42da985de8da9d2bfa0d51a3ac13624e0e5a03..c2d0869e026bf2c7529f7eb23f97f6dba5c68d81 100644 --- a/src/connector/odbc/tests/main.c +++ b/src/connector/odbc/tests/main.c @@ -1,17 +1,16 @@ -#include +#include "../src/todbc_log.h" + +#ifdef _MSC_VER +#include +#include +#include "os.h" +#endif #include #include #include #include -#include "os.h" -#include "../src/todbc_log.h" - -// static const char *dsn = "TAOS_DSN"; -// static const char *uid = "root"; -// static const char *pwd = "taosdata"; - #define CHK_TEST(statement) \ do { \ D("testing: %s", #statement); \ @@ -72,9 +71,9 @@ static int open_connect(const char *dsn, const char *uid, const char *pwd, SQLHE CHK_RESULT(r, SQL_HANDLE_ENV, env, ""); if (r!=SQL_SUCCESS) break; do { - r = SQLConnect(conn, (SQLCHAR*)dsn, strlen(dsn), - (SQLCHAR*)uid, strlen(uid), - (SQLCHAR*)pwd, strlen(pwd)); + r = SQLConnect(conn, (SQLCHAR*)dsn, (SQLSMALLINT)strlen(dsn), + (SQLCHAR*)uid, (SQLSMALLINT)strlen(uid), + (SQLCHAR*)pwd, (SQLSMALLINT)strlen(pwd)); CHK_RESULT(r, SQL_HANDLE_DBC, conn, ""); if (r==SQL_SUCCESS) { *pEnv = env; @@ -105,7 +104,7 @@ static int open_driver_connect(const char *connstr, SQLHENV *pEnv, SQLHDBC *pCon SQLHDBC ConnectionHandle = conn; SQLHWND WindowHandle = NULL; SQLCHAR * InConnectionString = (SQLCHAR*)connstr; - SQLSMALLINT StringLength1 = strlen(connstr); + SQLSMALLINT StringLength1 = (SQLSMALLINT)strlen(connstr); SQLCHAR * OutConnectionString = buf; SQLSMALLINT BufferLength = sizeof(buf); SQLSMALLINT * StringLength2Ptr = &blen; @@ -144,7 +143,7 @@ static int do_statement(SQLHSTMT stmt, const char *statement) { CHK_RESULT(r, SQL_HANDLE_STMT, stmt, ""); for (size_t i=0; i4) ? argv[4] : NULL; const char *sqls = (argc>5) ? argv[5] : NULL; + dsn = NULL; + uid = NULL; + pwd = NULL; + connstr = argv[1]; + sqls = argv[2]; if (0) { CHK_TEST(test_env()); diff --git a/src/connector/odbc/tests/simples.stmts b/src/connector/odbc/tests/simples.stmts new file mode 100644 index 0000000000000000000000000000000000000000..0db58a8807491b9ea4be96dc7c4efc5b43488244 --- /dev/null +++ b/src/connector/odbc/tests/simples.stmts @@ -0,0 +1,44 @@ +P:drop database if exists m; +P:create database m; +P:use m; + +P:create table t (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, blob binary(1), name nchar(1)); +P:insert into t (ts, b) values('2020-10-10 00:00:00', 0); +P:insert into t (ts, b) values('2020-10-10 00:00:00.001', 1); +P:insert into t (ts, b) values('2020-10-10 00:00:00.002', 10); +P:select * from t; + +P:drop table t; +P:create table t (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, blob binary(1), name nchar(1)); +P:insert into t (ts, v1) values('2020-10-10 00:00:00', 0); +P:insert into t (ts, v1) values('2020-10-10 00:00:00.001', 1); +P:insert into t (ts, v1) values('2020-10-10 00:00:00.002', 10); +P:select * from t; + +P:drop table t; +P:create table t (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, blob binary(1), name nchar(1)); +P:insert into t (ts, name) values('2020-10-10 00:00:00', 0); +P:insert into t (ts, name) values('2020-10-10 00:00:00.001', 1); +P:insert into t (ts, name) values('2020-10-10 00:00:00.002', '人'); +P:insert into t (ts, name) values('2020-10-10 00:00:00.003', 'a'); +P:select * from t; + +P:drop table t; +P:create table t (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, blob binary(3), name nchar(1)); +P:insert into t (ts, blob) values('2020-10-10 00:00:00', 0); +P:insert into t (ts, blob) values('2020-10-10 00:00:00.001', 1); +P:insert into t (ts, blob) values('2020-10-10 00:00:00.002', 'a'); +P:insert into t (ts, blob) values('2020-10-10 00:00:00.003', 'b'); +P:insert into t (ts, blob) values('2020-10-10 00:00:00.004', '人'); +P:select * from t; + +P:drop table t; +P:create table t (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, blob binary(3), name nchar(1)); +N:insert into t (ts, blob) values('2020-10-10 00:00:00', '1234'); +N:insert into t (ts, blob) values('2020-10-10 00:00:00.001', '0000'); +N:insert into t (ts, blob) values('2020-10-10 00:00:00.002', '人a'); +P:insert into t (ts, blob) values('2020-10-10 00:00:00.003', 'a'); +P:insert into t (ts, blob) values('2020-10-10 00:00:00.004', 'b'); +P:insert into t (ts, blob) values('2020-10-10 00:00:00.005', '人'); +P:select * from t; + diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 70ef5e18b6a0adb73e3c8259712befa3e9a1d780..4b40d3919be1df5d6543b06ef7ba5889d477c62e 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -24,9 +24,9 @@ extern "C" { #include #ifdef TAOS_ERROR_C -#define TAOS_DEFINE_ERROR(name, mod, code, msg) {.val = (0x80000000 | ((mod)<<16) | (code)), .str=(msg)}, +#define TAOS_DEFINE_ERROR(name, mod, code, msg) {.val = (int32_t)((0x80000000 | ((mod)<<16) | (code))), .str=(msg)}, #else -#define TAOS_DEFINE_ERROR(name, mod, code, msg) static const int32_t name = (0x80000000 | ((mod)<<16) | (code)); +#define TAOS_DEFINE_ERROR(name, mod, code, msg) static const int32_t name = (int32_t)((0x80000000 | ((mod)<<16) | (code))); #endif #define TAOS_SYSTEM_ERROR(code) (0x80ff0000 | (code)) diff --git a/src/os/inc/osTime.h b/src/os/inc/osTime.h index 6b209219c6c736ed95c69659a78d14037987be00..b20ccadadb22a04733d97bd19b919660ee677d0d 100644 --- a/src/os/inc/osTime.h +++ b/src/os/inc/osTime.h @@ -38,14 +38,14 @@ int32_t taosGetTimestampSec(); static FORCE_INLINE int64_t taosGetTimestampMs() { struct timeval systemTime; gettimeofday(&systemTime, NULL); - return (int64_t)systemTime.tv_sec * 1000L + (uint64_t)systemTime.tv_usec / 1000; + return (int64_t)systemTime.tv_sec * 1000L + (int64_t)systemTime.tv_usec / 1000; } //@return timestamp in microsecond static FORCE_INLINE int64_t taosGetTimestampUs() { struct timeval systemTime; gettimeofday(&systemTime, NULL); - return (int64_t)systemTime.tv_sec * 1000000L + (uint64_t)systemTime.tv_usec; + return (int64_t)systemTime.tv_sec * 1000000L + (int64_t)systemTime.tv_usec; } /* diff --git a/src/os/inc/osWindows.h b/src/os/inc/osWindows.h index dc1da35037dc06c258856a1a143146492eeed0e5..518719c3f0213811aeb92c7852911ce78a7326d6 100644 --- a/src/os/inc/osWindows.h +++ b/src/os/inc/osWindows.h @@ -43,6 +43,7 @@ #include "msvcProcess.h" #include "msvcDirect.h" #include "msvcFcntl.h" +#include "msvcLibgen.h" #include "msvcStdio.h" #include "sys/msvcStat.h" #include "sys/msvcTypes.h" diff --git a/src/os/src/windows/wSysinfo.c b/src/os/src/windows/wSysinfo.c index 61adc3ee14ed4a815117d306559970f67a961ea8..1bfee25c4a6a1851bdfbc16e795185412f007df2 100644 --- a/src/os/src/windows/wSysinfo.c +++ b/src/os/src/windows/wSysinfo.c @@ -31,7 +31,10 @@ #pragma comment(lib, "Mswsock.lib ") #endif +#pragma warning(push) +#pragma warning(disable:4091) #include +#pragma warning(pop) static void taosGetSystemTimezone() { // get and set default timezone