Commit a974b122 authored by Steven Murray's avatar Steven Murray
Browse files

Moved autocommitMode parameter from Stmt constructor to Stmt::executeQuery()...

Moved autocommitMode parameter from Stmt constructor to Stmt::executeQuery() and Stmt::executeNonQuery()
parent b17de6d2
......@@ -68,13 +68,13 @@ int CreateSchemaCmd::exceptionThrowingMain(const int argc, char *const *const ar
case rdbms::Login::DBTYPE_SQLITE:
{
SqliteCatalogueSchema schema;
conn.executeNonQueries(schema.sql);
conn.executeNonQueries(schema.sql, rdbms::AutocommitMode::AUTOCOMMIT_ON);
}
break;
case rdbms::Login::DBTYPE_ORACLE:
{
OracleCatalogueSchema schema;
conn.executeNonQueries(schema.sql);
conn.executeNonQueries(schema.sql, rdbms::AutocommitMode::AUTOCOMMIT_ON);
}
break;
case rdbms::Login::DBTYPE_NONE:
......
......@@ -168,8 +168,8 @@ uint64_t OracleCatalogue::getNextArchiveFileId(rdbms::Conn &conn) {
"ARCHIVE_FILE_ID_SEQ.NEXTVAL AS ARCHIVE_FILE_ID "
"FROM "
"DUAL";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_OFF);
auto rset = stmt.executeQuery();
auto stmt = conn.createStmt(sql);
auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF);
if (!rset.next()) {
throw exception::Exception(std::string("Result set is unexpectedly empty"));
}
......@@ -193,8 +193,8 @@ uint64_t OracleCatalogue::getNextStorageClassId(rdbms::Conn &conn) {
"STORAGE_CLASS_ID_SEQ.NEXTVAL AS STORAGE_CLASS_ID "
"FROM "
"DUAL";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_OFF);
auto rset = stmt.executeQuery();
auto stmt = conn.createStmt(sql);
auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF);
if (!rset.next()) {
throw exception::Exception(std::string("Result set is unexpectedly empty"));
}
......@@ -249,9 +249,9 @@ common::dataStructures::Tape OracleCatalogue::selectTapeForUpdate(rdbms::Conn &c
"WHERE "
"VID = :VID "
"FOR UPDATE";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_OFF);
auto stmt = conn.createStmt(sql);
stmt.bindString(":VID", vid);
auto rset = stmt.executeQuery();
auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF);
if (!rset.next()) {
throw exception::Exception(std::string("The tape with VID " + vid + " does not exist"));
}
......@@ -461,7 +461,7 @@ void OracleCatalogue::filesWrittenToTape(const std::set<TapeItemWrittenPointer>
":COPY_NB,"
":CREATION_TIME,"
":ARCHIVE_FILE_ID)";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_OFF);
auto stmt = conn.createStmt(sql);
rdbms::wrapper::OcciStmt &occiStmt = dynamic_cast<rdbms::wrapper::OcciStmt &>(stmt.getStmt());
occiStmt.setColumn(tapeFileBatch.vid);
occiStmt.setColumn(tapeFileBatch.fSeq);
......@@ -590,7 +590,7 @@ void OracleCatalogue::idempotentBatchInsertArchiveFiles(rdbms::Conn &conn,
"WHERE "
"DISK_INSTANCE_NAME = :DISK_INSTANCE_NAME AND "
"STORAGE_CLASS_NAME = :STORAGE_CLASS_NAME";
auto stmt = conn.createStmt(sql, autocommitMode);
auto stmt = conn.createStmt(sql);
rdbms::wrapper::OcciStmt &occiStmt = dynamic_cast<rdbms::wrapper::OcciStmt &>(stmt.getStmt());
occiStmt->setBatchErrorMode(true);
......@@ -684,9 +684,9 @@ std::map<uint64_t, OracleCatalogue::FileSizeAndChecksum> OracleCatalogue::select
"ARCHIVE_FILE "
"INNER JOIN TEMP_TAPE_FILE_BATCH ON "
"ARCHIVE_FILE.ARCHIVE_FILE_ID = TEMP_TAPE_FILE_BATCH.ARCHIVE_FILE_ID";
auto stmt = conn.createStmt(sql, autocommitMode);
auto stmt = conn.createStmt(sql);
auto rset = stmt.executeQuery();
auto rset = stmt.executeQuery(autocommitMode);
std::map<uint64_t, FileSizeAndChecksum> fileSizesAndChecksums;
while (rset.next()) {
......@@ -744,7 +744,7 @@ void OracleCatalogue::insertTapeFileBatchIntoTempTable(rdbms::Conn &conn,
"ARCHIVE_FILE_ID)"
"VALUES("
":ARCHIVE_FILE_ID)";
auto stmt = conn.createStmt(sql, autocommitMode);
auto stmt = conn.createStmt(sql);
rdbms::wrapper::OcciStmt &occiStmt = dynamic_cast<rdbms::wrapper::OcciStmt &>(stmt.getStmt());
occiStmt->setBatchErrorMode(false);
......
......@@ -202,7 +202,7 @@ RdbmsArchiveFileItorImpl::RdbmsArchiveFileItorImpl(
}
auto conn = connPool.getConn();
m_stmt = conn.createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_OFF);
m_stmt = conn.createStmt(sql);
if(searchCriteria.archiveFileId) {
m_stmt.bindUint64(":ARCHIVE_FILE_ID", searchCriteria.archiveFileId.value());
}
......@@ -233,7 +233,7 @@ RdbmsArchiveFileItorImpl::RdbmsArchiveFileItorImpl(
if(searchCriteria.tapePool) {
m_stmt.bindString(":TAPE_POOL_NAME", searchCriteria.tapePool.value());
}
m_rset = m_stmt.executeQuery();
m_rset = m_stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF);
m_rsetIsEmpty = !m_rset.next();
} catch(exception::UserError &) {
......
This diff is collapsed.
......@@ -46,7 +46,7 @@ void SchemaCreatingSqliteCatalogue::createCatalogueSchema() {
try {
const SqliteCatalogueSchema schema;
auto conn = m_connPool.getConn();
conn.executeNonQueries(schema.sql);
conn.executeNonQueries(schema.sql, rdbms::AutocommitMode::AUTOCOMMIT_ON);
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str());
}
......
......@@ -123,17 +123,17 @@ void SqliteCatalogue::deleteArchiveFile(const std::string &diskInstanceName, con
t.reset();
{
const char *const sql = "DELETE FROM TAPE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID;";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_OFF);
auto stmt = conn.createStmt(sql);
stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
stmt.executeNonQuery();
stmt.executeNonQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF);
}
const auto deleteFromTapeFileTime = t.secs(utils::Timer::resetCounter);
{
const char *const sql = "DELETE FROM ARCHIVE_FILE WHERE ARCHIVE_FILE_ID = :ARCHIVE_FILE_ID;";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_OFF);
auto stmt = conn.createStmt(sql);
stmt.bindUint64(":ARCHIVE_FILE_ID", archiveFileId);
stmt.executeNonQuery();
stmt.executeNonQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF);
}
const auto deleteFromArchiveFileTime = t.secs(utils::Timer::resetCounter);
......@@ -199,8 +199,8 @@ uint64_t SqliteCatalogue::getNextArchiveFileId(rdbms::Conn &conn) {
"ID AS ID "
"FROM "
"ARCHIVE_FILE_ID";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_OFF);
auto rset = stmt.executeQuery();
auto stmt = conn.createStmt(sql);
auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF);
if(!rset.next()) {
throw exception::Exception("ARCHIVE_FILE_ID table is empty");
}
......@@ -238,8 +238,8 @@ uint64_t SqliteCatalogue::getNextStorageClassId(rdbms::Conn &conn) {
"ID AS ID "
"FROM "
"STORAGE_CLASS_ID";
auto stmt = conn.createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_OFF);
auto rset = stmt.executeQuery();
auto stmt = conn.createStmt(sql);
auto rset = stmt.executeQuery(rdbms::AutocommitMode::AUTOCOMMIT_OFF);
if(!rset.next()) {
throw exception::Exception("STORAGE_CLASS_ID table is empty");
}
......@@ -295,9 +295,9 @@ common::dataStructures::Tape SqliteCatalogue::selectTape(const rdbms::Autocommit
"WHERE "
"VID = :VID;";
auto stmt = conn.createStmt(sql, autocommitMode);
auto stmt = conn.createStmt(sql);
stmt.bindString(":VID", vid);
auto rset = stmt.executeQuery();
auto rset = stmt.executeQuery(autocommitMode);
if (!rset.next()) {
throw exception::Exception(std::string("The tape with VID " + vid + " does not exist"));
}
......
......@@ -77,9 +77,9 @@ Conn &Conn::operator=(Conn &&rhs) {
//------------------------------------------------------------------------------
// createStmt
//------------------------------------------------------------------------------
Stmt Conn::createStmt(const std::string &sql, const AutocommitMode autocommitMode) {
Stmt Conn::createStmt(const std::string &sql) {
if(nullptr != m_connAndStmts && nullptr != m_connAndStmts->conn) {
return m_connAndStmts->stmtPool->getStmt(*m_connAndStmts->conn, sql, autocommitMode);
return m_connAndStmts->stmtPool->getStmt(*m_connAndStmts->conn, sql);
} else {
throw exception::Exception(std::string(__FUNCTION__) + " failed: Conn does not contain a connection");
}
......@@ -88,7 +88,7 @@ Stmt Conn::createStmt(const std::string &sql, const AutocommitMode autocommitMod
//------------------------------------------------------------------------------
// executeNonQueries
//------------------------------------------------------------------------------
void Conn::executeNonQueries(const std::string &sqlStmts) {
void Conn::executeNonQueries(const std::string &sqlStmts, const AutocommitMode autocommitMode) {
try {
std::string::size_type searchPos = 0;
std::string::size_type findResult = std::string::npos;
......@@ -100,7 +100,7 @@ void Conn::executeNonQueries(const std::string &sqlStmts) {
searchPos = findResult + 1;
if(0 < sqlStmt.size()) { // Ignore empty statements
executeNonQuery(sqlStmt, AutocommitMode::AUTOCOMMIT_ON);
executeNonQuery(sqlStmt, autocommitMode);
}
}
......@@ -114,8 +114,8 @@ void Conn::executeNonQueries(const std::string &sqlStmts) {
//------------------------------------------------------------------------------
void Conn::executeNonQuery(const std::string &sql, const AutocommitMode autocommitMode) {
try {
auto stmt = createStmt(sql, autocommitMode);
stmt.executeNonQuery();
auto stmt = createStmt(sql);
stmt.executeNonQuery(autocommitMode);
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.what());
}
......
......@@ -82,10 +82,9 @@ public:
* Creates a prepared statement.
*
* @param sql The SQL statement.
* @param autocommitMode The autocommit mode of the statement.
* @return The prepared statement.
*/
Stmt createStmt(const std::string &sql, const AutocommitMode autocommitMode);
Stmt createStmt(const std::string &sql);
/**
* Convenience method that parses the specified string of multiple SQL
......@@ -96,16 +95,16 @@ public:
* autocommit ON.
*
* @param sqlStmts The SQL statements to be executed.
* @param autocommitMode The autocommit mode of the statement.
* @param autocommitMode The autocommit mode of the statements.
*/
void executeNonQueries(const std::string &sqlStmts);
void executeNonQueries(const std::string &sqlStmts, const AutocommitMode autocommitMode);
/**
* Convenience method that wraps Conn::createStmt() followed by
* Stmt::executeNonQuery().
*
* @param sql The SQL statement.
* @param autocommitMode The autocommit mode of the statement.
* @param autocommitMode The autocommit mode of the statements.
*/
void executeNonQuery(const std::string &sql, const AutocommitMode autocommitMode);
......
......@@ -67,7 +67,7 @@ TEST_F(cta_rdbms_ConnTest, createTableInMemoryDatabase_executeNonQueries) {
ASSERT_TRUE(conn.getTableNames().empty());
conn.executeNonQueries(sql);
conn.executeNonQueries(sql, AutocommitMode::AUTOCOMMIT_ON);
ASSERT_EQ(1, conn.getTableNames().size());
}
......@@ -121,7 +121,7 @@ TEST_F(cta_rdbms_ConnTest, createSameTableInTwoSeparateInMemoryDatabases_execute
ASSERT_TRUE(conn.getTableNames().empty());
conn.executeNonQueries(sql);
conn.executeNonQueries(sql, AutocommitMode::AUTOCOMMIT_ON);
ASSERT_EQ(1, conn.getTableNames().size());
}
......@@ -135,7 +135,7 @@ TEST_F(cta_rdbms_ConnTest, createSameTableInTwoSeparateInMemoryDatabases_execute
ASSERT_TRUE(conn.getTableNames().empty());
conn.executeNonQueries(sql);
conn.executeNonQueries(sql, AutocommitMode::AUTOCOMMIT_ON);
ASSERT_EQ(1, conn.getTableNames().size());
}
......
......@@ -175,9 +175,9 @@ void Stmt::bindOptionalString(const std::string &paramName, const optional<std::
//-----------------------------------------------------------------------------
// executeQuery
//-----------------------------------------------------------------------------
Rset Stmt::executeQuery() {
Rset Stmt::executeQuery(const AutocommitMode autocommitMode) {
if(nullptr != m_stmt) {
return Rset(m_stmt->executeQuery());
return Rset(m_stmt->executeQuery(autocommitMode));
} else {
throw exception::Exception(std::string(__FUNCTION__) + " failed: Stmt does not contain a cached statement");
}
......@@ -186,9 +186,9 @@ Rset Stmt::executeQuery() {
//-----------------------------------------------------------------------------
// executeNonQuery
//-----------------------------------------------------------------------------
void Stmt::executeNonQuery() {
void Stmt::executeNonQuery(const AutocommitMode autocommitMode) {
if(nullptr != m_stmt) {
return m_stmt->executeNonQuery();
return m_stmt->executeNonQuery(autocommitMode);
} else {
throw exception::Exception(std::string(__FUNCTION__) + " failed: Stmt does not contain a cached statement");
}
......
......@@ -18,6 +18,7 @@
#pragma once
#include "rdbms/AutocommitMode.hpp"
#include "rdbms/Rset.hpp"
#include "common/optional.hpp"
......@@ -161,14 +162,17 @@ public:
/**
* Executes the statement and returns the result set.
*
* @param autocommitMode The autocommit mode of the statement.
* @return The result set.
*/
Rset executeQuery();
Rset executeQuery(const AutocommitMode autocommitMode);
/**
* Executes the statement.
*
* @param autocommitMode The autocommit mode of the statement.
*/
void executeNonQuery();
void executeNonQuery(const AutocommitMode autocommitMode);
/**
* Returns the number of rows affected by the last execution of this
......
......@@ -27,16 +27,14 @@ namespace rdbms {
//------------------------------------------------------------------------------
// getStmt
//------------------------------------------------------------------------------
Stmt StmtPool::getStmt(wrapper::Conn &conn, const std::string &sql, const AutocommitMode autocommitMode) {
const CachedStmtKey key(sql, autocommitMode);
Stmt StmtPool::getStmt(wrapper::Conn &conn, const std::string &sql) {
threading::MutexLocker locker(m_stmtsMutex);
auto itor = m_stmts.find(key);
auto itor = m_stmts.find(sql);
// If there is no prepared statement in the cache
if(itor == m_stmts.end()) {
auto stmt = conn.createStmt(sql, autocommitMode);
auto stmt = conn.createStmt(sql);
return Stmt(std::move(stmt), *this);
} else {
auto &stmtList = itor->second;
......@@ -75,11 +73,9 @@ uint64_t StmtPool::getNbStmts() const {
void StmtPool::returnStmt(std::unique_ptr<wrapper::Stmt> stmt) {
threading::MutexLocker locker(m_stmtsMutex);
const CachedStmtKey key(stmt->getSql(), stmt->getAutocommitMode());
stmt->clear();
m_stmts[key].push_back(std::move(stmt));
m_stmts[stmt->getSql()].push_back(std::move(stmt));
}
//------------------------------------------------------------------------------
......
......@@ -49,10 +49,9 @@ public:
*
* @param conn The database connection to which the database statements
* @param sql The SQL statement.
* @param autocommitMode The autocommit mode of the statement.
* @return The prepared statement.
*/
Stmt getStmt(wrapper::Conn &conn, const std::string &sql, const AutocommitMode autocommitMode);
Stmt getStmt(wrapper::Conn &conn, const std::string &sql);
/**
* Returns the number of cached statements currently in the pool.
......@@ -83,48 +82,13 @@ private:
*/
mutable threading::Mutex m_stmtsMutex;
/**
* Key used to lookup prepares statements within the cache.
*/
struct CachedStmtKey {
/**
* The SQL of the cached statement.
*/
std::string sql;
/**
* The autocommit mode of the cached statement.
*/
const AutocommitMode autocommitMode;
/**
* Constructor.
*
* @param s The SQL of the cached statement.
* @param a The autocommit mode of the cached statement.
*/
CachedStmtKey(const std::string &s, const AutocommitMode a): sql(s), autocommitMode(a) {
}
/**
* Less than operator.
*/
bool operator<(const CachedStmtKey &rhs) const {
if(sql != rhs.sql) {
return sql < rhs.sql;
} else {
return autocommitMode < rhs.autocommitMode;
}
}
};
/**
* The cached database statements.
*
* Please note that for a single key there maybe more than one cached
* statement, hence the map to list of statements.
*/
std::map<CachedStmtKey, std::list< std::unique_ptr<wrapper::Stmt> > > m_stmts;
std::map<std::string, std::list< std::unique_ptr<wrapper::Stmt> > > m_stmts;
}; // class StmtPool
......
......@@ -45,7 +45,7 @@ TEST_F(cta_rdbms_StmtPoolTest, getStmt) {
StmtPool pool;
ASSERT_EQ(0, pool.getNbStmts());
{
auto stmt = pool.getStmt(*conn, sql, AutocommitMode::AUTOCOMMIT_ON);
auto stmt = pool.getStmt(*conn, sql);
ASSERT_EQ(0, pool.getNbStmts());
}
ASSERT_EQ(1, pool.getNbStmts());
......@@ -61,7 +61,7 @@ TEST_F(cta_rdbms_StmtPoolTest, moveAssignment) {
StmtPool pool;
ASSERT_EQ(0, pool.getNbStmts());
{
Stmt stmt1 = pool.getStmt(*conn, sql, AutocommitMode::AUTOCOMMIT_ON);
Stmt stmt1 = pool.getStmt(*conn, sql);
Stmt stmt2;
stmt2 = std::move(stmt1);
ASSERT_EQ(0, pool.getNbStmts());
......@@ -79,7 +79,7 @@ TEST_F(cta_rdbms_StmtPoolTest, moveConstructor) {
StmtPool pool;
ASSERT_EQ(0, pool.getNbStmts());
{
Stmt stmt1 = pool.getStmt(*conn, sql, AutocommitMode::AUTOCOMMIT_ON);
Stmt stmt1 = pool.getStmt(*conn, sql);
Stmt stmt2(std::move(stmt1));
ASSERT_EQ(0, pool.getNbStmts());
}
......@@ -109,8 +109,8 @@ TEST_F(cta_rdbms_StmtPoolTest, createSameTableInTwoSeparateInMemoryDatabases) {
StmtPool pool;
{
Stmt stmt = pool.getStmt(*conn, selectTableNamesSql, AutocommitMode::AUTOCOMMIT_ON);
auto rset = stmt.executeQuery();
Stmt stmt = pool.getStmt(*conn, selectTableNamesSql);
auto rset = stmt.executeQuery(AutocommitMode::AUTOCOMMIT_ON);
std::list<std::string> names;
while(rset.next()) {
names.push_back(rset.columnString("NAME"));
......@@ -119,13 +119,13 @@ TEST_F(cta_rdbms_StmtPoolTest, createSameTableInTwoSeparateInMemoryDatabases) {
}
{
Stmt stmt = pool.getStmt(*conn, createTableSql, AutocommitMode::AUTOCOMMIT_ON);
stmt.executeNonQuery();
Stmt stmt = pool.getStmt(*conn, createTableSql);
stmt.executeNonQuery(AutocommitMode::AUTOCOMMIT_ON);
}
{
Stmt stmt = pool.getStmt(*conn, selectTableNamesSql, AutocommitMode::AUTOCOMMIT_ON);
auto rset = stmt.executeQuery();
Stmt stmt = pool.getStmt(*conn, selectTableNamesSql);
auto rset = stmt.executeQuery(AutocommitMode::AUTOCOMMIT_ON);
std::list<std::string> names;
while(rset.next()) {
names.push_back(rset.columnString("NAME"));
......@@ -143,8 +143,8 @@ TEST_F(cta_rdbms_StmtPoolTest, createSameTableInTwoSeparateInMemoryDatabases) {
StmtPool pool;
{
Stmt stmt = pool.getStmt(*conn, selectTableNamesSql, AutocommitMode::AUTOCOMMIT_ON);
auto rset = stmt.executeQuery();
Stmt stmt = pool.getStmt(*conn, selectTableNamesSql);
auto rset = stmt.executeQuery(AutocommitMode::AUTOCOMMIT_ON);
std::list<std::string> names;
while(rset.next()) {
names.push_back(rset.columnString("NAME"));
......@@ -153,13 +153,13 @@ TEST_F(cta_rdbms_StmtPoolTest, createSameTableInTwoSeparateInMemoryDatabases) {
}
{
Stmt stmt = pool.getStmt(*conn, createTableSql, AutocommitMode::AUTOCOMMIT_ON);
stmt.executeNonQuery();
Stmt stmt = pool.getStmt(*conn, createTableSql);
stmt.executeNonQuery(AutocommitMode::AUTOCOMMIT_ON);
}
{
Stmt stmt = pool.getStmt(*conn, selectTableNamesSql, AutocommitMode::AUTOCOMMIT_ON);
auto rset = stmt.executeQuery();
Stmt stmt = pool.getStmt(*conn, selectTableNamesSql);
auto rset = stmt.executeQuery(AutocommitMode::AUTOCOMMIT_ON);
std::list<std::string> names;
while(rset.next()) {
names.push_back(rset.columnString("NAME"));
......@@ -186,8 +186,8 @@ TEST_F(cta_rdbms_StmtPoolTest, createSameTableInTwoSeparateInMemoryDatabases_get
ASSERT_TRUE(conn->getTableNames().empty());
{
Stmt stmt = pool.getStmt(*conn, createTableSql, AutocommitMode::AUTOCOMMIT_ON);
stmt.executeNonQuery();
Stmt stmt = pool.getStmt(*conn, createTableSql);
stmt.executeNonQuery(AutocommitMode::AUTOCOMMIT_ON);
}
ASSERT_EQ(1, conn->getTableNames().size());
......@@ -204,8 +204,8 @@ TEST_F(cta_rdbms_StmtPoolTest, createSameTableInTwoSeparateInMemoryDatabases_get
ASSERT_TRUE(conn->getTableNames().empty());
{
Stmt stmt = pool.getStmt(*conn, createTableSql, AutocommitMode::AUTOCOMMIT_ON);
stmt.executeNonQuery();
Stmt stmt = pool.getStmt(*conn, createTableSql);
stmt.executeNonQuery(AutocommitMode::AUTOCOMMIT_ON);
}
ASSERT_EQ(1, conn->getTableNames().size());
......@@ -222,8 +222,8 @@ TEST_F(cta_rdbms_StmtPoolTest, sameSqlTwoCachedStmts) {
StmtPool pool;
ASSERT_EQ(0, pool.getNbStmts());
{
Stmt stmt1 = pool.getStmt(*conn, sql, AutocommitMode::AUTOCOMMIT_ON);
Stmt stmt2 = pool.getStmt(*conn, sql, AutocommitMode::AUTOCOMMIT_ON);
Stmt stmt1 = pool.getStmt(*conn, sql);
Stmt stmt2 = pool.getStmt(*conn, sql);
ASSERT_EQ(0, pool.getNbStmts());
}
ASSERT_EQ(2, pool.getNbStmts());
......
......@@ -49,10 +49,9 @@ public:
* Creates a prepared statement.
*
* @param sql The SQL statement.
* @param autocommitMode The autocommit mode of the statement.
* @return The prepared statement.
*/
virtual std::unique_ptr<Stmt> createStmt(const std::string &sql, const AutocommitMode autocommitMode) = 0;
virtual std::unique_ptr<Stmt> createStmt(const std::string &sql) = 0;
/**
* Commits the current transaction.
......
......@@ -48,8 +48,8 @@ TEST_F(cta_rdbms_wrapper_ConnTest, createSameTableInTwoSeparateInMemoryDatabases
ASSERT_TRUE(conn->getTableNames().empty());
auto stmt = conn->createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_ON);
stmt->executeNonQuery();
auto stmt = conn->createStmt(sql);
stmt->executeNonQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON);
ASSERT_EQ(1, conn->getTableNames().size());
}
......@@ -62,8 +62,8 @@ TEST_F(cta_rdbms_wrapper_ConnTest, createSameTableInTwoSeparateInMemoryDatabases
ASSERT_TRUE(conn->getTableNames().empty());
auto stmt = conn->createStmt(sql, rdbms::AutocommitMode::AUTOCOMMIT_ON);
stmt->executeNonQuery();
auto stmt = conn->createStmt(sql);
stmt->executeNonQuery(rdbms::AutocommitMode::AUTOCOMMIT_ON);
ASSERT_EQ(1, conn->getTableNames().size());
}
......
......@@ -68,7 +68,7 @@ void OcciConn::close() {
//------------------------------------------------------------------------------
// createStmt
//------------------------------------------------------------------------------
std::unique_ptr<Stmt> OcciConn::createStmt(const std::string &sql, AutocommitMode autocommitMode) {
std::unique_ptr<Stmt> OcciConn::createStmt(const std::string &sql) {
try {
threading::MutexLocker locker(m_mutex);
......@@ -80,7 +80,7 @@ std::unique_ptr<Stmt> OcciConn::createStmt(const std::string &sql, AutocommitMod
if (nullptr == stmt) {
throw exception::Exception("oracle::occi::createStatement() returned a nullptr pointer");
}
return cta::make_unique<OcciStmt>(autocommitMode, sql, *this, stmt);
return cta::make_unique<OcciStmt>(sql, *this, stmt);
} catch(exception::Exception &ex) {
throw exception::Exception(std::string(__FUNCTION__) + " failed for SQL statement " + sql + ": " +
ex.getMessage().str());
......@@ -140,8 +140,8 @@ std::list<std::string> OcciConn::getTableNames() {
"USER_TABLES "
"ORDER BY "
"TABLE_NAME";
auto stmt = createStmt(sql, AutocommitMode::AUTOCOMMIT_OFF);
auto rset = stmt->executeQuery();
auto stmt = createStmt(sql);
auto rset = stmt->executeQuery(AutocommitMode::AUTOCOMMIT_OFF);
while (rset->next()) {
auto name = rset->columnOptionalString("TABLE_NAME");
if(name) {
......@@ -168,8 +168,8 @@ std::list<std::string> OcciConn::getSequenceNames() {
"USER_SEQUENCES "
"ORDER BY "
"SEQUENCE_NAME";