Skip to content

Commit 6fc74e1

Browse files
author
serg@serg.mylan
committed
post-review fixes
HA_EXTRA_WRITE_CACHE now part of start_bulk_insert() test cleanups
1 parent e8eda81 commit 6fc74e1

16 files changed

+57
-88
lines changed

mysql-test/r/myisam.result

+2-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_par
523523
t1 1 a 1 a A 1000 NULL NULL YES BTREE
524524
alter table t1 engine=heap;
525525
alter table t1 disable keys;
526-
ERROR HY000: Table storage engine for 't1' doesn't have this option
526+
Warnings:
527+
Note 1031 Table storage engine for 't1' doesn't have this option
527528
show keys from t1;
528529
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
529530
t1 1 a 1 a NULL NULL NULL NULL YES HASH

mysql-test/r/repair_part1.result renamed to mysql-test/r/repair.result

+8
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ repair table t1 use_frm;
2828
Table Op Msg_type Msg_text
2929
test.t1 repair error Table 'test.t1' doesn't exist
3030
create table t1 engine=myisam SELECT 1,"table 1";
31+
repair table t1;
32+
Table Op Msg_type Msg_text
33+
test.t1 repair error Can't open file: 't1.MYI' (errno: 130)
34+
repair table t1 use_frm;
35+
Table Op Msg_type Msg_text
36+
test.t1 repair warning Number of rows changed from 0 to 1
37+
test.t1 repair status OK
38+
drop table t1;

mysql-test/r/repair_part2.result

-8
This file was deleted.

mysql-test/t/lowercase_table2.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
# Test of --lower-case-table-names=2
3-
# (User has case insensitive file system and want's to preserve case of
3+
# (User has case insensitive file system and wants to preserve case of
44
# table names)
55
#
66
--source include/have_innodb.inc

mysql-test/t/lowercase_table3.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
# Test of force of lower-case-table-names=0
3-
# (User has case insensitive file system and want's to preserve case of
3+
# (User has case insensitive file system and wants to preserve case of
44
# table names)
55
#
66

mysql-test/t/lowercase_table_qcache.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ select * from MySQL.db;
2626
enable_result_log;
2727
show status like "Qcache_queries_in_cache";
2828

29-
set GLOBAL query_cache_size=0;
29+
set GLOBAL query_cache_size=0;

mysql-test/t/myisam.test

-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ show keys from t1;
498498
alter table t1 enable keys;
499499
show keys from t1;
500500
alter table t1 engine=heap;
501-
--error 1031
502501
alter table t1 disable keys;
503502
show keys from t1;
504503
drop table t1,t2;

mysql-test/t/repair_part1.test renamed to mysql-test/t/repair.test

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ drop table t1;
2727
# non-existent table
2828
repair table t1 use_frm;
2929

30-
#
31-
# Create test table for repair2
32-
# The following must be last in this file
33-
3430
create table t1 engine=myisam SELECT 1,"table 1";
31+
system echo 1 > $MYSQL_TEST_DIR/var/master-data/test/t1.MYI ;
32+
repair table t1;
33+
repair table t1 use_frm;
34+
drop table t1;

mysql-test/t/repair_part2-master.sh

-1
This file was deleted.

mysql-test/t/repair_part2.test

-7
This file was deleted.

sql/field.cc

+3-4
Original file line numberDiff line numberDiff line change
@@ -3098,8 +3098,7 @@ longlong Field_timestamp::val_int(void)
30983098
}
30993099

31003100

