~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to storage/falcon/TransactionState.h

  • Committer: Alexander Nozdrin
  • Date: 2009-04-24 10:04:14 UTC
  • mfrom: (2651.1.45 mysql-6.0)
  • Revision ID: alik@sun.com-20090424100414-92m55kfywauveb56
PullĀ fromĀ 6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2009 Sun Microsystems, Inc.
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#if !defined(TRANSACTION_STATE_H)
 
17
#define TRANSACTION_STATE_H
 
18
 
 
19
#include "Engine.h"
 
20
#include "SyncObject.h"
 
21
 
 
22
// Transaction States
 
23
 
 
24
enum State {
 
25
        Active,                                 // 0
 
26
        Limbo,                                  // 1
 
27
        Committed,                              // 2
 
28
        RolledBack,                             // 3
 
29
 
 
30
        // The following are 'relative states'.  See getRelativeState()
 
31
 
 
32
        Us,                                             // 4
 
33
        CommittedVisible,               // 5
 
34
        CommittedInvisible,             // 6
 
35
        WasActive,                              // 7
 
36
        Deadlock,                               // 8
 
37
        
 
38
        // And the remaining are for transactions pending reuse
 
39
        
 
40
        Available,                              // 9
 
41
        Initializing                    // 10
 
42
        };
 
43
 
 
44
 
 
45
// TransactionState stores the main state information for a Transaction.
 
46
// The reason for having this as a separate class instead of having it
 
47
// stored in the Transaction object is that we want to be able to purge
 
48
// transaction objects earlier than when record versions are scavanged. 
 
49
// To be able to do that we let the TransactionState object live as long
 
50
// as there is RecordVersions refering to it while we purge the Transaction 
 
51
// objects earlier. 
 
52
 
 
53
class TransactionState
 
54
{
 
55
public:
 
56
        TransactionState();
 
57
 
 
58
        void            addRef();
 
59
        void            release();
 
60
        void            waitForTransaction();
 
61
        bool            committedBefore(TransId transactionId);
 
62
        
 
63
        inline bool     isActive()
 
64
                {
 
65
                return state == Active || state == Limbo;
 
66
                }
 
67
 
 
68
        inline bool     isCommitted()
 
69
                {
 
70
                return state == Committed;
 
71
                }
 
72
 
 
73
 
 
74
public:
 
75
        TransId                 transactionId;       // used also as startEvent by dep.mgr.
 
76
        TransId                 commitId;            // used as commitEvent by dep.mgr.
 
77
        volatile                INTERLOCK_TYPE state;
 
78
        SyncObject              syncIsActive;
 
79
        bool                    pendingPageWrites;
 
80
        bool                    hasTransactionReference;
 
81
        
 
82
        volatile TransactionState* waitingFor; // Used for deadlock detection
 
83
 
 
84
private:
 
85
        volatile INTERLOCK_TYPE useCount;
 
86
};
 
87
 
 
88
#endif