Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Data/PostgreSQL/src/SessionHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ void SessionHandle::connect(const std::string& aConnectionString)
{
Poco::FastMutex::ScopedLock mutexLocker(_sessionMutex);

_inTransaction = false;
_preparedStatementsToBeDeallocated.clear();

if (isConnectedNoLock())
{
throw ConnectionFailedException("Already Connected");
Expand Down
33 changes: 33 additions & 0 deletions Data/PostgreSQL/testsuite/src/PostgreSQLTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "Poco/Data/DataException.h"
#include <iostream>

#include "Poco/Data/Transaction.h"

using namespace Poco::Data;
using namespace Poco::Data::Keywords;
Expand Down Expand Up @@ -794,6 +795,37 @@ void PostgreSQLTest::testReconnect()
}


void PostgreSQLTest::testTransactionWithReconnect()
{
if (!_pSession) fail ("Test not available.");

try
{
_pSession->begin();
*_pSession << "CREATE TABLE Person (LastName VARCHAR(30), FirstName VARCHAR(30), Address VARCHAR(30), Age INTEGER)", now;
_pSession->reconnect();
_pSession->commit();
}
catch (Poco::Exception& e)
{
_pSession->rollback();
std::cout << e.displayText() << std::endl;
}

try
{
_pSession->begin();
*_pSession << "CREATE TABLE Person (LastName VARCHAR(30), FirstName VARCHAR(30), Address VARCHAR(30), Age INTEGER)", now;
_pSession->commit();
}
catch (Poco::Exception& e)
{
_pSession->rollback();
std::cout << e.displayText() << std::endl;
}
}


void PostgreSQLTest::testSqlState()
{
if (!_pSession) fail ("Test not available.");
Expand Down Expand Up @@ -1333,6 +1365,7 @@ CppUnit::Test* PostgreSQLTest::suite()
CppUnit_addTest(pSuite, PostgreSQLTest, testSessionTransactionNoAutoCommit);
CppUnit_addTest(pSuite, PostgreSQLTest, testTransaction);
CppUnit_addTest(pSuite, PostgreSQLTest, testReconnect);
CppUnit_addTest(pSuite, PostgreSQLTest, testTransactionWithReconnect);

return pSuite;
}
2 changes: 1 addition & 1 deletion Data/PostgreSQL/testsuite/src/PostgreSQLTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class PostgreSQLTest: public CppUnit::TestCase
void testSessionTransactionNoAutoCommit();
void testTransaction();
void testReconnect();

void testTransactionWithReconnect();
void testSqlState();

void setUp();
Expand Down
Loading