* move bas_ext from the handler to the handlerton

* provide a default bas_ext value of the empty list
This commit is contained in:
Sergei Golubchik 2013-04-07 17:08:49 +02:00
parent 09ece94fac
commit 58e62d701e
33 changed files with 86 additions and 262 deletions

View File

@ -78,6 +78,17 @@ static handler *partition_create_handler(handlerton *hton,
static uint partition_flags();
static uint alter_table_flags(uint flags);
/*
If frm_error() is called then we will use this to to find out what file
extensions exist for the storage engine. This is also used by the default
rename_table and delete_table method in handler.cc.
*/
static const char *ha_partition_ext[]=
{
ha_par_ext, NullS
};
static int partition_initialize(void *p)
{
@ -93,6 +104,7 @@ static int partition_initialize(void *p)
partition_hton->flags= HTON_NOT_USER_SELECTABLE |
HTON_HIDDEN |
HTON_TEMPORARY_NOT_SUPPORTED;
partition_hton->tablefile_extensions= ha_partition_ext;
return 0;
}
@ -7311,21 +7323,6 @@ int ha_partition::final_drop_index(TABLE *table_arg)
}
/*
If frm_error() is called then we will use this to to find out what file
extensions exist for the storage engine. This is also used by the default
rename_table and delete_table method in handler.cc.
*/
static const char *ha_partition_ext[]=
{
ha_par_ext, NullS
};
const char **ha_partition::bas_ext() const
{ return ha_partition_ext; }
uint ha_partition::min_of_the_max_uint(
uint (handler::*operator_func)(void) const) const
{

View File

@ -882,10 +882,6 @@ public:
the ha_partition_hton cannot know all its capabilities
*/
virtual uint alter_table_flags(uint flags);
/*
extensions of table handler files
*/
virtual const char **bas_ext() const;
/*
unireg.cc will call the following to make sure that the storage engine
can handle the data it is about to send.

View File

@ -443,11 +443,13 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
int ha_initialize_handlerton(st_plugin_int *plugin)
{
handlerton *hton;
static const char *no_exts[]= { 0 };
DBUG_ENTER("ha_initialize_handlerton");
DBUG_PRINT("plugin", ("initialize plugin: '%s'", plugin->name.str));
hton= (handlerton *)my_malloc(sizeof(handlerton),
MYF(MY_WME | MY_ZEROFILL));
hton->tablefile_extensions= no_exts;
if (hton == NULL)
{
@ -4719,26 +4721,20 @@ static my_bool exts_handlerton(THD *unused, plugin_ref plugin,
{
List<char> *found_exts= (List<char> *) arg;
handlerton *hton= plugin_data(plugin, handlerton *);
handler *file;
if (hton->state == SHOW_OPTION_YES && hton->create &&
(file= hton->create(hton, (TABLE_SHARE*) 0, current_thd->mem_root)))
List_iterator_fast<char> it(*found_exts);
const char **ext, *old_ext;
for (ext= hton->tablefile_extensions; *ext; ext++)
{
List_iterator_fast<char> it(*found_exts);
const char **ext, *old_ext;
for (ext= file->bas_ext(); *ext; ext++)
while ((old_ext= it++))
{
while ((old_ext= it++))
{
if (!strcmp(old_ext, *ext))
break;
}
if (!old_ext)
found_exts->push_back((char *) *ext);
it.rewind();
if (!strcmp(old_ext, *ext))
break;
}
delete file;
if (!old_ext)
found_exts->push_back((char *) *ext);
it.rewind();
}
return FALSE;
}

View File

@ -1086,6 +1086,7 @@ struct handlerton
ha_create_table_option *field_options; // these are specified per field
ha_create_table_option *index_options; // these are specified per index
const char **tablefile_extensions;
};
@ -2416,7 +2417,10 @@ public:
element - data file extention. This order is assumed by
prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.
*/
virtual const char **bas_ext() const =0;
const char **bas_ext() const
{
return ht->tablefile_extensions;
}
virtual int get_default_no_partitions(HA_CREATE_INFO *create_info)
{ return 1;}

View File

@ -2987,23 +2987,15 @@ void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg)
break;
case 2:
{
handler *file= 0;
const char *datext= "";
if (share->db_type() != NULL)
{
if ((file= get_new_handler(share, current_thd->mem_root,
share->db_type())))
{
if (!(datext= *file->bas_ext()))
datext= "";
}
}
if (share->db_type() && share->db_type()->tablefile_extensions[0])
datext= share->db_type()->tablefile_extensions[0];
err_no= (db_errno == ENOENT) ? ER_FILE_NOT_FOUND : (db_errno == EAGAIN) ?
ER_FILE_USED : ER_CANT_OPEN_FILE;
strxmov(buff, share->normalized_path.str, datext, NullS);
my_error(err_no,errortype, buff, db_errno);
delete file;
break;
}
case 5:

