~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/create_table.cc

  • Committer: Andrew Hutchings
  • Date: 2010-09-26 17:58:17 UTC
  • mto: (1795.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1796.
  • Revision ID: andrew@linuxjedi.co.uk-20100926175817-3pwsapakdfte1izu
Fix spelling mistake

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/message.h>
27
26
#include <drizzled/identifier.h>
28
27
 
29
28
#include <iostream>
67
66
    return true;
68
67
  }
69
68
 
 
69
  /* 
 
70
    Now we set the name in our Table proto so that it will match 
 
71
    create_info.db_type.
 
72
  */
 
73
  {
 
74
    create_table_message.mutable_engine()->set_name(create_info.db_type->getName());
 
75
  }
 
76
 
70
77
 
71
78
  /* If CREATE TABLE of non-temporary table, do implicit commit */
72
79
  if (not lex_identified_temp_table)
80
87
  TableList *create_table= session->lex->unlink_first_table(&link_to_local);
81
88
  TableList *select_tables= session->lex->query_tables;
82
89
 
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(),
 
90
 
 
91
  /*
 
92
    Now that we have the engine, we can figure out the table identifier. We need the engine in order
 
93
    to determine if the table is transactional or not if it is temp.
 
94
  */
 
95
 
 
96
  create_table_message.set_schema(create_table->db);
 
97
 
 
98
  TableIdentifier new_table_identifier(create_table->db,
 
99
                                       create_table->table_name,
87
100
                                       create_table_message.type());
88
101
 
89
 
  if (not check(new_table_identifier))
 
102
  if (create_table_precheck(new_table_identifier))
90
103
  {
91
104
    /* put tables back for PS rexecuting */
92
105
    session->lex->link_first_table_back(create_table, link_to_local);
109
122
     TABLE in the same way. That way we avoid that a new table is
110
123
     created during a gobal read lock.
111
124
   */
112
 
  if (! (need_start_waiting= not session->wait_if_global_read_lock(0, 1)))
 
125
  if (! (need_start_waiting= ! wait_if_global_read_lock(session, 0, 1)))
113
126
  {
114
127
    /* put tables back for PS rexecuting */
115
128
    session->lex->link_first_table_back(create_table, link_to_local);
146
159
             Release the protection against the global read lock and wake
147
160
             everyone, who might want to set a global read lock.
148
161
           */
149
 
          session->startWaitingGlobalReadLock();
 
162
          start_waiting_global_read_lock(session);
150
163
          /* put tables back for PS rexecuting */
151
164
          session->lex->link_first_table_back(create_table, link_to_local);
152
 
 
153
165
          return true;
154
166
        }
155
167
      }
225
237
     Release the protection against the global read lock and wake
226
238
     everyone, who might want to set a global read lock.
227
239
   */
228
 
  session->startWaitingGlobalReadLock();
 
240
  start_waiting_global_read_lock(session);
229
241
 
230
242
  return res;
231
243
}
232
244
 
233
 
bool statement::CreateTable::check(const TableIdentifier &identifier)
234
 
{
235
 
  // Check table name for validity
236
 
  if (not identifier.isValid())
237
 
    return false;
238
 
 
239
 
  // See if any storage engine objects to the name of the file
240
 
  if (not plugin::StorageEngine::canCreateTable(identifier))
241
 
  {
242
 
    my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), "", "", identifier.getSchemaName().c_str());
243
 
 
244
 
    return false;
245
 
  }
246
 
 
247
 
  // Make sure the schema exists, we will do this again during the actual
248
 
  // create for the table.
249
 
  if (not plugin::StorageEngine::doesSchemaExist(identifier))
250
 
  {
251
 
    my_error(ER_BAD_DB_ERROR, MYF(0), identifier.getSchemaName().c_str());
252
 
 
253
 
    return false;
254
 
  }
255
 
 
256
 
  return true;
257
 
}
258
 
 
259
245
bool statement::CreateTable::validateCreateTableOption()
260
246
{
261
247
  bool rc= true;