~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Brian Aker
  • Date: 2009-08-18 07:19:56 UTC
  • mfrom: (1116.1.3 stewart)
  • mto: This revision was merged to the branch mainline in revision 1118.
  • Revision ID: brian@gaz-20090818071956-nfpoe9rp3i7p50kx
Merge my branch from Stewart into one branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
static bool
78
78
mysql_prepare_alter_table(Session *session, Table *table,
79
79
                          HA_CREATE_INFO *create_info,
 
80
                          drizzled::message::Table *table_proto,
80
81
                          Alter_info *alter_info);
81
82
 
82
83
static void set_table_default_charset(HA_CREATE_INFO *create_info, char *db)
2562
2563
  alter_info.flags.set(ALTER_RECREATE);
2563
2564
  schema_table->table->use_all_columns();
2564
2565
  if (mysql_prepare_alter_table(session, schema_table->table,
2565
 
                                &local_create_info, &alter_info))
 
2566
                                &local_create_info, table_proto, &alter_info))
2566
2567
    return true;
2567
2568
 
 
2569
  /* I_S tables are created with MAX_ROWS for some efficiency drive.
 
2570
     When CREATE LIKE, we don't want to keep it coming across */
 
2571
  drizzled::message::Table::TableOptions *table_options;
 
2572
  table_options= table_proto->mutable_options();
 
2573
  table_options->clear_max_rows();
 
2574
 
2568
2575
  if (mysql_prepare_create_table(session, &local_create_info, &alter_info,
2569
2576
                                 tmp_table, &db_options,
2570
2577
                                 schema_table->table->file,
2571
2578
                                 &schema_table->table->s->key_info, &keys, 0))
2572
2579
    return true;
2573
2580
 
2574
 
  local_create_info.max_rows= 0;
2575
 
 
2576
2581
  table_proto->set_name("system_stupid_i_s_fix_nonsense");
2577
2582
  if(tmp_table)
2578
2583
    table_proto->set_type(drizzled::message::Table::TEMPORARY);
2950
2955
  return(error);
2951
2956
}
2952
2957
 
2953
 
static int 
 
2958
static int
2954
2959
create_temporary_table(Session *session,
2955
2960
                       Table *table,
2956
2961
                       char *new_db,
2957
2962
                       char *tmp_name,
2958
2963
                       HA_CREATE_INFO *create_info,
 
2964
                       drizzled::message::Table *create_proto,
2959
2965
                       Alter_info *alter_info,
2960
2966
                       bool db_changed)
2961
2967
{
3014
3020
    Create a table with a temporary name.
3015
3021
    We don't log the statement, it will be logged later.
3016
3022
  */
3017
 
  drizzled::message::Table table_proto;
3018
 
  table_proto.set_name(tmp_name);
3019
 
  table_proto.set_type(drizzled::message::Table::TEMPORARY);
 
3023
  create_proto->set_name(tmp_name);
 
3024
  create_proto->set_type(drizzled::message::Table::TEMPORARY);
3020
3025
 
3021
3026
  drizzled::message::Table::StorageEngine *protoengine;
3022
 
  protoengine= table_proto.mutable_engine();
 
3027
  protoengine= create_proto->mutable_engine();
3023
3028
  protoengine->set_name(new_db_type->getName());
3024
3029
 
3025
3030
  error= mysql_create_table(session, new_db, tmp_name,
3026
 
                            create_info, &table_proto, alter_info, 1, 0);
 
3031
                            create_info, create_proto, alter_info, 1, 0);
3027
3032
 
3028
3033
  return(error);
3029
3034
}
3073
3078
static bool
3074
3079
mysql_prepare_alter_table(Session *session, Table *table,
3075
3080
                          HA_CREATE_INFO *create_info,
 
3081
                          drizzled::message::Table *table_proto,
3076
3082
                          Alter_info *alter_info)
