Commit 736853e5 authored by unknown's avatar unknown

post-review fixes

HA_EXTRA_WRITE_CACHE now part of start_bulk_insert()
test cleanups


BitKeeper/deleted/.del-repair_part2-master.sh~f44a8c15d6c36585:
  Delete: mysql-test/t/repair_part2-master.sh
BitKeeper/deleted/.del-repair_part2.test~c20f60783b04d001:
  Delete: mysql-test/t/repair_part2.test
BitKeeper/deleted/.del-repair_part2.result~72ca166fb248b566:
  Delete: mysql-test/r/repair_part2.result
mysql-test/r/myisam.result:
  updated
mysql-test/t/lowercase_table2.test:
  typo fixed
mysql-test/r/repair.result:
  single repair.test from repair_part[12].test
mysql-test/t/lowercase_table3.test:
  typo fixed
mysql-test/t/lowercase_table_qcache.test:
  newline added
mysql-test/t/myisam.test:
  updated
mysql-test/t/repair.test:
  single repair.test from repair_part[12].test
sql/field.cc:
  reverted
sql/field.h:
  style fix
sql/ha_myisam.cc:
  add HA_EXTRA_WRITE_CACHE to start_bulk_insert
sql/sql_insert.cc:
  add HA_EXTRA_WRITE_CACHE to start_bulk_insert
sql/sql_load.cc:
  add HA_EXTRA_WRITE_CACHE to start_bulk_insert
sql/sql_table.cc:
  add HA_EXTRA_WRITE_CACHE to start_bulk_insert