View File

@ -199,6 +199,14 @@ static void init_archive_psi_keys(void)
TRUE Error
*/
/*
We just implement one additional file extension.
*/
static const char *ha_archive_exts[] = {
ARZ,
NullS
};
int archive_db_init(void *p)
{
DBUG_ENTER("archive_db_init");
@ -214,6 +222,7 @@ int archive_db_init(void *p)
archive_hton->create= archive_create_handler;
archive_hton->flags= HTON_NO_FLAGS;
archive_hton->discover= archive_discover;
archive_hton->tablefile_extensions= ha_archive_exts;
if (mysql_mutex_init(az_key_mutex_archive_mutex,
&archive_mutex, MY_MUTEX_INIT_FAST))
@ -530,20 +539,6 @@ int ha_archive::init_archive_reader()
}
/*
We just implement one additional file extension.
*/
static const char *ha_archive_exts[] = {
ARZ,
NullS
};
const char **ha_archive::bas_ext() const
{
return ha_archive_exts;
}
/*
When opening a file we:
Create/get our shared structure.

View File

@ -83,7 +83,6 @@ public:
{
}
const char *index_type(uint inx) { return "NONE"; }
const char **bas_ext() const;
ulonglong table_flags() const
{
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_CAN_BIT_FIELD |

View File

@ -52,15 +52,6 @@ ha_blackhole::ha_blackhole(handlerton *hton,
{}
static const char *ha_blackhole_exts[] = {
NullS
};
const char **ha_blackhole::bas_ext() const
{
return ha_blackhole_exts;
}
int ha_blackhole::open(const char *name, int mode, uint test_if_locked)
{
DBUG_ENTER("ha_blackhole::open");

View File

@ -51,7 +51,6 @@ public:
don't implement this method unless you really have indexes
*/
const char *index_type(uint key_number);
const char **bas_ext() const;
ulonglong table_flags() const
{
return(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |

View File

@ -369,16 +369,6 @@ ha_cassandra::ha_cassandra(handlerton *hton, TABLE_SHARE *table_arg)
{}
static const char *ha_cassandra_exts[] = {
NullS
};
const char **ha_cassandra::bas_ext() const
{
return ha_cassandra_exts;
}
int ha_cassandra::connect_and_check_options(TABLE *table_arg)
{
ha_table_option_struct *options= table_arg->s->option_struct;

View File

@ -131,11 +131,6 @@ public:
*/
const char *index_type(uint inx) { return "HASH"; }
/** @brief
The file extensions.
*/
const char **bas_ext() const;
/** @brief
This is a list of flags that indicate what functionality the storage engine
implements. The current table flags are documented in handler.h

View File

@ -144,6 +144,16 @@ static void init_tina_psi_keys(void)
}
#endif /* HAVE_PSI_INTERFACE */
/*
If frm_error() is called in table.cc this is called to find out what file
extensions exist for this handler.
*/
static const char *ha_tina_exts[] = {
CSV_EXT,
CSM_EXT,
NullS
};
static int tina_init_func(void *p)
{
handlerton *tina_hton;
@ -161,6 +171,7 @@ static int tina_init_func(void *p)
tina_hton->create= tina_create_handler;
tina_hton->flags= (HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES |
HTON_NO_PARTITION);
tina_hton->tablefile_extensions= ha_tina_exts;
return 0;
}
@ -832,21 +843,6 @@ err:
DBUG_RETURN(error);
}
/*
If frm_error() is called in table.cc this is called to find out what file
extensions exist for this handler.
*/
static const char *ha_tina_exts[] = {
CSV_EXT,
CSM_EXT,
NullS
};
const char **ha_tina::bas_ext() const
{
return ha_tina_exts;
}
/*
Three functions below are needed to enable concurrent insert functionality
for CSV engine. For more details see mysys/thr_lock.c
@ -1771,23 +1767,6 @@ bool ha_tina::check_if_incompatible_data(HA_CREATE_INFO *info,
struct st_mysql_storage_engine csv_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
mysql_declare_plugin(csv)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&csv_storage_engine,
"CSV",
"Brian Aker, MySQL AB",
"CSV storage engine",
PLUGIN_LICENSE_GPL,
tina_init_func, /* Plugin Init */
tina_done_func, /* Plugin Deinit */
0x0100 /* 1.0 */,
NULL, /* status variables */
NULL, /* system variables */
NULL, /* config options */
0, /* flags */
}
mysql_declare_plugin_end;
maria_declare_plugin(csv)
{
MYSQL_STORAGE_ENGINE_PLUGIN,

View File

@ -103,7 +103,6 @@ public:
free_root(&blobroot, MYF(0));
}
const char *index_type(uint inx) { return "NONE"; }
const char **bas_ext() const;
ulonglong table_flags() const
{
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_NO_AUTO_INCREMENT |

View File

@ -229,6 +229,27 @@ static void init_example_psi_keys()
#endif
/**
@brief
If frm_error() is called then we will use this to determine
the file extensions that exist for the storage engine. This is also
used by the default rename_table and delete_table method in
handler.cc and by the default discover_many method.
For engines that have two file name extentions (separate meta/index file
and data file), the order of elements is relevant. First element of engine
file name extentions array should be meta/index file extention. Second
element - data file extention. This order is assumed by
prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.
@see
rename_table method in handler.cc and
delete_table method in handler.cc
*/
static const char *ha_example_exts[] = {
NullS
};
static int example_init_func(void *p)
{
DBUG_ENTER("example_init_func");
@ -247,6 +268,7 @@ static int example_init_func(void *p)
example_hton->flags= HTON_CAN_RECREATE;
example_hton->table_options= example_table_option_list;
example_hton->field_options= example_field_option_list;
example_hton->tablefile_extensions= ha_example_exts;
DBUG_RETURN(0);
}
@ -353,33 +375,6 @@ ha_example::ha_example(handlerton *hton, TABLE_SHARE *table_arg)
{}
/**
@brief
If frm_error() is called then we will use this to determine
the file extensions that exist for the storage engine. This is also
used by the default rename_table and delete_table method in
handler.cc.
For engines that have two file name extentions (separate meta/index file
and data file), the order of elements is relevant. First element of engine
file name extentions array should be meta/index file extention. Second
element - data file extention. This order is assumed by
prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.
@see
rename_table method in handler.cc and
delete_table method in handler.cc
*/
static const char *ha_example_exts[] = {
NullS
};
const char **ha_example::bas_ext() const
{
return ha_example_exts;
}
/**
@brief
Used for opening tables. The name will be the name of the file.

View File

@ -72,11 +72,6 @@ public:
*/
const char *index_type(uint inx) { return "HASH"; }
/** @brief
The file extensions.
*/
const char **bas_ext() const;
/** @brief
This is a list of flags that indicate what functionality the storage engine
implements. The current table flags are documented in handler.h

View File

@ -1615,21 +1615,6 @@ ha_rows ha_federated::records_in_range(uint inx, key_range *start_key,
DBUG_ENTER("ha_federated::records_in_range");
DBUG_RETURN(FEDERATED_RECORDS_IN_RANGE);
}
/*
If frm_error() is called then we will use this to to find out
what file extentions exist for the storage engine. This is
also used by the default rename_table and delete_table method
in handler.cc.
*/
const char **ha_federated::bas_ext() const
{
static const char *ext[]=
{
NullS
};
return ext;
}
/*

View File

@ -134,7 +134,6 @@ public:
*/
// perhaps get index type
const char *index_type(uint inx) { return "REMOTE"; }
const char **bas_ext() const;
/*
This is a list of flags that says what the storage engine
implements. The current table flags are documented in

View File

@ -1719,22 +1719,6 @@ ha_rows ha_federatedx::records_in_range(uint inx, key_range *start_key,
DBUG_ENTER("ha_federatedx::records_in_range");
DBUG_RETURN(FEDERATEDX_RECORDS_IN_RANGE);
}
/*
If frm_error() is called then we will use this to to find out
what file extentions exist for the storage engine. This is
also used by the default rename_table and delete_table method
in handler.cc.
*/
const char **ha_federatedx::bas_ext() const
{
static const char *ext[]=
{
NullS
};
return ext;
}
federatedx_txn *ha_federatedx::get_txn(THD *thd, bool no_create)
{

View File

@ -317,7 +317,6 @@ public:
*/
// perhaps get index type
const char *index_type(uint inx) { return "REMOTE"; }
const char **bas_ext() const;
/*
This is a list of flags that says what the storage engine
implements. The current table flags are documented in

View File

@ -75,16 +75,6 @@ ha_heap::ha_heap(handlerton *hton, TABLE_SHARE *table_arg)
internal_table(0)
{}
static const char *ha_heap_exts[] = {
NullS
};
const char **ha_heap::bas_ext() const
{
return ha_heap_exts;
}
/*
Hash index statistics is updated (copied from HP_KEYDEF::hash_buckets to
rec_per_key) after 1/HEAP_STATS_UPDATE_THRESHOLD fraction of table records

View File

@ -45,7 +45,6 @@ public:
}
/* Rows also use a fixed-size format */
enum row_type get_row_type() const { return ROW_TYPE_FIXED; }
const char **bas_ext() const;
ulonglong table_flags() const
{
return (HA_FAST_KEY_READ | HA_NO_BLOBS | HA_NULL_IN_KEY |

View File

@ -996,12 +996,6 @@ static const char *ha_maria_exts[]=
};
const char **ha_maria::bas_ext() const
{
return ha_maria_exts;
}
const char *ha_maria::index_type(uint key_number)
{
return ((table->key_info[key_number].flags & HA_FULLTEXT) ?
@ -3487,6 +3481,7 @@ static int ha_maria_init(void *p)
maria_hton->db_type= DB_TYPE_UNKNOWN;
maria_hton->create= maria_create_handler;
maria_hton->panic= maria_hton_panic;
maria_hton->tablefile_extensions= ha_maria_exts;
maria_hton->commit= maria_commit;
maria_hton->rollback= maria_rollback;
maria_hton->checkpoint_state= maria_checkpoint_state;

View File

@ -59,7 +59,6 @@ public:
~ha_maria() {}
handler *clone(const char *name, MEM_ROOT *mem_root);
const char *index_type(uint key_number);
const char **bas_ext() const;
ulonglong table_flags() const
{ return int_table_flags; }
ulong index_flags(uint inx, uint part, bool all_parts) const;

View File

@ -677,12 +677,6 @@ static const char *ha_myisam_exts[] = {
NullS
};
const char **ha_myisam::bas_ext() const
{
return ha_myisam_exts;
}
const char *ha_myisam::index_type(uint key_number)
{
return ((table->key_info[key_number].flags & HA_FULLTEXT) ?
@ -2209,6 +2203,7 @@ static int myisam_init(void *p)
myisam_hton->create= myisam_create_handler;
myisam_hton->panic= myisam_panic;
myisam_hton->flags= HTON_CAN_RECREATE | HTON_SUPPORT_LOG_TABLES;
myisam_hton->tablefile_extensions= ha_myisam_exts;
mi_killed= mi_killed_in_mariadb;
return 0;

View File

@ -54,7 +54,6 @@ class ha_myisam: public handler
~ha_myisam() {}
handler *clone(const char *name, MEM_ROOT *mem_root);
const char *index_type(uint key_number);
const char **bas_ext() const;
ulonglong table_flags() const { return int_table_flags; }
int index_init(uint idx, bool sorted);
int index_end();

View File

@ -171,12 +171,6 @@ extern "C" void myrg_print_wrong_table(const char *table_name)
}
const char **ha_myisammrg::bas_ext() const
{
return ha_myisammrg_exts;
}
const char *ha_myisammrg::index_type(uint key_number)
{
return ((table->key_info[key_number].flags & HA_FULLTEXT) ?
@ -1724,6 +1718,7 @@ static int myisammrg_init(void *p)
myisammrg_hton->create= myisammrg_create_handler;
myisammrg_hton->panic= myisammrg_panic;
myisammrg_hton->flags= HTON_NO_PARTITION;
myisammrg_hton->tablefile_extensions= ha_myisammrg_exts;
return 0;
}

View File

@ -82,7 +82,6 @@ public:
ha_myisammrg(handlerton *hton, TABLE_SHARE *table_arg);
~ha_myisammrg();
const char **bas_ext() const;
const char *index_type(uint key_number);
ulonglong table_flags() const
{

View File

@ -196,15 +196,6 @@ ha_perfschema::ha_perfschema(handlerton *hton, TABLE_SHARE *share)
ha_perfschema::~ha_perfschema()
{}
static const char *ha_pfs_exts[]= {
NullS
};
const char **ha_perfschema::bas_ext() const
{
return ha_pfs_exts;
}
int ha_perfschema::open(const char *name, int mode, uint test_if_locked)
{
DBUG_ENTER("ha_perfschema::open");

View File

@ -44,8 +44,6 @@ public:
const char *index_type(uint) { return ""; }
const char **bas_ext(void) const;
/** Capabilities of the performance schema tables. */
ulonglong table_flags(void) const
{

View File

@ -2005,9 +2005,6 @@ int CSphSEQuery::BuildRequest ( char ** ppBuffer )
// SPHINX HANDLER
//////////////////////////////////////////////////////////////////////////////
static const char * ha_sphinx_exts[] = { NullS };
#if MYSQL_VERSION_ID<50100
ha_sphinx::ha_sphinx ( TABLE_ARG * table )
: handler ( &sphinx_hton, table )
@ -2047,16 +2044,6 @@ ha_sphinx::~ha_sphinx()
}
}
// If frm_error() is called then we will use this to to find out what file extentions
// exist for the storage engine. This is also used by the default rename_table and
// delete_table method in handler.cc.
const char ** ha_sphinx::bas_ext() const
{
return ha_sphinx_exts;
}
// Used for opening tables. The name will be the name of the file.
// A table is opened when it needs to be opened. For instance
// when a request comes in for a select on the table (tables are not

View File

@ -57,7 +57,6 @@ public:
const char * table_type () const { return "SPHINX"; } ///< SE name for display purposes
const char * index_type ( uint ) { return "HASH"; } ///< index type name for display purposes
const char ** bas_ext () const; ///< my file extensions
#if MYSQL_VERSION_ID>50100
ulonglong table_flags () const { return HA_CAN_INDEX_BLOBS |

View File

@ -2560,6 +2560,13 @@ skip_overwrite:
}
/****************************************************************//**
Gives the file extension of an InnoDB single-table tablespace. */
static const char* ha_innobase_exts[] = {
".ibd",
NullS
};
/*********************************************************************//**
Opens an InnoDB database.
@return 0 on success, error code on failure */
@ -2608,6 +2615,7 @@ innobase_init(
innobase_hton->release_temporary_latches=innobase_release_temporary_latches;
innobase_hton->alter_table_flags = innobase_alter_table_flags;
innobase_hton->kill_query = innobase_kill_query;
innobase_hton->tablefile_extensions = ha_innobase_exts;
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
@ -4032,13 +4040,6 @@ ha_innobase::table_flags() const
return int_table_flags | HA_BINLOG_STMT_CAPABLE;
}
/****************************************************************//**
Gives the file extension of an InnoDB single-table tablespace. */
static const char* ha_innobase_exts[] = {
".ibd",
NullS
};
/****************************************************************//**
Returns the index type. */
UNIV_INTERN
@ -4051,17 +4052,6 @@ ha_innobase::index_type(
return("BTREE");
}
/****************************************************************//**
Returns the table file name extension.
@return file extension string */
UNIV_INTERN
const char**
ha_innobase::bas_ext() const
/*========================*/
{
return(ha_innobase_exts);
}
/****************************************************************//**
Returns the operations supported for indexes.
@return flags of supported operations */

View File

@ -125,7 +125,6 @@ class ha_innobase: public handler
enum row_type get_row_type() const;
const char* index_type(uint key_number);
const char** bas_ext() const;
Table_flags table_flags() const;
ulong index_flags(uint idx, uint part, bool all_parts) const;
uint max_supported_keys() const;