Commit d15f89c4 authored by unknown's avatar unknown

After merge fixes


mysql-test/r/alter_table.result:
  Fixed results after merge
sql/handler.cc:
  Trivial optimzation
sql/sql_table.cc:
  Trvial optimization
sql/sql_yacc.yy:
  After merge fix
sql/unireg.cc:
  Removed argument 'null_fields' from make_empty_rec() as it was not needed
  Moved assert() to right place to take bit fields into account
parent f8f714a2
...@@ -389,7 +389,7 @@ alter table t1 modify a varchar(10); ...@@ -389,7 +389,7 @@ alter table t1 modify a varchar(10);
show create table t2; show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` varchar(10) NOT NULL default '', `a` varchar(10) NOT NULL,
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`) ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`)
flush tables; flush tables;
...@@ -397,7 +397,7 @@ alter table t1 modify a varchar(10) not null; ...@@ -397,7 +397,7 @@ alter table t1 modify a varchar(10) not null;
show create table t2; show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
`a` varchar(10) NOT NULL default '', `a` varchar(10) NOT NULL,
PRIMARY KEY (`a`) PRIMARY KEY (`a`)
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`) ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`)
drop table if exists t1, t2; drop table if exists t1, t2;
...@@ -405,17 +405,26 @@ create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, p ...@@ -405,17 +405,26 @@ create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, p
insert into t1 (a) values(1); insert into t1 (a) values(1);
show table status like 't1'; show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 9 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL t1 MyISAM 10 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
alter table t1 modify a int; alter table t1 modify a int;
show table status like 't1'; show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 9 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL t1 MyISAM 10 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
drop table t1; drop table t1;
create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM; create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
insert into t1 (a) values(1); insert into t1 (a) values(1);
Warnings:
Warning 1364 Field 'b' doesn't have a default value
Warning 1364 Field 'c' doesn't have a default value
Warning 1364 Field 'd' doesn't have a default value
Warning 1364 Field 'e' doesn't have a default value
Warning 1364 Field 'f' doesn't have a default value
Warning 1364 Field 'g' doesn't have a default value
Warning 1364 Field 'h' doesn't have a default value
Warning 1364 Field 'i' doesn't have a default value
show table status like 't1'; show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 9 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL t1 MyISAM 10 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL
drop table t1; drop table t1;
set names koi8r; set names koi8r;
create table t1 (a char(10) character set koi8r); create table t1 (a char(10) character set koi8r);
......
...@@ -1420,6 +1420,7 @@ void handler::update_auto_increment() ...@@ -1420,6 +1420,7 @@ void handler::update_auto_increment()
ulonglong nr; ulonglong nr;
THD *thd= table->in_use; THD *thd= table->in_use;
struct system_variables *variables= &thd->variables; struct system_variables *variables= &thd->variables;
bool auto_increment_field_not_null;
DBUG_ENTER("handler::update_auto_increment"); DBUG_ENTER("handler::update_auto_increment");
/* /*
...@@ -1427,13 +1428,14 @@ void handler::update_auto_increment() ...@@ -1427,13 +1428,14 @@ void handler::update_auto_increment()
row was not inserted row was not inserted
*/ */
thd->prev_insert_id= thd->next_insert_id; thd->prev_insert_id= thd->next_insert_id;
auto_increment_field_not_null= table->auto_increment_field_not_null;
table->auto_increment_field_not_null= FALSE;
if ((nr= table->next_number_field->val_int()) != 0 || if ((nr= table->next_number_field->val_int()) != 0 ||
table->auto_increment_field_not_null && auto_increment_field_not_null &&
thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO) thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO)
{ {
/* Clear flag for next row */ /* Clear flag for next row */
table->auto_increment_field_not_null= FALSE;
/* Mark that we didn't generate a new value **/ /* Mark that we didn't generate a new value **/
auto_increment_column_changed=0; auto_increment_column_changed=0;
...@@ -1449,7 +1451,6 @@ void handler::update_auto_increment() ...@@ -1449,7 +1451,6 @@ void handler::update_auto_increment()
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
table->auto_increment_field_not_null= FALSE;
if (!(nr= thd->next_insert_id)) if (!(nr= thd->next_insert_id))
{ {
nr= get_auto_increment(); nr= get_auto_increment();
......
...@@ -640,7 +640,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, ...@@ -640,7 +640,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
{ {
const char *key_name; const char *key_name;
create_field *sql_field,*dup_field; create_field *sql_field,*dup_field;
uint field,null_fields,blob_columns; uint field,null_fields,blob_columns,max_key_length;
ulong record_offset= 0; ulong record_offset= 0;
KEY *key_info; KEY *key_info;
KEY_PART_INFO *key_part_info; KEY_PART_INFO *key_part_info;
...@@ -654,6 +654,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, ...@@ -654,6 +654,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
select_field_pos= fields->elements - select_field_count; select_field_pos= fields->elements - select_field_count;
null_fields=blob_columns=0; null_fields=blob_columns=0;
create_info->varchar= 0; create_info->varchar= 0;
max_key_length= file->max_key_length();
for (field_no=0; (sql_field=it++) ; field_no++) for (field_no=0; (sql_field=it++) ; field_no++)
{ {
...@@ -1190,10 +1191,10 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, ...@@ -1190,10 +1191,10 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
{ {
if (f_is_blob(sql_field->pack_flag)) if (f_is_blob(sql_field->pack_flag))
{ {
if ((length=column->length) > file->max_key_length() || if ((length=column->length) > max_key_length ||
length > file->max_key_part_length()) length > file->max_key_part_length())
{ {
length=min(file->max_key_length(), file->max_key_part_length()); length=min(max_key_length, file->max_key_part_length());
if (key->type == Key::MULTIPLE) if (key->type == Key::MULTIPLE)
{ {
/* not a critical problem */ /* not a critical problem */
......
...@@ -3990,7 +3990,7 @@ select_options: ...@@ -3990,7 +3990,7 @@ select_options:
{ {
if (test_all_bits(Select->options, SELECT_ALL | SELECT_DISTINCT)) if (test_all_bits(Select->options, SELECT_ALL | SELECT_DISTINCT))
{ {
net_printf(Lex->thd, ER_WRONG_USAGE, "ALL", "DISTINCT"); my_error(ER_WRONG_USAGE, MYF(0), "ALL", "DISTINCT");
YYABORT; YYABORT;
} }
} }
......
...@@ -45,8 +45,7 @@ static bool pack_fields(File file, List<create_field> &create_fields, ...@@ -45,8 +45,7 @@ static bool pack_fields(File file, List<create_field> &create_fields,
static bool make_empty_rec(THD *thd, int file, enum db_type table_type, static bool make_empty_rec(THD *thd, int file, enum db_type table_type,
uint table_options, uint table_options,
List<create_field> &create_fields, List<create_field> &create_fields,
uint reclength, uint null_fields, uint reclength, ulong data_offset);
ulong data_offset);
/* /*
Create a frm (table definition) file Create a frm (table definition) file
...@@ -72,7 +71,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, ...@@ -72,7 +71,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
uint keys, KEY *key_info, uint keys, KEY *key_info,
handler *db_file) handler *db_file)
{ {
uint reclength,info_length,screens,key_info_length,maxlength,null_fields; uint reclength,info_length,screens,key_info_length,maxlength;
File file; File file;
ulong filepos, data_offset; ulong filepos, data_offset;
uchar fileinfo[64],forminfo[288],*keybuff; uchar fileinfo[64],forminfo[288],*keybuff;
...@@ -111,7 +110,6 @@ bool mysql_create_frm(THD *thd, my_string file_name, ...@@ -111,7 +110,6 @@ bool mysql_create_frm(THD *thd, my_string file_name,
} }
} }
reclength=uint2korr(forminfo+266); reclength=uint2korr(forminfo+266);
null_fields=uint2korr(forminfo+282);
if ((file=create_frm(file_name, reclength, fileinfo, if ((file=create_frm(file_name, reclength, fileinfo,
create_info, keys)) < 0) create_info, keys)) < 0)
...@@ -145,7 +143,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, ...@@ -145,7 +143,7 @@ bool mysql_create_frm(THD *thd, my_string file_name,
(ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length, (ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length,
MY_SEEK_SET,MYF(0))); MY_SEEK_SET,MYF(0)));
if (make_empty_rec(thd,file,create_info->db_type,create_info->table_options, if (make_empty_rec(thd,file,create_info->db_type,create_info->table_options,
create_fields,reclength, null_fields, data_offset)) create_fields,reclength, data_offset))
goto err; goto err;
VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0))); VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0)));
...@@ -661,7 +659,7 @@ static bool pack_fields(File file, List<create_field> &create_fields, ...@@ -661,7 +659,7 @@ static bool pack_fields(File file, List<create_field> &create_fields,
static bool make_empty_rec(THD *thd, File file,enum db_type table_type, static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
uint table_options, uint table_options,
List<create_field> &create_fields, List<create_field> &create_fields,
uint reclength, uint null_fields, uint reclength,
ulong data_offset) ulong data_offset)
{ {
int error; int error;
...@@ -696,7 +694,6 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type, ...@@ -696,7 +694,6 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
null_count++; // Need one bit for delete mark null_count++; // Need one bit for delete mark
*buff|= 1; *buff|= 1;
} }
DBUG_ASSERT(data_offset == ((null_fields + null_count + 7) / 8));
null_pos= buff; null_pos= buff;
List_iterator<create_field> it(create_fields); List_iterator<create_field> it(create_fields);
...@@ -756,6 +753,7 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type, ...@@ -756,6 +753,7 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
else else
regfield->reset(); regfield->reset();
} }
DBUG_ASSERT(data_offset == ((null_count + 7) / 8));
/* Fill not used startpos */ /* Fill not used startpos */
if (null_count) if (null_count)
......
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