361
361
bool foreign_key_error= false;
363
table::Cache::singleton().mutex().lock(); /* Part 2 of rm a table */
365
if (session->lock_table_names_exclusively(tables))
367
table::Cache::singleton().mutex().unlock();
371
/* Don't give warnings for not found errors, as we already generate notes */
372
session->no_warnings_for_error= 1;
374
for (table= tables; table; table= table->next_local)
376
const char *db=table->getSchemaName();
377
TableIdentifier identifier(table->getSchemaName(), table->getTableName());
379
plugin::StorageEngine *table_type;
381
error= session->drop_temporary_table(identifier);
385
// removed temporary table
389
tables->unlock_table_names();
364
table::Cache::singleton().mutex().lock(); /* Part 2 of rm a table */
366
if (session->lock_table_names_exclusively(tables))
390
368
table::Cache::singleton().mutex().unlock();
391
session->no_warnings_for_error= 0;
395
// temporary table not found
399
table_type= table->getDbType();
372
/* Don't give warnings for not found errors, as we already generate notes */
373
session->no_warnings_for_error= 1;
375
for (table= tables; table; table= table->next_local)
403
abort_locked_tables(session, identifier);
404
table::Cache::singleton().removeTable(session, identifier,
405
RTFC_WAIT_OTHER_THREAD_FLAG |
406
RTFC_CHECK_KILLED_FLAG);
408
If the table was used in lock tables, remember it so that
409
unlock_table_names can free it
411
if ((locked_table= drop_locked_tables(session, identifier)))
412
table->table= locked_table;
414
if (session->getKilled())
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
417
390
tables->unlock_table_names();
418
391
table::Cache::singleton().mutex().unlock();
419
392
session->no_warnings_for_error= 0;
424
identifier.getPath();
426
if (table_type == NULL && not plugin::StorageEngine::doesTableExist(*session, identifier))
428
// Table was not found on disk and table can't be created from engine
429
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
430
ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR),
431
table->getTableName());
435
error= plugin::StorageEngine::dropTable(*session, identifier);
437
if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE))
440
session->clear_error();
443
if (error == HA_ERR_ROW_IS_REFERENCED)
445
/* the table is referenced by a foreign key constraint */
446
foreign_key_error= true;
450
if (error == 0 || (foreign_key_error == false))
452
transaction_services.dropTable(session, string(db), string(table->getTableName()), true);
457
if (wrong_tables.length())
458
wrong_tables.append(',');
459
wrong_tables.append(String(table->getTableName(),system_charset_info));
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();
463
It's safe to unlock table::Cache::singleton().mutex(): we have an exclusive lock
466
table::Cache::singleton().mutex().unlock();
468
471
if (wrong_tables.length())