~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handler.h

  • Committer: Monty Taylor
  • Date: 2009-06-07 12:05:17 UTC
  • mfrom: (1014.5.10 drizzle-test-coverage)
  • mto: This revision was merged to the branch mainline in revision 1056.
  • Revision ID: mordred@inaugust.com-20090607120517-4nv8kd7j3zm265fx
Merged lee from lp:~kalebral/drizzle/drizzle-test-coverage

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include <drizzled/plugin/storage_engine.h>
34
34
#include <drizzled/handler_structs.h>
35
35
#include <drizzled/ha_statistics.h>
 
36
#include <drizzled/atomics.h>
 
37
 
 
38
#include <drizzled/message/table.pb.h>
36
39
 
37
40
/* Bits to show what an alter table will do */
38
41
#include <drizzled/sql_bitmap.h>
42
45
#define HA_MAX_ALTER_FLAGS 40
43
46
typedef std::bitset<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
44
47
 
 
48
extern drizzled::atomic<uint32_t> refresh_version;  /* Increments on each reload */
 
49
 
45
50
 
46
51
typedef bool (*qc_engine_callback)(Session *session, char *table_key,
47
52
                                      uint32_t key_length,
182
187
 
183
188
  /** true <=> we're currently traversing a range in mrr_cur_range. */
184
189
  bool mrr_have_range;
 
190
 
 
191
  bool eq_range;
 
192
  /*
 
193
    true <=> the engine guarantees that returned records are within the range
 
194
    being scanned.
 
195
  */
 
196
  bool in_range_check_pushed_down;
 
197
 
185
198
  /** Current range (the one we're now returning rows from) */
186
199
  KEY_MULTI_RANGE mrr_cur_range;
187
200
 
189
202
  key_range save_end_range, *end_range;
190
203
  KEY_PART_INFO *range_key_part;
191
204
  int key_compare_result_on_equal;
192
 
  bool eq_range;
193
 
  /*
194
 
    true <=> the engine guarantees that returned records are within the range
195
 
    being scanned.
196
 
  */
197
 
  bool in_range_check_pushed_down;
198
205
 
199
206
  uint32_t errkey;                              /* Last dup key */
200
207
  uint32_t key_used_on_scan;
243
250
    pushed_cond(0), pushed_idx_cond(NULL), pushed_idx_cond_keyno(MAX_KEY),
244
251
    next_insert_id(0), insert_id_for_cur_row(0)
245
252
    {}
246
 
  virtual ~handler(void)
247
 
  {
248
 
    assert(locked == false);
249
 
    /* TODO: assert(inited == NONE); */
250
 
  }
 
253
  virtual ~handler(void);
251
254
  virtual handler *clone(MEM_ROOT *mem_root);
252
255
  /** This is called after create to allow us to set up cached variables */
253
256
  void init()
280
283
  int ha_delete_row(const unsigned char * buf);
281
284
  void ha_release_auto_increment();
282
285
 
283
 
  int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
284
286
  /** to be actually called to get 'check()' functionality*/
285
287
  int ha_check(Session *session, HA_CHECK_OPT *check_opt);
286
288
  int ha_repair(Session* session, HA_CHECK_OPT* check_opt);
297
299
  int ha_enable_indexes(uint32_t mode);
298
300
  int ha_discard_or_import_tablespace(bool discard);
299
301
  void ha_prepare_for_alter();
300
 
  int ha_rename_table(const char *from, const char *to);
301
 
  int ha_delete_table(const char *name);
302
302
  void ha_drop_table(const char *name);
303
303
 
304
 
  int ha_create(const char *name, Table *form, HA_CREATE_INFO *info);
305
 
 
306
 
  int ha_create_handler_files(const char *name, const char *old_name,
307
 
                              int action_flag, HA_CREATE_INFO *info);
308
 
 
309
304
  void adjust_next_insert_id_after_explicit_value(uint64_t nr);
310
305
  int update_auto_increment();
311
306
  void print_keydup_error(uint32_t key_nr, const char *msg);
567
562
  virtual bool is_fk_defined_on_table_or_index(uint32_t)
568
563
  { return false; }
569
564
  virtual char* get_foreign_key_create_info(void)
570
 
  { return(NULL);}  /* gets foreign key create string from InnoDB */
571
 
  /** used in ALTER Table; 1 if changing storage engine is allowed */
572
 
  virtual bool can_switch_engines(void) { return 1; }
 
565
  { return NULL;}  /* gets foreign key create string from InnoDB */
 
566
  /** used in ALTER Table; if changing storage engine is allowed.
 
567
      e.g. not be allowed if table has foreign key constraints in engine.
 
568
   */
 
569
  virtual bool can_switch_engines(void) { return true; }
573
570
  /** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
574
571
  virtual int get_foreign_key_list(Session *, List<FOREIGN_KEY_INFO> *)
575
572
  { return 0; }
578
575
  { return; }       /* prepare InnoDB for HANDLER */
579
576
  virtual void free_foreign_key_create_info(char *) {}
580
577
  /** The following can be called without an open handler */
581
 
  virtual const char *table_type() const =0;
582
 
  /**
583
 
    If frm_error() is called then we will use this to find out what file
584
 
    extentions exist for the storage engine. This is also used by the default
585
 
    rename_table and delete_table method in handler.cc.
586
 
 
587
 
    For engines that have two file name extentions (separate meta/index file
588
 
    and data file), the order of elements is relevant. First element of engine
589
 
    file name extentions array should be meta/index file extention. Second
590
 
    element - data file extention. This order is assumed by
591
 
    prepare_for_repair() when REPAIR Table ... USE_FRM is issued.
592
 
  */
593
 
  virtual const char **bas_ext() const =0;
594
578
 
595
579
  virtual uint32_t index_flags(uint32_t idx, uint32_t part, bool all_parts) const =0;
596
580
 
624
608
  virtual bool is_crashed(void) const  { return 0; }
625
609
  virtual bool auto_repair(void) const { return 0; }
626
610
 
627
 
 
628
 
#define CHF_CREATE_FLAG 0
629
 
#define CHF_DELETE_FLAG 1
630
 
#define CHF_RENAME_FLAG 2
631
 
 
632
 
 
633
 
  /**
634
 
    @note lock_count() can return > 1 if the table is MERGE or partitioned.
635
 
  */
636
 
  virtual uint32_t lock_count(void) const { return 1; }
637
611
  /**
638
612
    Is not invoked for non-transactional temporary tables.
639
613
 
735
709
  void **ha_data(Session *) const;
736
710
  Session *ha_session(void) const;
737
711
 
738
 
  /**
739
 
    Default rename_table() and delete_table() rename/delete files with a
740
 
    given name and extensions from bas_ext().
741
 
 
742
 
    These methods can be overridden, but their default implementation
743
 
    provide useful functionality.
744
 
  */
745
 
  virtual int rename_table(const char *from, const char *to);
746
 
  /**
747
 
    Delete a table in the engine. Called for base as well as temporary
748
 
    tables.
749
 
  */
750
 
  virtual int delete_table(const char *name);
751
 
 
752
712
private:
753
713
  /* Private helpers */
754
714
  inline void mark_trx_read_write();
890
850
  { return (my_errno=HA_ERR_WRONG_COMMAND); }
891
851
  virtual void prepare_for_alter(void) { return; }
892
852
  virtual void drop_table(const char *name);
893
 
  virtual int create(const char *, Table *, HA_CREATE_INFO *)=0;
894
 
 
895
 
  virtual int create_handler_files(const char *, const char *, int, HA_CREATE_INFO *)
896
 
  { return false; }
897
853
};
898
854
 