parent c6270543
......@@ -523,7 +523,8 @@ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_par
t1 1 a 1 a A 1000 NULL NULL YES BTREE
alter table t1 engine=heap;
alter table t1 disable keys;
ERROR HY000: Table storage engine for 't1' doesn't have this option
Warnings:
Note 1031 Table storage engine for 't1' doesn't have this option
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a NULL NULL NULL NULL YES HASH
......
......@@ -28,3 +28,11 @@ repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair error Table 'test.t1' doesn't exist
create table t1 engine=myisam SELECT 1,"table 1";
repair table t1;
Table Op Msg_type Msg_text
test.t1 repair error Can't open file: 't1.MYI' (errno: 130)
repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 1
test.t1 repair status OK
drop table t1;
repair table t1;
Table Op Msg_type Msg_text
test.t1 repair error Can't open file: 't1.MYI' (errno: 130)
repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 1
test.t1 repair status OK
drop table t1;
#
# Test of --lower-case-table-names=2
# (User has case insensitive file system and want's to preserve case of
# (User has case insensitive file system and wants to preserve case of
# table names)
#
--source include/have_innodb.inc
......
#
# Test of force of lower-case-table-names=0
# (User has case insensitive file system and want's to preserve case of
# (User has case insensitive file system and wants to preserve case of
# table names)
#
......
......@@ -26,4 +26,4 @@ select * from MySQL.db;
enable_result_log;
show status like "Qcache_queries_in_cache";
set GLOBAL query_cache_size=0;
\ No newline at end of file
set GLOBAL query_cache_size=0;
......@@ -498,7 +498,6 @@ show keys from t1;
alter table t1 enable keys;
show keys from t1;
alter table t1 engine=heap;
--error 1031
alter table t1 disable keys;
show keys from t1;
drop table t1,t2;
......
......@@ -27,8 +27,8 @@ drop table t1;
# non-existent table
repair table t1 use_frm;
#
# Create test table for repair2
# The following must be last in this file
create table t1 engine=myisam SELECT 1,"table 1";
system echo 1 > $MYSQL_TEST_DIR/var/master-data/test/t1.MYI ;
repair table t1;
repair table t1 use_frm;
drop table t1;
echo "1" > $MYSQL_TEST_DIR/var/master-data/test/t1.MYI
#
# This test starts with a crashed t1.MYI file left over from repair.test
#
repair table t1;
repair table t1 use_frm;
drop table t1;
......@@ -3098,8 +3098,7 @@ longlong Field_timestamp::val_int(void)
}
String *Field_timestamp::val_str(String *val_buffer,
String *val_ptr __attribute__((unused)))
String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
{
uint32 temp, temp2;
time_t time_arg;
......@@ -3119,8 +3118,8 @@ String *Field_timestamp::val_str(String *val_buffer,
if (temp == 0L)
{ /* Zero time is "000000" */
val_buffer->set("0000-00-00 00:00:00", 19, &my_charset_bin);
return val_buffer;
val_ptr->set("0000-00-00 00:00:00", 19, &my_charset_bin);
return val_ptr;
}
val_buffer->set_charset(&my_charset_bin); // Safety
time_arg=(time_t) temp;
......
......@@ -98,8 +98,9 @@ class Field
virtual void store_time(TIME *ltime,timestamp_type t_type);
virtual double val_real(void)=0;
virtual longlong val_int(void)=0;
String *val_str(String *str) { return val_str(str, str); }
/* val_str(buf1, buf2) gets two buffers and should use them as follows:
inline String *val_str(String *str) { return val_str(str, str); }
/*
val_str(buf1, buf2) gets two buffers and should use them as follows:
if it needs a temp buffer to convert result to string - use buf1
example Field_tiny::val_str()
if the value exists as a string already - use buf2
......
......@@ -810,7 +810,8 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
}
}
/* disable indexes, making it persistent if requested
/*
disable indexes, making it persistent if requested
SYNOPSIS
disable_indexes(all, save)
all disable all indexes
......@@ -863,11 +864,16 @@ int ha_myisam::enable_indexes()
void ha_myisam::start_bulk_insert(ha_rows rows)
{
THD *thd=current_thd;
ulong size= min(thd->variables.read_buff_size, table->avg_row_length*rows);
mi_extra(file, HA_EXTRA_WRITE_CACHE, (void*)&size);
can_enable_indexes= (file->s->state.key_map ==
set_bits(ulonglong, file->s->base.keys));
if (!(specialflag & SPECIAL_SAFE_MODE))
{
can_enable_indexes= (file->s->state.key_map ==
set_bits(ulonglong, file->s->base.keys));
/*
Only disable old index if the table was empty and we are inserting
a lot of rows.
......@@ -881,18 +887,16 @@ void ha_myisam::start_bulk_insert(ha_rows rows)
if (!file->bulk_insert &&
(!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT))
{
mi_init_bulk_insert(file,
current_thd->variables.bulk_insert_buff_size,
rows);
mi_init_bulk_insert(file, thd->variables.bulk_insert_buff_size, rows);
}
}
}
int ha_myisam::end_bulk_insert()
{
mi_end_bulk_insert(file);
return can_enable_indexes ? enable_indexes() : 0;
int err=mi_extra(file, HA_EXTRA_NO_CACHE, 0);
return err ? err : can_enable_indexes ? enable_indexes() : 0;
}
......
......@@ -264,17 +264,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
thd->proc_info="update";
if (duplic != DUP_ERROR)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
if ((lock_type != TL_WRITE_DELAYED && !(specialflag & SPECIAL_SAFE_MODE)) &&
values_list.elements >= MIN_ROWS_TO_USE_BULK_INSERT)
{
table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
min(thd->variables.read_buff_size,
table->avg_row_length*values_list.elements));
if (lock_type != TL_WRITE_DELAYED)
table->file->start_bulk_insert(values_list.elements);
bulk_insert=1;
}
else
bulk_insert=0;
while ((values= its++))
{
......@@ -352,24 +343,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
else
#endif
{
if (bulk_insert)
if (table->file->end_bulk_insert() && !error)
{
if (table->file->extra(HA_EXTRA_NO_CACHE))
{
if (!error)
{
table->file->print_error(my_errno,MYF(0));
error=1;
}
}
if (table->file->end_bulk_insert())
{
if (!error)
{
table->file->print_error(my_errno,MYF(0));
error=1;
}
}
table->file->print_error(my_errno,MYF(0));
error=1;
}
if (id && values_list.elements != 1)
thd->insert_id(id); // For update log
......@@ -387,7 +364,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table);
if ((info.copied || info.deleted || info.updated) &&
if ((info.copied || info.deleted || info.updated) &&
(error <= 0 || !transactional_table))
{
mysql_update_log.write(thd, thd->query, thd->query_length);
......@@ -1439,8 +1416,6 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
table->next_number_field=table->found_next_number_field;
thd->count_cuted_fields= CHECK_FIELD_WARN; // calc cuted fields
thd->cuted_fields=0;
if (info.handle_duplicates != DUP_REPLACE)
table->file->extra(HA_EXTRA_WRITE_CACHE);
if (info.handle_duplicates == DUP_IGNORE ||
info.handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
......@@ -1497,7 +1472,6 @@ void select_insert::send_error(uint errcode,const char *err)
*/
DBUG_VOID_RETURN;
}
table->file->extra(HA_EXTRA_NO_CACHE);
table->file->end_bulk_insert();
/*
If at least one row has been inserted/modified and will stay in the table
......@@ -1505,7 +1479,7 @@ void select_insert::send_error(uint errcode,const char *err)
error while inserting into a MyISAM table) we must write to the binlog (and
the error code will make the slave stop).
*/
if ((info.copied || info.deleted || info.updated) &&
if ((info.copied || info.deleted || info.updated) &&
!table->file->has_transactions())
{
if (last_insert_id)
......@@ -1518,7 +1492,7 @@ void select_insert::send_error(uint errcode,const char *err)
mysql_bin_log.write(&qinfo);
}
if (!table->tmp_table)
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
}
if (info.copied || info.deleted || info.updated)
query_cache_invalidate3(thd, table, 1);
......@@ -1532,8 +1506,7 @@ bool select_insert::send_eof()
int error,error2;
DBUG_ENTER("select_insert::send_eof");
if (!(error=table->file->extra(HA_EXTRA_NO_CACHE)))
error=table->file->end_bulk_insert();
error=table->file->end_bulk_insert();
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
/*
......@@ -1609,7 +1582,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
/* Don't set timestamp if used */
table->timestamp_default_now= table->timestamp_on_update_now= 0;
table->next_number_field=table->found_next_number_field;
restore_record(table,default_values); // Get empty record
......
......@@ -276,10 +276,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
{
if (use_timestamp)
table->timestamp_default_now= table->timestamp_on_update_now= 0;
table->next_number_field=table->found_next_number_field;
VOID(table->file->extra_opt(HA_EXTRA_WRITE_CACHE,
thd->variables.read_buff_size));
if (handle_duplicates == DUP_IGNORE ||
handle_duplicates == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
......@@ -291,8 +289,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
else
error=read_sep_field(thd,info,table,fields,read_info,*enclosed,
skip_lines);
if (table->file->extra(HA_EXTRA_NO_CACHE))
error=1; /* purecov: inspected */
if (table->file->end_bulk_insert())
error=1; /* purecov: inspected */
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
......
......@@ -2271,6 +2271,13 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
break;
}
}
if (error==HA_ERR_WRONG_COMMAND)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
table->table_name);
error=0;
}
if (!error)
{
mysql_update_log.write(thd, thd->query, thd->query_length);
......@@ -2866,7 +2873,6 @@ copy_data_between_tables(TABLE *from,TABLE *to,
DBUG_RETURN(-1); /* purecov: inspected */
to->file->external_lock(thd,F_WRLCK);
to->file->extra(HA_EXTRA_WRITE_CACHE);
from->file->info(HA_STATUS_VARIABLE);
to->file->start_bulk_insert(from->file->records);
......@@ -2951,17 +2957,15 @@ copy_data_between_tables(TABLE *from,TABLE *to,
end_read_record(&info);
free_io_cache(from);
delete [] copy; // This is never 0
uint tmp_error;
if ((tmp_error=to->file->extra(HA_EXTRA_NO_CACHE)))
if (to->file->end_bulk_insert() && !error)
{
to->file->print_error(tmp_error,MYF(0));
to->file->print_error(my_errno,MYF(0));
error=1;
}
to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
if (to->file->end_bulk_insert())
error=1;
tmp_error = ha_recovery_logging(thd,TRUE);
ha_recovery_logging(thd,TRUE);
/*
Ensure that the new table is saved properly to disk so that we
can do a rename
......
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