Merge xiphis.org:/home/antony/work2/mysql-5.1

into  xiphis.org:/home/antony/work3/mysql-5.1-plugable-2


configure.in:
  Auto merged
mysql-test/r/bdb.result:
  Auto merged
mysql-test/r/information_schema.result:
  Auto merged
mysql-test/t/bdb.test:
  Auto merged
sql/Makefile.am:
  Auto merged
sql/ha_archive.cc:
  Auto merged
sql/ha_berkeley.cc:
  Auto merged
sql/ha_federated.cc:
  Auto merged
sql/ha_innodb.cc:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_partition.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/item_sum.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_cache.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_delete.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_partition.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
sql/table.h:
  Auto merged
sql/sql_table.cc:
  SCCS merged
This commit is contained in:
unknown 2005-12-21 10:26:39 -08:00
commit 5459c9709e
54 changed files with 1507 additions and 702 deletions

View file

@ -34,11 +34,14 @@ AC_CACHE_CHECK([whether to use $2], [mysql_cv_use_]m4_bpatsubst([$3], -, _),
[mysql_cv_use_]m4_bpatsubst([$3], -, _)=[$with_]m4_bpatsubst([$3], -, _))
AH_TEMPLATE([$5], [Build $2])
if test "[$mysql_cv_use_]m4_bpatsubst([$3], -, _)" != no; then
AC_DEFINE([$5])
mysql_se_decls="${mysql_se_decls},$6"
mysql_se_htons="${mysql_se_htons},&$6"
if test "$6" != "no"
then
AC_DEFINE([$5])
mysql_se_decls="${mysql_se_decls},$6"
mysql_se_htons="${mysql_se_htons},&$6"
mysql_se_objs="$mysql_se_objs $8"
fi
mysql_se_dirs="$mysql_se_dirs $7"
mysql_se_objs="$mysql_se_objs $8"
mysql_se_libs="$mysql_se_libs $9"
$10
fi

View file

