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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 *extra_msg;
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 *extra_msg);
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 : void _ma_unpin_all_pages(MARIA_HA *info, LSN undo_lsn);
67 :
68 : my_bool _ma_log_prefix(MARIA_PAGE *page, uint changed_length, int move_length);
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 : my_bool _ma_log_delete(MARIA_PAGE *page, const uchar *key_pos,
75 : uint changed_length, uint move_length);
76 : my_bool _ma_log_change(MARIA_PAGE *page, const uchar *key_pos, uint length);
77 : my_bool _ma_log_new(MARIA_PAGE *page, my_bool root_page);
78 :
79 : uint _ma_apply_redo_index_new_page(MARIA_HA *info, LSN lsn,
80 : const uchar *header, uint length);
81 : uint _ma_apply_redo_index_free_page(MARIA_HA *info, LSN lsn,
82 : const uchar *header);
83 : uint _ma_apply_redo_index(MARIA_HA *info,
84 : LSN lsn, const uchar *header, uint length);
85 :
86 : my_bool _ma_apply_undo_key_insert(MARIA_HA *info, LSN undo_lsn,
87 : const uchar *header, uint length);
88 : my_bool _ma_apply_undo_key_delete(MARIA_HA *info, LSN undo_lsn,
89 : const uchar *header, uint length,
90 : my_bool with_root);
91 :
92 : static inline void _ma_finalize_row(MARIA_HA *info)
93 1491 : {
94 1491 : info->trn->rec_lsn= LSN_IMPOSSIBLE;
95 : }
96 :
97 : /* unpinning is often the last operation before finalizing */
98 :
99 : static inline void _ma_unpin_all_pages_and_finalize_row(MARIA_HA *info,
100 : LSN undo_lsn)
101 0 : {
102 0 : _ma_unpin_all_pages(info, undo_lsn);
103 0 : _ma_finalize_row(info);
104 : }
105 :
106 : extern my_bool _ma_lock_key_del(MARIA_HA *info, my_bool insert_at_end);
107 : extern void _ma_unlock_key_del(MARIA_HA *info);
108 : static inline void _ma_fast_unlock_key_del(MARIA_HA *info)
109 0 : {
110 0 : if (info->key_del_used)
111 0 : _ma_unlock_key_del(info);
112 : }
|