~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/drop_index.cc

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems
 
4
 *  Copyright (C) 2009 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
22
 
#include "drizzled/show.h"
23
 
#include "drizzled/session.h"
24
 
#include "drizzled/statement/drop_index.h"
25
 
#include "drizzled/statement/alter_table.h"
26
 
#include "drizzled/db.h"
 
21
#include <config.h>
 
22
 
 
23
#include <drizzled/show.h>
 
24
#include <drizzled/session.h>
 
25
#include <drizzled/statement/drop_index.h>
 
26
#include <drizzled/statement/alter_table.h>
 
27
#include <drizzled/plugin/storage_engine.h>
27
28
 
28
29
namespace drizzled
29
30
{
30
31
 
31
32
bool statement::DropIndex::execute()
32
33
{
33
 
  TableList *first_table= (TableList *) session->lex->select_lex.table_list.first;
34
 
  TableList *all_tables= session->lex->query_tables;
 
34
  TableList *first_table= (TableList *) getSession()->getLex()->select_lex.table_list.first;
 
35
  TableList *all_tables= getSession()->getLex()->query_tables;
35
36
 
36
37
  /* Chicken/Egg... we need to search for the table, to know if the table exists, so we can build a full identifier from it */
37
38
  message::table::shared_ptr original_table_message;
38
39
  {
39
 
    TableIdentifier identifier(first_table->getSchemaName(), first_table->getTableName());
40
 
    if (plugin::StorageEngine::getTableDefinition(*session, identifier, original_table_message) != EEXIST)
 
40
    identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
 
41
    if (not (original_table_message= plugin::StorageEngine::getTableMessage(*getSession(), identifier)))
41
42
    {
42
 
      std::string path;
43
 
      identifier.getSQLPath(path);
44
 
      my_error(ER_BAD_TABLE_ERROR, MYF(0), path.c_str());
 
43
      my_error(ER_BAD_TABLE_ERROR, identifier);
45
44
      return true;
46
45
    }
47
46
  }
58
57
  HA_CREATE_INFO create_info;
59
58
 
60
59
  assert(first_table == all_tables && first_table != 0);
61
 
  if (! session->endActiveTransaction())
 
60
  if (getSession()->inTransaction())
62
61
  {
 
62
    my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
63
63
    return true;
64
64
  }
65
65
 
66
 
  memset(&create_info, 0, sizeof(create_info));
67
66
  create_info.db_type= 0;
68
67
 
69
68
  bool res;
70
69
  if (original_table_message->type() == message::Table::STANDARD )
71
70
  {
72
 
    TableIdentifier identifier(first_table->getSchemaName(), first_table->getTableName());
 
71
    identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
73
72
 
74
73
    create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
75
74
 
76
 
    res= alter_table(session, 
 
75
    res= alter_table(getSession(), 
77
76
                     identifier,
78
77
                     identifier,
79
78
                     &create_info, 
85
84
  }
86
85
  else
87
86
  {
88
 
    TableIdentifier catch22(first_table->getSchemaName(), first_table->getTableName());
89
 
    Table *table= session->find_temporary_table(catch22);
 
87
    identifier::Table catch22(first_table->getSchemaName(), first_table->getTableName());
 
88
    Table *table= getSession()->find_temporary_table(catch22);
90
89
    assert(table);
91
90
    {
92
 
      TableIdentifier identifier(first_table->getSchemaName(), first_table->getTableName(), table->getShare()->getPath());
 
91
      identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName(), table->getShare()->getPath());
93
92
      create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
94
93
 
95
 
      res= alter_table(session, 
 
94
      res= alter_table(getSession(), 
96
95
                       identifier,
97
96
                       identifier,
98
97
                       &create_info,