Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
DBConnectionTransactionScopeImpl Struct Referencefinal
Inheritance diagram for DBConnectionTransactionScopeImpl:
[legend]
Collaboration diagram for DBConnectionTransactionScopeImpl:
[legend]

Public Member Functions

 DBConnectionTransactionScopeImpl (DBConnection &connection)
 
 ~DBConnectionTransactionScopeImpl () override
 
bool TransactionStart (const wxString &name) override
 
bool TransactionCommit (const wxString &name) override
 
bool TransactionRollback (const wxString &name) override
 
- Public Member Functions inherited from TransactionScopeImpl
virtual ~TransactionScopeImpl ()
 
virtual bool TransactionStart (const wxString &name)=0
 
virtual bool TransactionCommit (const wxString &name)=0
 
virtual bool TransactionRollback (const wxString &name)=0
 

Public Attributes

DBConnectionmConnection
 

Detailed Description

Definition at line 593 of file DBConnection.cpp.

Constructor & Destructor Documentation

◆ DBConnectionTransactionScopeImpl()

DBConnectionTransactionScopeImpl::DBConnectionTransactionScopeImpl ( DBConnection connection)
inlineexplicit

Definition at line 594 of file DBConnection.cpp.

595 : mConnection{ connection } {}

◆ ~DBConnectionTransactionScopeImpl()

DBConnectionTransactionScopeImpl::~DBConnectionTransactionScopeImpl ( )
overridedefault

Member Function Documentation

◆ TransactionCommit()

bool DBConnectionTransactionScopeImpl::TransactionCommit ( const wxString &  name)
overridevirtual
Returns
success

Implements TransactionScopeImpl.

Definition at line 640 of file DBConnection.cpp.

641{
642 char *errmsg = nullptr;
643
644 int rc = sqlite3_exec(mConnection.DB(),
645 wxT("RELEASE ") + name + wxT(";"),
646 nullptr,
647 nullptr,
648 &errmsg);
649
650 if (errmsg)
651 {
652 ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
653 ADD_EXCEPTION_CONTEXT("sqlite3.context", "TransactionScope::TransactionCommit");
654
656 XO("Failed to release savepoint:\n\n%s").Format(name)
657 );
658 sqlite3_free(errmsg);
659 }
660
661 return rc == SQLITE_OK;
662}
const TranslatableString name
Definition: Distortion.cpp:82
#define XO(s)
Definition: Internat.h:31
#define ADD_EXCEPTION_CONTEXT(name, value)
Definition: SentryHelper.h:21
sqlite3 * DB()
void SetDBError(const TranslatableString &msg, const TranslatableString &libraryError={}, int errorCode=-1)
Set stored errors and write to log; and default libraryError to what database library reports.
Abstract base class used in importing a file.

References ADD_EXCEPTION_CONTEXT, DBConnection::DB(), mConnection, name, DBConnection::SetDBError(), and XO.

Referenced by TransactionRollback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransactionRollback()

bool DBConnectionTransactionScopeImpl::TransactionRollback ( const wxString &  name)
overridevirtual
Returns
success

Implements TransactionScopeImpl.

Definition at line 664 of file DBConnection.cpp.

665{
666 char *errmsg = nullptr;
667
668 int rc = sqlite3_exec(mConnection.DB(),
669 wxT("ROLLBACK TO ") + name + wxT(";"),
670 nullptr,
671 nullptr,
672 &errmsg);
673
674 if (errmsg)
675 {
676 ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
677 ADD_EXCEPTION_CONTEXT("sqlite3.context", "TransactionScope::TransactionRollback");
679 XO("Failed to release savepoint:\n\n%s").Format(name)
680 );
681 sqlite3_free(errmsg);
682 }
683
684 if (rc != SQLITE_OK)
685 return false;
686
687 // Rollback AND REMOVE the transaction
688 // -- must do both; rolling back a savepoint only rewinds it
689 // without removing it, unlike the ROLLBACK command
690
691 return TransactionCommit(name);
692}
bool TransactionCommit(const wxString &name) override

References ADD_EXCEPTION_CONTEXT, DBConnection::DB(), mConnection, name, DBConnection::SetDBError(), TransactionCommit(), and XO.

Here is the call graph for this function:

◆ TransactionStart()

bool DBConnectionTransactionScopeImpl::TransactionStart ( const wxString &  name)
overridevirtual
Returns
success; if false, TransactionScope ctor throws

Implements TransactionScopeImpl.

Definition at line 616 of file DBConnection.cpp.

617{
618 char *errmsg = nullptr;
619
620 int rc = sqlite3_exec(mConnection.DB(),
621 wxT("SAVEPOINT ") + name + wxT(";"),
622 nullptr,
623 nullptr,
624 &errmsg);
625
626 if (errmsg)
627 {
628 ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
629 ADD_EXCEPTION_CONTEXT("sqlite3.context", "TransactionScope::TransactionStart");
630
632 XO("Failed to create savepoint:\n\n%s").Format(name)
633 );
634 sqlite3_free(errmsg);
635 }
636
637 return rc == SQLITE_OK;
638}

References ADD_EXCEPTION_CONTEXT, DBConnection::DB(), mConnection, name, DBConnection::SetDBError(), and XO.

Here is the call graph for this function:

Member Data Documentation

◆ mConnection

DBConnection& DBConnectionTransactionScopeImpl::mConnection

Definition at line 601 of file DBConnection.cpp.

Referenced by TransactionCommit(), TransactionRollback(), and TransactionStart().


The documentation for this struct was generated from the following file: