Fixed transaction handling in MySQL test when SQL parser is switched off

This commit is contained in:
Friedrich Wilckens 2024-02-15 12:02:57 -08:00 committed by Alex Fabijanic
parent 137cd32183
commit a64e6cf2f6

View File

@ -1850,9 +1850,11 @@ void SQLExecutor::sessionTransaction(const std::string& connect)
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (0 == count);
assertTrue (!_pSession->isTransaction());
_pSession->begin();
if (_pSession->impl()->shouldParse()) {
assertTrue (!_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); }
@ -1936,11 +1938,13 @@ void SQLExecutor::transaction(const std::string& connect)
}
assertTrue (!_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); }
assertTrue (0 == count);
assertTrue (!_pSession->isTransaction());
if (_pSession->impl()->shouldParse()) {
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); }
assertTrue (0 == count);
assertTrue (!_pSession->isTransaction());
}
{
Transaction trans((*_pSession));
@ -1965,7 +1969,8 @@ void SQLExecutor::transaction(const std::string& connect)
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assertTrue (2 == count);
_pSession->begin();
if (_pSession->impl()->shouldParse())
_pSession->begin();
try { (*_pSession) << "DELETE FROM Person", now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
@ -1988,6 +1993,8 @@ void SQLExecutor::transaction(const std::string& connect)
sql.push_back(sql1);
sql.push_back(sql2);
assertTrue (!_pSession->isTransaction());
Transaction trans((*_pSession));
trans.execute(sql1, false);
@ -2038,6 +2045,8 @@ void SQLExecutor::reconnect()
int count = 0;
std::string result;
_pSession->setFeature("autoCommit", true);
try { (*_pSession) << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(age), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }