~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Brian Aker
  • Date: 2009-12-01 02:39:03 UTC
  • mfrom: (1234.1.4 push)
  • Revision ID: brian@gaz-20091201023903-1id5z7xnup695jaq
Merge of Brian + Jay test fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1024
1024
    uint32_t primary_key= (uint32_t) (find_type((char*) "PRIMARY",
1025
1025
                                                &share->keynames, 3) - 1); /* @TODO Huh? */
1026
1026
 
1027
 
    int64_t ha_option= handler_file->ha_table_flags();
1028
 
 
1029
1027
    keyinfo= share->key_info;
1030
1028
    key_part= keyinfo->key_part;
1031
1029
 
1112
1110
            If this field is part of the primary key and all keys contains
1113
1111
            the primary key, then we can use any key to find this column
1114
1112
          */
1115
 
          if (ha_option & HA_PRIMARY_KEY_IN_READ_INDEX)
 
1113
          if (share->storage_engine->check_flag(HTON_BIT_PRIMARY_KEY_IN_READ_INDEX))
1116
1114
          {
1117
1115
            field->part_of_key= share->keys_in_use;
1118
1116
            if (field->part_of_sortkey.test(key))
1134
1132
        an unique index on the underlying MyISAM table. (Bug #10400)
1135
1133
      */
1136
1134
      if ((keyinfo->flags & HA_NOSAME) ||
1137
 
          (ha_option & HA_ANY_INDEX_MAY_BE_UNIQUE))
 
1135
          (handler_file->getEngine()->check_flag(HTON_BIT_ANY_INDEX_MAY_BE_UNIQUE)))
1138
1136
        set_if_bigger(share->max_unique_length,keyinfo->key_length);
1139
1137
    }
1140
1138
    if (primary_key < MAX_KEY &&
1495
1493
                          HA_OPEN_ABORT_IF_LOCKED :
1496
1494
                           HA_OPEN_IGNORE_IF_LOCKED) | ha_open_flags))))
1497
1495
    {
1498
 
      /* Set a flag if the table is crashed and it can be auto. repaired */
1499
 
      share->crashed= ((ha_err == HA_ERR_CRASHED_ON_USAGE) &&
1500
 
                       outparam->cursor->auto_repair() &&
1501
 
                       !(ha_open_flags & HA_OPEN_FOR_REPAIR));
1502
 
 
1503
1496
      switch (ha_err)
1504
1497
      {
1505
1498
        case HA_ERR_NO_SUCH_TABLE:
1971
1964
void Table::prepare_for_position()
1972
1965
{
1973
1966
 
1974
 
  if ((cursor->ha_table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) &&
 
1967
  if ((cursor->getEngine()->check_flag(HTON_BIT_PRIMARY_KEY_IN_READ_INDEX)) &&
1975
1968
      s->primary_key < MAX_KEY)
1976
1969
  {
1977
1970
    mark_columns_used_by_index_no_reset(s->primary_key);
2102
2095
    mark_columns_used_by_index_no_reset(s->primary_key);
2103
2096
 
2104
2097
  /* If we the engine wants all predicates we mark all keys */
2105
 
  if (cursor->ha_table_flags() & HA_REQUIRES_KEY_COLUMNS_FOR_DELETE)
 
2098
  if (cursor->getEngine()->check_flag(HTON_BIT_REQUIRES_KEY_COLUMNS_FOR_DELETE))
2106
2099
  {
2107
2100
    Field **reg_field;
2108
2101
    for (reg_field= field ; *reg_field ; reg_field++)
2126
2119
    if neeed, either the primary key column or all columns to be read.
2127
2120
    (see mark_columns_needed_for_delete() for details)
2128
2121
 
2129
 
    If the engine has HA_REQUIRES_KEY_COLUMNS_FOR_DELETE, we will
 
2122
    If the engine has HTON_BIT_REQUIRES_KEY_COLUMNS_FOR_DELETE, we will
2130
2123
    mark all USED key columns as 'to-be-read'. This allows the engine to
2131
2124
    loop over the given record to find all changed keys and doesn't have to
2132
2125
    retrieve the row again.
2149
2142
  else
2150
2143
    mark_columns_used_by_index_no_reset(s->primary_key);
2151
2144
 
2152
 
  if (cursor->ha_table_flags() & HA_REQUIRES_KEY_COLUMNS_FOR_DELETE)
 
2145
  if (cursor->getEngine()->check_flag(HTON_BIT_REQUIRES_KEY_COLUMNS_FOR_DELETE))
2153
2146
  {
2154
2147
    /* Mark all used key columns for read */
2155
2148
    Field **reg_field;
2601
2594
    share->storage_engine= myisam_engine;
2602
2595
    table->cursor= share->db_type()->getCursor(*share, &table->mem_root);
2603
2596
    if (group &&
2604
 
        (param->group_parts > table->cursor->max_key_parts() ||
2605
 
         param->group_length > table->cursor->max_key_length()))
 
2597
        (param->group_parts > table->cursor->getEngine()->max_key_parts() ||
 
2598
         param->group_length > table->cursor->getEngine()->max_key_length()))
2606
2599
      using_unique_constraint=1;
2607
2600
  }
2608
2601
  else
3149
3142
      goto err;
3150
3143
 
3151
3144
    memset(seg, 0, sizeof(*seg) * keyinfo->key_parts);
3152
 
    if (keyinfo->key_length >= cursor->max_key_length() ||
3153
 
        keyinfo->key_parts > cursor->max_key_parts() ||
 
3145
    if (keyinfo->key_length >= cursor->getEngine()->max_key_length() ||
 
3146
        keyinfo->key_parts > cursor->getEngine()->max_key_parts() ||
3154
3147
        share->uniques)
3155
3148
    {
3156
3149
      /* Can't create a key; Make a unique constraint instead of a key */