1 | /***************************************************************************** |
2 | |
3 | Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. |
4 | Copyright (c) 2017, MariaDB Corporation. |
5 | |
6 | This program is free software; you can redistribute it and/or modify it under |
7 | the terms of the GNU General Public License as published by the Free Software |
8 | Foundation; version 2 of the License. |
9 | |
10 | This program is distributed in the hope that it will be useful, but WITHOUT |
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU General Public License along with |
15 | this program; if not, write to the Free Software Foundation, Inc., |
16 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
17 | |
18 | *****************************************************************************/ |
19 | |
20 | /**************************************************//** |
21 | @file include/row0purge.h |
22 | Purge obsolete records |
23 | |
24 | Created 3/14/1997 Heikki Tuuri |
25 | *******************************************************/ |
26 | |
27 | #ifndef row0purge_h |
28 | #define row0purge_h |
29 | |
30 | #include "univ.i" |
31 | #include "data0data.h" |
32 | #include "btr0types.h" |
33 | #include "btr0pcur.h" |
34 | #include "dict0types.h" |
35 | #include "trx0types.h" |
36 | #include "que0types.h" |
37 | #include "row0types.h" |
38 | #include "ut0vec.h" |
39 | |
40 | /** Create a purge node to a query graph. |
41 | @param[in] parent parent node, i.e., a thr node |
42 | @param[in] heap memory heap where created |
43 | @return own: purge node */ |
44 | purge_node_t* |
45 | row_purge_node_create( |
46 | que_thr_t* parent, |
47 | mem_heap_t* heap) |
48 | MY_ATTRIBUTE((warn_unused_result)); |
49 | |
50 | /***********************************************************//** |
51 | Determines if it is possible to remove a secondary index entry. |
52 | Removal is possible if the secondary index entry does not refer to any |
53 | not delete marked version of a clustered index record where DB_TRX_ID |
54 | is newer than the purge view. |
55 | |
56 | NOTE: This function should only be called by the purge thread, only |
57 | while holding a latch on the leaf page of the secondary index entry |
58 | (or keeping the buffer pool watch on the page). It is possible that |
59 | this function first returns true and then false, if a user transaction |
60 | inserts a record that the secondary index entry would refer to. |
61 | However, in that case, the user transaction would also re-insert the |
62 | secondary index entry after purge has removed it and released the leaf |
63 | page latch. |
64 | @return true if the secondary index record can be purged */ |
65 | bool |
66 | row_purge_poss_sec( |
67 | /*===============*/ |
68 | purge_node_t* node, /*!< in/out: row purge node */ |
69 | dict_index_t* index, /*!< in: secondary index */ |
70 | const dtuple_t* entry) /*!< in: secondary index entry */ |
71 | MY_ATTRIBUTE((nonnull, warn_unused_result)); |
72 | /*************************************************************** |
73 | Does the purge operation for a single undo log record. This is a high-level |
74 | function used in an SQL execution graph. |
75 | @return query thread to run next or NULL */ |
76 | que_thr_t* |
77 | row_purge_step( |
78 | /*===========*/ |
79 | que_thr_t* thr) /*!< in: query thread */ |
80 | MY_ATTRIBUTE((nonnull, warn_unused_result)); |
81 | |
82 | /* Purge node structure */ |
83 | |
84 | struct purge_node_t{ |
85 | que_common_t common; /*!< node type: QUE_NODE_PURGE */ |
86 | /*----------------------*/ |
87 | /* Local storage for this graph node */ |
88 | roll_ptr_t roll_ptr;/* roll pointer to undo log record */ |
89 | ib_vector_t* undo_recs;/*!< Undo recs to purge */ |
90 | |
91 | undo_no_t undo_no;/*!< undo number of the record */ |
92 | |
93 | ulint rec_type;/*!< undo log record type: TRX_UNDO_INSERT_REC, |
94 | ... */ |
95 | dict_table_t* table; /*!< table where purge is done */ |
96 | |
97 | ulint cmpl_info;/* compiler analysis info of an update */ |
98 | |
99 | upd_t* update; /*!< update vector for a clustered index |
100 | record */ |
101 | const dtuple_t* ref; /*!< NULL, or row reference to the next row to |
102 | handle */ |
103 | dtuple_t* row; /*!< NULL, or a copy (also fields copied to |
104 | heap) of the indexed fields of the row to |
105 | handle */ |
106 | dict_index_t* index; /*!< NULL, or the next index whose record should |
107 | be handled */ |
108 | mem_heap_t* heap; /*!< memory heap used as auxiliary storage for |
109 | row; this must be emptied after a successful |
110 | purge of a row */ |
111 | ibool found_clust;/* TRUE if the clustered index record |
112 | determined by ref was found in the clustered |
113 | index, and we were able to position pcur on |
114 | it */ |
115 | btr_pcur_t pcur; /*!< persistent cursor used in searching the |
116 | clustered index record */ |
117 | ibool done; /* Debug flag */ |
118 | trx_id_t trx_id; /*!< trx id for this purging record */ |
119 | |
120 | #ifdef UNIV_DEBUG |
121 | /***********************************************************//** |
122 | Validate the persisent cursor. The purge node has two references |
123 | to the clustered index record - one via the ref member, and the |
124 | other via the persistent cursor. These two references must match |
125 | each other if the found_clust flag is set. |
126 | @return true if the persistent cursor is consistent with |
127 | the ref member.*/ |
128 | bool validate_pcur(); |
129 | #endif |
130 | }; |
131 | |
132 | #endif |
133 | |