~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/transaction_context.h

Style cleanup around TransactionContext::modified_non_trans_table and dead code removal

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
  TransactionContext() :
33
33
    no_2pc(false),
34
34
    resource_contexts(),
35
 
    modified_non_trans_table(false)
 
35
    modified_non_trans_data(false)
36
36
  {}
37
37
 
38
 
  void reset() { no_2pc= false; modified_non_trans_table= false; resource_contexts.clear();}
 
38
  void reset() { no_2pc= false; modified_non_trans_data= false; resource_contexts.clear();}
39
39
 
40
40
  typedef std::vector<ResourceContext *> ResourceContexts;
41
41
 
54
54
    resource_contexts.push_back(resource);
55
55
  }
56
56
 
 
57
  /**
 
58
   * Marks that this transaction has modified state
 
59
   * of some non-transactional data.
 
60
   */
 
61
  void markModifiedNonTransData()
 
62
  {
 
63
    modified_non_trans_data= true;
 
64
  }
 
65
 
 
66
  /**
 
67
   * Returns true if the transaction has modified
 
68
   * state of some non-transactional data.
 
69
   */
 
70
  bool hasModifiedNonTransData() const
 
71
  {
 
72
    return modified_non_trans_data;
 
73
  }
 
74
 
57
75
  /* true is not all entries in the resource contexts support 2pc */
58
76
  bool no_2pc;
59
77
private:
60
 
  /* storage engines that registered in this transaction */
 
78
  /** Resource that registered in this transaction */
61
79
  ResourceContexts resource_contexts;
62
 
public:
63
 
  /*
64
 
    The purpose of this flag is to keep track of non-transactional
65
 
    tables that were modified in scope of:
66
 
    - transaction, when the variable is a member of
67
 
    Session::transaction.all
68
 
    - top-level statement or sub-statement, when the variable is a
69
 
    member of Session::transaction.stmt
70
 
    This member has the following life cycle:
71
 
    * stmt.modified_non_trans_table is used to keep track of
72
 
    modified non-transactional tables of top-level statements. At
73
 
    the end of the previous statement and at the beginning of the session,
74
 
    it is reset to false.  If such functions
75
 
    as mysql_insert, mysql_update, mysql_delete etc modify a
76
 
    non-transactional table, they set this flag to true.  At the
77
 
    end of the statement, the value of stmt.modified_non_trans_table
78
 
    is merged with all.modified_non_trans_table and gets reset.
79
 
    * all.modified_non_trans_table is reset at the end of transaction
80
 
 
81
 
    * Since we do not have a dedicated context for execution of a
82
 
    sub-statement, to keep track of non-transactional changes in a
83
 
    sub-statement, we re-use stmt.modified_non_trans_table.
84
 
    At entrance into a sub-statement, a copy of the value of
85
 
    stmt.modified_non_trans_table (containing the changes of the
86
 
    outer statement) is saved on stack. Then
87
 
    stmt.modified_non_trans_table is reset to false and the
88
 
    substatement is executed. Then the new value is merged with the
89
 
    saved value.
90
 
  */
91
 
  bool modified_non_trans_table;
 
80
  /** Whether this transaction has changed non-transaction data state */
 
81
  bool modified_non_trans_data;
92
82
};
93
83
 
94
84
} /* namespace drizzled */