~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/rename_table.cc

  • Committer: Lee Bieber
  • Date: 2011-02-11 20:30:05 UTC
  • mfrom: (2157.1.3 build)
  • Revision ID: kalebral@gmail.com-20110211203005-757o1y2yf78dxzqr
Merge Stewart - 716848: drizzleimport displays wrong program_name
Merge Stewart - update README file
Merge Andrew and Joe - Exposes the InnoDB SYS_REPLICATION_LOG to data_dictionary so that it is fast and fixes many issues we have been having

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
 
21
#include "config.h"
22
22
#include <drizzled/show.h>
23
23
#include <drizzled/lock.h>
24
24
#include <drizzled/session.h>
25
25
#include <drizzled/statement/rename_table.h>
26
 
#include <drizzled/sql_table.h>
27
 
#include <drizzled/pthread_globals.h>
28
 
#include <drizzled/plugin/storage_engine.h>
 
26
#include "drizzled/sql_table.h"
 
27
#include "drizzled/pthread_globals.h"
29
28
 
30
29
namespace drizzled
31
30
{
32
31
 
33
32
bool statement::RenameTable::execute()
34
33
{
35
 
  TableList *first_table= (TableList *) getSession()->getLex()->select_lex.table_list.first;
36
 
  TableList *all_tables= getSession()->getLex()->query_tables;
 
34
  TableList *first_table= (TableList *) getSession()->lex->select_lex.table_list.first;
 
35
  TableList *all_tables= getSession()->lex->query_tables;
37
36
  assert(first_table == all_tables && first_table != 0);
38
37
  TableList *table;
39
38
 
153
152
  }
154
153
 
155
154
  plugin::StorageEngine *engine= NULL;
156
 
  message::table::shared_ptr table_message;
 
155
  message::table::shared_ptr table_proto;
157
156
 
158
157
  identifier::Table old_identifier(ren_table->getSchemaName(), old_alias, message::Table::STANDARD);
159
158
 
160
 
  if (not (table_message= plugin::StorageEngine::getTableMessage(*getSession(), old_identifier)))
 
159
  if (plugin::StorageEngine::getTableDefinition(*getSession(), old_identifier, table_proto) != EEXIST)
161
160
  {
162
161
    my_error(ER_TABLE_UNKNOWN, old_identifier);
163
162
    return true;
164
163
  }
165
164
 
166
 
  engine= plugin::StorageEngine::findByName(*getSession(), table_message->engine().name());
 
165
  engine= plugin::StorageEngine::findByName(*getSession(), table_proto->engine().name());
167
166
 
168
167
  identifier::Table new_identifier(new_db, new_alias, message::Table::STANDARD);
169
168
  if (plugin::StorageEngine::doesTableExist(*getSession(), new_identifier))
170
169
  {
171
 
    my_error(ER_TABLE_EXISTS_ERROR, new_identifier);
 
170
    my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
172
171
    return 1; // This can't be skipped
173
172
  }
174
173