3101-
String *Field_timestamp::val_str(String *val_buffer,
3102-
String *val_ptr __attribute__((unused)))
3101+
String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
31033102
{
31043103
uint32 temp, temp2;
31053104
time_t time_arg;
@@ -3119,8 +3118,8 @@ String *Field_timestamp::val_str(String *val_buffer,
31193118

31203119
if (temp == 0L)
31213120
{ /* Zero time is "000000" */
3122-
val_buffer->set("0000-00-00 00:00:00", 19, &my_charset_bin);
3123-
return val_buffer;
3121+
val_ptr->set("0000-00-00 00:00:00", 19, &my_charset_bin);
3122+
return val_ptr;
31243123
}
31253124
val_buffer->set_charset(&my_charset_bin); // Safety
31263125
time_arg=(time_t) temp;

sql/field.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ class Field
9898
virtual void store_time(TIME *ltime,timestamp_type t_type);
9999
virtual double val_real(void)=0;
100100
virtual longlong val_int(void)=0;
101-
String *val_str(String *str) { return val_str(str, str); }
102-
/* val_str(buf1, buf2) gets two buffers and should use them as follows:
101+
inline String *val_str(String *str) { return val_str(str, str); }
102+
/*
103+
val_str(buf1, buf2) gets two buffers and should use them as follows:
103104
if it needs a temp buffer to convert result to string - use buf1
104105
example Field_tiny::val_str()
105106
if the value exists as a string already - use buf2

sql/ha_myisam.cc

+13-9
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,8 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
810810
}
811811
}
812812

813-
/* disable indexes, making it persistent if requested
813+
/*
814+
disable indexes, making it persistent if requested
814815
SYNOPSIS
815816
disable_indexes(all, save)
816817
all disable all indexes
@@ -863,11 +864,16 @@ int ha_myisam::enable_indexes()
863864

864865
void ha_myisam::start_bulk_insert(ha_rows rows)
865866
{
867+
THD *thd=current_thd;
868+
ulong size= min(thd->variables.read_buff_size, table->avg_row_length*rows);
869+
870+
mi_extra(file, HA_EXTRA_WRITE_CACHE, (void*)&size);
871+
872+
can_enable_indexes= (file->s->state.key_map ==
873+
set_bits(ulonglong, file->s->base.keys));
874+
866875
if (!(specialflag & SPECIAL_SAFE_MODE))
867876
{
868-
can_enable_indexes= (file->s->state.key_map ==
869-
set_bits(ulonglong, file->s->base.keys));
870-
871877
/*
872878
Only disable old index if the table was empty and we are inserting
873879
a lot of rows.
@@ -881,18 +887,16 @@ void ha_myisam::start_bulk_insert(ha_rows rows)
881887
if (!file->bulk_insert &&
882888
(!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT))
883889
{
884-
mi_init_bulk_insert(file,
885-
current_thd->variables.bulk_insert_buff_size,
886-
rows);
890+
mi_init_bulk_insert(file, thd->variables.bulk_insert_buff_size, rows);
887891
}
888892
}
889893
}
890894

891-
892895
int ha_myisam::end_bulk_insert()
893896
{
894897
mi_end_bulk_insert(file);
895-
return can_enable_indexes ? enable_indexes() : 0;
898+
int err=mi_extra(file, HA_EXTRA_NO_CACHE, 0);
899+
return err ? err : can_enable_indexes ? enable_indexes() : 0;
896900
}
897901

898902

sql/sql_insert.cc

+9-36
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
264264
thd->proc_info="update";
265265
if (duplic != DUP_ERROR)
266266
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
267-
if ((lock_type != TL_WRITE_DELAYED && !(specialflag & SPECIAL_SAFE_MODE)) &&
268-
values_list.elements >= MIN_ROWS_TO_USE_BULK_INSERT)
269-
{
270-
table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
271-
min(thd->variables.read_buff_size,
272-
table->avg_row_length*values_list.elements));
267+
if (lock_type != TL_WRITE_DELAYED)
273268
table->file->start_bulk_insert(values_list.elements);
274-
bulk_insert=1;
275-
}
276-
else
277-
bulk_insert=0;
278269

279270
while ((values= its++))
280271
{
@@ -352,24 +343,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
352343
else
353344
#endif
354345
{
355-
if (bulk_insert)
346+
if (table->file->end_bulk_insert() && !error)
356347
{
357-
if (table->file->extra(HA_EXTRA_NO_CACHE))
358-
{
359-
if (!error)
360-
{
361-
table->file->print_error(my_errno,MYF(0));
362-
error=1;
363-
}
364-
}
365-
if (table->file->end_bulk_insert())
366-
{
367-
if (!error)
368-
{
369-
table->file->print_error(my_errno,MYF(0));
370-
error=1;
371-
}
372-
}
348+
table->file->print_error(my_errno,MYF(0));
349+
error=1;
373350
}
374351
if (id && values_list.elements != 1)
375352
thd->insert_id(id); // For update log
@@ -387,7 +364,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
387364
transactional_table= table->file->has_transactions();
388365

389366
log_delayed= (transactional_table || table->tmp_table);
390-
if ((info.copied || info.deleted || info.updated) &&
367+
if ((info.copied || info.deleted || info.updated) &&
391368
(error <= 0 || !transactional_table))
392369
{
393370
mysql_update_log.write(thd, thd->query, thd->query_length);
@@ -1439,8 +1416,6 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
14391416
table->next_number_field=table->found_next_number_field;
14401417
thd->count_cuted_fields= CHECK_FIELD_WARN; // calc cuted fields
14411418
thd->cuted_fields=0;
1442-
if (info.handle_duplicates != DUP_REPLACE)
1443-
table->file->extra(HA_EXTRA_WRITE_CACHE);
14441419
if (info.handle_duplicates == DUP_IGNORE ||
14451420
info.handle_duplicates == DUP_REPLACE)
14461421
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
@@ -1497,15 +1472,14 @@ void select_insert::send_error(uint errcode,const char *err)
14971472
*/
14981473
DBUG_VOID_RETURN;
14991474
}
1500-
table->file->extra(HA_EXTRA_NO_CACHE);
15011475
table->file->end_bulk_insert();
15021476
/*
15031477
If at least one row has been inserted/modified and will stay in the table
15041478
(the table doesn't have transactions) (example: we got a duplicate key
15051479
error while inserting into a MyISAM table) we must write to the binlog (and
15061480
the error code will make the slave stop).
15071481
*/
1508-
if ((info.copied || info.deleted || info.updated) &&
1482+
if ((info.copied || info.deleted || info.updated) &&
15091483
!table->file->has_transactions())
15101484
{
15111485
if (last_insert_id)
@@ -1518,7 +1492,7 @@ void select_insert::send_error(uint errcode,const char *err)
15181492
mysql_bin_log.write(&qinfo);
15191493
}
15201494
if (!table->tmp_table)
1521-
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
1495+
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
15221496
}
15231497
if (info.copied || info.deleted || info.updated)
15241498
query_cache_invalidate3(thd, table, 1);
@@ -1532,8 +1506,7 @@ bool select_insert::send_eof()
15321506
int error,error2;
15331507
DBUG_ENTER("select_insert::send_eof");
15341508

1535-
if (!(error=table->file->extra(HA_EXTRA_NO_CACHE)))
1536-
error=table->file->end_bulk_insert();
1509+
error=table->file->end_bulk_insert();
15371510
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
15381511

15391512
/*
@@ -1609,7 +1582,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
16091582

16101583
/* Don't set timestamp if used */
16111584
table->timestamp_default_now= table->timestamp_on_update_now= 0;
1612-
1585+
16131586
table->next_number_field=table->found_next_number_field;
16141587

16151588
restore_record(table,default_values); // Get empty record

sql/sql_load.cc

+1-5
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
276276
{
277277
if (use_timestamp)
278278
table->timestamp_default_now= table->timestamp_on_update_now= 0;
279-
279+
280280
table->next_number_field=table->found_next_number_field;
281-
VOID(table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
282-
thd->variables.read_buff_size));
283281
if (handle_duplicates == DUP_IGNORE ||
284282
handle_duplicates == DUP_REPLACE)
285283
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
@@ -291,8 +289,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
291289
else
292290
error=read_sep_field(thd,info,table,fields,read_info,*enclosed,
293291
skip_lines);
294-
if (table->file->extra(HA_EXTRA_NO_CACHE))
295-
error=1; /* purecov: inspected */
296292
if (table->file->end_bulk_insert())
297293
error=1; /* purecov: inspected */
298294
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);

