~drizzle-trunk/drizzle/jenkins-Drizzle-Builder-187

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_table.cc

  • Committer: Stewart Smith
  • Date: 2012-07-11 14:06:00 UTC
  • mto: This revision was merged to the branch mainline in revision 2574.
  • Revision ID: stewart@flamingspork.com-20120711140600-oxrs1cjabjuqpd05
force a identifier::Schema to be constructed with a identifier::Catalog. This is close to the final 'big' part for CATALOG support. We also have to modify all around the server that creates identifier::Schema so it does so properly. Since a single Session cannot span schemas, we get off a wee bit easy :) The big limitation in this patch is that INFORMATION_SCHEMA and DATA_DICTIONARY only appear in the LOCAL catalog (and this really needs to be fixed before CATALOGs other than LOCAL are supported).

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
#include <drizzled/open_tables_state.h>
52
52
#include <drizzled/table/cache.h>
53
53
#include <drizzled/create_field.h>
 
54
#include <drizzled/catalog/instance.h>
54
55
 
55
56
using namespace std;
56
57
 
128
129
  /* Chicken/Egg... we need to search for the table, to know if the table exists, so we can build a full identifier from it */
129
130
  message::table::shared_ptr original_table_message;
130
131
  {
131
 
    identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
 
132
    identifier::Table identifier(session().catalog().identifier(),
 
133
                                 first_table->getSchemaName(),
 
134
                                 first_table->getTableName());
132
135
    if (not (original_table_message= plugin::StorageEngine::getTableMessage(session(), identifier)))
133
136
    {
134
137
      my_error(ER_BAD_TABLE_ERROR, identifier);
163
166
  bool res;
164
167
  if (original_table_message->type() == message::Table::STANDARD )
165
168
  {
166
 
    identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName());
167
 
    identifier::Table new_identifier(select_lex->db ? select_lex->db : first_table->getSchemaName(),
 
169
    identifier::Table identifier(session().catalog().identifier(),
 
170
                                 first_table->getSchemaName(),
 
171
                                 first_table->getTableName());
 
172
    identifier::Table new_identifier(session().catalog().identifier(),
 
173
                                     select_lex->db ? select_lex->db : first_table->getSchemaName(),
168
174
                                   lex().name.data() ? lex().name.data() : first_table->getTableName());
169
175
 
170
176
    res= alter_table(&session(),
181
187
  }
182
188
  else
183
189
  {
184
 
    identifier::Table catch22(first_table->getSchemaName(), first_table->getTableName());
 
190
    identifier::Table catch22(session().catalog().identifier(),
 
191
                              first_table->getSchemaName(),
 
192
                              first_table->getTableName());
185
193
    Table *table= session().open_tables.find_temporary_table(catch22);
186
194
    assert(table);
187
195
    {
188
 
      identifier::Table identifier(first_table->getSchemaName(), first_table->getTableName(), table->getMutableShare()->getPath());
189
 
      identifier::Table new_identifier(select_lex->db ? select_lex->db : first_table->getSchemaName(),
 
196
      identifier::Table identifier(session().catalog().identifier(),
 
197
                                   first_table->getSchemaName(),
 
198
                                   first_table->getTableName(),
 
199
                                   table->getMutableShare()->getPath());
 
200
 
 
201
      identifier::Table new_identifier(session().catalog().identifier(),
 
202
                                       select_lex->db ? select_lex->db : first_table->getSchemaName(),
190
203
                                       lex().name.data() ? lex().name.data() : first_table->getTableName(),
191
204
                                       table->getMutableShare()->getPath());
192
205
 
1048
1061
    return true;
1049
1062
  }
1050
1063
 
1051
 
  set_table_default_charset(create_info, new_table_identifier.getSchemaName().c_str());
 
1064
  set_table_default_charset(session->catalog().identifier(), create_info, new_table_identifier.getSchemaName().c_str());
1052
1065
 
1053
1066
  snprintf(tmp_name, sizeof(tmp_name), "%s-%lx_%"PRIx64, TMP_FILE_PREFIX, (unsigned long) current_pid, session->thread_id);
1054
1067
 
1058
1071
    case we just use it as is. Neither of these tables require locks in order to  be
1059
1072
    filled.
1060
1073
  */
1061
 
  identifier::Table new_table_as_temporary(original_table_identifier.getSchemaName(),
1062
 
                                         tmp_name,
1063
 
                                         create_proto.type() != message::Table::TEMPORARY ? message::Table::INTERNAL :
1064
 
                                         message::Table::TEMPORARY);
 
1074
  identifier::Table new_table_as_temporary(session->catalog().identifier(),
 
1075
                                           original_table_identifier.getSchemaName(),
 
1076
                                           tmp_name,
 
1077
                                           create_proto.type() != message::Table::TEMPORARY ? message::Table::INTERNAL :
 
1078
                                           message::Table::TEMPORARY);
1065
1079
 
1066
1080
  /*
1067
1081
    Create a table with a temporary name.
1247
1261
        table. This is when the old and new tables are compatible, according to
1248
1262
        compare_table(). Then, we need one additional call to
1249
1263
      */
1250
 
      identifier::Table original_table_to_drop(original_table_identifier.getSchemaName(),
 
1264
      identifier::Table original_table_to_drop(session->catalog().identifier(),
 
1265
                                               original_table_identifier.getSchemaName(),
1251
1266
                                             old_name, create_proto.type() != message::Table::TEMPORARY ? message::Table::INTERNAL :
1252
1267
                                             message::Table::TEMPORARY);
1253
1268