3077
3083
{
3078
3084
  /* New column definitions are added here */
3093
3099
 
3094
3100
  create_info->varchar= false;
3095
3101
  /* Let new create options override the old ones */
3096
 
  if (!(used_fields & HA_CREATE_USED_MIN_ROWS))
3097
 
    create_info->min_rows= table->s->min_rows;
3098
 
  if (!(used_fields & HA_CREATE_USED_MAX_ROWS))
3099
 
    create_info->max_rows= table->s->max_rows;
3100
 
  if (!(used_fields & HA_CREATE_USED_AVG_ROW_LENGTH))
3101
 
    create_info->avg_row_length= table->s->avg_row_length;
 
3102
  drizzled::message::Table::TableOptions *table_options;
 
3103
  table_options= table_proto->mutable_options();
 
3104
 
3102
3105
  if (!(used_fields & HA_CREATE_USED_BLOCK_SIZE))
3103
3106
    create_info->block_size= table->s->block_size;
3104
3107
  if (!(used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
3402
3405
    goto err;
3403
3406
  }
3404
3407
 
3405
 
  if (!create_info->comment.str)
3406
 
  {
3407
 
    create_info->comment.str= table->s->comment.str;
3408
 
    create_info->comment.length= table->s->comment.length;
3409
 
  }
3410
 
 
3411
 
  table->file->update_create_info(create_info);
 
3408
  if (! table_proto->options().has_comment()
 
3409
      && table->s->hasComment())
 
3410
    table_options->set_comment(table->s->getComment());
3412
3411
 
3413
3412
  if (table->s->tmp_table)
3414
3413
    create_info->options|=HA_LEX_CREATE_TMP_TABLE;
3467
3466
                       char *new_db, 
3468
3467
                       char *new_name,
3469
3468
                       HA_CREATE_INFO *create_info,
 
3469
                       drizzled::message::Table *create_proto,
3470
3470
                       TableList *table_list,
3471
3471
                       Alter_info *alter_info,
3472
3472
                       uint32_t order_num, 
3770
3770
  */
3771
3771
  new_db_type= create_info->db_type;
3772
3772
 
3773
 
  if (mysql_prepare_alter_table(session, table, create_info, alter_info))
3774
 
    goto err;
 
3773
  if (mysql_prepare_alter_table(session, table, create_info, create_proto,
 
3774
                                alter_info))
 
3775
      goto err;
3775
3776
 
3776
3777
  set_table_default_charset(create_info, db);
3777
3778
 
3783
3784
  my_casedn_str(files_charset_info, tmp_name);
3784
3785
 
3785
3786
  /* Create a temporary table with the new format */
3786
 
  error= create_temporary_table(session, table, new_db, tmp_name, create_info, alter_info, ! strcmp(db, new_db));
3787
 
 
 
3787
  error= create_temporary_table(session, table, new_db, tmp_name, create_info, create_proto, alter_info, !strcmp(db, new_db));
3788
3788
  if (error != 0)
3789
3789
    goto err;
3790
3790
 
4278
4278
{
4279
4279
  HA_CREATE_INFO create_info;
4280
4280
  Alter_info alter_info;
 
4281
  drizzled::message::Table table_proto;
4281
4282
 
4282
4283
  assert(!table_list->next_global);
4283
4284
  /*
4292
4293
  /* Force alter table to recreate table */
4293
4294
  alter_info.flags.set(ALTER_CHANGE_COLUMN);
4294
4295
  alter_info.flags.set(ALTER_RECREATE);
4295
 
  return(mysql_alter_table(session, NULL, NULL, &create_info,
4296
 
                                table_list, &alter_info, 0,
4297
 
                                (order_st *) 0, 0));
 
4296
  return(mysql_alter_table(session, NULL, NULL, &create_info, &table_proto,
 
4297
                           table_list, &alter_info, 0,
 
4298
                           (order_st *) 0, 0));
4298
4299
}
4299
4300
 
4300
4301