From d06bb6fa39d1fcac1b30b256603ec87ffe752713 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Mon, 16 May 2005 15:21:35 +0300 Subject: [PATCH] After merge fixes --- mysql-test/r/alter_table.result | 19 ++++++++++++++----- sql/handler.cc | 7 ++++--- sql/sql_table.cc | 7 ++++--- sql/sql_yacc.yy | 2 +- sql/unireg.cc | 12 +++++------- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index e91a164db6f..74f0e3d9425 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -389,7 +389,7 @@ alter table t1 modify a varchar(10); show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` varchar(10) NOT NULL default '', + `a` varchar(10) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`) flush tables; @@ -397,7 +397,7 @@ alter table t1 modify a varchar(10) not null; show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` varchar(10) NOT NULL default '', + `a` varchar(10) NOT NULL, PRIMARY KEY (`a`) ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`) 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 insert into t1 (a) values(1); 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 -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; 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 -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; 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); +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'; 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; set names koi8r; create table t1 (a char(10) character set koi8r); diff --git a/sql/handler.cc b/sql/handler.cc index a34b3bd8aac..d641628ac86 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1420,6 +1420,7 @@ void handler::update_auto_increment() ulonglong nr; THD *thd= table->in_use; struct system_variables *variables= &thd->variables; + bool auto_increment_field_not_null; DBUG_ENTER("handler::update_auto_increment"); /* @@ -1427,13 +1428,14 @@ void handler::update_auto_increment() row was not inserted */ 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 || - table->auto_increment_field_not_null && + auto_increment_field_not_null && thd->variables.sql_mode & MODE_NO_AUTO_VALUE_ON_ZERO) { /* Clear flag for next row */ - table->auto_increment_field_not_null= FALSE; /* Mark that we didn't generate a new value **/ auto_increment_column_changed=0; @@ -1449,7 +1451,6 @@ void handler::update_auto_increment() } DBUG_VOID_RETURN; } - table->auto_increment_field_not_null= FALSE; if (!(nr= thd->next_insert_id)) { nr= get_auto_increment(); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b6e44f8ec25..4ddef3fc653 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -640,7 +640,7 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, { const char *key_name; 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; KEY *key_info; KEY_PART_INFO *key_part_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; null_fields=blob_columns=0; create_info->varchar= 0; + max_key_length= file->max_key_length(); 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, { 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=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) { /* not a critical problem */ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 21a9d344e22..9328d7345c3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3990,7 +3990,7 @@ select_options: { 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; } } diff --git a/sql/unireg.cc b/sql/unireg.cc index 82f91d1da68..da463885f85 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -45,8 +45,7 @@ static bool pack_fields(File file, List &create_fields, static bool make_empty_rec(THD *thd, int file, enum db_type table_type, uint table_options, List &create_fields, - uint reclength, uint null_fields, - ulong data_offset); + uint reclength, ulong data_offset); /* Create a frm (table definition) file @@ -72,7 +71,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, uint keys, KEY *key_info, 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; ulong filepos, data_offset; uchar fileinfo[64],forminfo[288],*keybuff; @@ -111,7 +110,6 @@ bool mysql_create_frm(THD *thd, my_string file_name, } } reclength=uint2korr(forminfo+266); - null_fields=uint2korr(forminfo+282); if ((file=create_frm(file_name, reclength, fileinfo, create_info, keys)) < 0) @@ -145,7 +143,7 @@ bool mysql_create_frm(THD *thd, my_string file_name, (ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length, MY_SEEK_SET,MYF(0))); 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; VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0))); @@ -661,7 +659,7 @@ static bool pack_fields(File file, List &create_fields, static bool make_empty_rec(THD *thd, File file,enum db_type table_type, uint table_options, List &create_fields, - uint reclength, uint null_fields, + uint reclength, ulong data_offset) { int error; @@ -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 *buff|= 1; } - DBUG_ASSERT(data_offset == ((null_fields + null_count + 7) / 8)); null_pos= buff; List_iterator it(create_fields); @@ -756,6 +753,7 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type, else regfield->reset(); } + DBUG_ASSERT(data_offset == ((null_count + 7) / 8)); /* Fill not used startpos */ if (null_count)