Add warning of TRANSACTIONAL=1 is used with handler that doesn't support it

Added hton_name() and handler->engine_name() and use these when appropriate


KNOWN_BUGS.txt:
  Added some of the known bugs
mysql-test/r/maria.result:
  Added test for TRANSACTIONAL=1
mysql-test/r/myisam.result:
  Added test for TRANSACTIONAL=1
mysql-test/t/maria.test:
  Added test for TRANSACTIONAL=1
mysql-test/t/myisam.test:
  Added test for TRANSACTIONAL=1
sql/handler.cc:
  ha_resolve_storage_engine_name() -> hton_name()
sql/handler.h:
  Added hton_name() and handler->engine_name()
sql/set_var.cc:
  Use hton_name()
sql/sql_table.cc:
  Add warning of TRANSACTIONAL=1 is used with handler that doesn't support it
  Indentation fixes
  ha_resolve_storage_engine_name() -> hton_name()
sql/sql_tablespace.cc:
  ha_resolve_storage_engine_name() -> hton_name()
  Indentation fixes
sql/sql_yacc.yy:
  ha_resolve_storage_engine_name() -> hton_name()
sql/unireg.cc:
  ha_resolve_storage_engine_name() -> hton_name()
  Indentation fixes
This commit is contained in:
unknown 2008-02-11 20:55:04 +02:00
parent 5fa560e995
commit 315d7b3419
12 changed files with 121 additions and 27 deletions

View File

@ -20,8 +20,8 @@ http://bugs.mysql.com/ so that we can either fix it for next release
or in the worst case add it here for others to know!
Known bugs that are planned to be fixed before next minor release
=================================================================
Known bugs that we are working on and will be fixed shortly
===========================================================
- If the log files are damaged or inconsistent, Maria may fail to start.
We should fix that if this happens and mysqld is restarted (thanks to
@ -31,9 +31,15 @@ Known bugs that are planned to be fixed before next minor release
Temporary fix is to remove or maria_log.???????? files from the data
directory, restart mysqld and run CHECK TABLE / REPAIR TABLE or
mysqlcheck on your Maria tables
- We have some instabilities in log writing that is under investigatation
This causes mainly assert to triggers in the code and sometimes
the log handler doesn't start up after restart.
- LOAD INDEX commands are for the moment ignored for Maria tables
(The code needs to be rewritten to do all reads through page cache to
avoid half-block reads)
- Freeing maria tmp table after fetching rows using prepared statements causes
a crash.
Known bugs that are planned to be fixed before Beta
===================================================

View File

@ -2245,3 +2245,36 @@ n c
301 c
302 d
drop table t1;
create table t1 (n int not null, c char(1)) engine=maria;
alter table t1 engine=myisam;
alter table t1 engine=maria;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`n` int(11) NOT NULL,
`c` char(1) DEFAULT NULL
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
drop table t1;
create table t1 (n int not null, c char(1)) engine=maria transactional=1;
alter table t1 engine=myisam;
Warnings:
Error 1478 Table storage engine 'MyISAM' does not support the create option 'TRANSACTIONAL=1'
alter table t1 engine=maria;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`n` int(11) NOT NULL,
`c` char(1) DEFAULT NULL
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
drop table t1;
create table t1 (n int not null, c char(1)) engine=myisam transactional=1;
Warnings:
Error 1478 Table storage engine 'MyISAM' does not support the create option 'TRANSACTIONAL=1'
alter table t1 engine=maria;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`n` int(11) NOT NULL,
`c` char(1) DEFAULT NULL
) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1 TRANSACTIONAL=1
drop table t1;

View File

