Skip to content

Commit

Permalink
ODBC-251 the testcase only + ODBC-210
Browse files Browse the repository at this point in the history
It's not quite clear if we should fix anything with 251, but adding the
testcase to have it.
Fixed rest of compilation warnings with iOdbc. At some point I've
decided it's better to suppress the most common warnings in tests - in
iOdbc SQLCHAR is unsigned char, and that caused tons of wranings
Paramethrised some OSX packaging files along the way and fixed some
cmake some found potential cmake issues.
  • Loading branch information
lawrinn committed Jun 19, 2019
1 parent bb8aaf1 commit d8dc34c
Show file tree
Hide file tree
Showing 18 changed files with 382 additions and 391 deletions.
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ IF(WIN32)
ADD_OPTION(WITH_SIGNCODE "Digitally sign files" OFF)
ENDIF()

IF(APPLE)
OPTION(WITH_IODBC "Build with iOdbc" ON)
ELSE()
OPTION(WITH_IODBC "Build with iOdbc" OFF)
ENDIF()
#ADD_OPTION(WITH_UNIT_TESTS "build test suite" ON)
#ADD_OPTION(WITH_SSL "Enables use of TLS/SSL library" ON)

Expand Down Expand Up @@ -193,12 +198,6 @@ IF(NOT WIN32)
# Looking for DM(UnixODBC) files
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindDM.cmake)

IF(APPLE)
SET(ODBC_LIB_DIR "/usr/local/Cellar/libiodbc/3.52.12/lib/")
SET(ODBC_INCLUDE_DIR "/usr/local/Cellar/libiodbc/3.52.12/include")
SET(DM_FOUND TRUE)
ENDIF()

IF(DM_FOUND)
INCLUDE_DIRECTORIES(${ODBC_INCLUDE_DIR})
LINK_DIRECTORIES(${ODBC_LIB_DIR})
Expand Down
5 changes: 3 additions & 2 deletions cmake/FindDM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ IF(ODBC_CONFIG)
IF(WITH_IODBC)
STRING(REPLACE "-I" "" ODBC_INCLUDE_DIR ${ODBC_INCLUDE_DIR})
STRING(REPLACE "-L" "" ODBC_LIB_DIR ${ODBC_LIB_DIR})
STRING(REPLACE " -liodbc -liodbcinst" "" ODBC_LIB_DIR ${ODBC_LIB_DIR})
STRING(REGEX REPLACE " +-liodbc -liodbcinst" "" ODBC_LIB_DIR ${ODBC_LIB_DIR})
ENDIF()
ELSE()
MESSAGE(STATUS "${ODBC_CONFIG_EXEC} is not found ")
# Try to find the include directory, giving precedence to special variables
SET(LIB_PATHS /usr/local /usr)
SET(LIB_PATHS /usr/local /usr /usr/local/Cellar/libiodbc/3.52.12)

