60
69
#define ARCHIVE_VERSION 3
62
class ha_archive: public drizzled::Cursor
71
class ha_archive: public handler
64
drizzled::THR_LOCK_DATA lock; /* MySQL lock */
73
THR_LOCK_DATA lock; /* MySQL lock */
65
74
ArchiveShare *share; /* Shared lock info */
67
76
azio_stream archive; /* Archive file we are working with */
68
drizzled::internal::my_off_t current_position; /* The position of the row we just read */
77
my_off_t current_position; /* The position of the row we just read */
69
78
unsigned char byte_buffer[IO_SIZE]; /* Initial buffer for our string */
70
drizzled::String buffer; /* Buffer used for blob storage */
71
drizzled::ha_rows scan_rows; /* Number of rows left in scan */
79
String buffer; /* Buffer used for blob storage */
80
ha_rows scan_rows; /* Number of rows left in scan */
72
81
bool delayed_insert; /* If the insert is delayed */
73
82
bool bulk_insert; /* If we are performing a bulk insert */
74
83
const unsigned char *current_key;
75
84
uint32_t current_key_len;
76
85
uint32_t current_k_offset;
77
std::vector <unsigned char> record_buffer;
86
archive_record_buffer *record_buffer;
78
87
bool archive_reader_open;
89
archive_record_buffer *create_record_buffer(unsigned int length);
90
void destroy_record_buffer(archive_record_buffer *r);
81
ha_archive(drizzled::plugin::StorageEngine &engine_arg,
82
drizzled::Table &table_arg);
93
ha_archive(drizzled::plugin::StorageEngine *engine, TableShare *table_arg);
86
98
const char *index_type(uint32_t)
100
uint64_t table_flags() const
102
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ |
103
HA_STATS_RECORDS_IS_EXACT |
106
uint32_t index_flags(uint32_t, uint32_t, bool) const
108
return HA_ONLY_WHOLE_INDEX;
88
110
void get_auto_increment(uint64_t, uint64_t, uint64_t,
89
111
uint64_t *first_value, uint64_t *nb_reserved_values);
90
drizzled::ha_rows records() { return share->rows_recorded; }
91
int doStartIndexScan(uint32_t keynr, bool sorted);
112
uint32_t max_supported_keys() const { return 1; }
113
uint32_t max_supported_key_length() const { return sizeof(uint64_t); }
114
uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
115
ha_rows records() { return share->rows_recorded; }
116
int index_init(uint32_t keynr, bool sorted);
92
117
virtual int index_read(unsigned char * buf, const unsigned char * key,
94
drizzled::ha_rkey_function find_flag);
118
uint32_t key_len, enum ha_rkey_function find_flag);
119
virtual int index_read_idx(unsigned char * buf, uint32_t index, const unsigned char * key,
120
uint32_t key_len, enum ha_rkey_function find_flag);
95
121
int index_next(unsigned char * buf);
96
int doOpen(const drizzled::identifier::Table &identifier, int mode, uint32_t test_if_locked);
97
122
int open(const char *name, int mode, uint32_t test_if_locked);
99
int doInsertRecord(unsigned char * buf);
124
int write_row(unsigned char * buf);
100
125
int real_write_row(unsigned char *buf, azio_stream *writer);
101
126
int delete_all_rows();
102
int doStartTableScan(bool scan=1);
127
int rnd_init(bool scan=1);
103
128
int rnd_next(unsigned char *buf);
104
129
int rnd_pos(unsigned char * buf, unsigned char *pos);
130
int get_row(azio_stream *file_to_read, unsigned char *buf);
131
int get_row_version2(azio_stream *file_to_read, unsigned char *buf);
132
int get_row_version3(azio_stream *file_to_read, unsigned char *buf);
105
133
ArchiveShare *get_share(const char *table_name, int *rc);
106
134
int free_share();
107
135
int init_archive_writer();
108
136
int init_archive_reader();
137
bool auto_repair() const { return 1; } // For the moment we just do this
138
int read_data_header(azio_stream *file_to_read);
109
139
void position(const unsigned char *record);
112
int get_row(azio_stream *file_to_read, unsigned char *buf);
113
int get_row_version2(azio_stream *file_to_read, unsigned char *buf);
114
int get_row_version3(azio_stream *file_to_read, unsigned char *buf);
115
int read_data_header(azio_stream *file_to_read);
119
void start_bulk_insert(drizzled::ha_rows rows);
141
int optimize(Session* session, HA_CHECK_OPT* check_opt);
142
int repair(Session* session, HA_CHECK_OPT* check_opt);
143
void start_bulk_insert(ha_rows rows);
120
144
int end_bulk_insert();
122
drizzled::THR_LOCK_DATA **store_lock(drizzled::Session *session,
123
drizzled::THR_LOCK_DATA **to,
124
drizzled::thr_lock_type lock_type);
125
int check(drizzled::Session* session);
126
bool check_and_repair(drizzled::Session *session);
145
enum row_type get_row_type() const
147
return ROW_TYPE_COMPRESSED;
149
THR_LOCK_DATA **store_lock(Session *session, THR_LOCK_DATA **to,
150
enum thr_lock_type lock_type);
151
bool is_crashed() const;
152
int check(Session* session, HA_CHECK_OPT* check_opt);
153
bool check_and_repair(Session *session);
127
154
uint32_t max_row_length(const unsigned char *buf);
128
155
bool fix_rec_buff(unsigned int length);
129
156
int unpack_row(azio_stream *file_to_read, unsigned char *record);