@ -2432,9 +2432,14 @@ MYSQL_STORAGE_ENGINE(innobase,,innodb,,,,storage/innobase,ha_innodb.o,[ dnl
MYSQL_STORAGE_ENGINE(berkeley,,berkeley-db,,,,storage/bdb,,,[
MYSQL_SETUP_BERKELEY_DB
])
MYSQL_STORAGE_ENGINE(example)
MYSQL_STORAGE_ENGINE(example,,,,,no,storage/example,,,[
AC_CONFIG_FILES(storage/example/Makefile)
])
MYSQL_STORAGE_ENGINE(archive)
MYSQL_STORAGE_ENGINE(csv,,,,,tina_hton,,ha_tina.o)
dnl MYSQL_STORAGE_ENGINE(csv,,,,,tina_hton,,ha_tina.o)
MYSQL_STORAGE_ENGINE(csv,,,,,no,storage/csv,,,[
AC_CONFIG_FILES(storage/csv/Makefile)
])
MYSQL_STORAGE_ENGINE(blackhole)
MYSQL_STORAGE_ENGINE(federated)
MYSQL_STORAGE_ENGINE(ndbcluster,,ndbcluster,,,,storage/ndb,,,[

View file

@ -51,6 +51,7 @@ struct st_mysql_plugin
int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */
void *info; /* pointer to type-specific plugin descriptor */
const char *name; /* plugin name */
uint version; /* plugin version */
const char *author; /* plugin author (for SHOW PLUGINS) */
const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
int (*init)(void); /* the function to invoke when plugin is loaded */

View file

@ -285,6 +285,40 @@ n
4
5
6
set autocommit=0;
begin;
savepoint `my_savepoint`;
insert into t1 values (7);
savepoint `savept2`;
insert into t1 values (3);
select n from t1;
n
3
4
5
6
7
savepoint savept3;
rollback to savepoint savept2;
rollback to savepoint savept3;
ERROR 42000: SAVEPOINT savept3 does not exist
rollback to savepoint savept2;
release savepoint `my_savepoint`;
select n from t1;
n
4
5
6
7
rollback to savepoint `my_savepoint`;
ERROR 42000: SAVEPOINT my_savepoint does not exist
rollback to savepoint savept2;
ERROR 42000: SAVEPOINT savept2 does not exist
insert into t1 values (8);
savepoint sv;
commit;
savepoint sv;
set autocommit=1;
rollback;
drop table t1;
create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=BDB;

View file

@ -42,6 +42,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
KEY_COLUMN_USAGE
PLUGINS
ROUTINES
SCHEMATA
SCHEMA_PRIVILEGES
@ -723,7 +724,7 @@ CREATE TABLE t_crashme ( f1 BIGINT);
CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
count(*)
102
103
drop view a2, a1;
drop table t_crashme;
select table_schema,table_name, column_name from
@ -731,6 +732,7 @@ information_schema.columns
where data_type = 'longtext';
table_schema table_name column_name
information_schema COLUMNS COLUMN_TYPE
information_schema PLUGINS PLUGIN_DESCRIPTION
information_schema ROUTINES ROUTINE_DEFINITION
information_schema ROUTINES SQL_MODE
information_schema TRIGGERS ACTION_CONDITION
@ -793,7 +795,7 @@ delete from mysql.db where user='mysqltest_4';
flush privileges;
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
table_schema count(*)
information_schema 16
information_schema 17
mysql 18
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row

View file

@ -7,6 +7,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
KEY_COLUMN_USAGE
PLUGINS
ROUTINES
SCHEMATA
SCHEMA_PRIVILEGES

View file

@ -147,6 +147,32 @@ insert into t1 values (6);
-- error 1062
insert into t1 values (4);
select n from t1;
set autocommit=0;
#
# savepoints
#
begin;
savepoint `my_savepoint`;
insert into t1 values (7);
savepoint `savept2`;
insert into t1 values (3);
select n from t1;
savepoint savept3;
rollback to savepoint savept2;
--error 1305
rollback to savepoint savept3;
rollback to savepoint savept2;
release savepoint `my_savepoint`;
select n from t1;
-- error 1305
rollback to savepoint `my_savepoint`;
--error 1305
rollback to savepoint savept2;
insert into t1 values (8);
savepoint sv;
commit;
savepoint sv;
set autocommit=1;
# nop
rollback;
drop table t1;

View file

@ -102,9 +102,7 @@ EXTRA_mysqld_SOURCES = ha_innodb.cc ha_berkeley.cc ha_archive.cc \
ha_innodb.h ha_berkeley.h ha_archive.h \
ha_blackhole.cc ha_federated.cc ha_ndbcluster.cc \
ha_blackhole.h ha_federated.h ha_ndbcluster.h \
ha_partition.cc ha_partition.h \
examples/ha_tina.cc examples/ha_example.cc \
examples/ha_tina.h examples/ha_example.h
ha_partition.cc ha_partition.h
mysqld_DEPENDENCIES = @mysql_se_objs@
gen_lex_hash_SOURCES = gen_lex_hash.cc
gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)

View file

@ -62,7 +62,8 @@ struct show_table_authors_st show_table_authors[]= {
{ "Albert Chin-A-Young", "",
"Tru64 port, large file support, better TCP wrappers support" },
{ "Jorge del Conde", "Mexico City, Mexico", "Windows development" },
{ "Antony T. Curtis", "Norwalk, CA, USA", "Parser, port to OS/2" },
{ "Antony T. Curtis", "Norwalk, CA, USA",
"Parser, port to OS/2, storage engines and some random stuff" },
{ "Yuri Dario", "", "OS/2 port" },
{ "Sergei Golubchik", "Kerpen, Germany",
"Full-text search, precision math" },

View file

@ -140,6 +140,7 @@ static handler *archive_create_handler(TABLE_SHARE *table);
/* dummy handlerton - only to have something to return from archive_db_init */
handlerton archive_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"ARCHIVE",
SHOW_OPTION_YES,
"Archive storage engine",
@ -163,12 +164,9 @@ handlerton archive_hton = {
archive_create_handler, /* Create a new handler */
NULL, /* Drop a database */
archive_db_end, /* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_NO_FLAGS
};

View file

@ -116,20 +116,24 @@ static void update_status(BDB_SHARE *share, TABLE *table);
static int berkeley_close_connection(THD *thd);
static int berkeley_commit(THD *thd, bool all);
static int berkeley_rollback(THD *thd, bool all);
static int berkeley_rollback_to_savepoint(THD* thd, void *savepoint);
static int berkeley_savepoint(THD* thd, void *savepoint);
static int berkeley_release_savepoint(THD* thd, void *savepoint);
static handler *berkeley_create_handler(TABLE_SHARE *table);
handlerton berkeley_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"BerkeleyDB",
SHOW_OPTION_YES,
"Supports transactions and page-level locking",
DB_TYPE_BERKELEY_DB,
berkeley_init,
0, /* slot */
0, /* savepoint size */
sizeof(DB_TXN *), /* savepoint size */
berkeley_close_connection,
NULL, /* savepoint_set */
NULL, /* savepoint_rollback */
NULL, /* savepoint_release */
berkeley_savepoint, /* savepoint_set */
berkeley_rollback_to_savepoint, /* savepoint_rollback */
berkeley_release_savepoint, /* savepoint_release */
berkeley_commit,
berkeley_rollback,
NULL, /* prepare */
@ -142,12 +146,9 @@ handlerton berkeley_hton = {
berkeley_create_handler, /* Create a new handler */
NULL, /* Drop a database */
berkeley_end, /* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
berkeley_flush_logs, /* Flush logs */
berkeley_show_status, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME
};
@ -159,6 +160,7 @@ handler *berkeley_create_handler(TABLE_SHARE *table)
typedef struct st_berkeley_trx_data {
DB_TXN *all;
DB_TXN *stmt;
DB_TXN *sp_level;
uint bdb_lock_count;
} berkeley_trx_data;
@ -310,10 +312,53 @@ static int berkeley_rollback(THD *thd, bool all)
DBUG_RETURN(error);
}
static int berkeley_savepoint(THD* thd, void *savepoint)
{
int error;
DB_TXN **save_txn= (DB_TXN**) savepoint;
DBUG_ENTER("berkeley_savepoint");
berkeley_trx_data *trx=(berkeley_trx_data *)thd->ha_data[berkeley_hton.slot];
if (!(error= db_env->txn_begin(db_env, trx->sp_level, save_txn, 0)))
{
trx->sp_level= *save_txn;
}
DBUG_RETURN(error);
}
static int berkeley_rollback_to_savepoint(THD* thd, void *savepoint)
{
int error;
DB_TXN *parent, **save_txn= (DB_TXN**) savepoint;
DBUG_ENTER("berkeley_rollback_to_savepoint");
berkeley_trx_data *trx=(berkeley_trx_data *)thd->ha_data[berkeley_hton.slot];
parent= (*save_txn)->parent;
if (!(error= (*save_txn)->abort(*save_txn)))
{
trx->sp_level= parent;
error= berkeley_savepoint(thd, savepoint);
}
DBUG_RETURN(error);
}
static int berkeley_release_savepoint(THD* thd, void *savepoint)
{
int error;
DB_TXN *parent, **save_txn= (DB_TXN**) savepoint;
DBUG_ENTER("berkeley_release_savepoint");
berkeley_trx_data *trx=(berkeley_trx_data *)thd->ha_data[berkeley_hton.slot];
parent= (*save_txn)->parent;
if (!(error= (*save_txn)->commit(*save_txn,0)))
{
trx->sp_level= parent;
*save_txn= 0;
}
DBUG_RETURN(error);
}
static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
{
char **all_logs, **free_logs, **a, **f;
uint hton_name_len= strlen(berkeley_hton.name);
int error=1;
MEM_ROOT **root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
MEM_ROOT show_logs_root, *old_mem_root= *root_ptr;
@ -338,19 +383,20 @@ static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
{
for (a = all_logs, f = free_logs; *a; ++a)
{
const char *status;
if (f && *f && strcmp(*a, *f) == 0)
{
f++;
status= SHOW_LOG_STATUS_FREE;
if ((error= stat_print(thd, berkeley_hton.name, hton_name_len,
*a, strlen(*a),
STRING_WITH_LEN(SHOW_LOG_STATUS_FREE))))
break;
}
else
status= SHOW_LOG_STATUS_INUSE;
if (stat_print(thd, berkeley_hton.name, *a, status))
{
error=1;
goto err;
if ((error= stat_print(thd, berkeley_hton.name, hton_name_len,
*a, strlen(*a),
STRING_WITH_LEN(SHOW_LOG_STATUS_INUSE))))
break;
}
}
}
@ -1872,6 +1918,8 @@ int ha_berkeley::external_lock(THD *thd, int lock_type)
if (!trx)
DBUG_RETURN(1);
}
if (trx->all == 0)
trx->sp_level= 0;
if (lock_type != F_UNLCK)
{
if (!trx->bdb_lock_count++)
@ -1890,12 +1938,13 @@ int ha_berkeley::external_lock(THD *thd, int lock_type)
trx->bdb_lock_count--; // We didn't get the lock
DBUG_RETURN(error);
}
trx->sp_level= trx->all;
trans_register_ha(thd, TRUE, &berkeley_hton);
if (thd->in_lock_tables)
DBUG_RETURN(0); // Don't create stmt trans
}
DBUG_PRINT("trans",("starting transaction stmt"));
if ((error= db_env->txn_begin(db_env, trx->all, &trx->stmt, 0)))
if ((error= db_env->txn_begin(db_env, trx->sp_level, &trx->stmt, 0)))
{
/* We leave the possible master transaction open */
trx->bdb_lock_count--; // We didn't get the lock
@ -1949,7 +1998,7 @@ int ha_berkeley::start_stmt(THD *thd, thr_lock_type lock_type)
if (!trx->stmt)
{
DBUG_PRINT("trans",("starting transaction stmt"));
error= db_env->txn_begin(db_env, trx->all, &trx->stmt, 0);
error= db_env->txn_begin(db_env, trx->sp_level, &trx->stmt, 0);
trans_register_ha(thd, FALSE, &berkeley_hton);
}
transaction= trx->stmt;

View file

@ -30,6 +30,7 @@ static handler *blackhole_create_handler(TABLE_SHARE *table);
/* Blackhole storage engine handlerton */
handlerton blackhole_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"BLACKHOLE",
SHOW_OPTION_YES,
"/dev/null storage engine (anything you write to it disappears)",
@ -53,12 +54,9 @@ handlerton blackhole_hton= {
blackhole_create_handler, /* Create a new handler */
NULL, /* Drop a database */
NULL, /* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_CAN_RECREATE
};

View file

@ -367,6 +367,7 @@ static int federated_rollback(THD *thd, bool all);
/* Federated storage engine handlerton */
handlerton federated_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"FEDERATED",
SHOW_OPTION_YES,
"Federated MySQL storage engine",
@ -390,12 +391,9 @@ handlerton federated_hton= {
federated_create_handler, /* Create a new handler */
NULL, /* Drop a database */
federated_db_end, /* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_ALTER_NOT_SUPPORTED
};

View file

@ -27,6 +27,7 @@
static handler *heap_create_handler(TABLE_SHARE *table);
handlerton heap_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"MEMORY",
SHOW_OPTION_YES,
"Hash based, stored in memory, useful for temporary tables",
@ -50,12 +51,9 @@ handlerton heap_hton= {
heap_create_handler, /* Create a new handler */
NULL, /* Drop a database */
heap_panic, /* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_CAN_RECREATE
};

View file

@ -208,6 +208,7 @@ static int innobase_release_savepoint(THD* thd, void *savepoint);
static handler *innobase_create_handler(TABLE_SHARE *table);
handlerton innobase_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"InnoDB",
SHOW_OPTION_YES,
"Supports transactions, row-level locking, and foreign keys",
@ -231,16 +232,9 @@ handlerton innobase_hton = {
innobase_create_handler, /* Create a new handler */
innobase_drop_database, /* Drop a database */
innobase_end, /* Panic call */
innobase_release_temporary_latches, /* Release temporary latches */
innodb_export_status, /* Update Statistics */
innobase_start_trx_and_assign_read_view, /* Start Consistent Snapshot */
innobase_flush_logs, /* Flush logs */
innobase_show_status, /* Show status */
#ifdef HAVE_REPLICATION
innobase_repl_report_sent_binlog, /* Replication Report Sent Binlog */
#else
NULL,
#endif
HTON_NO_FLAGS
};
@ -1977,6 +1971,11 @@ innobase_repl_report_sent_binlog(
int cmp;
ibool can_release_threads = 0;
if (!innodb_inited) {
return 0;
}
/* If synchronous replication is not switched on, or this thd is
sending binlog to a slave where we do not need synchronous replication,
then return immediately */
@ -6481,10 +6480,11 @@ ha_innobase::transactional_table_lock(
Here we export InnoDB status variables to MySQL. */
int
innodb_export_status(void)
innodb_export_status()
/*======================*/
{
srv_export_innodb_status();
if (innodb_inited)
srv_export_innodb_status();
return 0;
}
@ -6571,7 +6571,8 @@ innodb_show_status(
bool result = FALSE;
if (stat_print(thd, innobase_hton.name, "", str)) {
if (stat_print(thd, innobase_hton.name, strlen(innobase_hton.name),
STRING_WITH_LEN(""), str, flen)) {
result= TRUE;
}
my_free(str, MYF(0));
@ -6596,6 +6597,7 @@ innodb_mutex_show_status(
ulint rw_lock_count_os_wait= 0;
ulint rw_lock_count_os_yield= 0;
ulonglong rw_lock_wait_time= 0;
uint hton_name_len= strlen(innobase_hton.name), buf1len, buf2len;
DBUG_ENTER("innodb_mutex_show_status");
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
@ -6610,16 +6612,17 @@ innodb_mutex_show_status(
{
if (mutex->count_using > 0)
{
my_snprintf(buf1, sizeof(buf1), "%s:%s",
mutex->cmutex_name, mutex->cfile_name);
my_snprintf(buf2, sizeof(buf2),
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
mutex->count_using, mutex->count_spin_loop,
mutex->count_spin_rounds,
mutex->count_os_wait, mutex->count_os_yield,
mutex->lspent_time/1000);
if (stat_print(thd, innobase_hton.name, buf1, buf2))
buf1len= my_snprintf(buf1, sizeof(buf1), "%s:%s",
mutex->cmutex_name, mutex->cfile_name);
buf2len= my_snprintf(buf2, sizeof(buf2),
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
mutex->count_using, mutex->count_spin_loop,
mutex->count_spin_rounds,
mutex->count_os_wait, mutex->count_os_yield,
mutex->lspent_time/1000);
if (stat_print(thd, innobase_hton.name, hton_name_len,
buf1, buf1len, buf2, buf2len))
{
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
mutex_exit(&mutex_list_mutex);
@ -6641,15 +6644,16 @@ innodb_mutex_show_status(
mutex = UT_LIST_GET_NEXT(list, mutex);
}
my_snprintf(buf2, sizeof(buf2),
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
rw_lock_count, rw_lock_count_spin_loop,
rw_lock_count_spin_rounds,
rw_lock_count_os_wait, rw_lock_count_os_yield,
rw_lock_wait_time/1000);
buf2len= my_snprintf(buf2, sizeof(buf2),
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
rw_lock_count, rw_lock_count_spin_loop,
rw_lock_count_spin_rounds,
rw_lock_count_os_wait, rw_lock_count_os_yield,
rw_lock_wait_time/1000);
if (stat_print(thd, innobase_hton.name, "rw_lock_mutexes", buf2))
if (stat_print(thd, innobase_hton.name, hton_name_len,
STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len))
{
DBUG_RETURN(1);
}

View file

@ -55,6 +55,7 @@ static handler *myisam_create_handler(TABLE_SHARE *table);
/* MyISAM handlerton */
handlerton myisam_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"MyISAM",
SHOW_OPTION_YES,
"Default engine as of MySQL 3.23 with great performance",
@ -82,12 +83,9 @@ handlerton myisam_hton= {
myisam_create_handler, /* Create a new handler */
NULL, /* Drop a database */
mi_panic,/* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_CAN_RECREATE
};

View file

@ -37,6 +37,7 @@ static handler *myisammrg_create_handler(TABLE_SHARE *table);
/* MyISAM MERGE handlerton */
handlerton myisammrg_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"MRG_MYISAM",
SHOW_OPTION_YES,
"Collection of identical MyISAM tables",
@ -60,12 +61,9 @@ handlerton myisammrg_hton= {
myisammrg_create_handler, /* Create a new handler */
NULL, /* Drop a database */
myrg_panic, /* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_CAN_RECREATE
};

View file

@ -59,6 +59,7 @@ static int ndbcluster_rollback(THD *thd, bool all);
static handler* ndbcluster_create_handler(TABLE_SHARE *table);
handlerton ndbcluster_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"ndbcluster",
SHOW_OPTION_YES,
"Clustered, fault-tolerant, memory-based tables",
@ -82,12 +83,9 @@ handlerton ndbcluster_hton = {
ndbcluster_create_handler, /* Create a new handler */
ndbcluster_drop_database, /* Drop a database */
ndbcluster_end, /* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
ndbcluster_show_status, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_NO_FLAGS
};
@ -8078,10 +8076,12 @@ ndbcluster_show_status(THD* thd, stat_print_fn *stat_print,
Ndb::Free_list_usage tmp; tmp.m_name= 0;
while (ndb->get_free_list_usage(&tmp))
{
my_snprintf(buf, sizeof(buf),
uint buflen=
my_snprintf(buf, sizeof(buf),
"created=%u, free=%u, sizeof=%u",
tmp.m_created, tmp.m_free, tmp.m_sizeof);
if (stat_print(thd, ndbcluster_hton.name, tmp.m_name, buf))
if (stat_print(thd, ndbcluster_hton.name, strlen(ndbcluster_hton.name),
tmp.m_name, strlen(tmp.m_name), buf, buflen))
DBUG_RETURN(TRUE);
}
}

View file

@ -69,6 +69,7 @@ static PARTITION_SHARE *get_share(const char *table_name, TABLE * table);
static handler *partition_create_handler(TABLE_SHARE *share);
handlerton partition_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"partition",
SHOW_OPTION_YES,
"Partition Storage Engine Helper", /* A comment used by SHOW to describe an engine */
@ -92,12 +93,9 @@ handlerton partition_hton = {
partition_create_handler, /* Create a new handler */
NULL, /* Drop a database */
NULL, /* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_NOT_USER_SELECTABLE
};
@ -697,6 +695,7 @@ bool ha_partition::create_handler_file(const char *name)
void ha_partition::clear_handler_file()
{
my_free((char*) m_file_buffer, MYF(MY_ALLOW_ZERO_PTR));
my_free((char*) m_engine_array, MYF(MY_ALLOW_ZERO_PTR));
m_file_buffer= NULL;
m_name_buffer_ptr= NULL;
m_engine_array= NULL;
@ -715,18 +714,19 @@ bool ha_partition::create_handlers()
for (i= 0; i < m_tot_parts; i++)
{
if (!(m_file[i]= get_new_handler(table_share, current_thd->mem_root,
(enum db_type) m_engine_array[i])))
m_engine_array[i])))
DBUG_RETURN(TRUE);
DBUG_PRINT("info", ("engine_type: %u", m_engine_array[i]));
}
m_file[m_tot_parts]= 0;
/* For the moment we only support partition over the same table engine */
if (m_engine_array[0] == (uchar) DB_TYPE_MYISAM)
if (m_engine_array[0] == &myisam_hton)
{
DBUG_PRINT("info", ("MyISAM"));
m_myisam= TRUE;
}
else if (m_engine_array[0] == (uchar) DB_TYPE_INNODB)
/* INNODB may not be compiled in... */
else if (ha_legacy_type(m_engine_array[0]) == DB_TYPE_INNODB)
{
DBUG_PRINT("info", ("InnoDB"));
m_innodb= TRUE;
@ -761,7 +761,7 @@ bool ha_partition::new_handlers_from_part_info()
if (!(m_file[i]= get_new_handler(table_share, thd->mem_root,
part_elem->engine_type)))
goto error;
DBUG_PRINT("info", ("engine_type: %u", (uint) part_elem->engine_type));
DBUG_PRINT("info", ("engine_type: %u", (uint) ha_legacy_type(part_elem->engine_type)));
if (m_is_sub_partitioned)
{
for (j= 0; j < m_part_info->no_subparts; j++)
@ -769,11 +769,11 @@ bool ha_partition::new_handlers_from_part_info()
if (!(m_file[i]= get_new_handler(table_share, thd->mem_root,
part_elem->engine_type)))
goto error;
DBUG_PRINT("info", ("engine_type: %u", (uint) part_elem->engine_type));
DBUG_PRINT("info", ("engine_type: %u", (uint) ha_legacy_type(part_elem->engine_type)));
}
}
} while (++i < m_part_info->no_parts);
if (part_elem->engine_type == DB_TYPE_MYISAM)
if (part_elem->engine_type == &myisam_hton)
{
DBUG_PRINT("info", ("MyISAM"));
m_myisam= TRUE;
@ -795,7 +795,7 @@ bool ha_partition::get_from_handler_file(const char *name)
char buff[FN_REFLEN], *address_tot_name_len;
File file;
char *file_buffer, *name_buffer_ptr;
uchar *engine_array;
handlerton **engine_array;
uint i, len_bytes, len_words, tot_partition_words, tot_name_words, chksum;
DBUG_ENTER("ha_partition::get_from_handler_file");
DBUG_PRINT("enter", ("table name: '%s'", name));
@ -824,7 +824,11 @@ bool ha_partition::get_from_handler_file(const char *name)
goto err2;
m_tot_parts= uint4korr((file_buffer) + 8);
tot_partition_words= (m_tot_parts + 3) / 4;
engine_array= (uchar *) ((file_buffer) + 12);
if (!(engine_array= (handlerton **) my_malloc(m_tot_parts * sizeof(handlerton*),MYF(0))))
goto err2;
for (i= 0; i < m_tot_parts; i++)
engine_array[i]= ha_resolve_by_legacy_type(current_thd,
(enum legacy_db_type) *(uchar *) ((file_buffer) + 12 + i));
address_tot_name_len= file_buffer + 12 + 4 * tot_partition_words;
tot_name_words= (uint4korr(address_tot_name_len) + 3) / 4;
if (len_words != (tot_partition_words + tot_name_words + 4))

View file

@ -46,7 +46,7 @@ private:
/* Data for the partition handler */
char *m_file_buffer; // Buffer with names
char *m_name_buffer_ptr; // Pointer to first partition name
uchar *m_engine_array; // Array of types of the handlers
handlerton **m_engine_array; // Array of types of the handlers
handler **m_file; // Array of references to handler inst.
partition_info *m_part_info; // local reference to partition
byte *m_start_key_ref; // Reference of start key in current

File diff suppressed because it is too large Load diff

View file

@ -178,7 +178,7 @@
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
#define MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
enum db_type
enum legacy_db_type
{
DB_TYPE_UNKNOWN=0,DB_TYPE_DIAB_ISAM=1,
DB_TYPE_HASH,DB_TYPE_MISAM,DB_TYPE_PISAM,
@ -191,7 +191,7 @@ enum db_type
DB_TYPE_BLACKHOLE_DB,
DB_TYPE_PARTITION_DB,
DB_TYPE_BINLOG,
DB_TYPE_DEFAULT // Must be last
DB_TYPE_DEFAULT=127 // Must be last
};
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
@ -315,8 +315,9 @@ typedef struct st_table TABLE;
typedef struct st_table_share TABLE_SHARE;
struct st_foreign_key_info;
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
typedef bool (stat_print_fn)(THD *thd, const char *type, const char *file,
const char *status);
typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
const char *file, uint file_len,
const char *status, uint status_len);
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
/*
@ -332,6 +333,13 @@ enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
*/
typedef struct
{
/*
handlerton structure version
*/
const int interface_version;
#define MYSQL_HANDLERTON_INTERFACE_VERSION 0x00000000
/*
storage engine name as it should be printed to a user
*/
@ -351,7 +359,7 @@ typedef struct
Historical number used for frm file to determine the correct storage engine.
This is going away and new engines will just use "name" for this.
*/
enum db_type db_type;
enum legacy_db_type db_type;
/*
Method that initizlizes a storage engine
*/
@ -416,19 +424,17 @@ typedef struct
handler *(*create)(TABLE_SHARE *table);
void (*drop_database)(char* path);
int (*panic)(enum ha_panic_function flag);
int (*release_temporary_latches)(THD *thd);
int (*update_statistics)();
int (*start_consistent_snapshot)(THD *thd);
bool (*flush_logs)();
bool (*show_status)(THD *thd, stat_print_fn *print, enum ha_stat_type stat);
int (*repl_report_sent_binlog)(THD *thd, char *log_file_name,
my_off_t end_offset);
uint32 flags; /* global handler flags */
} handlerton;
extern const handlerton default_hton;
struct show_table_alias_st {
const char *alias;
const char *type;
enum legacy_db_type type;
};
/* Possible flags of a handlerton */
@ -496,7 +502,7 @@ public:
char* part_comment;
char* data_file_name;
char* index_file_name;
enum db_type engine_type;
handlerton *engine_type;
enum partition_state part_state;
uint16 nodegroup_id;
@ -504,7 +510,7 @@ public:
: part_max_rows(0), part_min_rows(0), partition_name(NULL),
tablespace_name(NULL), range_value(0), part_comment(NULL),
data_file_name(NULL), index_file_name(NULL),
engine_type(DB_TYPE_UNKNOWN),part_state(PART_NORMAL),
engine_type(NULL),part_state(PART_NORMAL),
nodegroup_id(UNDEF_NODEGROUP)
{
subpartitions.empty();
@ -567,7 +573,7 @@ public:
key_map all_fields_in_PF, all_fields_in_PPF, all_fields_in_SPF;
key_map some_fields_in_PF;
enum db_type default_engine_type;
handlerton *default_engine_type;
Item_result part_result_type;
partition_type part_type;
partition_type subpart_type;
@ -608,7 +614,7 @@ public:
part_info_string(NULL),
part_func_string(NULL), subpart_func_string(NULL),
curr_part_elem(NULL), current_partition(NULL),
default_engine_type(DB_TYPE_UNKNOWN),
default_engine_type(NULL),
part_result_type(INT_RESULT),
part_type(NOT_A_PARTITION), subpart_type(NOT_A_PARTITION),
part_info_len(0), part_func_len(0), subpart_func_len(0),
@ -683,7 +689,7 @@ typedef struct st_ha_create_information
ulong raid_chunksize;
ulong used_fields;
SQL_LIST merge_list;
enum db_type db_type;
handlerton *db_type;
enum row_type row_type;
uint null_bits; /* NULL bits at start of record */
uint options; /* OR of HA_CREATE_ options */
@ -730,7 +736,7 @@ int get_parts_for_update(const byte *old_data, byte *new_data,
uint32 *old_part_id, uint32 *new_part_id);
int get_part_for_delete(const byte *buf, const byte *rec0,
partition_info *part_info, uint32 *part_id);
bool check_partition_info(partition_info *part_info,enum db_type eng_type,
bool check_partition_info(partition_info *part_info,handlerton *eng_type,
handler *file, ulonglong max_rows);
bool fix_partition_func(THD *thd, const char *name, TABLE *table);
char *generate_partition_syntax(partition_info *part_info,
@ -746,7 +752,7 @@ void get_full_part_id_from_key(const TABLE *table, byte *buf,
part_id_range *part_spec);
bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
uint part_info_len, TABLE *table,
enum db_type default_db_type);
handlerton *default_db_type);
#endif
@ -1416,32 +1422,56 @@ extern ulong total_ha, total_ha_2pc;
#define ha_rollback(thd) (ha_rollback_trans((thd), TRUE))
/* lookups */
enum db_type ha_resolve_by_name(const char *name, uint namelen);
const char *ha_get_storage_engine(enum db_type db_type);
handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name);
handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
const char *ha_get_storage_engine(enum legacy_db_type db_type);
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
enum db_type db_type);
enum db_type ha_checktype(THD *thd, enum db_type database_type,
handlerton *db_type);
handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
bool no_substitute, bool report_error);
bool ha_check_storage_engine_flag(enum db_type db_type, uint32 flag);
inline enum legacy_db_type ha_legacy_type(const handlerton *db_type)
{
return (db_type == NULL) ? DB_TYPE_UNKNOWN : db_type->db_type;
}
inline const char *ha_resolve_storage_engine_name(const handlerton *db_type)
{
return db_type == NULL ? "UNKNOWN" : db_type->name;
}
inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag)
{
return db_type == NULL ? FALSE : test(db_type->flags & flag);
}
inline bool ha_storage_engine_is_enabled(const handlerton *db_type)
{
return (db_type && db_type->create) ?
(db_type->state == SHOW_OPTION_YES) : FALSE;
}
/* basic stuff */
int ha_init(void);
int ha_register_builtin_plugins();
int ha_initialize_handlerton(handlerton *hton);
TYPELIB *ha_known_exts(void);
int ha_panic(enum ha_panic_function flag);
int ha_update_statistics();
void ha_close_connection(THD* thd);
my_bool ha_storage_engine_is_enabled(enum db_type database_type);
bool ha_flush_logs(enum db_type db_type=DB_TYPE_DEFAULT);
bool ha_flush_logs(handlerton *db_type);
void ha_drop_database(char* path);
int ha_create_table(THD *thd, const char *path,
const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
bool update_create_info);
int ha_delete_table(THD *thd, enum db_type db_type, const char *path,
int ha_delete_table(THD *thd, handlerton *db_type, const char *path,
const char *db, const char *alias, bool generate_warning);
/* statistics and info */
bool ha_show_status(THD *thd, enum db_type db_type, enum ha_stat_type stat);
bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat);
/* discovery */
int ha_create_table_from_engine(THD* thd, const char *db, const char *name);

View file

@ -2547,7 +2547,7 @@ bool Item_sum_count_distinct::setup(THD *thd)
table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows
table->no_rows=1;
if (table->s->db_type == DB_TYPE_HEAP)
if (table->s->db_type == &heap_hton)
{
/*
No blobs, otherwise it would have been MyISAM: set up a compare

View file

@ -48,6 +48,7 @@ static int binlog_rollback(THD *thd, bool all);
static int binlog_prepare(THD *thd, bool all);
handlerton binlog_hton = {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"binlog",
SHOW_OPTION_YES,
"This is a meta storage engine to represent the binlog in a transaction",
@ -71,12 +72,9 @@ handlerton binlog_hton = {
NULL, /* Create a new handler */
NULL, /* Drop a database */
NULL, /* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_NOT_USER_SELECTABLE | HTON_HIDDEN
};

View file

@ -607,7 +607,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables,
bool if_exists, bool drop_temporary,
bool log_query);
bool quick_rm_table(enum db_type base,const char *db,
bool quick_rm_table(handlerton *base,const char *db,
const char *table_name);
void close_cached_table(THD *thd, TABLE *table);
bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list);
@ -754,7 +754,7 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool do_send_ok);
bool mysql_create_like_table(THD *thd, TABLE_LIST *table,
HA_CREATE_INFO *create_info,
Table_ident *src_table);
bool mysql_rename_table(enum db_type base,
bool mysql_rename_table(handlerton *base,
const char *old_db,
const char * old_name,
const char *new_db,
@ -1005,7 +1005,7 @@ bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags);
int lock_tables(THD *thd, TABLE_LIST *tables, uint counter, bool *need_reopen);
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
const char *table_name, bool link_in_list);
bool rm_temporary_table(enum db_type base, char *path);
bool rm_temporary_table(handlerton *base, char *path);
void free_io_cache(TABLE *entry);
void intern_close_table(TABLE *entry);
bool close_thread_table(THD *thd, TABLE **table_ptr);
@ -1333,6 +1333,10 @@ extern handlerton partition_hton;
extern SHOW_COMP_OPTION have_partition_db;
#endif
extern handlerton myisam_hton;
extern handlerton myisammrg_hton;
extern handlerton heap_hton;
extern SHOW_COMP_OPTION have_isam;
extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink;
extern SHOW_COMP_OPTION have_query_cache;

View file

@ -2624,6 +2624,18 @@ static int init_common_variables(const char *conf_file_name, int argc,
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
if (plugin_init())
{
sql_print_error("Failed to init plugins.");
return 1;
}
if (ha_register_builtin_plugins())
{
sql_print_error("Failed to register built-in storage engines.");
return 1;
}
load_defaults(conf_file_name, groups, &argc, &argv);
defaults_argv=argv;
get_options(argc,argv);
@ -3107,17 +3119,15 @@ server.");
/*
Check that the default storage engine is actually available.
*/
if (!ha_storage_engine_is_enabled((enum db_type)
global_system_variables.table_type))
if (!ha_storage_engine_is_enabled(global_system_variables.table_type))
{
if (!opt_bootstrap)
{
sql_print_error("Default storage engine (%s) is not available",
ha_get_storage_engine((enum db_type)
global_system_variables.table_type));
global_system_variables.table_type->name);
unireg_abort(1);
}
global_system_variables.table_type= DB_TYPE_MYISAM;
global_system_variables.table_type= &myisam_hton;
}
tc_log= (total_ha_2pc > 1 ? (opt_bin_log ?
@ -3472,7 +3482,7 @@ we force server id to 2, but this MySQL server will not act as a slave.");
if (!opt_noacl)
{
plugin_init();
plugin_load();
#ifdef HAVE_DLOPEN
udf_init();
#endif
@ -6117,6 +6127,7 @@ struct show_var_st status_vars[]= {
{"Com_show_master_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_MASTER_STAT]), SHOW_LONG_STATUS},
{"Com_show_new_master", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_NEW_MASTER]), SHOW_LONG_STATUS},
{"Com_show_open_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_OPEN_TABLES]), SHOW_LONG_STATUS},
{"Com_show_plugins", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PLUGINS]), SHOW_LONG_STATUS},
{"Com_show_privileges", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PRIVILEGES]), SHOW_LONG_STATUS},
{"Com_show_processlist", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
{"Com_show_slave_hosts", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS},
@ -6427,7 +6438,7 @@ static void mysql_init_variables(void)
/* Set default values for some option variables */
global_system_variables.table_type= DB_TYPE_MYISAM;
global_system_variables.table_type= &myisam_hton;
global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
global_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
max_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
@ -6820,9 +6831,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break;
case OPT_STORAGE_ENGINE:
{
if ((enum db_type)((global_system_variables.table_type=
ha_resolve_by_name(argument, strlen(argument)))) ==
DB_TYPE_UNKNOWN)
LEX_STRING name= { argument, strlen(argument) };
if ((global_system_variables.table_type=
ha_resolve_by_name(current_thd, &name)) == NULL)
{
fprintf(stderr,"Unknown/unsupported table type: %s\n",argument);
exit(1);

View file

@ -3037,11 +3037,12 @@ bool sys_var_thd_storage_engine::check(THD *thd, set_var *var)
if (var->value->result_type() == STRING_RESULT)
{
enum db_type db_type;
LEX_STRING name;
handlerton *db_type;
if (!(res=var->value->val_str(&str)) ||
!(var->save_result.ulong_value=
(ulong) (db_type= ha_resolve_by_name(res->ptr(), res->length()))) ||
ha_checktype(thd, db_type, 1, 0) != db_type)
!(name.str= (char *)res->ptr()) || !(name.length= res->length()) ||
!(var->save_result.hton= db_type= ha_resolve_by_name(thd, &name)) ||
ha_checktype(thd, ha_legacy_type(db_type), 1, 0) != db_type)
{
value= res ? res->c_ptr() : "NULL";
goto err;
@ -3059,29 +3060,28 @@ err:
byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *base)
{
ulong val;
val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
thd->variables.*offset);
const char *table_type= ha_get_storage_engine((enum db_type)val);
return (byte *) table_type;
handlerton *val;
val= (type == OPT_GLOBAL) ? global_system_variables.*offset :
thd->variables.*offset;
return (byte *) val->name;
}
void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
global_system_variables.*offset= (ulong) DB_TYPE_MYISAM;
global_system_variables.*offset= &myisam_hton;
else
thd->variables.*offset= (ulong) (global_system_variables.*offset);
thd->variables.*offset= global_system_variables.*offset;
}
bool sys_var_thd_storage_engine::update(THD *thd, set_var *var)
{
if (var->type == OPT_GLOBAL)
global_system_variables.*offset= var->save_result.ulong_value;
else
thd->variables.*offset= var->save_result.ulong_value;
handlerton **value= &(global_system_variables.*offset);
if (var->type != OPT_GLOBAL)
value= &(thd->variables.*offset);
*value= var->save_result.hton;
return 0;
}

View file

@ -379,9 +379,9 @@ public:
class sys_var_thd_storage_engine :public sys_var_thd
{
protected:
ulong SV::*offset;
handlerton *SV::*offset;
public:
sys_var_thd_storage_engine(const char *name_arg, ulong SV::*offset_arg)
sys_var_thd_storage_engine(const char *name_arg, handlerton *SV::*offset_arg)
:sys_var_thd(name_arg), offset(offset_arg)
{}
bool check(THD *thd, set_var *var);
@ -398,7 +398,7 @@ SHOW_TYPE type() { return SHOW_CHAR; }
class sys_var_thd_table_type :public sys_var_thd_storage_engine
{
public:
sys_var_thd_table_type(const char *name_arg, ulong SV::*offset_arg)
sys_var_thd_table_type(const char *name_arg, handlerton *SV::*offset_arg)
:sys_var_thd_storage_engine(name_arg, offset_arg)
{}
void warn_deprecated(THD *thd);
@ -812,6 +812,7 @@ public:
CHARSET_INFO *charset;
ulong ulong_value;
ulonglong ulonglong_value;
handlerton *hton;
DATE_TIME_FORMAT *date_time_format;
Time_zone *time_zone;
} save_result;

View file

@ -1433,7 +1433,7 @@ void close_temporary_table(THD *thd, TABLE *table,
void close_temporary(TABLE *table, bool free_share, bool delete_table)
{
db_type table_type= table->s->db_type;
handlerton *table_type= table->s->db_type;
DBUG_ENTER("close_temporary");
free_io_cache(table);
@ -1802,7 +1802,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
*/
{
char path[FN_REFLEN];
db_type not_used;
enum legacy_db_type not_used;
strxnmov(path, FN_REFLEN-1, mysql_data_home, "/", table_list->db, "/",
table_list->table_name, reg_ext, NullS);
(void) unpack_filename(path, path);
@ -3308,7 +3308,7 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
}
bool rm_temporary_table(enum db_type base, char *path)
bool rm_temporary_table(handlerton *base, char *path)
{
bool error=0;
handler *file;

View file

@ -2243,7 +2243,7 @@ Query_cache::register_tables_from_list(TABLE_LIST *tables_used,
tables_used->engine_data))
DBUG_RETURN(0);
if (tables_used->table->s->db_type == DB_TYPE_MRG_MYISAM)
if (tables_used->table->s->db_type == &myisammrg_hton)
{
ha_myisammrg *handler = (ha_myisammrg *) tables_used->table->file;
MYRG_INFO *file = handler->myrg_info();
@ -2871,7 +2871,7 @@ static TABLE_COUNTER_TYPE process_and_count_tables(TABLE_LIST *tables_used,
"other non-cacheable table(s)"));
DBUG_RETURN(0);
}
if (tables_used->table->s->db_type == DB_TYPE_MRG_MYISAM)
if (tables_used->table->s->db_type == &myisammrg_hton)
{
ha_myisammrg *handler = (ha_myisammrg *)tables_used->table->file;
MYRG_INFO *file = handler->myrg_info();

View file

@ -526,7 +526,7 @@ struct system_variables
ulong read_rnd_buff_size;
ulong div_precincrement;
ulong sortbuff_size;
ulong table_type;
handlerton *table_type;
ulong tmp_table_size;
ulong tx_isolation;
ulong completion_type;

View file

@ -822,7 +822,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
/* If it is a temporary table, close and regenerate it */
if (!dont_send_ok && (table= find_temporary_table(thd, table_list)))
{
db_type table_type= table->s->db_type;
handlerton *table_type= table->s->db_type;
TABLE_SHARE *share= table->s;
if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE))
goto trunc_by_del;
@ -852,7 +852,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
if (!dont_send_ok)
{
db_type table_type;
enum legacy_db_type table_type;
mysql_frm_type(thd, path, &table_type);
if (table_type == DB_TYPE_UNKNOWN)
{
@ -860,7 +860,8 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
table_list->db, table_list->table_name);
DBUG_RETURN(TRUE);
}
if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE)
if (!ha_check_storage_engine_flag(ha_resolve_by_legacy_type(thd, table_type),
HTON_CAN_RECREATE)
|| thd->lex->sphead)
goto trunc_by_del;
if (lock_and_wait_for_table_name(thd, table_list))

View file

@ -2527,7 +2527,7 @@ void select_create::abort()
if (table)
{
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
enum db_type table_type=table->s->db_type;
handlerton *table_type=table->s->db_type;
if (!table->s->tmp_table)
{
ulong version= table->s->version;

View file

@ -93,7 +93,7 @@ enum enum_sql_command {
SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
SQLCOM_INSTALL_PLUGIN, SQLCOM_UNINSTALL_PLUGIN,
SQLCOM_SHOW_AUTHORS,
SQLCOM_SHOW_AUTHORS, SQLCOM_SHOW_PLUGINS,
/* This should be the last !!! */
SQLCOM_END

View file

@ -6477,7 +6477,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
rotate_relay_log(active_mi);
pthread_mutex_unlock(&LOCK_active_mi);
#endif
if (ha_flush_logs())
if (ha_flush_logs(NULL))
result=1;
if (flush_error_log())
result=1;
@ -6793,7 +6793,7 @@ bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
HA_CREATE_INFO create_info;
DBUG_ENTER("mysql_create_index");
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type=DB_TYPE_DEFAULT;
create_info.db_type= (handlerton*) &default_hton;
create_info.default_table_charset= thd->variables.collation_database;
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
&create_info, table_list,
@ -6809,7 +6809,7 @@ bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info)
HA_CREATE_INFO create_info;
DBUG_ENTER("mysql_drop_index");
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type=DB_TYPE_DEFAULT;
create_info.db_type= (handlerton*) &default_hton;
create_info.default_table_charset= thd->variables.collation_database;
alter_info->clear();
alter_info->flags= ALTER_DROP_INDEX;

View file

@ -654,7 +654,7 @@ static bool set_up_default_partitions(partition_info *part_info,
partition_element *part_elem= new partition_element();
if (likely(part_elem != 0))
{
part_elem->engine_type= DB_TYPE_UNKNOWN;
part_elem->engine_type= NULL;
part_elem->partition_name= default_name;
default_name+=MAX_PART_NAME_SIZE;
part_info->partitions.push_back(part_elem);
@ -726,7 +726,7 @@ static bool set_up_default_subpartitions(partition_info *part_info,
partition_element *subpart_elem= new partition_element();
if (likely(subpart_elem != 0))
{
subpart_elem->engine_type= DB_TYPE_UNKNOWN;
subpart_elem->engine_type= NULL;
subpart_elem->partition_name= name_ptr;
name_ptr+= MAX_PART_NAME_SIZE;
part_elem->subpartitions.push_back(subpart_elem);
@ -786,7 +786,7 @@ bool set_up_defaults_for_partitioning(partition_info *part_info,
FALSE Ok, no mixed engines
*/
static bool check_engine_mix(u_char *engine_array, uint no_parts)
static bool check_engine_mix(handlerton **engine_array, uint no_parts)
{
/*
Current check verifies only that all handlers are the same.
@ -827,10 +827,10 @@ static bool check_engine_mix(u_char *engine_array, uint no_parts)
This code is used early in the CREATE TABLE and ALTER TABLE process.
*/
bool check_partition_info(partition_info *part_info,enum db_type eng_type,
bool check_partition_info(partition_info *part_info,handlerton *eng_type,
handler *file, ulonglong max_rows)
{
u_char *engine_array= NULL;
handlerton **engine_array= NULL;
uint part_count= 0, i, no_parts, tot_partitions;
bool result= TRUE;
List_iterator<partition_element> part_it(part_info->partitions);
@ -858,7 +858,8 @@ bool check_partition_info(partition_info *part_info,enum db_type eng_type,
my_error(ER_SAME_NAME_PARTITION, MYF(0));
goto end;
}
engine_array= (u_char*)my_malloc(tot_partitions, MYF(MY_WME));
engine_array= (handlerton**)my_malloc(tot_partitions * sizeof(handlerton *),
MYF(MY_WME));
if (unlikely(!engine_array))
goto end;
i= 0;
@ -868,10 +869,10 @@ bool check_partition_info(partition_info *part_info,enum db_type eng_type,
partition_element *part_elem= part_it++;
if (!is_sub_partitioned(part_info))
{
if (part_elem->engine_type == DB_TYPE_UNKNOWN)
if (part_elem->engine_type == NULL)
part_elem->engine_type= eng_type;
DBUG_PRINT("info", ("engine = %u",(uint)part_elem->engine_type));
engine_array[part_count++]= (u_char)part_elem->engine_type;
DBUG_PRINT("info", ("engine = %s", part_elem->engine_type->name));
engine_array[part_count++]= part_elem->engine_type;
}
else
{
@ -880,10 +881,10 @@ bool check_partition_info(partition_info *part_info,enum db_type eng_type,
do
{
part_elem= sub_it++;
if (part_elem->engine_type == DB_TYPE_UNKNOWN)
if (part_elem->engine_type == NULL)
part_elem->engine_type= eng_type;
DBUG_PRINT("info", ("engine = %u",(uint)part_elem->engine_type));
engine_array[part_count++]= (u_char)part_elem->engine_type;
DBUG_PRINT("info", ("engine = %s", part_elem->engine_type->name));
engine_array[part_count++]= part_elem->engine_type;
} while (++j < no_subparts);
}
} while (++i < part_info->no_parts);
@ -1950,9 +1951,9 @@ static int add_keyword_int(File fptr, const char *keyword, longlong num)
return err + add_space(fptr);
}
static int add_engine(File fptr, enum db_type engine_type)
static int add_engine(File fptr, handlerton *engine_type)
{
const char *engine_str= ha_get_storage_engine(engine_type);
const char *engine_str= engine_type->name;
int err= add_string(fptr, "ENGINE = ");
return err + add_string(fptr, engine_str);
return err;
@ -3147,7 +3148,7 @@ void get_partition_set(const TABLE *table, byte *buf, const uint index,
bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
uint part_info_len, TABLE* table,
enum db_type default_db_type)
handlerton *default_db_type)
{
Item *thd_free_list= thd->free_list;
bool result= TRUE;
@ -3184,7 +3185,7 @@ bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
part_info= lex.part_info;
table->part_info= part_info;
table->file->set_part_info(part_info);
if (part_info->default_engine_type == DB_TYPE_UNKNOWN)
if (part_info->default_engine_type == NULL)
part_info->default_engine_type= default_db_type;
else
{

View file

@ -33,7 +33,6 @@ static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM];
static rw_lock_t THR_LOCK_plugin;
static bool initialized= 0;
static struct st_plugin_dl *plugin_dl_find(LEX_STRING *dl)
{
uint i;
@ -348,6 +347,43 @@ void plugin_unlock(struct st_plugin_int *plugin)
}
static int plugin_initialize(struct st_plugin_int *plugin)
{
DBUG_ENTER("plugin_initialize");
if (plugin->plugin->init)
{
if (plugin->plugin->init())
{
sql_print_error("Plugin '%s' init function returned error.",
plugin->name.str);
DBUG_PRINT("warning", ("Plugin '%s' init function returned error.",
plugin->name.str))
goto err;
}
}
switch (plugin->plugin->type)
{
case MYSQL_STORAGE_ENGINE_PLUGIN:
if (ha_initialize_handlerton((handlerton*) plugin->plugin->info))
{
sql_print_error("Plugin '%s' handlerton init returned error.",
plugin->name.str);
DBUG_PRINT("warning", ("Plugin '%s' handlerton init returned error.",
plugin->name.str))
goto err;
}
break;
default:
break;
}
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
}
static void plugin_call_initializer(void)
{
uint i;
@ -356,20 +392,13 @@ static void plugin_call_initializer(void)
{
struct st_plugin_int *tmp= dynamic_element(&plugin_array, i,
struct st_plugin_int *);
if (tmp->state == PLUGIN_IS_UNINITIALIZED && tmp->plugin->init)
{
DBUG_PRINT("info", ("Initializing plugin: '%s'", tmp->name.str));
if (tmp->plugin->init())
{
sql_print_error("Plugin '%s' init function returned error.",
tmp->name.str);
DBUG_PRINT("warning", ("Plugin '%s' init function returned error.",
tmp->name.str))
plugin_del(&tmp->name);
}
}
if (tmp->state == PLUGIN_IS_UNINITIALIZED)
tmp->state= PLUGIN_IS_READY;
{
if (plugin_initialize(tmp))
plugin_del(&tmp->name);
else
tmp->state= PLUGIN_IS_READY;
}
}
DBUG_VOID_RETURN;
}
@ -410,42 +439,84 @@ static byte *get_hash_key(const byte *buff, uint *length,
}
void plugin_init(void)
int plugin_init(void)
{
int i;
DBUG_ENTER("plugin_init");
if (initialized)
DBUG_RETURN(0);
my_rwlock_init(&THR_LOCK_plugin, NULL);
if (my_init_dynamic_array(&plugin_dl_array,
sizeof(struct st_plugin_dl),16,16) ||
my_init_dynamic_array(&plugin_array,
sizeof(struct st_plugin_int),16,16))
goto err;
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
{
if (hash_init(&plugin_hash[i], system_charset_info, 16, 0, 0,
get_hash_key, NULL, 0))
goto err;
}
initialized= 1;
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
}
my_bool plugin_register_builtin(struct st_mysql_plugin *plugin)
{
struct st_plugin_int tmp;
DBUG_ENTER("plugin_register_builtin");
tmp.plugin= plugin;
tmp.name.str= (char *)plugin->name;
tmp.name.length= strlen(plugin->name);
tmp.state= PLUGIN_IS_UNINITIALIZED;
/* Cannot be unloaded */
tmp.ref_count= 1;
tmp.plugin_dl= 0;
if (insert_dynamic(&plugin_array, (gptr)&tmp))
DBUG_RETURN(1);
if (my_hash_insert(&plugin_hash[plugin->type],
(byte*)dynamic_element(&plugin_array,
plugin_array.elements - 1,
struct st_plugin_int *)))
DBUG_RETURN(1);
DBUG_RETURN(0);
}
void plugin_load(void)
{
TABLE_LIST tables;
TABLE *table;
READ_RECORD read_record_info;
int error, i;
MEM_ROOT mem;
DBUG_ENTER("plugin_init");
if (initialized)
DBUG_VOID_RETURN;
my_rwlock_init(&THR_LOCK_plugin, NULL);
THD *new_thd = new THD;
if (!new_thd ||
my_init_dynamic_array(&plugin_dl_array,sizeof(struct st_plugin_dl),16,16) ||
my_init_dynamic_array(&plugin_array,sizeof(struct st_plugin_int),16,16))
THD *new_thd;
DBUG_ENTER("plugin_load");
DBUG_ASSERT(initialized);
if (!(new_thd= new THD))
{
sql_print_error("Can't allocate memory for plugin structures");
delete new_thd;
delete_dynamic(&plugin_dl_array);
delete_dynamic(&plugin_array);
DBUG_VOID_RETURN;
}
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
{
if (hash_init(&plugin_hash[i], system_charset_info, 16, 0, 0,
get_hash_key, NULL, 0))
{
sql_print_error("Can't allocate memory for plugin structures");
delete new_thd;
delete_dynamic(&plugin_dl_array);
delete_dynamic(&plugin_array);
DBUG_VOID_RETURN;
}
}
init_sql_alloc(&mem, 1024, 0);
initialized= 1;
new_thd->thread_stack= (char*) &tables;
new_thd->store_globals();
new_thd->db= my_strdup("mysql", MYF(0));
@ -458,10 +529,6 @@ void plugin_init(void)
{
DBUG_PRINT("error",("Can't open plugin table"));
sql_print_error("Can't open the mysql.plugin table. Please run the mysql_install_db script to create it.");
delete_dynamic(&plugin_dl_array);
delete_dynamic(&plugin_array);
for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++)
hash_free(&plugin_hash[i]);
goto end;
}
table= tables.table;
@ -530,27 +597,31 @@ my_bool mysql_install_plugin(THD *thd, LEX_STRING *name, LEX_STRING *dl)
int error;
struct st_plugin_int *tmp;
DBUG_ENTER("mysql_install_plugin");
bzero(&tables, sizeof(tables));
tables.db= (char *)"mysql";
tables.table_name= tables.alias= (char *)"plugin";
if (check_table_access(thd, INSERT_ACL, &tables, 0))
DBUG_RETURN(TRUE);
/* need to open before acquiring THR_LOCK_plugin or it will deadlock */
if (! (table = open_ltable(thd, &tables, TL_WRITE)))
DBUG_RETURN(TRUE);
rw_wrlock(&THR_LOCK_plugin);
if (plugin_add(name, dl, REPORT_TO_USER))
goto err;
tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN);
if (tmp->plugin->init)
if (plugin_initialize(tmp))
{
if (tmp->plugin->init())
{
my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str,
"Plugin initialization function failed.");
goto err;
}
tmp->state= PLUGIN_IS_READY;
my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str,
"Plugin initialization function failed.");
goto err;
}
if (! (table = open_ltable(thd, &tables, TL_WRITE)))
goto deinit;
tmp->state= PLUGIN_IS_READY;
restore_record(table, s->default_values);
table->field[0]->store(name->str, name->length, system_charset_info);
table->field[1]->store(dl->str, dl->length, files_charset_info);
@ -560,6 +631,7 @@ my_bool mysql_install_plugin(THD *thd, LEX_STRING *name, LEX_STRING *dl)
table->file->print_error(error, MYF(0));
goto deinit;
}
rw_unlock(&THR_LOCK_plugin);
DBUG_RETURN(FALSE);
deinit:
@ -578,12 +650,29 @@ my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name)
TABLE_LIST tables;
struct st_plugin_int *plugin;
DBUG_ENTER("mysql_uninstall_plugin");
bzero(&tables, sizeof(tables));
tables.db= (char *)"mysql";
tables.table_name= tables.alias= (char *)"plugin";
/* need to open before acquiring THR_LOCK_plugin or it will deadlock */
if (! (table= open_ltable(thd, &tables, TL_WRITE)))
DBUG_RETURN(TRUE);
rw_wrlock(&THR_LOCK_plugin);
if (! (plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN)))
if (!(plugin= plugin_find_internal(name, MYSQL_ANY_PLUGIN)))
{
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str);
goto err;
}
if (!plugin->plugin_dl)
{
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
"Built-in plugins cannot be deleted,.");
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str);
goto err;
}
if (plugin->ref_count)
{
plugin->state= PLUGIN_IS_DELETED;
@ -596,11 +685,7 @@ my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name)
plugin->plugin->deinit();
plugin_del(name);
}
bzero(&tables, sizeof(tables));
tables.db= (char *)"mysql";
tables.table_name= tables.alias= (char *)"plugin";
if (! (table= open_ltable(thd, &tables, TL_WRITE)))
goto err;
table->field[0]->store(name->str, name->length, system_charset_info);
table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
if (! table->file->index_read_idx(table->record[0], 0,
@ -621,3 +706,44 @@ err:
rw_unlock(&THR_LOCK_plugin);
DBUG_RETURN(TRUE);
}
my_bool plugin_foreach(THD *thd, plugin_foreach_func *func,
int type, void *arg)
{
uint idx;
struct st_plugin_int *plugin;
DBUG_ENTER("mysql_uninstall_plugin");
rw_rdlock(&THR_LOCK_plugin);
if (type == MYSQL_ANY_PLUGIN)
{
for (idx= 0; idx < plugin_array.elements; idx++)
{
plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *);
/* FREED records may have garbage pointers */
if ((plugin->state != PLUGIN_IS_FREED) &&
func(thd, plugin, arg))
goto err;
}
}
else
{
HASH *hash= &plugin_hash[type];
for (idx= 0; idx < hash->records; idx++)
{
plugin= (struct st_plugin_int *) hash_element(hash, idx);
if ((plugin->state != PLUGIN_IS_FREED) &&
(plugin->state != PLUGIN_IS_DELETED) &&
func(thd, plugin, arg))
goto err;
}
}
rw_unlock(&THR_LOCK_plugin);
DBUG_RETURN(FALSE);
err:
rw_unlock(&THR_LOCK_plugin);
DBUG_RETURN(TRUE);
}

View file

@ -53,11 +53,20 @@ struct st_plugin_int
extern char *opt_plugin_dir_ptr;
extern char opt_plugin_dir[FN_REFLEN];
extern void plugin_init(void);
extern int plugin_init(void);
extern void plugin_load(void);
extern void plugin_free(void);
extern my_bool plugin_is_ready(LEX_STRING *name, int type);
extern st_plugin_int *plugin_lock(LEX_STRING *name, int type);
extern void plugin_unlock(struct st_plugin_int *plugin);
extern my_bool mysql_install_plugin(THD *thd, LEX_STRING *name, LEX_STRING *dl);
extern my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name);
extern my_bool plugin_register_builtin(struct st_mysql_plugin *plugin);
typedef my_bool (plugin_foreach_func)(THD *thd,
st_plugin_int *plugin,
void *arg);
extern my_bool plugin_foreach(THD *thd, plugin_foreach_func *func,
int type, void *arg);
#endif

View file

@ -134,7 +134,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
{
TABLE_LIST *ren_table,*new_table;
frm_type_enum frm_type;
db_type table_type;
enum legacy_db_type table_type;
DBUG_ENTER("rename_tables");
@ -176,7 +176,8 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
if (table_type == DB_TYPE_UNKNOWN)
my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
else
rc= mysql_rename_table(table_type, ren_table->db, old_alias,
rc= mysql_rename_table(ha_resolve_by_legacy_type(thd, table_type),
ren_table->db, old_alias,
new_table->db, new_alias);
break;
}

View file

@ -8637,7 +8637,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
OPTION_BIG_TABLES || (select_options & TMP_TABLE_FORCE_MYISAM))
{
table->file= get_new_handler(share, &table->mem_root,
share->db_type= DB_TYPE_MYISAM);
share->db_type= &myisam_hton);
if (group &&
(param->group_parts > table->file->max_key_parts() ||
param->group_length > table->file->max_key_length()))
@ -8646,7 +8646,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
else
{
table->file= get_new_handler(share, &table->mem_root,
share->db_type= DB_TYPE_HEAP);
share->db_type= &heap_hton);
}
if (!table->file)
goto err;
@ -8776,7 +8776,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
if (thd->variables.tmp_table_size == ~(ulong) 0) // No limit
share->max_rows= ~(ha_rows) 0;
else
share->max_rows= (((share->db_type == DB_TYPE_HEAP) ?
share->max_rows= (((share->db_type == &heap_hton) ?
min(thd->variables.tmp_table_size,
thd->variables.max_heap_table_size) :
thd->variables.tmp_table_size)/ share->reclength);
@ -8916,7 +8916,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
if (thd->is_fatal_error) // If end of memory
goto err; /* purecov: inspected */
share->db_record_offset= 1;
if (share->db_type == DB_TYPE_MYISAM)
if (share->db_type == &myisam_hton)
{
if (create_myisam_tmp_table(table,param,select_options))
goto err;
@ -9236,7 +9236,8 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
int write_err;
DBUG_ENTER("create_myisam_from_heap");
if (table->s->db_type != DB_TYPE_HEAP || error != HA_ERR_RECORD_FILE_FULL)
if (table->s->db_type != &heap_hton ||
error != HA_ERR_RECORD_FILE_FULL)
{
table->file->print_error(error,MYF(0));
DBUG_RETURN(1);
@ -9244,9 +9245,9 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
new_table= *table;
share= *table->s;
new_table.s= &share;
new_table.s->db_type= DB_TYPE_MYISAM;
new_table.s->db_type= &myisam_hton;
if (!(new_table.file= get_new_handler(&share, &new_table.mem_root,
DB_TYPE_MYISAM)))
&myisam_hton)))
DBUG_RETURN(1); // End of memory
save_proc_info=thd->proc_info;
@ -11685,7 +11686,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
free_io_cache(entry); // Safety
entry->file->info(HA_STATUS_VARIABLE);
if (entry->s->db_type == DB_TYPE_HEAP ||
if (entry->s->db_type == &heap_hton ||
(!entry->s->blob_fields &&
((ALIGN_SIZE(reclength) + HASH_OVERHEAD) * entry->file->records <
thd->variables.sortbuff_size)))

View file

@ -48,6 +48,32 @@ static bool schema_table_store_record(THD *thd, TABLE *table);
** List all table types supported
***************************************************************************/
static my_bool show_handlerton(THD *thd, st_plugin_int *plugin,
void *arg)
{
handlerton *default_type= (handlerton *) arg;
Protocol *protocol= thd->protocol;
handlerton *hton= (handlerton *) plugin->plugin->info;
if (!(hton->flags & HTON_HIDDEN))
{
protocol->prepare_for_resend();
protocol->store(hton->name, system_charset_info);
const char *option_name= show_comp_option_name[(int) hton->state];
if (hton->state == SHOW_OPTION_YES && default_type == hton)
option_name= "DEFAULT";
protocol->store(option_name, system_charset_info);
protocol->store(hton->comment, system_charset_info);
protocol->store(hton->commit ? "YES" : "NO", system_charset_info);
protocol->store(hton->prepare ? "YES" : "NO", system_charset_info);
protocol->store(hton->savepoint_set ? "YES" : "NO", system_charset_info);
return protocol->write() ? 1 : 0;
}
return 0;
}
bool mysqld_show_storage_engines(THD *thd)
{
List<Item> field_list;
@ -65,34 +91,126 @@ bool mysqld_show_storage_engines(THD *thd)
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
DBUG_RETURN(TRUE);
const char *default_type_name=
ha_get_storage_engine((enum db_type)thd->variables.table_type);
if (plugin_foreach(thd, show_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, thd->variables.table_type))
DBUG_RETURN(TRUE);
handlerton **types;
for (types= sys_table_types; *types; types++)
{
if (!((*types)->flags & HTON_HIDDEN))
{
protocol->prepare_for_resend();
protocol->store((*types)->name, system_charset_info);
const char *option_name= show_comp_option_name[(int) (*types)->state];
if ((*types)->state == SHOW_OPTION_YES &&
!my_strcasecmp(system_charset_info, default_type_name, (*types)->name))
option_name= "DEFAULT";
protocol->store(option_name, system_charset_info);
protocol->store((*types)->comment, system_charset_info);
protocol->store((*types)->commit ? "YES" : "NO", system_charset_info);
protocol->store((*types)->prepare ? "YES" : "NO", system_charset_info);
protocol->store((*types)->savepoint_set ? "YES" : "NO", system_charset_info);
if (protocol->write())
DBUG_RETURN(TRUE);
}
}
send_eof(thd);
DBUG_RETURN(FALSE);
}
static int make_version_string(char *buf, int buf_length, uint version)
{
return my_snprintf(buf, buf_length, "%d.%d.%d",
(version>>24)&0xff, (version>>16)&0xff,version&0xffff);
}
static my_bool show_plugins(THD *thd, st_plugin_int *plugin,
void *arg)
{
TABLE *table= (TABLE*) arg;
struct st_mysql_plugin *plug= plugin->plugin;
Protocol *protocol= thd->protocol;
CHARSET_INFO *cs= system_charset_info;
char version_buf[20];
restore_record(table, s->default_values);
table->field[0]->store(plugin->name.str, plugin->name.length, cs);
switch (plugin->state)
{
/* case PLUGIN_IS_FREED: does not happen */
case PLUGIN_IS_DELETED:
table->field[1]->store(STRING_WITH_LEN("DELETED"), cs);
break;
case PLUGIN_IS_UNINITIALIZED:
table->field[1]->store(STRING_WITH_LEN("INACTIVE"), cs);
break;
case PLUGIN_IS_READY:
table->field[1]->store(STRING_WITH_LEN("ACTIVE"), cs);
break;
default:
DBUG_ASSERT(0);
}
switch (plug->type)
{
case MYSQL_UDF_PLUGIN:
table->field[2]->store(STRING_WITH_LEN("UDF"), cs);
break;
case MYSQL_STORAGE_ENGINE_PLUGIN:
table->field[2]->store(STRING_WITH_LEN("STORAGE"), cs);
break;
case MYSQL_FTPARSER_PLUGIN:
table->field[2]->store(STRING_WITH_LEN("FTPARSER"), cs);
break;
default:
table->field[2]->store(STRING_WITH_LEN("UNKNOWN"), cs);
break;
}
if (plug->version)
{
table->field[3]->store(version_buf,
make_version_string(version_buf, sizeof(version_buf), plug->version),
cs);
table->field[3]->set_notnull();
}
else
table->field[3]->set_null();
if (plug->info)
{
table->field[4]->store(version_buf,
make_version_string(version_buf, sizeof(version_buf),
*(uint *)plug->info), cs);
table->field[4]->set_notnull();
}
else
table->field[4]->set_null();
if (plugin->plugin_dl)
{
table->field[5]->store(plugin->plugin_dl->dl.str,
plugin->plugin_dl->dl.length, cs);
table->field[5]->set_notnull();
}
else
table->field[5]->set_null();
if (plug->author)
{
table->field[6]->store(plug->author, strlen(plug->author), cs);
table->field[6]->set_notnull();
}
else
table->field[6]->set_null();
if (plug->descr)
{
table->field[7]->store(plug->descr, strlen(plug->descr), cs);
table->field[7]->set_notnull();
}
else
table->field[7]->set_null();
return schema_table_store_record(thd, table);
}
int fill_plugins(THD *thd, TABLE_LIST *tables, COND *cond)
{
DBUG_ENTER("fill_plugins");
TABLE *table= tables->table;
if (plugin_foreach(thd, show_plugins, MYSQL_ANY_PLUGIN, table))
DBUG_RETURN(1);
DBUG_RETURN(0);
}
/***************************************************************************
** List all Authors.
** If you can update it, you get to be in it :)
@ -999,8 +1117,8 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
packet->append(STRING_WITH_LEN(" ENGINE="));
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (table->part_info)
packet->append(ha_get_storage_engine(table->part_info->
default_engine_type));
packet->append(ha_resolve_storage_engine_name(
table->part_info->default_engine_type));
else
packet->append(file->table_type());
#else
@ -2084,7 +2202,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
Security_context *sctx= thd->security_ctx;
uint derived_tables= lex->derived_tables;
int error= 1;
db_type not_used;
enum legacy_db_type not_used;
Open_tables_state open_tables_state_backup;
DBUG_ENTER("get_all_tables");
@ -4172,6 +4290,20 @@ ST_FIELD_INFO variables_fields_info[]=
};
ST_FIELD_INFO plugin_fields_info[]=
{
{"PLUGIN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Name"},
{"PLUGIN_STATUS", 10, MYSQL_TYPE_STRING, 0, 0, "Status"},
{"PLUGIN_TYPE", 10, MYSQL_TYPE_STRING, 0, 0, "Type"},
{"PLUGIN_VERSION", 20, MYSQL_TYPE_STRING, 0, 1, 0},
{"PLUGIN_TYPE_VERSION", 20, MYSQL_TYPE_STRING, 0, 1, 0},
{"PLUGIN_LIBRARY", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Library"},
{"PLUGIN_AUTHOR", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{"PLUGIN_DESCRIPTION", 65535, MYSQL_TYPE_STRING, 0, 1, 0},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
};
/*
Description of ST_FIELD_INFO in table.h
*/
@ -4192,6 +4324,8 @@ ST_SCHEMA_TABLE schema_tables[]=
get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
{"OPEN_TABLES", open_tables_fields_info, create_schema_table,
fill_open_tables, make_old_format, 0, -1, -1, 1},
{"PLUGINS", plugin_fields_info, create_schema_table,
fill_plugins, make_old_format, 0, -1, -1, 0},
{"ROUTINES", proc_fields_info, create_schema_table,
fill_schema_proc, make_proc_old_format, 0, -1, -1, 0},
{"SCHEMATA", schema_fields_info, create_schema_table,

View file

@ -27,7 +27,6 @@
#include <io.h>
#endif
const char *primary_key_name="PRIMARY";
static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end);
@ -40,7 +39,7 @@ static int copy_data_between_tables(TABLE *from,TABLE *to,
ha_rows *copied,ha_rows *deleted);
static bool prepare_blob_field(THD *thd, create_field *sql_field);
static bool check_engine(THD *thd, const char *table_name,
enum db_type *new_engine);
handlerton **new_engine);
/*
SYNOPSIS
@ -290,7 +289,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
for (table= tables; table; table= table->next_local)
{
TABLE_SHARE *share;
table->db_type= DB_TYPE_UNKNOWN;
table->db_type= NULL;
if ((share= get_cached_table_share(table->db, table->table_name)))
table->db_type= share->db_type;
}
@ -304,7 +303,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
for (table= tables; table; table= table->next_local)
{
char *db=table->db;
db_type table_type;
handlerton *table_type;
enum legacy_db_type frm_db_type;
mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL, TRUE);
if (!close_temporary_table(thd, table))
@ -331,12 +331,12 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
/* remove .frm file and engine files */
build_table_path(path, sizeof(path), db, alias, reg_ext);
}
if (table_type == DB_TYPE_UNKNOWN &&
if (table_type == NULL &&
(drop_temporary ||
(access(path, F_OK) &&
ha_create_table_from_engine(thd, db, alias)) ||
(!drop_view &&
mysql_frm_type(thd, path, &table_type) != FRMTYPE_TABLE)))
mysql_frm_type(thd, path, &frm_db_type) != FRMTYPE_TABLE)))
{
// Table was not found on disk and table can't be created from engine
if (if_exists)
@ -349,13 +349,16 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
else
{
char *end;
if (table_type == DB_TYPE_UNKNOWN)
mysql_frm_type(thd, path, &table_type);
if (table_type == NULL)
{
mysql_frm_type(thd, path, &frm_db_type);
table_type= ha_resolve_by_legacy_type(thd, frm_db_type);
}
*(end=fn_ext(path))=0; // Remove extension for delete
error= ha_delete_table(thd, table_type, path, db, table->table_name,
!dont_log_query);
if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) &&
(if_exists || table_type == DB_TYPE_UNKNOWN))
(if_exists || table_type == NULL))
error= 0;
if (error == HA_ERR_ROW_IS_REFERENCED)
{
@ -413,7 +416,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
bool quick_rm_table(enum db_type base,const char *db,
bool quick_rm_table(handlerton *base,const char *db,
const char *table_name)
{
char path[FN_REFLEN];
@ -1670,10 +1673,10 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
this information in the default_db_type variable, it is either
DB_TYPE_DEFAULT or the engine set in the ALTER TABLE command.
*/
enum db_type part_engine_type= create_info->db_type;
handlerton *part_engine_type= create_info->db_type;
char *part_syntax_buf;
uint syntax_len;
if (part_engine_type == DB_TYPE_PARTITION_DB)
if (part_engine_type == &partition_hton)
{
/*
This only happens at ALTER TABLE.
@ -1681,7 +1684,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
TABLE command.
*/
part_engine_type= ha_checktype(thd,
part_info->default_engine_type, 0, 0);
ha_legacy_type(part_info->default_engine_type), 0, 0);
}
else
{
@ -1702,7 +1705,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
part_info->part_info_string= part_syntax_buf;
part_info->part_info_len= syntax_len;
if ((!(file->partition_flags() & HA_CAN_PARTITION)) ||
create_info->db_type == DB_TYPE_PARTITION_DB)
create_info->db_type == &partition_hton)
{
/*
The handler assigned to the table cannot handle partitioning.
@ -1711,7 +1714,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
DBUG_PRINT("info", ("db_type: %d part_flag: %d",
create_info->db_type,file->partition_flags()));
delete file;
create_info->db_type= DB_TYPE_PARTITION_DB;
create_info->db_type= &partition_hton;
if (!(file= get_ha_partition(part_info)))
{
DBUG_RETURN(TRUE);
@ -1928,8 +1931,9 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
tmp_table.s->db_create_options=0;
tmp_table.s->blob_ptr_size= portable_sizeof_char_ptr;
tmp_table.s->db_low_byte_first= test(create_info->db_type == DB_TYPE_MYISAM ||
create_info->db_type == DB_TYPE_HEAP);
tmp_table.s->db_low_byte_first=
test(create_info->db_type == &myisam_hton ||
create_info->db_type == &heap_hton);
tmp_table.null_row=tmp_table.maybe_null=0;
while ((item=it++))
@ -2006,7 +2010,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
****************************************************************************/
bool
mysql_rename_table(enum db_type base,
mysql_rename_table(handlerton *base,
const char *old_db,
const char *old_name,
const char *new_db,
@ -2020,7 +2024,7 @@ mysql_rename_table(enum db_type base,
int error=0;
DBUG_ENTER("mysql_rename_table");
file= (base == DB_TYPE_UNKNOWN ? 0 :
file= (base == NULL ? 0 :
get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base));
build_table_path(from, sizeof(from), old_db, old_name, "");
@ -2861,7 +2865,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
char *src_table= table_ident->table.str;
int err;
bool res= TRUE;
db_type not_used;
enum legacy_db_type not_used;
TABLE_LIST src_tables_list;
DBUG_ENTER("mysql_create_like_table");
@ -3149,7 +3153,7 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
fields.push_back(c_fld);
}
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type=DB_TYPE_DEFAULT;
create_info.db_type= (handlerton*) &default_hton;
create_info.default_table_charset= thd->variables.collation_database;
db_options= 0;
if (mysql_prepare_table(thd, &create_info, &fields,
@ -3173,7 +3177,7 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
{
/* Re-initialize the create_info, which was changed by prepare table. */
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type=DB_TYPE_DEFAULT;
create_info.db_type= (handlerton*) &default_hton;
create_info.default_table_charset= thd->variables.collation_database;
/* Cleanup the fields list. We do not want to create existing fields. */
fields.delete_elements();
@ -3268,7 +3272,7 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list,
}
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type=DB_TYPE_DEFAULT;
create_info.db_type= (handlerton*) &default_hton;
create_info.default_table_charset= thd->variables.collation_database;
if ((drop_key)|| (drop.elements<= 0))
@ -3484,13 +3488,13 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
ha_rows copied,deleted;
ulonglong next_insert_id;
uint db_create_options, used_fields;
enum db_type old_db_type,new_db_type;
handlerton *old_db_type, *new_db_type;
uint need_copy_table= 0;
#ifdef WITH_PARTITION_STORAGE_ENGINE
bool online_add_empty_partition= FALSE;
bool online_drop_partition= FALSE;
bool partition_changed= FALSE;
enum db_type default_engine_type;
handlerton *default_engine_type;
#endif
DBUG_ENTER("mysql_alter_table");
@ -3567,7 +3571,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
old_db_type= table->s->db_type;
if (create_info->db_type == DB_TYPE_DEFAULT)
if (create_info->db_type == (handlerton*) &default_hton)
create_info->db_type= old_db_type;
#ifdef WITH_PARTITION_STORAGE_ENGINE
@ -3671,7 +3675,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
DBUG_RETURN(TRUE);
}
}
create_info->db_type= DB_TYPE_PARTITION_DB;
create_info->db_type= &partition_hton;
thd->lex->part_info= tab_part_info;
if (table->file->alter_table_flags() & HA_ONLINE_ADD_EMPTY_PARTITION &&
(tab_part_info->part_type == RANGE_PARTITION ||
@ -3903,7 +3907,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
partition_changed= TRUE;
tab_part_info->no_parts= tab_part_info->partitions.elements;
create_info->db_type= DB_TYPE_PARTITION_DB;
create_info->db_type= &partition_hton;
thd->lex->part_info= tab_part_info;
if (alter_info->flags == ALTER_ADD_PARTITION ||
alter_info->flags == ALTER_REORGANISE_PARTITION)
@ -3974,9 +3978,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
*/
if (thd->lex->part_info != table->part_info)
partition_changed= TRUE;
if (create_info->db_type != DB_TYPE_PARTITION_DB)
if (create_info->db_type != &partition_hton)
thd->lex->part_info->default_engine_type= create_info->db_type;
create_info->db_type= DB_TYPE_PARTITION_DB;
create_info->db_type= &partition_hton;
}
}
#endif
@ -4667,7 +4671,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
error=0;
if (!need_copy_table)
new_db_type=old_db_type=DB_TYPE_UNKNOWN; // this type cannot happen in regular ALTER
new_db_type=old_db_type= NULL; // this type cannot happen in regular ALTER
if (mysql_rename_table(old_db_type,db,table_name,db,old_name))
{
error=1;
@ -4997,7 +5001,7 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list,
lex->col_list.empty();
lex->alter_info.reset();
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type=DB_TYPE_DEFAULT;
create_info.db_type= (handlerton*) &default_hton;
create_info.row_type=ROW_TYPE_NOT_USED;
create_info.default_table_charset=default_charset_info;
/* Force alter table to recreate table */
@ -5129,21 +5133,21 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt)
}
static bool check_engine(THD *thd, const char *table_name,
enum db_type *new_engine)
handlerton **new_engine)
{
enum db_type req_engine= *new_engine;
handlerton *req_engine= *new_engine;
bool no_substitution=
test(thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION);
if ((*new_engine=
ha_checktype(thd, req_engine, no_substitution, 1)) == DB_TYPE_UNKNOWN)
if (!(*new_engine= ha_checktype(thd, ha_legacy_type(req_engine),
no_substitution, 1)))
return TRUE;
if (req_engine != *new_engine)
if (req_engine != (handlerton*) &default_hton && req_engine != *new_engine)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_USING_OTHER_HANDLER,
ER(ER_WARN_USING_OTHER_HANDLER),
ha_get_storage_engine(*new_engine),
ha_resolve_storage_engine_name(*new_engine),
table_name);
}
return FALSE;

View file

@ -1177,7 +1177,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
{
char path[FN_REFLEN];
TABLE_LIST *view;
db_type not_used;
enum legacy_db_type not_used;
DBUG_ENTER("mysql_drop_view");
for (view= views; view; view= view->next_local)
@ -1250,7 +1250,7 @@ err:
FRMTYPE_VIEW view
*/
frm_type_enum mysql_frm_type(THD *thd, char *path, db_type *dbt)
frm_type_enum mysql_frm_type(THD *thd, char *path, enum legacy_db_type *dbt)
{
File file;
uchar header[10]; //"TYPE=VIEW\n" it is 10 characters
@ -1279,7 +1279,7 @@ frm_type_enum mysql_frm_type(THD *thd, char *path, db_type *dbt)
(header[2] < FRM_VER+3 || header[2] > FRM_VER+4)))
DBUG_RETURN(FRMTYPE_TABLE);
*dbt= ha_checktype(thd, (enum db_type) (uint) *(header + 3), 0, 0);
*dbt= (enum legacy_db_type) (uint) *(header + 3);
DBUG_RETURN(FRMTYPE_TABLE); // Is probably a .frm table
}

View file

@ -27,7 +27,7 @@ bool check_key_in_view(THD *thd, TABLE_LIST * view);
bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view);
frm_type_enum mysql_frm_type(THD *thd, char *path, db_type *dbt);
frm_type_enum mysql_frm_type(THD *thd, char *path, enum legacy_db_type *dbt);
int view_checksum(THD *thd, TABLE_LIST *view);

View file

@ -92,7 +92,7 @@ inline Item *is_truth_value(Item *A, bool v1, bool v2)
enum enum_var_type var_type;
Key::Keytype key_type;
enum ha_key_alg key_alg;
enum db_type db_type;
handlerton *db_type;
enum row_type row_type;
enum ha_rkey_function ha_rkey_mode;
enum enum_tx_isolation tx_isolation;
@ -1174,7 +1174,7 @@ create:
lex->change=NullS;
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.options=$2 | $4;
lex->create_info.db_type= (enum db_type) lex->thd->variables.table_type;
lex->create_info.db_type= lex->thd->variables.table_type;
lex->create_info.default_table_charset= NULL;
lex->name=0;
}
@ -2822,7 +2822,7 @@ part_definition:
part_info->current_partition= p_elem;
part_info->use_default_partitions= FALSE;
part_info->partitions.push_back(p_elem);
p_elem->engine_type= DB_TYPE_UNKNOWN;
p_elem->engine_type= NULL;
part_info->count_curr_parts++;
}
part_name {}
@ -3005,7 +3005,7 @@ sub_part_definition:
part_info->current_partition->subpartitions.push_back(p_elem);
part_info->use_default_subpartitions= FALSE;
part_info->count_curr_subparts++;
p_elem->engine_type= DB_TYPE_UNKNOWN;
p_elem->engine_type= NULL;
}
sub_name opt_part_options {}
;
@ -3234,8 +3234,8 @@ default_collation:
storage_engines:
ident_or_text
{
$$ = ha_resolve_by_name($1.str,$1.length);
if ($$ == DB_TYPE_UNKNOWN &&
$$ = ha_resolve_by_name(YYTHD, &$1);
if ($$ == NULL &&
test(YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION))
{
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
@ -3886,7 +3886,7 @@ alter:
lex->select_lex.init_order();
lex->select_lex.db=lex->name=0;
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.db_type= DB_TYPE_DEFAULT;
lex->create_info.db_type= (handlerton*) &default_hton;
lex->create_info.default_table_charset= NULL;
lex->create_info.row_type= ROW_TYPE_NOT_USED;
lex->alter_info.reset();
@ -7034,11 +7034,19 @@ show_param:
if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
YYABORT;
}
| PLUGIN_SYM
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SELECT;
lex->orig_sql_command= SQLCOM_SHOW_PLUGINS;
if (prepare_schema_table(YYTHD, lex, 0, SCH_PLUGINS))
YYABORT;
}
| ENGINE_SYM storage_engines
{ Lex->create_info.db_type= $2; }
show_engine_param
| ENGINE_SYM ALL
{ Lex->create_info.db_type= DB_TYPE_DEFAULT; }
{ Lex->create_info.db_type= NULL; }
show_engine_param
| opt_full COLUMNS from_or_in table_ident opt_db wild_and_where
{
@ -7130,14 +7138,24 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command = SQLCOM_SHOW_ENGINE_STATUS;
lex->create_info.db_type= DB_TYPE_INNODB;
if (!(lex->create_info.db_type=
ha_resolve_by_legacy_type(YYTHD, DB_TYPE_INNODB)))
{
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
YYABORT;
}
WARN_DEPRECATED("SHOW INNODB STATUS", "SHOW ENGINE INNODB STATUS");
}
| MUTEX_SYM STATUS_SYM
{
LEX *lex= Lex;
lex->sql_command = SQLCOM_SHOW_ENGINE_MUTEX;
lex->create_info.db_type= DB_TYPE_INNODB;
if (!(lex->create_info.db_type=
ha_resolve_by_legacy_type(YYTHD, DB_TYPE_INNODB)))
{
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
YYABORT;
}
WARN_DEPRECATED("SHOW MUTEX STATUS", "SHOW ENGINE INNODB MUTEX");
}
| opt_full PROCESSLIST_SYM
@ -7171,14 +7189,24 @@ show_param:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_ENGINE_LOGS;
lex->create_info.db_type= DB_TYPE_BERKELEY_DB;
if (!(lex->create_info.db_type=
ha_resolve_by_legacy_type(YYTHD, DB_TYPE_BERKELEY_DB)))
{
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "BerkeleyDB");
YYABORT;
}
WARN_DEPRECATED("SHOW BDB LOGS", "SHOW ENGINE BDB LOGS");
}
| LOGS_SYM
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_ENGINE_LOGS;
lex->create_info.db_type= DB_TYPE_BERKELEY_DB;
if (!(lex->create_info.db_type=
ha_resolve_by_legacy_type(YYTHD, DB_TYPE_BERKELEY_DB)))
{
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "BerkeleyDB");
YYABORT;
}
WARN_DEPRECATED("SHOW LOGS", "SHOW ENGINE BDB LOGS");
}
| GRANTS
@ -9863,7 +9891,7 @@ opt_migrate:
;
install:
INSTALL_SYM PLUGIN_SYM IDENT_sys SONAME_SYM TEXT_STRING_sys
INSTALL_SYM PLUGIN_SYM ident SONAME_SYM TEXT_STRING_sys
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_INSTALL_PLUGIN;
@ -9872,7 +9900,7 @@ install:
};
uninstall:
UNINSTALL_SYM PLUGIN_SYM IDENT_sys
UNINSTALL_SYM PLUGIN_SYM ident
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;

View file

@ -327,6 +327,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
SQL_CRYPT *crypted=0;
Field **field_ptr, *reg_field;
const char **interval_array;
enum legacy_db_type legacy_db_type;
DBUG_ENTER("open_binary_frm");
new_field_pack_flag= head[27];
@ -349,11 +350,11 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
share->frm_version= FRM_VER_TRUE_VARCHAR;
#ifdef WITH_PARTITION_STORAGE_ENGINE
share->default_part_db_type= ha_checktype(thd,
(enum db_type) (uint) *(head+61),0,
0);
share->default_part_db_type=
ha_checktype(thd, (enum legacy_db_type) (uint) *(head+61), 0, 0);
#endif
share->db_type= ha_checktype(thd, (enum db_type) (uint) *(head+3),0,0);
legacy_db_type= (enum legacy_db_type) (uint) *(head+3);
share->db_type= ha_checktype(thd, legacy_db_type, 0, 0);
share->db_create_options= db_create_options= uint2korr(head+30);
share->db_options_in_use= share->db_create_options;
share->mysql_version= uint4korr(head+51);
@ -385,7 +386,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (db_create_options & HA_OPTION_LONG_BLOB_PTR)
share->blob_ptr_size= portable_sizeof_char_ptr;
/* Set temporarily a good value for db_low_byte_first */
share->db_low_byte_first= test(share->db_type != DB_TYPE_ISAM);
share->db_low_byte_first= test(legacy_db_type != DB_TYPE_ISAM);
error=4;
share->max_rows= uint4korr(head+18);
share->min_rows= uint4korr(head+22);
@ -513,14 +514,14 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (next_chunk + 2 < buff_end)
{
uint str_db_type_length= uint2korr(next_chunk);
enum db_type tmp_db_type= ha_resolve_by_name(next_chunk + 2,
str_db_type_length);
if (tmp_db_type != DB_TYPE_UNKNOWN)
LEX_STRING name= { next_chunk + 2, str_db_type_length };
handlerton *tmp_db_type= ha_resolve_by_name(thd, &name);
if (tmp_db_type != NULL)
{
share->db_type= tmp_db_type;
DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)",
str_db_type_length, next_chunk + 2,
share->db_type));
ha_legacy_type(share->db_type)));
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
else
@ -528,10 +529,10 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (!strncmp(next_chunk + 2, "partition", str_db_type_length))
{
/* Use partition handler */
share->db_type= DB_TYPE_PARTITION_DB;
share->db_type= &partition_hton;
DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)",
str_db_type_length, next_chunk + 2,
share->db_type));
ha_legacy_type(share->db_type)));
}
}
#endif
@ -1634,7 +1635,7 @@ void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg)
handler *file= 0;
const char *datext= "";
if (share->db_type != DB_TYPE_UNKNOWN)
if (share->db_type != NULL)
{
if ((file= get_new_handler(share, current_thd->mem_root,
share->db_type)))
@ -1899,7 +1900,8 @@ File create_frm(THD *thd, const char *name, const char *db,
fileinfo[1]= 1;
fileinfo[2]= FRM_VER+3+ test(create_info->varchar);
fileinfo[3]= (uchar) ha_checktype(thd,create_info->db_type,0,0);
fileinfo[3]= (uchar) ha_legacy_type(
ha_checktype(thd,ha_legacy_type(create_info->db_type),0,0));
fileinfo[4]=1;
int2store(fileinfo+6,IO_SIZE); /* Next block starts here */
key_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16;

View file

@ -153,7 +153,7 @@ typedef struct st_table_share
ulong timestamp_offset; /* Set to offset+1 of record */
ulong reclength; /* Recordlength */
enum db_type db_type; /* table_type for handler */
handlerton *db_type; /* table_type for handler */
enum row_type row_type; /* How rows are stored */
enum tmp_table_type tmp_table;
@ -200,7 +200,7 @@ typedef struct st_table_share
#ifdef WITH_PARTITION_STORAGE_ENGINE
const uchar *partition_info;
uint partition_info_len;
enum db_type default_part_db_type;
handlerton *default_part_db_type;
#endif
} TABLE_SHARE;
@ -324,6 +324,7 @@ enum enum_schema_tables
SCH_COLUMN_PRIVILEGES,
SCH_KEY_COLUMN_USAGE,
SCH_OPEN_TABLES,
SCH_PLUGINS,
SCH_PROCEDURES,
SCH_SCHEMATA,
SCH_SCHEMA_PRIVILEGES,
@ -639,7 +640,7 @@ typedef struct st_table_list
bool where_processed;
/* FRMTYPE_ERROR if any type is acceptable */
enum frm_type_enum required_type;
enum db_type db_type; /* table_type for handler */
handlerton *db_type; /* table_type for handler */
char timestamp_buffer[20]; /* buffer for timestamp (19+1) */
/*
This TABLE_LIST object is just placeholder for prelocking, it will be

View file

@ -35,7 +35,7 @@ static uchar * pack_screens(List<create_field> &create_fields,
uint *info_length, uint *screens, bool small_file);
static uint pack_keys(uchar *keybuff,uint key_count, KEY *key_info,
ulong data_offset);
static bool pack_header(uchar *forminfo,enum db_type table_type,
static bool pack_header(uchar *forminfo,enum legacy_db_type table_type,
List<create_field> &create_fields,
uint info_length, uint screens, uint table_options,
ulong data_offset, handler *file);
@ -43,7 +43,7 @@ static uint get_interval_id(uint *int_count,List<create_field> &create_fields,
create_field *last_field);
static bool pack_fields(File file, List<create_field> &create_fields,
ulong data_offset);
static bool make_empty_rec(THD *thd, int file, enum db_type table_type,
static bool make_empty_rec(THD *thd, int file, enum legacy_db_type table_type,
uint table_options,
List<create_field> &create_fields,
uint reclength, ulong data_offset,
@ -103,7 +103,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
create_info->null_bits++;
data_offset= (create_info->null_bits + 7) / 8;
if (pack_header(forminfo, create_info->db_type,create_fields,info_length,
if (pack_header(forminfo, ha_legacy_type(create_info->db_type),
create_fields,info_length,
screens, create_info->table_options,
data_offset, db_file))
{
@ -115,7 +116,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
thd->net.last_error[0]=0;
if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,1)))
DBUG_RETURN(1);
if (pack_header(forminfo, create_info->db_type, create_fields,info_length,
if (pack_header(forminfo, ha_legacy_type(create_info->db_type),
create_fields,info_length,
screens, create_info->table_options, data_offset, db_file))
{
my_free((gptr) screen_buff,MYF(0));
@ -125,7 +127,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
reclength=uint2korr(forminfo+266);
/* Calculate extra data segment length */
str_db_type.str= (char *) ha_get_storage_engine(create_info->db_type);
str_db_type.str= (char *) ha_resolve_storage_engine_name(create_info->db_type);
str_db_type.length= strlen(str_db_type.str);
/* str_db_type */
create_info->extra_size= (2 + str_db_type.length +
@ -168,7 +170,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (part_info)
fileinfo[61]= (uchar) part_info->default_engine_type;
fileinfo[61]= (uchar) ha_legacy_type(part_info->default_engine_type);
#endif
int2store(fileinfo+59,db_file->extra_rec_buf_length());
if (my_pwrite(file,(byte*) fileinfo,64,0L,MYF_RW) ||
@ -178,7 +180,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
VOID(my_seek(file,
(ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length,
MY_SEEK_SET,MYF(0)));
if (make_empty_rec(thd,file,create_info->db_type,create_info->table_options,
if (make_empty_rec(thd,file,ha_legacy_type(create_info->db_type),
create_info->table_options,
create_fields,reclength, data_offset, db_file))
goto err;
@ -480,7 +483,7 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
/* Make formheader */
static bool pack_header(uchar *forminfo, enum db_type table_type,
static bool pack_header(uchar *forminfo, enum legacy_db_type table_type,
List<create_field> &create_fields,
uint info_length, uint screens, uint table_options,
ulong data_offset, handler *file)
@ -739,7 +742,7 @@ static bool pack_fields(File file, List<create_field> &create_fields,
/* save an empty record on start of formfile */
static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type,
uint table_options,
List<create_field> &create_fields,
uint reclength,

39
storage/csv/Makefile.am Normal file
View file

@ -0,0 +1,39 @@
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#called from the top level Makefile
MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir)
INCLUDES = -I$(top_srcdir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/sql \
-I$(srcdir)
WRAPLIBS=
pkglib_LTLIBRARIES = ha_csv.la
ha_csv_la_LDFLAGS = -module
ha_csv_la_SOURCES = ha_tina.cc
LDADD =
DEFS = -DMYSQL_SERVER @DEFS@
# Don't update the files from bitkeeper
%::SCCS/s.%

View file

@ -51,18 +51,22 @@ TODO:
#include "ha_tina.h"
#include <sys/mman.h>
#include <plugin.h>
/* Stuff for shares */
pthread_mutex_t tina_mutex;
static HASH tina_open_tables;
static int tina_init= 0;
static handler *tina_create_handler(TABLE_SHARE *table);
static int tina_init_func();
handlerton tina_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"CSV",
SHOW_OPTION_YES,
"CSV storage engine",
DB_TYPE_CSV_DB,
NULL, /* One needs to be written! */
(bool (*)()) tina_init_func,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
@ -81,12 +85,9 @@ handlerton tina_hton= {
tina_create_handler, /* Create a new handler */
NULL, /* Drop a database */
tina_end, /* Panic call */
NULL, /* Release temporary latches */
NULL, /* Update Statistics */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Replication Report Sent Binlog */
HTON_CAN_RECREATE
};
@ -155,6 +156,35 @@ int get_mmap(TINA_SHARE *share, int write)
DBUG_RETURN(0);
}
static int tina_init_func()
{
if (!tina_init)
{
tina_init++;
VOID(pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST));
(void) hash_init(&tina_open_tables,system_charset_info,32,0,0,
(hash_get_key) tina_get_key,0,0);
}
return 0;
}
static int tina_done_func()
{
if (tina_init)
{
if (tina_open_tables.records)
{
return 1;
}
hash_free(&tina_open_tables);
pthread_mutex_destroy(&tina_mutex);
tina_init--;
}
return 0;
}
/*
Simple lock controls.
*/
@ -164,19 +194,6 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
char *tmp_name;
uint length;
if (!tina_init)
{
/* Hijack a mutex for init'ing the storage engine */
pthread_mutex_lock(&LOCK_mysql_create_db);
if (!tina_init)
{
tina_init++;
VOID(pthread_mutex_init(&tina_mutex,MY_MUTEX_INIT_FAST));
(void) hash_init(&tina_open_tables,system_charset_info,32,0,0,
(hash_get_key) tina_get_key,0,0);
}
pthread_mutex_unlock(&LOCK_mysql_create_db);
}
pthread_mutex_lock(&tina_mutex);
length=(uint) strlen(table_name);
if (!(share=(TINA_SHARE*) hash_search(&tina_open_tables,
@ -262,13 +279,7 @@ static int free_share(TINA_SHARE *share)
int tina_end(ha_panic_function type)
{
if (tina_init)
{
hash_free(&tina_open_tables);
VOID(pthread_mutex_destroy(&tina_mutex));
}
tina_init= 0;
return 0;
return tina_done_func();
}
/*
@ -933,3 +944,16 @@ int ha_tina::create(const char *name, TABLE *table_arg,
DBUG_RETURN(0);
}
mysql_declare_plugin
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&tina_hton,
tina_hton.name,
0x00010000 /* 0.1.0 */,
"Brian Aker, MySQL AB",
"CSV Storage Engine",
tina_init_func, /* Plugin Init */
tina_done_func /* Plugin Deinit */
}
mysql_declare_plugin_end;

View file

@ -0,0 +1,39 @@
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#called from the top level Makefile
MYSQLDATAdir = $(localstatedir)
MYSQLSHAREdir = $(pkgdatadir)
MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir)
INCLUDES = -I$(top_srcdir)/include \
-I$(top_srcdir)/regex \
-I$(top_srcdir)/sql \
-I$(srcdir)
WRAPLIBS=
pkglib_LTLIBRARIES = ha_example.la
ha_example_la_LDFLAGS = -module
ha_example_la_SOURCES = ha_example.cc
LDADD =
DEFS = -DMYSQL_SERVER @DEFS@
# Don't update the files from bitkeeper
%::SCCS/s.%

View file

@ -68,17 +68,20 @@
#endif
#include "../mysql_priv.h"
#include <plugin.h>
#include "ha_example.h"
static handler* example_create_handler(TABLE_SHARE *table);
static int example_init_func();
handlerton example_hton= {
MYSQL_HANDLERTON_INTERFACE_VERSION,
"EXAMPLE",
SHOW_OPTION_YES,
"Example storage engine",
DB_TYPE_EXAMPLE_DB,
NULL, /* We do need to write one! */
(bool (*)()) example_init_func,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
@ -123,6 +126,34 @@ static byte* example_get_key(EXAMPLE_SHARE *share,uint *length,
}
static int example_init_func()
{
if (!example_init)
{
example_init++;
VOID(pthread_mutex_init(&example_mutex,MY_MUTEX_INIT_FAST));
(void) hash_init(&example_open_tables,system_charset_info,32,0,0,
(hash_get_key) example_get_key,0,0);
}
return 0;
}
static int example_done_func()
{
if (example_init)
{
if (example_open_tables.records)
{
return 1;
}
hash_free(&example_open_tables);
pthread_mutex_destroy(&example_mutex);
example_init--;
}
return 0;
}
/*
Example of simple lock controls. The "share" it creates is structure we will
pass to each example handler. Do you have to have one of these? Well, you have
@ -134,25 +165,6 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
uint length;
char *tmp_name;
/*
So why does this exist? There is no way currently to init a storage engine.
Innodb and BDB both have modifications to the server to allow them to
do this. Since you will not want to do this, this is probably the next
best method.
*/
if (!example_init)
{
/* Hijack a mutex for init'ing the storage engine */
pthread_mutex_lock(&LOCK_mysql_create_db);
if (!example_init)
{
example_init++;
VOID(pthread_mutex_init(&example_mutex,MY_MUTEX_INIT_FAST));
(void) hash_init(&example_open_tables,system_charset_info,32,0,0,
(hash_get_key) example_get_key,0,0);
}
pthread_mutex_unlock(&LOCK_mysql_create_db);
}
pthread_mutex_lock(&example_mutex);
length=(uint) strlen(table_name);
@ -186,7 +198,6 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
error:
pthread_mutex_destroy(&share->mutex);
pthread_mutex_unlock(&example_mutex);
my_free((gptr) share, MYF(0));
return NULL;
@ -713,3 +724,17 @@ int ha_example::create(const char *name, TABLE *table_arg,
/* This is not implemented but we want someone to be able that it works. */
DBUG_RETURN(0);
}
mysql_declare_plugin
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&example_hton,
example_hton.name,
0x01000000 /* 1.0.0 */,
"Brian Aker, MySQL AB",
"Example Storage Engine",
tina_init_func, /* Plugin Init */
tina_done_func /* Plugin Deinit */
}
mysql_declare_plugin_end;