From 43705039aac98e4b8065353da3f828d894dd6f00 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 19 Oct 2019 15:38:00 +0100 Subject: Refactor to ease testing --- libpqpp/Jamfile.jam | 30 ++++++++++++++++++++++++------ libpqpp/pq-column.cpp | 2 +- libpqpp/unittests/Jamfile.jam | 5 +++-- libpqpp/unittests/testpq.cpp | 16 ++++++++++++++++ 4 files changed, 44 insertions(+), 9 deletions(-) (limited to 'libpqpp') diff --git a/libpqpp/Jamfile.jam b/libpqpp/Jamfile.jam index d825fa5..03553f2 100644 --- a/libpqpp/Jamfile.jam +++ b/libpqpp/Jamfile.jam @@ -1,23 +1,41 @@ import package ; +import pkg-config ; lib adhocutil : : : : /usr/include/adhocutil ; lib dbppcore : : : : /usr/include/dbpp ; lib boost_date_time ; lib stdc++fs ; +pkg-config.import pq : : libpq ; +pkg-config.import glibmm : : glibmm-2.4 ; + +project + : requirements + 17 + hidden + "-Wl,-z,defs,--warn-once,--gc-sections" + release:"-flto=2" + release:"-flto=2" + debug:extra + debug:on + coverage:on + ; + lib dbpp-postgresql : [ glob *.cpp ] : - ..//glibmm - ..//pq + glibmm + pq adhocutil - dbppcore + yes:../..//dbppcore + no:dbppcore boost_date_time stdc++fs : : . - "-I`pg_config --includedir`" - ..//glibmm - dbppcore + pq + glibmm + yes:../..//dbppcore + no:dbppcore ; build-project unittests ; diff --git a/libpqpp/pq-column.cpp b/libpqpp/pq-column.cpp index 4fac1ac..0753c50 100644 --- a/libpqpp/pq-column.cpp +++ b/libpqpp/pq-column.cpp @@ -77,7 +77,7 @@ PQ::Column::apply(DB::HandleField & h) const fractions * (long)pow(10, boost::posix_time::time_res_traits::num_fractional_digits() + flen1 - flen2))); } else { - h.interval(boost::posix_time::duration_from_string(value())); + h.interval(boost::posix_time::duration_from_string(val)); } break; } diff --git a/libpqpp/unittests/Jamfile.jam b/libpqpp/unittests/Jamfile.jam index 4e6cc23..7865882 100644 --- a/libpqpp/unittests/Jamfile.jam +++ b/libpqpp/unittests/Jamfile.jam @@ -15,9 +15,10 @@ run ROOT=\"$(me)\" BOOST_TEST_DYN_LINK ..//dbpp-postgresql - dbpptestcore + yes:../../..//dbpptestcore + no:dbpptestcore adhocutil - ../..//pq + ..//pq boost_utf stdc++fs ; diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp index e78a079..67ce07a 100644 --- a/libpqpp/unittests/testpq.cpp +++ b/libpqpp/unittests/testpq.cpp @@ -441,6 +441,22 @@ BOOST_AUTO_TEST_CASE( largeBlob ) } } +BOOST_AUTO_TEST_CASE( bulkPerfTest ) +{ + auto ro = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("PQmock")); + auto sel = ro->select(R"SQL(select s a, cast(s as numeric(7,1)) b, cast(s as text) c, + make_interval(secs => s) d, make_timestamp(2019,1,1,1,1,1) + make_interval(mins=>s) e, + s % 2 = 0 f + from generate_series(1, 1000) s)SQL"); + + int64_t tot = 0; + for (const auto & [a,b,c,d,e,f] : sel->as()) { + tot += a + b + c.length() + d.hours() + e.time_of_day().hours() + f; + } + BOOST_REQUIRE_EQUAL(tot, 1013265); +} + BOOST_AUTO_TEST_SUITE_END(); BOOST_AUTO_TEST_CASE( connfail ) -- cgit v1.2.3