IF("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
SET(LIB_PATHS "${LIB_PATHS}" "/usr/lib/x86_64-linux-gnu")
Expand All @@ -80,6 +80,7 @@ ELSE()
ENV DM_DIR
PATHS /usr/local
/usr
/usr/local/Cellar/libiodbc/3.52.12
PATH_SUFFIXES include include/iodbc
NO_DEFAULT_PATH
DOC "Driver Manager Includes")
Expand Down
6 changes: 3 additions & 3 deletions ma_dsn.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,16 +626,16 @@ SQLULEN MADB_DsnToString(MADB_Dsn *Dsn, char *OutString, SQLULEN OutLength)
{
Value= "1";
}
default:
/* To avoid warning with some compilers */
break;
case DSN_TYPE_CBOXGROUP:
if (*GET_FIELD_PTR(Dsn, &DsnKeys[i], char))
{
_snprintf(IntVal, sizeof(IntVal), "%hu", (short)*GET_FIELD_PTR(Dsn, &DsnKeys[i], char));
Value= IntVal;
}
break;
default:
/* To avoid warning with some compilers */
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion ma_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -3422,7 +3422,7 @@ SQLRETURN MADB_StmtTables(MADB_Stmt *Stmt, char *CatalogName, SQLSMALLINT Catalo
/* Since we treat our databases as catalogs, the only acceptable value for schema is NULL or "%"
if that is not the special case of call for schemas list. Otherwise we return empty resultset*/
else if (SchemaName &&
(!strcmp(SchemaName,SQL_ALL_SCHEMAS) && CatalogName && CatalogNameLength == 0 && TableName && TableNameLength == 0 ||
((!strcmp(SchemaName,SQL_ALL_SCHEMAS) && CatalogName && CatalogNameLength == 0 && TableName && TableNameLength == 0) ||
strcmp(SchemaName, SQL_ALL_SCHEMAS)))
{
MADB_InitDynamicString(&StmtStr, "SELECT NULL AS TABLE_CAT, NULL AS TABLE_SCHEM, "
Expand Down
9 changes: 9 additions & 0 deletions osxinstall/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,20 @@ ELSE()
ENDIF()

MESSAGE(STATUS "PKG package file name ${PKG_PACKAGE}")
IF(WITH_SIGNCODE)
SET(SIGN_WITH_DEVID "--sign \"${DEVELOPER_ID}\"")
ELSE()
SET(SIGN_WITH_DEVID "")
ENDIF()

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/WELCOME.html.in
${CMAKE_CURRENT_BINARY_DIR}/WELCOME.html @ONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/scripts/postinstall.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/postinstall @ONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/distribution.plist.in
${CMAKE_CURRENT_BINARY_DIR}/distribution.plist @ONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build_package.sh.in
${CMAKE_CURRENT_BINARY_DIR}/build_package.sh @ONLY)

ADD_EXECUTABLE(install_driver install_driver.c)
TARGET_LINK_LIBRARIES(install_driver ${ODBC_INSTLIBS})#${PLATFORM_DEPENDENCIES})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
# *************************************************************************************/

pkgbuild --root ROOT --scripts scripts --identifier $1 --version $2 libmaodbc.pkg
productbuild --distribution distribution.plist --resources . --package-path libmaodbc.pkg $3
productbuild --distribution distribution.plist --resources . --package-path libmaodbc.pkg @SIGN_WITH_DEVID@ $3
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
<choice id="com.mariadb.connector.odbc" visible="false">
<pkg-ref id="com.mariadb.connector.odbc"/>
</choice>
<pkg-ref id="com.mariadb.connector.odbc" version="3.1.0" onConclusion="none">libmaodbc.pkg</pkg-ref>
<pkg-ref id="com.mariadb.connector.odbc" version="@PRODUCT_VERSION@" onConclusion="none">libmaodbc.pkg</pkg-ref>
</installer-gui-script>
5 changes: 4 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ IF (WIN32 AND (BUILD_INTERACTIVE_TESTS OR USE_INTERACTIVE_TESTS))
MESSAGE(STATUS "Configuring to build interactive test")
SET (ODBC_TESTS ${ODBC_TESTS} "interactive")
ENDIF()

# iOdbc has
IF(WITH_IODBC)
SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-Wno-pointer-sign")
ENDIF()
FOREACH (ODBC_TEST ${ODBC_TESTS})
IF (${ODBC_TEST} STREQUAL "interactive")
ADD_EXECUTABLE(odbc_${ODBC_TEST} ${ODBC_TEST}.c tap.h)
Expand Down
14 changes: 7 additions & 7 deletions test/bulk.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
2013, 2018 MariaDB Corporation AB
2013, 2019 MariaDB Corporation AB
The MySQL Connector/ODBC is licensed under the terms of the GPLv2
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
Expand Down Expand Up @@ -85,7 +85,7 @@ ODBC_TEST(t_bulk_insert_test)
CHECK_STMT_RC(Stmt, SQLSetStmtAttr(Stmt, SQL_ATTR_ROW_ARRAY_SIZE,
(SQLPOINTER)2, 0));

CHECK_STMT_RC(Stmt, SQLPrepare(Stmt, "INSERT INTO t_bulk_insert VALUES (?,?,?)", SQL_NTS));
CHECK_STMT_RC(Stmt, SQLPrepare(Stmt, (SQLCHAR*)"INSERT INTO t_bulk_insert VALUES (?,?,?)", SQL_NTS));

CHECK_STMT_RC(Stmt, SQLBindCol(Stmt, 1, SQL_C_CHAR, &a[0], 30, indicator));
CHECK_STMT_RC(Stmt, SQLBindCol(Stmt, 2, SQL_DOUBLE, &b[0], 8, b_indicator));
Expand Down Expand Up @@ -443,8 +443,8 @@ ODBC_TEST(t_odbc90)
nval int not null, sval varchar(32) not null, ts timestamp)");
id[0]= 2;
ind4[0]= SQL_COLUMN_IGNORE;
strcpy(sval[0], "Record 1");
strcpy(sval[1], "Record 21");
strcpy((char*)(sval[0]), "Record 1");
strcpy((char*)(sval[1]), "Record 21");
nval[0]= 100;

sprintf((char *)conn, "DRIVER=%s;SERVER=%s;UID=%s;PASSWORD=%s;DATABASE=%s%s;",
Expand All @@ -454,7 +454,7 @@ ODBC_TEST(t_odbc90)
CHECK_ENV_RC(henv1, SQLSetEnvAttr(henv1, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER)SQL_OV_ODBC2, SQL_IS_INTEGER));
CHECK_ENV_RC(henv1, SQLAllocHandle(SQL_HANDLE_DBC, henv1, &Connection1));
CHECK_DBC_RC(Connection1, SQLDriverConnect(Connection1, NULL, conn, (SQLSMALLINT)strlen(conn), NULL, 0,
CHECK_DBC_RC(Connection1, SQLDriverConnect(Connection1, NULL, conn, (SQLSMALLINT)strlen((const char*)conn), NULL, 0,
NULL, SQL_DRIVER_NOPROMPT));
CHECK_DBC_RC(Connection1, SQLAllocHandle(SQL_HANDLE_STMT, Connection1, &Stmt1));

Expand Down Expand Up @@ -580,7 +580,7 @@ ODBC_TEST(t_odbc149)
/* This cursor closing is required, otherwise DM(not on Windows) freaks out */
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));

CHECK_STMT_RC(Stmt, SQLPrepare(Stmt, "INSERT INTO odbc149(id, ts, c, b, w) values(?, ?, ?, ?, ?)", SQL_NTS));
CHECK_STMT_RC(Stmt, SQLPrepare(Stmt, (SQLCHAR*)"INSERT INTO odbc149(id, ts, c, b, w) values(?, ?, ?, ?, ?)", SQL_NTS));
CHECK_STMT_RC(Stmt, SQLSetStmtAttr(Stmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)MAODBC_ROWS, 0));

CHECK_STMT_RC(Stmt, SQLBindParameter(Stmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, id, 0, NULL));
Expand Down Expand Up @@ -629,7 +629,7 @@ ODBC_TEST(t_odbc149)
}

is_num(idBuf, id[row]);
IS_STR(cBuf, c[row], strlen(c[row]) + 1);
IS_STR(cBuf, c[row], strlen((const char*)(c[row])) + 1);
is_num(bBufLen, bLen[row]);
memcmp(bBuf, b[row], bBufLen);
IS_WSTR(wBuf, w[row], wLen/sizeof(SQLWCHAR));
Expand Down
2 changes: 2 additions & 0 deletions test/connstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ ODBC_TEST(all_other_fields_test)
/* IsNamedPipe is switched off when TcpIp is switched on(since TcpIp goes after NamedPipe in the DsnKeys.
Do detect IsNamedPipe, comparing its offset in the MADB_Dsn with offset recorded in the DsnKeys */
is_num(*(my_bool*)((char*)Dsn + DsnKeys[i].DsnOffset), DsnKeys[i].DsnOffset == (size_t)&((MADB_Dsn*)NULL)->IsNamedPipe ? 0 : 1);
case DSN_TYPE_CBOXGROUP:
break;
}

++i;
Expand Down
Loading

0 comments on commit d8dc34c

Please sign in to comment.