bug#18604 create logfile for MyISAM tables

- changed alter tablespace truct to work with handlerton pointer (to avoid crash in parser on unknown db type"
- pushed warnings when default storage engine is used and/or tablespace stuff is not supported by storage engine
parent d999da80
......@@ -3,11 +3,32 @@ CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
INITIAL_SIZE 16M
UNDO_BUFFER_SIZE = 1M
ENGINE=NDB;
ENGINE=MYISAM;
Warnings:
Error 1539 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP'
ALTER LOGFILE GROUP lg1
ADD UNDOFILE 'undofile02.dat'
INITIAL_SIZE = 4M
ENGINE=XYZ;
Warnings:
Error 1266 Using storage engine MyISAM for table 'lg1'
Error 1539 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP'
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 12M;
Warnings:
Error 1539 Table storage engine 'MyISAM' does not support the create option 'TABLESPACE or LOGFILE GROUP'
set storage_engine=ndb;
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
INITIAL_SIZE 16M
UNDO_BUFFER_SIZE = 1M;
ALTER LOGFILE GROUP lg1
ADD UNDOFILE 'undofile02.dat'
INITIAL_SIZE = 4M
ENGINE=NDB;
set storage_engine=myisam;
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
......
......@@ -14,16 +14,33 @@
DROP TABLE IF EXISTS t1;
--enable_warnings
# some negative tests
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
INITIAL_SIZE 16M
UNDO_BUFFER_SIZE = 1M
ENGINE=MYISAM;
ALTER LOGFILE GROUP lg1
ADD UNDOFILE 'undofile02.dat'
INITIAL_SIZE = 4M
ENGINE=XYZ;
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 12M;
##################################
# Basic test of disk tables for NDB
# Start by creating a logfile group
##################################
set storage_engine=ndb;
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
INITIAL_SIZE 16M
UNDO_BUFFER_SIZE = 1M
ENGINE=NDB;
UNDO_BUFFER_SIZE = 1M;
ALTER LOGFILE GROUP lg1
ADD UNDOFILE 'undofile02.dat'
......@@ -34,6 +51,7 @@ ENGINE=NDB;
# Create a tablespace connected to the logfile group
###################################################
set storage_engine=myisam;
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
......
......@@ -402,6 +402,7 @@ enum tablespace_access_mode
TS_NOT_ACCESSIBLE = 2
};
struct handlerton;
class st_alter_tablespace : public Sql_alloc
{
public:
......@@ -419,7 +420,7 @@ class st_alter_tablespace : public Sql_alloc
ulonglong autoextend_size;
ulonglong max_size;
uint nodegroup_id;
enum legacy_db_type storage_engine;
const handlerton *storage_engine;
bool wait_until_completed;
const char *ts_comment;
enum tablespace_access_mode ts_access_mode;
......@@ -437,7 +438,7 @@ class st_alter_tablespace : public Sql_alloc
initial_size= 128*1024*1024; //Default 128 MByte
autoextend_size= 0; //No autoextension as default
max_size= 0; //Max size == initial size => no extension
storage_engine= DB_TYPE_UNKNOWN;
storage_engine= NULL;
nodegroup_id= UNDEF_NODEGROUP;
wait_until_completed= TRUE;
ts_comment= NULL;
......@@ -468,7 +469,7 @@ enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
*/
typedef struct
struct handlerton
{
/*
handlerton structure version
......@@ -581,7 +582,7 @@ typedef struct
const char *query, uint query_length,
const char *db, const char *table_name);
int (*release_temporary_latches)(THD *thd);
} handlerton;
};
extern const handlerton default_hton;
......
......@@ -21,18 +21,28 @@
int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
{
int error= HA_ADMIN_NOT_IMPLEMENTED;
handlerton *hton;
const handlerton *hton= ts_info->storage_engine;
DBUG_ENTER("mysql_alter_tablespace");
/*
If the user haven't defined an engine, this will fallback to using the
default storage engine.
*/
hton= ha_resolve_by_legacy_type(thd, ts_info->storage_engine != DB_TYPE_UNKNOWN ?
ts_info->storage_engine : DB_TYPE_DEFAULT);
if (hton == NULL || hton == &default_hton || hton->state != SHOW_OPTION_YES)
{
hton= ha_resolve_by_legacy_type(thd, DB_TYPE_DEFAULT);
if (ts_info->storage_engine != 0)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_WARN_USING_OTHER_HANDLER,
ER(ER_WARN_USING_OTHER_HANDLER),
hton->name,
ts_info->tablespace_name
? ts_info->tablespace_name : ts_info->logfile_group_name);
}
if (hton->state == SHOW_OPTION_YES &&
hton->alter_tablespace && (error= hton->alter_tablespace(thd, ts_info)))
if (hton->alter_tablespace)
{
if ((error= hton->alter_tablespace(thd, ts_info)))
{
if (error == HA_ADMIN_NOT_IMPLEMENTED)
{
......@@ -48,6 +58,15 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
}
DBUG_RETURN(error);
}
}
else
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_ILLEGAL_HA_CREATE_OPTION,
ER(ER_ILLEGAL_HA_CREATE_OPTION),
hton->name,
"TABLESPACE or LOGFILE GROUP");
}
if (mysql_bin_log.is_open())
{
thd->binlog_query(THD::STMT_QUERY_TYPE,
......
......@@ -3187,13 +3187,13 @@ opt_ts_engine:
opt_storage ENGINE_SYM opt_equal storage_engines
{
LEX *lex= Lex;
if (lex->alter_tablespace_info->storage_engine != DB_TYPE_UNKNOWN)
if (lex->alter_tablespace_info->storage_engine != NULL)
{
my_error(ER_FILEGROUP_OPTION_ONLY_ONCE,MYF(0),
"STORAGE ENGINE");
YYABORT;
}
lex->alter_tablespace_info->storage_engine= $4->db_type;
lex->alter_tablespace_info->storage_engine= $4 ? $4 : &default_hton;
};
opt_ts_wait:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment