~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handler.cc

  • 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:
776
776
  to maintain atomicity: if CREATE TABLE .. SELECT failed,
777
777
  the newly created table is deleted.
778
778
  In addition, some DDL statements issue interim transaction
779
 
  commits: e.g. ALTER TABLE issues a commit after data is copied
 
779
  commits: e.g. ALTER Table issues a commit after data is copied
780
780
  from the original table to the internal temporary table. Other
781
781
  statements, e.g. CREATE TABLE ... SELECT do not always commit
782
782
  after itself.
783
783
  And finally there is a group of DDL statements such as
784
 
  RENAME/DROP TABLE that doesn't start a new transaction
 
784
  RENAME/DROP Table that doesn't start a new transaction
785
785
  and doesn't commit.
786
786
 
787
787
  This diversity makes it hard to say what will happen if
1692
1692
  handler *file;
1693
1693
  char tmp_path[FN_REFLEN];
1694
1694
  int error;
1695
 
  TABLE dummy_table;
 
1695
  Table dummy_table;
1696
1696
  TABLE_SHARE dummy_share;
1697
1697
 
1698
1698
  memset(&dummy_table, 0, sizeof(dummy_table));
1699
1699
  memset(&dummy_share, 0, sizeof(dummy_share));
1700
1700
  dummy_table.s= &dummy_share;
1701
1701
 
1702
 
  /* DB_TYPE_UNKNOWN is used in ALTER TABLE when renaming only .frm files */
 
1702
  /* DB_TYPE_UNKNOWN is used in ALTER Table when renaming only .frm files */
1703
1703
  if (table_type == NULL ||
1704
1704
      ! (file=get_new_handler((TABLE_SHARE*)0, thd->mem_root, table_type)))
1705
1705
    return(ENOENT);
1757
1757
    return NULL;
1758
1758
  if (new_handler && !new_handler->ha_open(table,
1759
1759
                                           table->s->normalized_path.str,
1760
 
                                           table->db_stat,
 
1760
                                           table->getDBStat(),
1761
1761
                                           HA_OPEN_IGNORE_IF_LOCKED))
1762
1762
    return new_handler;
1763
1763
  return NULL;
1787
1787
  Try O_RDONLY if cannot open as O_RDWR
1788
1788
  Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set
1789
1789
*/
1790
 
int handler::ha_open(TABLE *table_arg, const char *name, int mode,
 
1790
int handler::ha_open(Table *table_arg, const char *name, int mode,
1791
1791
                     int test_if_locked)
1792
1792
{
1793
1793
  int error;
2555
2555
}
2556
2556
 
2557
2557
 
2558
 
static bool update_frm_version(TABLE *table)
 
2558
static bool update_frm_version(Table *table)
2559
2559
{
2560
2560
  char path[FN_REFLEN];
2561
2561
  File file;
2577
2577
    uchar version[4];
2578
2578
    char *key= table->s->table_cache_key.str;
2579
2579
    uint key_length= table->s->table_cache_key.length;
2580
 
    TABLE *entry;
 
2580
    Table *entry;
2581
2581
    HASH_SEARCH_STATE state;
2582
2582
 
2583
2583
    int4store(version, DRIZZLE_VERSION_ID);
2588
2588
      goto err;
2589
2589
    }
2590
2590
 
2591
 
    for (entry=(TABLE*) hash_first(&open_cache,(uchar*) key,key_length, &state);
 
2591
    for (entry=(Table*) hash_first(&open_cache,(uchar*) key,key_length, &state);
2592
2592
         entry;
2593
 
         entry= (TABLE*) hash_next(&open_cache,(uchar*) key,key_length, &state))
 
2593
         entry= (Table*) hash_next(&open_cache,(uchar*) key,key_length, &state))
2594
2594
      entry->s->mysql_version= DRIZZLE_VERSION_ID;
2595
2595
  }
2596
2596
err:
2679
2679
/**
2680
2680
  Performs checks upon the table.
2681
2681
 
2682
 
  @param thd                thread doing CHECK TABLE operation
 
2682
  @param thd                thread doing CHECK Table operation
2683
2683
  @param check_opt          options from the parser
2684
2684
 
2685
2685
  @retval
2687
2687
  @retval
2688
2688
    HA_ADMIN_NEEDS_UPGRADE    Table has structures requiring upgrade
2689
2689
  @retval
2690
 
    HA_ADMIN_NEEDS_ALTER      Table has structures requiring ALTER TABLE
 
2690
    HA_ADMIN_NEEDS_ALTER      Table has structures requiring ALTER Table
2691
2691
  @retval
2692
2692
    HA_ADMIN_NOT_IMPLEMENTED
2693
2693
*/
2968
2968
*/
2969
2969
 
