Skip to content

Commit

Permalink
#3317: Data::MySQL MySQL headers and library search paths
Browse files Browse the repository at this point in the history
  • Loading branch information
obiltschnig committed Jun 17, 2021
1 parent 65fd5f8 commit 08ef4db
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 63 deletions.
5 changes: 3 additions & 2 deletions Data/MySQL/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

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 += -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 MySQL.make

SYSLIBS += -lmysqlclient
SYSFLAGS += -DTHREADSAFE -DNO_TCL

objects = Binder Extractor SessionImpl Connector \
Expand Down
40 changes: 40 additions & 0 deletions Data/MySQL/MySQL.make
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions Data/MySQL/include/Poco/Data/MySQL/Binder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "Poco/Data/AbstractBinder.h"
#include "Poco/Data/LOB.h"
#include "Poco/Data/MySQL/MySQLException.h"
#include <mysql.h>
#include <mysql/mysql.h>


namespace Poco {
Expand Down Expand Up @@ -72,7 +72,7 @@ class MySQL_API Binder: public Poco::Data::AbstractBinder

virtual void bind(std::size_t pos, const unsigned long& val, Direction dir = PD_IN);
/// Binds an unsigned long.
#endif
#endif

virtual void bind(std::size_t pos, const bool& val, Direction dir);
/// Binds a boolean.
Expand Down
2 changes: 1 addition & 1 deletion Data/MySQL/include/Poco/Data/MySQL/MySQLException.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

#include "Poco/Data/MySQL/MySQL.h"
#include "Poco/Data/DataException.h"
#include <mysql/mysql.h>
#include <typeinfo>
#include <string>
#include <mysql.h>


namespace Poco {
Expand Down
4 changes: 2 additions & 2 deletions Data/MySQL/include/Poco/Data/MySQL/ResultMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#define Data_MySQL_ResultMetadata_INCLUDED


#include <mysql.h>
#include <vector>
#include "Poco/Data/MetaColumn.h"
#include <mysql/mysql.h>
#include <vector>


#if LIBMYSQL_VERSION_ID >= 80000
Expand Down
2 changes: 1 addition & 1 deletion Data/MySQL/include/Poco/Data/MySQL/SessionHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#define Data_MySQL_SessionHandle_INCLUDED


#include <mysql.h>
#include "Poco/Data/MySQL/MySQLException.h"
#include <mysql/mysql.h>


namespace Poco {
Expand Down
4 changes: 2 additions & 2 deletions Data/MySQL/include/Poco/Data/MySQL/StatementExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#define Data_MySQL_StatementHandle_INCLUDED


#include <mysql.h>
#include "Poco/Data/MySQL/MySQLException.h"
#include <mysql/mysql.h>


namespace Poco {
Expand Down Expand Up @@ -66,7 +66,7 @@ class StatementExecutor
/// Fetches the column.

int getAffectedRowCount() const;

operator MYSQL_STMT* ();
/// Cast operator to native handle type.

Expand Down
2 changes: 1 addition & 1 deletion Data/MySQL/include/Poco/Data/MySQL/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "Poco/Data/MySQL/MySQL.h"
#include "Poco/Data/Session.h"
#include <mysql.h>
#include <mysql/mysql.h>


namespace Poco {
Expand Down
4 changes: 2 additions & 2 deletions Data/MySQL/src/Connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "Poco/Data/MySQL/SessionImpl.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/Exception.h"
#include <mysql.h>
#include <mysql/mysql.h>


namespace Poco {
Expand Down Expand Up @@ -46,7 +46,7 @@ const std::string& Connector::name() const
Poco::AutoPtr<Poco::Data::SessionImpl> Connector::createSession(const std::string& connectionString,
std::size_t timeout)
{
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString, timeout));
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString, timeout));
}


Expand Down
2 changes: 1 addition & 1 deletion Data/MySQL/src/MySQLException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


#include "Poco/Data/MySQL/MySQLException.h"
#include <mysql.h>
#include <mysql/mysql.h>
#include <stdio.h>


Expand Down
6 changes: 3 additions & 3 deletions Data/MySQL/src/StatementExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
//


#include <mysql.h>
#include "Poco/Data/MySQL/StatementExecutor.h"
#include "Poco/Format.h"
#include <mysql/mysql.h>


namespace Poco {
Expand Down Expand Up @@ -52,7 +52,7 @@ void StatementExecutor::prepare(const std::string& query)
_state = STMT_COMPILED;
return;
}

int rc = mysql_stmt_prepare(_pHandle, query.c_str(), static_cast<unsigned int>(query.length()));
if (rc != 0)
{
Expand Down Expand Up @@ -119,7 +119,7 @@ bool StatementExecutor::fetch()
int res = mysql_stmt_fetch(_pHandle);

// 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);

return (res == 0) || (res == MYSQL_DATA_TRUNCATED);
Expand Down
2 changes: 1 addition & 1 deletion Data/MySQL/src/Utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


#include "Poco/Data/MySQL/Utility.h"
#include <mysql.h>
#include <mysql/mysql.h>


namespace Poco {
Expand Down
4 changes: 2 additions & 2 deletions Data/MySQL/testsuite/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

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.
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

Expand Down
2 changes: 2 additions & 0 deletions Data/MySQL/testsuite/src/MySQLTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ Poco::SharedPtr<SQLExecutor> MySQLTest::_pExecutor = 0;
#define MYSQL_USER "pocotest"
#define MYSQL_PWD "pocotest"
#define MYSQL_HOST "127.0.0.1"
#ifndef MYSQL_PORT
#define MYSQL_PORT 3306
#endif
#define MYSQL_DB "pocotest"

//
Expand Down
1 change: 1 addition & 0 deletions Data/MySQL/testsuite/src/MySQLTestSuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "MySQLTestSuite.h"
#include "MySQLTest.h"


CppUnit::Test* MySQLTestSuite::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MySQLTestSuite");
Expand Down
Loading

0 comments on commit 08ef4db

Please sign in to comment.