899
855
 
1015
971
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
1016
972
int ha_commit_one_phase(Session *session, bool all);
1017
973
int ha_rollback_trans(Session *session, bool all);
1018
 
int ha_prepare(Session *session);
1019
974
int ha_recover(HASH *commit_list);
1020
975
 
1021
976
/* transactions: these functions never call StorageEngine functions directly */
1031
986
/* these are called by storage engines */
1032
987
void trans_register_ha(Session *session, bool all, StorageEngine *engine);
1033
988
 
1034
 
void table_case_convert(char * name, uint32_t length);
1035
 
const char *table_case_name(HA_CREATE_INFO *info, const char *name);
1036
 
 
1037
 
extern ulong specialflag;
1038
 
extern uint32_t lower_case_table_names;
1039
989
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
1040
990
uint32_t tablename_to_filename(const char *from, char *to, uint32_t to_length);
1041
991
 
1082
1032
                         select_result *result);
1083
1033
int mysql_explain_select(Session *session, Select_Lex *sl, char const *type,
1084
1034
                         select_result *result);
1085
 
bool mysql_union(Session *session, LEX *lex, select_result *result,
1086
 
                 Select_Lex_Unit *unit, uint64_t setup_tables_done_option);
 
1035
 
1087
1036
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
1088
1037
                                                      LEX *lex,
1089
1038
                                                      TableList *table));
1096
1045
                         int64_t table_flags);
1097
1046
bool mysql_create_table(Session *session,const char *db, const char *table_name,
1098
1047
                        HA_CREATE_INFO *create_info,
 
1048
                        drizzled::message::Table *table_proto,
1099
1049
                        Alter_info *alter_info,
1100
1050
                        bool tmp_table, uint32_t select_field_count);
1101
1051
bool mysql_create_table_no_lock(Session *session, const char *db,
1102
1052
                                const char *table_name,
1103
1053
                                HA_CREATE_INFO *create_info,
 
1054
                                drizzled::message::Table *table_proto,
1104
1055
                                Alter_info *alter_info,
1105
 
                                bool tmp_table, uint32_t select_field_count,
1106
 
                                bool lock_open_lock);
 
1056
                                bool tmp_table, uint32_t select_field_count);
1107
1057
 
1108
1058
bool mysql_alter_table(Session *session, char *new_db, char *new_name,
1109
1059
                       HA_CREATE_INFO *create_info,
1145
1095
                  SQL_LIST *order, ha_rows rows, uint64_t options,
1146
1096
                  bool reset_auto_increment);
1147
1097
bool mysql_truncate(Session *session, TableList *table_list, bool dont_send_ok);
1148
 
uint32_t create_table_def_key(Session *session, char *key, TableList *table_list,
1149
 
                              bool tmp_table);
 
1098
uint32_t create_table_def_key(char *key, TableList *table_list);
1150
1099
TableShare *get_table_share(Session *session, TableList *table_list, char *key,
1151
1100
                             uint32_t key_length, uint32_t db_flags, int *error);
1152
 
void release_table_share(TableShare *share, enum release_type type);
 
1101
void release_table_share(TableShare *share);
1153
1102
TableShare *get_cached_table_share(const char *db, const char *table_name);
1154
 
Table *open_ltable(Session *session, TableList *table_list, thr_lock_type update,
1155
 
                   uint32_t lock_flags);
 
1103
Table *open_ltable(Session *session, TableList *table_list, thr_lock_type update);
1156
1104
Table *open_table(Session *session, TableList *table_list, bool *refresh, uint32_t flags);
1157
1105
bool name_lock_locked_table(Session *session, TableList *tables);
1158
1106
bool reopen_name_locked_table(Session* session, TableList* table_list, bool link_in);