23
23
#include <drizzled/xid.h>
24
24
#include <drizzled/discrete_interval.h>
25
#include <drizzled/identifier.h>
26
#include <drizzled/definitions.h>
27
#include <drizzled/key_map.h>
25
#include <drizzled/table_identifier.h>
29
27
/* Definitions for parameters to do with Cursor-routines */
143
145
If a blob column has NULL value, then its length and blob data pointer
144
146
must be set to 0.
148
class Cursor :public memory::SqlAlloc
148
Table &table; /* The current open table */
149
plugin::StorageEngine &engine; /* storage engine of this Cursor */
151
TableShare *table_share; /* The table definition */
152
Table *table; /* The current open table */
152
154
ha_rows estimation_rows_to_insert;
155
plugin::StorageEngine *engine; /* storage engine of this Cursor */
155
157
inline plugin::StorageEngine *getEngine() const /* table_type for handler */
159
161
unsigned char *ref; /* Pointer to current row */
160
162
unsigned char *dup_ref; /* Pointer to duplicate row */
162
TableShare *getShare();
164
Table *getTable() const
164
TableShare *getShare() const
169
169
ha_statistics stats;
170
170
/** MultiRangeRead-related members: */
171
171
range_seq_t mrr_iter; /* Interator to traverse the range sequence */
172
172
RANGE_SEQ_IF mrr_funcs; /* Range sequence traversal functions */
173
HANDLER_BUFFER *multi_range_buffer; /* MRR buffer info */
174
174
uint32_t ranges_in_seq; /* Total number of ranges in the traversed sequence */
175
175
/* true <=> source MRR ranges and the output are ordered */
176
176
bool mrr_is_output_sorted;
225
225
Discrete_interval auto_inc_interval_for_cur_row;
227
Cursor(plugin::StorageEngine &engine_arg, Table &share_arg);
227
Cursor(plugin::StorageEngine &engine_arg, TableShare &share_arg);
228
228
virtual ~Cursor(void);
229
229
virtual Cursor *clone(memory::Root *mem_root);
231
231
/* ha_ methods: pubilc wrappers for private virtual API */
233
int ha_open(const TableIdentifier &identifier, int mode, int test_if_locked);
233
int ha_open(Table *table, const char *name, int mode, int test_if_locked);
234
234
int startIndexScan(uint32_t idx, bool sorted);
235
235
int endIndexScan();
236
236
int startTableScan(bool scan);
269
269
void adjust_next_insert_id_after_explicit_value(uint64_t nr);
270
270
int update_auto_increment();
271
virtual void change_table_ptr(Table *table_arg, TableShare *share);
272
273
/* Estimates calculation */
273
274
virtual double scan_time(void)
319
320
virtual ha_rows estimate_rows_upper_bound()
320
321
{ return stats.records+EXTRA_RECORDS; }
324
Get the row type from the storage engine. If this method returns
325
ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used.
327
virtual enum row_type get_row_type() const { return ROW_TYPE_NOT_USED; }
322
329
virtual const char *index_type(uint32_t)
323
330
{ assert(0); return "";}
477
486
@note that one can NOT rely on table->in_use in store_lock(). It may
478
refer to a different thread if called from abortLockForThread().
487
refer to a different thread if called from mysql_lock_abort_for_thread().
480
489
@note If the table is MERGE, store_lock() can return less locks
481
490
than lock_count() claimed. This can happen when the MERGE children
511
520
/* Service methods for use by storage engines. */
512
void ha_statistic_increment(uint64_t system_status_var::*offset) const;
521
void ha_statistic_increment(ulong system_status_var::*offset) const;
513
522
void **ha_data(Session *) const;
523
Session *ha_session(void) const;
516
526
/* Private helpers */
522
532
the corresponding 'ha_*' method above.
525
virtual int open(const char *, int , uint32_t ) { assert(0); return -1; }
526
virtual int doOpen(const TableIdentifier &identifier, int mode, uint32_t test_if_locked);
535
virtual int open(const char *name, int mode, uint32_t test_if_locked)=0;
527
536
virtual int doStartIndexScan(uint32_t idx, bool)
528
537
{ active_index= idx; return 0; }
529
538
virtual int doEndIndexScan() { active_index= MAX_KEY; return 0; }
586
virtual void release_auto_increment(void) { return; }
595
virtual void release_auto_increment(void) { return; };
587
596
/** admin commands - called from mysql_admin_table */
588
597
virtual int check(Session *)
589
598
{ return HA_ADMIN_NOT_IMPLEMENTED; }
639
648
/* basic stuff */
640
649
void ha_init_errors(void);
643
SortField *make_unireg_sortorder(Order *order, uint32_t *length,
644
SortField *sortorder);
651
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
652
SORT_FIELD *sortorder);
645
653
int setup_order(Session *session, Item **ref_pointer_array, TableList *tables,
646
List<Item> &fields, List <Item> &all_fields, Order *order);
654
List<Item> &fields, List <Item> &all_fields, order_st *order);
647
655
int setup_group(Session *session, Item **ref_pointer_array, TableList *tables,
648
List<Item> &fields, List<Item> &all_fields, Order *order,
656
List<Item> &fields, List<Item> &all_fields, order_st *order,
649
657
bool *hidden_group_fields);
650
658
bool fix_inner_refs(Session *session, List<Item> &all_fields, Select_Lex *select,
651
659
Item **ref_pointer_array);
686
694
bool is_if_not_exists,
687
695
bool is_engine_set);
689
bool mysql_rename_table(Session &session,
690
plugin::StorageEngine *base,
697
bool mysql_rename_table(plugin::StorageEngine *base,
691
698
TableIdentifier &old_identifier,
692
699
TableIdentifier &new_identifier);
694
701
bool mysql_prepare_update(Session *session, TableList *table_list,
695
Item **conds, uint32_t order_num, Order *order);
702
Item **conds, uint32_t order_num, order_st *order);
696
703
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
697
704
List<Item> &values,COND *conds,
698
uint32_t order_num, Order *order, ha_rows limit,
705
uint32_t order_num, order_st *order, ha_rows limit,
699
706
enum enum_duplicates handle_duplicates, bool ignore);
700
707
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table,
701
708
List<Item> &fields, List_item *values,
722
729
void close_handle_and_leave_table_as_lock(Table *table);
723
730
bool wait_for_tables(Session *session);
724
731
bool table_is_used(Table *table, bool wait_for_name_lock);
725
Table *drop_locked_tables(Session *session, const drizzled::TableIdentifier &identifier);
726
void abort_locked_tables(Session *session, const drizzled::TableIdentifier &identifier);
732
Table *drop_locked_tables(Session *session,const char *db, const char *table_name);
733
void abort_locked_tables(Session *session,const char *db, const char *table_name);
727
734
extern Field *not_found_field;
728
735
extern Field *view_ref_found;