From 8aecf8a9b0ff94a3a35fdd14f276e3894a90969e Mon Sep 17 00:00:00 2001 From: Alex Fabijanic Date: Thu, 22 Jun 2017 22:42:21 +0200 Subject: [PATCH] move mysql init to createSession() and protect it with mutex --- .../MySQL/include/Poco/Data/MySQL/Connector.h | 3 + Data/MySQL/src/Connector.cpp | 19 +- Data/MySQL/testsuite/src/MySQLTest.cpp | 14 +- Data/MySQL/testsuite/src/SQLExecutor.cpp | 435 +++++++++--------- 4 files changed, 245 insertions(+), 226 deletions(-) diff --git a/Data/MySQL/include/Poco/Data/MySQL/Connector.h b/Data/MySQL/include/Poco/Data/MySQL/Connector.h index 1b8003c10..c7f70b26b 100644 --- a/Data/MySQL/include/Poco/Data/MySQL/Connector.h +++ b/Data/MySQL/include/Poco/Data/MySQL/Connector.h @@ -22,6 +22,7 @@ #include "Poco/Data/MySQL/MySQL.h" #include "Poco/Data/Connector.h" +#include "Poco/Mutex.h" // Note: to avoid static (de)initialization problems, @@ -60,6 +61,8 @@ public: static void unregisterConnector(); /// Unregisters the Connector under the Keyword Connector::KEY at the Poco::Data::SessionFactory + + static Poco::Mutex _mutex; }; diff --git a/Data/MySQL/src/Connector.cpp b/Data/MySQL/src/Connector.cpp index ea835908b..3afac3073 100644 --- a/Data/MySQL/src/Connector.cpp +++ b/Data/MySQL/src/Connector.cpp @@ -30,6 +30,7 @@ namespace MySQL { std::string Connector::KEY(POCO_DATA_MYSQL_CONNECTOR_NAME); +Poco::Mutex Connector::_mutex; Connector::Connector() @@ -50,17 +51,25 @@ const std::string& Connector::name() const Poco::AutoPtr Connector::createSession(const std::string& connectionString, std::size_t timeout) { + static bool initDone = false; + { + Poco::Mutex::ScopedLock l(_mutex); + if (!initDone) + { + if (mysql_library_init(0, 0, 0) != 0) + { + throw Exception("mysql_library_init error"); + } + initDone = true; + } + } + return Poco::AutoPtr(new SessionImpl(connectionString, timeout)); } void Connector::registerConnector() { - if (mysql_library_init(0, 0, 0) != 0) - { - throw Exception("mysql_library_init error"); - } - Poco::Data::SessionFactory::instance().add(new Connector()); } diff --git a/Data/MySQL/testsuite/src/MySQLTest.cpp b/Data/MySQL/testsuite/src/MySQLTest.cpp index 5d1ab2208..5561af524 100644 --- a/Data/MySQL/testsuite/src/MySQLTest.cpp +++ b/Data/MySQL/testsuite/src/MySQLTest.cpp @@ -49,16 +49,22 @@ Poco::SharedPtr MySQLTest::_pExecutor = 0; std::string MySQLTest::getHost() { - return "localhost"; + return "127.0.0.1"; //localhost"; } + + std::string MySQLTest::getPort() { return "3306"; } + + std::string MySQLTest::getUser() { return "root"; } + + std::string MySQLTest::getPass() { if (Environment::has("APPVEYOR")) @@ -68,18 +74,20 @@ std::string MySQLTest::getPass() else return "poco"; } + + std::string MySQLTest::getBase() { return "pocotestdb"; } -std::string MySQLTest::_dbConnString; +std::string MySQLTest::_dbConnString; // // Connection string - +// MySQLTest::MySQLTest(const std::string& name): CppUnit::TestCase(name) diff --git a/Data/MySQL/testsuite/src/SQLExecutor.cpp b/Data/MySQL/testsuite/src/SQLExecutor.cpp index 5b1702eee..13ffdf5e9 100644 --- a/Data/MySQL/testsuite/src/SQLExecutor.cpp +++ b/Data/MySQL/testsuite/src/SQLExecutor.cpp @@ -174,29 +174,28 @@ SQLExecutor::~SQLExecutor() void SQLExecutor::bareboneMySQLTest(const std::string& host, const std::string& user, const std::string& pwd, const std::string& db, const std::string& port, const char* tableCreateString) { - int rc; MYSQL* hsession = mysql_init(0); - assert (hsession != 0); + poco_assert (hsession != 0); MYSQL* tmp = mysql_real_connect(hsession, host.c_str(), user.c_str(), pwd.c_str(), db.c_str(), NumberParser::parse(port), 0, 0); - assert(tmp == hsession); + poco_assert (tmp == hsession); MYSQL_STMT* hstmt = mysql_stmt_init(hsession); - assert(hstmt != 0); + poco_assert (hstmt != 0); std::string sql = "DROP TABLE Test"; mysql_real_query(hsession, sql.c_str(), static_cast(sql.length())); sql = tableCreateString; - rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast(sql.length())); - assert(rc == 0); + int rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast(sql.length())); + poco_assert (rc == 0); rc = mysql_stmt_execute(hstmt); - assert(rc == 0); + poco_assert (rc == 0); sql = "INSERT INTO Test VALUES (?,?,?,?,?)"; rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast(sql.length())); - assert(rc == 0); + poco_assert (rc == 0); std::string str[3] = { "111", "222", "333" }; int fourth = 4; @@ -223,14 +222,14 @@ void SQLExecutor::bareboneMySQLTest(const std::string& host, const std::string& bind_param[4].buffer_type = MYSQL_TYPE_FLOAT; rc = mysql_stmt_bind_param(hstmt, bind_param); - assert (rc == 0); + poco_assert (rc == 0); rc = mysql_stmt_execute(hstmt); - assert (rc == 0); + poco_assert (rc == 0); sql = "SELECT * FROM Test"; rc = mysql_stmt_prepare(hstmt, sql.c_str(), static_cast(sql.length())); - assert (rc == 0); + poco_assert (rc == 0); char chr[3][5] = {{ 0 }}; unsigned long lengths[5] = { 0 }; @@ -263,25 +262,25 @@ void SQLExecutor::bareboneMySQLTest(const std::string& host, const std::string& bind_result[4].length = &lengths[4]; rc = mysql_stmt_bind_result(hstmt, bind_result); - assert (rc == 0); + poco_assert (rc == 0); rc = mysql_stmt_execute(hstmt); - assert (rc == 0); + poco_assert (rc == 0); rc = mysql_stmt_fetch(hstmt); - assert (rc == 0); + poco_assert (rc == 0); - assert (0 == std::strncmp("111", chr[0], 3)); - assert (0 == std::strncmp("222", chr[1], 3)); - assert (0 == std::strncmp("333", chr[2], 3)); - assert (4 == fourth); - assert (1.5 == fifth); + poco_assert (0 == std::strncmp("111", chr[0], 3)); + poco_assert (0 == std::strncmp("222", chr[1], 3)); + poco_assert (0 == std::strncmp("333", chr[2], 3)); + poco_assert (4 == fourth); + poco_assert (1.5 == fifth); rc = mysql_stmt_close(hstmt); - assert(rc == 0); + poco_assert (rc == 0); sql = "DROP TABLE Test"; rc = mysql_real_query(hsession, sql.c_str(), static_cast(sql.length())); - assert(rc == 0); + poco_assert (rc == 0); mysql_close(hsession); } @@ -311,17 +310,17 @@ void SQLExecutor::simpleAccess() catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); try { *_pSession << "SELECT LastName FROM Person", into(result), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (lastName == result); + poco_assert (lastName == result); try { *_pSession << "SELECT Age FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == age); + poco_assert (count == age); } @@ -343,14 +342,14 @@ void SQLExecutor::complexType() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); Person c1; Person c2; try { *_pSession << "SELECT * FROM Person WHERE LastName = 'LN1'", into(c1), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (c1 == p1); + poco_assert (c1 == p1); } @@ -380,7 +379,7 @@ void SQLExecutor::simpleAccessVector() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); std::vector lastNamesR; std::vector firstNamesR; @@ -389,10 +388,10 @@ void SQLExecutor::simpleAccessVector() try { *_pSession << "SELECT * FROM Person", into(lastNamesR), into(firstNamesR), into(addressesR), into(agesR), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (ages == agesR); - assert (lastNames == lastNamesR); - assert (firstNames == firstNamesR); - assert (addresses == addressesR); + poco_assert (ages == agesR); + poco_assert (lastNames == lastNamesR); + poco_assert (firstNames == firstNamesR); + poco_assert (addresses == addressesR); } @@ -411,13 +410,13 @@ void SQLExecutor::complexTypeVector() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); std::vector result; try { *_pSession << "SELECT * FROM Person", into(result), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (result == people); + poco_assert (result == people); } @@ -436,7 +435,7 @@ void SQLExecutor::insertVector() try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 0); + poco_assert (count == 0); try { stmt.execute(); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } @@ -444,13 +443,13 @@ void SQLExecutor::insertVector() try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 4); + poco_assert (count == 4); } count = 0; try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 4); + poco_assert (count == 4); } @@ -479,19 +478,19 @@ void SQLExecutor::insertSingleBulk() for (x = 0; x < 100; ++x) { std::size_t i = stmt.execute(); - assert (i == 1); + poco_assert (i == 1); } int count = 0; try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 100); + poco_assert (count == 100); try { *_pSession << "SELECT SUM(str) FROM Strings", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == ((0+99)*100/2)); + poco_assert (count == ((0+99)*100/2)); } @@ -509,12 +508,12 @@ void SQLExecutor::unsignedInts() try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); try { *_pSession << "SELECT str FROM Strings", into(ret), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (ret == data); + poco_assert (ret == data); } @@ -532,12 +531,12 @@ void SQLExecutor::floats() try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); try { *_pSession << "SELECT str FROM Strings", into(ret), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (ret == data); + poco_assert (ret == data); } @@ -555,12 +554,12 @@ void SQLExecutor::doubles() try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); try { *_pSession << "SELECT str FROM Strings", into(ret), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (ret == data); + poco_assert (ret == data); } @@ -580,11 +579,11 @@ void SQLExecutor::insertSingleBulkVec() catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 100); + poco_assert (count == 100); try { *_pSession << "SELECT SUM(str) FROM Strings", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == ((0+99)*100/2)); + poco_assert (count == ((0+99)*100/2)); } @@ -605,10 +604,10 @@ void SQLExecutor::limits() try { *_pSession << "SELECT * FROM Strings", into(retData), limit(50), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (retData.size() == 50); + poco_assert (retData.size() == 50); for (int x = 0; x < 50; ++x) { - assert(data[x] == retData[x]); + poco_assert (data[x] == retData[x]); } } @@ -630,7 +629,7 @@ void SQLExecutor::limitZero() try { *_pSession << "SELECT * FROM Strings", into(retData), limit(0), now; }// stupid test, but at least we shouldn't crash catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (retData.size() == 0); + poco_assert (retData.size() == 0); } @@ -649,18 +648,18 @@ void SQLExecutor::limitOnce() std::vector retData; Statement stmt = (*_pSession << "SELECT * FROM Strings", into(retData), limit(50), now); - assert (!stmt.done()); - assert (retData.size() == 50); + poco_assert (!stmt.done()); + poco_assert (retData.size() == 50); stmt.execute(); - assert (!stmt.done()); - assert (retData.size() == 100); + poco_assert (!stmt.done()); + poco_assert (retData.size() == 100); stmt.execute(); - assert (stmt.done()); - assert (retData.size() == 101); + poco_assert (stmt.done()); + poco_assert (retData.size() == 101); for (int x = 0; x < 101; ++x) { - assert(data[x] == retData[x]); + poco_assert (data[x] == retData[x]); } } @@ -680,26 +679,26 @@ void SQLExecutor::limitPrepare() std::vector retData; Statement stmt = (*_pSession << "SELECT * FROM Strings", into(retData), limit(50)); - assert (retData.size() == 0); - assert (!stmt.done()); + poco_assert (retData.size() == 0); + poco_assert (!stmt.done()); try { stmt.execute(); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (!stmt.done()); - assert (retData.size() == 50); + poco_assert (!stmt.done()); + poco_assert (retData.size() == 50); try { stmt.execute(); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (stmt.done()); - assert (retData.size() == 100); + poco_assert (stmt.done()); + poco_assert (retData.size() == 100); try { stmt.execute(); }// will restart execution! catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (!stmt.done()); - assert (retData.size() == 150); + poco_assert (!stmt.done()); + poco_assert (retData.size() == 150); for (int x = 0; x < 150; ++x) { - assert(data[x%100] == retData[x]); + poco_assert (data[x%100] == retData[x]); } } @@ -722,7 +721,7 @@ void SQLExecutor::prepare() try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 0); + poco_assert (count == 0); } @@ -751,7 +750,7 @@ void SQLExecutor::setSimple() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); std::set lastNamesR; std::set firstNamesR; @@ -760,10 +759,10 @@ void SQLExecutor::setSimple() try { *_pSession << "SELECT * FROM Person", into(lastNamesR), into(firstNamesR), into(addressesR), into(agesR), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (ages == agesR); - assert (lastNames == lastNamesR); - assert (firstNames == firstNamesR); - assert (addresses == addressesR); + poco_assert (ages == agesR); + poco_assert (lastNames == lastNamesR); + poco_assert (firstNames == firstNamesR); + poco_assert (addresses == addressesR); } @@ -781,13 +780,13 @@ void SQLExecutor::setComplex() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); std::set result; try { *_pSession << "SELECT * FROM Person", into(result), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (result == people); + poco_assert (result == people); } @@ -810,15 +809,15 @@ void SQLExecutor::setComplexUnique() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 5); + poco_assert (count == 5); std::set result; try { *_pSession << "SELECT * FROM Person", into(result), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (result.size() == 2); - assert (*result.begin() == p1); - assert (*++result.begin() == p2); + poco_assert (result.size() == 2); + poco_assert (*result.begin() == p1); + poco_assert (*++result.begin() == p2); } void SQLExecutor::multiSetSimple() @@ -846,7 +845,7 @@ void SQLExecutor::multiSetSimple() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); std::multiset lastNamesR; std::multiset firstNamesR; @@ -855,10 +854,10 @@ void SQLExecutor::multiSetSimple() try { *_pSession << "SELECT * FROM Person", into(lastNamesR), into(firstNamesR), into(addressesR), into(agesR), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (ages.size() == agesR.size()); - assert (lastNames.size() == lastNamesR.size()); - assert (firstNames.size() == firstNamesR.size()); - assert (addresses.size() == addressesR.size()); + poco_assert (ages.size() == agesR.size()); + poco_assert (lastNames.size() == lastNamesR.size()); + poco_assert (firstNames.size() == firstNamesR.size()); + poco_assert (addresses.size() == addressesR.size()); } @@ -881,13 +880,13 @@ void SQLExecutor::multiSetComplex() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 5); + poco_assert (count == 5); std::multiset result; try { *_pSession << "SELECT * FROM Person", into(result), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (result.size() == people.size()); + poco_assert (result.size() == people.size()); } @@ -907,13 +906,13 @@ void SQLExecutor::mapComplex() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); std::map result; try { *_pSession << "SELECT * FROM Person", into(result), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (result == people); + poco_assert (result == people); } @@ -936,13 +935,13 @@ void SQLExecutor::mapComplexUnique() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 5); + poco_assert (count == 5); std::map result; try { *_pSession << "SELECT * FROM Person", into(result), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (result.size() == 2); + poco_assert (result.size() == 2); } @@ -965,13 +964,13 @@ void SQLExecutor::multiMapComplex() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 5); + poco_assert (count == 5); std::multimap result; try { *_pSession << "SELECT * FROM Person", into(result), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (result.size() == people.size()); + poco_assert (result.size() == people.size()); } @@ -991,12 +990,12 @@ void SQLExecutor::selectIntoSingle() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); Person result; try { *_pSession << "SELECT * FROM Person", into(result), limit(1), now; }// will return 1 object into one single result catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (result == p1); + poco_assert (result == p1); } @@ -1017,15 +1016,15 @@ void SQLExecutor::selectIntoSingleStep() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); Person result; Statement stmt = (*_pSession << "SELECT * FROM Person", into(result), limit(1)); stmt.execute(); - assert (result == p1); - assert (!stmt.done()); + poco_assert (result == p1); + poco_assert (!stmt.done()); stmt.execute(); - assert (result == p2); - assert (stmt.done()); + poco_assert (result == p2); + poco_assert (stmt.done()); } @@ -1045,7 +1044,7 @@ void SQLExecutor::selectIntoSingleFail() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), limit(2, true), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); Person result; try { @@ -1075,7 +1074,7 @@ void SQLExecutor::lowerLimitOk() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); Person result; try { @@ -1105,15 +1104,15 @@ void SQLExecutor::singleSelect() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); Person result; Statement stmt = (*_pSession << "SELECT * FROM Person", into(result), limit(1)); stmt.execute(); - assert (result == p1); - assert (!stmt.done()); + poco_assert (result == p1); + poco_assert (!stmt.done()); stmt.execute(); - assert (result == p2); - assert (stmt.done()); + poco_assert (result == p2); + poco_assert (stmt.done()); } @@ -1133,7 +1132,7 @@ void SQLExecutor::lowerLimitFail() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); Person result; try { @@ -1162,14 +1161,14 @@ void SQLExecutor::combinedLimits() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); std::vector result; try { *_pSession << "SELECT * FROM Person", into(result), lowerLimit(2), upperLimit(2), now; }// will return 2 objects catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (result.size() == 2); - assert (result[0] == p1); - assert (result[1] == p2); + poco_assert (result.size() == 2); + poco_assert (result[0] == p1); + poco_assert (result[1] == p2); } @@ -1190,14 +1189,14 @@ void SQLExecutor::ranges() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); std::vector result; try { *_pSession << "SELECT * FROM Person", into(result), range(2, 2), now; }// will return 2 objects catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (result.size() == 2); - assert (result[0] == p1); - assert (result[1] == p2); + poco_assert (result.size() == 2); + poco_assert (result[0] == p1); + poco_assert (result[1] == p2); } @@ -1217,7 +1216,7 @@ void SQLExecutor::combinedIllegalLimits() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); Person result; try { @@ -1246,7 +1245,7 @@ void SQLExecutor::illegalRange() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 2); + poco_assert (count == 2); Person result; try { @@ -1266,13 +1265,13 @@ void SQLExecutor::emptyDB() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 0); + poco_assert (count == 0); Person result; Statement stmt = (*_pSession << "SELECT * FROM Person", into(result), limit(1)); stmt.execute(); - assert (result.firstName.empty()); - assert (stmt.done()); + poco_assert (result.firstName.empty()); + poco_assert (stmt.done()); } @@ -1291,14 +1290,14 @@ void SQLExecutor::dateTime() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); DateTime bd; - assert (bd != birthday); + poco_assert (bd != birthday); try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (bd == birthday); + poco_assert (bd == birthday); std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person"); } @@ -1319,14 +1318,14 @@ void SQLExecutor::date() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); Date bd; - assert (bd != birthday); + poco_assert (bd != birthday); try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (bd == birthday); + poco_assert (bd == birthday); std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person"); } @@ -1347,14 +1346,14 @@ void SQLExecutor::time() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); Time bd; - assert (bd != birthday); + poco_assert (bd != birthday); try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (bd == birthday); + poco_assert (bd == birthday); std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person"); } @@ -1375,20 +1374,20 @@ void SQLExecutor::blob(unsigned int bigSize) try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); Poco::Data::CLOB res; - assert (res.size() == 0); + poco_assert (res.size() == 0); try { *_pSession << "SELECT Image FROM Person", into(res), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (res == img); + poco_assert (res == img); Poco::Data::CLOB big; std::vector v(bigSize, 'x'); big.assignRaw(&v[0], (std::size_t) v.size()); - assert (big.size() == (std::size_t) bigSize); + poco_assert (big.size() == (std::size_t) bigSize); try { *_pSession << "DELETE FROM Person", now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } @@ -1401,7 +1400,7 @@ void SQLExecutor::blob(unsigned int bigSize) try { *_pSession << "SELECT Image FROM Person", into(res), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (res == big); + poco_assert (res == big); } @@ -1419,7 +1418,7 @@ void SQLExecutor::blobStmt() try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); Poco::Data::CLOB res; poco_assert (res.size() == 0); @@ -1442,11 +1441,11 @@ void SQLExecutor::tuples() catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } TupleType ret(-10,-11,-12,-13,-14,-15,-16,-17,-18,-19); - assert (ret != t); + poco_assert (ret != t); try { *_pSession << "SELECT * FROM Tuples", into(ret), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (ret == t); + poco_assert (ret == t); } @@ -1471,13 +1470,13 @@ void SQLExecutor::tupleVector() try { *_pSession << "SELECT COUNT(*) FROM Tuples", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (v.size() == (std::size_t) count); + poco_assert (v.size() == (std::size_t) count); std::vector > ret; try { *_pSession << "SELECT * FROM Tuples", into(ret), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (ret == v); + poco_assert (ret == v); } #if __cplusplus >= 201103L @@ -1493,11 +1492,11 @@ void SQLExecutor::stdTuples() catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } TupleType ret = std::make_tuple(-10,-11,-12,-13,-14,-15,-16,-17,-18,-19,-20,-21,-22,-23,-24,-25,-26,-27,-28,-29); - assert (ret != t); + poco_assert (ret != t); try { *_pSession << "SELECT * FROM Tuples", into(ret), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (ret == t); + poco_assert (ret == t); } @@ -1521,13 +1520,13 @@ void SQLExecutor::stdTupleVector() try { *_pSession << "SELECT COUNT(*) FROM Tuples", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (v.size() == (std::size_t) count); + poco_assert (v.size() == (std::size_t) count); std::vector ret; try { *_pSession << "SELECT * FROM Tuples", into(ret), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (ret == v); + poco_assert (ret == v); } #endif //__cplusplus >= 201103L @@ -1551,55 +1550,55 @@ void SQLExecutor::internalExtraction() Statement stmt = (*_pSession << "SELECT * FROM Vectors", now); RecordSet rset(stmt); - assert (3 == rset.columnCount()); - assert (4 == rset.rowCount()); + poco_assert (3 == rset.columnCount()); + poco_assert (4 == rset.rowCount()); int curVal = 3; do { - assert (rset["str0"] == curVal); + poco_assert (rset["str0"] == curVal); ++curVal; } while (rset.moveNext()); rset.moveFirst(); - assert (rset["str0"] == "3"); + poco_assert (rset["str0"] == "3"); rset.moveLast(); - assert (rset["str0"] == "6"); + poco_assert (rset["str0"] == "6"); RecordSet rset2(rset); - assert (3 == rset2.columnCount()); - assert (4 == rset2.rowCount()); + poco_assert (3 == rset2.columnCount()); + poco_assert (4 == rset2.rowCount()); int i = rset.value(0,0); - assert (1 == i); + poco_assert (1 == i); std::string s = rset.value(0,0); - assert ("1" == s); + poco_assert ("1" == s); int a = rset.value(0,2); - assert (3 == a); + poco_assert (3 == a); try { double d = rset.value(1,1); - assert (2.5 == d); + poco_assert (2.5 == d); } catch (BadCastException&) { float f = rset.value(1,1); - assert (2.5 == f); + poco_assert (2.5 == f); } s = rset.value(2,2); - assert ("5" == s); + poco_assert ("5" == s); i = rset.value("str0", 2); - assert (5 == i); + poco_assert (5 == i); const Column& col = rset.column(0); Column::Iterator it = col.begin(); Column::Iterator end = col.end(); for (int i = 1; it != end; ++it, ++i) - assert (*it == i); + poco_assert (*it == i); rset = (*_pSession << "SELECT COUNT(*) AS cnt FROM Vectors", now); @@ -1608,7 +1607,7 @@ void SQLExecutor::internalExtraction() { //this is what most drivers will return int i = rset.value(0,0); - assert (4 == i); + poco_assert (4 == i); } catch(BadCastException&) { @@ -1616,18 +1615,18 @@ void SQLExecutor::internalExtraction() { //this is for Oracle double i = rset.value(0,0); - assert (4 == int(i)); + poco_assert (4 == int(i)); } catch(BadCastException&) { //this is for PostgreSQL Poco::Int64 big = rset.value(0,0); - assert (4 == big); + poco_assert (4 == big); } } s = rset.value("cnt", 0).convert(); - assert ("4" == s); + poco_assert ("4" == s); try { const Column& col1 = rset.column(100); fail ("must fail"); } catch (RangeException&) { } @@ -1660,7 +1659,7 @@ void SQLExecutor::doNull() try { *_pSession << "SELECT COUNT(*) FROM Vectors", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); int i0 = 0; Statement stmt1 = (*_pSession << "SELECT i0 FROM Vectors", into(i0, Poco::Data::Position(0), -1)); @@ -1696,11 +1695,11 @@ void SQLExecutor::setTransactionIsolation(Session& session, Poco::UInt32 ti) Transaction t(session, false); t.setIsolation(ti); - assert (ti == t.getIsolation()); - assert (t.isIsolation(ti)); + poco_assert (ti == t.getIsolation()); + poco_assert (t.isIsolation(ti)); - assert (ti == session.getTransactionIsolation()); - assert (session.isTransactionIsolation(ti)); + poco_assert (ti == session.getTransactionIsolation()); + poco_assert (session.isTransactionIsolation(ti)); } catch(Poco::Exception& e){ std::cout << funct << ':' << e.displayText() << std::endl;} } @@ -1756,9 +1755,9 @@ void SQLExecutor::sessionTransaction(const std::string& connect) bool autoCommit = _pSession->getFeature("autoCommit"); _pSession->setFeature("autoCommit", true); - assert (!_pSession->isTransaction()); + poco_assert (!_pSession->isTransaction()); _pSession->setFeature("autoCommit", false); - assert (!_pSession->isTransaction()); + poco_assert (!_pSession->isTransaction()); setTransactionIsolation((*_pSession), Session::TRANSACTION_READ_UNCOMMITTED); setTransactionIsolation((*_pSession), Session::TRANSACTION_REPEATABLE_READ); @@ -1767,51 +1766,51 @@ void SQLExecutor::sessionTransaction(const std::string& connect) setTransactionIsolation((*_pSession), Session::TRANSACTION_READ_COMMITTED); _pSession->begin(); - assert (_pSession->isTransaction()); + poco_assert (_pSession->isTransaction()); 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(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (_pSession->isTransaction()); + poco_assert (_pSession->isTransaction()); local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (0 == locCount); + poco_assert (0 == locCount); try { (*_pSession) << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (2 == count); - assert (_pSession->isTransaction()); + poco_assert (2 == count); + poco_assert (_pSession->isTransaction()); _pSession->rollback(); - assert (!_pSession->isTransaction()); + poco_assert (!_pSession->isTransaction()); local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (0 == locCount); + poco_assert (0 == locCount); try { (*_pSession) << "SELECT count(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (0 == count); - assert (!_pSession->isTransaction()); + poco_assert (0 == count); + poco_assert (!_pSession->isTransaction()); _pSession->begin(); 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(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (_pSession->isTransaction()); + poco_assert (_pSession->isTransaction()); local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (0 == locCount); + poco_assert (0 == locCount); _pSession->commit(); - assert (!_pSession->isTransaction()); + poco_assert (!_pSession->isTransaction()); local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (2 == locCount); + poco_assert (2 == locCount); try { (*_pSession) << "SELECT count(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (2 == count); + poco_assert (2 == count); _pSession->setFeature("autoCommit", autoCommit); } @@ -1851,37 +1850,37 @@ void SQLExecutor::transaction(const std::string& connect) bool autoCommit = _pSession->getFeature("autoCommit"); _pSession->setFeature("autoCommit", true); - assert (!_pSession->isTransaction()); + poco_assert (!_pSession->isTransaction()); _pSession->setFeature("autoCommit", false); - assert (!_pSession->isTransaction()); + poco_assert (!_pSession->isTransaction()); _pSession->setTransactionIsolation(Session::TRANSACTION_READ_COMMITTED); { Transaction trans((*_pSession)); - assert (trans.isActive()); - assert (_pSession->isTransaction()); + poco_assert (trans.isActive()); + poco_assert (_pSession->isTransaction()); 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(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (_pSession->isTransaction()); - assert (trans.isActive()); + poco_assert (_pSession->isTransaction()); + poco_assert (trans.isActive()); try { (*_pSession) << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (2 == count); - assert (_pSession->isTransaction()); - assert (trans.isActive()); + poco_assert (2 == count); + poco_assert (_pSession->isTransaction()); + poco_assert (trans.isActive()); } - assert (!_pSession->isTransaction()); + poco_assert (!_pSession->isTransaction()); try { (*_pSession) << "SELECT count(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (0 == count); - assert (!_pSession->isTransaction()); + poco_assert (0 == count); + poco_assert (!_pSession->isTransaction()); { Transaction trans((*_pSession)); @@ -1890,21 +1889,21 @@ void SQLExecutor::transaction(const std::string& connect) catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (0 == locCount); + poco_assert (0 == locCount); - assert (_pSession->isTransaction()); - assert (trans.isActive()); + poco_assert (_pSession->isTransaction()); + poco_assert (trans.isActive()); trans.commit(); - assert (!_pSession->isTransaction()); - assert (!trans.isActive()); + poco_assert (!_pSession->isTransaction()); + poco_assert (!trans.isActive()); local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (2 == locCount); + poco_assert (2 == locCount); } try { (*_pSession) << "SELECT count(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (2 == count); + poco_assert (2 == count); _pSession->begin(); try { (*_pSession) << "DELETE FROM Person", now; } @@ -1912,16 +1911,16 @@ void SQLExecutor::transaction(const std::string& connect) catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (2 == locCount); + poco_assert (2 == locCount); try { (*_pSession) << "SELECT count(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (0 == count); + poco_assert (0 == count); _pSession->commit(); local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (0 == locCount); + poco_assert (0 == locCount); std::string sql1 = format("INSERT INTO Person VALUES ('%s','%s','%s',%d)", lastNames[0], firstNames[0], addresses[0], ages[0]); std::string sql2 = format("INSERT INTO Person VALUES ('%s','%s','%s',%d)", lastNames[1], firstNames[1], addresses[1], ages[1]); @@ -1935,35 +1934,35 @@ void SQLExecutor::transaction(const std::string& connect) try { (*_pSession) << "SELECT count(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (1 == count); + poco_assert (1 == count); trans.execute(sql2, false); try { (*_pSession) << "SELECT count(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (2 == count); + poco_assert (2 == count); local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (0 == locCount); + poco_assert (0 == locCount); trans.rollback(); local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (0 == locCount); + poco_assert (0 == locCount); try { (*_pSession) << "SELECT count(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (0 == count); + poco_assert (0 == count); trans.execute(sql); local << "SELECT COUNT(*) FROM Person", into(locCount), now; - assert (2 == locCount); + poco_assert (2 == locCount); try { (*_pSession) << "SELECT count(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (2 == count); + poco_assert (2 == count); _pSession->setFeature("autoCommit", autoCommit); } @@ -1987,24 +1986,24 @@ void SQLExecutor::reconnect() try { (*_pSession) << "SELECT COUNT(*) FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == 1); + poco_assert (count == 1); - assert (_pSession->isConnected()); + poco_assert (_pSession->isConnected()); _pSession->close(); - assert (!_pSession->isConnected()); + poco_assert (!_pSession->isConnected()); try { (*_pSession) << "SELECT LastName FROM Person", into(result), now; fail ("must fail"); } catch(NotConnectedException&){ } - assert (!_pSession->isConnected()); + poco_assert (!_pSession->isConnected()); _pSession->open(); - assert (_pSession->isConnected()); + poco_assert (_pSession->isConnected()); try { (*_pSession) << "SELECT Age FROM Person", into(count), now; } catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); } - assert (count == age); - assert (_pSession->isConnected()); + poco_assert (count == age); + poco_assert (_pSession->isConnected()); }