Finalize storage engine plugins
Give BerkeleyDB savepoints Remove "enum db_type" from most of the code
This commit is contained in:
parent
0538845963
commit
13a776778c
@ -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], -, _))
|
[mysql_cv_use_]m4_bpatsubst([$3], -, _)=[$with_]m4_bpatsubst([$3], -, _))
|
||||||
AH_TEMPLATE([$5], [Build $2])
|
AH_TEMPLATE([$5], [Build $2])
|
||||||
if test "[$mysql_cv_use_]m4_bpatsubst([$3], -, _)" != no; then
|
if test "[$mysql_cv_use_]m4_bpatsubst([$3], -, _)" != no; then
|
||||||
AC_DEFINE([$5])
|
if test "$6" != "no"
|
||||||
mysql_se_decls="${mysql_se_decls},$6"
|
then
|
||||||
mysql_se_htons="${mysql_se_htons},&$6"
|
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_dirs="$mysql_se_dirs $7"
|
||||||
mysql_se_objs="$mysql_se_objs $8"
|
|
||||||
mysql_se_libs="$mysql_se_libs $9"
|
mysql_se_libs="$mysql_se_libs $9"
|
||||||
$10
|
$10
|
||||||
fi
|
fi
|
||||||
|
@ -2411,9 +2411,14 @@ MYSQL_STORAGE_ENGINE(innobase,,innodb,,,,storage/innobase,ha_innodb.o,[ dnl
|
|||||||
MYSQL_STORAGE_ENGINE(berkeley,,berkeley-db,,,,storage/bdb,,,[
|
MYSQL_STORAGE_ENGINE(berkeley,,berkeley-db,,,,storage/bdb,,,[
|
||||||
MYSQL_SETUP_BERKELEY_DB
|
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(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(blackhole)
|
||||||
MYSQL_STORAGE_ENGINE(federated)
|
MYSQL_STORAGE_ENGINE(federated)
|
||||||
MYSQL_STORAGE_ENGINE(ndbcluster,,ndbcluster,,,,storage/ndb,,,[
|
MYSQL_STORAGE_ENGINE(ndbcluster,,ndbcluster,,,,storage/ndb,,,[
|
||||||
|
@ -51,6 +51,7 @@ struct st_mysql_plugin
|
|||||||
int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */
|
int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */
|
||||||
void *info; /* pointer to type-specific plugin descriptor */
|
void *info; /* pointer to type-specific plugin descriptor */
|
||||||
const char *name; /* plugin name */
|
const char *name; /* plugin name */
|
||||||
|
uint version; /* plugin version */
|
||||||
const char *author; /* plugin author (for SHOW PLUGINS) */
|
const char *author; /* plugin author (for SHOW PLUGINS) */
|
||||||
const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
|
const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
|
||||||
int (*init)(void); /* the function to invoke when plugin is loaded */
|
int (*init)(void); /* the function to invoke when plugin is loaded */
|
||||||
|
@ -285,6 +285,40 @@ n
|
|||||||
4
|
4
|
||||||
5
|
5
|
||||||
6
|
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;
|
rollback;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=BDB;
|
create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) engine=BDB;
|
||||||
|
@ -42,6 +42,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY
|
|||||||
COLUMNS
|
COLUMNS
|
||||||
COLUMN_PRIVILEGES
|
COLUMN_PRIVILEGES
|
||||||
KEY_COLUMN_USAGE
|
KEY_COLUMN_USAGE
|
||||||
|
PLUGINS
|
||||||
ROUTINES
|
ROUTINES
|
||||||
SCHEMATA
|
SCHEMATA
|
||||||
SCHEMA_PRIVILEGES
|
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 a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
|
||||||
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
|
CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
|
||||||
count(*)
|
count(*)
|
||||||
102
|
103
|
||||||
drop view a2, a1;
|
drop view a2, a1;
|
||||||
drop table t_crashme;
|
drop table t_crashme;
|
||||||
select table_schema,table_name, column_name from
|
select table_schema,table_name, column_name from
|
||||||
@ -731,6 +732,7 @@ information_schema.columns
|
|||||||
where data_type = 'longtext';
|
where data_type = 'longtext';
|
||||||
table_schema table_name column_name
|
table_schema table_name column_name
|
||||||
information_schema COLUMNS COLUMN_TYPE
|
information_schema COLUMNS COLUMN_TYPE
|
||||||
|
information_schema PLUGINS PLUGIN_DESCRIPTION
|
||||||
information_schema ROUTINES ROUTINE_DEFINITION
|
information_schema ROUTINES ROUTINE_DEFINITION
|
||||||
information_schema ROUTINES SQL_MODE
|
information_schema ROUTINES SQL_MODE
|
||||||
information_schema TRIGGERS ACTION_CONDITION
|
information_schema TRIGGERS ACTION_CONDITION
|
||||||
@ -793,7 +795,7 @@ delete from mysql.db where user='mysqltest_4';
|
|||||||
flush privileges;
|
flush privileges;
|
||||||
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
|
SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
|
||||||
table_schema count(*)
|
table_schema count(*)
|
||||||
information_schema 16
|
information_schema 17
|
||||||
mysql 18
|
mysql 18
|
||||||
create table t1 (i int, j int);
|
create table t1 (i int, j int);
|
||||||
create trigger trg1 before insert on t1 for each row
|
create trigger trg1 before insert on t1 for each row
|
||||||
|
@ -7,6 +7,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY
|
|||||||
COLUMNS
|
COLUMNS
|
||||||
COLUMN_PRIVILEGES
|
COLUMN_PRIVILEGES
|
||||||
KEY_COLUMN_USAGE
|
KEY_COLUMN_USAGE
|
||||||
|
PLUGINS
|
||||||
ROUTINES
|
ROUTINES
|
||||||
SCHEMATA
|
SCHEMATA
|
||||||
SCHEMA_PRIVILEGES
|
SCHEMA_PRIVILEGES
|
||||||
|
@ -147,6 +147,32 @@ insert into t1 values (6);
|
|||||||
-- error 1062
|
-- error 1062
|
||||||
insert into t1 values (4);
|
insert into t1 values (4);
|
||||||
select n from t1;
|
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
|
# nop
|
||||||
rollback;
|
rollback;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
@ -101,9 +101,7 @@ EXTRA_mysqld_SOURCES = ha_innodb.cc ha_berkeley.cc ha_archive.cc \
|
|||||||
ha_innodb.h ha_berkeley.h ha_archive.h \
|
ha_innodb.h ha_berkeley.h ha_archive.h \
|
||||||
ha_blackhole.cc ha_federated.cc ha_ndbcluster.cc \
|
ha_blackhole.cc ha_federated.cc ha_ndbcluster.cc \
|
||||||
ha_blackhole.h ha_federated.h ha_ndbcluster.h \
|
ha_blackhole.h ha_federated.h ha_ndbcluster.h \
|
||||||
ha_partition.cc ha_partition.h \
|
ha_partition.cc ha_partition.h
|
||||||
examples/ha_tina.cc examples/ha_example.cc \
|
|
||||||
examples/ha_tina.h examples/ha_example.h
|
|
||||||
mysqld_DEPENDENCIES = @mysql_se_objs@
|
mysqld_DEPENDENCIES = @mysql_se_objs@
|
||||||
gen_lex_hash_SOURCES = gen_lex_hash.cc
|
gen_lex_hash_SOURCES = gen_lex_hash.cc
|
||||||
gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
|
gen_lex_hash_LDADD = $(LDADD) $(CXXLDFLAGS)
|
||||||
|
@ -62,7 +62,8 @@ struct show_table_authors_st show_table_authors[]= {
|
|||||||
{ "Albert Chin-A-Young", "",
|
{ "Albert Chin-A-Young", "",
|
||||||
"Tru64 port, large file support, better TCP wrappers support" },
|
"Tru64 port, large file support, better TCP wrappers support" },
|
||||||
{ "Jorge del Conde", "Mexico City, Mexico", "Windows development" },
|
{ "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" },
|
{ "Yuri Dario", "", "OS/2 port" },
|
||||||
{ "Sergei Golubchik", "Kerpen, Germany",
|
{ "Sergei Golubchik", "Kerpen, Germany",
|
||||||
"Full-text search, precision math" },
|
"Full-text search, precision math" },
|
||||||
|
@ -140,6 +140,7 @@ static handler *archive_create_handler(TABLE_SHARE *table);
|
|||||||
|
|
||||||
/* dummy handlerton - only to have something to return from archive_db_init */
|
/* dummy handlerton - only to have something to return from archive_db_init */
|
||||||
handlerton archive_hton = {
|
handlerton archive_hton = {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"ARCHIVE",
|
"ARCHIVE",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"Archive storage engine",
|
"Archive storage engine",
|
||||||
@ -163,12 +164,9 @@ handlerton archive_hton = {
|
|||||||
archive_create_handler, /* Create a new handler */
|
archive_create_handler, /* Create a new handler */
|
||||||
NULL, /* Drop a database */
|
NULL, /* Drop a database */
|
||||||
archive_db_end, /* Panic call */
|
archive_db_end, /* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
NULL, /* Flush logs */
|
NULL, /* Flush logs */
|
||||||
NULL, /* Show status */
|
NULL, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_NO_FLAGS
|
HTON_NO_FLAGS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,20 +114,24 @@ static void berkeley_noticecall(DB_ENV *db_env, db_notices notice);
|
|||||||
static int berkeley_close_connection(THD *thd);
|
static int berkeley_close_connection(THD *thd);
|
||||||
static int berkeley_commit(THD *thd, bool all);
|
static int berkeley_commit(THD *thd, bool all);
|
||||||
static int berkeley_rollback(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);
|
static handler *berkeley_create_handler(TABLE_SHARE *table);
|
||||||
|
|
||||||
handlerton berkeley_hton = {
|
handlerton berkeley_hton = {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"BerkeleyDB",
|
"BerkeleyDB",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"Supports transactions and page-level locking",
|
"Supports transactions and page-level locking",
|
||||||
DB_TYPE_BERKELEY_DB,
|
DB_TYPE_BERKELEY_DB,
|
||||||
berkeley_init,
|
berkeley_init,
|
||||||
0, /* slot */
|
0, /* slot */
|
||||||
0, /* savepoint size */
|
sizeof(DB_TXN *), /* savepoint size */
|
||||||
berkeley_close_connection,
|
berkeley_close_connection,
|
||||||
NULL, /* savepoint_set */
|
berkeley_savepoint, /* savepoint_set */
|
||||||
NULL, /* savepoint_rollback */
|
berkeley_rollback_to_savepoint, /* savepoint_rollback */
|
||||||
NULL, /* savepoint_release */
|
berkeley_release_savepoint, /* savepoint_release */
|
||||||
berkeley_commit,
|
berkeley_commit,
|
||||||
berkeley_rollback,
|
berkeley_rollback,
|
||||||
NULL, /* prepare */
|
NULL, /* prepare */
|
||||||
@ -140,12 +144,9 @@ handlerton berkeley_hton = {
|
|||||||
berkeley_create_handler, /* Create a new handler */
|
berkeley_create_handler, /* Create a new handler */
|
||||||
NULL, /* Drop a database */
|
NULL, /* Drop a database */
|
||||||
berkeley_end, /* Panic call */
|
berkeley_end, /* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
berkeley_flush_logs, /* Flush logs */
|
berkeley_flush_logs, /* Flush logs */
|
||||||
berkeley_show_status, /* Show status */
|
berkeley_show_status, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME
|
HTON_CLOSE_CURSORS_AT_COMMIT | HTON_FLUSH_AFTER_RENAME
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -157,6 +158,7 @@ handler *berkeley_create_handler(TABLE_SHARE *table)
|
|||||||
typedef struct st_berkeley_trx_data {
|
typedef struct st_berkeley_trx_data {
|
||||||
DB_TXN *all;
|
DB_TXN *all;
|
||||||
DB_TXN *stmt;
|
DB_TXN *stmt;
|
||||||
|
DB_TXN *sp_level;
|
||||||
uint bdb_lock_count;
|
uint bdb_lock_count;
|
||||||
} berkeley_trx_data;
|
} berkeley_trx_data;
|
||||||
|
|
||||||
@ -309,10 +311,53 @@ static int berkeley_rollback(THD *thd, bool all)
|
|||||||
DBUG_RETURN(error);
|
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)
|
static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
|
||||||
{
|
{
|
||||||
char **all_logs, **free_logs, **a, **f;
|
char **all_logs, **free_logs, **a, **f;
|
||||||
|
uint hton_name_len= strlen(berkeley_hton.name);
|
||||||
int error=1;
|
int error=1;
|
||||||
MEM_ROOT **root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
|
MEM_ROOT **root_ptr= my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC);
|
||||||
MEM_ROOT show_logs_root, *old_mem_root= *root_ptr;
|
MEM_ROOT show_logs_root, *old_mem_root= *root_ptr;
|
||||||
@ -337,19 +382,20 @@ static bool berkeley_show_logs(THD *thd, stat_print_fn *stat_print)
|
|||||||
{
|
{
|
||||||
for (a = all_logs, f = free_logs; *a; ++a)
|
for (a = all_logs, f = free_logs; *a; ++a)
|
||||||
{
|
{
|
||||||
const char *status;
|
|
||||||
if (f && *f && strcmp(*a, *f) == 0)
|
if (f && *f && strcmp(*a, *f) == 0)
|
||||||
{
|
{
|
||||||
f++;
|
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
|
else
|
||||||
status= SHOW_LOG_STATUS_INUSE;
|
|
||||||
|
|
||||||
if (stat_print(thd, berkeley_hton.name, *a, status))
|
|
||||||
{
|
{
|
||||||
error=1;
|
if ((error= stat_print(thd, berkeley_hton.name, hton_name_len,
|
||||||
goto err;
|
*a, strlen(*a),
|
||||||
|
STRING_WITH_LEN(SHOW_LOG_STATUS_INUSE))))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1882,6 +1928,8 @@ int ha_berkeley::external_lock(THD *thd, int lock_type)
|
|||||||
if (!trx)
|
if (!trx)
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
if (trx->all == 0)
|
||||||
|
trx->sp_level= 0;
|
||||||
if (lock_type != F_UNLCK)
|
if (lock_type != F_UNLCK)
|
||||||
{
|
{
|
||||||
if (!trx->bdb_lock_count++)
|
if (!trx->bdb_lock_count++)
|
||||||
@ -1900,12 +1948,13 @@ int ha_berkeley::external_lock(THD *thd, int lock_type)
|
|||||||
trx->bdb_lock_count--; // We didn't get the lock
|
trx->bdb_lock_count--; // We didn't get the lock
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
trx->sp_level= trx->all;
|
||||||
trans_register_ha(thd, TRUE, &berkeley_hton);
|
trans_register_ha(thd, TRUE, &berkeley_hton);
|
||||||
if (thd->in_lock_tables)
|
if (thd->in_lock_tables)
|
||||||
DBUG_RETURN(0); // Don't create stmt trans
|
DBUG_RETURN(0); // Don't create stmt trans
|
||||||
}
|
}
|
||||||
DBUG_PRINT("trans",("starting transaction stmt"));
|
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 */
|
/* We leave the possible master transaction open */
|
||||||
trx->bdb_lock_count--; // We didn't get the lock
|
trx->bdb_lock_count--; // We didn't get the lock
|
||||||
@ -1959,7 +2008,7 @@ int ha_berkeley::start_stmt(THD *thd, thr_lock_type lock_type)
|
|||||||
if (!trx->stmt)
|
if (!trx->stmt)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("trans",("starting transaction 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);
|
trans_register_ha(thd, FALSE, &berkeley_hton);
|
||||||
}
|
}
|
||||||
transaction= trx->stmt;
|
transaction= trx->stmt;
|
||||||
|
@ -30,6 +30,7 @@ static handler *blackhole_create_handler(TABLE_SHARE *table);
|
|||||||
/* Blackhole storage engine handlerton */
|
/* Blackhole storage engine handlerton */
|
||||||
|
|
||||||
handlerton blackhole_hton= {
|
handlerton blackhole_hton= {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"BLACKHOLE",
|
"BLACKHOLE",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"/dev/null storage engine (anything you write to it disappears)",
|
"/dev/null storage engine (anything you write to it disappears)",
|
||||||
@ -53,12 +54,9 @@ handlerton blackhole_hton= {
|
|||||||
blackhole_create_handler, /* Create a new handler */
|
blackhole_create_handler, /* Create a new handler */
|
||||||
NULL, /* Drop a database */
|
NULL, /* Drop a database */
|
||||||
NULL, /* Panic call */
|
NULL, /* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
NULL, /* Flush logs */
|
NULL, /* Flush logs */
|
||||||
NULL, /* Show status */
|
NULL, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_CAN_RECREATE
|
HTON_CAN_RECREATE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -367,6 +367,7 @@ static int federated_rollback(THD *thd, bool all);
|
|||||||
/* Federated storage engine handlerton */
|
/* Federated storage engine handlerton */
|
||||||
|
|
||||||
handlerton federated_hton= {
|
handlerton federated_hton= {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"FEDERATED",
|
"FEDERATED",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"Federated MySQL storage engine",
|
"Federated MySQL storage engine",
|
||||||
@ -390,12 +391,9 @@ handlerton federated_hton= {
|
|||||||
federated_create_handler, /* Create a new handler */
|
federated_create_handler, /* Create a new handler */
|
||||||
NULL, /* Drop a database */
|
NULL, /* Drop a database */
|
||||||
federated_db_end, /* Panic call */
|
federated_db_end, /* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
NULL, /* Flush logs */
|
NULL, /* Flush logs */
|
||||||
NULL, /* Show status */
|
NULL, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_ALTER_NOT_SUPPORTED
|
HTON_ALTER_NOT_SUPPORTED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
static handler *heap_create_handler(TABLE_SHARE *table);
|
static handler *heap_create_handler(TABLE_SHARE *table);
|
||||||
|
|
||||||
handlerton heap_hton= {
|
handlerton heap_hton= {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"MEMORY",
|
"MEMORY",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"Hash based, stored in memory, useful for temporary tables",
|
"Hash based, stored in memory, useful for temporary tables",
|
||||||
@ -50,12 +51,9 @@ handlerton heap_hton= {
|
|||||||
heap_create_handler, /* Create a new handler */
|
heap_create_handler, /* Create a new handler */
|
||||||
NULL, /* Drop a database */
|
NULL, /* Drop a database */
|
||||||
heap_panic, /* Panic call */
|
heap_panic, /* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
NULL, /* Flush logs */
|
NULL, /* Flush logs */
|
||||||
NULL, /* Show status */
|
NULL, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_CAN_RECREATE
|
HTON_CAN_RECREATE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -208,6 +208,7 @@ static int innobase_release_savepoint(THD* thd, void *savepoint);
|
|||||||
static handler *innobase_create_handler(TABLE_SHARE *table);
|
static handler *innobase_create_handler(TABLE_SHARE *table);
|
||||||
|
|
||||||
handlerton innobase_hton = {
|
handlerton innobase_hton = {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"InnoDB",
|
"InnoDB",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"Supports transactions, row-level locking, and foreign keys",
|
"Supports transactions, row-level locking, and foreign keys",
|
||||||
@ -231,16 +232,9 @@ handlerton innobase_hton = {
|
|||||||
innobase_create_handler, /* Create a new handler */
|
innobase_create_handler, /* Create a new handler */
|
||||||
innobase_drop_database, /* Drop a database */
|
innobase_drop_database, /* Drop a database */
|
||||||
innobase_end, /* Panic call */
|
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_start_trx_and_assign_read_view, /* Start Consistent Snapshot */
|
||||||
innobase_flush_logs, /* Flush logs */
|
innobase_flush_logs, /* Flush logs */
|
||||||
innobase_show_status, /* Show status */
|
innobase_show_status, /* Show status */
|
||||||
#ifdef HAVE_REPLICATION
|
|
||||||
innobase_repl_report_sent_binlog, /* Replication Report Sent Binlog */
|
|
||||||
#else
|
|
||||||
NULL,
|
|
||||||
#endif
|
|
||||||
HTON_NO_FLAGS
|
HTON_NO_FLAGS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1977,6 +1971,11 @@ innobase_repl_report_sent_binlog(
|
|||||||
int cmp;
|
int cmp;
|
||||||
ibool can_release_threads = 0;
|
ibool can_release_threads = 0;
|
||||||
|
|
||||||
|
if (!innodb_inited) {
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* If synchronous replication is not switched on, or this thd is
|
/* If synchronous replication is not switched on, or this thd is
|
||||||
sending binlog to a slave where we do not need synchronous replication,
|
sending binlog to a slave where we do not need synchronous replication,
|
||||||
then return immediately */
|
then return immediately */
|
||||||
@ -6472,10 +6471,11 @@ ha_innobase::transactional_table_lock(
|
|||||||
Here we export InnoDB status variables to MySQL. */
|
Here we export InnoDB status variables to MySQL. */
|
||||||
|
|
||||||
int
|
int
|
||||||
innodb_export_status(void)
|
innodb_export_status()
|
||||||
/*======================*/
|
/*======================*/
|
||||||
{
|
{
|
||||||
srv_export_innodb_status();
|
if (innodb_inited)
|
||||||
|
srv_export_innodb_status();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6562,7 +6562,8 @@ innodb_show_status(
|
|||||||
|
|
||||||
bool result = FALSE;
|
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;
|
result= TRUE;
|
||||||
}
|
}
|
||||||
my_free(str, MYF(0));
|
my_free(str, MYF(0));
|
||||||
@ -6587,6 +6588,7 @@ innodb_mutex_show_status(
|
|||||||
ulint rw_lock_count_os_wait= 0;
|
ulint rw_lock_count_os_wait= 0;
|
||||||
ulint rw_lock_count_os_yield= 0;
|
ulint rw_lock_count_os_yield= 0;
|
||||||
ulonglong rw_lock_wait_time= 0;
|
ulonglong rw_lock_wait_time= 0;
|
||||||
|
uint hton_name_len= strlen(innobase_hton.name), buf1len, buf2len;
|
||||||
DBUG_ENTER("innodb_mutex_show_status");
|
DBUG_ENTER("innodb_mutex_show_status");
|
||||||
|
|
||||||
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
|
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
|
||||||
@ -6601,16 +6603,17 @@ innodb_mutex_show_status(
|
|||||||
{
|
{
|
||||||
if (mutex->count_using > 0)
|
if (mutex->count_using > 0)
|
||||||
{
|
{
|
||||||
my_snprintf(buf1, sizeof(buf1), "%s:%s",
|
buf1len= my_snprintf(buf1, sizeof(buf1), "%s:%s",
|
||||||
mutex->cmutex_name, mutex->cfile_name);
|
mutex->cmutex_name, mutex->cfile_name);
|
||||||
my_snprintf(buf2, sizeof(buf2),
|
buf2len= my_snprintf(buf2, sizeof(buf2),
|
||||||
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
|
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
|
||||||
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
|
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
|
||||||
mutex->count_using, mutex->count_spin_loop,
|
mutex->count_using, mutex->count_spin_loop,
|
||||||
mutex->count_spin_rounds,
|
mutex->count_spin_rounds,
|
||||||
mutex->count_os_wait, mutex->count_os_yield,
|
mutex->count_os_wait, mutex->count_os_yield,
|
||||||
mutex->lspent_time/1000);
|
mutex->lspent_time/1000);
|
||||||
if (stat_print(thd, innobase_hton.name, buf1, buf2))
|
if (stat_print(thd, innobase_hton.name, hton_name_len,
|
||||||
|
buf1, buf1len, buf2, buf2len))
|
||||||
{
|
{
|
||||||
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
|
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
|
||||||
mutex_exit(&mutex_list_mutex);
|
mutex_exit(&mutex_list_mutex);
|
||||||
@ -6632,15 +6635,16 @@ innodb_mutex_show_status(
|
|||||||
mutex = UT_LIST_GET_NEXT(list, mutex);
|
mutex = UT_LIST_GET_NEXT(list, mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
my_snprintf(buf2, sizeof(buf2),
|
buf2len= my_snprintf(buf2, sizeof(buf2),
|
||||||
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
|
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
|
||||||
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
|
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
|
||||||
rw_lock_count, rw_lock_count_spin_loop,
|
rw_lock_count, rw_lock_count_spin_loop,
|
||||||
rw_lock_count_spin_rounds,
|
rw_lock_count_spin_rounds,
|
||||||
rw_lock_count_os_wait, rw_lock_count_os_yield,
|
rw_lock_count_os_wait, rw_lock_count_os_yield,
|
||||||
rw_lock_wait_time/1000);
|
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);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ static handler *myisam_create_handler(TABLE_SHARE *table);
|
|||||||
/* MyISAM handlerton */
|
/* MyISAM handlerton */
|
||||||
|
|
||||||
handlerton myisam_hton= {
|
handlerton myisam_hton= {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"MyISAM",
|
"MyISAM",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"Default engine as of MySQL 3.23 with great performance",
|
"Default engine as of MySQL 3.23 with great performance",
|
||||||
@ -82,12 +83,9 @@ handlerton myisam_hton= {
|
|||||||
myisam_create_handler, /* Create a new handler */
|
myisam_create_handler, /* Create a new handler */
|
||||||
NULL, /* Drop a database */
|
NULL, /* Drop a database */
|
||||||
mi_panic,/* Panic call */
|
mi_panic,/* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
NULL, /* Flush logs */
|
NULL, /* Flush logs */
|
||||||
NULL, /* Show status */
|
NULL, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_CAN_RECREATE
|
HTON_CAN_RECREATE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ static handler *myisammrg_create_handler(TABLE_SHARE *table);
|
|||||||
/* MyISAM MERGE handlerton */
|
/* MyISAM MERGE handlerton */
|
||||||
|
|
||||||
handlerton myisammrg_hton= {
|
handlerton myisammrg_hton= {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"MRG_MYISAM",
|
"MRG_MYISAM",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"Collection of identical MyISAM tables",
|
"Collection of identical MyISAM tables",
|
||||||
@ -60,12 +61,9 @@ handlerton myisammrg_hton= {
|
|||||||
myisammrg_create_handler, /* Create a new handler */
|
myisammrg_create_handler, /* Create a new handler */
|
||||||
NULL, /* Drop a database */
|
NULL, /* Drop a database */
|
||||||
myrg_panic, /* Panic call */
|
myrg_panic, /* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
NULL, /* Flush logs */
|
NULL, /* Flush logs */
|
||||||
NULL, /* Show status */
|
NULL, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_CAN_RECREATE
|
HTON_CAN_RECREATE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ static int ndbcluster_rollback(THD *thd, bool all);
|
|||||||
static handler* ndbcluster_create_handler(TABLE_SHARE *table);
|
static handler* ndbcluster_create_handler(TABLE_SHARE *table);
|
||||||
|
|
||||||
handlerton ndbcluster_hton = {
|
handlerton ndbcluster_hton = {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"ndbcluster",
|
"ndbcluster",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"Clustered, fault-tolerant, memory-based tables",
|
"Clustered, fault-tolerant, memory-based tables",
|
||||||
@ -82,12 +83,9 @@ handlerton ndbcluster_hton = {
|
|||||||
ndbcluster_create_handler, /* Create a new handler */
|
ndbcluster_create_handler, /* Create a new handler */
|
||||||
ndbcluster_drop_database, /* Drop a database */
|
ndbcluster_drop_database, /* Drop a database */
|
||||||
ndbcluster_end, /* Panic call */
|
ndbcluster_end, /* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
NULL, /* Flush logs */
|
NULL, /* Flush logs */
|
||||||
ndbcluster_show_status, /* Show status */
|
ndbcluster_show_status, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_NO_FLAGS
|
HTON_NO_FLAGS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -8060,10 +8058,12 @@ ndbcluster_show_status(THD* thd, stat_print_fn *stat_print,
|
|||||||
Ndb::Free_list_usage tmp; tmp.m_name= 0;
|
Ndb::Free_list_usage tmp; tmp.m_name= 0;
|
||||||
while (ndb->get_free_list_usage(&tmp))
|
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",
|
"created=%u, free=%u, sizeof=%u",
|
||||||
tmp.m_created, tmp.m_free, tmp.m_sizeof);
|
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);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ static PARTITION_SHARE *get_share(const char *table_name, TABLE * table);
|
|||||||
static handler *partition_create_handler(TABLE_SHARE *share);
|
static handler *partition_create_handler(TABLE_SHARE *share);
|
||||||
|
|
||||||
handlerton partition_hton = {
|
handlerton partition_hton = {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"partition",
|
"partition",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"Partition Storage Engine Helper", /* A comment used by SHOW to describe an engine */
|
"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 */
|
partition_create_handler, /* Create a new handler */
|
||||||
NULL, /* Drop a database */
|
NULL, /* Drop a database */
|
||||||
NULL, /* Panic call */
|
NULL, /* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
NULL, /* Flush logs */
|
NULL, /* Flush logs */
|
||||||
NULL, /* Show status */
|
NULL, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_NOT_USER_SELECTABLE
|
HTON_NOT_USER_SELECTABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -697,6 +695,7 @@ bool ha_partition::create_handler_file(const char *name)
|
|||||||
void ha_partition::clear_handler_file()
|
void ha_partition::clear_handler_file()
|
||||||
{
|
{
|
||||||
my_free((char*) m_file_buffer, MYF(MY_ALLOW_ZERO_PTR));
|
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_file_buffer= NULL;
|
||||||
m_name_buffer_ptr= NULL;
|
m_name_buffer_ptr= NULL;
|
||||||
m_engine_array= NULL;
|
m_engine_array= NULL;
|
||||||
@ -715,18 +714,19 @@ bool ha_partition::create_handlers()
|
|||||||
for (i= 0; i < m_tot_parts; i++)
|
for (i= 0; i < m_tot_parts; i++)
|
||||||
{
|
{
|
||||||
if (!(m_file[i]= get_new_handler(table_share, current_thd->mem_root,
|
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_RETURN(TRUE);
|
||||||
DBUG_PRINT("info", ("engine_type: %u", m_engine_array[i]));
|
DBUG_PRINT("info", ("engine_type: %u", m_engine_array[i]));
|
||||||
}
|
}
|
||||||
m_file[m_tot_parts]= 0;
|
m_file[m_tot_parts]= 0;
|
||||||
/* For the moment we only support partition over the same table engine */
|
/* 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"));
|
DBUG_PRINT("info", ("MyISAM"));
|
||||||
m_myisam= TRUE;
|
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"));
|
DBUG_PRINT("info", ("InnoDB"));
|
||||||
m_innodb= TRUE;
|
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,
|
if (!(m_file[i]= get_new_handler(table_share, thd->mem_root,
|
||||||
part_elem->engine_type)))
|
part_elem->engine_type)))
|
||||||
goto error;
|
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)
|
if (m_is_sub_partitioned)
|
||||||
{
|
{
|
||||||
for (j= 0; j < m_part_info->no_subparts; j++)
|
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,
|
if (!(m_file[i]= get_new_handler(table_share, thd->mem_root,
|
||||||
part_elem->engine_type)))
|
part_elem->engine_type)))
|
||||||
goto error;
|
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);
|
} 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"));
|
DBUG_PRINT("info", ("MyISAM"));
|
||||||
m_myisam= TRUE;
|
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;
|
char buff[FN_REFLEN], *address_tot_name_len;
|
||||||
File file;
|
File file;
|
||||||
char *file_buffer, *name_buffer_ptr;
|
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;
|
uint i, len_bytes, len_words, tot_partition_words, tot_name_words, chksum;
|
||||||
DBUG_ENTER("ha_partition::get_from_handler_file");
|
DBUG_ENTER("ha_partition::get_from_handler_file");
|
||||||
DBUG_PRINT("enter", ("table name: '%s'", name));
|
DBUG_PRINT("enter", ("table name: '%s'", name));
|
||||||
@ -824,7 +824,11 @@ bool ha_partition::get_from_handler_file(const char *name)
|
|||||||
goto err2;
|
goto err2;
|
||||||
m_tot_parts= uint4korr((file_buffer) + 8);
|
m_tot_parts= uint4korr((file_buffer) + 8);
|
||||||
tot_partition_words= (m_tot_parts + 3) / 4;
|
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;
|
address_tot_name_len= file_buffer + 12 + 4 * tot_partition_words;
|
||||||
tot_name_words= (uint4korr(address_tot_name_len) + 3) / 4;
|
tot_name_words= (uint4korr(address_tot_name_len) + 3) / 4;
|
||||||
if (len_words != (tot_partition_words + tot_name_words + 4))
|
if (len_words != (tot_partition_words + tot_name_words + 4))
|
||||||
|
@ -46,7 +46,7 @@ private:
|
|||||||
/* Data for the partition handler */
|
/* Data for the partition handler */
|
||||||
char *m_file_buffer; // Buffer with names
|
char *m_file_buffer; // Buffer with names
|
||||||
char *m_name_buffer_ptr; // Pointer to first partition name
|
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.
|
handler **m_file; // Array of references to handler inst.
|
||||||
partition_info *m_part_info; // local reference to partition
|
partition_info *m_part_info; // local reference to partition
|
||||||
byte *m_start_key_ref; // Reference of start key in current
|
byte *m_start_key_ref; // Reference of start key in current
|
||||||
|
805
sql/handler.cc
805
sql/handler.cc
File diff suppressed because it is too large
Load Diff
@ -178,7 +178,7 @@
|
|||||||
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
|
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
|
||||||
#define MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
|
#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_UNKNOWN=0,DB_TYPE_DIAB_ISAM=1,
|
||||||
DB_TYPE_HASH,DB_TYPE_MISAM,DB_TYPE_PISAM,
|
DB_TYPE_HASH,DB_TYPE_MISAM,DB_TYPE_PISAM,
|
||||||
@ -191,7 +191,7 @@ enum db_type
|
|||||||
DB_TYPE_BLACKHOLE_DB,
|
DB_TYPE_BLACKHOLE_DB,
|
||||||
DB_TYPE_PARTITION_DB,
|
DB_TYPE_PARTITION_DB,
|
||||||
DB_TYPE_BINLOG,
|
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,
|
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;
|
typedef struct st_table_share TABLE_SHARE;
|
||||||
struct st_foreign_key_info;
|
struct st_foreign_key_info;
|
||||||
typedef struct st_foreign_key_info 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,
|
typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
|
||||||
const char *status);
|
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 };
|
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
|
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
|
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.
|
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.
|
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
|
Method that initizlizes a storage engine
|
||||||
*/
|
*/
|
||||||
@ -416,19 +424,17 @@ typedef struct
|
|||||||
handler *(*create)(TABLE_SHARE *table);
|
handler *(*create)(TABLE_SHARE *table);
|
||||||
void (*drop_database)(char* path);
|
void (*drop_database)(char* path);
|
||||||
int (*panic)(enum ha_panic_function flag);
|
int (*panic)(enum ha_panic_function flag);
|
||||||
int (*release_temporary_latches)(THD *thd);
|
|
||||||
int (*update_statistics)();
|
|
||||||
int (*start_consistent_snapshot)(THD *thd);
|
int (*start_consistent_snapshot)(THD *thd);
|
||||||
bool (*flush_logs)();
|
bool (*flush_logs)();
|
||||||
bool (*show_status)(THD *thd, stat_print_fn *print, enum ha_stat_type stat);
|
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 */
|
uint32 flags; /* global handler flags */
|
||||||
} handlerton;
|
} handlerton;
|
||||||
|
|
||||||
|
extern const handlerton default_hton;
|
||||||
|
|
||||||
struct show_table_alias_st {
|
struct show_table_alias_st {
|
||||||
const char *alias;
|
const char *alias;
|
||||||
const char *type;
|
enum legacy_db_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Possible flags of a handlerton */
|
/* Possible flags of a handlerton */
|
||||||
@ -496,7 +502,7 @@ public:
|
|||||||
char* part_comment;
|
char* part_comment;
|
||||||
char* data_file_name;
|
char* data_file_name;
|
||||||
char* index_file_name;
|
char* index_file_name;
|
||||||
enum db_type engine_type;
|
handlerton *engine_type;
|
||||||
enum partition_state part_state;
|
enum partition_state part_state;
|
||||||
uint16 nodegroup_id;
|
uint16 nodegroup_id;
|
||||||
|
|
||||||
@ -504,7 +510,7 @@ public:
|
|||||||
: part_max_rows(0), part_min_rows(0), partition_name(NULL),
|
: part_max_rows(0), part_min_rows(0), partition_name(NULL),
|
||||||
tablespace_name(NULL), range_value(0), part_comment(NULL),
|
tablespace_name(NULL), range_value(0), part_comment(NULL),
|
||||||
data_file_name(NULL), index_file_name(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)
|
nodegroup_id(UNDEF_NODEGROUP)
|
||||||
{
|
{
|
||||||
subpartitions.empty();
|
subpartitions.empty();
|
||||||
@ -567,7 +573,7 @@ public:
|
|||||||
key_map all_fields_in_PF, all_fields_in_PPF, all_fields_in_SPF;
|
key_map all_fields_in_PF, all_fields_in_PPF, all_fields_in_SPF;
|
||||||
key_map some_fields_in_PF;
|
key_map some_fields_in_PF;
|
||||||
|
|
||||||
enum db_type default_engine_type;
|
handlerton *default_engine_type;
|
||||||
Item_result part_result_type;
|
Item_result part_result_type;
|
||||||
partition_type part_type;
|
partition_type part_type;
|
||||||
partition_type subpart_type;
|
partition_type subpart_type;
|
||||||
@ -608,7 +614,7 @@ public:
|
|||||||
part_info_string(NULL),
|
part_info_string(NULL),
|
||||||
part_func_string(NULL), subpart_func_string(NULL),
|
part_func_string(NULL), subpart_func_string(NULL),
|
||||||
curr_part_elem(NULL), current_partition(NULL),
|
curr_part_elem(NULL), current_partition(NULL),
|
||||||
default_engine_type(DB_TYPE_UNKNOWN),
|
default_engine_type(NULL),
|
||||||
part_result_type(INT_RESULT),
|
part_result_type(INT_RESULT),
|
||||||
part_type(NOT_A_PARTITION), subpart_type(NOT_A_PARTITION),
|
part_type(NOT_A_PARTITION), subpart_type(NOT_A_PARTITION),
|
||||||
part_info_len(0), part_func_len(0), subpart_func_len(0),
|
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 raid_chunksize;
|
||||||
ulong used_fields;
|
ulong used_fields;
|
||||||
SQL_LIST merge_list;
|
SQL_LIST merge_list;
|
||||||
enum db_type db_type;
|
handlerton *db_type;
|
||||||
enum row_type row_type;
|
enum row_type row_type;
|
||||||
uint null_bits; /* NULL bits at start of record */
|
uint null_bits; /* NULL bits at start of record */
|
||||||
uint options; /* OR of HA_CREATE_ options */
|
uint options; /* OR of HA_CREATE_ options */
|
||||||
@ -727,7 +733,7 @@ int get_parts_for_update(const byte *old_data, byte *new_data,
|
|||||||
uint32 *old_part_id, uint32 *new_part_id);
|
uint32 *old_part_id, uint32 *new_part_id);
|
||||||
int get_part_for_delete(const byte *buf, const byte *rec0,
|
int get_part_for_delete(const byte *buf, const byte *rec0,
|
||||||
partition_info *part_info, uint32 *part_id);
|
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);
|
handler *file, ulonglong max_rows);
|
||||||
bool fix_partition_func(THD *thd, const char *name, TABLE *table);
|
bool fix_partition_func(THD *thd, const char *name, TABLE *table);
|
||||||
char *generate_partition_syntax(partition_info *part_info,
|
char *generate_partition_syntax(partition_info *part_info,
|
||||||
@ -743,7 +749,7 @@ void get_full_part_id_from_key(const TABLE *table, byte *buf,
|
|||||||
part_id_range *part_spec);
|
part_id_range *part_spec);
|
||||||
bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
|
bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
|
||||||
uint part_info_len, TABLE *table,
|
uint part_info_len, TABLE *table,
|
||||||
enum db_type default_db_type);
|
handlerton *default_db_type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -1413,32 +1419,56 @@ extern ulong total_ha, total_ha_2pc;
|
|||||||
#define ha_rollback(thd) (ha_rollback_trans((thd), TRUE))
|
#define ha_rollback(thd) (ha_rollback_trans((thd), TRUE))
|
||||||
|
|
||||||
/* lookups */
|
/* lookups */
|
||||||
enum db_type ha_resolve_by_name(const char *name, uint namelen);
|
handlerton *ha_resolve_by_name(THD *thd, LEX_STRING *name);
|
||||||
const char *ha_get_storage_engine(enum db_type db_type);
|
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,
|
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
|
||||||
enum db_type db_type);
|
handlerton *db_type);
|
||||||
enum db_type ha_checktype(THD *thd, enum db_type database_type,
|
handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
|
||||||
bool no_substitute, bool report_error);
|
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 */
|
/* basic stuff */
|
||||||
int ha_init(void);
|
int ha_init(void);
|
||||||
|
int ha_register_builtin_plugins();
|
||||||
|
int ha_initialize_handlerton(handlerton *hton);
|
||||||
|
|
||||||
TYPELIB *ha_known_exts(void);
|
TYPELIB *ha_known_exts(void);
|
||||||
int ha_panic(enum ha_panic_function flag);
|
int ha_panic(enum ha_panic_function flag);
|
||||||
int ha_update_statistics();
|
int ha_update_statistics();
|
||||||
void ha_close_connection(THD* thd);
|
void ha_close_connection(THD* thd);
|
||||||
my_bool ha_storage_engine_is_enabled(enum db_type database_type);
|
bool ha_flush_logs(handlerton *db_type);
|
||||||
bool ha_flush_logs(enum db_type db_type=DB_TYPE_DEFAULT);
|
|
||||||
void ha_drop_database(char* path);
|
void ha_drop_database(char* path);
|
||||||
int ha_create_table(THD *thd, const char *path,
|
int ha_create_table(THD *thd, const char *path,
|
||||||
const char *db, const char *table_name,
|
const char *db, const char *table_name,
|
||||||
HA_CREATE_INFO *create_info,
|
HA_CREATE_INFO *create_info,
|
||||||
bool update_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);
|
const char *db, const char *alias, bool generate_warning);
|
||||||
|
|
||||||
/* statistics and info */
|
/* 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 */
|
/* discovery */
|
||||||
int ha_create_table_from_engine(THD* thd, const char *db, const char *name);
|
int ha_create_table_from_engine(THD* thd, const char *db, const char *name);
|
||||||
|
@ -2321,7 +2321,7 @@ bool Item_sum_count_distinct::setup(THD *thd)
|
|||||||
table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows
|
table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows
|
||||||
table->no_rows=1;
|
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
|
No blobs, otherwise it would have been MyISAM: set up a compare
|
||||||
|
@ -48,6 +48,7 @@ static int binlog_rollback(THD *thd, bool all);
|
|||||||
static int binlog_prepare(THD *thd, bool all);
|
static int binlog_prepare(THD *thd, bool all);
|
||||||
|
|
||||||
handlerton binlog_hton = {
|
handlerton binlog_hton = {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"binlog",
|
"binlog",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"This is a meta storage engine to represent the binlog in a transaction",
|
"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, /* Create a new handler */
|
||||||
NULL, /* Drop a database */
|
NULL, /* Drop a database */
|
||||||
NULL, /* Panic call */
|
NULL, /* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
NULL, /* Flush logs */
|
NULL, /* Flush logs */
|
||||||
NULL, /* Show status */
|
NULL, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_NOT_USER_SELECTABLE | HTON_HIDDEN
|
HTON_NOT_USER_SELECTABLE | HTON_HIDDEN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -602,7 +602,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,
|
int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables,
|
||||||
bool if_exists, bool drop_temporary,
|
bool if_exists, bool drop_temporary,
|
||||||
bool log_query);
|
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);
|
const char *table_name);
|
||||||
void close_cached_table(THD *thd, TABLE *table);
|
void close_cached_table(THD *thd, TABLE *table);
|
||||||
bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list);
|
bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list);
|
||||||
@ -748,7 +748,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,
|
bool mysql_create_like_table(THD *thd, TABLE_LIST *table,
|
||||||
HA_CREATE_INFO *create_info,
|
HA_CREATE_INFO *create_info,
|
||||||
Table_ident *src_table);
|
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_db,
|
||||||
const char * old_name,
|
const char * old_name,
|
||||||
const char *new_db,
|
const char *new_db,
|
||||||
@ -1001,7 +1001,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);
|
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,
|
TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
|
||||||
const char *table_name, bool link_in_list);
|
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 free_io_cache(TABLE *entry);
|
||||||
void intern_close_table(TABLE *entry);
|
void intern_close_table(TABLE *entry);
|
||||||
bool close_thread_table(THD *thd, TABLE **table_ptr);
|
bool close_thread_table(THD *thd, TABLE **table_ptr);
|
||||||
@ -1329,6 +1329,10 @@ extern handlerton partition_hton;
|
|||||||
extern SHOW_COMP_OPTION have_partition_db;
|
extern SHOW_COMP_OPTION have_partition_db;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern handlerton myisam_hton;
|
||||||
|
extern handlerton myisammrg_hton;
|
||||||
|
extern handlerton heap_hton;
|
||||||
|
|
||||||
extern SHOW_COMP_OPTION have_isam;
|
extern SHOW_COMP_OPTION have_isam;
|
||||||
extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink;
|
extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink;
|
||||||
extern SHOW_COMP_OPTION have_query_cache;
|
extern SHOW_COMP_OPTION have_query_cache;
|
||||||
|
@ -2622,6 +2622,18 @@ static int init_common_variables(const char *conf_file_name, int argc,
|
|||||||
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
|
strmake(pidfile_name, glob_hostname, sizeof(pidfile_name)-5);
|
||||||
strmov(fn_ext(pidfile_name),".pid"); // Add proper extension
|
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);
|
load_defaults(conf_file_name, groups, &argc, &argv);
|
||||||
defaults_argv=argv;
|
defaults_argv=argv;
|
||||||
get_options(argc,argv);
|
get_options(argc,argv);
|
||||||
@ -3105,17 +3117,15 @@ server.");
|
|||||||
/*
|
/*
|
||||||
Check that the default storage engine is actually available.
|
Check that the default storage engine is actually available.
|
||||||
*/
|
*/
|
||||||
if (!ha_storage_engine_is_enabled((enum db_type)
|
if (!ha_storage_engine_is_enabled(global_system_variables.table_type))
|
||||||
global_system_variables.table_type))
|
|
||||||
{
|
{
|
||||||
if (!opt_bootstrap)
|
if (!opt_bootstrap)
|
||||||
{
|
{
|
||||||
sql_print_error("Default storage engine (%s) is not available",
|
sql_print_error("Default storage engine (%s) is not available",
|
||||||
ha_get_storage_engine((enum db_type)
|
global_system_variables.table_type->name);
|
||||||
global_system_variables.table_type));
|
|
||||||
unireg_abort(1);
|
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 ?
|
tc_log= (total_ha_2pc > 1 ? (opt_bin_log ?
|
||||||
@ -3470,7 +3480,7 @@ we force server id to 2, but this MySQL server will not act as a slave.");
|
|||||||
|
|
||||||
if (!opt_noacl)
|
if (!opt_noacl)
|
||||||
{
|
{
|
||||||
plugin_init();
|
plugin_load();
|
||||||
#ifdef HAVE_DLOPEN
|
#ifdef HAVE_DLOPEN
|
||||||
udf_init();
|
udf_init();
|
||||||
#endif
|
#endif
|
||||||
@ -6102,6 +6112,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_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_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_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_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_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},
|
{"Com_show_slave_hosts", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS},
|
||||||
@ -6412,7 +6423,7 @@ static void mysql_init_variables(void)
|
|||||||
|
|
||||||
|
|
||||||
/* Set default values for some option variables */
|
/* 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.tx_isolation= ISO_REPEATABLE_READ;
|
||||||
global_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
|
global_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
|
||||||
max_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
|
max_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
|
||||||
@ -6805,9 +6816,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
break;
|
break;
|
||||||
case OPT_STORAGE_ENGINE:
|
case OPT_STORAGE_ENGINE:
|
||||||
{
|
{
|
||||||
if ((enum db_type)((global_system_variables.table_type=
|
LEX_STRING name= { argument, strlen(argument) };
|
||||||
ha_resolve_by_name(argument, strlen(argument)))) ==
|
if ((global_system_variables.table_type=
|
||||||
DB_TYPE_UNKNOWN)
|
ha_resolve_by_name(current_thd, &name)) == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Unknown/unsupported table type: %s\n",argument);
|
fprintf(stderr,"Unknown/unsupported table type: %s\n",argument);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -3034,11 +3034,12 @@ bool sys_var_thd_storage_engine::check(THD *thd, set_var *var)
|
|||||||
|
|
||||||
if (var->value->result_type() == STRING_RESULT)
|
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)) ||
|
if (!(res=var->value->val_str(&str)) ||
|
||||||
!(var->save_result.ulong_value=
|
!(name.str= (char *)res->ptr()) || !(name.length= res->length()) ||
|
||||||
(ulong) (db_type= ha_resolve_by_name(res->ptr(), res->length()))) ||
|
!(var->save_result.hton= db_type= ha_resolve_by_name(thd, &name)) ||
|
||||||
ha_checktype(thd, db_type, 1, 0) != db_type)
|
ha_checktype(thd, ha_legacy_type(db_type), 1, 0) != db_type)
|
||||||
{
|
{
|
||||||
value= res ? res->c_ptr() : "NULL";
|
value= res ? res->c_ptr() : "NULL";
|
||||||
goto err;
|
goto err;
|
||||||
@ -3056,29 +3057,28 @@ err:
|
|||||||
byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
|
byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
|
||||||
LEX_STRING *base)
|
LEX_STRING *base)
|
||||||
{
|
{
|
||||||
ulong val;
|
handlerton *val;
|
||||||
val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
|
val= (type == OPT_GLOBAL) ? global_system_variables.*offset :
|
||||||
thd->variables.*offset);
|
thd->variables.*offset;
|
||||||
const char *table_type= ha_get_storage_engine((enum db_type)val);
|
return (byte *) val->name;
|
||||||
return (byte *) table_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type)
|
void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type)
|
||||||
{
|
{
|
||||||
if (type == OPT_GLOBAL)
|
if (type == OPT_GLOBAL)
|
||||||
global_system_variables.*offset= (ulong) DB_TYPE_MYISAM;
|
global_system_variables.*offset= &myisam_hton;
|
||||||
else
|
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)
|
bool sys_var_thd_storage_engine::update(THD *thd, set_var *var)
|
||||||
{
|
{
|
||||||
if (var->type == OPT_GLOBAL)
|
handlerton **value= &(global_system_variables.*offset);
|
||||||
global_system_variables.*offset= var->save_result.ulong_value;
|
if (var->type != OPT_GLOBAL)
|
||||||
else
|
value= &(thd->variables.*offset);
|
||||||
thd->variables.*offset= var->save_result.ulong_value;
|
*value= var->save_result.hton;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,9 +379,9 @@ public:
|
|||||||
class sys_var_thd_storage_engine :public sys_var_thd
|
class sys_var_thd_storage_engine :public sys_var_thd
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
ulong SV::*offset;
|
handlerton *SV::*offset;
|
||||||
public:
|
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)
|
:sys_var_thd(name_arg), offset(offset_arg)
|
||||||
{}
|
{}
|
||||||
bool check(THD *thd, set_var *var);
|
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
|
class sys_var_thd_table_type :public sys_var_thd_storage_engine
|
||||||
{
|
{
|
||||||
public:
|
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)
|
:sys_var_thd_storage_engine(name_arg, offset_arg)
|
||||||
{}
|
{}
|
||||||
void warn_deprecated(THD *thd);
|
void warn_deprecated(THD *thd);
|
||||||
@ -812,6 +812,7 @@ public:
|
|||||||
CHARSET_INFO *charset;
|
CHARSET_INFO *charset;
|
||||||
ulong ulong_value;
|
ulong ulong_value;
|
||||||
ulonglong ulonglong_value;
|
ulonglong ulonglong_value;
|
||||||
|
handlerton *hton;
|
||||||
DATE_TIME_FORMAT *date_time_format;
|
DATE_TIME_FORMAT *date_time_format;
|
||||||
Time_zone *time_zone;
|
Time_zone *time_zone;
|
||||||
} save_result;
|
} save_result;
|
||||||
|
@ -1433,7 +1433,7 @@ void close_temporary_table(THD *thd, TABLE *table,
|
|||||||
|
|
||||||
void close_temporary(TABLE *table, bool free_share, bool delete_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");
|
DBUG_ENTER("close_temporary");
|
||||||
|
|
||||||
free_io_cache(table);
|
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];
|
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, "/",
|
strxnmov(path, FN_REFLEN-1, mysql_data_home, "/", table_list->db, "/",
|
||||||
table_list->table_name, reg_ext, NullS);
|
table_list->table_name, reg_ext, NullS);
|
||||||
(void) unpack_filename(path, path);
|
(void) unpack_filename(path, path);
|
||||||
@ -3278,7 +3278,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;
|
bool error=0;
|
||||||
handler *file;
|
handler *file;
|
||||||
|
@ -2232,7 +2232,7 @@ Query_cache::register_tables_from_list(TABLE_LIST *tables_used,
|
|||||||
tables_used->engine_data))
|
tables_used->engine_data))
|
||||||
DBUG_RETURN(0);
|
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;
|
ha_myisammrg *handler = (ha_myisammrg *) tables_used->table->file;
|
||||||
MYRG_INFO *file = handler->myrg_info();
|
MYRG_INFO *file = handler->myrg_info();
|
||||||
@ -2860,7 +2860,7 @@ static TABLE_COUNTER_TYPE process_and_count_tables(TABLE_LIST *tables_used,
|
|||||||
"other non-cacheable table(s)"));
|
"other non-cacheable table(s)"));
|
||||||
DBUG_RETURN(0);
|
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;
|
ha_myisammrg *handler = (ha_myisammrg *)tables_used->table->file;
|
||||||
MYRG_INFO *file = handler->myrg_info();
|
MYRG_INFO *file = handler->myrg_info();
|
||||||
|
@ -527,7 +527,7 @@ struct system_variables
|
|||||||
ulong read_rnd_buff_size;
|
ulong read_rnd_buff_size;
|
||||||
ulong div_precincrement;
|
ulong div_precincrement;
|
||||||
ulong sortbuff_size;
|
ulong sortbuff_size;
|
||||||
ulong table_type;
|
handlerton *table_type;
|
||||||
ulong tmp_table_size;
|
ulong tmp_table_size;
|
||||||
ulong tx_isolation;
|
ulong tx_isolation;
|
||||||
ulong completion_type;
|
ulong completion_type;
|
||||||
|
@ -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 it is a temporary table, close and regenerate it */
|
||||||
if (!dont_send_ok && (table= find_temporary_table(thd, table_list)))
|
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;
|
TABLE_SHARE *share= table->s;
|
||||||
if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE))
|
if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE))
|
||||||
goto trunc_by_del;
|
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)
|
if (!dont_send_ok)
|
||||||
{
|
{
|
||||||
db_type table_type;
|
enum legacy_db_type table_type;
|
||||||
mysql_frm_type(thd, path, &table_type);
|
mysql_frm_type(thd, path, &table_type);
|
||||||
if (table_type == DB_TYPE_UNKNOWN)
|
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);
|
table_list->db, table_list->table_name);
|
||||||
DBUG_RETURN(TRUE);
|
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)
|
|| thd->lex->sphead)
|
||||||
goto trunc_by_del;
|
goto trunc_by_del;
|
||||||
if (lock_and_wait_for_table_name(thd, table_list))
|
if (lock_and_wait_for_table_name(thd, table_list))
|
||||||
|
@ -2585,7 +2585,7 @@ void select_create::abort()
|
|||||||
if (table)
|
if (table)
|
||||||
{
|
{
|
||||||
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
|
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)
|
if (!table->s->tmp_table)
|
||||||
{
|
{
|
||||||
ulong version= table->s->version;
|
ulong version= table->s->version;
|
||||||
|
@ -93,7 +93,7 @@ enum enum_sql_command {
|
|||||||
SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
|
SQLCOM_XA_COMMIT, SQLCOM_XA_ROLLBACK, SQLCOM_XA_RECOVER,
|
||||||
SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
|
SQLCOM_SHOW_PROC_CODE, SQLCOM_SHOW_FUNC_CODE,
|
||||||
SQLCOM_INSTALL_PLUGIN, SQLCOM_UNINSTALL_PLUGIN,
|
SQLCOM_INSTALL_PLUGIN, SQLCOM_UNINSTALL_PLUGIN,
|
||||||
SQLCOM_SHOW_AUTHORS,
|
SQLCOM_SHOW_AUTHORS, SQLCOM_SHOW_PLUGINS,
|
||||||
/* This should be the last !!! */
|
/* This should be the last !!! */
|
||||||
|
|
||||||
SQLCOM_END
|
SQLCOM_END
|
||||||
|
@ -6788,7 +6788,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
|
|||||||
rotate_relay_log(active_mi);
|
rotate_relay_log(active_mi);
|
||||||
pthread_mutex_unlock(&LOCK_active_mi);
|
pthread_mutex_unlock(&LOCK_active_mi);
|
||||||
#endif
|
#endif
|
||||||
if (ha_flush_logs())
|
if (ha_flush_logs(NULL))
|
||||||
result=1;
|
result=1;
|
||||||
if (flush_error_log())
|
if (flush_error_log())
|
||||||
result=1;
|
result=1;
|
||||||
@ -7104,7 +7104,7 @@ bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
|
|||||||
HA_CREATE_INFO create_info;
|
HA_CREATE_INFO create_info;
|
||||||
DBUG_ENTER("mysql_create_index");
|
DBUG_ENTER("mysql_create_index");
|
||||||
bzero((char*) &create_info,sizeof(create_info));
|
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;
|
create_info.default_table_charset= thd->variables.collation_database;
|
||||||
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
|
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
|
||||||
&create_info, table_list,
|
&create_info, table_list,
|
||||||
@ -7120,7 +7120,7 @@ bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info)
|
|||||||
HA_CREATE_INFO create_info;
|
HA_CREATE_INFO create_info;
|
||||||
DBUG_ENTER("mysql_drop_index");
|
DBUG_ENTER("mysql_drop_index");
|
||||||
bzero((char*) &create_info,sizeof(create_info));
|
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;
|
create_info.default_table_charset= thd->variables.collation_database;
|
||||||
alter_info->clear();
|
alter_info->clear();
|
||||||
alter_info->flags= ALTER_DROP_INDEX;
|
alter_info->flags= ALTER_DROP_INDEX;
|
||||||
|
@ -599,7 +599,7 @@ static bool set_up_default_partitions(partition_info *part_info,
|
|||||||
partition_element *part_elem= new partition_element();
|
partition_element *part_elem= new partition_element();
|
||||||
if (likely(part_elem != 0))
|
if (likely(part_elem != 0))
|
||||||
{
|
{
|
||||||
part_elem->engine_type= DB_TYPE_UNKNOWN;
|
part_elem->engine_type= NULL;
|
||||||
part_elem->partition_name= default_name;
|
part_elem->partition_name= default_name;
|
||||||
default_name+=MAX_PART_NAME_SIZE;
|
default_name+=MAX_PART_NAME_SIZE;
|
||||||
part_info->partitions.push_back(part_elem);
|
part_info->partitions.push_back(part_elem);
|
||||||
@ -671,7 +671,7 @@ static bool set_up_default_subpartitions(partition_info *part_info,
|
|||||||
partition_element *subpart_elem= new partition_element();
|
partition_element *subpart_elem= new partition_element();
|
||||||
if (likely(subpart_elem != 0))
|
if (likely(subpart_elem != 0))
|
||||||
{
|
{
|
||||||
subpart_elem->engine_type= DB_TYPE_UNKNOWN;
|
subpart_elem->engine_type= NULL;
|
||||||
subpart_elem->partition_name= name_ptr;
|
subpart_elem->partition_name= name_ptr;
|
||||||
name_ptr+= MAX_PART_NAME_SIZE;
|
name_ptr+= MAX_PART_NAME_SIZE;
|
||||||
part_elem->subpartitions.push_back(subpart_elem);
|
part_elem->subpartitions.push_back(subpart_elem);
|
||||||
@ -731,7 +731,7 @@ bool set_up_defaults_for_partitioning(partition_info *part_info,
|
|||||||
FALSE Ok, no mixed engines
|
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.
|
Current check verifies only that all handlers are the same.
|
||||||
@ -772,10 +772,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.
|
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)
|
handler *file, ulonglong max_rows)
|
||||||
{
|
{
|
||||||
u_char *engine_array= NULL;
|
handlerton **engine_array= NULL;
|
||||||
uint part_count= 0, i, no_parts, tot_partitions;
|
uint part_count= 0, i, no_parts, tot_partitions;
|
||||||
bool result= TRUE;
|
bool result= TRUE;
|
||||||
List_iterator<partition_element> part_it(part_info->partitions);
|
List_iterator<partition_element> part_it(part_info->partitions);
|
||||||
@ -803,7 +803,8 @@ bool check_partition_info(partition_info *part_info,enum db_type eng_type,
|
|||||||
my_error(ER_SAME_NAME_PARTITION, MYF(0));
|
my_error(ER_SAME_NAME_PARTITION, MYF(0));
|
||||||
goto end;
|
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))
|
if (unlikely(!engine_array))
|
||||||
goto end;
|
goto end;
|
||||||
i= 0;
|
i= 0;
|
||||||
@ -813,10 +814,10 @@ bool check_partition_info(partition_info *part_info,enum db_type eng_type,
|
|||||||
partition_element *part_elem= part_it++;
|
partition_element *part_elem= part_it++;
|
||||||
if (!is_sub_partitioned(part_info))
|
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;
|
part_elem->engine_type= eng_type;
|
||||||
DBUG_PRINT("info", ("engine = %u",(uint)part_elem->engine_type));
|
DBUG_PRINT("info", ("engine = %s", part_elem->engine_type->name));
|
||||||
engine_array[part_count++]= (u_char)part_elem->engine_type;
|
engine_array[part_count++]= part_elem->engine_type;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -825,10 +826,10 @@ bool check_partition_info(partition_info *part_info,enum db_type eng_type,
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
part_elem= sub_it++;
|
part_elem= sub_it++;
|
||||||
if (part_elem->engine_type == DB_TYPE_UNKNOWN)
|
if (part_elem->engine_type == NULL)
|
||||||
part_elem->engine_type= eng_type;
|
part_elem->engine_type= eng_type;
|
||||||
DBUG_PRINT("info", ("engine = %u",(uint)part_elem->engine_type));
|
DBUG_PRINT("info", ("engine = %s", part_elem->engine_type->name));
|
||||||
engine_array[part_count++]= (u_char)part_elem->engine_type;
|
engine_array[part_count++]= part_elem->engine_type;
|
||||||
} while (++j < no_subparts);
|
} while (++j < no_subparts);
|
||||||
}
|
}
|
||||||
} while (++i < part_info->no_parts);
|
} while (++i < part_info->no_parts);
|
||||||
@ -1895,9 +1896,9 @@ static int add_keyword_int(File fptr, const char *keyword, longlong num)
|
|||||||
return err + add_space(fptr);
|
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 = ");
|
int err= add_string(fptr, "ENGINE = ");
|
||||||
return err + add_string(fptr, engine_str);
|
return err + add_string(fptr, engine_str);
|
||||||
return err;
|
return err;
|
||||||
@ -3092,7 +3093,7 @@ void get_partition_set(const TABLE *table, byte *buf, const uint index,
|
|||||||
|
|
||||||
bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
|
bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
|
||||||
uint part_info_len, TABLE* table,
|
uint part_info_len, TABLE* table,
|
||||||
enum db_type default_db_type)
|
handlerton *default_db_type)
|
||||||
{
|
{
|
||||||
Item *thd_free_list= thd->free_list;
|
Item *thd_free_list= thd->free_list;
|
||||||
bool result= TRUE;
|
bool result= TRUE;
|
||||||
@ -3129,7 +3130,7 @@ bool mysql_unpack_partition(THD *thd, const uchar *part_buf,
|
|||||||
part_info= lex.part_info;
|
part_info= lex.part_info;
|
||||||
table->part_info= part_info;
|
table->part_info= part_info;
|
||||||
table->file->set_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;
|
part_info->default_engine_type= default_db_type;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,6 @@ static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM];
|
|||||||
static rw_lock_t THR_LOCK_plugin;
|
static rw_lock_t THR_LOCK_plugin;
|
||||||
static bool initialized= 0;
|
static bool initialized= 0;
|
||||||
|
|
||||||
|
|
||||||
static struct st_plugin_dl *plugin_dl_find(LEX_STRING *dl)
|
static struct st_plugin_dl *plugin_dl_find(LEX_STRING *dl)
|
||||||
{
|
{
|
||||||
uint i;
|
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)
|
static void plugin_call_initializer(void)
|
||||||
{
|
{
|
||||||
uint i;
|
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 *tmp= dynamic_element(&plugin_array, i,
|
||||||
struct st_plugin_int *);
|
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)
|
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;
|
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_LIST tables;
|
||||||
TABLE *table;
|
TABLE *table;
|
||||||
READ_RECORD read_record_info;
|
READ_RECORD read_record_info;
|
||||||
int error, i;
|
int error, i;
|
||||||
MEM_ROOT mem;
|
MEM_ROOT mem;
|
||||||
DBUG_ENTER("plugin_init");
|
THD *new_thd;
|
||||||
if (initialized)
|
DBUG_ENTER("plugin_load");
|
||||||
DBUG_VOID_RETURN;
|
|
||||||
my_rwlock_init(&THR_LOCK_plugin, NULL);
|
DBUG_ASSERT(initialized);
|
||||||
THD *new_thd = new THD;
|
|
||||||
if (!new_thd ||
|
if (!(new_thd= 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))
|
|
||||||
{
|
{
|
||||||
sql_print_error("Can't allocate memory for plugin structures");
|
sql_print_error("Can't allocate memory for plugin structures");
|
||||||
delete new_thd;
|
delete new_thd;
|
||||||
delete_dynamic(&plugin_dl_array);
|
|
||||||
delete_dynamic(&plugin_array);
|
|
||||||
DBUG_VOID_RETURN;
|
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);
|
init_sql_alloc(&mem, 1024, 0);
|
||||||
initialized= 1;
|
|
||||||
new_thd->thread_stack= (char*) &tables;
|
new_thd->thread_stack= (char*) &tables;
|
||||||
new_thd->store_globals();
|
new_thd->store_globals();
|
||||||
new_thd->db= my_strdup("mysql", MYF(0));
|
new_thd->db= my_strdup("mysql", MYF(0));
|
||||||
@ -458,10 +529,6 @@ void plugin_init(void)
|
|||||||
{
|
{
|
||||||
DBUG_PRINT("error",("Can't open plugin table"));
|
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.");
|
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;
|
goto end;
|
||||||
}
|
}
|
||||||
table= tables.table;
|
table= tables.table;
|
||||||
@ -530,27 +597,31 @@ my_bool mysql_install_plugin(THD *thd, LEX_STRING *name, LEX_STRING *dl)
|
|||||||
int error;
|
int error;
|
||||||
struct st_plugin_int *tmp;
|
struct st_plugin_int *tmp;
|
||||||
DBUG_ENTER("mysql_install_plugin");
|
DBUG_ENTER("mysql_install_plugin");
|
||||||
|
|
||||||
bzero(&tables, sizeof(tables));
|
bzero(&tables, sizeof(tables));
|
||||||
tables.db= (char *)"mysql";
|
tables.db= (char *)"mysql";
|
||||||
tables.table_name= tables.alias= (char *)"plugin";
|
tables.table_name= tables.alias= (char *)"plugin";
|
||||||
if (check_table_access(thd, INSERT_ACL, &tables, 0))
|
if (check_table_access(thd, INSERT_ACL, &tables, 0))
|
||||||
DBUG_RETURN(TRUE);
|
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);
|
rw_wrlock(&THR_LOCK_plugin);
|
||||||
if (plugin_add(name, dl, REPORT_TO_USER))
|
if (plugin_add(name, dl, REPORT_TO_USER))
|
||||||
goto err;
|
goto err;
|
||||||
tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN);
|
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.");
|
||||||
my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str,
|
goto err;
|
||||||
"Plugin initialization function failed.");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
tmp->state= PLUGIN_IS_READY;
|
|
||||||
}
|
}
|
||||||
if (! (table = open_ltable(thd, &tables, TL_WRITE)))
|
|
||||||
goto deinit;
|
tmp->state= PLUGIN_IS_READY;
|
||||||
|
|
||||||
restore_record(table, s->default_values);
|
restore_record(table, s->default_values);
|
||||||
table->field[0]->store(name->str, name->length, system_charset_info);
|
table->field[0]->store(name->str, name->length, system_charset_info);
|
||||||
table->field[1]->store(dl->str, dl->length, files_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));
|
table->file->print_error(error, MYF(0));
|
||||||
goto deinit;
|
goto deinit;
|
||||||
}
|
}
|
||||||
|
|
||||||
rw_unlock(&THR_LOCK_plugin);
|
rw_unlock(&THR_LOCK_plugin);
|
||||||
DBUG_RETURN(FALSE);
|
DBUG_RETURN(FALSE);
|
||||||
deinit:
|
deinit:
|
||||||
@ -578,12 +650,29 @@ my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name)
|
|||||||
TABLE_LIST tables;
|
TABLE_LIST tables;
|
||||||
struct st_plugin_int *plugin;
|
struct st_plugin_int *plugin;
|
||||||
DBUG_ENTER("mysql_uninstall_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);
|
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);
|
my_error(ER_SP_DOES_NOT_EXIST, MYF(0), "PLUGIN", name->str);
|
||||||
goto err;
|
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)
|
if (plugin->ref_count)
|
||||||
{
|
{
|
||||||
plugin->state= PLUGIN_IS_DELETED;
|
plugin->state= PLUGIN_IS_DELETED;
|
||||||
@ -596,11 +685,7 @@ my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name)
|
|||||||
plugin->plugin->deinit();
|
plugin->plugin->deinit();
|
||||||
plugin_del(name);
|
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->field[0]->store(name->str, name->length, system_charset_info);
|
||||||
table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
|
table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS);
|
||||||
if (! table->file->index_read_idx(table->record[0], 0,
|
if (! table->file->index_read_idx(table->record[0], 0,
|
||||||
@ -621,3 +706,44 @@ err:
|
|||||||
rw_unlock(&THR_LOCK_plugin);
|
rw_unlock(&THR_LOCK_plugin);
|
||||||
DBUG_RETURN(TRUE);
|
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);
|
||||||
|
}
|
||||||
|
@ -53,11 +53,20 @@ struct st_plugin_int
|
|||||||
|
|
||||||
extern char *opt_plugin_dir_ptr;
|
extern char *opt_plugin_dir_ptr;
|
||||||
extern char opt_plugin_dir[FN_REFLEN];
|
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 void plugin_free(void);
|
||||||
extern my_bool plugin_is_ready(LEX_STRING *name, int type);
|
extern my_bool plugin_is_ready(LEX_STRING *name, int type);
|
||||||
extern st_plugin_int *plugin_lock(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 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_install_plugin(THD *thd, LEX_STRING *name, LEX_STRING *dl);
|
||||||
extern my_bool mysql_uninstall_plugin(THD *thd, LEX_STRING *name);
|
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
|
#endif
|
||||||
|
@ -134,7 +134,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
|
|||||||
{
|
{
|
||||||
TABLE_LIST *ren_table,*new_table;
|
TABLE_LIST *ren_table,*new_table;
|
||||||
frm_type_enum frm_type;
|
frm_type_enum frm_type;
|
||||||
db_type table_type;
|
enum legacy_db_type table_type;
|
||||||
|
|
||||||
DBUG_ENTER("rename_tables");
|
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)
|
if (table_type == DB_TYPE_UNKNOWN)
|
||||||
my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
|
my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
|
||||||
else
|
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);
|
new_table->db, new_alias);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -8589,7 +8589,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
|||||||
OPTION_BIG_TABLES || (select_options & TMP_TABLE_FORCE_MYISAM))
|
OPTION_BIG_TABLES || (select_options & TMP_TABLE_FORCE_MYISAM))
|
||||||
{
|
{
|
||||||
table->file= get_new_handler(share, &table->mem_root,
|
table->file= get_new_handler(share, &table->mem_root,
|
||||||
share->db_type= DB_TYPE_MYISAM);
|
share->db_type= &myisam_hton);
|
||||||
if (group &&
|
if (group &&
|
||||||
(param->group_parts > table->file->max_key_parts() ||
|
(param->group_parts > table->file->max_key_parts() ||
|
||||||
param->group_length > table->file->max_key_length()))
|
param->group_length > table->file->max_key_length()))
|
||||||
@ -8598,7 +8598,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
table->file= get_new_handler(share, &table->mem_root,
|
table->file= get_new_handler(share, &table->mem_root,
|
||||||
share->db_type= DB_TYPE_HEAP);
|
share->db_type= &heap_hton);
|
||||||
}
|
}
|
||||||
if (!table->file)
|
if (!table->file)
|
||||||
goto err;
|
goto err;
|
||||||
@ -8728,7 +8728,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
|||||||
if (thd->variables.tmp_table_size == ~(ulong) 0) // No limit
|
if (thd->variables.tmp_table_size == ~(ulong) 0) // No limit
|
||||||
share->max_rows= ~(ha_rows) 0;
|
share->max_rows= ~(ha_rows) 0;
|
||||||
else
|
else
|
||||||
share->max_rows= (((share->db_type == DB_TYPE_HEAP) ?
|
share->max_rows= (((share->db_type == &heap_hton) ?
|
||||||
min(thd->variables.tmp_table_size,
|
min(thd->variables.tmp_table_size,
|
||||||
thd->variables.max_heap_table_size) :
|
thd->variables.max_heap_table_size) :
|
||||||
thd->variables.tmp_table_size)/ share->reclength);
|
thd->variables.tmp_table_size)/ share->reclength);
|
||||||
@ -8868,7 +8868,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
|
|||||||
if (thd->is_fatal_error) // If end of memory
|
if (thd->is_fatal_error) // If end of memory
|
||||||
goto err; /* purecov: inspected */
|
goto err; /* purecov: inspected */
|
||||||
share->db_record_offset= 1;
|
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))
|
if (create_myisam_tmp_table(table,param,select_options))
|
||||||
goto err;
|
goto err;
|
||||||
@ -9175,7 +9175,8 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
|
|||||||
int write_err;
|
int write_err;
|
||||||
DBUG_ENTER("create_myisam_from_heap");
|
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));
|
table->file->print_error(error,MYF(0));
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
@ -9183,9 +9184,9 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
|
|||||||
new_table= *table;
|
new_table= *table;
|
||||||
share= *table->s;
|
share= *table->s;
|
||||||
new_table.s= &share;
|
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,
|
if (!(new_table.file= get_new_handler(&share, &new_table.mem_root,
|
||||||
DB_TYPE_MYISAM)))
|
&myisam_hton)))
|
||||||
DBUG_RETURN(1); // End of memory
|
DBUG_RETURN(1); // End of memory
|
||||||
|
|
||||||
save_proc_info=thd->proc_info;
|
save_proc_info=thd->proc_info;
|
||||||
@ -11615,7 +11616,7 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields, Item *having)
|
|||||||
|
|
||||||
free_io_cache(entry); // Safety
|
free_io_cache(entry); // Safety
|
||||||
entry->file->info(HA_STATUS_VARIABLE);
|
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 &&
|
(!entry->s->blob_fields &&
|
||||||
((ALIGN_SIZE(reclength) + HASH_OVERHEAD) * entry->file->records <
|
((ALIGN_SIZE(reclength) + HASH_OVERHEAD) * entry->file->records <
|
||||||
thd->variables.sortbuff_size)))
|
thd->variables.sortbuff_size)))
|
||||||
|
186
sql/sql_show.cc
186
sql/sql_show.cc
@ -48,6 +48,32 @@ static bool schema_table_store_record(THD *thd, TABLE *table);
|
|||||||
** List all table types supported
|
** 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)
|
bool mysqld_show_storage_engines(THD *thd)
|
||||||
{
|
{
|
||||||
List<Item> field_list;
|
List<Item> field_list;
|
||||||
@ -65,34 +91,126 @@ bool mysqld_show_storage_engines(THD *thd)
|
|||||||
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
|
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
const char *default_type_name=
|
if (plugin_foreach(thd, show_handlerton,
|
||||||
ha_get_storage_engine((enum db_type)thd->variables.table_type);
|
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);
|
send_eof(thd);
|
||||||
DBUG_RETURN(FALSE);
|
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.
|
** List all Authors.
|
||||||
** If you can update it, you get to be in it :)
|
** If you can update it, you get to be in it :)
|
||||||
@ -1005,8 +1123,8 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
|
|||||||
packet->append(STRING_WITH_LEN(" ENGINE="));
|
packet->append(STRING_WITH_LEN(" ENGINE="));
|
||||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
if (table->part_info)
|
if (table->part_info)
|
||||||
packet->append(ha_get_storage_engine(table->part_info->
|
packet->append(ha_resolve_storage_engine_name(
|
||||||
default_engine_type));
|
table->part_info->default_engine_type));
|
||||||
else
|
else
|
||||||
packet->append(file->table_type());
|
packet->append(file->table_type());
|
||||||
#else
|
#else
|
||||||
@ -2090,7 +2208,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||||||
Security_context *sctx= thd->security_ctx;
|
Security_context *sctx= thd->security_ctx;
|
||||||
uint derived_tables= lex->derived_tables;
|
uint derived_tables= lex->derived_tables;
|
||||||
int error= 1;
|
int error= 1;
|
||||||
db_type not_used;
|
enum legacy_db_type not_used;
|
||||||
Open_tables_state open_tables_state_backup;
|
Open_tables_state open_tables_state_backup;
|
||||||
DBUG_ENTER("get_all_tables");
|
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
|
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},
|
get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
|
||||||
{"OPEN_TABLES", open_tables_fields_info, create_schema_table,
|
{"OPEN_TABLES", open_tables_fields_info, create_schema_table,
|
||||||
fill_open_tables, make_old_format, 0, -1, -1, 1},
|
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,
|
{"ROUTINES", proc_fields_info, create_schema_table,
|
||||||
fill_schema_proc, make_proc_old_format, 0, -1, -1, 0},
|
fill_schema_proc, make_proc_old_format, 0, -1, -1, 0},
|
||||||
{"SCHEMATA", schema_fields_info, create_schema_table,
|
{"SCHEMATA", schema_fields_info, create_schema_table,
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
const char *primary_key_name="PRIMARY";
|
const char *primary_key_name="PRIMARY";
|
||||||
|
|
||||||
static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end);
|
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);
|
ha_rows *copied,ha_rows *deleted);
|
||||||
static bool prepare_blob_field(THD *thd, create_field *sql_field);
|
static bool prepare_blob_field(THD *thd, create_field *sql_field);
|
||||||
static bool check_engine(THD *thd, const char *table_name,
|
static bool check_engine(THD *thd, const char *table_name,
|
||||||
enum db_type *new_engine);
|
handlerton **new_engine);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SYNOPSIS
|
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)
|
for (table= tables; table; table= table->next_local)
|
||||||
{
|
{
|
||||||
TABLE_SHARE *share;
|
TABLE_SHARE *share;
|
||||||
table->db_type= DB_TYPE_UNKNOWN;
|
table->db_type= NULL;
|
||||||
if ((share= get_cached_table_share(table->db, table->table_name)))
|
if ((share= get_cached_table_share(table->db, table->table_name)))
|
||||||
table->db_type= share->db_type;
|
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)
|
for (table= tables; table; table= table->next_local)
|
||||||
{
|
{
|
||||||
char *db=table->db;
|
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);
|
mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL, TRUE);
|
||||||
if (!close_temporary_table(thd, table))
|
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 */
|
/* remove .frm file and engine files */
|
||||||
build_table_path(path, sizeof(path), db, alias, reg_ext);
|
build_table_path(path, sizeof(path), db, alias, reg_ext);
|
||||||
}
|
}
|
||||||
if (table_type == DB_TYPE_UNKNOWN &&
|
if (table_type == NULL &&
|
||||||
(drop_temporary ||
|
(drop_temporary ||
|
||||||
(access(path, F_OK) &&
|
(access(path, F_OK) &&
|
||||||
ha_create_table_from_engine(thd, db, alias)) ||
|
ha_create_table_from_engine(thd, db, alias)) ||
|
||||||
(!drop_view &&
|
(!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
|
// Table was not found on disk and table can't be created from engine
|
||||||
if (if_exists)
|
if (if_exists)
|
||||||
@ -349,13 +349,16 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *end;
|
char *end;
|
||||||
if (table_type == DB_TYPE_UNKNOWN)
|
if (table_type == NULL)
|
||||||
mysql_frm_type(thd, path, &table_type);
|
{
|
||||||
|
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
|
*(end=fn_ext(path))=0; // Remove extension for delete
|
||||||
error= ha_delete_table(thd, table_type, path, db, table->table_name,
|
error= ha_delete_table(thd, table_type, path, db, table->table_name,
|
||||||
!dont_log_query);
|
!dont_log_query);
|
||||||
if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) &&
|
if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) &&
|
||||||
(if_exists || table_type == DB_TYPE_UNKNOWN))
|
(if_exists || table_type == NULL))
|
||||||
error= 0;
|
error= 0;
|
||||||
if (error == HA_ERR_ROW_IS_REFERENCED)
|
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)
|
const char *table_name)
|
||||||
{
|
{
|
||||||
char path[FN_REFLEN];
|
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
|
this information in the default_db_type variable, it is either
|
||||||
DB_TYPE_DEFAULT or the engine set in the ALTER TABLE command.
|
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;
|
char *part_syntax_buf;
|
||||||
uint syntax_len;
|
uint syntax_len;
|
||||||
if (part_engine_type == DB_TYPE_PARTITION_DB)
|
if (part_engine_type == &partition_hton)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
This only happens at ALTER TABLE.
|
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.
|
TABLE command.
|
||||||
*/
|
*/
|
||||||
part_engine_type= ha_checktype(thd,
|
part_engine_type= ha_checktype(thd,
|
||||||
part_info->default_engine_type, 0, 0);
|
ha_legacy_type(part_info->default_engine_type), 0, 0);
|
||||||
}
|
}
|
||||||
else
|
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_string= part_syntax_buf;
|
||||||
part_info->part_info_len= syntax_len;
|
part_info->part_info_len= syntax_len;
|
||||||
if ((!(file->partition_flags() & HA_CAN_PARTITION)) ||
|
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.
|
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",
|
DBUG_PRINT("info", ("db_type: %d part_flag: %d",
|
||||||
create_info->db_type,file->partition_flags()));
|
create_info->db_type,file->partition_flags()));
|
||||||
delete file;
|
delete file;
|
||||||
create_info->db_type= DB_TYPE_PARTITION_DB;
|
create_info->db_type= &partition_hton;
|
||||||
if (!(file= get_ha_partition(part_info)))
|
if (!(file= get_ha_partition(part_info)))
|
||||||
{
|
{
|
||||||
DBUG_RETURN(TRUE);
|
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->db_create_options=0;
|
||||||
tmp_table.s->blob_ptr_size= portable_sizeof_char_ptr;
|
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 ||
|
tmp_table.s->db_low_byte_first=
|
||||||
create_info->db_type == DB_TYPE_HEAP);
|
test(create_info->db_type == &myisam_hton ||
|
||||||
|
create_info->db_type == &heap_hton);
|
||||||
tmp_table.null_row=tmp_table.maybe_null=0;
|
tmp_table.null_row=tmp_table.maybe_null=0;
|
||||||
|
|
||||||
while ((item=it++))
|
while ((item=it++))
|
||||||
@ -2006,7 +2010,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
mysql_rename_table(enum db_type base,
|
mysql_rename_table(handlerton *base,
|
||||||
const char *old_db,
|
const char *old_db,
|
||||||
const char *old_name,
|
const char *old_name,
|
||||||
const char *new_db,
|
const char *new_db,
|
||||||
@ -2020,7 +2024,7 @@ mysql_rename_table(enum db_type base,
|
|||||||
int error=0;
|
int error=0;
|
||||||
DBUG_ENTER("mysql_rename_table");
|
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));
|
get_new_handler((TABLE_SHARE*) 0, thd->mem_root, base));
|
||||||
|
|
||||||
build_table_path(from, sizeof(from), old_db, old_name, "");
|
build_table_path(from, sizeof(from), old_db, old_name, "");
|
||||||
@ -2865,7 +2869,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
|||||||
char *src_table= table_ident->table.str;
|
char *src_table= table_ident->table.str;
|
||||||
int err;
|
int err;
|
||||||
bool res= TRUE;
|
bool res= TRUE;
|
||||||
db_type not_used;
|
enum legacy_db_type not_used;
|
||||||
|
|
||||||
TABLE_LIST src_tables_list;
|
TABLE_LIST src_tables_list;
|
||||||
DBUG_ENTER("mysql_create_like_table");
|
DBUG_ENTER("mysql_create_like_table");
|
||||||
@ -3153,7 +3157,7 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
|
|||||||
fields.push_back(c_fld);
|
fields.push_back(c_fld);
|
||||||
}
|
}
|
||||||
bzero((char*) &create_info,sizeof(create_info));
|
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;
|
create_info.default_table_charset= thd->variables.collation_database;
|
||||||
db_options= 0;
|
db_options= 0;
|
||||||
if (mysql_prepare_table(thd, &create_info, &fields,
|
if (mysql_prepare_table(thd, &create_info, &fields,
|
||||||
@ -3177,7 +3181,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. */
|
/* Re-initialize the create_info, which was changed by prepare table. */
|
||||||
bzero((char*) &create_info,sizeof(create_info));
|
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;
|
create_info.default_table_charset= thd->variables.collation_database;
|
||||||
/* Cleanup the fields list. We do not want to create existing fields. */
|
/* Cleanup the fields list. We do not want to create existing fields. */
|
||||||
fields.delete_elements();
|
fields.delete_elements();
|
||||||
@ -3272,7 +3276,7 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bzero((char*) &create_info,sizeof(create_info));
|
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;
|
create_info.default_table_charset= thd->variables.collation_database;
|
||||||
|
|
||||||
if ((drop_key)|| (drop.elements<= 0))
|
if ((drop_key)|| (drop.elements<= 0))
|
||||||
@ -3488,13 +3492,13 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
ha_rows copied,deleted;
|
ha_rows copied,deleted;
|
||||||
ulonglong next_insert_id;
|
ulonglong next_insert_id;
|
||||||
uint db_create_options, used_fields;
|
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;
|
uint need_copy_table= 0;
|
||||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
bool online_add_empty_partition= FALSE;
|
bool online_add_empty_partition= FALSE;
|
||||||
bool online_drop_partition= FALSE;
|
bool online_drop_partition= FALSE;
|
||||||
bool partition_changed= FALSE;
|
bool partition_changed= FALSE;
|
||||||
enum db_type default_engine_type;
|
handlerton *default_engine_type;
|
||||||
#endif
|
#endif
|
||||||
DBUG_ENTER("mysql_alter_table");
|
DBUG_ENTER("mysql_alter_table");
|
||||||
|
|
||||||
@ -3571,7 +3575,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
old_db_type= table->s->db_type;
|
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;
|
create_info->db_type= old_db_type;
|
||||||
|
|
||||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
@ -3675,7 +3679,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
create_info->db_type= DB_TYPE_PARTITION_DB;
|
create_info->db_type= &partition_hton;
|
||||||
thd->lex->part_info= tab_part_info;
|
thd->lex->part_info= tab_part_info;
|
||||||
if (table->file->alter_table_flags() & HA_ONLINE_ADD_EMPTY_PARTITION &&
|
if (table->file->alter_table_flags() & HA_ONLINE_ADD_EMPTY_PARTITION &&
|
||||||
(tab_part_info->part_type == RANGE_PARTITION ||
|
(tab_part_info->part_type == RANGE_PARTITION ||
|
||||||
@ -3905,7 +3909,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
partition_changed= TRUE;
|
partition_changed= TRUE;
|
||||||
create_info->db_type= DB_TYPE_PARTITION_DB;
|
create_info->db_type= &partition_hton;
|
||||||
thd->lex->part_info= tab_part_info;
|
thd->lex->part_info= tab_part_info;
|
||||||
if (alter_info->flags == ALTER_ADD_PARTITION ||
|
if (alter_info->flags == ALTER_ADD_PARTITION ||
|
||||||
alter_info->flags == ALTER_REORGANISE_PARTITION)
|
alter_info->flags == ALTER_REORGANISE_PARTITION)
|
||||||
@ -3976,9 +3980,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
*/
|
*/
|
||||||
if (thd->lex->part_info != table->part_info)
|
if (thd->lex->part_info != table->part_info)
|
||||||
partition_changed= TRUE;
|
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;
|
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
|
#endif
|
||||||
@ -4669,7 +4673,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
|
|
||||||
error=0;
|
error=0;
|
||||||
if (!need_copy_table)
|
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))
|
if (mysql_rename_table(old_db_type,db,table_name,db,old_name))
|
||||||
{
|
{
|
||||||
error=1;
|
error=1;
|
||||||
@ -4999,7 +5003,7 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list,
|
|||||||
lex->col_list.empty();
|
lex->col_list.empty();
|
||||||
lex->alter_info.reset();
|
lex->alter_info.reset();
|
||||||
bzero((char*) &create_info,sizeof(create_info));
|
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.row_type=ROW_TYPE_NOT_USED;
|
||||||
create_info.default_table_charset=default_charset_info;
|
create_info.default_table_charset=default_charset_info;
|
||||||
/* Force alter table to recreate table */
|
/* Force alter table to recreate table */
|
||||||
@ -5131,21 +5135,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,
|
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=
|
bool no_substitution=
|
||||||
test(thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION);
|
test(thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION);
|
||||||
if ((*new_engine=
|
if (!(*new_engine= ha_checktype(thd, ha_legacy_type(req_engine),
|
||||||
ha_checktype(thd, req_engine, no_substitution, 1)) == DB_TYPE_UNKNOWN)
|
no_substitution, 1)))
|
||||||
return TRUE;
|
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,
|
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||||
ER_WARN_USING_OTHER_HANDLER,
|
ER_WARN_USING_OTHER_HANDLER,
|
||||||
ER(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);
|
table_name);
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1169,7 +1169,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
|
|||||||
{
|
{
|
||||||
char path[FN_REFLEN];
|
char path[FN_REFLEN];
|
||||||
TABLE_LIST *view;
|
TABLE_LIST *view;
|
||||||
db_type not_used;
|
enum legacy_db_type not_used;
|
||||||
DBUG_ENTER("mysql_drop_view");
|
DBUG_ENTER("mysql_drop_view");
|
||||||
|
|
||||||
for (view= views; view; view= view->next_local)
|
for (view= views; view; view= view->next_local)
|
||||||
@ -1242,7 +1242,7 @@ err:
|
|||||||
FRMTYPE_VIEW view
|
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;
|
File file;
|
||||||
uchar header[10]; //"TYPE=VIEW\n" it is 10 characters
|
uchar header[10]; //"TYPE=VIEW\n" it is 10 characters
|
||||||
@ -1271,7 +1271,7 @@ frm_type_enum mysql_frm_type(THD *thd, char *path, db_type *dbt)
|
|||||||
(header[2] < FRM_VER+3 || header[2] > FRM_VER+4)))
|
(header[2] < FRM_VER+3 || header[2] > FRM_VER+4)))
|
||||||
DBUG_RETURN(FRMTYPE_TABLE);
|
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
|
DBUG_RETURN(FRMTYPE_TABLE); // Is probably a .frm table
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
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);
|
int view_checksum(THD *thd, TABLE_LIST *view);
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ inline Item *is_truth_value(Item *A, bool v1, bool v2)
|
|||||||
enum enum_var_type var_type;
|
enum enum_var_type var_type;
|
||||||
Key::Keytype key_type;
|
Key::Keytype key_type;
|
||||||
enum ha_key_alg key_alg;
|
enum ha_key_alg key_alg;
|
||||||
enum db_type db_type;
|
handlerton *db_type;
|
||||||
enum row_type row_type;
|
enum row_type row_type;
|
||||||
enum ha_rkey_function ha_rkey_mode;
|
enum ha_rkey_function ha_rkey_mode;
|
||||||
enum enum_tx_isolation tx_isolation;
|
enum enum_tx_isolation tx_isolation;
|
||||||
@ -1174,7 +1174,7 @@ create:
|
|||||||
lex->change=NullS;
|
lex->change=NullS;
|
||||||
bzero((char*) &lex->create_info,sizeof(lex->create_info));
|
bzero((char*) &lex->create_info,sizeof(lex->create_info));
|
||||||
lex->create_info.options=$2 | $4;
|
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->create_info.default_table_charset= NULL;
|
||||||
lex->name=0;
|
lex->name=0;
|
||||||
}
|
}
|
||||||
@ -2781,7 +2781,7 @@ part_definition:
|
|||||||
part_info->current_partition= p_elem;
|
part_info->current_partition= p_elem;
|
||||||
part_info->use_default_partitions= FALSE;
|
part_info->use_default_partitions= FALSE;
|
||||||
part_info->partitions.push_back(p_elem);
|
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_info->count_curr_parts++;
|
||||||
}
|
}
|
||||||
part_name {}
|
part_name {}
|
||||||
@ -2964,7 +2964,7 @@ sub_part_definition:
|
|||||||
part_info->current_partition->subpartitions.push_back(p_elem);
|
part_info->current_partition->subpartitions.push_back(p_elem);
|
||||||
part_info->use_default_subpartitions= FALSE;
|
part_info->use_default_subpartitions= FALSE;
|
||||||
part_info->count_curr_subparts++;
|
part_info->count_curr_subparts++;
|
||||||
p_elem->engine_type= DB_TYPE_UNKNOWN;
|
p_elem->engine_type= NULL;
|
||||||
}
|
}
|
||||||
sub_name opt_part_options {}
|
sub_name opt_part_options {}
|
||||||
;
|
;
|
||||||
@ -3193,8 +3193,8 @@ default_collation:
|
|||||||
storage_engines:
|
storage_engines:
|
||||||
ident_or_text
|
ident_or_text
|
||||||
{
|
{
|
||||||
$$ = ha_resolve_by_name($1.str,$1.length);
|
$$ = ha_resolve_by_name(YYTHD, &$1);
|
||||||
if ($$ == DB_TYPE_UNKNOWN &&
|
if ($$ == NULL &&
|
||||||
test(YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION))
|
test(YYTHD->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION))
|
||||||
{
|
{
|
||||||
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
|
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), $1.str);
|
||||||
@ -3845,7 +3845,7 @@ alter:
|
|||||||
lex->select_lex.init_order();
|
lex->select_lex.init_order();
|
||||||
lex->select_lex.db=lex->name=0;
|
lex->select_lex.db=lex->name=0;
|
||||||
bzero((char*) &lex->create_info,sizeof(lex->create_info));
|
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.default_table_charset= NULL;
|
||||||
lex->create_info.row_type= ROW_TYPE_NOT_USED;
|
lex->create_info.row_type= ROW_TYPE_NOT_USED;
|
||||||
lex->alter_info.reset();
|
lex->alter_info.reset();
|
||||||
@ -7010,11 +7010,19 @@ show_param:
|
|||||||
if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
|
if (prepare_schema_table(YYTHD, lex, 0, SCH_OPEN_TABLES))
|
||||||
YYABORT;
|
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
|
| ENGINE_SYM storage_engines
|
||||||
{ Lex->create_info.db_type= $2; }
|
{ Lex->create_info.db_type= $2; }
|
||||||
show_engine_param
|
show_engine_param
|
||||||
| ENGINE_SYM ALL
|
| ENGINE_SYM ALL
|
||||||
{ Lex->create_info.db_type= DB_TYPE_DEFAULT; }
|
{ Lex->create_info.db_type= NULL; }
|
||||||
show_engine_param
|
show_engine_param
|
||||||
| opt_full COLUMNS from_or_in table_ident opt_db wild_and_where
|
| opt_full COLUMNS from_or_in table_ident opt_db wild_and_where
|
||||||
{
|
{
|
||||||
@ -7106,14 +7114,24 @@ show_param:
|
|||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
lex->sql_command = SQLCOM_SHOW_ENGINE_STATUS;
|
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");
|
WARN_DEPRECATED("SHOW INNODB STATUS", "SHOW ENGINE INNODB STATUS");
|
||||||
}
|
}
|
||||||
| MUTEX_SYM STATUS_SYM
|
| MUTEX_SYM STATUS_SYM
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
lex->sql_command = SQLCOM_SHOW_ENGINE_MUTEX;
|
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");
|
WARN_DEPRECATED("SHOW MUTEX STATUS", "SHOW ENGINE INNODB MUTEX");
|
||||||
}
|
}
|
||||||
| opt_full PROCESSLIST_SYM
|
| opt_full PROCESSLIST_SYM
|
||||||
@ -7147,14 +7165,24 @@ show_param:
|
|||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
lex->sql_command= SQLCOM_SHOW_ENGINE_LOGS;
|
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");
|
WARN_DEPRECATED("SHOW BDB LOGS", "SHOW ENGINE BDB LOGS");
|
||||||
}
|
}
|
||||||
| LOGS_SYM
|
| LOGS_SYM
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
lex->sql_command= SQLCOM_SHOW_ENGINE_LOGS;
|
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");
|
WARN_DEPRECATED("SHOW LOGS", "SHOW ENGINE BDB LOGS");
|
||||||
}
|
}
|
||||||
| GRANTS
|
| GRANTS
|
||||||
@ -9828,7 +9856,7 @@ opt_migrate:
|
|||||||
;
|
;
|
||||||
|
|
||||||
install:
|
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 *lex= Lex;
|
||||||
lex->sql_command= SQLCOM_INSTALL_PLUGIN;
|
lex->sql_command= SQLCOM_INSTALL_PLUGIN;
|
||||||
@ -9837,7 +9865,7 @@ install:
|
|||||||
};
|
};
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
UNINSTALL_SYM PLUGIN_SYM IDENT_sys
|
UNINSTALL_SYM PLUGIN_SYM ident
|
||||||
{
|
{
|
||||||
LEX *lex= Lex;
|
LEX *lex= Lex;
|
||||||
lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;
|
lex->sql_command= SQLCOM_UNINSTALL_PLUGIN;
|
||||||
|
28
sql/table.cc
28
sql/table.cc
@ -327,6 +327,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
|
|||||||
SQL_CRYPT *crypted=0;
|
SQL_CRYPT *crypted=0;
|
||||||
Field **field_ptr, *reg_field;
|
Field **field_ptr, *reg_field;
|
||||||
const char **interval_array;
|
const char **interval_array;
|
||||||
|
enum legacy_db_type legacy_db_type;
|
||||||
DBUG_ENTER("open_binary_frm");
|
DBUG_ENTER("open_binary_frm");
|
||||||
|
|
||||||
new_field_pack_flag= head[27];
|
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;
|
share->frm_version= FRM_VER_TRUE_VARCHAR;
|
||||||
|
|
||||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
share->default_part_db_type= ha_checktype(thd,
|
share->default_part_db_type=
|
||||||
(enum db_type) (uint) *(head+61),0,
|
ha_checktype(thd, (enum legacy_db_type) (uint) *(head+61), 0, 0);
|
||||||
0);
|
|
||||||
#endif
|
#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_create_options= db_create_options= uint2korr(head+30);
|
||||||
share->db_options_in_use= share->db_create_options;
|
share->db_options_in_use= share->db_create_options;
|
||||||
share->mysql_version= uint4korr(head+51);
|
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)
|
if (db_create_options & HA_OPTION_LONG_BLOB_PTR)
|
||||||
share->blob_ptr_size= portable_sizeof_char_ptr;
|
share->blob_ptr_size= portable_sizeof_char_ptr;
|
||||||
/* Set temporarily a good value for db_low_byte_first */
|
/* 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;
|
error=4;
|
||||||
share->max_rows= uint4korr(head+18);
|
share->max_rows= uint4korr(head+18);
|
||||||
share->min_rows= uint4korr(head+22);
|
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)
|
if (next_chunk + 2 < buff_end)
|
||||||
{
|
{
|
||||||
uint str_db_type_length= uint2korr(next_chunk);
|
uint str_db_type_length= uint2korr(next_chunk);
|
||||||
enum db_type tmp_db_type= ha_resolve_by_name(next_chunk + 2,
|
LEX_STRING name= { next_chunk + 2, str_db_type_length };
|
||||||
str_db_type_length);
|
handlerton *tmp_db_type= ha_resolve_by_name(thd, &name);
|
||||||
if (tmp_db_type != DB_TYPE_UNKNOWN)
|
if (tmp_db_type != NULL)
|
||||||
{
|
{
|
||||||
share->db_type= tmp_db_type;
|
share->db_type= tmp_db_type;
|
||||||
DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)",
|
DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)",
|
||||||
str_db_type_length, next_chunk + 2,
|
str_db_type_length, next_chunk + 2,
|
||||||
share->db_type));
|
ha_legacy_type(share->db_type)));
|
||||||
}
|
}
|
||||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
else
|
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))
|
if (!strncmp(next_chunk + 2, "partition", str_db_type_length))
|
||||||
{
|
{
|
||||||
/* Use partition handler */
|
/* Use partition handler */
|
||||||
share->db_type= DB_TYPE_PARTITION_DB;
|
share->db_type= &partition_hton;
|
||||||
DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)",
|
DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)",
|
||||||
str_db_type_length, next_chunk + 2,
|
str_db_type_length, next_chunk + 2,
|
||||||
share->db_type));
|
ha_legacy_type(share->db_type)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1634,7 +1635,7 @@ void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg)
|
|||||||
handler *file= 0;
|
handler *file= 0;
|
||||||
const char *datext= "";
|
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,
|
if ((file= get_new_handler(share, current_thd->mem_root,
|
||||||
share->db_type)))
|
share->db_type)))
|
||||||
@ -1900,7 +1901,8 @@ File create_frm(THD *thd, const char *name, const char *db,
|
|||||||
fileinfo[1]= 1;
|
fileinfo[1]= 1;
|
||||||
fileinfo[2]= FRM_VER+3+ test(create_info->varchar);
|
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;
|
fileinfo[4]=1;
|
||||||
int2store(fileinfo+6,IO_SIZE); /* Next block starts here */
|
int2store(fileinfo+6,IO_SIZE); /* Next block starts here */
|
||||||
key_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16;
|
key_length=keys*(7+NAME_LEN+MAX_REF_PARTS*9)+16;
|
||||||
|
@ -153,7 +153,7 @@ typedef struct st_table_share
|
|||||||
ulong timestamp_offset; /* Set to offset+1 of record */
|
ulong timestamp_offset; /* Set to offset+1 of record */
|
||||||
ulong reclength; /* Recordlength */
|
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 row_type row_type; /* How rows are stored */
|
||||||
enum tmp_table_type tmp_table;
|
enum tmp_table_type tmp_table;
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ typedef struct st_table_share
|
|||||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
const uchar *partition_info;
|
const uchar *partition_info;
|
||||||
uint partition_info_len;
|
uint partition_info_len;
|
||||||
enum db_type default_part_db_type;
|
handlerton *default_part_db_type;
|
||||||
#endif
|
#endif
|
||||||
} TABLE_SHARE;
|
} TABLE_SHARE;
|
||||||
|
|
||||||
@ -324,6 +324,7 @@ enum enum_schema_tables
|
|||||||
SCH_COLUMN_PRIVILEGES,
|
SCH_COLUMN_PRIVILEGES,
|
||||||
SCH_KEY_COLUMN_USAGE,
|
SCH_KEY_COLUMN_USAGE,
|
||||||
SCH_OPEN_TABLES,
|
SCH_OPEN_TABLES,
|
||||||
|
SCH_PLUGINS,
|
||||||
SCH_PROCEDURES,
|
SCH_PROCEDURES,
|
||||||
SCH_SCHEMATA,
|
SCH_SCHEMATA,
|
||||||
SCH_SCHEMA_PRIVILEGES,
|
SCH_SCHEMA_PRIVILEGES,
|
||||||
@ -642,7 +643,7 @@ typedef struct st_table_list
|
|||||||
bool where_processed;
|
bool where_processed;
|
||||||
/* FRMTYPE_ERROR if any type is acceptable */
|
/* FRMTYPE_ERROR if any type is acceptable */
|
||||||
enum frm_type_enum required_type;
|
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) */
|
char timestamp_buffer[20]; /* buffer for timestamp (19+1) */
|
||||||
/*
|
/*
|
||||||
This TABLE_LIST object is just placeholder for prelocking, it will be
|
This TABLE_LIST object is just placeholder for prelocking, it will be
|
||||||
|
@ -35,7 +35,7 @@ static uchar * pack_screens(List<create_field> &create_fields,
|
|||||||
uint *info_length, uint *screens, bool small_file);
|
uint *info_length, uint *screens, bool small_file);
|
||||||
static uint pack_keys(uchar *keybuff,uint key_count, KEY *key_info,
|
static uint pack_keys(uchar *keybuff,uint key_count, KEY *key_info,
|
||||||
ulong data_offset);
|
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,
|
List<create_field> &create_fields,
|
||||||
uint info_length, uint screens, uint table_options,
|
uint info_length, uint screens, uint table_options,
|
||||||
ulong data_offset, handler *file);
|
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);
|
create_field *last_field);
|
||||||
static bool pack_fields(File file, List<create_field> &create_fields,
|
static bool pack_fields(File file, List<create_field> &create_fields,
|
||||||
ulong data_offset);
|
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,
|
uint table_options,
|
||||||
List<create_field> &create_fields,
|
List<create_field> &create_fields,
|
||||||
uint reclength, ulong data_offset,
|
uint reclength, ulong data_offset,
|
||||||
@ -103,7 +103,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
|
|||||||
create_info->null_bits++;
|
create_info->null_bits++;
|
||||||
data_offset= (create_info->null_bits + 7) / 8;
|
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,
|
screens, create_info->table_options,
|
||||||
data_offset, db_file))
|
data_offset, db_file))
|
||||||
{
|
{
|
||||||
@ -115,7 +116,8 @@ bool mysql_create_frm(THD *thd, const char *file_name,
|
|||||||
thd->net.last_error[0]=0;
|
thd->net.last_error[0]=0;
|
||||||
if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,1)))
|
if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,1)))
|
||||||
DBUG_RETURN(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))
|
screens, create_info->table_options, data_offset, db_file))
|
||||||
{
|
{
|
||||||
my_free((gptr) screen_buff,MYF(0));
|
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);
|
reclength=uint2korr(forminfo+266);
|
||||||
|
|
||||||
/* Calculate extra data segment length */
|
/* 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.length= strlen(str_db_type.str);
|
||||||
/* str_db_type */
|
/* str_db_type */
|
||||||
create_info->extra_size= (2 + str_db_type.length +
|
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
|
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||||
if (part_info)
|
if (part_info)
|
||||||
fileinfo[61]= (uchar) part_info->default_engine_type;
|
fileinfo[61]= (uchar) ha_legacy_type(part_info->default_engine_type);
|
||||||
#endif
|
#endif
|
||||||
int2store(fileinfo+59,db_file->extra_rec_buf_length());
|
int2store(fileinfo+59,db_file->extra_rec_buf_length());
|
||||||
if (my_pwrite(file,(byte*) fileinfo,64,0L,MYF_RW) ||
|
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,
|
VOID(my_seek(file,
|
||||||
(ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length,
|
(ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length,
|
||||||
MY_SEEK_SET,MYF(0)));
|
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))
|
create_fields,reclength, data_offset, db_file))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
@ -480,7 +483,7 @@ static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo,
|
|||||||
|
|
||||||
/* Make formheader */
|
/* 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,
|
List<create_field> &create_fields,
|
||||||
uint info_length, uint screens, uint table_options,
|
uint info_length, uint screens, uint table_options,
|
||||||
ulong data_offset, handler *file)
|
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 */
|
/* 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,
|
uint table_options,
|
||||||
List<create_field> &create_fields,
|
List<create_field> &create_fields,
|
||||||
uint reclength,
|
uint reclength,
|
||||||
|
39
storage/csv/Makefile.am
Normal file
39
storage/csv/Makefile.am
Normal 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.%
|
@ -51,18 +51,22 @@ TODO:
|
|||||||
#include "ha_tina.h"
|
#include "ha_tina.h"
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
#include <plugin.h>
|
||||||
|
|
||||||
/* Stuff for shares */
|
/* Stuff for shares */
|
||||||
pthread_mutex_t tina_mutex;
|
pthread_mutex_t tina_mutex;
|
||||||
static HASH tina_open_tables;
|
static HASH tina_open_tables;
|
||||||
static int tina_init= 0;
|
static int tina_init= 0;
|
||||||
static handler *tina_create_handler(TABLE_SHARE *table);
|
static handler *tina_create_handler(TABLE_SHARE *table);
|
||||||
|
static int tina_init_func();
|
||||||
|
|
||||||
handlerton tina_hton= {
|
handlerton tina_hton= {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"CSV",
|
"CSV",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"CSV storage engine",
|
"CSV storage engine",
|
||||||
DB_TYPE_CSV_DB,
|
DB_TYPE_CSV_DB,
|
||||||
NULL, /* One needs to be written! */
|
(bool (*)()) tina_init_func,
|
||||||
0, /* slot */
|
0, /* slot */
|
||||||
0, /* savepoint size. */
|
0, /* savepoint size. */
|
||||||
NULL, /* close_connection */
|
NULL, /* close_connection */
|
||||||
@ -81,12 +85,9 @@ handlerton tina_hton= {
|
|||||||
tina_create_handler, /* Create a new handler */
|
tina_create_handler, /* Create a new handler */
|
||||||
NULL, /* Drop a database */
|
NULL, /* Drop a database */
|
||||||
tina_end, /* Panic call */
|
tina_end, /* Panic call */
|
||||||
NULL, /* Release temporary latches */
|
|
||||||
NULL, /* Update Statistics */
|
|
||||||
NULL, /* Start Consistent Snapshot */
|
NULL, /* Start Consistent Snapshot */
|
||||||
NULL, /* Flush logs */
|
NULL, /* Flush logs */
|
||||||
NULL, /* Show status */
|
NULL, /* Show status */
|
||||||
NULL, /* Replication Report Sent Binlog */
|
|
||||||
HTON_CAN_RECREATE
|
HTON_CAN_RECREATE
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -155,6 +156,35 @@ int get_mmap(TINA_SHARE *share, int write)
|
|||||||
DBUG_RETURN(0);
|
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.
|
Simple lock controls.
|
||||||
*/
|
*/
|
||||||
@ -164,19 +194,6 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table)
|
|||||||
char *tmp_name;
|
char *tmp_name;
|
||||||
uint length;
|
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);
|
pthread_mutex_lock(&tina_mutex);
|
||||||
length=(uint) strlen(table_name);
|
length=(uint) strlen(table_name);
|
||||||
if (!(share=(TINA_SHARE*) hash_search(&tina_open_tables,
|
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)
|
int tina_end(ha_panic_function type)
|
||||||
{
|
{
|
||||||
if (tina_init)
|
return tina_done_func();
|
||||||
{
|
|
||||||
hash_free(&tina_open_tables);
|
|
||||||
VOID(pthread_mutex_destroy(&tina_mutex));
|
|
||||||
}
|
|
||||||
tina_init= 0;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -933,3 +944,16 @@ int ha_tina::create(const char *name, TABLE *table_arg,
|
|||||||
DBUG_RETURN(0);
|
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;
|
||||||
|
|
39
storage/example/Makefile.am
Normal file
39
storage/example/Makefile.am
Normal 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.%
|
@ -68,17 +68,20 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../mysql_priv.h"
|
#include "../mysql_priv.h"
|
||||||
|
#include <plugin.h>
|
||||||
|
|
||||||
#include "ha_example.h"
|
#include "ha_example.h"
|
||||||
|
|
||||||
static handler* example_create_handler(TABLE_SHARE *table);
|
static handler* example_create_handler(TABLE_SHARE *table);
|
||||||
|
static int example_init_func();
|
||||||
|
|
||||||
handlerton example_hton= {
|
handlerton example_hton= {
|
||||||
|
MYSQL_HANDLERTON_INTERFACE_VERSION,
|
||||||
"EXAMPLE",
|
"EXAMPLE",
|
||||||
SHOW_OPTION_YES,
|
SHOW_OPTION_YES,
|
||||||
"Example storage engine",
|
"Example storage engine",
|
||||||
DB_TYPE_EXAMPLE_DB,
|
DB_TYPE_EXAMPLE_DB,
|
||||||
NULL, /* We do need to write one! */
|
(bool (*)()) example_init_func,
|
||||||
0, /* slot */
|
0, /* slot */
|
||||||
0, /* savepoint size. */
|
0, /* savepoint size. */
|
||||||
NULL, /* close_connection */
|
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
|
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
|
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;
|
uint length;
|
||||||
char *tmp_name;
|
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);
|
pthread_mutex_lock(&example_mutex);
|
||||||
length=(uint) strlen(table_name);
|
length=(uint) strlen(table_name);
|
||||||
|
|
||||||
@ -186,7 +198,6 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
pthread_mutex_destroy(&share->mutex);
|
pthread_mutex_destroy(&share->mutex);
|
||||||
pthread_mutex_unlock(&example_mutex);
|
|
||||||
my_free((gptr) share, MYF(0));
|
my_free((gptr) share, MYF(0));
|
||||||
|
|
||||||
return NULL;
|
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. */
|
/* This is not implemented but we want someone to be able that it works. */
|
||||||
DBUG_RETURN(0);
|
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;
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user