~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Lee Bieber
  • Date: 2011-02-17 04:08:28 UTC
  • mfrom: (2172.3.5 drizzle-build)
  • Revision ID: kalebral@gmail.com-20110217040828-433pc76qapign1of
Merge Brian - add the DDL for replication

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
                   bool drop_temporary)
143
143
{
144
144
  TableList *table;
145
 
  String wrong_tables;
 
145
  util::string::vector wrong_tables;
146
146
  int error= 0;
147
147
  bool foreign_key_error= false;
148
148
 
198
198
      }
199
199
      identifier::Table identifier(table->getSchemaName(), table->getTableName(), table->getInternalTmpTable() ? message::Table::INTERNAL : message::Table::STANDARD);
200
200
 
 
201
      message::table::shared_ptr message= plugin::StorageEngine::getTableMessage(*session, identifier, true);
 
202
 
201
203
      if (drop_temporary || not plugin::StorageEngine::doesTableExist(*session, identifier))
202
204
      {
203
205
        // Table was not found on disk and table can't be created from engine
204
206
        if (if_exists)
 
207
        {
205
208
          push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
206
209
                              ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
207
210
                              table->getTableName());
 
211
        }
208
212
        else
209
213
        {
210
214
          error= 1;
217
221
        /* Generate transaction event ONLY when we successfully drop */ 
218
222
        if (plugin::StorageEngine::dropTable(*session, identifier, local_error))
219
223
        {
220
 
          TransactionServices &transaction_services= TransactionServices::singleton();
221
 
          transaction_services.dropTable(*session, identifier, if_exists);
 
224
          if (message) // If we have no definition, we don't know if the table should have been replicated
 
225
          {
 
226
            TransactionServices &transaction_services= TransactionServices::singleton();
 
227
            transaction_services.dropTable(*session, identifier, *message, if_exists);
 
228
          }
222
229
        }
223
230
        else
224
231
        {
239
246
 
240
247
      if (error)
241
248
      {
242
 
        if (wrong_tables.length())
243
 
          wrong_tables.append(',');
244
 
        wrong_tables.append(String(table->getTableName(), system_charset_info));
 
249
        wrong_tables.push_back(table->getTableName());
245
250
      }
246
251
    }
247
252
 
249
254
 
250
255
  } while (0);
251
256
 
252
 
  if (wrong_tables.length())
 
257
  if (wrong_tables.size())
253
258
  {
254
259
    if (not foreign_key_error)
255
260
    {
 
261
      std::string table_error;
 
262
 
 
263
      for (util::string::vector::iterator iter= wrong_tables.begin();
 
264
           iter != wrong_tables.end();
 
265
           iter++)
 
266
      {
 
267
        table_error+= *iter;
 
268
        table_error+= ',';
 
269
      }
 
270
      table_error.resize(table_error.size() -1);
 
271
 
256
272
      my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),
257
 
                      wrong_tables.c_ptr());
 
273
                      table_error.c_str());
258
274
    }
259
275
    else
260
276
    {