remove handlerton::find_files (new implementation is coming),
and handlerton::table_exists_in_engine (new implementation is coming), and handlerton::license (redundant)
This commit is contained in:
parent
94753d8b94
commit
09ece94fac
@ -4371,96 +4371,6 @@ int ha_discover(THD *thd, const char *db, const char *name,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Call this function in order to give the handler the possiblity
|
||||
to ask engine if there are any new tables that should be written to disk
|
||||
or any dropped tables that need to be removed from disk
|
||||
*/
|
||||
struct st_find_files_args
|
||||
{
|
||||
const char *db;
|
||||
const char *path;
|
||||
const char *wild;
|
||||
bool dir;
|
||||
List<LEX_STRING> *files;
|
||||
};
|
||||
|
||||
static my_bool find_files_handlerton(THD *thd, plugin_ref plugin,
|
||||
void *arg)
|
||||
{
|
||||
st_find_files_args *vargs= (st_find_files_args *)arg;
|
||||
handlerton *hton= plugin_data(plugin, handlerton *);
|
||||
|
||||
|
||||
if (hton->state == SHOW_OPTION_YES && hton->find_files)
|
||||
if (hton->find_files(hton, thd, vargs->db, vargs->path, vargs->wild,
|
||||
vargs->dir, vargs->files))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
ha_find_files(THD *thd,const char *db,const char *path,
|
||||
const char *wild, bool dir, List<LEX_STRING> *files)
|
||||
{
|
||||
int error= 0;
|
||||
DBUG_ENTER("ha_find_files");
|
||||
DBUG_PRINT("enter", ("db: '%s' path: '%s' wild: '%s' dir: %d",
|
||||
db, path, wild, dir));
|
||||
st_find_files_args args= {db, path, wild, dir, files};
|
||||
|
||||
plugin_foreach(thd, find_files_handlerton,
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN, &args);
|
||||
/* The return value is not currently used */
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
/**
|
||||
Ask handler if the table exists in engine.
|
||||
@retval
|
||||
HA_ERR_NO_SUCH_TABLE Table does not exist
|
||||
@retval
|
||||
HA_ERR_TABLE_EXIST Table exists
|
||||
@retval
|
||||
\# Error code
|
||||
*/
|
||||
struct st_table_exists_in_engine_args
|
||||
{
|
||||
const char *db;
|
||||
const char *name;
|
||||
int err;
|
||||
};
|
||||
|
||||
static my_bool table_exists_in_engine_handlerton(THD *thd, plugin_ref plugin,
|
||||
void *arg)
|
||||
{
|
||||
st_table_exists_in_engine_args *vargs= (st_table_exists_in_engine_args *)arg;
|
||||
handlerton *hton= plugin_data(plugin, handlerton *);
|
||||
|
||||
int err= HA_ERR_NO_SUCH_TABLE;
|
||||
|
||||
if (hton->state == SHOW_OPTION_YES && hton->table_exists_in_engine)
|
||||
err = hton->table_exists_in_engine(hton, thd, vargs->db, vargs->name);
|
||||
|
||||
vargs->err = err;
|
||||
if (vargs->err == HA_ERR_TABLE_EXIST)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name)
|
||||
{
|
||||
DBUG_ENTER("ha_table_exists_in_engine");
|
||||
DBUG_PRINT("enter", ("db: %s, name: %s", db, name));
|
||||
st_table_exists_in_engine_args args= {db, name, HA_ERR_NO_SUCH_TABLE};
|
||||
plugin_foreach(thd, table_exists_in_engine_handlerton,
|
||||
MYSQL_STORAGE_ENGINE_PLUGIN, &args);
|
||||
DBUG_PRINT("exit", ("error: %d", args.err));
|
||||
DBUG_RETURN(args.err);
|
||||
}
|
||||
|
||||
#ifdef HAVE_NDB_BINLOG
|
||||
/*
|
||||
TODO: change this into a dynamic struct
|
||||
|
@ -1079,14 +1079,6 @@ struct handlerton
|
||||
const char *name,
|
||||
uchar **frmblob,
|
||||
size_t *frmlen);
|
||||
int (*find_files)(handlerton *hton, THD *thd,
|
||||
const char *db,
|
||||
const char *path,
|
||||
const char *wild, bool dir, List<LEX_STRING> *files);
|
||||
int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
|
||||
const char *name);
|
||||
|
||||
uint32 license; /* Flag for Engine License */
|
||||
/*
|
||||
Optional clauses in the CREATE/ALTER TABLE
|
||||
*/
|
||||
@ -3041,9 +3033,6 @@ bool ha_check_if_table_exists(THD* thd, const char *db, const char *name,
|
||||
bool *exists);
|
||||
int ha_discover(THD* thd, const char* dbname, const char* name,
|
||||
uchar** frmblob, size_t* frmlen);
|
||||
int ha_find_files(THD *thd,const char *db,const char *path,
|
||||
const char *wild, bool dir, List<LEX_STRING>* files);
|
||||
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name);
|
||||
|
||||
/* key cache */
|
||||
extern "C" int ha_init_key_cache(const char *name, KEY_CACHE *key_cache, void *);
|
||||
|
@ -833,8 +833,6 @@ find_files(THD *thd, List<LEX_STRING> *files, const char *db,
|
||||
DBUG_PRINT("info",("found: %d files", files->elements));
|
||||
my_dirend(dirp);
|
||||
|
||||
(void) ha_find_files(thd, db, path, wild, dir, files);
|
||||
|
||||
DBUG_RETURN(FIND_FILES_OK);
|
||||
}
|
||||
|
||||
@ -3889,13 +3887,6 @@ make_table_name_list(THD *thd, List<LEX_STRING> *table_names, LEX *lex,
|
||||
{
|
||||
if (table_names->push_back(&lookup_field_vals->table_value))
|
||||
return 1;
|
||||
/*
|
||||
Check that table is relevant in current transaction.
|
||||
(used for ndb engine, see ndbcluster_find_files(), ha_ndbcluster.cc)
|
||||
*/
|
||||
(void) ha_find_files(thd, db_name->str, path,
|
||||
lookup_field_vals->table_value.str, 0,
|
||||
table_names);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -4421,24 +4421,14 @@ bool mysql_create_table_no_lock(THD *thd,
|
||||
{
|
||||
bool create_if_not_exists =
|
||||
create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS;
|
||||
int retcode = ha_table_exists_in_engine(thd, db, table_name);
|
||||
DBUG_PRINT("info", ("exists_in_engine: %u",retcode));
|
||||
switch (retcode)
|
||||
bool exists_in_engine;
|
||||
ha_check_if_table_exists(thd, db, table_name, &exists_in_engine);
|
||||
if (exists_in_engine)
|
||||
{
|
||||
case HA_ERR_NO_SUCH_TABLE:
|
||||
/* Normal case, no table exists. we can go and create it */
|
||||
break;
|
||||
case HA_ERR_TABLE_EXIST:
|
||||
DBUG_PRINT("info", ("Table existed in handler"));
|
||||
|
||||
if (create_if_not_exists)
|
||||
goto warn;
|
||||
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
|
||||
goto err;
|
||||
default:
|
||||
DBUG_PRINT("info", ("error: %u from storage engine", retcode));
|
||||
my_error(retcode, MYF(0),table_name);
|
||||
goto err;
|
||||
if (create_if_not_exists)
|
||||
goto warn;
|
||||
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), table_name);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user