~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/drop_index.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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
19
19
 */
20
20
 
21
21
#include "config.h"
 
22
 
22
23
#include "drizzled/show.h"
23
24
#include "drizzled/session.h"
24
25
#include "drizzled/statement/drop_index.h"
25
26
#include "drizzled/statement/alter_table.h"
26
27
#include "drizzled/db.h"
 
28
#include "drizzled/plugin/storage_engine.h"
27
29
 
28
30
namespace drizzled
29
31
{
30
32
 
31
33
bool statement::DropIndex::execute()
32
34
{
33
 
  TableList *first_table= (TableList *) session->lex->select_lex.table_list.first;
34
 
  TableList *all_tables= session->lex->query_tables;
 
35
  TableList *first_table= (TableList *) getSession()->lex->select_lex.table_list.first;
 
36
  TableList *all_tables= getSession()->lex->query_tables;
35
37
 
36
38
  /* 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
 
  message::Table original_table_message;
 
39
  message::table::shared_ptr original_table_message;
38
40
  {
39
 
    TableIdentifier identifier(first_table->db, first_table->table_name);
40
 
    if (plugin::StorageEngine::getTableDefinition(*session, identifier, original_table_message) != EEXIST)
 
41
    identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
 
42
    if (plugin::StorageEngine::getTableDefinition(*getSession(), identifier, original_table_message) != EEXIST)
41
43
    {
42
 
      my_error(ER_BAD_TABLE_ERROR, MYF(0), identifier.getSQLPath().c_str());
 
44
      my_error(ER_BAD_TABLE_ERROR, identifier);
43
45
      return true;
44
46
    }
45
47
  }
56
58
  HA_CREATE_INFO create_info;
57
59
 
58
60
  assert(first_table == all_tables && first_table != 0);
59
 
  if (! session->endActiveTransaction())
 
61
  if (getSession()->inTransaction())
60
62
  {
 
63
    my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
61
64
    return true;
62
65
  }
63
66
 
64
 
  memset(&create_info, 0, sizeof(create_info));
65
67
  create_info.db_type= 0;
66
68
 
67
69
  bool res;
68
 
  if (original_table_message.type() == message::Table::STANDARD )
 
70
  if (original_table_message->type() == message::Table::STANDARD )
69
71
  {
70
 
    TableIdentifier identifier(first_table->db, first_table->table_name);
 
72
    identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
71
73
 
72
74
    create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
73
75
 
74
 
    res= alter_table(session, 
 
76
    res= alter_table(getSession(), 
75
77
                     identifier,
76
78
                     identifier,
77
79
                     &create_info, 
78
 
                     original_table_message,
 
80
                     *original_table_message,
79
81
                     create_table_proto, 
80
82
                     first_table,
81
83
                     &alter_info,
82
 
                     0, (order_st*) 0, 0);
 
84
                     0, (Order*) 0, 0);
83
85
  }
84
86
  else
85
87
  {
86
 
    Table *table= session->find_temporary_table(first_table);
 
88
    identifier::Table catch22(first_table->getSchemaName(), first_table->getTableName());
 
89
    Table *table= getSession()->find_temporary_table(catch22);
87
90
    assert(table);
88
91
    {
89
 
      TableIdentifier identifier(first_table->db, first_table->table_name, table->s->getPath());
 
92
      identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName(), table->getShare()->getPath());
90
93
      create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
91
94
 
92
 
      res= alter_table(session, 
 
95
      res= alter_table(getSession(), 
93
96
                       identifier,
94
97
                       identifier,
95
98
                       &create_info, 
96
 
                       original_table_message,
 
99
                       *original_table_message,
97
100
                       create_table_proto, 
98
101
                       first_table,
99
102
                       &alter_info,
100
 
                       0, (order_st*) 0, 0);
 
103
                       0, (Order*) 0, 0);
101
104
    }
102
105
  }
103
106
  return res;