~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_table.cc

Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "drizzled/data_home.h"
29
29
#include "drizzled/sql_table.h"
30
30
#include "drizzled/table_proto.h"
 
31
#include "drizzled/plugin/info_schema_table.h"
31
32
 
32
33
using namespace std;
33
34
 
689
690
 
690
691
  new_name_buff[0]= '\0';
691
692
 
692
 
  if (table_list && table_list->schema_table)
 
693
  /**
 
694
   * @todo this is a result of retaining the behavior that was here before. This should be removed
 
695
   * and the correct error handling should be done in doDropTable for the I_S engine.
 
696
   */
 
697
  plugin::InfoSchemaTable *sch_table= plugin::InfoSchemaTable::getTable(table_list->table_name);
 
698
  if (sch_table)
693
699
  {
694
700
    my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), "", "", INFORMATION_SCHEMA_NAME.c_str());
695
701
    return true;
968
974
  alter_info->build_method= HA_BUILD_OFFLINE;
969
975
 
970
976
  snprintf(tmp_name, sizeof(tmp_name), "%s-%lx_%"PRIx64, TMP_FILE_PREFIX, (unsigned long) current_pid, session->thread_id);
971
 
  
 
977
 
972
978
  /* Safety fix for innodb */
973
979
  my_casedn_str(files_charset_info, tmp_name);
974
980
 
1430
1436
  return error;
1431
1437
}
1432
1438
 
1433
 
/** @TODO This will soon die. */
1434
 
bool create_like_schema_frm(Session* session,
1435
 
                            TableList* schema_table,
1436
 
                            message::Table* table_proto)
1437
 
{
1438
 
  HA_CREATE_INFO local_create_info;
1439
 
  AlterInfo alter_info;
1440
 
  bool lex_identified_temp_table= (table_proto->type() == drizzled::message::Table::TEMPORARY);
1441
 
  uint32_t keys= schema_table->table->s->keys;
1442
 
  uint32_t db_options= 0;
1443
 
 
1444
 
  memset(&local_create_info, 0, sizeof(local_create_info));
1445
 
  local_create_info.db_type= schema_table->table->s->db_type();
1446
 
  local_create_info.row_type= schema_table->table->s->row_type;
1447
 
  local_create_info.default_table_charset=default_charset_info;
1448
 
  alter_info.flags.set(ALTER_CHANGE_COLUMN);
1449
 
  alter_info.flags.set(ALTER_RECREATE);
1450
 
  schema_table->table->use_all_columns();
1451
 
  if (mysql_prepare_alter_table(session, schema_table->table,
1452
 
                                &local_create_info, table_proto, &alter_info))
1453
 
    return true;
1454
 
 
1455
 
  /* I_S tables are created with MAX_ROWS for some efficiency drive.
1456
 
     When CREATE LIKE, we don't want to keep it coming across */
1457
 
  message::Table::TableOptions *table_options;
1458
 
  table_options= table_proto->mutable_options();
1459
 
  table_options->clear_max_rows();
1460
 
 
1461
 
  if (mysql_prepare_create_table(session, &local_create_info, table_proto,
1462
 
                                 &alter_info,
1463
 
                                 lex_identified_temp_table, &db_options,
1464
 
                                 schema_table->table->cursor,
1465
 
                                 &schema_table->table->s->key_info, &keys, 0))
1466
 
    return true;
1467
 
 
1468
 
  table_proto->set_name("system_stupid_i_s_fix_nonsense");
1469
 
 
1470
 
  {
1471
 
    message::Table::StorageEngine *protoengine;
1472
 
    protoengine= table_proto->mutable_engine();
1473
 
 
1474
 
    plugin::StorageEngine *engine= local_create_info.db_type;
1475
 
 
1476
 
    protoengine->set_name(engine->getName());
1477
 
  }
1478
 
 
1479
 
  if (fill_table_proto(table_proto, "system_stupid_i_s_fix_nonsense",
1480
 
                       alter_info.create_list, &local_create_info,
1481
 
                       keys, schema_table->table->s->key_info))
1482
 
    return true;
1483
 
 
1484
 
  return false;
1485
 
}
1486
 
 
1487
 
 
1488
1439
static Table *open_alter_table(Session *session, Table *table, char *db, char *table_name)
1489
1440
{
1490
1441
  Table *new_table;