#3317: Data::MySQL MySQL headers and library search paths

This commit is contained in:
Günter Obiltschnig
2021-06-17 14:21:22 +02:00
parent 65fd5f8f18
commit 08ef4dbf32
17 changed files with 125 additions and 63 deletions

View File

@@ -6,8 +6,9 @@
include $(POCO_BASE)/build/rules/global include $(POCO_BASE)/build/rules/global
SYSLIBS += -L/usr/local/lib -L/usr/local/lib$(LIB64SUFFIX)/mysql -L/usr/lib$(LIB64SUFFIX)/mysql -L/usr/mysql/lib$(LIB64SUFFIX) -L/usr/mysql/lib$(LIB64SUFFIX)/mysql -L/usr/local/mysql/lib$(LIB64SUFFIX) -L/usr/local/opt/mysql-client/lib -lmysqlclient include MySQL.make
INCLUDE += -I/usr/local/include/mysql/ -I/usr/include/mysql/ -I/usr/mysql/include/mysql -I/usr/local/mysql/include -I/usr/local/opt/mysql-client/include/mysql
SYSLIBS += -lmysqlclient
SYSFLAGS += -DTHREADSAFE -DNO_TCL SYSFLAGS += -DTHREADSAFE -DNO_TCL
objects = Binder Extractor SessionImpl Connector \ objects = Binder Extractor SessionImpl Connector \

40
Data/MySQL/MySQL.make Normal file
View File

@@ -0,0 +1,40 @@
#
# MySQL.make
#
# Makefile fragment for finding MySQL library
#
ifndef POCO_MYSQL_INCLUDE
ifeq (0, $(shell test -d /usr/local/include/mysql; echo $$?))
POCO_MYSQL_INCLUDE = /usr/local/include
else
ifeq (0, $(shell test -d /usr/local/opt/mysql-client; echo $$?))
POCO_MYSQL_INCLUDE = /usr/local/opt/mysql-client/include
else
ifeq (0, $(shell test -d /usr/local/opt/mysql; echo $$?))
POCO_MYSQL_INCLUDE = /usr/local/opt/mysql/include
endif
endif
endif
endif
ifndef POCO_MYSQL_LIB
ifeq (0, $(shell test -d /usr/local/include/mysql; echo $$?))
POCO_MYSQL_LIB = /usr/local/lib
else
ifeq (0, $(shell test -d /usr/local/opt/mysql-client/lib; echo $$?))
POCO_MYSQL_INCLUDE = /usr/local/opt/mysql-client/lib
else
ifeq (0, $(shell test -d /usr/local/opt/mysql/lib; echo $$?))
POCO_MYSQL_INCLUDE = /usr/local/opt/mysql/lib
endif
endif
endif
endif
ifdef POCO_MYSQL_INCLUDE
INCLUDE += -I$(POCO_MYSQL_INCLUDE)
endif
ifdef POCO_MYSQL_LIB
SYSLIBS += -L$(POCO_MYSQL_LIB)
endif

View File

