~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1997, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/row0undo.h
 
1
/******************************************************
21
2
Row undo
22
3
 
 
4
(c) 1997 Innobase Oy
 
5
 
23
6
Created 1/8/1997 Heikki Tuuri
24
7
*******************************************************/
25
8
 
36
19
#include "que0types.h"
37
20
#include "row0types.h"
38
21
 
39
 
/********************************************************************//**
40
 
Creates a row undo node to a query graph.
41
 
@return own: undo node */
 
22
/************************************************************************
 
23
Creates a row undo node to a query graph. */
42
24
UNIV_INTERN
43
25
undo_node_t*
44
26
row_undo_node_create(
45
27
/*=================*/
46
 
        trx_t*          trx,    /*!< in: transaction */
47
 
        que_thr_t*      parent, /*!< in: parent node, i.e., a thr node */
48
 
        mem_heap_t*     heap);  /*!< in: memory heap where created */
49
 
/***********************************************************//**
 
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
/***************************************************************
50
33
Looks for the clustered index record when node has the row reference.
51
34
The pcur in node is used in the search. If found, stores the row to node,
52
35
and stores the position of pcur, and detaches it. The pcur must be closed
53
 
by the caller in any case.
54
 
@return TRUE if found; NOTE the node->pcur must be closed by the
55
 
caller, regardless of the return value */
 
36
by the caller in any case. */
56
37
UNIV_INTERN
57
38
ibool
58
39
row_undo_search_clust_to_pcur(
59
40
/*==========================*/
60
 
        undo_node_t*    node);  /*!< in: row undo node */
61
 
/***********************************************************//**
 
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
/***************************************************************
62
46
Undoes a row operation in a table. This is a high-level function used
63
 
in SQL execution graphs.
64
 
@return query thread to run next or NULL */
 
47
in SQL execution graphs. */
65
48
UNIV_INTERN
66
49
que_thr_t*
67
50
row_undo_step(
68
51
/*==========*/
69
 
        que_thr_t*      thr);   /*!< in: query thread */
 
52
                                /* out: query thread to run next or NULL */
 
53
        que_thr_t*      thr);   /* in: query thread */
70
54
 
71
55
/* A single query thread will try to perform the undo for all successive
72
56
versions of a clustered index record, if the transaction has modified it
83
67
and another thread is currently doing the undo for successive versions of
84
68
that index record. */
85
69
 
86
 
/** Execution state of an undo node */
87
 
enum undo_exec {
88
 
        UNDO_NODE_FETCH_NEXT = 1,       /*!< we should fetch the next
89
 
                                        undo log record */
90
 
        UNDO_NODE_PREV_VERS,            /*!< the roll ptr to previous
91
 
                                        version of a row is stored in
92
 
                                        node, and undo should be done
93
 
                                        based on it */
94
 
        UNDO_NODE_INSERT,               /*!< undo a fresh insert of a
95
 
                                        row to a table */
96
 
        UNDO_NODE_MODIFY                /*!< undo a modify operation
97
 
                                        (DELETE or UPDATE) on a row
98
 
                                        of a table */
99
 
};
 
70
/* Undo node structure */
100
71
 
101
 
/** Undo node structure */
102
72
struct undo_node_struct{
103
 
        que_common_t    common; /*!< node type: QUE_NODE_UNDO */
104
 
        enum undo_exec  state;  /*!< node execution state */
105
 
        trx_t*          trx;    /*!< trx for which undo is done */
106
 
        roll_ptr_t      roll_ptr;/*!< roll pointer to undo log record */
107
 
        trx_undo_rec_t* undo_rec;/*!< undo log record */
108
 
        undo_no_t       undo_no;/*!< undo number of the record */
109
 
        ulint           rec_type;/*!< undo log record type: TRX_UNDO_INSERT_REC,
 
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,
110
80
                                ... */
111
 
        roll_ptr_t      new_roll_ptr;
112
 
                                /*!< roll ptr to restore to clustered index
113
 
                                record */
114
 
        trx_id_t        new_trx_id; /*!< trx id to restore to clustered index
115
 
                                record */
116
 
        btr_pcur_t      pcur;   /*!< persistent cursor used in searching the
 
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
117
86
                                clustered index record */
118
 
        dict_table_t*   table;  /*!< table where undo is done */
119
 
        ulint           cmpl_info;/*!< compiler analysis of an update */
120
 
        upd_t*          update; /*!< update vector for a clustered index
 
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
121
90
                                record */
122
 
        dtuple_t*       ref;    /*!< row reference to the next row to handle */
123
 
        dtuple_t*       row;    /*!< a copy (also fields copied to heap) of the
 
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
124
93
                                row to handle */
125
 
        row_ext_t*      ext;    /*!< NULL, or prefixes of the externally
 
94
        row_ext_t*      ext;    /* NULL, or prefixes of the externally
126
95
                                stored columns of the row */
127
 
        dtuple_t*       undo_row;/*!< NULL, or the row after undo */
128
 
        row_ext_t*      undo_ext;/*!< NULL, or prefixes of the externally
 
96
        dtuple_t*       undo_row;/* NULL, or the row after undo */
 
97
        row_ext_t*      undo_ext;/* NULL, or prefixes of the externally
129
98
                                stored columns of undo_row */
130
 
        dict_index_t*   index;  /*!< the next index whose record should be
 
99
        dict_index_t*   index;  /* the next index whose record should be
131
100
                                handled */
132
 
        mem_heap_t*     heap;   /*!< memory heap used as auxiliary storage for
 
101
        mem_heap_t*     heap;   /* memory heap used as auxiliary storage for
133
102
                                row; this must be emptied after undo is tried
134
103
                                on a row */
135
104
};
136
105
 
 
106
/* Execution states for an undo node */
 
107
#define UNDO_NODE_FETCH_NEXT    1       /* we should fetch the next undo log
 
108
                                        record */
 
109
#define UNDO_NODE_PREV_VERS     2       /* the roll ptr to previous version of
 
110
                                        a row is stored in node, and undo
 
111
                                        should be done based on it */
 
112
#define UNDO_NODE_INSERT        3
 
113
#define UNDO_NODE_MODIFY        4
 
114
 
137
115
 
138
116
#ifndef UNIV_NONINL
139
117
#include "row0undo.ic"