~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

  • Committer: Brian Aker
  • Date: 2008-08-18 20:57:01 UTC
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: brian@tangent.org-20080818205701-rzeyd4qw4xj7wx7l
Refactoring of class Table

Show diffs side-by-side

added added

removed removed

Lines of Context:
2260
2260
*/
2261
2261
 
2262
2262
bool
2263
 
table_check_intact(Table *table, const uint table_f_count,
2264
 
                   const TABLE_FIELD_W_TYPE *table_def)
 
2263
Table::table_check_intact(const uint table_f_count,
 
2264
                          const TABLE_FIELD_W_TYPE *table_def)
2265
2265
{
2266
2266
  uint i;
2267
2267
  bool error= false;
2268
2268
  bool fields_diff_count;
2269
2269
 
2270
 
  fields_diff_count= (table->s->fields != table_f_count);
 
2270
  fields_diff_count= (s->fields != table_f_count);
2271
2271
  if (fields_diff_count)
2272
2272
  {
2273
2273
 
2274
2274
    /* previous MySQL version */
2275
 
    if (DRIZZLE_VERSION_ID > table->s->mysql_version)
 
2275
    if (DRIZZLE_VERSION_ID > s->mysql_version)
2276
2276
    {
2277
2277
      sql_print_error(ER(ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE),
2278
 
                      table->alias, table_f_count, table->s->fields,
2279
 
                      table->s->mysql_version, DRIZZLE_VERSION_ID);
 
2278
                      alias, table_f_count, s->fields,
 
2279
                      s->mysql_version, DRIZZLE_VERSION_ID);
2280
2280
      return(true);
2281
2281
    }
2282
 
    else if (DRIZZLE_VERSION_ID == table->s->mysql_version)
 
2282
    else if (DRIZZLE_VERSION_ID == s->mysql_version)
2283
2283
    {
2284
 
      sql_print_error(ER(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED), table->alias,
2285
 
                      table_f_count, table->s->fields);
 
2284
      sql_print_error(ER(ER_COL_COUNT_DOESNT_MATCH_CORRUPTED), alias,
 
2285
                      table_f_count, s->fields);
2286
2286
      return(true);
2287
2287
    }
2288
2288
    /*
2298
2298
  {
2299
2299
    String sql_type(buffer, sizeof(buffer), system_charset_info);
2300
2300
    sql_type.length(0);
2301
 
    if (i < table->s->fields)
 
2301
    if (i < s->fields)
2302
2302
    {
2303
 
      Field *field= table->field[i];
 
2303
      Field *field= this->field[i];
2304
2304
 
2305
2305
      if (strncmp(field->field_name, table_def->name.str,
2306
2306
                  table_def->name.length))
2312
2312
        */
2313
2313
        sql_print_error(_("Incorrect definition of table %s.%s: "
2314
2314
                        "expected column '%s' at position %d, found '%s'."),
2315
 
                        table->s->db.str, table->alias, table_def->name.str, i,
 
2315
                        s->db.str, alias, table_def->name.str, i,
2316
2316
                        field->field_name);
2317
2317
      }
2318
2318
      field->sql_type(sql_type);
2338
2338
      {
2339
2339
        sql_print_error(_("Incorrect definition of table %s.%s: "
2340
2340
                        "expected column '%s' at position %d to have type "
2341
 
                        "%s, found type %s."), table->s->db.str, table->alias,
 
2341
                        "%s, found type %s."), s->db.str, alias,
2342
2342
                        table_def->name.str, i, table_def->type.str,
2343
2343
                        sql_type.c_ptr_safe());
2344
2344
        error= true;
2348
2348
        sql_print_error(_("Incorrect definition of table %s.%s: "
2349
2349
                        "expected the type of column '%s' at position %d "
2350
2350
                        "to have character set '%s' but the type has no "
2351
 
                        "character set."), table->s->db.str, table->alias,
 
2351
                        "character set."), s->db.str, alias,
2352
2352
                        table_def->name.str, i, table_def->cset.str);
2353
2353
        error= true;
2354
2354
      }
2358
2358
        sql_print_error(_("Incorrect definition of table %s.%s: "
2359
2359
                        "expected the type of column '%s' at position %d "
2360
2360
                        "to have character set '%s' but found "
2361
 
                        "character set '%s'."), table->s->db.str, table->alias,
 
2361
                        "character set '%s'."), s->db.str, alias,
2362
2362
                        table_def->name.str, i, table_def->cset.str,
2363
2363
                        field->charset()->csname);
2364
2364
        error= true;
2369
2369
      sql_print_error(_("Incorrect definition of table %s.%s: "
2370
2370
                      "expected column '%s' at position %d to have type %s "
2371
2371
                      " but the column is not found."),
2372
 
                      table->s->db.str, table->alias,
 
2372
                      s->db.str, alias,
2373
2373
                      table_def->name.str, i, table_def->type.str);
2374
2374
      error= true;
2375
2375
    }
3365
3365
    as if we had "USE INDEX i1, USE INDEX i1, IGNORE INDEX i1".
3366
3366
 
3367
3367
    As an optimization if there is a covering index, and we have 
3368
 
    IGNORE INDEX FOR GROUP/ORDER, and this index is used for the JOIN part, 
3369
 
    then we have to ignore the IGNORE INDEX FROM GROUP/ORDER.
 
3368
    IGNORE INDEX FOR GROUP/order_st, and this index is used for the JOIN part, 
 
3369
    then we have to ignore the IGNORE INDEX FROM GROUP/order_st.
3370
3370
 
3371
3371
  RETURN VALUE
3372
3372
    false                no errors found
3950
3950
 
3951
3951
Table *
3952
3952
create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
3953
 
                 ORDER *group, bool distinct, bool save_sum_fields,
 
3953
                 order_st *group, bool distinct, bool save_sum_fields,
3954
3954
                 uint64_t select_options, ha_rows rows_limit,
3955
3955
                 char *table_alias)
3956
3956
{
4006
4006
  {
4007
4007
    if (!param->quick_group)
4008
4008
      group=0;                                  // Can't use group key
4009
 
    else for (ORDER *tmp=group ; tmp ; tmp=tmp->next)
 
4009
    else for (order_st *tmp=group ; tmp ; tmp=tmp->next)
4010
4010
    {
4011
4011
      /*
4012
4012
        marker == 4 means two things:
4456
4456
    keyinfo->rec_per_key=0;
4457
4457
    keyinfo->algorithm= HA_KEY_ALG_UNDEF;
4458
4458
    keyinfo->name= (char*) "group_key";
4459
 
    ORDER *cur_group= group;
 
4459
    order_st *cur_group= group;
4460
4460
    for (; cur_group ; cur_group= cur_group->next, key_part_info++)
4461
4461
    {
4462
4462
      Field *field=(*cur_group->item)->get_tmp_table_field();