~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handler.h

  • Committer: Brian Aker
  • Date: 2008-08-16 22:34:15 UTC
  • mto: This revision was merged to the branch mainline in revision 346.
  • Revision ID: brian@tangent.org-20080816223415-n24esdpfcqi4pwpy
Refactor around classes. TABLE_LIST has been factored out of table.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
  set.
214
214
  This is actually removed even before it was introduced the first time.
215
215
  The new idea is that handlers will handle the lock level already in
216
 
  store_lock for ALTER TABLE partitions.
 
216
  store_lock for ALTER Table partitions.
217
217
 
218
218
  HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
219
219
  care of changing the partitions online and in one phase. Thus all phases
259
259
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
260
260
#define HA_OPEN_TEMPORARY       512
261
261
 
262
 
/* For transactional LOCK TABLE. handler::lock_table() */
 
262
/* For transactional LOCK Table. handler::lock_table() */
263
263
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
264
264
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
265
265
 
465
465
 
466
466
struct handlerton;
467
467
 
468
 
/* The handler for a table type.  Will be included in the TABLE structure */
 
468
/* The handler for a table type.  Will be included in the Table structure */
469
469
 
470
470
class Table;
471
 
typedef Table TABLE;
472
471
typedef struct st_table_share TABLE_SHARE;
473
472
struct st_foreign_key_info;
474
473
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
823
822
  TABLEOP_HOOKS() {}
824
823
  virtual ~TABLEOP_HOOKS() {}
825
824
 
826
 
  inline void prelock(TABLE **tables, uint count)
 
825
  inline void prelock(Table **tables, uint count)
827
826
  {
828
827
    do_prelock(tables, count);
829
828
  }
830
829
 
831
 
  inline int postlock(TABLE **tables, uint count)
 
830
  inline int postlock(Table **tables, uint count)
832
831
  {
833
832
    return do_postlock(tables, count);
834
833
  }
835
834
private:
836
835
  /* Function primitive that is called prior to locking tables */
