50
43
off_t saved_data_file_length;
51
44
pthread_mutex_t mutex;
52
46
bool update_file_opened;
53
47
bool tina_write_opened;
54
int meta_file; /* Meta file we use */
55
int tina_write_filedes; /* File Cursor for readers */
48
File meta_file; /* Meta file we use */
49
File tina_write_filedes; /* File handler for readers */
56
50
bool crashed; /* Meta file is crashed */
57
drizzled::ha_rows rows_recorded; /* Number of rows in tables */
58
uint32_t data_file_version; /* Version of the data file used */
51
ha_rows rows_recorded; /* Number of rows in tables */
52
uint data_file_version; /* Version of the data file used */
61
class ha_tina: public drizzled::Cursor
60
class ha_tina: public handler
63
drizzled::THR_LOCK_DATA lock; /* MySQL lock */
64
TinaShare *share; /* Shared lock info */
62
THR_LOCK_DATA lock; /* MySQL lock */
63
TINA_SHARE *share; /* Shared lock info */
65
64
off_t current_position; /* Current position in the file during a file scan */
66
65
off_t next_position; /* Next position in the file scan */
67
66
off_t local_saved_data_file_length; /* save position for reads */
68
67
off_t temp_file_length;
69
unsigned char byte_buffer[IO_SIZE];
68
uchar byte_buffer[IO_SIZE];
70
69
Transparent_file *file_buff;
71
int data_file; /* File Cursor for readers */
73
drizzled::String buffer;
70
File data_file; /* File handler for readers */
71
File update_temp_file;
75
74
The chain contains "holes" in the file, occured because of
76
deletes/updates. It is used in doEndTableScan() to get rid of them
75
deletes/updates. It is used in rnd_end() to get rid of them
77
76
in the end of the query.
79
std::vector< std::pair<off_t, off_t> > chain;
80
uint32_t local_data_file_version; /* Saved version of the data file used */
78
tina_set chain_buffer[DEFAULT_CHAIN_LENGTH];
83
uint local_data_file_version; /* Saved version of the data file used */
81
84
bool records_is_known;
82
drizzled::memory::Root blobroot;
84
bool get_write_pos(off_t *end_pos,
85
std::vector< std::pair<off_t, off_t> >::iterator &closest_hole);
88
bool get_write_pos(off_t *end_pos, tina_set *closest_hole);
86
89
int open_update_temp_file_if_needed();
87
90
int init_tina_writer();
88
91
int init_data_file();
91
ha_tina(drizzled::plugin::StorageEngine &engine, drizzled::TableShare &table_arg);
94
ha_tina(handlerton *hton, TABLE_SHARE *table_arg);
97
102
const char *table_type(void) const { return "CSV"; }
98
const char *index_type(uint32_t)
103
const char *index_type(uint inx __attribute__((__unused__)))
99
104
{ return "NONE"; }
105
const char **bas_ext() const;
106
uint64_t table_flags() const
108
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_NO_AUTO_INCREMENT |
109
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE);
111
uint32_t index_flags(uint idx __attribute__((__unused__)),
112
uint part __attribute__((__unused__)),
113
bool all_parts __attribute__((__unused__))) const
116
We will never have indexes so this will never be called(AKA we return
121
uint max_record_length() const { return HA_MAX_REC_LENGTH; }
122
uint max_keys() const { return 0; }
123
uint max_key_parts() const { return 0; }
124
uint max_key_length() const { return 0; }
102
126
Called in test_quick_select to determine if indexes should be used.
104
128
virtual double scan_time() { return (double) (stats.records+stats.deleted) / 20.0+10; }
106
129
/* The next method will never be called */
107
130
virtual bool fast_key_read() { return 1;}
109
@TODO return actual upper bound of number of records in the table.
132
TODO: return actual upper bound of number of records in the table.
110
133
(e.g. save number of records seen on full table scan and/or use file size
113
drizzled::ha_rows estimate_rows_upper_bound() { return HA_POS_ERROR; }
136
ha_rows estimate_rows_upper_bound() { return HA_POS_ERROR; }
115
int doOpen(const drizzled::TableIdentifier &identifier, int mode, uint32_t test_if_locked);
116
int open(const char *, int , uint32_t ) { assert(0); return -1; }
138
int open(const char *name, int mode, uint open_options);
118
int doInsertRecord(unsigned char * buf);
119
int doUpdateRecord(const unsigned char * old_data, unsigned char * new_data);
120
int doDeleteRecord(const unsigned char * buf);
121
int doStartTableScan(bool scan=1);
122
int rnd_next(unsigned char *buf);
123
int rnd_pos(unsigned char * buf, unsigned char *pos);
124
int doEndTableScan();
125
TinaShare *get_share(const std::string &table_name);
127
int repair(drizzled::Session* session, drizzled::HA_CHECK_OPT* check_opt);
140
int write_row(uchar * buf);
141
int update_row(const uchar * old_data, uchar * new_data);
142
int delete_row(const uchar * buf);
143
int rnd_init(bool scan=1);
144
int rnd_next(uchar *buf);
145
int rnd_pos(uchar * buf, uchar *pos);
146
bool check_and_repair(THD *thd);
147
int check(THD* thd, HA_CHECK_OPT* check_opt);
148
bool is_crashed() const;
150
int repair(THD* thd, HA_CHECK_OPT* check_opt);
128
151
/* This is required for SQL layer to know that we support autorepair */
129
void position(const unsigned char *record);
152
bool auto_repair() const { return 1; }
153
void position(const uchar *record);
155
int extra(enum ha_extra_function operation);
131
156
int delete_all_rows(void);
132
void get_auto_increment(uint64_t, uint64_t,
157
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
158
bool check_if_incompatible_data(HA_CREATE_INFO *info,
161
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
162
enum thr_lock_type lock_type);
165
These functions used to get/update status of the handler.
166
Needed to enable concurrent inserts.
169
void update_status();
138
171
/* The following methods were added just for TINA */
139
int encode_quote(unsigned char *buf);
140
int find_current_row(unsigned char *buf);
172
int encode_quote(uchar *buf);
173
int find_current_row(uchar *buf);
141
174
int chain_append();
144
#endif /* PLUGIN_CSV_HA_TINA_H */