diff options
author | msvensson@neptunus.(none) <> | 2006-02-17 17:21:34 +0100 |
---|---|---|
committer | msvensson@neptunus.(none) <> | 2006-02-17 17:21:34 +0100 |
commit | b2a13dd760d844443b7aa86e8c35be3f7033b9f1 (patch) | |
tree | d3a9c3db6152ba79cf9daa25d67bc9076e43a172 | |
parent | a50d87da347450c995f758893a50b8475ae0973b (diff) | |
parent | 9495f8c56a7a9be36ee9c3f7ea09957e726104b8 (diff) | |
download | mariadb-git-b2a13dd760d844443b7aa86e8c35be3f7033b9f1.tar.gz |
Merge bk-internal:/home/bk/mysql-5.1-new
into neptunus.(none):/home/msvensson/mysql/mysql-5.1
-rw-r--r-- | mysql-test/r/ndb_temporary.result | 21 | ||||
-rw-r--r-- | mysql-test/t/ndb_temporary.test | 38 | ||||
-rw-r--r-- | sql/ha_ndbcluster.cc | 2 | ||||
-rw-r--r-- | sql/handler.h | 1 | ||||
-rw-r--r-- | sql/share/errmsg.txt | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 36 |
6 files changed, 79 insertions, 21 deletions
diff --git a/mysql-test/r/ndb_temporary.result b/mysql-test/r/ndb_temporary.result new file mode 100644 index 00000000000..73afd43206d --- /dev/null +++ b/mysql-test/r/ndb_temporary.result @@ -0,0 +1,21 @@ +DROP TABLE IF EXISTS t1; +create temporary table t1 (a int key) engine=ndb; +ERROR HY000: Table storage engine 'ndbcluster' does not support the create option 'TEMPORARY' +create temporary table t1 (a int key) engine=myisam; +alter table t1 engine=ndb; +ERROR HY000: Table storage engine 'ndbcluster' does not support the create option 'TEMPORARY' +drop table t1; +SET SESSION storage_engine=NDBCLUSTER; +create table t1 (a int key); +select engine from information_schema.tables where table_name = 't1'; +engine +NDBCLUSTER +drop table t1; +create temporary table t1 (a int key); +show create table t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `a` int(11) NOT NULL, + PRIMARY KEY (`a`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/t/ndb_temporary.test b/mysql-test/t/ndb_temporary.test new file mode 100644 index 00000000000..7f6902bf745 --- /dev/null +++ b/mysql-test/t/ndb_temporary.test @@ -0,0 +1,38 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# +# creating a temporary table with engine=ndb should give an error +# +--error ER_ILLEGAL_HA_CREATE_OPTION +create temporary table t1 (a int key) engine=ndb; + + +# +# alter temporary table to engine=ndb should give an error +# +create temporary table t1 (a int key) engine=myisam; +--error ER_ILLEGAL_HA_CREATE_OPTION +alter table t1 engine=ndb; +drop table t1; + + +# +# if default storage engine=ndb, temporary tables +# without explicit engine= should be created as myisam +# +SET SESSION storage_engine=NDBCLUSTER; +create table t1 (a int key); + +# verify that we have a ndb table +select engine from information_schema.tables where table_name = 't1'; +drop table t1; + +# verify that we have a myisam table +create temporary table t1 (a int key); +show create table t1; +drop table t1; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 714de69d1ec..f90d18356d4 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -5848,7 +5848,7 @@ static bool ndbcluster_init() #ifdef HAVE_NDB_BINLOG ndbcluster_binlog_init_handlerton(); #endif - h.flags= HTON_NO_FLAGS; + h.flags= HTON_TEMPORARY_NOT_SUPPORTED; } // Set connectstring if specified diff --git a/sql/handler.h b/sql/handler.h index 58504162d8f..fa4450544e9 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -604,6 +604,7 @@ struct show_table_alias_st { #define HTON_HIDDEN (1 << 3) //Engine does not appear in lists #define HTON_FLUSH_AFTER_RENAME (1 << 4) #define HTON_NOT_USER_SELECTABLE (1 << 5) +#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported typedef struct st_thd_trans { diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index bf2443d9a6b..aa9cefd78b7 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5806,3 +5806,5 @@ ER_COL_COUNT_DOESNT_MATCH_PLEASE_UPDATE eng "Column count of mysql.%s is wrong. Expected %d, found %d. Created with MySQL %d, now running %d. Please use scripts/mysql_fix_privilege_tables" ER_TABLE_NEEDS_UPGRADE eng "Table upgrade required. Please do \"REPAIR TABLE `%-.32s`\" to fix it!" +ER_ILLEGAL_HA_CREATE_OPTION + eng "Table storage engine '%-.64s' does not support the create option '%.64s'" diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1afaf6ca0c6..9b14e07255f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -42,7 +42,7 @@ static int copy_data_between_tables(TABLE *from,TABLE *to, ha_rows *copied,ha_rows *deleted); static bool prepare_blob_field(THD *thd, create_field *sql_field); static bool check_engine(THD *thd, const char *table_name, - handlerton **new_engine); + HA_CREATE_INFO *create_info); static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, List<create_field> *fields, List<Key> *keys, bool tmp_table, @@ -2021,7 +2021,7 @@ bool mysql_create_table_internal(THD *thd, MYF(0)); DBUG_RETURN(TRUE); } - if (check_engine(thd, table_name, &create_info->db_type)) + if (check_engine(thd, table_name, create_info)) DBUG_RETURN(TRUE); db_options= create_info->table_options; if (create_info->row_type == ROW_TYPE_DYNAMIC) @@ -2148,22 +2148,6 @@ bool mysql_create_table_internal(THD *thd, } #endif -#ifdef NOT_USED - /* - if there is a technical reason for a handler not to have support - for temp. tables this code can be re-enabled. - Otherwise, if a handler author has a wish to prohibit usage of - temporary tables for his handler he should implement a check in - ::create() method - */ - if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) && - (file->table_flags() & HA_NO_TEMP_TABLES)) - { - my_error(ER_ILLEGAL_HA, MYF(0), table_name); - goto err; - } -#endif - set_table_default_charset(thd, create_info, (char*) db); if (mysql_prepare_table(thd, create_info, &fields, @@ -4010,7 +3994,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, DBUG_RETURN(TRUE); } #endif - if (check_engine(thd, new_name, &create_info->db_type)) + if (check_engine(thd, new_name, create_info)) DBUG_RETURN(TRUE); new_db_type= create_info->db_type; if (create_info->row_type == ROW_TYPE_NOT_USED) @@ -5435,8 +5419,9 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) } static bool check_engine(THD *thd, const char *table_name, - handlerton **new_engine) + HA_CREATE_INFO *create_info) { + handlerton **new_engine= &create_info->db_type; handlerton *req_engine= *new_engine; bool no_substitution= test(thd->variables.sql_mode & MODE_NO_ENGINE_SUBSTITUTION); @@ -5452,5 +5437,16 @@ static bool check_engine(THD *thd, const char *table_name, ha_resolve_storage_engine_name(*new_engine), table_name); } + if (create_info->options & HA_LEX_CREATE_TMP_TABLE && + ha_check_storage_engine_flag(*new_engine, HTON_TEMPORARY_NOT_SUPPORTED)) + { + if (create_info->used_fields & HA_CREATE_USED_ENGINE) + { + my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0), (*new_engine)->name, "TEMPORARY"); + *new_engine= 0; + return TRUE; + } + *new_engine= &myisam_hton; + } return FALSE; } |