~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/create_table.cc

  • Committer: Andrew Hutchings
  • Date: 2010-11-01 22:14:18 UTC
  • mto: This revision was merged to the branch mainline in revision 1907.
  • Revision ID: andrew@linuxjedi.co.uk-20101101221418-9n9gmm4ms7fl8vo5
Fix copyright

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <drizzled/lock.h>
24
24
#include <drizzled/session.h>
25
25
#include <drizzled/statement/create_table.h>
26
 
#include <drizzled/table_identifier.h>
 
26
#include <drizzled/message.h>
 
27
#include <drizzled/identifier.h>
27
28
 
28
29
#include <iostream>
29
30
 
51
52
    if (create_info.db_type == NULL)
52
53
    {
53
54
      my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), 
54
 
               create_table_message.name().c_str());
 
55
               create_table_message.engine().name().c_str());
55
56
 
56
57
      return true;
57
58
    }
61
62
    create_info.db_type= session->getDefaultStorageEngine();
62
63
  }
63
64
 
64
 
  /* 
65
 
    Now we set the name in our Table proto so that it will match 
66
 
    create_info.db_type.
67
 
  */
 
65
  if (not validateCreateTableOption())
68
66
  {
69
 
    message::Table::StorageEngine *protoengine;
70
 
 
71
 
    protoengine= create_table_message.mutable_engine();
72
 
    protoengine->set_name(create_info.db_type->getName());
 
67
    return true;
73
68
  }
74
69
 
75
70
 
85
80
  TableList *create_table= session->lex->unlink_first_table(&link_to_local);
86
81
  TableList *select_tables= session->lex->query_tables;
87
82
 
88
 
 
89
 
  /*
90
 
    Now that we have the engine, we can figure out the table identifier. We need the engine in order
91
 
    to determine if the table is transactional or not if it is temp.
92
 
  */
93
 
 
94
 
  create_table_message.set_schema(create_table->db);
95
 
 
96
 
  TableIdentifier new_table_identifier(create_table->db,
97
 
                                       create_table->table_name,
 
83
  drizzled::message::init(create_table_message, create_table_message.name(), create_table->getSchemaName(), create_info.db_type->getName());
 
84
 
 
85
  TableIdentifier new_table_identifier(create_table->getSchemaName(),
 
86
                                       create_table->getTableName(),
98
87
                                       create_table_message.type());
99
88
 
100
89
  if (create_table_precheck(new_table_identifier))
137
126
    if (not lex_identified_temp_table)
138
127
    {
139
128
      session->lex->link_first_table_back(create_table, link_to_local);
140
 
      create_table->create= true;
 
129
      create_table->setCreate(true);
141
130
    }
142
131
 
143
132
    if (not (res= session->openTablesLock(session->lex->query_tables)))
240
229
  return res;
241
230
}
242
231
 
 
232
bool statement::CreateTable::validateCreateTableOption()
 
233
{
 
234
  bool rc= true;
 
235
  size_t num_engine_options= create_table_message.engine().options_size();
 
236
 
 
237
  assert(create_info.db_type);
 
238
 
 
239
  for (size_t y= 0; y < num_engine_options; ++y)
 
240
  {
 
241
    bool valid= create_info.db_type->validateCreateTableOption(create_table_message.engine().options(y).name(),
 
242
                                                               create_table_message.engine().options(y).state());
 
243
 
 
244
    if (not valid)
 
245
    {
 
246
      my_error(ER_UNKNOWN_ENGINE_OPTION, MYF(0),
 
247
               create_table_message.engine().options(y).name().c_str(),
 
248
               create_table_message.engine().options(y).state().c_str());
 
249
 
 
250
      rc= false;
 
251
    }
 
252
  }
 
253
 
 
254
  return rc;
 
255
}
 
256
 
243
257
} /* namespace drizzled */
244
258