Commit b2a13dd7 authored by msvensson@neptunus.(none)'s avatar msvensson@neptunus.(none)

Merge bk-internal:/home/bk/mysql-5.1-new

into  neptunus.(none):/home/msvensson/mysql/mysql-5.1
parents a50d87da 9495f8c5
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;
-- 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;
......@@ -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
......
......@@ -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
{
......
......@@ -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'"
......@@ -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;
}
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