summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2006-04-24 18:26:30 +0200
committerunknown <tomas@poseidon.ndb.mysql.com>2006-04-24 18:26:30 +0200
commit8b308fbbc53cd7d476c42d1a753db75aa2af2e65 (patch)
tree63ec5a5711acbef541170ceee0362dc3443d5a51
parent0ba08ecf787a095534cbae4a4f93dd5c028b681f (diff)
downloadmariadb-git-8b308fbbc53cd7d476c42d1a753db75aa2af2e65.tar.gz
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 mysql-test/r/ndb_dd_basic.result: bug#18604 create logfile for MyISAM tables mysql-test/t/ndb_dd_basic.test: bug#18604 create logfile for MyISAM tables
-rw-r--r--mysql-test/r/ndb_dd_basic.result23
-rw-r--r--mysql-test/t/ndb_dd_basic.test22
-rw-r--r--sql/handler.h9
-rw-r--r--sql/sql_tablespace.cc51
-rw-r--r--sql/sql_yacc.yy4
5 files changed, 84 insertions, 25 deletions
diff --git a/mysql-test/r/ndb_dd_basic.result b/mysql-test/r/ndb_dd_basic.result
index 8b16bce830c..d5ac5071a8e 100644
--- a/mysql-test/r/ndb_dd_basic.result
+++ b/mysql-test/r/ndb_dd_basic.result
@@ -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
diff --git a/mysql-test/t/ndb_dd_basic.test b/mysql-test/t/ndb_dd_basic.test
index 0bc0e07fad8..9df2cfb0371 100644
--- a/mysql-test/t/ndb_dd_basic.test
+++ b/mysql-test/t/ndb_dd_basic.test
@@ -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
diff --git a/sql/handler.h b/sql/handler.h
index c7c3aa54c3b..090ef1f9f30 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -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;
diff --git a/sql/sql_tablespace.cc b/sql/sql_tablespace.cc
index e7f6b04045e..8bc39ec82c6 100644
--- a/sql/sql_tablespace.cc
+++ b/sql/sql_tablespace.cc
@@ -21,32 +21,51 @@
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 == HA_ADMIN_NOT_IMPLEMENTED)
- {
- my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "");
- }
- else if (error == 1)
+ if ((error= hton->alter_tablespace(thd, ts_info)))
{
- DBUG_RETURN(1);
+ if (error == HA_ADMIN_NOT_IMPLEMENTED)
+ {
+ my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "");
+ }
+ else if (error == 1)
+ {
+ DBUG_RETURN(1);
+ }
+ else
+ {
+ my_error(error, MYF(0));
+ }
+ DBUG_RETURN(error);
}
- else
- {
- my_error(error, MYF(0));
- }
- 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())
{
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 47f0b1e259e..d533aac9850 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -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: