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 603 of file DBConnection.cpp.

Constructor & Destructor Documentation

◆ DBConnectionTransactionScopeImpl()

DBConnectionTransactionScopeImpl::DBConnectionTransactionScopeImpl ( DBConnection connection)
inlineexplicit

Definition at line 604 of file DBConnection.cpp.

605 : mConnection{ connection } {}

◆ ~DBConnectionTransactionScopeImpl()

DBConnectionTransactionScopeImpl::~DBConnectionTransactionScopeImpl ( )
overridedefault

Member Function Documentation

◆ TransactionCommit()

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

Implements TransactionScopeImpl.

Definition at line 650 of file DBConnection.cpp.

651{
652 char *errmsg = nullptr;
653
654 int rc = sqlite3_exec(mConnection.DB(),
655 wxT("RELEASE ") + name + wxT(";"),
656 nullptr,
657 nullptr,
658 &errmsg);
659
660 if (errmsg)
661 {
662 ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
663 ADD_EXCEPTION_CONTEXT("sqlite3.context", "TransactionScope::TransactionCommit");
664
666 XO("Failed to release savepoint:\n\n%s").Format(name)
667 );
668 sqlite3_free(errmsg);
669 }
670
671 return rc == SQLITE_OK;
672}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
#define ADD_EXCEPTION_CONTEXT(name, value)
Definition: SentryHelper.h:21
wxString name
Definition: TagsEditor.cpp:166
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(), wxT(), 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 674 of file DBConnection.cpp.

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

References ADD_EXCEPTION_CONTEXT, DBConnection::DB(), mConnection, name, DBConnection::SetDBError(), TransactionCommit(), wxT(), 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 626 of file DBConnection.cpp.

627{
628 char *errmsg = nullptr;
629
630 int rc = sqlite3_exec(mConnection.DB(),
631 wxT("SAVEPOINT ") + name + wxT(";"),
632 nullptr,
633 nullptr,
634 &errmsg);
635
636 if (errmsg)
637 {
638 ADD_EXCEPTION_CONTEXT("sqlite3.rc", std::to_string(rc));
639 ADD_EXCEPTION_CONTEXT("sqlite3.context", "TransactionScope::TransactionStart");
640
642 XO("Failed to create savepoint:\n\n%s").Format(name)
643 );
644 sqlite3_free(errmsg);
645 }
646
647 return rc == SQLITE_OK;
648}

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

Here is the call graph for this function:

Member Data Documentation

◆ mConnection

DBConnection& DBConnectionTransactionScopeImpl::mConnection

Definition at line 611 of file DBConnection.cpp.

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


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