837
 
  virtual void do_prelock(TABLE **tables __attribute__((unused)),
 
836
  virtual void do_prelock(Table **tables __attribute__((unused)),
838
837
                          uint count __attribute__((unused)))
839
838
  {
840
839
    /* Default is to do nothing */
848
847
 
849
848
     @return Error code or zero.
850
849
   */
851
 
  virtual int do_postlock(TABLE **tables __attribute__((unused)),
 
850
  virtual int do_postlock(Table **tables __attribute__((unused)),
852
851
                          uint count __attribute__((unused)))
853
852
  {
854
853
    return 0;                           /* Default is to do nothing */
980
979
  }
981
980
};
982
981
 
983
 
void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted, 
 
982
void get_sweep_read_cost(Table *table, ha_rows nrows, bool interrupted, 
984
983
                         COST_VECT *cost);
985
984
 
986
985
/*
1062
1061
  {}
1063
1062
};
1064
1063
 
1065
 
uint calculate_key_len(TABLE *, uint, const uchar *, key_part_map);
 
1064
uint calculate_key_len(Table *, uint, const uchar *, key_part_map);
1066
1065
/*
1067
1066
  bitmap with first N+1 bits set
1068
1067
  (keypart_map for a key prefix of [0..N] keyparts)
1222
1221
  }
1223
1222
  /* ha_ methods: pubilc wrappers for private virtual API */
1224
1223
 
1225
 
  int ha_open(TABLE *table, const char *name, int mode, int test_if_locked);
 
1224
  int ha_open(Table *table, const char *name, int mode, int test_if_locked);
1226
1225
  int ha_index_init(uint idx, bool sorted)
1227
1226
  {
1228
1227
    int result;
1300
1299
  int ha_delete_table(const char *name);
1301
1300
  void ha_drop_table(const char *name);
1302
1301
 
1303
 
  int ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info);
 
1302
  int ha_create(const char *name, Table *form, HA_CREATE_INFO *info);
1304
1303
 
1305
1304
  int ha_create_handler_files(const char *name, const char *old_name,
1306
1305
                              int action_flag, HA_CREATE_INFO *info);
1311
1310
  virtual void print_error(int error, myf errflag);
1312
1311
  virtual bool get_error_message(int error, String *buf);
1313
1312
  uint get_dup_key(int error);
1314
 
  virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share)
 
1313
  virtual void change_table_ptr(Table *table_arg, TABLE_SHARE *share)
1315
1314
  {
1316
1315
    table= table_arg;
1317
1316
    table_share= share;
1598
1597
  { return false; }
1599
1598
  virtual char* get_foreign_key_create_info(void)
1600
1599
  { return(NULL);}  /* gets foreign key create string from InnoDB */
1601
 
  /** used in ALTER TABLE; 1 if changing storage engine is allowed */
 
1600
  /** used in ALTER Table; 1 if changing storage engine is allowed */
1602
1601
  virtual bool can_switch_engines(void) { return 1; }
1603
1602
  /** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
1604
1603
  virtual int get_foreign_key_list(THD *thd __attribute__((unused)),
1619
1618
    and data file), the order of elements is relevant. First element of engine
1620
1619
    file name extentions array should be meta/index file extention. Second
1621
1620
    element - data file extention. This order is assumed by
1622
 
    prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.
 
1621
    prepare_for_repair() when REPAIR Table ... USE_FRM is issued.
1623
1622
  */
1624
1623
  virtual const char **bas_ext() const =0;
1625
1624
 
1633
1632
 
1634
1633
  virtual uint32_t index_flags(uint idx, uint part, bool all_parts) const =0;
1635
1634
 
1636
 
  virtual int add_index(TABLE *table_arg __attribute__((unused)),
 
1635
  virtual int add_index(Table *table_arg __attribute__((unused)),
1637
1636
                        KEY *key_info __attribute__((unused)),
1638
1637
                        uint num_of_keys __attribute__((unused)))
1639
1638
  { return (HA_ERR_WRONG_COMMAND); }
1640
 
  virtual int prepare_drop_index(TABLE *table_arg __attribute__((unused)),
 
1639
  virtual int prepare_drop_index(Table *table_arg __attribute__((unused)),
1641
1640
                                 uint *key_num __attribute__((unused)),
1642
1641
                                 uint num_of_keys __attribute__((unused)))
1643
1642
  { return (HA_ERR_WRONG_COMMAND); }
1644
 
  virtual int final_drop_index(TABLE *table_arg __attribute__((unused)))
 
1643
  virtual int final_drop_index(Table *table_arg __attribute__((unused)))
1645
1644
  { return (HA_ERR_WRONG_COMMAND); }
1646
1645
 
1647
1646
  uint max_record_length() const
1801
1800
                              uint table_changes __attribute__((unused)))
1802
1801
 { return COMPATIBLE_DATA_NO; }
1803
1802
 
1804
 
 /* On-line ALTER TABLE interface */
 
1803
 /* On-line ALTER Table interface */
1805
1804
 
1806
1805
 /**
1807
1806
    Check if a storage engine supports a particular alter table on-line
1827
1826
      implementation.
1828
1827
 */
1829
1828
 virtual int
1830
 
   check_if_supported_alter(TABLE *altered_table __attribute__((unused)),
 
1829
   check_if_supported_alter(Table *altered_table __attribute__((unused)),
1831
1830
                            HA_CREATE_INFO *create_info,
1832
1831
                            HA_ALTER_FLAGS *alter_flags __attribute__((unused)),
1833
1832
                            uint table_changes)
1852
1851
   @retval   error  error code passed from storage engine
1853
1852
 */
1854
1853
 virtual int alter_table_phase1(THD *thd __attribute__((unused)),
1855
 
                                TABLE *altered_table __attribute__((unused)),
 
1854
                                Table *altered_table __attribute__((unused)),
1856
1855
                                HA_CREATE_INFO *create_info __attribute__((unused)),
1857
1856
                                HA_ALTER_INFO *alter_info __attribute__((unused)),
1858
1857
                                HA_ALTER_FLAGS *alter_flags  __attribute__((unused)))
1878
1877
      supported.
1879
1878
 */
1880
1879
 virtual int alter_table_phase2(THD *thd  __attribute__((unused)),
1881
 
                                TABLE *altered_table  __attribute__((unused)),
 
1880
                                Table *altered_table  __attribute__((unused)),
1882
1881
                                HA_CREATE_INFO *create_info __attribute__((unused)),
1883
1882
                                HA_ALTER_INFO *alter_info __attribute__((unused)),
1884
1883
                                HA_ALTER_FLAGS *alter_flags __attribute__((unused)))
1893
1892
    @param    table             The altered table, re-opened
1894
1893
 */
1895
1894
 virtual int alter_table_phase3(THD *thd __attribute__((unused)),
1896
 
                                TABLE *table __attribute__((unused)))
 
1895
                                Table *table __attribute__((unused)))
1897
1896
 {
1898
1897
   return HA_ERR_UNSUPPORTED;
1899
1898
 }
2111
2110
  virtual void prepare_for_alter(void) { return; }
2112
2111
  virtual void drop_table(const char *name);
2113
2112
  virtual int create(const char *name __attribute__((unused)),
2114
 
                     TABLE *form __attribute__((unused)),
 
2113
                     Table *form __attribute__((unused)),
2115
2114
                     HA_CREATE_INFO *info __attribute__((unused)))=0;
2116
2115
 
2117
2116
  virtual int create_handler_files(const char *name __attribute__((unused)),
2142
2141
    : h2(NULL) {};
2143
2142
 
2144
2143
  handler *h; /* The "owner" handler object. It is used for scanning the index */
2145
 
  TABLE *table; /* Always equal to h->table */
 
2144
  Table *table; /* Always equal to h->table */
2146
2145
private:
2147
2146
  /*
2148
2147
    Secondary handler object. It is used to retrieve full table rows by
2163
2162
 
2164
2163
  bool use_default_impl; /* true <=> shortcut all calls to default MRR impl */
2165
2164
public:
2166
 
  void init(handler *h_arg, TABLE *table_arg)
 
2165
  void init(handler *h_arg, Table *table_arg)
2167
2166
  {
2168
2167
    h= h_arg; 
2169
2168
    table= table_arg;