~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/create_index.cc

  • Committer: Lee Bieber
  • Date: 2011-03-18 04:10:25 UTC
  • mfrom: (2241.1.2 build)
  • Revision ID: kalebral@gmail.com-20110318041025-1xoj1azy6zobhnbm
Merge Stewart - refactoring of default values
Merge Olaf - more refactoring

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
 
23
 
#include "drizzled/show.h"
24
 
#include "drizzled/session.h"
25
 
#include "drizzled/statement/create_index.h"
26
 
#include "drizzled/statement/alter_table.h"
27
 
#include "drizzled/db.h"
28
 
#include "drizzled/plugin/storage_engine.h"
 
23
#include <drizzled/show.h>
 
24
#include <drizzled/session.h>
 
25
#include <drizzled/statement/create_index.h>
 
26
#include <drizzled/statement/alter_table.h>
 
27
#include <drizzled/plugin/storage_engine.h>
29
28
 
30
29
namespace drizzled
31
30
{
33
32
namespace statement
34
33
{
35
34
 
36
 
CreateIndex::CreateIndex(Session *in_session, const drizzled::ha_build_method method_arg) :
 
35
CreateIndex::CreateIndex(Session *in_session) :
37
36
  CreateTable(in_session)
38
37
  {
39
 
    getSession()->getLex()->sql_command= SQLCOM_CREATE_INDEX;
 
38
    set_command(SQLCOM_CREATE_INDEX);
40
39
    alter_info.flags.set(ALTER_ADD_INDEX);
41
 
    alter_info.build_method= method_arg;
42
 
    getSession()->getLex()->col_list.empty();
 
40
    lex().col_list.clear();
43
41
  }
44
42
 
45
43
bool statement::CreateIndex::execute()
46
44
{
47
 
  TableList *first_table= (TableList *) getSession()->lex->select_lex.table_list.first;
48
 
  TableList *all_tables= getSession()->lex->query_tables;
 
45
  TableList *first_table= (TableList *) lex().select_lex.table_list.first;
 
46
  TableList *all_tables= lex().query_tables;
49
47
 
50
48
  /* Chicken/Egg... we need to search for the table, to know if the table exists, so we can build a full identifier from it */
51
49
  message::table::shared_ptr original_table_message;
52
50
  {
53
51
    identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
54
 
    if (plugin::StorageEngine::getTableDefinition(*getSession(), identifier, original_table_message) != EEXIST)
 
52
    if (not (original_table_message= plugin::StorageEngine::getTableMessage(session(), identifier)))
55
53
    {
56
54
      my_error(ER_BAD_TABLE_ERROR, identifier);
57
55
      return true;
68
66
  */
69
67
 
70
68
  assert(first_table == all_tables && first_table != 0);
71
 
  if (getSession()->inTransaction())
 
69
  if (session().inTransaction())
72
70
  {
73
71
    my_error(ER_TRANSACTIONAL_DDL_NOT_SUPPORTED, MYF(0));
74
72
    return true;
80
78
    identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
81
79
    create_info().default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
82
80
 
83
 
    res= alter_table(getSession(), 
 
81
    res= alter_table(&session(), 
84
82
                     identifier,
85
83
                     identifier,
86
84
                     &create_info(), 
93
91
  else
94
92
  {
95
93
    identifier::Table catch22(first_table->getSchemaName(), first_table->getTableName());
96
 
    Table *table= getSession()->find_temporary_table(catch22);
 
94
    Table *table= session().find_temporary_table(catch22);
97
95
    assert(table);
98
96
    {
99
97
      identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName(), table->getMutableShare()->getPath());
100
98
      create_info().default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
101
99
 
102
 
      res= alter_table(getSession(), 
 
100
      res= alter_table(&session(), 
103
101
                       identifier,
104
102
                       identifier,
105
103
                       &create_info(),