mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / innobase / include / row0undo.h
blobf7f71a440b5af34d3f9ce82919bfcc334930d3e3
1 /******************************************************
2 Row undo
4 (c) 1997 Innobase Oy
6 Created 1/8/1997 Heikki Tuuri
7 *******************************************************/
9 #ifndef row0undo_h
10 #define row0undo_h
12 #include "univ.i"
13 #include "mtr0mtr.h"
14 #include "trx0sys.h"
15 #include "btr0types.h"
16 #include "btr0pcur.h"
17 #include "dict0types.h"
18 #include "trx0types.h"
19 #include "que0types.h"
20 #include "row0types.h"
22 /************************************************************************
23 Creates a row undo node to a query graph. */
25 undo_node_t*
26 row_undo_node_create(
27 /*=================*/
28 /* out, own: undo node */
29 trx_t* trx, /* in: transaction */
30 que_thr_t* parent, /* in: parent node, i.e., a thr node */
31 mem_heap_t* heap); /* in: memory heap where created */
32 /***************************************************************
33 Looks for the clustered index record when node has the row reference.
34 The pcur in node is used in the search. If found, stores the row to node,
35 and stores the position of pcur, and detaches it. The pcur must be closed
36 by the caller in any case. */
38 ibool
39 row_undo_search_clust_to_pcur(
40 /*==========================*/
41 /* out: TRUE if found; NOTE the node->pcur
42 must be closed by the caller, regardless of
43 the return value */
44 undo_node_t* node); /* in: row undo node */
45 /***************************************************************
46 Undoes a row operation in a table. This is a high-level function used
47 in SQL execution graphs. */
49 que_thr_t*
50 row_undo_step(
51 /*==========*/
52 /* out: query thread to run next or NULL */
53 que_thr_t* thr); /* in: query thread */
55 /* A single query thread will try to perform the undo for all successive
56 versions of a clustered index record, if the transaction has modified it
57 several times during the execution which is rolled back. It may happen
58 that the task is transferred to another query thread, if the other thread
59 is assigned to handle an undo log record in the chain of different versions
60 of the record, and the other thread happens to get the x-latch to the
61 clustered index record at the right time.
62 If a query thread notices that the clustered index record it is looking
63 for is missing, or the roll ptr field in the record doed not point to the
64 undo log record the thread was assigned to handle, then it gives up the undo
65 task for that undo log record, and fetches the next. This situation can occur
66 just in the case where the transaction modified the same record several times
67 and another thread is currently doing the undo for successive versions of
68 that index record. */
70 /* Undo node structure */
72 struct undo_node_struct{
73 que_common_t common; /* node type: QUE_NODE_UNDO */
74 ulint state; /* node execution state */
75 trx_t* trx; /* trx for which undo is done */
76 dulint roll_ptr;/* roll pointer to undo log record */
77 trx_undo_rec_t* undo_rec;/* undo log record */
78 dulint undo_no;/* undo number of the record */
79 ulint rec_type;/* undo log record type: TRX_UNDO_INSERT_REC,
80 ... */
81 dulint new_trx_id; /* trx id to restore to clustered index
82 record */
83 btr_pcur_t pcur; /* persistent cursor used in searching the
84 clustered index record */
85 dict_table_t* table; /* table where undo is done */
86 ulint cmpl_info;/* compiler analysis of an update */
87 upd_t* update; /* update vector for a clustered index
88 record */
89 dtuple_t* ref; /* row reference to the next row to handle */
90 dtuple_t* row; /* a copy (also fields copied to heap) of the
91 row to handle */
92 dict_index_t* index; /* the next index whose record should be
93 handled */
94 mem_heap_t* heap; /* memory heap used as auxiliary storage for
95 row; this must be emptied after undo is tried
96 on a row */
99 /* Execution states for an undo node */
100 #define UNDO_NODE_FETCH_NEXT 1 /* we should fetch the next undo log
101 record */
102 #define UNDO_NODE_INSERT 2
103 #define UNDO_NODE_MODIFY 3
106 #ifndef UNIV_NONINL
107 #include "row0undo.ic"
108 #endif
110 #endif