summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2018-08-29 19:55:09 +0200
committerMarcin Siodelski <marcin@isc.org>2018-09-03 09:31:34 +0200
commitb82d365bcdb2102821cbb07e0d7ec7f24369a007 (patch)
tree7cb7ffb760fda45668c9e77e484ff9b8cf5d6fd1 /src
parent[#92,!13] Moved MySqlConnection class to libkea-mysql library. (diff)
downloadkea-b82d365bcdb2102821cbb07e0d7ec7f24369a007.tar.xz
kea-b82d365bcdb2102821cbb07e0d7ec7f24369a007.zip
[#92,!13] Moved PgSqlConnection and PgSqlExchange to libkea-pgsql.
Diffstat (limited to 'src')
-rw-r--r--src/bin/d2/Makefile.am3
-rw-r--r--src/bin/d2/tests/Makefile.am3
-rw-r--r--src/bin/dhcp4/Makefile.am3
-rw-r--r--src/bin/dhcp4/tests/Makefile.am9
-rw-r--r--src/bin/dhcp6/Makefile.am3
-rw-r--r--src/bin/dhcp6/tests/Makefile.am3
-rw-r--r--src/bin/lfc/Makefile.am9
-rw-r--r--src/bin/lfc/tests/Makefile.am10
-rw-r--r--src/lib/Makefile.am4
-rw-r--r--src/lib/dhcpsrv/Makefile.am7
-rw-r--r--src/lib/dhcpsrv/pgsql_host_data_source.h4
-rw-r--r--src/lib/dhcpsrv/pgsql_lease_mgr.h22
-rw-r--r--src/lib/dhcpsrv/tests/Makefile.am4
-rw-r--r--src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc2
-rw-r--r--src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc2
-rw-r--r--src/lib/dhcpsrv/testutils/Makefile.am8
-rw-r--r--src/lib/pgsql/Makefile.am31
-rw-r--r--src/lib/pgsql/pgsql_connection.cc (renamed from src/lib/dhcpsrv/pgsql_connection.cc)7
-rw-r--r--src/lib/pgsql/pgsql_connection.h (renamed from src/lib/dhcpsrv/pgsql_connection.h)4
-rw-r--r--src/lib/pgsql/pgsql_exchange.cc (renamed from src/lib/dhcpsrv/pgsql_exchange.cc)9
-rw-r--r--src/lib/pgsql/pgsql_exchange.h (renamed from src/lib/dhcpsrv/pgsql_exchange.h)6
-rw-r--r--src/lib/pgsql/tests/.gitignore1
-rw-r--r--src/lib/pgsql/tests/Makefile.am38
-rw-r--r--src/lib/pgsql/tests/pgsql_exchange_unittest.cc (renamed from src/lib/dhcpsrv/tests/pgsql_exchange_unittest.cc)5
-rw-r--r--src/lib/pgsql/tests/run_unittests.cc20
-rw-r--r--src/lib/process/Makefile.am3
26 files changed, 182 insertions, 38 deletions
diff --git a/src/bin/d2/Makefile.am b/src/bin/d2/Makefile.am
index bc0cf74258..f529ae55a8 100644
--- a/src/bin/d2/Makefile.am
+++ b/src/bin/d2/Makefile.am
@@ -101,6 +101,9 @@ kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
if HAVE_MYSQL
kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
endif
+if HAVE_PGSQL
+kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
diff --git a/src/bin/d2/tests/Makefile.am b/src/bin/d2/tests/Makefile.am
index 4a4841b877..609ca8ed57 100644
--- a/src/bin/d2/tests/Makefile.am
+++ b/src/bin/d2/tests/Makefile.am
@@ -89,6 +89,9 @@ d2_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
if HAVE_MYSQL
d2_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
endif
+if HAVE_PGSQL
+d2_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
d2_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
d2_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
diff --git a/src/bin/dhcp4/Makefile.am b/src/bin/dhcp4/Makefile.am
index 069e9f737c..b2376041f0 100644
--- a/src/bin/dhcp4/Makefile.am
+++ b/src/bin/dhcp4/Makefile.am
@@ -88,6 +88,9 @@ kea_dhcp4_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
if HAVE_MYSQL
kea_dhcp4_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
endif
+if HAVE_PGSQL
+kea_dhcp4_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
kea_dhcp4_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
kea_dhcp4_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
diff --git a/src/bin/dhcp4/tests/Makefile.am b/src/bin/dhcp4/tests/Makefile.am
index e02b18a9c9..f913edf330 100644
--- a/src/bin/dhcp4/tests/Makefile.am
+++ b/src/bin/dhcp4/tests/Makefile.am
@@ -131,6 +131,15 @@ dhcp4_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp/tests/libdhcptest.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+
+if HAVE_MYSQL
+dhcp4_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
+endif
+if HAVE_PGSQL
+dhcp4_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
+
+dhcp4_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
diff --git a/src/bin/dhcp6/Makefile.am b/src/bin/dhcp6/Makefile.am
index 0e4654f7ac..a624707824 100644
--- a/src/bin/dhcp6/Makefile.am
+++ b/src/bin/dhcp6/Makefile.am
@@ -88,6 +88,9 @@ kea_dhcp6_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
if HAVE_MYSQL
kea_dhcp6_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
endif
+if HAVE_PGSQL
+kea_dhcp6_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
kea_dhcp6_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
kea_dhcp6_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
diff --git a/src/bin/dhcp6/tests/Makefile.am b/src/bin/dhcp6/tests/Makefile.am
index 8597b9463a..119fa169bc 100644
--- a/src/bin/dhcp6/tests/Makefile.am
+++ b/src/bin/dhcp6/tests/Makefile.am
@@ -139,6 +139,9 @@ dhcp6_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
if HAVE_MYSQL
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
endif
+if HAVE_PGSQL
+dhcp6_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
diff --git a/src/bin/lfc/Makefile.am b/src/bin/lfc/Makefile.am
index 7bfeb96df7..33c3db56e4 100644
--- a/src/bin/lfc/Makefile.am
+++ b/src/bin/lfc/Makefile.am
@@ -61,6 +61,15 @@ kea_lfc_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
kea_lfc_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
kea_lfc_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
kea_lfc_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+
+if HAVE_MYSQL
+kea_lfc_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
+endif
+if HAVE_PGSQL
+kea_lfc_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
+
+kea_lfc_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
kea_lfc_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
kea_lfc_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
kea_lfc_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
diff --git a/src/bin/lfc/tests/Makefile.am b/src/bin/lfc/tests/Makefile.am
index 900667ae6a..6f7a955764 100644
--- a/src/bin/lfc/tests/Makefile.am
+++ b/src/bin/lfc/tests/Makefile.am
@@ -61,6 +61,16 @@ lfc_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
lfc_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
lfc_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
lfc_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+
+if HAVE_MYSQL
+lfc_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
+endif
+if HAVE_PGSQL
+lfc_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
+
+
+lfc_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
lfc_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
lfc_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
lfc_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 9f6a23755d..14ecc0bb92 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -5,6 +5,10 @@ if HAVE_MYSQL
SUBDIRS += mysql
endif
+if HAVE_PGSQL
+SUBDIRS += pgsql
+endif
+
SUBDIRS += testutils hooks dhcp config stats asiodns dhcp_ddns eval \
dhcpsrv cfgrpt \
process http
diff --git a/src/lib/dhcpsrv/Makefile.am b/src/lib/dhcpsrv/Makefile.am
index 52346131dd..f6ccf62174 100644
--- a/src/lib/dhcpsrv/Makefile.am
+++ b/src/lib/dhcpsrv/Makefile.am
@@ -146,8 +146,6 @@ libkea_dhcpsrv_la_SOURCES += network.cc network.h
libkea_dhcpsrv_la_SOURCES += network_state.cc network_state.h
if HAVE_PGSQL
-libkea_dhcpsrv_la_SOURCES += pgsql_connection.cc pgsql_connection.h
-libkea_dhcpsrv_la_SOURCES += pgsql_exchange.cc pgsql_exchange.h
libkea_dhcpsrv_la_SOURCES += pgsql_host_data_source.cc pgsql_host_data_source.h
libkea_dhcpsrv_la_SOURCES += pgsql_lease_mgr.cc pgsql_lease_mgr.h
endif
@@ -218,6 +216,9 @@ libkea_dhcpsrv_la_LIBADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
if HAVE_MYSQL
libkea_dhcpsrv_la_LIBADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
endif
+if HAVE_PGSQL
+libkea_dhcpsrv_la_LIBADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
libkea_dhcpsrv_la_LIBADD += $(top_builddir)/src/lib/database/libkea-database.la
libkea_dhcpsrv_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
@@ -327,8 +328,6 @@ endif
if HAVE_PGSQL
libkea_dhcpsrv_include_HEADERS += \
- pgsql_connection.h \
- pgsql_exchange.h \
pgsql_host_data_source.h \
pgsql_lease_mgr.h
endif
diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.h b/src/lib/dhcpsrv/pgsql_host_data_source.h
index 5da08a89e8..66b024a5f7 100644
--- a/src/lib/dhcpsrv/pgsql_host_data_source.h
+++ b/src/lib/dhcpsrv/pgsql_host_data_source.h
@@ -8,8 +8,8 @@
#define PGSQL_HOST_DATA_SOURCE_H
#include <dhcpsrv/base_host_data_source.h>
-#include <dhcpsrv/pgsql_connection.h>
-#include <dhcpsrv/pgsql_exchange.h>
+#include <pgsql/pgsql_connection.h>
+#include <pgsql/pgsql_exchange.h>
namespace isc {
namespace dhcp {
diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.h b/src/lib/dhcpsrv/pgsql_lease_mgr.h
index 053ae78d9f..c779fafaa6 100644
--- a/src/lib/dhcpsrv/pgsql_lease_mgr.h
+++ b/src/lib/dhcpsrv/pgsql_lease_mgr.h
@@ -10,8 +10,8 @@
#include <dhcp/hwaddr.h>
#include <dhcpsrv/dhcpsrv_exceptions.h>
#include <dhcpsrv/lease_mgr.h>
-#include <dhcpsrv/pgsql_connection.h>
-#include <dhcpsrv/pgsql_exchange.h>
+#include <pgsql/pgsql_connection.h>
+#include <pgsql/pgsql_exchange.h>
#include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
@@ -588,7 +588,7 @@ private:
///
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
- bool addLeaseCommon(StatementIndex stindex, PsqlBindArray& bind_array);
+ bool addLeaseCommon(StatementIndex stindex, db::PsqlBindArray& bind_array);
/// @brief Get Lease Collection Common Code
///
@@ -611,7 +611,7 @@ private:
/// @throw isc::db::MultipleRecords Multiple records were retrieved
/// from the database where only one was expected.
template <typename Exchange, typename LeaseCollection>
- void getLeaseCollection(StatementIndex stindex, PsqlBindArray& bind_array,
+ void getLeaseCollection(StatementIndex stindex, db::PsqlBindArray& bind_array,
Exchange& exchange, LeaseCollection& result,
bool single = false) const;
@@ -631,7 +631,7 @@ private:
/// failed.
/// @throw isc::db::MultipleRecords Multiple records were retrieved
/// from the database where only one was expected.
- void getLeaseCollection(StatementIndex stindex, PsqlBindArray& bind_array,
+ void getLeaseCollection(StatementIndex stindex, db::PsqlBindArray& bind_array,
Lease4Collection& result) const {
getLeaseCollection(stindex, bind_array, exchange4_, result);
}
@@ -651,7 +651,7 @@ private:
/// failed.
/// @throw isc::db::MultipleRecords Multiple records were retrieved
/// from the database where only one was expected.
- void getLeaseCollection(StatementIndex stindex, PsqlBindArray& bind_array,
+ void getLeaseCollection(StatementIndex stindex, db::PsqlBindArray& bind_array,
Lease6Collection& result) const {
getLeaseCollection(stindex, bind_array, exchange6_, result);
}
@@ -665,7 +665,7 @@ private:
/// @param stindex Index of statement being executed
/// @param bind_array array containing input parameters for the query
/// @param lease Lease4 object returned
- void getLease(StatementIndex stindex, PsqlBindArray& bind_array,
+ void getLease(StatementIndex stindex, db::PsqlBindArray& bind_array,
Lease4Ptr& result) const;
/// @brief Get Lease6 Common Code
@@ -677,7 +677,7 @@ private:
/// @param stindex Index of statement being executed
/// @param bind_array array containing input parameters for the query
/// @param lease Lease6 object returned
- void getLease(StatementIndex stindex, PsqlBindArray& bind_array,
+ void getLease(StatementIndex stindex, db::PsqlBindArray& bind_array,
Lease6Ptr& result) const;
/// @brief Get expired leases common code.
@@ -715,7 +715,7 @@ private:
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
template <typename LeasePtr>
- void updateLeaseCommon(StatementIndex stindex, PsqlBindArray& bind_array,
+ void updateLeaseCommon(StatementIndex stindex, db::PsqlBindArray& bind_array,
const LeasePtr& lease);
/// @brief Delete lease common code
@@ -733,7 +733,7 @@ private:
/// @throw isc::db::DbOperationError An operation on the open database has
/// failed.
uint64_t deleteLeaseCommon(StatementIndex stindex,
- PsqlBindArray& bind_array);
+ db::PsqlBindArray& bind_array);
/// @brief Delete expired-reclaimed leases.
///
@@ -755,7 +755,7 @@ private:
boost::scoped_ptr<PgSqlLease6Exchange> exchange6_; ///< Exchange object
/// PostgreSQL connection handle
- PgSqlConnection conn_;
+ db::PgSqlConnection conn_;
};
} // namespace dhcp
diff --git a/src/lib/dhcpsrv/tests/Makefile.am b/src/lib/dhcpsrv/tests/Makefile.am
index 6f4347bada..235e709963 100644
--- a/src/lib/dhcpsrv/tests/Makefile.am
+++ b/src/lib/dhcpsrv/tests/Makefile.am
@@ -110,7 +110,6 @@ libdhcpsrv_unittests_SOURCES += mysql_lease_mgr_unittest.cc
libdhcpsrv_unittests_SOURCES += mysql_host_data_source_unittest.cc
endif
if HAVE_PGSQL
-libdhcpsrv_unittests_SOURCES += pgsql_exchange_unittest.cc
libdhcpsrv_unittests_SOURCES += pgsql_lease_mgr_unittest.cc
libdhcpsrv_unittests_SOURCES += pgsql_host_data_source_unittest.cc
endif
@@ -174,6 +173,9 @@ libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
if HAVE_MYSQL
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
endif
+if HAVE_PGSQL
+libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
diff --git a/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc b/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc
index f892a58817..ef43d53e6b 100644
--- a/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc
+++ b/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc
@@ -10,13 +10,13 @@
#include <dhcpsrv/tests/test_utils.h>
#include <exceptions/exceptions.h>
#include <dhcpsrv/host.h>
-#include <dhcpsrv/pgsql_connection.h>
#include <dhcpsrv/pgsql_host_data_source.h>
#include <dhcpsrv/testutils/generic_host_data_source_unittest.h>
#include <dhcpsrv/testutils/pgsql_schema.h>
#include <dhcpsrv/testutils/host_data_source_utils.h>
#include <dhcpsrv/host_mgr.h>
#include <dhcpsrv/host_data_source_factory.h>
+#include <pgsql/pgsql_connection.h>
#include <gtest/gtest.h>
diff --git a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc
index 4a128b40b3..27ae1e1cbe 100644
--- a/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc
@@ -8,11 +8,11 @@
#include <asiolink/io_address.h>
#include <dhcpsrv/lease_mgr_factory.h>
-#include <dhcpsrv/pgsql_connection.h>
#include <dhcpsrv/pgsql_lease_mgr.h>
#include <dhcpsrv/tests/test_utils.h>
#include <dhcpsrv/tests/generic_lease_mgr_unittest.h>
#include <dhcpsrv/testutils/pgsql_schema.h>
+#include <pgsql/pgsql_connection.h>
#include <exceptions/exceptions.h>
#include <gtest/gtest.h>
diff --git a/src/lib/dhcpsrv/testutils/Makefile.am b/src/lib/dhcpsrv/testutils/Makefile.am
index 257a4612e4..8c156a29a8 100644
--- a/src/lib/dhcpsrv/testutils/Makefile.am
+++ b/src/lib/dhcpsrv/testutils/Makefile.am
@@ -33,11 +33,16 @@ endif
libdhcpsrvtest_la_CXXFLAGS = $(AM_CXXFLAGS)
libdhcpsrvtest_la_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+
+libdhcpsrvtest_la_LIBADD =
+
if HAVE_MYSQL
libdhcpsrvtest_la_CPPFLAGS += $(MYSQL_CPPFLAGS)
+libdhcpsrvtest_la_LIBADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
endif
if HAVE_PGSQL
libdhcpsrvtest_la_CPPFLAGS += $(PGSQL_CPPFLAGS)
+libdhcpsrvtest_la_LIBADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
endif
if HAVE_CQL
libdhcpsrvtest_la_CPPFLAGS += $(CQL_CPPFLAGS)
@@ -54,7 +59,8 @@ if HAVE_CQL
libdhcpsrvtest_la_LDFLAGS += $(CQL_LIBS)
endif
-libdhcpsrvtest_la_LIBADD = $(top_builddir)/src/lib/database/libkea-database.la
+
+libdhcpsrvtest_la_LIBADD += $(top_builddir)/src/lib/database/libkea-database.la
libdhcpsrvtest_la_LIBADD += $(top_builddir)/src/lib/cc/libkea-cc.la
libdhcpsrvtest_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
diff --git a/src/lib/pgsql/Makefile.am b/src/lib/pgsql/Makefile.am
new file mode 100644
index 0000000000..1a86faca3f
--- /dev/null
+++ b/src/lib/pgsql/Makefile.am
@@ -0,0 +1,31 @@
+SUBDIRS = . tests
+
+AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES) $(PGSQL_CPPFLAGS)
+
+AM_CXXFLAGS = $(KEA_CXXFLAGS)
+
+CLEANFILES = *.gcno *.gcda
+
+lib_LTLIBRARIES = libkea-pgsql.la
+libkea_pgsql_la_SOURCES = pgsql_connection.cc pgsql_connection.h
+libkea_pgsql_la_SOURCES += pgsql_exchange.cc pgsql_exchange.h
+
+
+libkea_pgsql_la_LIBADD = $(top_builddir)/src/lib/database/libkea-database.la
+libkea_pgsql_la_LIBADD += $(top_builddir)/src/lib/cc/libkea-cc.la
+libkea_pgsql_la_LIBADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+libkea_pgsql_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
+libkea_pgsql_la_LIBADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la
+libkea_pgsql_la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la
+libkea_pgsql_la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+libkea_pgsql_la_LIBADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS)
+
+libkea_pgsql_la_LDFLAGS = -no-undefined -version-info 0:0:0
+
+libkea_pgsql_la_LDFLAGS += $(PGSQL_LIBS)
+
+# Specify the headers for copying into the installation directory tree.
+libkea_pgsql_includedir = $(pkgincludedir)/database
+libkea_pgsql_include_HEADERS = \
+ pgsql_connection.h
diff --git a/src/lib/dhcpsrv/pgsql_connection.cc b/src/lib/pgsql/pgsql_connection.cc
index 29b1f1dd8e..af98f098cb 100644
--- a/src/lib/dhcpsrv/pgsql_connection.cc
+++ b/src/lib/pgsql/pgsql_connection.cc
@@ -7,7 +7,7 @@
#include <config.h>
#include <database/db_log.h>
-#include <dhcpsrv/pgsql_connection.h>
+#include <pgsql/pgsql_connection.h>
// PostgreSQL errors should be tested based on the SQL state code. Each state
// code is 5 decimal, ASCII, digits, the first two define the category of
@@ -25,11 +25,10 @@
#define PGSQL_STATECODE_LEN 5
#include <utils/errcodes.h>
-using namespace isc::db;
using namespace std;
namespace isc {
-namespace dhcp {
+namespace db {
// Default connection timeout
@@ -361,5 +360,5 @@ PgSqlConnection::rollback() {
}
}
-}; // end of isc::dhcp namespace
+}; // end of isc::db namespace
}; // end of isc namespace
diff --git a/src/lib/dhcpsrv/pgsql_connection.h b/src/lib/pgsql/pgsql_connection.h
index 20b3f3ffe1..57e118f2e0 100644
--- a/src/lib/dhcpsrv/pgsql_connection.h
+++ b/src/lib/pgsql/pgsql_connection.h
@@ -15,7 +15,7 @@
#include <stdint.h>
namespace isc {
-namespace dhcp {
+namespace db {
/// @brief Define PostgreSQL backend version: 5.0
const uint32_t PG_SCHEMA_VERSION_MAJOR = 5;
@@ -423,7 +423,7 @@ public:
};
-}; // end of isc::dhcp namespace
+}; // end of isc::db namespace
}; // end of isc namespace
#endif // PGSQL_CONNECTION_H
diff --git a/src/lib/dhcpsrv/pgsql_exchange.cc b/src/lib/pgsql/pgsql_exchange.cc
index f32d07ca63..d65aa6dee6 100644
--- a/src/lib/dhcpsrv/pgsql_exchange.cc
+++ b/src/lib/pgsql/pgsql_exchange.cc
@@ -6,7 +6,8 @@
#include <config.h>
-#include <dhcpsrv/pgsql_exchange.h>
+#include <pgsql/pgsql_exchange.h>
+#include <pgsql/pgsql_connection.h>
#include <boost/lexical_cast.hpp>
@@ -14,10 +15,8 @@
#include <sstream>
#include <vector>
-using namespace isc::db;
-
namespace isc {
-namespace dhcp {
+namespace db {
const int PsqlBindArray::TEXT_FMT = 0;
const int PsqlBindArray::BINARY_FMT = 1;
@@ -298,5 +297,5 @@ PgSqlExchange::dumpRow(const PgSqlResult& r, int row) {
return (stream.str());
}
-}; // end of isc::dhcp namespace
+}; // end of isc::db namespace
}; // end of isc namespace
diff --git a/src/lib/dhcpsrv/pgsql_exchange.h b/src/lib/pgsql/pgsql_exchange.h
index fd506dd26c..4aa82b2235 100644
--- a/src/lib/dhcpsrv/pgsql_exchange.h
+++ b/src/lib/pgsql/pgsql_exchange.h
@@ -8,7 +8,7 @@
#define PGSQL_EXCHANGE_H
#include <asiolink/io_address.h>
-#include <dhcpsrv/pgsql_connection.h>
+#include <pgsql/pgsql_connection.h>
#include <boost/lexical_cast.hpp>
#include <boost/noncopyable.hpp>
@@ -19,7 +19,7 @@
#include <iostream>
namespace isc {
-namespace dhcp {
+namespace db {
/// @brief Structure used to bind C++ input values to dynamic SQL parameters
/// The structure contains three vectors which store the input values,
@@ -396,7 +396,7 @@ protected:
std::vector<std::string>columns_;
};
-}; // end of isc::dhcp namespace
+}; // end of isc::db namespace
}; // end of isc namespace
#endif // PGSQL_EXCHANGE_H
diff --git a/src/lib/pgsql/tests/.gitignore b/src/lib/pgsql/tests/.gitignore
new file mode 100644
index 0000000000..0d7d352ca5
--- /dev/null
+++ b/src/lib/pgsql/tests/.gitignore
@@ -0,0 +1 @@
+/libpgsql_unittests \ No newline at end of file
diff --git a/src/lib/pgsql/tests/Makefile.am b/src/lib/pgsql/tests/Makefile.am
new file mode 100644
index 0000000000..6dfe25ce98
--- /dev/null
+++ b/src/lib/pgsql/tests/Makefile.am
@@ -0,0 +1,38 @@
+SUBDIRS = .
+
+AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+
+AM_CXXFLAGS = $(KEA_CXXFLAGS)
+
+if USE_STATIC_LINK
+AM_LDFLAGS = -static
+endif
+
+CLEANFILES = *.gcno *.gcda
+
+TESTS_ENVIRONMENT = \
+ $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+
+TESTS =
+if HAVE_GTEST
+TESTS += libpgsql_unittests
+
+libpgsql_unittests_SOURCES = pgsql_exchange_unittest.cc
+libpgsql_unittests_SOURCES += run_unittests.cc
+
+libpgsql_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+libpgsql_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) $(PGSQL_LIBS)
+
+libpgsql_unittests_LDADD = $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+libpgsql_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
+libpgsql_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+libpgsql_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libpgsql_unittests_LDADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la
+libpgsql_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
+libpgsql_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+libpgsql_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD)
+
+endif
+
+noinst_PROGRAMS = $(TESTS)
diff --git a/src/lib/dhcpsrv/tests/pgsql_exchange_unittest.cc b/src/lib/pgsql/tests/pgsql_exchange_unittest.cc
index df3339aa6d..173665ac94 100644
--- a/src/lib/dhcpsrv/tests/pgsql_exchange_unittest.cc
+++ b/src/lib/pgsql/tests/pgsql_exchange_unittest.cc
@@ -6,8 +6,8 @@
#include <config.h>
-#include <dhcpsrv/pgsql_connection.h>
-#include <dhcpsrv/pgsql_exchange.h>
+#include <pgsql/pgsql_connection.h>
+#include <pgsql/pgsql_exchange.h>
#include <boost/lexical_cast.hpp>
@@ -18,7 +18,6 @@
using namespace isc;
using namespace isc::db;
-using namespace isc::dhcp;
namespace {
diff --git a/src/lib/pgsql/tests/run_unittests.cc b/src/lib/pgsql/tests/run_unittests.cc
new file mode 100644
index 0000000000..4e83d4bd6c
--- /dev/null
+++ b/src/lib/pgsql/tests/run_unittests.cc
@@ -0,0 +1,20 @@
+// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+
+#include <log/logger_support.h>
+#include <gtest/gtest.h>
+
+int
+main(int argc, char* argv[]) {
+ ::testing::InitGoogleTest(&argc, argv);
+ isc::log::initLogger();
+
+ int result = RUN_ALL_TESTS();
+
+ return (result);
+}
diff --git a/src/lib/process/Makefile.am b/src/lib/process/Makefile.am
index 0a0efda632..33f9692d7c 100644
--- a/src/lib/process/Makefile.am
+++ b/src/lib/process/Makefile.am
@@ -59,6 +59,9 @@ libkea_process_la_LIBADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
if HAVE_MYSQL
libkea_process_la_LIBADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
endif
+if HAVE_PGSQL
+libkea_process_la_LIBADD += $(top_builddir)/src/lib/pgsql/libkea-pgsql.la
+endif
libkea_process_la_LIBADD += $(top_builddir)/src/lib/database/libkea-database.la
libkea_process_la_LIBADD += $(top_builddir)/src/lib/cc/libkea-cc.la