~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/drop_index.cc

  • Committer: Prafulla Tekawade
  • Date: 2010-07-18 03:36:32 UTC
  • mto: (1662.1.4 rollup)
  • mto: This revision was merged to the branch mainline in revision 1664.
  • Revision ID: prafulla_t@users.sourceforge.net-20100718033632-p7q6qtgliqbhe38p
Fix for Bug 592444

There were two problems:
o. In greedy_search optimizer method, best_extension_by_limited search
   maintains join embedding(nestedness) of tables added so far, so that 
   correct(valid)  join order is selected
   These are requirements from nested outer join executioner.
   The problem was, embedding_map was not correctly updated when a table 
   is added to optimal plan outside best_extension_by_limited search, 
   by greedy_search method. We need to update join->cur_embedding_map
   correctly here so that execution plan for other tables get
   generated.
   Invoked checked_interleaving_with_nj from greedy_search on the
   best_table selected. Fixed its prototype to take only one JoinTab
   This is same as mysql 5.1 source tree.
o. The other problem was, join->cur_embedding_map was not restored correctly
   when a table is added to the optimal plan to reflect the current embedding 
   map. 
   Taken good documented method restore_prev_nj_state which restores 
   cur_embedding_map from mysql 5.1 source tree and modified it for drizzled 
   code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
  TableList *all_tables= session->lex->query_tables;
35
35
 
36
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 */
37
 
  message::table::shared_ptr original_table_message;
 
37
  message::Table original_table_message;
38
38
  {
39
 
    TableIdentifier identifier(first_table->getSchemaName(), first_table->getTableName());
 
39
    TableIdentifier identifier(first_table->db, first_table->table_name);
40
40
    if (plugin::StorageEngine::getTableDefinition(*session, identifier, original_table_message) != EEXIST)
41
41
    {
42
 
      std::string path;
43
 
      identifier.getSQLPath(path);
44
 
      my_error(ER_BAD_TABLE_ERROR, MYF(0), path.c_str());
 
42
      my_error(ER_BAD_TABLE_ERROR, MYF(0), identifier.getSQLPath().c_str());
45
43
      return true;
46
44
    }
47
45
  }
65
63
 
66
64
  memset(&create_info, 0, sizeof(create_info));
67
65
  create_info.db_type= 0;
 
66
  create_info.row_type= ROW_TYPE_NOT_USED;
68
67
 
69
68
  bool res;
70
 
  if (original_table_message->type() == message::Table::STANDARD )
 
69
  if (original_table_message.type() == message::Table::STANDARD )
71
70
  {
72
 
    TableIdentifier identifier(first_table->getSchemaName(), first_table->getTableName());
 
71
    TableIdentifier identifier(first_table->db, first_table->table_name);
73
72
 
74
73
    create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
75
74
 
77
76
                     identifier,
78
77
                     identifier,
79
78
                     &create_info, 
80
 
                     *original_table_message,
 
79
                     original_table_message,
81
80
                     create_table_proto, 
82
81
                     first_table,
83
82
                     &alter_info,
84
 
                     0, (Order*) 0, 0);
 
83
                     0, (order_st*) 0, 0);
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
    Table *table= session->find_temporary_table(first_table);
90
88
    assert(table);
91
89
    {
92
 
      TableIdentifier identifier(first_table->getSchemaName(), first_table->getTableName(), table->getShare()->getPath());
 
90
      TableIdentifier identifier(first_table->db, first_table->table_name, table->s->getPath());
93
91
      create_info.default_table_charset= plugin::StorageEngine::getSchemaCollation(identifier);
94
92
 
95
93
      res= alter_table(session, 
96
94
                       identifier,
97
95
                       identifier,
98
96
                       &create_info, 
99
 
                       *original_table_message,
 
97
                       original_table_message,
100
98
                       create_table_proto, 
101
99
                       first_table,
102
100
                       &alter_info,
103
 
                       0, (Order*) 0, 0);
 
101
                       0, (order_st*) 0, 0);
104
102
    }
105
103
  }
106
104
  return res;