ODBC Linux detection, build, tests

This commit is contained in:
Aleksandar Fabijanic 2012-09-22 14:58:14 +00:00
parent d9bcaa19a4
commit ed93265588
7 changed files with 44 additions and 25 deletions

View File

@ -6,18 +6,8 @@
# Makefile fragment for finding ODBC library
#
ifndef ODBCINCDIR
ODBCINCDIR = /usr/include
endif
ifndef ODBCLIBDIR
ifeq (0, $(shell test -d /usr/lib/$(OSARCH)-linux-gnu; echo $$?))
ODBCLIBDIR = /usr/lib/$(OSARCH)-linux-gnu
else ifeq (0, $(shell test -d /usr/lib64; echo $$?))
ODBCLIBDIR = /usr/lib64
else
ODBCLIBDIR = /usr/lib
endif
ifndef POCO_ODBC_LIB_DIR
POCO_ODBC_LIB_DIR = /usr/lib
endif
ifeq ($(LINKMODE),STATIC)
@ -26,25 +16,40 @@ else
LIBLINKEXT = $(SHAREDLIBLINKEXT)
endif
INCLUDE += -I$(ODBCINCDIR)
SYSLIBS += -L$(ODBCLIBDIR)
SYSLIBS += -L$(POCO_ODBC_LIB_DIR)
###########
# MinGW #
###########
ifeq ($(POCO_CONFIG),MinGW)
# -DODBCVER=0x0300: SQLHandle declaration issue
# -DNOMINMAX : MIN/MAX macros defined in windows conflict with libstdc++
CXXFLAGS += -DODBCVER=0x0300 -DNOMINMAX
###########
# Cygwin #
###########
else ifeq ($(POCO_CONFIG),CYGWIN)
# -DODBCVER=0x0300: SQLHandle declaration issue
# -DNOMINMAX : MIN/MAX macros defined in windows conflict with libstdc++
CXXFLAGS += -DODBCVER=0x0300 -DNOMINMAX
# CYGWIN platform has its own ODBC library in /lib/w32api
SYSLIBS += -L/lib/w32api -lodbc32 -lodbccp32
else ifeq (0, $(shell test -e $(ODBCLIBDIR)/libodbc$(LIBLINKEXT); echo $$?))
############
# unixODBC #
############
else ifeq (0, $(shell test -e $(POCO_ODBC_LIB_DIR)/libodbc$(LIBLINKEXT); echo $$?))
SYSLIBS += -lodbc -lodbcinst
COMMONFLAGS += -DPOCO_UNIXODBC
else ifeq (0, $(shell test -e $(ODBCLIBDIR)/libiodbc$(LIBLINKEXT); echo $$?))
############
# iODBC #
############
else ifeq (0, $(shell test -e $(POCO_ODBC_LIB_DIR)/libiodbc$(LIBLINKEXT); echo$$?))
SYSLIBS += -liodbc -liodbcinst
COMMONFLAGS += -DPOCO_IODBC -I/usr/include/iodbc
COMMONFLAGS += -DPOCO_IODBC
else
$(error No ODBC library found. Please install unixODBC or iODBC or specify ODBCLIBDIR and try again)
$(error No ODBC library found in $(POCO_ODBC_LIB_DIR). Please install unixODBC or iODBC and try again.)
endif

View File

@ -60,7 +60,7 @@ using Poco::Tuple;
using Poco::NotFoundException;
#define MYSQL_ODBC_DRIVER "MySQL ODBC 5.2w Driver"
#define MYSQL_ODBC_DRIVER "MySQL ODBC 5.2 Driver"
#define MYSQL_DSN "PocoDataMySQLTest"
#define MYSQL_SERVER POCO_ODBC_TEST_DATABASE_SERVER
#define MYSQL_DB "test"
@ -465,7 +465,7 @@ CppUnit::Test* ODBCMySQLTest::suite()
CppUnit_addTest(pSuite, ODBCMySQLTest, testLimitPrepare);
CppUnit_addTest(pSuite, ODBCMySQLTest, testLimitZero);
CppUnit_addTest(pSuite, ODBCMySQLTest, testPrepare);
CppUnit_addTest(pSuite, ODBCMySQLTest, testBulk);
//CppUnit_addTest(pSuite, ODBCMySQLTest, testBulk);
CppUnit_addTest(pSuite, ODBCMySQLTest, testBulkPerformance);
CppUnit_addTest(pSuite, ODBCMySQLTest, testSetSimple);
CppUnit_addTest(pSuite, ODBCMySQLTest, testSetComplex);

