Below is the list of changes that have just been committed into a local
5.0 repository of svoj. When svoj does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2094 06/05/16 18:37:23 svoj@april.(none) +1 -0
BUG#17001 - Table and server crash on ALTER TABLE
frm and data files for tables created by earlier MySQL
versions becomes out of sync after certain ALTER TABLE statements:
- One that changes column default value;
- One that changes table comment;
- One that changes table password.
As a result one can expirience either server crash or data corruption/loss.
This fix ensures that running ALTER TABLE on tables created by earlier
MySQL versions recreates data files.
sql/sql_table.cc
1.304 06/05/16 18:37:19 svoj@april.(none) +10 -2
Ensure that running ALTER TABLE on tables created by earlier
MySQL versions recreates data files.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: svoj
# Host: april.(none)
# Root: /home/svoj/devel/mysql/BUG17001/mysql-5.0
--- 1.303/sql/sql_table.cc 2006-03-30 18:14:51 +05:00
+++ 1.304/sql/sql_table.cc 2006-05-16 18:37:19 +05:00
@@ -3197,7 +3197,7 @@
uint db_create_options, used_fields;
enum db_type old_db_type,new_db_type;
bool need_copy_table;
- bool no_table_reopen= FALSE;
+ bool no_table_reopen= FALSE, varchar= FALSE;
DBUG_ENTER("mysql_alter_table");
thd->proc_info="init";
@@ -3399,6 +3399,8 @@
Field **f_ptr,*field;
for (f_ptr=table->field ; (field= *f_ptr) ; f_ptr++)
{
+ if (field->type() == MYSQL_TYPE_STRING)
+ varchar= TRUE;
/* Check if field should be dropped */
Alter_drop *drop;
drop_it.rewind();
@@ -3660,12 +3662,18 @@
better have a negative test here, instead of positive, like
alter_info->flags & ALTER_ADD_COLUMN|ALTER_ADD_INDEX|...
so that ALTER TABLE won't break when somebody will add new flag
+
+ MySQL uses frm version to determine the type of the data fields and
+ their layout. See Field_string::type() for details.
+ Thus, if the table is too old we may have to rebuild the data to
+ update the layout.
*/
need_copy_table= (alter_info->flags &
~(ALTER_CHANGE_COLUMN_DEFAULT|ALTER_OPTIONS) ||
(create_info->used_fields &
~(HA_CREATE_USED_COMMENT|HA_CREATE_USED_PASSWORD)) ||
- table->s->tmp_table);
+ table->s->tmp_table ||
+ (table->s->frm_version < FRM_VER_TRUE_VARCHAR && varchar));
create_info->frm_only= !need_copy_table;
/*
| Thread |
|---|
| • bk commit into 5.0 tree (svoj:1.2094) BUG#17001 | Sergey Vojtovich | 16 May |