361
359
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))
368
table::Cache::singleton().mutex().unlock();
361
LOCK_open.lock(); /* Part 2 of rm a table */
363
if (lock_table_names_exclusively(session, tables))
369
/* Don't give warnings for not found errors, as we already generate notes */
370
session->no_warnings_for_error= 1;
372
for (table= tables; table; table= table->next_local)
374
const char *db=table->getSchemaName();
375
TableIdentifier identifier(table->getSchemaName(), table->getTableName());
377
plugin::StorageEngine *table_type;
379
error= session->drop_temporary_table(identifier);
383
// removed temporary table
387
unlock_table_names(tables, NULL);
389
session->no_warnings_for_error= 0;
393
// 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;
397
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
390
tables->unlock_table_names();
391
table::Cache::singleton().mutex().unlock();
401
abort_locked_tables(session, identifier);
402
table::Cache::singleton().removeTable(session, identifier,
403
RTFC_WAIT_OTHER_THREAD_FLAG |
404
RTFC_CHECK_KILLED_FLAG);
406
If the table was used in lock tables, remember it so that
407
unlock_table_names can free it
409
if ((locked_table= drop_locked_tables(session, identifier)))
410
table->table= locked_table;
415
unlock_table_names(tables, NULL);
392
417
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();
422
identifier.getPath();
424
if (table_type == NULL && not plugin::StorageEngine::doesTableExist(*session, identifier))
426
// Table was not found on disk and table can't be created from engine
427
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
428
ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
429
table->getTableName());
433
error= plugin::StorageEngine::dropTable(*session, identifier);
435
if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE))
438
session->clear_error();
441
if (error == HA_ERR_ROW_IS_REFERENCED)
443
/* the table is referenced by a foreign key constraint */
444
foreign_key_error= true;
448
if (error == 0 || (foreign_key_error == false))
450
transaction_services.dropTable(session, string(db), string(table->getTableName()), true);
455
if (wrong_tables.length())
456
wrong_tables.append(',');
457
wrong_tables.append(String(table->getTableName(),system_charset_info));
461
It's safe to unlock LOCK_open: we have an exclusive lock
471
466
if (wrong_tables.length())