1 | /* Copyright (C) 2007 Michael Widenius |
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ |
15 | |
16 | /* |
17 | When we have finished the write/update/delete of a row, we have cleanups to |
18 | do. For now it is signalling to Checkpoint that all dirtied pages have |
19 | their rec_lsn set and page LSN set (_ma_unpin_all_pages() has been called), |
20 | and that bitmap pages are correct (_ma_bitmap_release_unused() has been |
21 | called). |
22 | */ |
23 | |
24 | /* Struct for clr_end */ |
25 | |
26 | struct st_msg_to_write_hook_for_clr_end |
27 | { |
28 | LSN previous_undo_lsn; |
29 | enum translog_record_type undone_record_type; |
30 | ha_checksum checksum_delta; |
31 | void *; |
32 | }; |
33 | |
34 | struct st_msg_to_write_hook_for_undo_key |
35 | { |
36 | my_off_t *root; |
37 | my_off_t value; |
38 | uint keynr; |
39 | ulonglong auto_increment; |
40 | }; |
41 | |
42 | |
43 | /* Function definitions for some redo functions */ |
44 | |
45 | my_bool _ma_write_clr(MARIA_HA *info, LSN undo_lsn, |
46 | enum translog_record_type undo_type, |
47 | my_bool store_checksum, ha_checksum checksum, |
48 | LSN *res_lsn, void *); |
49 | int _ma_write_undo_key_insert(MARIA_HA *info, const MARIA_KEY *key, |
50 | my_off_t *root, my_off_t new_root, |
51 | LSN *res_lsn); |
52 | my_bool _ma_write_undo_key_delete(MARIA_HA *info, const MARIA_KEY *key, |
53 | my_off_t new_root, LSN *res_lsn); |
54 | my_bool write_hook_for_clr_end(enum translog_record_type type, |
55 | TRN *trn, MARIA_HA *tbl_info, LSN *lsn, |
56 | void *hook_arg); |
57 | extern my_bool write_hook_for_undo_key(enum translog_record_type type, |
58 | TRN *trn, MARIA_HA *tbl_info, |
59 | LSN *lsn, void *hook_arg); |
60 | extern my_bool write_hook_for_undo_key_insert(enum translog_record_type type, |
61 | TRN *trn, MARIA_HA *tbl_info, |
62 | LSN *lsn, void *hook_arg); |
63 | extern my_bool write_hook_for_undo_key_delete(enum translog_record_type type, |
64 | TRN *trn, MARIA_HA *tbl_info, |
65 | LSN *lsn, void *hook_arg); |
66 | |
67 | my_bool _ma_log_prefix(MARIA_PAGE *page, uint changed_length, int move_length, |
68 | enum en_key_debug debug_marker); |
69 | my_bool _ma_log_suffix(MARIA_PAGE *page, uint org_length, |
70 | uint new_length); |
71 | my_bool _ma_log_add(MARIA_PAGE *page, uint buff_length, uchar *key_pos, |
72 | uint changed_length, int move_length, |
73 | my_bool handle_overflow, |
74 | enum en_key_debug debug_marker); |
75 | my_bool _ma_log_delete(MARIA_PAGE *page, const uchar *key_pos, |
76 | uint changed_length, uint move_length, |
77 | uint append_length, enum en_key_debug debug_marker); |
78 | my_bool _ma_log_change(MARIA_PAGE *page, const uchar *key_pos, uint length, |
79 | enum en_key_debug debug_marker); |
80 | my_bool _ma_log_new(MARIA_PAGE *page, my_bool root_page); |
81 | #ifdef EXTRA_DEBUG_KEY_CHANGES |
82 | void _ma_log_key_changes(MARIA_PAGE *ma_page, LEX_CUSTRING *log_array, |
83 | uchar *log_pos, uint *changed_length, |
84 | uint *translog_parts); |
85 | #else |
86 | #define _ma_log_key_changes(A,B,C,D,E) |
87 | #endif |
88 | |
89 | uint _ma_apply_redo_index_new_page(MARIA_HA *info, LSN lsn, |
90 | const uchar *, uint length); |
91 | uint _ma_apply_redo_index_free_page(MARIA_HA *info, LSN lsn, |
92 | const uchar *); |
93 | uint _ma_apply_redo_index(MARIA_HA *info, |
94 | LSN lsn, const uchar *, uint length); |
95 | |
96 | my_bool _ma_apply_undo_key_insert(MARIA_HA *info, LSN undo_lsn, |
97 | const uchar *, uint length); |
98 | my_bool _ma_apply_undo_key_delete(MARIA_HA *info, LSN undo_lsn, |
99 | const uchar *, uint length, |
100 | my_bool with_root); |
101 | |
102 | static inline void _ma_finalize_row(MARIA_HA *info) |
103 | { |
104 | info->trn->rec_lsn= LSN_IMPOSSIBLE; |
105 | } |
106 | |
107 | /* unpinning is often the last operation before finalizing */ |
108 | |
109 | static inline void _ma_unpin_all_pages_and_finalize_row(MARIA_HA *info, |
110 | LSN undo_lsn) |
111 | { |
112 | _ma_unpin_all_pages(info, undo_lsn); |
113 | _ma_finalize_row(info); |
114 | } |
115 | |
116 | extern my_bool _ma_lock_key_del(MARIA_HA *info, my_bool insert_at_end); |
117 | extern void _ma_unlock_key_del(MARIA_HA *info); |
118 | static inline void _ma_fast_unlock_key_del(MARIA_HA *info) |
119 | { |
120 | if (info->key_del_used) |
121 | _ma_unlock_key_del(info); |
122 | } |
123 | |