@ -2023,4 +2023,14 @@ CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
create table t1 (n int not null, c char(1)) transactional=1;
Warnings:
Error 1478 Table storage engine 'MyISAM' does not support the create option 'TRANSACTIONAL=1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`n` int(11) NOT NULL,
`c` char(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 TRANSACTIONAL=1
drop table t1;
End of 5.1 tests

View File

@ -1454,8 +1454,26 @@ insert into t1 values(null, "d");
select * from t1;
drop table t1;
#
# Test warnings with transactional=1 with MyISAM
#
# End of 5.2 tests
create table t1 (n int not null, c char(1)) engine=maria;
alter table t1 engine=myisam;
alter table t1 engine=maria;
show create table t1;
drop table t1;
create table t1 (n int not null, c char(1)) engine=maria transactional=1;
alter table t1 engine=myisam;
alter table t1 engine=maria;
show create table t1;
drop table t1;
create table t1 (n int not null, c char(1)) engine=myisam transactional=1;
alter table t1 engine=maria;
show create table t1;
drop table t1;
# End of 5.1 tests
--disable_result_log
--disable_query_log

View File

@ -1278,5 +1278,12 @@ DELETE FROM t1 WHERE c1 >= 10;
CHECK TABLE t1;
DROP TABLE t1;
#
# Test warnings with transactional=1 with MyISAM
#
create table t1 (n int not null, c char(1)) transactional=1;
show create table t1;
drop table t1;
--echo End of 5.1 tests

View File

@ -373,8 +373,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin)
handlerton *hton= (handlerton *)plugin->data;
DBUG_ENTER("ha_finalize_handlerton");
switch (hton->state)
{
switch (hton->state) {
case SHOW_OPTION_NO:
case SHOW_OPTION_DISABLED:
break;
@ -647,7 +646,7 @@ int ha_prepare(THD *thd)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
ha_resolve_storage_engine_name(*ht));
hton_name(*ht)->str);
}
}
}
@ -1041,7 +1040,7 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin,
while ((got= hton->recover(hton, info->list, info->len)) > 0 )
{
sql_print_information("Found %d prepared transaction(s) in %s",
got, ha_resolve_storage_engine_name(hton));
got, hton_name(hton)->str);
for (int i=0; i < got; i ++)
{
my_xid x=info->list[i].get_my_xid();
@ -3814,7 +3813,7 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
{
if (db_type->state != SHOW_OPTION_YES)
{
const LEX_STRING *name=&hton2plugin[db_type->slot]->name;
const LEX_STRING *name= hton_name(db_type);
result= stat_print(thd, name->str, name->length,
"", 0, "DISABLED", 8) ? 1 : 0;
}

View File

@ -709,6 +709,12 @@ struct handlerton
};
inline LEX_STRING *hton_name(const handlerton *hton)
{
return &(hton2plugin[hton->slot]->name);
}
/* Possible flags of a handlerton (there can be 32 of them) */
#define HTON_NO_FLAGS 0
#define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0)
@ -1629,6 +1635,8 @@ public:
*/
virtual void use_hidden_primary_key();
LEX_STRING *engine_name() { return hton_name(ht); }
protected:
/* Service methods for use by storage engines. */
void ha_statistic_increment(ulong SSV::*offset) const;
@ -1644,6 +1652,7 @@ protected:
*/
virtual int rename_table(const char *from, const char *to);
virtual int delete_table(const char *name);
private:
/*
Low-level primitives for storage engines. These should be
@ -1848,7 +1857,7 @@ static inline enum legacy_db_type ha_legacy_type(const handlerton *db_type)
static inline const char *ha_resolve_storage_engine_name(const handlerton *db_type)
{
return db_type == NULL ? "UNKNOWN" : hton2plugin[db_type->slot]->name.str;
return db_type == NULL ? "UNKNOWN" : hton_name(db_type)->str;
}
static inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag)

View File

@ -3529,7 +3529,7 @@ uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
if (type == OPT_GLOBAL)
plugin= my_plugin_lock(thd, &(global_system_variables.*offset));
hton= plugin_data(plugin, handlerton*);
engine_name= &hton2plugin[hton->slot]->name;
engine_name= hton_name(hton);
result= (uchar *) thd->strmake(engine_name->str, engine_name->length);
if (type == OPT_GLOBAL)
plugin_unlock(thd, plugin);

View File

@ -3418,6 +3418,14 @@ bool mysql_create_table_no_lock(THD *thd,
goto err;
}
/* Give warnings for not supported table options */
if (create_info->transactional && !file->ht->commit)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_ILLEGAL_HA_CREATE_OPTION,
ER(ER_ILLEGAL_HA_CREATE_OPTION),
file->engine_name()->str,
"TRANSACTIONAL=1");
VOID(pthread_mutex_lock(&LOCK_open));
if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
{
@ -5414,6 +5422,7 @@ bool alter_table_manage_keys(TABLE *table, int indexes_were_disabled,
Sets create_info->varchar if the table has a VARCHAR column.
Prepares alter_info->create_list and alter_info->key_list with
columns and keys of the new table.
@retval TRUE error, out of memory or a semantical error in ALTER
TABLE instructions
@retval FALSE success
@ -5440,7 +5449,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
uint used_fields= create_info->used_fields;
KEY *key_info=table->key_info;
bool rc= TRUE;
Create_field *def;
Field **f_ptr,*field;
DBUG_ENTER("mysql_prepare_alter_table");
create_info->varchar= FALSE;
@ -5476,18 +5486,16 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
create_info->tablespace= tablespace;
}
restore_record(table, s->default_values); // Empty record for DEFAULT
Create_field *def;
/*
First collect all fields from table which isn't in drop_list
*/
Field **f_ptr,*field;
for (f_ptr=table->field ; (field= *f_ptr) ; f_ptr++)
{
Alter_drop *drop;
if (field->type() == MYSQL_TYPE_STRING)
create_info->varchar= TRUE;
/* Check if field should be dropped */
Alter_drop *drop;
drop_it.rewind();
while ((drop=drop_it++))
{
@ -5561,7 +5569,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
{
if (def->change && ! def->field)
{
my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change, table->s->table_name.str);
my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change,
table->s->table_name.str);
goto err;
}
/*
@ -5596,7 +5605,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}
if (!find)
{
my_error(ER_BAD_FIELD_ERROR, MYF(0), def->after, table->s->table_name.str);
my_error(ER_BAD_FIELD_ERROR, MYF(0), def->after,
table->s->table_name.str);
goto err;
}
find_it.after(def); // Put element after this
@ -5646,6 +5656,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
continue; // Wrong field (from UNIREG)
const char *key_part_name=key_part->field->field_name;
Create_field *cfield;
uint key_part_length;
field_it.rewind();
while ((cfield=field_it++))
{
@ -5661,7 +5673,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
}
if (!cfield)
continue; // Field is removed
uint key_part_length=key_part->length;
key_part_length= key_part->length;
if (cfield->field) // Not new field
{
/*
@ -7312,7 +7324,7 @@ static bool check_engine(THD *thd, const char *table_name,
if (create_info->used_fields & HA_CREATE_USED_ENGINE)
{
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0),
ha_resolve_storage_engine_name(*new_engine), "TEMPORARY");
hton_name(*new_engine)->str, "TEMPORARY");
*new_engine= 0;
return TRUE;
}

View File

@ -34,7 +34,7 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_WARN_USING_OTHER_HANDLER,
ER(ER_WARN_USING_OTHER_HANDLER),
ha_resolve_storage_engine_name(hton),
hton_name(hton)->str,
ts_info->tablespace_name ? ts_info->tablespace_name
: ts_info->logfile_group_name);
}
@ -43,14 +43,15 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
{
if ((error= hton->alter_tablespace(hton, thd, ts_info)))
{
if (error == 1)
{
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));
@ -63,7 +64,7 @@ int mysql_alter_tablespace(THD *thd, st_alter_tablespace *ts_info)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_ILLEGAL_HA_CREATE_OPTION,
ER(ER_ILLEGAL_HA_CREATE_OPTION),
ha_resolve_storage_engine_name(hton),
hton_name(hton)->str,
"TABLESPACE or LOGFILE GROUP");
}
write_bin_log(thd, FALSE, thd->query, thd->query_length);

View File

@ -1650,7 +1650,7 @@ create:
push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_USING_OTHER_HANDLER,
ER(ER_WARN_USING_OTHER_HANDLER),
ha_resolve_storage_engine_name(lex->create_info.db_type),
hton_name(lex->create_info.db_type)->str,
$5->table.str);
}
}

View File

@ -159,8 +159,7 @@ bool mysql_create_frm(THD *thd, const char *file_name,
reclength=uint2korr(forminfo+266);
/* Calculate extra data segment length */
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= *hton_name(create_info->db_type);
/* str_db_type */
create_info->extra_size= (2 + str_db_type.length +
2 + create_info->connect_string.length);