From 9648ae631dc9e965862a431f5c45727f68746070 Mon Sep 17 00:00:00 2001 From: freemine Date: Sun, 1 Nov 2020 07:11:46 +0800 Subject: [PATCH] add tconv --- src/connector/odbc/tests/CMakeLists.txt | 7 +++-- src/connector/odbc/tests/main.c | 36 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/connector/odbc/tests/CMakeLists.txt b/src/connector/odbc/tests/CMakeLists.txt index d777bf72ee..cb159a79ab 100644 --- a/src/connector/odbc/tests/CMakeLists.txt +++ b/src/connector/odbc/tests/CMakeLists.txt @@ -1,13 +1,16 @@ PROJECT(TDengine) IF (TD_LINUX) - AUX_SOURCE_DIRECTORY(. SRC) + # AUX_SOURCE_DIRECTORY(. SRC) ADD_EXECUTABLE(tcodbc main.c) TARGET_LINK_LIBRARIES(tcodbc odbc) + ADD_EXECUTABLE(tconv tconv.c) ENDIF () IF (TD_WINDOWS_64) - AUX_SOURCE_DIRECTORY(. SRC) + # AUX_SOURCE_DIRECTORY(. SRC) ADD_EXECUTABLE(tcodbc main.c) TARGET_LINK_LIBRARIES(tcodbc odbc32 odbccp32 user32 legacy_stdio_definitions os) + ADD_EXECUTABLE(tconv tconv.c) + TARGET_LINK_LIBRARIES(tconv os) ENDIF () diff --git a/src/connector/odbc/tests/main.c b/src/connector/odbc/tests/main.c index 74bceaaf31..c938bc9993 100644 --- a/src/connector/odbc/tests/main.c +++ b/src/connector/odbc/tests/main.c @@ -22,6 +22,17 @@ do { \ } \ } while (0); +typedef struct db_column_s db_column_t; +struct db_column_s { + char name[4096]; // seems enough + SQLSMALLINT nameLength; + SQLSMALLINT dataType; + SQLULEN columnSize; + SQLSMALLINT decimalDigits; + SQLSMALLINT nullable; +}; + +static db_column_t *columns = NULL; typedef struct data_s data_t; struct data_s { @@ -129,6 +140,30 @@ static int open_driver_connect(const char *connstr, SQLHENV *pEnv, SQLHDBC *pCon return 1; } + +static SQLRETURN traverse_cols(SQLHSTMT stmt, SQLSMALLINT cols) { + SQLRETURN r = SQL_ERROR; + for (SQLSMALLINT i=0; i