1371
struct handlerton_delete_table_args {
1378
static bool deletetable_handlerton(Session *unused1 __attribute__((unused)),
1382
struct handlerton_delete_table_args *dtargs= (struct handlerton_delete_table_args *) args;
1384
Session *session= dtargs->session;
1385
const char *path= dtargs->path;
1388
char tmp_path[FN_REFLEN];
1390
if(dtargs->error!=ENOENT) /* already deleted table */
1393
handlerton *table_type= plugin_data(plugin, handlerton *);
1398
if(!(table_type->state == SHOW_OPTION_YES && table_type->create))
1401
if ((file= table_type->create(table_type, NULL, session->mem_root)))
1406
path= check_lowercase_names(file, path, tmp_path);
1407
int error= file->ha_delete_table(path);
1411
dtargs->error= error;
1413
delete dtargs->file;
1372
1422
This should return ENOENT if the file doesn't exists.
1373
1423
The .frm file will be deleted only if we return 0 or ENOENT
1375
int ha_delete_table(Session *session, handlerton *table_type, const char *path,
1425
int ha_delete_table(Session *session, const char *path,
1376
1426
const char *db, const char *alias, bool generate_warning)
1379
char tmp_path[FN_REFLEN];
1428
TABLE_SHARE dummy_share;
1381
1429
Table dummy_table;
1382
TABLE_SHARE dummy_share;
1431
struct handlerton_delete_table_args dtargs;
1432
dtargs.error= ENOENT;
1433
dtargs.session= session;
1437
plugin_foreach(NULL, deletetable_handlerton, DRIZZLE_STORAGE_ENGINE_PLUGIN,
1384
1440
memset(&dummy_table, 0, sizeof(dummy_table));
1385
1441
memset(&dummy_share, 0, sizeof(dummy_share));
1386
1442
dummy_table.s= &dummy_share;
1388
/* DB_TYPE_UNKNOWN is used in ALTER Table when renaming only .frm files */
1389
if (table_type == NULL ||
1390
! (file=get_new_handler((TABLE_SHARE*)0, session->mem_root, table_type)))
1393
path= check_lowercase_names(file, path, tmp_path);
1394
if ((error= file->ha_delete_table(path)) && generate_warning)
1444
if (dtargs.error && generate_warning)
1397
1447
Because file->print_error() use my_error() to generate the error message
1410
1460
dummy_share.table_name.length= strlen(alias);
1411
1461
dummy_table.alias= alias;
1463
handler *file= dtargs.file;
1413
1464
file->change_table_ptr(&dummy_table, &dummy_share);
1415
1466
session->push_internal_handler(&ha_delete_table_error_handler);
1416
file->print_error(error, 0);
1467
file->print_error(dtargs.error, 0);
1418
1469
session->pop_internal_handler();
1421
1472
XXX: should we convert *all* errors to warnings here?
1422
1473
What if the error is fatal?
1424
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, error,
1475
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR, dtargs.error,
1425
1476
ha_delete_table_error_handler.buff);
1482
return dtargs.error;
1431
1485
/****************************************************************************