~drizzle-trunk/drizzle/development

« back to all changes in this revision

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