60
58
#define ARCHIVE_VERSION 3
62
class ha_archive: public drizzled::Cursor
60
class ha_archive: public handler
64
drizzled::THR_LOCK_DATA lock; /* MySQL lock */
65
ArchiveShare *share; /* Shared lock info */
62
THR_LOCK_DATA lock; /* MySQL lock */
63
ARCHIVE_SHARE *share; /* Shared lock info */
67
65
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 */
69
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 */
66
my_off_t current_position; /* The position of the row we just read */
67
uchar byte_buffer[IO_SIZE]; /* Initial buffer for our string */
68
String buffer; /* Buffer used for blob storage */
69
ha_rows scan_rows; /* Number of rows left in scan */
72
70
bool delayed_insert; /* If the insert is delayed */
73
71
bool bulk_insert; /* If we are performing a bulk insert */
74
const unsigned char *current_key;
75
uint32_t current_key_len;
76
uint32_t current_k_offset;
77
std::vector <unsigned char> record_buffer;
72
const uchar *current_key;
74
uint current_k_offset;
75
archive_record_buffer *record_buffer;
78
76
bool archive_reader_open;
78
archive_record_buffer *create_record_buffer(unsigned int length);
79
void destroy_record_buffer(archive_record_buffer *r);
81
ha_archive(drizzled::plugin::StorageEngine &engine_arg,
82
drizzled::TableShare &table_arg);
82
ha_archive(handlerton *hton, TABLE_SHARE *table_arg);
86
const char *index_type(uint32_t)
86
const char *table_type() const { return "ARCHIVE"; }
87
const char *index_type(uint inx __attribute__((__unused__)))
88
void get_auto_increment(uint64_t, uint64_t, uint64_t,
89
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);
92
virtual int index_read(unsigned char * buf, const unsigned char * key,
94
drizzled::ha_rkey_function find_flag);
95
int index_next(unsigned char * buf);
96
int doOpen(const drizzled::TableIdentifier &identifier, int mode, uint32_t test_if_locked);
97
int open(const char *name, int mode, uint32_t test_if_locked);
89
const char **bas_ext() const;
90
uint64_t table_flags() const
92
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_CAN_BIT_FIELD |
93
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
94
HA_STATS_RECORDS_IS_EXACT |
96
HA_FILE_BASED | HA_CAN_INSERT_DELAYED | HA_CAN_GEOMETRY);
98
uint32_t index_flags(uint idx __attribute__((__unused__)),
99
uint part __attribute__((__unused__)),
100
bool all_parts __attribute__((__unused__))) const
102
return HA_ONLY_WHOLE_INDEX;
104
virtual void get_auto_increment(uint64_t offset, uint64_t increment,
105
uint64_t nb_desired_values,
106
uint64_t *first_value,
107
uint64_t *nb_reserved_values);
108
uint max_supported_keys() const { return 1; }
109
uint max_supported_key_length() const { return sizeof(uint64_t); }
110
uint max_supported_key_part_length() const { return sizeof(uint64_t); }
111
ha_rows records() { return share->rows_recorded; }
112
int index_init(uint keynr, bool sorted);
113
virtual int index_read(uchar * buf, const uchar * key,
114
uint key_len, enum ha_rkey_function find_flag);
115
virtual int index_read_idx(uchar * buf, uint index, const uchar * key,
116
uint key_len, enum ha_rkey_function find_flag);
117
int index_next(uchar * buf);
118
int open(const char *name, int mode, uint test_if_locked);
99
int doInsertRecord(unsigned char * buf);
100
int real_write_row(unsigned char *buf, azio_stream *writer);
120
int write_row(uchar * buf);
121
int real_write_row(uchar *buf, azio_stream *writer);
101
122
int delete_all_rows();
102
int doStartTableScan(bool scan=1);
103
int rnd_next(unsigned char *buf);
104
int rnd_pos(unsigned char * buf, unsigned char *pos);
105
ArchiveShare *get_share(const char *table_name, int *rc);
123
int rnd_init(bool scan=1);
124
int rnd_next(uchar *buf);
125
int rnd_pos(uchar * buf, uchar *pos);
126
int get_row(azio_stream *file_to_read, uchar *buf);
127
int get_row_version2(azio_stream *file_to_read, uchar *buf);
128
int get_row_version3(azio_stream *file_to_read, uchar *buf);
129
ARCHIVE_SHARE *get_share(const char *table_name, int *rc);
106
130
int free_share();
107
131
int init_archive_writer();
108
132
int init_archive_reader();
109
void position(const unsigned char *record);
133
bool auto_repair() const { return 1; } // For the moment we just do this
134
int read_data_header(azio_stream *file_to_read);
135
void position(const uchar *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);
137
void update_create_info(HA_CREATE_INFO *create_info);
138
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
139
int optimize(THD* thd, HA_CHECK_OPT* check_opt);
140
int repair(THD* thd, HA_CHECK_OPT* check_opt);
141
void start_bulk_insert(ha_rows rows);
120
142
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);
127
uint32_t max_row_length(const unsigned char *buf);
143
enum row_type get_row_type() const
145
return ROW_TYPE_COMPRESSED;
147
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
148
enum thr_lock_type lock_type);
149
bool is_crashed() const;
150
int check(THD* thd, HA_CHECK_OPT* check_opt);
151
bool check_and_repair(THD *thd);
152
uint32 max_row_length(const uchar *buf);
128
153
bool fix_rec_buff(unsigned int length);
129
int unpack_row(azio_stream *file_to_read, unsigned char *record);
130
unsigned int pack_row(unsigned char *record);
154
int unpack_row(azio_stream *file_to_read, uchar *record);
155
unsigned int pack_row(uchar *record);
133
#endif /* PLUGIN_ARCHIVE_HA_ARCHIVE_H */