~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_table.cc

  • Committer: Brian Aker
  • Date: 2009-11-20 19:07:14 UTC
  • mfrom: (1223.1.5 push)
  • Revision ID: brian@gaz-20091120190714-dhr3lgqxrt7dq1fc
Collected Merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
  Select_Lex *select_lex= &session->lex->select_lex;
65
65
  bool need_start_waiting= false;
66
66
 
67
 
  if (create_info.used_fields & HA_CREATE_USED_ENGINE)
 
67
  if (is_engine_set)
68
68
  {
69
 
 
70
69
    create_info.db_type= 
71
70
      plugin::StorageEngine::findByName(*session, create_table_proto.engine().name());
72
71
 
501
500
    table_options->set_comment(table->s->getComment());
502
501
 
503
502
  if (table->s->tmp_table)
504
 
    create_info->options|= HA_LEX_CREATE_TMP_TABLE;
 
503
  {
 
504
    table_proto->set_type(message::Table::TEMPORARY);
 
505
  }
505
506
 
506
507
  rc= false;
507
508
  alter_info->create_list.swap(new_create_list);
800
801
  }
801
802
 
802
803
  if (table->s->tmp_table != NO_TMP_TABLE)
803
 
    create_info->options|= HA_LEX_CREATE_TMP_TABLE;
804
 
 
805
 
  if (check_engine(session, new_name, create_info))
806
 
    goto err;
 
804
  {
 
805
    create_proto->set_type(message::Table::TEMPORARY);
 
806
  }
 
807
  else
 
808
  {
 
809
    create_proto->set_type(message::Table::STANDARD);
 
810
  }
807
811
 
808
812
  new_db_type= create_info->db_type;
809
813
 
816
820
  }
817
821
 
818
822
  if (create_info->row_type == ROW_TYPE_NOT_USED)
 
823
  {
 
824
    message::Table::TableOptions *table_options;
 
825
    table_options= create_proto->mutable_options();
 
826
 
819
827
    create_info->row_type= table->s->row_type;
 
828
    table_options->set_row_type((drizzled::message::Table_TableOptions_RowType)table->s->row_type);
 
829
  }
820
830
 
821
831
  if (old_db_type->check_flag(HTON_BIT_ALTER_NOT_SUPPORTED) ||
822
832
      new_db_type->check_flag(HTON_BIT_ALTER_NOT_SUPPORTED))
946
956
  }
947
957
 
948
958
  /* We have to do full alter table. */
949
 
 
950
 
  /*
951
 
    If the old table had partitions and we are doing ALTER Table ...
952
 
    engine= <new_engine>, the new table must preserve the original
953
 
    partitioning. That means that the new engine is still the
954
 
    partitioning engine, not the engine specified in the parser.
955
 
    This is discovered  in prep_alter_part_table, which in such case
956
 
    updates create_info->db_type.
957
 
    Now we need to update the stack copy of create_info->db_type,
958
 
    as otherwise we won't be able to correctly move the files of the
959
 
    temporary table to the result table files.
960
 
  */
961
959
  new_db_type= create_info->db_type;
962
960
 
963
961
  if (mysql_prepare_alter_table(session, table, create_info, create_proto,
1433
1431
    We don't log the statement, it will be logged later.
1434
1432
  */
1435
1433
  create_proto->set_name(tmp_name);
1436
 
  create_proto->set_type(message::Table::TEMPORARY);
1437
1434
 
1438
1435
  message::Table::StorageEngine *protoengine;
1439
1436
  protoengine= create_proto->mutable_engine();
1440
1437
  protoengine->set_name(new_db_type->getName());
1441
1438
 
1442
1439
  error= mysql_create_table(session, new_db, tmp_name,
1443
 
                            create_info, create_proto, alter_info, true, 0);
 
1440
                            create_info, create_proto, alter_info, true, 0, false);
1444
1441
 
1445
 
  return(error);
 
1442
  return error;
1446
1443
}
1447
1444
 
1448
1445
/** @TODO This will soon die. */
1449
1446
bool create_like_schema_frm(Session* session,
1450
1447
                            TableList* schema_table,
1451
 
                            HA_CREATE_INFO *create_info,
1452
1448
                            message::Table* table_proto)
1453
1449
{
1454
1450
  HA_CREATE_INFO local_create_info;
1455
1451
  AlterInfo alter_info;
1456
 
  bool tmp_table= (create_info->options & HA_LEX_CREATE_TMP_TABLE);
 
1452
  bool lex_identified_temp_table= (table_proto->type() == drizzled::message::Table::TEMPORARY);
1457
1453
  uint32_t keys= schema_table->table->s->keys;
1458
1454
  uint32_t db_options= 0;
1459
1455
 
1476
1472
 
1477
1473
  if (mysql_prepare_create_table(session, &local_create_info, table_proto,
1478
1474
                                 &alter_info,
1479
 
                                 tmp_table, &db_options,
 
1475
                                 lex_identified_temp_table, &db_options,
1480
1476
                                 schema_table->table->cursor,
1481
1477
                                 &schema_table->table->s->key_info, &keys, 0))
1482
1478
    return true;
1483
1479
 
1484
1480
  table_proto->set_name("system_stupid_i_s_fix_nonsense");
1485
 
  if(tmp_table)
1486
 
    table_proto->set_type(message::Table::TEMPORARY);
1487
 
  else
1488
 
    table_proto->set_type(message::Table::STANDARD);
1489
1481
 
1490
1482
  {
1491
1483
    message::Table::StorageEngine *protoengine;