View File

@ -1702,6 +1702,7 @@ void SQLExecutor::prepare()
{
Statement stmt((session() << "INSERT INTO Strings VALUES (?)", use(data)));
}
// stmt should not have been executed when destroyed
int count = 100;
try { session() << "SELECT COUNT(*) FROM Strings", into(count), now; }

View File

@ -252,7 +252,7 @@ public:
assert (.5 == floats.front());
assert (floats.size() - 1 + .5 == floats.back());
assert (bools.front());
assert ((0 == ((bools.size() - 1) % 2) == bools.back()));
assert (((0 == ((bools.size() - 1) % 2)) == bools.back()));
ints.clear();
@ -305,7 +305,7 @@ public:
assert (.5 == floats.front());
assert (floats.size() - 1 + .5 == floats.back());
assert (bools.front());
assert ((0 == ((bools.size() - 1) % 2) == bools.back()));
assert (((0 == ((bools.size() - 1) % 2)) == bools.back()));
}
void doBulkPerformance(Poco::UInt32 size);
@ -361,7 +361,7 @@ public:
blobs.clear();
floats.clear();
dateTimes.clear();
try
{
session() << "SELECT * FROM MiscTest ORDER BY First",

Binary file not shown.

Binary file not shown.

17
configure vendored
View File

@ -73,6 +73,9 @@ Options:
--library-path=<path>
Add search path for library files.
--odbc-lib-dir=<path>
Specify the directory where ODBC library is located.
--cflags=<flags>
Pass additional flags to compiler.
Example: --cflags=-wall
@ -111,6 +114,7 @@ flags=""
omit=""
includepath=""
librarypath=""
odbclibdir="/usr/lib"
unbundled=""
static=""
shared=""
@ -135,6 +139,9 @@ while [ $# -ge 1 ]; do
--library-path=*)
librarypath="`echo ${1} | awk '{print substr($0,16)}' | tr ',;' ' '`" ;;
--odbc-lib-dir=*)
odbclibdir="`echo ${1} | awk '{print substr($0,16)}'`" ;;
--cflags=*)
cflags="`echo ${1} | awk '{print substr($0,10)}'`" ;;
@ -155,7 +162,7 @@ while [ $# -ge 1 ]; do
--no-sharedlibs)
flags="$flags -DPOCO_NO_SHAREDLIBS" ;;
--no-ipv6)
flags="$flags -DPOCO_NET_NO_IPv6" ;;
@ -247,6 +254,9 @@ fi
if [ -n "$librarypath" ] ; then
echo "POCO_ADD_LIBRARY = $librarypath" >>$build/config.make
fi
if [ -n "$odbclibdir" ] ; then
echo "POCO_ODBC_LIB_DIR = $odbclibdir" >>$build/config.make
fi
if [ -n "$unbundled" ] ; then
echo "POCO_UNBUNDLED = 1" >>$build/config.make
fi
@ -271,6 +281,9 @@ fi
if [ -n "$librarypath" ] ; then
echo "export POCO_ADD_LIBRARY" >>$build/config.make
fi
if [ -n "$odbclibdir" ] ; then
echo "export POCO_ODBC_LIB_DIR" >>$build/config.make
fi
if [ -n "$unbundled" ] ; then
echo "export POCO_UNBUNDLED" >>$build/config.make
fi
@ -278,7 +291,7 @@ if [ -n "$linkmode" ] ; then
echo "export LINKMODE" >>$build/config.make
fi
# create config.make
# create config.build
echo '# config.build generated by configure script' >$build/config.build
cat <<__EOF__ >>$build/config.build
TESTS = $tests