~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/innobase/include/row0undo.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
Row undo
 
3
 
 
4
(c) 1997 Innobase Oy
 
5
 
 
6
Created 1/8/1997 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#ifndef row0undo_h
 
10
#define row0undo_h
 
11
 
 
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"
 
21
 
 
22
/************************************************************************
 
23
Creates a row undo node to a query graph. */
 
24
 
 
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. */
 
37
 
 
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. */
 
48
 
 
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 */
 
54
 
 
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. */
 
69
 
 
70
/* Undo node structure */
 
71
 
 
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_roll_ptr; /* roll ptr to restore to clustered index
 
82
                                record */
 
83
        dulint          new_trx_id; /* trx id to restore to clustered index
 
84
                                record */
 
85
        btr_pcur_t      pcur;   /* persistent cursor used in searching the
 
86
                                clustered index record */
 
87
        dict_table_t*   table;  /* table where undo is done */
 
88
        ulint           cmpl_info;/* compiler analysis of an update */
 
89
        upd_t*          update; /* update vector for a clustered index
 
90
                                record */
 
91
        dtuple_t*       ref;    /* row reference to the next row to handle */
 
92
        dtuple_t*       row;    /* a copy (also fields copied to heap) of the
 
93
                                row to handle */
 
94
        dict_index_t*   index;  /* the next index whose record should be
 
95
                                handled */
 
96
        mem_heap_t*     heap;   /* memory heap used as auxiliary storage for
 
97
                                row; this must be emptied after undo is tried
 
98
                                on a row */
 
99
};
 
100
 
 
101
/* Execution states for an undo node */
 
102
#define UNDO_NODE_FETCH_NEXT    1       /* we should fetch the next undo log
 
103
                                        record */
 
104
#define UNDO_NODE_PREV_VERS     2       /* the roll ptr to previous version of
 
105
                                        a row is stored in node, and undo
 
106
                                        should be done based on it */
 
107
#define UNDO_NODE_INSERT        3
 
108
#define UNDO_NODE_MODIFY        4
 
109
 
 
110
 
 
111
#ifndef UNIV_NONINL
 
112
#include "row0undo.ic"
 
113
#endif
 
114
 
 
115
#endif