109
130
=================
110
131
[Warning: this description is work in progress and may be incomplete]
111
132
The table record is stored in a fixed-size buffer:
113
134
record: null_bytes, column1_data, column2_data, ...
115
The offsets of the parts of the buffer are also fixed: every column has
136
The offsets of the parts of the buffer are also fixed: every column has
116
137
an offset to its column{i}_data, and if it is nullable it also has its own
119
140
The record buffer only includes data about columns that are marked in the
120
141
relevant column set (table->read_set and/or table->write_set, depending on
122
143
<not-sure>It could be that it is required that null bits of non-present
123
144
columns are set to 1</not-sure>
125
146
VARIOUS EXCEPTIONS AND SPECIAL CASES
127
f the table has no nullable columns, then null_bytes is still
128
present, its length is one byte <not-sure> which must be set to 0xFF
148
f the table has no nullable columns, then null_bytes is still
149
present, its length is one byte <not-sure> which must be set to 0xFF
129
150
at all times. </not-sure>
131
152
If the table has columns of type BIT, then certain bits from those columns
132
153
may be stored in null_bytes as well. Grep around for Field_bit for
135
For blob columns (see Field_blob), the record buffer stores length of the
136
data, following by memory pointer to the blob data. The pointer is owned
156
For blob columns (see Field_blob), the record buffer stores length of the
157
data, following by memory pointer to the blob data. The pointer is owned
137
158
by the storage engine and is valid until the next operation.
139
160
If a blob column has NULL value, then its length and blob data pointer
276
290
int ha_reset_auto_increment(uint64_t value);
277
291
int ha_optimize(Session* session, HA_CHECK_OPT* check_opt);
278
292
int ha_analyze(Session* session, HA_CHECK_OPT* check_opt);
279
bool ha_check_and_repair(Session *session);
280
294
int ha_disable_indexes(uint32_t mode);
281
295
int ha_enable_indexes(uint32_t mode);
282
296
int ha_discard_or_import_tablespace(bool discard);
283
void ha_prepare_for_alter();
284
int ha_rename_table(const char *from, const char *to);
285
int ha_delete_table(const char *name);
286
297
void ha_drop_table(const char *name);
288
int ha_create(const char *name, Table *form, HA_CREATE_INFO *info);
290
int ha_create_handler_files(const char *name, const char *old_name,
291
int action_flag, HA_CREATE_INFO *info);
293
299
void adjust_next_insert_id_after_explicit_value(uint64_t nr);
294
300
int update_auto_increment();
295
301
void print_keydup_error(uint32_t key_nr, const char *msg);
296
302
virtual void print_error(int error, myf errflag);
297
303
virtual bool get_error_message(int error, String *buf);
298
304
uint32_t get_dup_key(int error);
299
virtual void change_table_ptr(Table *table_arg, TABLE_SHARE *share);
305
virtual void change_table_ptr(Table *table_arg, TableShare *share);
301
307
/* Estimates calculation */
302
308
virtual double scan_time(void)
303
309
{ return uint64_t2double(stats.data_file_length) / IO_SIZE + 2; }
304
virtual double read_time(uint32_t index __attribute__((unused)),
305
uint32_t ranges, ha_rows rows)
310
virtual double read_time(uint32_t, uint32_t ranges, ha_rows rows)
306
311
{ return rows2double(ranges+rows); }
308
313
virtual double index_only_read_time(uint32_t keynr, double records);
310
315
virtual ha_rows multi_range_read_info_const(uint32_t keyno, RANGE_SEQ_IF *seq,
311
void *seq_init_param,
316
void *seq_init_param,
312
317
uint32_t n_ranges, uint32_t *bufsz,
313
318
uint32_t *flags, COST_VECT *cost);
314
319
virtual int multi_range_read_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys,
431
427
row if available. If the key value is null, begin at the first key of the
434
virtual int index_read_idx_map(unsigned char * buf, uint32_t index, const unsigned char * key,
430
virtual int index_read_idx_map(unsigned char * buf, uint32_t index,
431
const unsigned char * key,
435
432
key_part_map keypart_map,
436
433
enum ha_rkey_function find_flag);
437
virtual int index_next(unsigned char * buf __attribute__((unused)))
438
{ return HA_ERR_WRONG_COMMAND; }
439
virtual int index_prev(unsigned char * buf __attribute__((unused)))
440
{ return HA_ERR_WRONG_COMMAND; }
441
virtual int index_first(unsigned char * buf __attribute__((unused)))
442
{ return HA_ERR_WRONG_COMMAND; }
443
virtual int index_last(unsigned char * buf __attribute__((unused)))
444
{ return HA_ERR_WRONG_COMMAND; }
445
virtual int index_next_same(unsigned char *buf __attribute__((unused)),
446
const unsigned char *key __attribute__((unused)),
447
uint32_t keylen __attribute__((unused)));
434
virtual int index_next(unsigned char *)
435
{ return HA_ERR_WRONG_COMMAND; }
436
virtual int index_prev(unsigned char *)
437
{ return HA_ERR_WRONG_COMMAND; }
438
virtual int index_first(unsigned char *)
439
{ return HA_ERR_WRONG_COMMAND; }
440
virtual int index_last(unsigned char *)
441
{ return HA_ERR_WRONG_COMMAND; }
442
virtual int index_next_same(unsigned char *, const unsigned char *, uint32_t);
450
445
The following functions works like index_read, but it find the last
477
471
The following function is only needed for tables that may be temporary
478
472
tables during joins.
480
virtual int restart_rnd_next(unsigned char *buf __attribute__((unused)),
481
unsigned char *pos __attribute__((unused)))
482
{ return HA_ERR_WRONG_COMMAND; }
483
virtual int rnd_same(unsigned char *buf __attribute__((unused)),
484
uint32_t inx __attribute__((unused)))
485
{ return HA_ERR_WRONG_COMMAND; }
486
virtual ha_rows records_in_range(uint32_t inx __attribute__((unused)),
487
key_range *min_key __attribute__((unused)),
488
key_range *max_key __attribute__((unused)))
474
virtual int restart_rnd_next(unsigned char *, unsigned char *)
475
{ return HA_ERR_WRONG_COMMAND; }
476
virtual int rnd_same(unsigned char *, uint32_t)
477
{ return HA_ERR_WRONG_COMMAND; }
478
virtual ha_rows records_in_range(uint32_t, key_range *, key_range *)
489
479
{ return (ha_rows) 10; }
490
480
virtual void position(const unsigned char *record)=0;
491
virtual int info(uint)=0; // see my_base.h for full description
492
virtual uint32_t calculate_key_hash_value(Field **field_array __attribute__((unused)))
481
virtual int info(uint32_t)=0; // see my_base.h for full description
482
virtual uint32_t calculate_key_hash_value(Field **)
493
483
{ assert(0); return 0; }
494
virtual int extra(enum ha_extra_function operation __attribute__((unused)))
484
virtual int extra(enum ha_extra_function)
496
virtual int extra_opt(enum ha_extra_function operation,
497
uint32_t cache_size __attribute__((unused)))
486
virtual int extra_opt(enum ha_extra_function operation, uint32_t)
498
487
{ return extra(operation); }
567
550
@retval true Foreign key defined on table or index
568
551
@retval false No foreign key defined
570
virtual bool is_fk_defined_on_table_or_index(uint32_t index __attribute__((unused)))
572
553
virtual char* get_foreign_key_create_info(void)
573
{ return(NULL);} /* gets foreign key create string from InnoDB */
574
/** used in ALTER Table; 1 if changing storage engine is allowed */
575
virtual bool can_switch_engines(void) { return 1; }
554
{ return NULL;} /* gets foreign key create string from InnoDB */
555
/** used in ALTER Table; if changing storage engine is allowed.
556
e.g. not be allowed if table has foreign key constraints in engine.
558
virtual bool can_switch_engines(void) { return true; }
576
559
/** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
577
virtual int get_foreign_key_list(Session *session __attribute__((unused)),
578
List<FOREIGN_KEY_INFO> *f_key_list __attribute__((unused)))
560
virtual int get_foreign_key_list(Session *, List<FOREIGN_KEY_INFO> *)
580
562
virtual uint32_t referenced_by_foreign_key() { return 0;}
581
virtual void init_table_handle_for_HANDLER()
582
{ return; } /* prepare InnoDB for HANDLER */
583
virtual void free_foreign_key_create_info(char* str __attribute__((unused))) {}
563
virtual void free_foreign_key_create_info(char *) {}
584
564
/** The following can be called without an open handler */
585
virtual const char *table_type() const =0;
587
If frm_error() is called then we will use this to find out what file
588
extentions exist for the storage engine. This is also used by the default
589
rename_table and delete_table method in handler.cc.
591
For engines that have two file name extentions (separate meta/index file
592
and data file), the order of elements is relevant. First element of engine
593
file name extentions array should be meta/index file extention. Second
594
element - data file extention. This order is assumed by
595
prepare_for_repair() when REPAIR Table ... USE_FRM is issued.
597
virtual const char **bas_ext() const =0;
599
virtual int get_default_no_partitions(HA_CREATE_INFO *info __attribute__((unused))) { return 1;}
600
virtual bool get_no_parts(const char *name __attribute__((unused)),
607
566
virtual uint32_t index_flags(uint32_t idx, uint32_t part, bool all_parts) const =0;
609
virtual int add_index(Table *table_arg __attribute__((unused)),
610
KEY *key_info __attribute__((unused)),
611
uint32_t num_of_keys __attribute__((unused)))
612
{ return (HA_ERR_WRONG_COMMAND); }
613
virtual int prepare_drop_index(Table *table_arg __attribute__((unused)),
614
uint32_t *key_num __attribute__((unused)),
615
uint32_t num_of_keys __attribute__((unused)))
616
{ return (HA_ERR_WRONG_COMMAND); }
617
virtual int final_drop_index(Table *table_arg __attribute__((unused)))
568
virtual int add_index(Table *, KEY *, uint32_t)
569
{ return (HA_ERR_WRONG_COMMAND); }
570
virtual int prepare_drop_index(Table *, uint32_t *, uint32_t)
571
{ return (HA_ERR_WRONG_COMMAND); }
572
virtual int final_drop_index(Table *)
618
573
{ return (HA_ERR_WRONG_COMMAND); }
620
575
uint32_t max_record_length() const
621
{ return cmin((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }
576
{ return std::min((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }
622
577
uint32_t max_keys() const
623
{ return cmin((unsigned int)MAX_KEY, max_supported_keys()); }
578
{ return std::min((unsigned int)MAX_KEY, max_supported_keys()); }
624
579
uint32_t max_key_parts() const
625
{ return cmin((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); }
580
{ return std::min((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); }
626
581
uint32_t max_key_length() const
627
{ return cmin((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); }
582
{ return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); }
628
583
uint32_t max_key_part_length(void) const
629
{ return cmin((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); }
584
{ return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); }
631
586
virtual uint32_t max_supported_record_length(void) const
632
587
{ return HA_MAX_REC_LENGTH; }
669
612
THR_LOCK_DATA **to,
670
613
enum thr_lock_type lock_type)=0;
672
/** Type of table for caching query */
673
virtual uint8_t table_cache_type() { return HA_CACHE_TBL_NONTRANSACT; }
677
@brief Register a named table with a call back function to the query cache.
679
@param session The thread handle
680
@param table_key A pointer to the table name in the table cache
681
@param key_length The length of the table name
682
@param[out] engine_callback The pointer to the storage engine call back
684
@param[out] engine_data Storage engine specific data which could be
687
This method offers the storage engine, the possibility to store a reference
688
to a table name which is going to be used with query cache.
689
The method is called each time a statement is written to the cache and can
690
be used to verify if a specific statement is cachable. It also offers
691
the possibility to register a generic (but static) call back function which
692
is called each time a statement is matched against the query cache.
694
@note If engine_data supplied with this function is different from
695
engine_data supplied with the callback function, and the callback returns
696
false, a table invalidation on the current table will occur.
698
@return Upon success the engine_callback will point to the storage engine
699
call back function, if any, and engine_data will point to any storage
700
engine data used in the specific implementation.
702
@retval false The specified table or current statement should not be
707
register_query_cache_table(Session *session __attribute__((unused)),
708
char *table_key __attribute__((unused)),
709
uint32_t key_length __attribute__((unused)),
710
qc_engine_callback *engine_callback,
711
uint64_t *engine_data __attribute__((unused)))
719
616
@retval true Primary key (if there is one) is clustered
720
617
key covering all fields
726
623
return memcmp(ref1, ref2, ref_length);
730
Condition pushdown to storage engines
734
Push condition down to the table handler.
736
@param cond Condition to be pushed. The condition tree must not be
737
modified by the by the caller.
740
The 'remainder' condition that caller must use to filter out records.
741
NULL means the handler will not return rows that do not match the
745
The pushed conditions form a stack (from which one can remove the
746
last pushed condition using cond_pop).
747
The table handler filters out rows using (pushed_cond1 AND pushed_cond2
748
AND ... AND pushed_condN)
749
or less restrictive condition, depending on handler's capabilities.
751
handler->ha_reset() call empties the condition stack.
752
Calls to rnd_init/rnd_end, index_init/index_end etc do not affect the
755
virtual const COND *cond_push(const COND *cond) { return cond; }
758
Pop the top condition from the condition stack of the handler instance.
760
Pops the top if condition stack, if stack is not empty.
762
virtual void cond_pop(void) { return; }
765
*idx_cond_push(uint32_t keyno __attribute__((unused)),
766
Item* idx_cond __attribute__((unused)))
770
Part of old fast alter table, to be depricated
773
check_if_incompatible_data(HA_CREATE_INFO *create_info __attribute__((unused)),
774
uint32_t table_changes __attribute__((unused)))
775
{ return COMPATIBLE_DATA_NO; }
777
/* On-line ALTER Table interface */
780
Check if a storage engine supports a particular alter table on-line
782
@param altered_table A temporary table show what table is to
784
@param create_info Information from the parsing phase about new
786
@param alter_flags Bitmask that shows what will be changed
787
@param table_changes Shows if table layout has changed (for
788
backwards compatibility with
789
check_if_incompatible_data
791
@retval HA_ALTER_ERROR Unexpected error
792
@retval HA_ALTER_SUPPORTED_WAIT_LOCK Supported, but requires DDL lock
793
@retval HA_ALTER_SUPPORTED_NO_LOCK Supported
794
@retval HA_ALTER_NOT_SUPPORTED Not supported
797
The default implementation is implemented to support fast
798
alter table (storage engines that support some changes by
799
just changing the frm file) without any change in the handler
803
check_if_supported_alter(Table *altered_table __attribute__((unused)),
804
HA_CREATE_INFO *create_info,
805
HA_ALTER_FLAGS *alter_flags __attribute__((unused)),
806
uint32_t table_changes)
808
if (this->check_if_incompatible_data(create_info, table_changes)
809
== COMPATIBLE_DATA_NO)
810
return(HA_ALTER_NOT_SUPPORTED);
811
else if ((*alter_flags & HA_ALTER_STORED_VCOL).is_set())
812
return(HA_ALTER_NOT_SUPPORTED);
814
return(HA_ALTER_SUPPORTED_WAIT_LOCK);
817
Tell storage engine to prepare for the on-line alter table (pre-alter)
819
@param session The thread handle
820
@param altered_table A temporary table show what table is to
822
@param alter_info Storage place for data used during phase1
824
@param alter_flags Bitmask that shows what will be changed
827
@retval error error code passed from storage engine
829
virtual int alter_table_phase1(Session *session __attribute__((unused)),
830
Table *altered_table __attribute__((unused)),
831
HA_CREATE_INFO *create_info __attribute__((unused)),
832
HA_ALTER_INFO *alter_info __attribute__((unused)),
833
HA_ALTER_FLAGS *alter_flags __attribute__((unused)))
835
return HA_ERR_UNSUPPORTED;
838
Tell storage engine to perform the on-line alter table (alter)
840
@param session The thread handle
841
@param altered_table A temporary table show what table is to
843
@param alter_info Storage place for data used during phase1
845
@param alter_flags Bitmask that shows what will be changed
848
@retval error error code passed from storage engine
851
If check_if_supported_alter returns HA_ALTER_SUPPORTED_WAIT_LOCK
852
this call is to be wrapped with a DDL lock. This is currently NOT
855
virtual int alter_table_phase2(Session *session __attribute__((unused)),
856
Table *altered_table __attribute__((unused)),
857
HA_CREATE_INFO *create_info __attribute__((unused)),
858
HA_ALTER_INFO *alter_info __attribute__((unused)),
859
HA_ALTER_FLAGS *alter_flags __attribute__((unused)))
861
return HA_ERR_UNSUPPORTED;
864
Tell storage engine that changed frm file is now on disk and table
865
has been re-opened (post-alter)
867
@param session The thread handle
868
@param table The altered table, re-opened
870
virtual int alter_table_phase3(Session *session __attribute__((unused)),
871
Table *table __attribute__((unused)))
873
return HA_ERR_UNSUPPORTED;
877
use_hidden_primary_key() is called in case of an update/delete when
878
(table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined
879
but we don't have a primary key
881
virtual void use_hidden_primary_key();
1006
725
@return non-0 in case of failure, 0 in case of success.
1007
726
When lock_type is F_UNLCK, the return value is ignored.
1009
virtual int external_lock(Session *session __attribute__((unused)),
1010
int lock_type __attribute__((unused)))
728
virtual int external_lock(Session *, int)
1014
732
virtual void release_auto_increment(void) { return; };
1015
733
/** admin commands - called from mysql_admin_table */
1016
virtual int check_for_upgrade(HA_CHECK_OPT *check_opt __attribute__((unused)))
1018
virtual int check(Session* session __attribute__((unused)),
1019
HA_CHECK_OPT* check_opt __attribute__((unused)))
734
virtual int check(Session *, HA_CHECK_OPT *)
1020
735
{ return HA_ADMIN_NOT_IMPLEMENTED; }
1023
In this method check_opt can be modified
1024
to specify CHECK option to use to call check()
1027
virtual int repair(Session* session __attribute__((unused)),
1028
HA_CHECK_OPT* check_opt __attribute__((unused)))
1029
{ return HA_ADMIN_NOT_IMPLEMENTED; }
1030
virtual void start_bulk_insert(ha_rows rows __attribute__((unused)))
737
virtual void start_bulk_insert(ha_rows)
1032
739
virtual int end_bulk_insert(void) { return 0; }
1033
virtual int index_read(unsigned char * buf __attribute__((unused)),
1034
const unsigned char * key __attribute__((unused)),
1035
uint32_t key_len __attribute__((unused)),
1036
enum ha_rkey_function find_flag __attribute__((unused)))
740
virtual int index_read(unsigned char *, const unsigned char *,
741
uint32_t, enum ha_rkey_function)
1037
742
{ return HA_ERR_WRONG_COMMAND; }
1038
virtual int index_read_last(unsigned char * buf __attribute__((unused)),
1039
const unsigned char * key __attribute__((unused)),
1040
uint32_t key_len __attribute__((unused)))
743
virtual int index_read_last(unsigned char *, const unsigned char *, uint32_t)
1041
744
{ return (my_errno= HA_ERR_WRONG_COMMAND); }
1043
746
This method is similar to update_row, however the handler doesn't need
1073
774
is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
1074
775
returned by storage engines that don't support this operation.
1076
virtual int reset_auto_increment(uint64_t value __attribute__((unused)))
1077
{ return HA_ERR_WRONG_COMMAND; }
1078
virtual int optimize(Session* session __attribute__((unused)),
1079
HA_CHECK_OPT* check_opt __attribute__((unused)))
1080
{ return HA_ADMIN_NOT_IMPLEMENTED; }
1081
virtual int analyze(Session* session __attribute__((unused)),
1082
HA_CHECK_OPT* check_opt __attribute__((unused)))
1083
{ return HA_ADMIN_NOT_IMPLEMENTED; }
1084
virtual bool check_and_repair(Session *session __attribute__((unused)))
1086
virtual int disable_indexes(uint32_t mode __attribute__((unused)))
1087
{ return HA_ERR_WRONG_COMMAND; }
1088
virtual int enable_indexes(uint32_t mode __attribute__((unused)))
1089
{ return HA_ERR_WRONG_COMMAND; }
1090
virtual int discard_or_import_tablespace(bool discard __attribute__((unused)))
777
virtual int reset_auto_increment(uint64_t)
778
{ return HA_ERR_WRONG_COMMAND; }
779
virtual int optimize(Session *, HA_CHECK_OPT *)
780
{ return HA_ADMIN_NOT_IMPLEMENTED; }
781
virtual int analyze(Session *, HA_CHECK_OPT *)
782
{ return HA_ADMIN_NOT_IMPLEMENTED; }
784
virtual int disable_indexes(uint32_t)
785
{ return HA_ERR_WRONG_COMMAND; }
786
virtual int enable_indexes(uint32_t)
787
{ return HA_ERR_WRONG_COMMAND; }
788
virtual int discard_or_import_tablespace(bool)
1091
789
{ return (my_errno=HA_ERR_WRONG_COMMAND); }
1092
virtual void prepare_for_alter(void) { return; }
1093
790
virtual void drop_table(const char *name);
1094
virtual int create(const char *name __attribute__((unused)),
1095
Table *form __attribute__((unused)),
1096
HA_CREATE_INFO *info __attribute__((unused)))=0;
1098
virtual int create_handler_files(const char *name __attribute__((unused)),
1099
const char *old_name __attribute__((unused)),
1100
int action_flag __attribute__((unused)),
1101
HA_CREATE_INFO *info __attribute__((unused)))
1108
A Disk-Sweep MRR interface implementation
1110
This implementation makes range (and, in the future, 'ref') scans to read
1111
table rows in disk sweeps.
1113
Currently it is used by MyISAM and InnoDB. Potentially it can be used with
1114
any table handler that has non-clustered indexes and on-disk rows.
1120
typedef void (handler::*range_check_toggle_func_t)(bool on);
1125
handler *h; /* The "owner" handler object. It is used for scanning the index */
1126
Table *table; /* Always equal to h->table */
1129
Secondary handler object. It is used to retrieve full table rows by
1134
/* Buffer to store rowids, or (rowid, range_id) pairs */
1135
unsigned char *rowids_buf;
1136
unsigned char *rowids_buf_cur; /* Current position when reading/writing */
1137
unsigned char *rowids_buf_last; /* When reading: end of used buffer space */
1138
unsigned char *rowids_buf_end; /* End of the buffer */
1140
bool dsmrr_eof; /* true <=> We have reached EOF when reading index tuples */
1142
/* true <=> need range association, buffer holds {rowid, range_id} pairs */
1145
bool use_default_impl; /* true <=> shortcut all calls to default MRR impl */
1147
void init(handler *h_arg, Table *table_arg)
1152
int dsmrr_init(handler *h, KEY *key, RANGE_SEQ_IF *seq_funcs,
1153
void *seq_init_param, uint32_t n_ranges, uint32_t mode,
1154
HANDLER_BUFFER *buf);
1156
int dsmrr_fill_buffer(handler *h);
1157
int dsmrr_next(handler *h, char **range_info);
1159
int dsmrr_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys, uint32_t *bufsz,
1160
uint32_t *flags, COST_VECT *cost);
1162
ha_rows dsmrr_info_const(uint32_t keyno, RANGE_SEQ_IF *seq,
1163
void *seq_init_param, uint32_t n_ranges, uint32_t *bufsz,
1164
uint32_t *flags, COST_VECT *cost);
1166
bool key_uses_partial_cols(uint32_t keyno);
1167
bool choose_mrr_impl(uint32_t keyno, ha_rows rows, uint32_t *flags, uint32_t *bufsz,
1169
bool get_disk_sweep_mrr_cost(uint32_t keynr, ha_rows rows, uint32_t flags,
1170
uint32_t *buffer_size, COST_VECT *cost);
1173
793
extern const char *ha_row_type[];
1174
794
extern const char *tx_isolation_names[];
1175
795
extern const char *binlog_format_names[];
1176
796
extern TYPELIB tx_isolation_typelib;
1177
extern TYPELIB myisam_stats_method_typelib;
1178
797
extern uint32_t total_ha, total_ha_2pc;
1180
799
/* Wrapper functions */
1185
804
int ha_init_errors(void);
1186
805
int ha_init(void);
1187
806
int ha_end(void);
1188
int ha_initialize_handlerton(st_plugin_int *plugin);
1189
int ha_finalize_handlerton(st_plugin_int *plugin);
1191
TYPELIB *ha_known_exts(void);
1192
void ha_close_connection(Session* session);
1193
bool ha_flush_logs(handlerton *db_type);
1194
void ha_drop_database(char* path);
1195
int ha_create_table(Session *session, const char *path,
1196
const char *db, const char *table_name,
1197
HA_CREATE_INFO *create_info,
1198
bool update_create_info);
1199
int ha_delete_table(Session *session, handlerton *db_type, const char *path,
1200
const char *db, const char *alias, bool generate_warning);
1202
808
/* statistics and info */
1203
bool ha_show_status(Session *session, handlerton *db_type, enum ha_stat_type stat);
809
bool ha_show_status(Session *session, drizzled::plugin::StorageEngine *db_type, enum ha_stat_type stat);
1206
int ha_create_table_from_engine(Session* session, const char *db, const char *name);
1207
int ha_discover(Session* session, const char* dbname, const char* name,
1208
unsigned char** frmblob, size_t* frmlen);
1209
811
int ha_find_files(Session *session,const char *db,const char *path,
1210
812
const char *wild, bool dir, List<LEX_STRING>* files);
1211
int ha_table_exists_in_engine(Session* session, const char* db, const char* name);
1214
extern "C" int ha_init_key_cache(const char *name, KEY_CACHE *key_cache);
1215
int ha_resize_key_cache(KEY_CACHE *key_cache);
1216
int ha_change_key_cache_param(KEY_CACHE *key_cache);
1217
int ha_change_key_cache(KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache);
1218
int ha_end_key_cache(KEY_CACHE *key_cache);
1220
/* report to InnoDB that control passes to the client */
1221
int ha_release_temporary_latches(Session *session);
1223
/* transactions: interface to handlerton functions */
1224
int ha_start_consistent_snapshot(Session *session);
1225
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
814
/* transactions: interface to plugin::StorageEngine functions */
1226
815
int ha_commit_one_phase(Session *session, bool all);
1227
816
int ha_rollback_trans(Session *session, bool all);
1228
int ha_prepare(Session *session);
1229
int ha_recover(HASH *commit_list);
1231
/* transactions: these functions never call handlerton functions directly */
818
/* transactions: these functions never call plugin::StorageEngine functions directly */
1232
819
int ha_commit_trans(Session *session, bool all);
1233
820
int ha_autocommit_or_rollback(Session *session, int error);
1234
821
int ha_enable_transaction(Session *session, bool on);
1239
826
int ha_release_savepoint(Session *session, SAVEPOINT *sv);
1241
828
/* these are called by storage engines */
1242
void trans_register_ha(Session *session, bool all, handlerton *ht);
1244
void table_case_convert(char * name, uint32_t length);
1245
const char *table_case_name(HA_CREATE_INFO *info, const char *name);
1247
extern char reg_ext[FN_EXTLEN];
1248
extern uint32_t reg_ext_length;
1249
extern ulong specialflag;
1250
extern uint32_t lower_case_table_names;
829
void trans_register_ha(Session *session, bool all, drizzled::plugin::StorageEngine *engine);
1251
831
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
1252
uint32_t tablename_to_filename(const char *from, char *to, uint32_t to_length);
1255
bool mysql_ha_open(Session *session, TableList *tables, bool reopen);
1256
bool mysql_ha_close(Session *session, TableList *tables);
1257
bool mysql_ha_read(Session *, TableList *,enum enum_ha_read_modes,char *,
1258
List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
1259
void mysql_ha_flush(Session *session);
1260
void mysql_ha_rm_tables(Session *session, TableList *tables, bool is_locked);
1261
void mysql_ha_cleanup(Session *session);
832
bool tablename_to_filename(const char *from, char *to, size_t to_length);
1264
836
Storage engine has to assume the transaction will end up with 2pc if
1268
840
#define trans_need_2pc(session, all) ((total_ha_2pc > 1) && \
1269
841
!((all ? &session->transaction.all : &session->transaction.stmt)->no_2pc))
844
bool mysql_xa_recover(Session *session);
846
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
847
SORT_FIELD *sortorder);
848
int setup_order(Session *session, Item **ref_pointer_array, TableList *tables,
849
List<Item> &fields, List <Item> &all_fields, order_st *order);
850
int setup_group(Session *session, Item **ref_pointer_array, TableList *tables,
851
List<Item> &fields, List<Item> &all_fields, order_st *order,
852
bool *hidden_group_fields);
853
bool fix_inner_refs(Session *session, List<Item> &all_fields, Select_Lex *select,
854
Item **ref_pointer_array);
856
bool handle_select(Session *session, LEX *lex, select_result *result,
857
uint64_t setup_tables_done_option);
858
bool mysql_select(Session *session, Item ***rref_pointer_array,
859
TableList *tables, uint32_t wild_num, List<Item> &list,
860
COND *conds, uint32_t og_num, order_st *order, order_st *group,
861
Item *having, uint64_t select_type,
862
select_result *result, Select_Lex_Unit *unit,
863
Select_Lex *select_lex);
864
void free_underlaid_joins(Session *session, Select_Lex *select);
865
bool mysql_explain_union(Session *session, Select_Lex_Unit *unit,
866
select_result *result);
867
int mysql_explain_select(Session *session, Select_Lex *sl, char const *type,
868
select_result *result);
870
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
873
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
874
bool mysql_derived_filling(Session *session, LEX *lex, TableList *t);
875
void sp_prepare_create_field(Session *session, CreateField *sql_field);
876
int prepare_create_field(CreateField *sql_field,
877
uint32_t *blob_columns,
878
int *timestamps, int *timestamps_with_niladic,
879
int64_t table_flags);
880
bool mysql_create_table(Session *session,const char *db, const char *table_name,
881
HA_CREATE_INFO *create_info,
882
drizzled::message::Table *table_proto,
883
AlterInfo *alter_info,
884
bool tmp_table, uint32_t select_field_count);
885
bool mysql_create_table_no_lock(Session *session, const char *db,
886
const char *table_name,
887
HA_CREATE_INFO *create_info,
888
drizzled::message::Table *table_proto,
889
AlterInfo *alter_info,
890
bool tmp_table, uint32_t select_field_count);
892
bool mysql_recreate_table(Session *session, TableList *table_list);
893
bool mysql_create_like_table(Session *session, TableList *table,
894
TableList *src_table,
895
HA_CREATE_INFO *create_info);
896
bool mysql_rename_table(drizzled::plugin::StorageEngine *base, const char *old_db,
897
const char * old_name, const char *new_db,
898
const char * new_name, uint32_t flags);
899
bool mysql_prepare_update(Session *session, TableList *table_list,
900
Item **conds, uint32_t order_num, order_st *order);
901
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
902
List<Item> &values,COND *conds,
903
uint32_t order_num, order_st *order, ha_rows limit,
904
enum enum_duplicates handle_duplicates, bool ignore);
905
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table,
906
List<Item> &fields, List_item *values,
907
List<Item> &update_fields,
908
List<Item> &update_values, enum_duplicates duplic,
909
COND **where, bool select_insert,
910
bool check_fields, bool abort_on_warning);
911
bool mysql_insert(Session *session,TableList *table,List<Item> &fields,
912
List<List_item> &values, List<Item> &update_fields,
913
List<Item> &update_values, enum_duplicates flag,
915
int check_that_all_fields_are_given_values(Session *session, Table *entry,
916
TableList *table_list);
917
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds);
918
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
919
SQL_LIST *order, ha_rows rows, uint64_t options,
920
bool reset_auto_increment);
921
bool mysql_truncate(Session *session, TableList *table_list, bool dont_send_ok);
922
TableShare *get_table_share(Session *session, TableList *table_list, char *key,
923
uint32_t key_length, uint32_t db_flags, int *error);
924
TableShare *get_cached_table_share(const char *db, const char *table_name);
925
bool reopen_name_locked_table(Session* session, TableList* table_list, bool link_in);
926
Table *table_cache_insert_placeholder(Session *session, const char *key,
927
uint32_t key_length);
928
bool lock_table_name_if_not_cached(Session *session, const char *db,
929
const char *table_name, Table **table);
930
bool reopen_table(Table *table);
931
bool reopen_tables(Session *session,bool get_locks,bool in_refresh);
932
void close_data_files_and_morph_locks(Session *session, const char *db,
933
const char *table_name);
934
void close_handle_and_leave_table_as_lock(Table *table);
935
bool wait_for_tables(Session *session);
936
bool table_is_used(Table *table, bool wait_for_name_lock);
937
Table *drop_locked_tables(Session *session,const char *db, const char *table_name);
938
void abort_locked_tables(Session *session,const char *db, const char *table_name);
939
extern Field *not_found_field;
940
extern Field *view_ref_found;
943
find_field_in_tables(Session *session, Item_ident *item,
944
TableList *first_table, TableList *last_table,
945
Item **ref, find_item_error_report_type report_error,
946
bool register_tree_change);
948
find_field_in_table_ref(Session *session, TableList *table_list,
949
const char *name, uint32_t length,
950
const char *item_name, const char *db_name,
951
const char *table_name, Item **ref,
953
uint32_t *cached_field_index_ptr,
954
bool register_tree_change, TableList **actual_table);
956
find_field_in_table(Session *session, Table *table, const char *name, uint32_t length,
957
bool allow_rowid, uint32_t *cached_field_index_ptr);
959
find_field_in_table_sef(Table *table, const char *name);
1271
962
#endif /* DRIZZLED_HANDLER_H */