@@ -22,7 +22,7 @@
#include "Poco/Data/AbstractBinder.h" #include "Poco/Data/AbstractBinder.h"
#include "Poco/Data/LOB.h" #include "Poco/Data/LOB.h"
#include "Poco/Data/MySQL/MySQLException.h" #include "Poco/Data/MySQL/MySQLException.h"
#include <mysql.h> #include <mysql/mysql.h>
namespace Poco { namespace Poco {
@@ -72,7 +72,7 @@ public:
virtual void bind(std::size_t pos, const unsigned long& val, Direction dir = PD_IN); virtual void bind(std::size_t pos, const unsigned long& val, Direction dir = PD_IN);
/// Binds an unsigned long. /// Binds an unsigned long.
#endif #endif
virtual void bind(std::size_t pos, const bool& val, Direction dir); virtual void bind(std::size_t pos, const bool& val, Direction dir);
/// Binds a boolean. /// Binds a boolean.

View File

@@ -20,9 +20,9 @@
#include "Poco/Data/MySQL/MySQL.h" #include "Poco/Data/MySQL/MySQL.h"
#include "Poco/Data/DataException.h" #include "Poco/Data/DataException.h"
#include <mysql/mysql.h>
#include <typeinfo> #include <typeinfo>
#include <string> #include <string>
#include <mysql.h>
namespace Poco { namespace Poco {

View File

@@ -18,9 +18,9 @@
#define Data_MySQL_ResultMetadata_INCLUDED #define Data_MySQL_ResultMetadata_INCLUDED
#include <mysql.h>
#include <vector>
#include "Poco/Data/MetaColumn.h" #include "Poco/Data/MetaColumn.h"
#include <mysql/mysql.h>
#include <vector>
#if LIBMYSQL_VERSION_ID >= 80000 #if LIBMYSQL_VERSION_ID >= 80000

View File

@@ -18,8 +18,8 @@
#define Data_MySQL_SessionHandle_INCLUDED #define Data_MySQL_SessionHandle_INCLUDED
#include <mysql.h>
#include "Poco/Data/MySQL/MySQLException.h" #include "Poco/Data/MySQL/MySQLException.h"
#include <mysql/mysql.h>
namespace Poco { namespace Poco {

View File

@@ -18,8 +18,8 @@
#define Data_MySQL_StatementHandle_INCLUDED #define Data_MySQL_StatementHandle_INCLUDED
#include <mysql.h>
#include "Poco/Data/MySQL/MySQLException.h" #include "Poco/Data/MySQL/MySQLException.h"
#include <mysql/mysql.h>
namespace Poco { namespace Poco {
@@ -66,7 +66,7 @@ public:
/// Fetches the column. /// Fetches the column.
int getAffectedRowCount() const; int getAffectedRowCount() const;
operator MYSQL_STMT* (); operator MYSQL_STMT* ();
/// Cast operator to native handle type. /// Cast operator to native handle type.

View File

@@ -20,7 +20,7 @@
#include "Poco/Data/MySQL/MySQL.h" #include "Poco/Data/MySQL/MySQL.h"
#include "Poco/Data/Session.h" #include "Poco/Data/Session.h"
#include <mysql.h> #include <mysql/mysql.h>
namespace Poco { namespace Poco {

View File

@@ -16,7 +16,7 @@
#include "Poco/Data/MySQL/SessionImpl.h" #include "Poco/Data/MySQL/SessionImpl.h"
#include "Poco/Data/SessionFactory.h" #include "Poco/Data/SessionFactory.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <mysql.h> #include <mysql/mysql.h>
namespace Poco { namespace Poco {
@@ -46,7 +46,7 @@ const std::string& Connector::name() const
Poco::AutoPtr<Poco::Data::SessionImpl> Connector::createSession(const std::string& connectionString, Poco::AutoPtr<Poco::Data::SessionImpl> Connector::createSession(const std::string& connectionString,
std::size_t timeout) std::size_t timeout)
{ {
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString, timeout)); return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString, timeout));
} }

View File

@@ -13,7 +13,7 @@
#include "Poco/Data/MySQL/MySQLException.h" #include "Poco/Data/MySQL/MySQLException.h"
#include <mysql.h> #include <mysql/mysql.h>
#include <stdio.h> #include <stdio.h>

View File

@@ -12,9 +12,9 @@
// //
#include <mysql.h>
#include "Poco/Data/MySQL/StatementExecutor.h" #include "Poco/Data/MySQL/StatementExecutor.h"
#include "Poco/Format.h" #include "Poco/Format.h"
#include <mysql/mysql.h>
namespace Poco { namespace Poco {
@@ -52,7 +52,7 @@ void StatementExecutor::prepare(const std::string& query)
_state = STMT_COMPILED; _state = STMT_COMPILED;
return; return;
} }
int rc = mysql_stmt_prepare(_pHandle, query.c_str(), static_cast<unsigned int>(query.length())); int rc = mysql_stmt_prepare(_pHandle, query.c_str(), static_cast<unsigned int>(query.length()));
if (rc != 0) if (rc != 0)
{ {
@@ -119,7 +119,7 @@ bool StatementExecutor::fetch()
int res = mysql_stmt_fetch(_pHandle); int res = mysql_stmt_fetch(_pHandle);
// we have specified zero buffers for BLOBs, so DATA_TRUNCATED is normal in this case // we have specified zero buffers for BLOBs, so DATA_TRUNCATED is normal in this case
if ((res != 0) && (res != MYSQL_NO_DATA) && (res != MYSQL_DATA_TRUNCATED)) if ((res != 0) && (res != MYSQL_NO_DATA) && (res != MYSQL_DATA_TRUNCATED))
throw StatementException("mysql_stmt_fetch error", _pHandle, _query); throw StatementException("mysql_stmt_fetch error", _pHandle, _query);
return (res == 0) || (res == MYSQL_DATA_TRUNCATED); return (res == 0) || (res == MYSQL_DATA_TRUNCATED);

View File

@@ -15,7 +15,7 @@
#include "Poco/Data/MySQL/Utility.h" #include "Poco/Data/MySQL/Utility.h"
#include <mysql.h> #include <mysql/mysql.h>
namespace Poco { namespace Poco {

View File

@@ -6,10 +6,10 @@
include $(POCO_BASE)/build/rules/global include $(POCO_BASE)/build/rules/global
INCLUDE += -I./../include -I/usr/local/include/mysql -I/usr/include/mysql/ -I/usr/mysql/include/mysql -I/usr/local/mysql/include -I/usr/local/opt/mysql-client/include/mysql include $(POCO_BASE)/Data/MySQL/MySQL.make
# Note: linking order is important, do not change it. # Note: linking order is important, do not change it.
SYSLIBS += -L/usr/local/lib -L/usr/local/lib$(LIB64SUFFIX)/mysql -L/usr/lib$(LIB64SUFFIX)/mysql -L/usr/mysql/lib$(LIB64SUFFIX) -L/usr/mysql/lib$(LIB64SUFFIX)/mysql -L/usr/local/mysql/lib$(LIB64SUFFIX) -L/usr/local/opt/mysql-client/lib -lmysqlclient -lz -lpthread -ldl SYSLIBS += -lmysqlclient -lz -lpthread -ldl
objects = MySQLTestSuite Driver MySQLTest SQLExecutor objects = MySQLTestSuite Driver MySQLTest SQLExecutor

View File

@@ -45,7 +45,9 @@ Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor = 0;
#define MYSQL_USER "pocotest" #define MYSQL_USER "pocotest"
#define MYSQL_PWD "pocotest" #define MYSQL_PWD "pocotest"
#define MYSQL_HOST "127.0.0.1" #define MYSQL_HOST "127.0.0.1"
#ifndef MYSQL_PORT
#define MYSQL_PORT 3306 #define MYSQL_PORT 3306
#endif
#define MYSQL_DB "pocotest" #define MYSQL_DB "pocotest"
// //

View File

@@ -11,6 +11,7 @@
#include "MySQLTestSuite.h" #include "MySQLTestSuite.h"
#include "MySQLTest.h" #include "MySQLTest.h"
CppUnit::Test* MySQLTestSuite::suite() CppUnit::Test* MySQLTestSuite::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MySQLTestSuite"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MySQLTestSuite");

View File

@@ -27,9 +27,9 @@
#ifdef _WIN32 #ifdef _WIN32
#include <Winsock2.h> #include <Winsock2.h>
#endif #endif
#include <mysql.h> #include <mysql/mysql.h>
#include <iostream> #include <iostream>
#include <limits> #include <limits>
@@ -141,7 +141,7 @@ private:
} } // namespace Poco::Data } } // namespace Poco::Data
SQLExecutor::SQLExecutor(const std::string& name, Poco::Data::Session* pSession): SQLExecutor::SQLExecutor(const std::string& name, Poco::Data::Session* pSession):
CppUnit::TestCase(name), CppUnit::TestCase(name),
_pSession(pSession) _pSession(pSession)
{ {
@@ -161,22 +161,22 @@ void SQLExecutor::bareboneMySQLTest(const char* host, const char* user, const ch
MYSQL* tmp = mysql_real_connect(hsession, host, user, pwd, db, port, 0, 0); MYSQL* tmp = mysql_real_connect(hsession, host, user, pwd, db, port, 0, 0);
assertTrue (tmp == hsession); assertTrue (tmp == hsession);
MYSQL_STMT* hstmt = mysql_stmt_init(hsession); MYSQL_STMT* hstmt = mysql_stmt_init(hsession);
assertTrue (hstmt != 0); assertTrue (hstmt != 0);
std::string sql = "DROP TABLE Test"; std::string sql = "DROP TABLE Test";
mysql_real_query(hsession, sql.c_str(), static_cast<unsigned long>(sql.length())); mysql_real_query(hsession, sql.c_str(), static_cast<unsigned long>(sql.length()));
sql = tableCreateString; sql = tableCreateString;
rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast<unsigned long>(sql.length())); rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast<unsigned long>(sql.length()));
assertTrue (rc == 0); assertTrue (rc == 0);
rc = mysql_stmt_execute(hstmt); rc = mysql_stmt_execute(hstmt);
assertTrue (rc == 0); assertTrue (rc == 0);
sql = "INSERT INTO Test VALUES (?,?,?,?,?)"; sql = "INSERT INTO Test VALUES (?,?,?,?,?)";
rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast<unsigned long>(sql.length())); rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast<unsigned long>(sql.length()));
assertTrue (rc == 0); assertTrue (rc == 0);
std::string str[3] = { "111", "222", "333" }; std::string str[3] = { "111", "222", "333" };
@@ -219,7 +219,7 @@ void SQLExecutor::bareboneMySQLTest(const char* host, const char* user, const ch
fifth = 0.0f; fifth = 0.0f;
MYSQL_BIND bind_result[5] = {{0}}; MYSQL_BIND bind_result[5] = {{0}};
bind_result[0].buffer = chr[0]; bind_result[0].buffer = chr[0];
bind_result[0].buffer_length = sizeof(chr[0]); bind_result[0].buffer_length = sizeof(chr[0]);
bind_result[0].buffer_type = MYSQL_TYPE_STRING; bind_result[0].buffer_type = MYSQL_TYPE_STRING;
@@ -279,15 +279,15 @@ void SQLExecutor::simpleAccess()
std::string result; std::string result;
count = 0; count = 0;
try try
{ {
Statement stmt(*_pSession); Statement stmt(*_pSession);
stmt << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(age);//, now; stmt << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(age);//, now;
stmt.execute(); stmt.execute();
} }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
@@ -549,7 +549,7 @@ void SQLExecutor::insertSingleBulkVec()
{ {
std::string funct = "insertSingleBulkVec()"; std::string funct = "insertSingleBulkVec()";
std::vector<int> data; std::vector<int> data;
for (int x = 0; x < 100; ++x) for (int x = 0; x < 100; ++x)
data.push_back(x); data.push_back(x);
@@ -938,7 +938,7 @@ void SQLExecutor::multiMapComplex()
people.insert(std::make_pair("LN1", p1)); people.insert(std::make_pair("LN1", p1));
people.insert(std::make_pair("LN1", p1)); people.insert(std::make_pair("LN1", p1));
people.insert(std::make_pair("LN2", p2)); people.insert(std::make_pair("LN2", p2));
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(people), now; } try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(people), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
@@ -1000,7 +1000,7 @@ void SQLExecutor::selectIntoSingleStep()
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (count == 2); assertTrue (count == 2);
Person result; Person result;
Statement stmt = (*_pSession << "SELECT * FROM Person", into(result), limit(1)); Statement stmt = (*_pSession << "SELECT * FROM Person", into(result), limit(1));
stmt.execute(); stmt.execute();
assertTrue (result == p1); assertTrue (result == p1);
assertTrue (!stmt.done()); assertTrue (!stmt.done());
@@ -1264,7 +1264,7 @@ void SQLExecutor::dateTime()
std::string firstName("Simpson"); std::string firstName("Simpson");
std::string address("Springfield"); std::string address("Springfield");
DateTime birthday(1980, 4, 1, 5, 45, 12, 354, 879); DateTime birthday(1980, 4, 1, 5, 45, 12, 354, 879);
int count = 0; int count = 0;
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; } try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
@@ -1273,14 +1273,14 @@ void SQLExecutor::dateTime()
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (count == 1); assertTrue (count == 1);
DateTime bd; DateTime bd;
assertTrue (bd != birthday); assertTrue (bd != birthday);
try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; } try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (bd == birthday); assertTrue (bd == birthday);
std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person"); std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person");
} }
@@ -1292,7 +1292,7 @@ void SQLExecutor::date()
std::string firstName("Simpson"); std::string firstName("Simpson");
std::string address("Springfield"); std::string address("Springfield");
Date birthday(1980, 4, 1); Date birthday(1980, 4, 1);
int count = 0; int count = 0;
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; } try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
@@ -1301,14 +1301,14 @@ void SQLExecutor::date()
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (count == 1); assertTrue (count == 1);
Date bd; Date bd;
assertTrue (bd != birthday); assertTrue (bd != birthday);
try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; } try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (bd == birthday); assertTrue (bd == birthday);
std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person"); std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person");
} }
@@ -1320,7 +1320,7 @@ void SQLExecutor::time()
std::string firstName("Simpson"); std::string firstName("Simpson");
std::string address("Springfield"); std::string address("Springfield");
Time birthday(1, 2, 3); Time birthday(1, 2, 3);
int count = 0; int count = 0;
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; } try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
@@ -1329,14 +1329,14 @@ void SQLExecutor::time()
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (count == 1); assertTrue (count == 1);
Time bd; Time bd;
assertTrue (bd != birthday); assertTrue (bd != birthday);
try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; } try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (bd == birthday); assertTrue (bd == birthday);
std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person"); std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person");
} }
@@ -1436,7 +1436,7 @@ void SQLExecutor::tupleVector()
typedef Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> TupleType; typedef Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> TupleType;
std::string funct = "tupleVector()"; std::string funct = "tupleVector()";
TupleType t(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19); TupleType t(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int>
t10(10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29); t10(10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29);
TupleType t100(100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119); TupleType t100(100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119);
std::vector<TupleType> v; std::vector<TupleType> v;
@@ -1475,8 +1475,8 @@ void SQLExecutor::internalExtraction()
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
try try
{ {
Statement stmt = (*_pSession << "SELECT * FROM Vectors", now); Statement stmt = (*_pSession << "SELECT * FROM Vectors", now);
RecordSet rset(stmt); RecordSet rset(stmt);
@@ -1523,7 +1523,7 @@ void SQLExecutor::internalExtraction()
assertTrue ("5" == s); assertTrue ("5" == s);
i = rset.value("str0", 2); i = rset.value("str0", 2);
assertTrue (5 == i); assertTrue (5 == i);
const Column<int>& col = rset.column<int>(0); const Column<int>& col = rset.column<int>(0);
Column<int>::Iterator it = col.begin(); Column<int>::Iterator it = col.begin();
Column<int>::Iterator end = col.end(); Column<int>::Iterator end = col.end();
@@ -1563,7 +1563,7 @@ void SQLExecutor::internalExtraction()
try { rset.value<std::string>(0,0); fail ("must fail"); } try { rset.value<std::string>(0,0); fail ("must fail"); }
catch (BadCastException&) { } catch (BadCastException&) { }
stmt = (*_pSession << "DELETE FROM Vectors", now); stmt = (*_pSession << "DELETE FROM Vectors", now);
rset = stmt; rset = stmt;
@@ -1579,10 +1579,10 @@ void SQLExecutor::internalExtraction()
void SQLExecutor::doNull() void SQLExecutor::doNull()
{ {
std::string funct = "null()"; std::string funct = "null()";
*_pSession << "INSERT INTO Vectors VALUES (?, ?, ?)", *_pSession << "INSERT INTO Vectors VALUES (?, ?, ?)",
use(Poco::Data::Keywords::null), use(Poco::Data::Keywords::null),
use(Poco::Data::Keywords::null), use(Poco::Data::Keywords::null),
use(Poco::Data::Keywords::null), now; use(Poco::Data::Keywords::null), now;
int count = 0; int count = 0;
@@ -1615,19 +1615,19 @@ void SQLExecutor::doNull()
void SQLExecutor::setTransactionIsolation(Session& session, Poco::UInt32 ti) void SQLExecutor::setTransactionIsolation(Session& session, Poco::UInt32 ti)
{ {
if (session.hasTransactionIsolation(ti)) if (session.hasTransactionIsolation(ti))
{ {
std::string funct = "setTransactionIsolation()"; std::string funct = "setTransactionIsolation()";
try try
{ {
Transaction t(session, false); Transaction t(session, false);
t.setIsolation(ti); t.setIsolation(ti);
assertTrue (ti == t.getIsolation()); assertTrue (ti == t.getIsolation());
assertTrue (t.isIsolation(ti)); assertTrue (t.isIsolation(ti));
assertTrue (ti == session.getTransactionIsolation()); assertTrue (ti == session.getTransactionIsolation());
assertTrue (session.isTransactionIsolation(ti)); assertTrue (session.isTransactionIsolation(ti));
} }
@@ -1789,11 +1789,11 @@ void SQLExecutor::transaction(const std::string& connect)
Transaction trans((*_pSession)); Transaction trans((*_pSession));
assertTrue (trans.isActive()); assertTrue (trans.isActive());
assertTrue (_pSession->isTransaction()); assertTrue (_pSession->isTransaction());
try { (*_pSession) << "INSERT INTO Person VALUES (?,?,?,?)", use(lastNames), use(firstNames), use(addresses), use(ages), now; } try { (*_pSession) << "INSERT INTO Person VALUES (?,?,?,?)", use(lastNames), use(firstNames), use(addresses), use(ages), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (_pSession->isTransaction()); assertTrue (_pSession->isTransaction());
assertTrue (trans.isActive()); assertTrue (trans.isActive());
@@ -1885,7 +1885,7 @@ void SQLExecutor::transaction(const std::string& connect)
assertTrue (0 == count); assertTrue (0 == count);
trans.execute(sql); trans.execute(sql);
local << "SELECT COUNT(*) FROM Person", into(locCount), now; local << "SELECT COUNT(*) FROM Person", into(locCount), now;
assertTrue (2 == locCount); assertTrue (2 == locCount);
@@ -1921,9 +1921,9 @@ void SQLExecutor::reconnect()
assertTrue (_pSession->isConnected()); assertTrue (_pSession->isConnected());
_pSession->close(); _pSession->close();
assertTrue (!_pSession->isConnected()); assertTrue (!_pSession->isConnected());
try try
{ {
(*_pSession) << "SELECT LastName FROM Person", into(result), now; (*_pSession) << "SELECT LastName FROM Person", into(result), now;
fail ("must fail"); fail ("must fail");
} }
catch(NotConnectedException&){ } catch(NotConnectedException&){ }

18
configure vendored
View File

@@ -102,6 +102,12 @@ Options:
--odbc-include=<path> --odbc-include=<path>
Specify the directory where ODBC header files are located. Specify the directory where ODBC header files are located.
--mysql-lib=<path>
Specify the directory where MySQL library is located.
--mysql-include=<path>
Specify the directory where MySQL header files are located.
--cflags=<flags> --cflags=<flags>
Pass additional flags to compiler. Pass additional flags to compiler.
Example: --cflags=-wall Example: --cflags=-wall
@@ -178,6 +184,12 @@ while [ $# -ge 1 ]; do
--odbc-include=*) --odbc-include=*)
odbcinclude="`echo ${1} | awk '{print substr($0,16)}'`" ;; odbcinclude="`echo ${1} | awk '{print substr($0,16)}'`" ;;
--mysql-lib=*)
mysqllib="`echo ${1} | awk '{print substr($0,13)}'`" ;;
--mysql-include=*)
mysqlinclude="`echo ${1} | awk '{print substr($0,17)}'`" ;;
--cflags=*) --cflags=*)
flags="$flags `echo ${1} | awk '{print substr($0,10)}'`" ;; flags="$flags `echo ${1} | awk '{print substr($0,10)}'`" ;;
@@ -315,6 +327,12 @@ fi
if [ -n "$odbcinclude" ] ; then if [ -n "$odbcinclude" ] ; then
echo "POCO_ODBC_INCLUDE = $odbcinclude" >>$build/config.make echo "POCO_ODBC_INCLUDE = $odbcinclude" >>$build/config.make
fi fi
if [ -n "$mysqllib" ] ; then
echo "POCO_MYSQL_LIB = $mysqllib" >>$build/config.make
fi
if [ -n "$mysqlinclude" ] ; then
echo "POCO_MYSQL_INCLUDE = $mysqlinclude" >>$build/config.make
fi
if [ -n "$unbundled" ] ; then if [ -n "$unbundled" ] ; then
echo "POCO_UNBUNDLED = 1" >>$build/config.make echo "POCO_UNBUNDLED = 1" >>$build/config.make
fi fi