From a6be6d86457a0b5dc982a0d4c7128a510313506d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 25 Feb 2016 22:24:53 +0000 Subject: Reuse prepared statements --- libpqpp/unittests/testpq.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libpqpp/unittests') diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp index 80757db..3d8c804 100644 --- a/libpqpp/unittests/testpq.cpp +++ b/libpqpp/unittests/testpq.cpp @@ -262,6 +262,22 @@ BOOST_AUTO_TEST_CASE( reconnectInTx ) delete rok; } +BOOST_AUTO_TEST_CASE( statementReuse ) +{ + auto ro = DB::MockDatabase::openConnectionTo("pqmock"); + auto pqconn = dynamic_cast(ro); + BOOST_REQUIRE_EQUAL(pqconn->preparedStatements.size(), 0); + for (int y = 0; y < 4; y += 1) { + auto m1 = ro->modify("INSERT INTO test(id) VALUES(?)"); + for (int x = 0; x < 4; x += 1) { + m1->bindParamI(0, x); + m1->execute(); + } + } + BOOST_REQUIRE_EQUAL(pqconn->preparedStatements.size(), 1); + delete ro; +} + BOOST_AUTO_TEST_SUITE_END(); BOOST_AUTO_TEST_CASE( connfail ) -- cgit v1.2.3