1 /* Copyright (C) 2008 Sun AB & 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 02110-1335 USA */
15 
16 #ifndef MA_STATE_INCLUDED
17 #define MA_STATE_INCLUDED
18 C_MODE_START
19 
20 /* Struct to store tables in use by one transaction */
21 
22 typedef struct st_maria_status_info
23 {
24   ha_rows records;                      /* Rows in table */
25   ha_rows del;                          /* Removed rows */
26   my_off_t empty;                       /* lost space in datafile */
27   my_off_t key_empty;                   /* lost space in indexfile */
28   my_off_t key_file_length;
29   my_off_t data_file_length;
30   ha_checksum checksum;
31   uint32 changed:1,                     /* Set if table was changed */
32          no_transid:1;                  /* Set if no transid was set on rows */
33 } MARIA_STATUS_INFO;
34 
35 
36 typedef struct st_used_tables {
37   struct st_used_tables *next;
38   struct st_maria_share *share;
39   MARIA_STATUS_INFO state_current;
40   MARIA_STATUS_INFO state_start;
41   uint use_count;
42 } MARIA_USED_TABLES;
43 
44 
45 /* Struct to store commit state at different times */
46 
47 typedef struct st_state_history {
48   struct st_state_history *next;
49   TrID trid;
50   MARIA_STATUS_INFO state;
51 } MARIA_STATE_HISTORY;
52 
53 
54 /* struct to remember history for closed tables */
55 
56 typedef struct st_state_history_closed {
57   LSN create_rename_lsn;
58   MARIA_STATE_HISTORY *state_history;
59 } MARIA_STATE_HISTORY_CLOSED;
60 
61 
62 my_bool _ma_setup_live_state(MARIA_HA *info);
63 MARIA_STATE_HISTORY *_ma_remove_not_visible_states(MARIA_STATE_HISTORY
64                                                    *org_history,
65                                                    my_bool all,
66                                                    my_bool trman_is_locked);
67 void _ma_reset_state(MARIA_HA *info);
68 my_bool _ma_get_status(void* param, my_bool concurrent_insert);
69 void _ma_update_status(void* param);
70 void _ma_update_status_with_lock(MARIA_HA *info);
71 void _ma_restore_status(void *param);
72 void _ma_copy_status(void* to, void *from);
73 my_bool _ma_reset_update_flag(void *param, my_bool concurrent_insert);
74 my_bool _ma_start_trans(void* param);
75 my_bool _ma_check_status(void *param);
76 void maria_versioning(MARIA_HA *info, my_bool versioning);
77 void _ma_set_share_data_file_length(struct st_maria_share *share,
78                                     ulonglong new_length);
79 void _ma_copy_nontrans_state_information(MARIA_HA *info);
80 my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit,
81                                   my_bool active_transactions);
82 my_bool _ma_row_visible_always(MARIA_HA *info);
83 my_bool _ma_row_visible_non_transactional_table(MARIA_HA *info);
84 my_bool _ma_row_visible_transactional_table(MARIA_HA *info);
85 void _ma_remove_not_visible_states_with_lock(struct st_maria_share *share,
86                                              my_bool all);
87 void _ma_remove_table_from_trnman(MARIA_HA *info);
88 void _ma_reset_history(struct st_maria_share *share);
89 
90 C_MODE_END
91 #endif
92