sql/sql_table.cc

+11-7
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,13 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
22712271
break;
22722272
}
22732273
}
2274+
if (error==HA_ERR_WRONG_COMMAND)
2275+
{
2276+
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2277+
ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
2278+
table->table_name);
2279+
error=0;
2280+
}
22742281
if (!error)
22752282
{
22762283
mysql_update_log.write(thd, thd->query, thd->query_length);
@@ -2866,7 +2873,6 @@ copy_data_between_tables(TABLE *from,TABLE *to,
28662873
DBUG_RETURN(-1); /* purecov: inspected */
28672874

28682875
to->file->external_lock(thd,F_WRLCK);
2869-
to->file->extra(HA_EXTRA_WRITE_CACHE);
28702876
from->file->info(HA_STATUS_VARIABLE);
28712877
to->file->start_bulk_insert(from->file->records);
28722878

@@ -2951,17 +2957,15 @@ copy_data_between_tables(TABLE *from,TABLE *to,
29512957
end_read_record(&info);
29522958
free_io_cache(from);
29532959
delete [] copy; // This is never 0
2954-
uint tmp_error;
2955-
if ((tmp_error=to->file->extra(HA_EXTRA_NO_CACHE)))
2960+
2961+
if (to->file->end_bulk_insert() && !error)
29562962
{
2957-
to->file->print_error(tmp_error,MYF(0));
2963+
to->file->print_error(my_errno,MYF(0));
29582964
error=1;
29592965
}
29602966
to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
2961-
if (to->file->end_bulk_insert())
2962-
error=1;
29632967

2964-
tmp_error = ha_recovery_logging(thd,TRUE);
2968+
ha_recovery_logging(thd,TRUE);
29652969
/*
29662970
Ensure that the new table is saved properly to disk so that we
29672971
can do a rename

0 commit comments

Comments
 (0)