Commit 6ae7fa68 authored by Marko Mäkelä's avatar Marko Mäkelä

Simplify TrxUndoRsegs

Construct directly from trx_rseg_t&.
push_back(), size(): Remove.
parent d4187bdc
...@@ -27,14 +27,8 @@ Created 3/26/1996 Heikki Tuuri ...@@ -27,14 +27,8 @@ Created 3/26/1996 Heikki Tuuri
#ifndef trx0purge_h #ifndef trx0purge_h
#define trx0purge_h #define trx0purge_h
#include "univ.i" #include "trx0rseg.h"
#include "trx0types.h"
#include "mtr0mtr.h"
#include "trx0sys.h"
#include "que0types.h" #include "que0types.h"
#include "page0page.h"
#include "fil0fil.h"
#include "read0types.h"
/** A dummy undo record used as a return value when we have a whole undo log /** A dummy undo record used as a return value when we have a whole undo log
which needs no purge */ which needs no purge */
...@@ -105,14 +99,14 @@ class TrxUndoRsegs { ...@@ -105,14 +99,14 @@ class TrxUndoRsegs {
typedef trx_rsegs_t::iterator iterator; typedef trx_rsegs_t::iterator iterator;
/** Default constructor */ /** Default constructor */
TrxUndoRsegs() : m_trx_no() { } TrxUndoRsegs(trx_id_t trx_no = 0) : m_trx_no(trx_no) {}
explicit TrxUndoRsegs(trx_id_t trx_no) /** Constructor */
: TrxUndoRsegs(trx_rseg_t& rseg)
m_trx_no(trx_no) : m_trx_no(rseg.last_trx_no), m_rsegs(1, &rseg) {}
{ /** Constructor */
// Do nothing TrxUndoRsegs(trx_id_t trx_no, trx_rseg_t& rseg)
} : m_trx_no(trx_no), m_rsegs(1, &rseg) {}
/** Get transaction number /** Get transaction number
@return trx_id_t - get transaction number. */ @return trx_id_t - get transaction number. */
...@@ -121,40 +115,10 @@ class TrxUndoRsegs { ...@@ -121,40 +115,10 @@ class TrxUndoRsegs {
return(m_trx_no); return(m_trx_no);
} }
/** Add rollback segment. bool empty() const { return m_rsegs.empty(); }
@param rseg rollback segment to add. */ void erase(iterator& it) { m_rsegs.erase(it); }
void push_back(trx_rseg_t* rseg) iterator begin() { return(m_rsegs.begin()); }
{ iterator end() { return(m_rsegs.end()); }
m_rsegs.push_back(rseg);
}
/** Erase the element pointed by given iterator.
@param[in] iterator iterator */
void erase(iterator& it)
{
m_rsegs.erase(it);
}
/** Number of registered rsegs.
@return size of rseg list. */
ulint size() const
{
return(m_rsegs.size());
}
/**
@return an iterator to the first element */
iterator begin()
{
return(m_rsegs.begin());
}
/**
@return an iterator to the end */
iterator end()
{
return(m_rsegs.end());
}
/** Append rollback segments from referred instance to current /** Append rollback segments from referred instance to current
instance. */ instance. */
...@@ -176,10 +140,6 @@ class TrxUndoRsegs { ...@@ -176,10 +140,6 @@ class TrxUndoRsegs {
return(lhs.m_trx_no > rhs.m_trx_no); return(lhs.m_trx_no > rhs.m_trx_no);
} }
/** Compiler defined copy-constructor/assignment operator
should be fine given that there is no reference to a memory
object outside scope of class object.*/
private: private:
/** The rollback segments transaction number. */ /** The rollback segments transaction number. */
trx_id_t m_trx_no; trx_id_t m_trx_no;
...@@ -202,7 +162,7 @@ struct TrxUndoRsegsIterator { ...@@ -202,7 +162,7 @@ struct TrxUndoRsegsIterator {
/** Sets the next rseg to purge in purge_sys. /** Sets the next rseg to purge in purge_sys.
@return whether anything is to be purged */ @return whether anything is to be purged */
bool set_next(); inline bool set_next();
private: private:
// Disable copying // Disable copying
......
...@@ -35,7 +35,6 @@ Created 3/26/1996 Heikki Tuuri ...@@ -35,7 +35,6 @@ Created 3/26/1996 Heikki Tuuri
#include "mem0mem.h" #include "mem0mem.h"
#include "mtr0mtr.h" #include "mtr0mtr.h"
#include "ut0byte.h" #include "ut0byte.h"
#include "mem0mem.h"
#include "ut0lst.h" #include "ut0lst.h"
#include "read0types.h" #include "read0types.h"
#include "page0types.h" #include "page0types.h"
......
...@@ -64,7 +64,7 @@ my_bool srv_purge_view_update_only_debug; ...@@ -64,7 +64,7 @@ my_bool srv_purge_view_update_only_debug;
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
/** Sentinel value */ /** Sentinel value */
const TrxUndoRsegs TrxUndoRsegsIterator::NullElement(UINT64_UNDEFINED); const TrxUndoRsegs TrxUndoRsegsIterator::NullElement(TRX_ID_MAX);
/** Constructor */ /** Constructor */
TrxUndoRsegsIterator::TrxUndoRsegsIterator() TrxUndoRsegsIterator::TrxUndoRsegsIterator()
...@@ -110,7 +110,7 @@ TrxUndoRsegsIterator::set_next() ...@@ -110,7 +110,7 @@ TrxUndoRsegsIterator::set_next()
while (!purge_queue.empty()) { while (!purge_queue.empty()) {
if (m_trx_undo_rsegs.get_trx_no() == UINT64_UNDEFINED) { if (m_trx_undo_rsegs.get_trx_no() == TRX_ID_MAX) {
m_trx_undo_rsegs = purge_queue.top(); m_trx_undo_rsegs = purge_queue.top();
} else if (purge_queue.top().get_trx_no() == } else if (purge_queue.top().get_trx_no() ==
m_trx_undo_rsegs.get_trx_no()) { m_trx_undo_rsegs.get_trx_no()) {
...@@ -903,10 +903,7 @@ trx_purge_cleanse_purge_queue( ...@@ -903,10 +903,7 @@ trx_purge_cleanse_purge_queue(
} }
} }
if (it->size()) { if (!it->empty()) {
/* size != 0 suggest that there exist other rsegs that
needs processing so add this element to purge queue.
Note: Other rseg could be non-redo rsegs. */
purge_sys->purge_queue.push(*it); purge_sys->purge_queue.push(*it);
} }
} }
...@@ -1174,9 +1171,6 @@ trx_purge_rseg_get_next_history_log( ...@@ -1174,9 +1171,6 @@ trx_purge_rseg_get_next_history_log(
rseg->last_trx_no = trx_no; rseg->last_trx_no = trx_no;
rseg->needs_purge = purge != 0; rseg->needs_purge = purge != 0;
TrxUndoRsegs elem(rseg->last_trx_no);
elem.push_back(rseg);
/* Purge can also produce events, however these are already ordered /* Purge can also produce events, however these are already ordered
in the rollback segment and any user generated event will be greater in the rollback segment and any user generated event will be greater
than the events that Purge produces. ie. Purge can never produce than the events that Purge produces. ie. Purge can never produce
...@@ -1184,7 +1178,7 @@ trx_purge_rseg_get_next_history_log( ...@@ -1184,7 +1178,7 @@ trx_purge_rseg_get_next_history_log(
mutex_enter(&purge_sys->pq_mutex); mutex_enter(&purge_sys->pq_mutex);
purge_sys->purge_queue.push(elem); purge_sys->purge_queue.push(*rseg);
mutex_exit(&purge_sys->pq_mutex); mutex_exit(&purge_sys->pq_mutex);
......
...@@ -479,15 +479,11 @@ trx_rseg_mem_restore( ...@@ -479,15 +479,11 @@ trx_rseg_mem_restore(
ut_ad(purge <= 1); ut_ad(purge <= 1);
rseg->needs_purge = purge != 0; rseg->needs_purge = purge != 0;
TrxUndoRsegs elem(rseg->last_trx_no);
elem.push_back(rseg);
if (rseg->last_page_no != FIL_NULL) { if (rseg->last_page_no != FIL_NULL) {
/* There is no need to cover this operation by the purge /* There is no need to cover this operation by the purge
mutex because we are still bootstrapping. */ mutex because we are still bootstrapping. */
purge_sys->purge_queue.push(*rseg);
purge_sys->purge_queue.push(elem);
} }
} }
} }
......
...@@ -1224,15 +1224,12 @@ trx_serialise(trx_t* trx) ...@@ -1224,15 +1224,12 @@ trx_serialise(trx_t* trx)
trx_sys.assign_new_trx_no(trx); trx_sys.assign_new_trx_no(trx);
/* If the rollack segment is not empty then the /* If the rollback segment is not empty then the
new trx_t::no can't be less than any trx_t::no new trx_t::no can't be less than any trx_t::no
already in the rollback segment. User threads only already in the rollback segment. User threads only
produce events when a rollback segment is empty. */ produce events when a rollback segment is empty. */
if (rseg->last_page_no == FIL_NULL) { if (rseg->last_page_no == FIL_NULL) {
TrxUndoRsegs elem(trx->no); purge_sys->purge_queue.push(TrxUndoRsegs(trx->no, *rseg));
elem.push_back(rseg);
purge_sys->purge_queue.push(elem);
mutex_exit(&purge_sys->pq_mutex); mutex_exit(&purge_sys->pq_mutex);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment