~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_table.cc

  • Committer: Monty Taylor
  • Date: 2009-09-25 22:17:36 UTC
  • mto: This revision was merged to the branch mainline in revision 1184.
  • Revision ID: mordred@inaugust.com-20090925221736-odo56sxjwgb0vetl
using namespace drizzled; to namespace drizzled { in statement/

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "drizzled/table_proto.h"
31
31
 
32
32
using namespace std;
33
 
using namespace drizzled;
34
33
 
35
34
static int copy_data_between_tables(Table *from,Table *to,
36
35
                                    List<CreateField> &create,
44
43
static bool mysql_prepare_alter_table(Session *session,
45
44
                                      Table *table,
46
45
                                      HA_CREATE_INFO *create_info,
47
 
                                      message::Table *table_proto,
 
46
                                      drizzled::message::Table *table_proto,
48
47
                                      AlterInfo *alter_info);
49
48
static int create_temporary_table(Session *session,
50
49
                                  Table *table,
51
50
                                  char *new_db,
52
51
                                  char *tmp_name,
53
52
                                  HA_CREATE_INFO *create_info,
54
 
                                  message::Table *create_proto,
 
53
                                  drizzled::message::Table *create_proto,
55
54
                                  AlterInfo *alter_info);
56
55
 
 
56
namespace drizzled
 
57
{
 
58
 
57
59
bool statement::AlterTable::execute()
58
60
{
59
61
  TableList *first_table= (TableList *) session->lex->select_lex.table_list.first;
108
110
  return res;
109
111
}
110
112
 
 
113
} /* namespace drizzled */
 
114
 
111
115
/**
112
116
  Prepare column and key definitions for CREATE TABLE in ALTER Table.
113
117
 
151
155
static bool mysql_prepare_alter_table(Session *session,
152
156
                                      Table *table,
153
157
                                      HA_CREATE_INFO *create_info,
154
 
                                      message::Table *table_proto,
 
158
                                      drizzled::message::Table *table_proto,
155
159
                                      AlterInfo *alter_info)
156
160
{
157
161
  /* New column definitions are added here */
170
174
  bool rc= true;
171
175
 
172
176
  /* Let new create options override the old ones */
173
 
  message::Table::TableOptions *table_options;
 
177
  drizzled::message::Table::TableOptions *table_options;
174
178
  table_options= table_proto->mutable_options();
175
179
 
176
180
  if (! (used_fields & HA_CREATE_USED_BLOCK_SIZE))
648
652
                       char *new_db,
649
653
                       char *new_name,
650
654
                       HA_CREATE_INFO *create_info,
651
 
                       message::Table *create_proto,
 
655
                       drizzled::message::Table *create_proto,
652
656
                       TableList *table_list,
653
657
                       AlterInfo *alter_info,
654
658
                       uint32_t order_num,
670
674
  char path[FN_REFLEN];
671
675
  ha_rows copied= 0;
672
676
  ha_rows deleted= 0;
673
 
  plugin::StorageEngine *old_db_type;
674
 
  plugin::StorageEngine *new_db_type;
675
 
  plugin::StorageEngine *save_old_db_type;
 
677
  drizzled::plugin::StorageEngine *old_db_type;
 
678
  drizzled::plugin::StorageEngine *new_db_type;
 
679
  drizzled::plugin::StorageEngine *save_old_db_type;
676
680
  bitset<32> tmp;
677
681
 
678
682
  new_name_buff[0]= '\0';
770
774
 
771
775
        build_table_filename(new_name_buff, sizeof(new_name_buff), new_db, new_name_buff, false);
772
776
 
773
 
        plugin::Registry &plugins= plugin::Registry::singleton();
 
777
        drizzled::plugin::Registry &plugins= drizzled::plugin::Registry::singleton();
774
778
        if (plugins.storage_engine.getTableProto(new_name_buff, NULL) == EEXIST)
775
779
        {
776
780
          /* Table will be closed by Session::executeCommand() */
898
902
        we don't take this name-lock and where this order really matters.
899
903
        TODO: Investigate if we need this access() check at all.
900
904
      */
901
 
      plugin::Registry &plugins= plugin::Registry::singleton();
 
905
      drizzled::plugin::Registry &plugins= drizzled::plugin::Registry::singleton();
902
906
      if (plugins.storage_engine.getTableProto(new_name, NULL) == EEXIST)
903
907
      {
904
908
        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_name);
1452
1456
                       char *new_db,
1453
1457
                       char *tmp_name,
1454
1458
                       HA_CREATE_INFO *create_info,
1455
 
                       message::Table *create_proto,
 
1459
                       drizzled::message::Table *create_proto,
1456
1460
                       AlterInfo *alter_info)
1457
1461
{
1458
1462
  int error;
1459
 
  plugin::StorageEngine *old_db_type, *new_db_type;
 
1463
  drizzled::plugin::StorageEngine *old_db_type, *new_db_type;
1460
1464
  old_db_type= table->s->db_type();
1461
1465
  new_db_type= create_info->db_type;
1462
1466
  /*
1464
1468
    We don't log the statement, it will be logged later.
1465
1469
  */
1466
1470
  create_proto->set_name(tmp_name);
1467
 
  create_proto->set_type(message::Table::TEMPORARY);
 
1471
  create_proto->set_type(drizzled::message::Table::TEMPORARY);
1468
1472
 
1469
 
  message::Table::StorageEngine *protoengine;
 
1473
  drizzled::message::Table::StorageEngine *protoengine;
1470
1474
  protoengine= create_proto->mutable_engine();
1471
1475
  protoengine->set_name(new_db_type->getName());
1472
1476
 
1480
1484
bool mysql_create_like_schema_frm(Session* session,
1481
1485
                                  TableList* schema_table,
1482
1486
                                  HA_CREATE_INFO *create_info,
1483
 
                                  message::Table* table_proto)
 
1487
                                  drizzled::message::Table* table_proto)
1484
1488
{
1485
1489
  HA_CREATE_INFO local_create_info;
1486
1490
  AlterInfo alter_info;
1501
1505
 
1502
1506
  /* I_S tables are created with MAX_ROWS for some efficiency drive.
1503
1507
     When CREATE LIKE, we don't want to keep it coming across */
1504
 
  message::Table::TableOptions *table_options;
 
1508
  drizzled::message::Table::TableOptions *table_options;
1505
1509
  table_options= table_proto->mutable_options();
1506
1510
  table_options->clear_max_rows();
1507
1511
 
1513
1517
 
1514
1518
  table_proto->set_name("system_stupid_i_s_fix_nonsense");
1515
1519
  if(tmp_table)
1516
 
    table_proto->set_type(message::Table::TEMPORARY);
 
1520
    table_proto->set_type(drizzled::message::Table::TEMPORARY);
1517
1521
  else
1518
 
    table_proto->set_type(message::Table::STANDARD);
 
1522
    table_proto->set_type(drizzled::message::Table::STANDARD);
1519
1523
 
1520
1524
  {
1521
 
    message::Table::StorageEngine *protoengine;
 
1525
    drizzled::message::Table::StorageEngine *protoengine;
1522
1526
    protoengine= table_proto->mutable_engine();
1523
1527
 
1524
 
    plugin::StorageEngine *engine= local_create_info.db_type;
 
1528
    drizzled::plugin::StorageEngine *engine= local_create_info.db_type;
1525
1529
 
1526
1530
    protoengine->set_name(engine->getName());
1527
1531
  }
1528
1532
 
1529
 
  if (fill_table_proto(table_proto, "system_stupid_i_s_fix_nonsense",
1530
 
                       alter_info.create_list, &local_create_info,
1531
 
                       keys, schema_table->table->s->key_info))
 
1533
  if (drizzled::fill_table_proto(table_proto, "system_stupid_i_s_fix_nonsense",
 
1534
                                 alter_info.create_list, &local_create_info,
 
1535
                                 keys, schema_table->table->s->key_info))
1532
1536
    return true;
1533
1537
 
1534
1538
  return false;
1535
1539
}
 
1540