361
358
bool foreign_key_error= false;
364
table::Cache::singleton().mutex().lock(); /* Part 2 of rm a table */
366
if (session->lock_table_names_exclusively(tables))
360
table::Cache::singleton().mutex().lock(); /* Part 2 of rm a table */
362
if (session->lock_table_names_exclusively(tables))
364
table::Cache::singleton().mutex().unlock();
368
/* Don't give warnings for not found errors, as we already generate notes */
369
session->no_warnings_for_error= 1;
371
for (table= tables; table; table= table->next_local)
373
const char *db=table->getSchemaName();
374
TableIdentifier identifier(table->getSchemaName(), table->getTableName());
376
plugin::StorageEngine *table_type;
378
error= session->drop_temporary_table(identifier);
382
// removed temporary table
386
tables->unlock_table_names();
368
387
table::Cache::singleton().mutex().unlock();
388
session->no_warnings_for_error= 0;
392
// temporary table not found
372
/* Don't give warnings for not found errors, as we already generate notes */
373
session->no_warnings_for_error= 1;
396
table_type= table->getDbType();
375
for (table= tables; table; table= table->next_local)
377
const char *db=table->getSchemaName();
378
TableIdentifier identifier(table->getSchemaName(), table->getTableName());
380
plugin::StorageEngine *table_type;
382
error= session->drop_temporary_table(identifier);
386
// removed temporary table
400
abort_locked_tables(session, identifier);
401
table::Cache::singleton().removeTable(session, identifier,
402
RTFC_WAIT_OTHER_THREAD_FLAG |
403
RTFC_CHECK_KILLED_FLAG);
405
If the table was used in lock tables, remember it so that
406
unlock_table_names can free it
408
if ((locked_table= drop_locked_tables(session, identifier)))
409
table->table= locked_table;
411
if (session->getKilled())
390
414
tables->unlock_table_names();
391
415
table::Cache::singleton().mutex().unlock();
392
416
session->no_warnings_for_error= 0;
396
// temporary table not found
400
table_type= table->getDbType();
404
abort_locked_tables(session, identifier);
405
table::Cache::singleton().removeTable(session, identifier,
406
RTFC_WAIT_OTHER_THREAD_FLAG |
407
RTFC_CHECK_KILLED_FLAG);
409
If the table was used in lock tables, remember it so that
410
unlock_table_names can free it
412
if ((locked_table= drop_locked_tables(session, identifier)))
413
table->table= locked_table;
415
if (session->getKilled())
418
tables->unlock_table_names();
419
table::Cache::singleton().mutex().unlock();
420
session->no_warnings_for_error= 0;
425
identifier.getPath();
427
if (table_type == NULL && not plugin::StorageEngine::doesTableExist(*session, identifier))
429
// Table was not found on disk and table can't be created from engine
430
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
431
ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
432
table->getTableName());
436
error= plugin::StorageEngine::dropTable(*session, identifier);
438
if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE))
441
session->clear_error();
444
if (error == HA_ERR_ROW_IS_REFERENCED)
446
/* the table is referenced by a foreign key constraint */
447
foreign_key_error= true;
451
if (error == 0 || (foreign_key_error == false))
453
transaction_services.dropTable(session, string(db), string(table->getTableName()), true);
458
if (wrong_tables.length())
459
wrong_tables.append(',');
460
wrong_tables.append(String(table->getTableName(),system_charset_info));
464
It's safe to unlock table::Cache::singleton().mutex(): we have an exclusive lock
467
table::Cache::singleton().mutex().unlock();
421
identifier.getPath();
423
if (table_type == NULL && not plugin::StorageEngine::doesTableExist(*session, identifier))
425
// Table was not found on disk and table can't be created from engine
426
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
427
ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
428
table->getTableName());
432
error= plugin::StorageEngine::dropTable(*session, identifier);
434
if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE))
437
session->clear_error();
440
if (error == HA_ERR_ROW_IS_REFERENCED)
442
/* the table is referenced by a foreign key constraint */
443
foreign_key_error= true;
447
if (error == 0 || (foreign_key_error == false))
449
transaction_services.dropTable(session, string(db), string(table->getTableName()), true);
454
if (wrong_tables.length())
455
wrong_tables.append(',');
456
wrong_tables.append(String(table->getTableName(),system_charset_info));
460
It's safe to unlock table::Cache::singleton().mutex(): we have an exclusive lock
463
table::Cache::singleton().mutex().unlock();
471
465
if (wrong_tables.length())