~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/drop_index.cc

edit

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>
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>
 
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"
28
27
 
29
28
namespace drizzled
30
29
{
31
30
 
32
31
bool statement::DropIndex::execute()
33
32
{
34
 
  TableList *first_table= (TableList *) getSession()->getLex()->select_lex.table_list.first;
35
 
  TableList *all_tables= getSession()->getLex()->query_tables;
 
33
  TableList *first_table= (TableList *) session->lex->select_lex.table_list.first;
 
34
  TableList *all_tables= session->lex->query_tables;
36
35
 
37
36
  /* Chicken/Egg... we need to search for the table, to know if the table exists, so we can build a full identifier from it */
38
37
  message::table::shared_ptr original_table_message;
39
38
  {
40
39
    identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
41
 
    if (not (original_table_message= plugin::StorageEngine::getTableMessage(*getSession(), identifier)))
 
40
    if (plugin::StorageEngine::getTableDefinition(*session, identifier, original_table_message) != EEXIST)
42
41
    {
43
 
      my_error(ER_BAD_TABLE_ERROR, identifier);
 
42
      std::string path;
 
43
      identifier.getSQLPath(path);
 
44
      my_error(ER_BAD_TABLE_ERROR, MYF(0), path.c_str());
44
45
      return true;
45
46
    }
46
47
  }
57
58
  HA_CREATE_INFO create_info;
58
59
 
59
60
  assert(first_table == all_tables && first_table != 0);
60
 
  if (getSession()->inTransaction())
 
61
  if (! session->endActiveTransaction())
61
62
  {
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));
66
67
  create_info.db_type= 0;
67
68
 
68
69
  bool res;
72
73
 
73
74
    create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
74
75
 
75
 
    res= alter_table(getSession(), 
 
76
    res= alter_table(session, 
76
77
                     identifier,
77
78
                     identifier,
78
79
                     &create_info, 
85
86
  else
86
87
  {
87
88
    identifier::Table catch22(first_table->getSchemaName(), first_table->getTableName());
88
 
    Table *table= getSession()->find_temporary_table(catch22);
 
89
    Table *table= session->find_temporary_table(catch22);
89
90
    assert(table);
90
91
    {
91
92
      identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName(), table->getShare()->getPath());
92
93
      create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
93
94
 
94
 
      res= alter_table(getSession(), 
 
95
      res= alter_table(session, 
95
96
                       identifier,
96
97
                       identifier,
97
98
                       &create_info,