13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifdef USE_PRAGMA_INTERFACE
17
#pragma interface /* gcc class implementation */
20
17
#include <inttypes.h>
20
#include <mysys/thr_lock.h>
21
#include <mysys/hash.h>
22
#include <drizzled/handler.h>
25
28
Please read ha_archive.cc first. If you are looking for more general
33
36
} archive_record_buffer;
36
typedef struct st_archive_share {
42
ArchiveShare(const char *name);
45
bool prime(uint64_t *auto_increment);
38
48
char data_file_name[FN_REFLEN];
39
uint32_t table_name_length,use_count;
40
50
pthread_mutex_t mutex;
42
52
azio_stream archive_write; /* Archive file we are working with */
43
53
bool archive_write_open;
44
54
bool dirty; /* Flag for if a flush should occur */
45
55
bool crashed; /* Meta file is crashed */
46
ha_rows rows_recorded; /* Number of rows in tables */
47
56
uint64_t mean_rec_length;
48
57
char real_path[FN_REFLEN];
49
58
unsigned int version;
59
ha_rows rows_recorded; /* Number of rows in tables */
50
60
ha_rows version_rows;
54
64
Version for file format.
61
71
class ha_archive: public handler
63
73
THR_LOCK_DATA lock; /* MySQL lock */
64
ARCHIVE_SHARE *share; /* Shared lock info */
74
ArchiveShare *share; /* Shared lock info */
66
76
azio_stream archive; /* Archive file we are working with */
67
77
my_off_t current_position; /* The position of the row we just read */
68
78
unsigned char byte_buffer[IO_SIZE]; /* Initial buffer for our string */
80
90
void destroy_record_buffer(archive_record_buffer *r);
83
ha_archive(handlerton *hton, TABLE_SHARE *table_arg);
93
ha_archive(StorageEngine *engine, TableShare *table_arg);
87
97
const char *table_type() const { return "ARCHIVE"; }
88
const char *index_type(uint32_t inx __attribute__((unused)))
98
const char *index_type(uint32_t)
90
100
const char **bas_ext() const;
91
101
uint64_t table_flags() const
93
103
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ |
94
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
95
104
HA_STATS_RECORDS_IS_EXACT |
99
uint32_t index_flags(uint32_t idx __attribute__((unused)),
100
uint32_t part __attribute__((unused)),
101
bool all_parts __attribute__((unused))) const
108
uint32_t index_flags(uint32_t, uint32_t, bool) const
103
110
return HA_ONLY_WHOLE_INDEX;
105
virtual void get_auto_increment(uint64_t offset, uint64_t increment,
106
uint64_t nb_desired_values,
107
uint64_t *first_value,
108
uint64_t *nb_reserved_values);
112
void get_auto_increment(uint64_t, uint64_t, uint64_t,
113
uint64_t *first_value, uint64_t *nb_reserved_values);
109
114
uint32_t max_supported_keys() const { return 1; }
110
115
uint32_t max_supported_key_length() const { return sizeof(uint64_t); }
111
116
uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
127
132
int get_row(azio_stream *file_to_read, unsigned char *buf);
128
133
int get_row_version2(azio_stream *file_to_read, unsigned char *buf);
129
134
int get_row_version3(azio_stream *file_to_read, unsigned char *buf);
130
ARCHIVE_SHARE *get_share(const char *table_name, int *rc);
135
ArchiveShare *get_share(const char *table_name, int *rc);
131
136
int free_share();
132
137
int init_archive_writer();
133
138
int init_archive_reader();
138
143
void update_create_info(HA_CREATE_INFO *create_info);
139
144
int create(const char *name, Table *form, HA_CREATE_INFO *create_info);
140
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
141
int repair(THD* thd, HA_CHECK_OPT* check_opt);
145
int optimize(Session* session, HA_CHECK_OPT* check_opt);
146
int repair(Session* session, HA_CHECK_OPT* check_opt);
142
147
void start_bulk_insert(ha_rows rows);
143
148
int end_bulk_insert();
144
enum row_type get_row_type() const
149
enum row_type get_row_type() const
146
151
return ROW_TYPE_COMPRESSED;
148
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
153
THR_LOCK_DATA **store_lock(Session *session, THR_LOCK_DATA **to,
149
154
enum thr_lock_type lock_type);
150
155
bool is_crashed() const;
151
int check(THD* thd, HA_CHECK_OPT* check_opt);
152
bool check_and_repair(THD *thd);
156
int check(Session* session, HA_CHECK_OPT* check_opt);
157
bool check_and_repair(Session *session);
153
158
uint32_t max_row_length(const unsigned char *buf);
154
159
bool fix_rec_buff(unsigned int length);
155
160
int unpack_row(azio_stream *file_to_read, unsigned char *record);