2970
2970
int
2971
 
handler::ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info)
 
2971
handler::ha_create(const char *name, Table *form, HA_CREATE_INFO *info)
2972
2972
{
2973
2973
  mark_trx_read_write();
2974
2974
 
2995
2995
/**
2996
2996
  Tell the storage engine that it is allowed to "disable transaction" in the
2997
2997
  handler. It is a hint that ACID is not required - it is used in NDB for
2998
 
  ALTER TABLE, for example, when data are copied to temporary table.
 
2998
  ALTER Table, for example, when data are copied to temporary table.
2999
2999
  A storage engine may treat this hint any way it likes. NDB for example
3000
3000
  starts to commit every now and then automatically.
3001
3001
  This hint can be safely ignored.
3087
3087
                    bool update_create_info)
3088
3088
{
3089
3089
  int error= 1;
3090
 
  TABLE table;
 
3090
  Table table;
3091
3091
  char name_buff[FN_REFLEN];
3092
3092
  const char *name;
3093
3093
  TABLE_SHARE share;
3135
3135
  size_t frmlen;
3136
3136
  char path[FN_REFLEN];
3137
3137
  HA_CREATE_INFO create_info;
3138
 
  TABLE table;
 
3138
  Table table;
3139
3139
  TABLE_SHARE share;
3140
3140
 
3141
3141
  memset(&create_info, 0, sizeof(create_info));
4073
4073
}
4074
4074
 
4075
4075
 
4076
 
static void get_sort_and_sweep_cost(TABLE *table, ha_rows nrows, COST_VECT *cost);
 
4076
static void get_sort_and_sweep_cost(Table *table, ha_rows nrows, COST_VECT *cost);
4077
4077
 
4078
4078
 
4079
4079
/**
4161
4161
*/
4162
4162
 
4163
4163
static 
4164
 
void get_sort_and_sweep_cost(TABLE *table, ha_rows nrows, COST_VECT *cost)
 
4164
void get_sort_and_sweep_cost(Table *table, ha_rows nrows, COST_VECT *cost)
4165
4165
{
4166
4166
  if (nrows)
4167
4167
  {
4220
4220
  @param cost         OUT  The cost.
4221
4221
*/
4222
4222
 
4223
 
void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted, 
 
4223
void get_sweep_read_cost(Table *table, ha_rows nrows, bool interrupted, 
4224
4224
                         COST_VECT *cost)
4225
4225
{
4226
4226
  cost->zero();
4514
4514
  - table is not mysql.event
4515
4515
*/
4516
4516
 
4517
 
static bool check_table_binlog_row_based(THD *thd, TABLE *table)
 
4517
static bool check_table_binlog_row_based(THD *thd, Table *table)
4518
4518
{
4519
4519
  if (table->s->cached_row_logging_check == -1)
4520
4520
  {
4566
4566
      if (lock == NULL)
4567
4567
        continue;
4568
4568
 
4569
 
      TABLE **const end_ptr= lock->table + lock->table_count;
4570
 
      for (TABLE **table_ptr= lock->table ; 
 
4569
      Table **const end_ptr= lock->table + lock->table_count;
 
4570
      for (Table **table_ptr= lock->table ; 
4571
4571
           table_ptr != end_ptr ;
4572
4572
           ++table_ptr)
4573
4573
      {
4574
 
        TABLE *const table= *table_ptr;
 
4574
        Table *const table= *table_ptr;
4575
4575
        if (table->current_lock == F_WRLCK &&
4576
4576
            check_table_binlog_row_based(thd, table))
4577
4577
        {
4591
4591
}
4592
4592
 
4593
4593
 
4594
 
typedef bool Log_func(THD*, TABLE*, bool, const uchar*, const uchar*);
 
4594
typedef bool Log_func(THD*, Table*, bool, const uchar*, const uchar*);
4595
4595
 
4596
 
static int binlog_log_row(TABLE* table,
 
4596
static int binlog_log_row(Table* table,
4597
4597
                          const uchar *before_record,
4598
4598
                          const uchar *after_record,
4599
4599
                          Log_func *log_func)