summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--myisam/mi_check.c14
-rw-r--r--mysql-test/r/distinct.result8
-rw-r--r--mysql-test/r/fulltext.result4
-rw-r--r--mysql-test/r/insert.result4
-rw-r--r--mysql-test/r/key_diff.result2
-rw-r--r--mysql-test/r/order_by.result6
-rw-r--r--mysql-test/r/select.result4
-rw-r--r--mysql-test/r/show_check.result2
-rw-r--r--sql/ha_myisam.cc17
-rw-r--r--sql/log.cc7
-rw-r--r--sql/sql_insert.cc3
11 files changed, 43 insertions, 28 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index b984f0e6ee6..d1165899bea 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -368,8 +368,8 @@ int chk_key(MI_CHECK *param, register MI_INFO *info)
{
/* Remember old statistics for key */
memcpy((char*) rec_per_key_part,
- (char*) share->state.rec_per_key_part+
- (uint) (rec_per_key_part - param->rec_per_key_part),
+ (char*) (share->state.rec_per_key_part +
+ (uint) (rec_per_key_part - param->rec_per_key_part)),
keyinfo->keysegs*sizeof(*rec_per_key_part));
continue;
}
@@ -1912,8 +1912,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
{
/* Remember old statistics for key */
memcpy((char*) rec_per_key_part,
- (char*) share->state.rec_per_key_part+
- (uint) (rec_per_key_part - param->rec_per_key_part),
+ (char*) (share->state.rec_per_key_part +
+ (uint) (rec_per_key_part - param->rec_per_key_part)),
sort_param.keyinfo->keysegs*sizeof(*rec_per_key_part));
continue;
}
@@ -2272,8 +2272,8 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
{
/* Remember old statistics for key */
memcpy((char*) rec_per_key_part,
- (char*) share->state.rec_per_key_part+
- (uint) (rec_per_key_part - param->rec_per_key_part),
+ (char*) (share->state.rec_per_key_part+
+ (uint) (rec_per_key_part - param->rec_per_key_part)),
sort_param[i].keyinfo->keysegs*sizeof(*rec_per_key_part));
i--;
continue;
@@ -2435,7 +2435,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
got_error=0;
if (&share->state.state != info->state)
- memcpy( &share->state.state, info->state, sizeof(*info->state));
+ memcpy(&share->state.state, info->state, sizeof(*info->state));
err:
got_error|= flush_blocks(param,share->kfile);
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result
index 919478c7265..020d6c6534f 100644
--- a/mysql-test/r/distinct.result
+++ b/mysql-test/r/distinct.result
@@ -173,9 +173,9 @@ INSERT INTO t2 values (1),(2),(3);
INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2');
explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
table type possible_keys key key_len ref rows Extra
-t1 ALL PRIMARY NULL NULL NULL 2 Using temporary
-t2 ref a a 4 t1.a 1 Using index
-t3 ref a a 5 t1.b 1 Using where; Using index
+t3 index a a 5 NULL 6 Using index; Using temporary
+t2 index a a 4 NULL 5 Using index; Distinct
+t1 eq_ref PRIMARY PRIMARY 4 t2.a 1 Using where; Distinct
SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
a
1
@@ -190,7 +190,7 @@ insert into t3 select * from t4;
explain select distinct t1.a from t1,t3 where t1.a=t3.a;
table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 2 Using index; Using temporary
-t3 ref a a 5 t1.a 1 Using where; Using index; Distinct
+t3 ref a a 5 t1.a 10 Using where; Using index; Distinct
select distinct t1.a from t1,t3 where t1.a=t3.a;
a
1
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index fc1e0788087..edf109fcc93 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -135,8 +135,8 @@ id
3
show keys from t2;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
-t2 1 tig 1 ticket A 3 NULL NULL YES BTREE
-t2 1 tix 1 inhalt A 1 1 NULL YES FULLTEXT
+t2 1 tig 1 ticket A NULL NULL NULL YES BTREE
+t2 1 tix 1 inhalt A NULL 1 NULL YES FULLTEXT
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result
index dedde4cc408..69b790ff35b 100644
--- a/mysql-test/r/insert.result
+++ b/mysql-test/r/insert.result
@@ -46,7 +46,7 @@ insert into t1 values ('skr',NULL),('skr',NULL),('test',NULL);
select * from t1;
sid id
skr 1
-skr 1
+skr 2
test 1
insert into t1 values ('rts',NULL),('rts',NULL),('test',NULL);
select * from t1;
@@ -54,7 +54,7 @@ sid id
rts 1
rts 2
skr 1
-skr 1
+skr 2
test 1
test 2
drop table t1;
diff --git a/mysql-test/r/key_diff.result b/mysql-test/r/key_diff.result
index f8671639e2c..4eaccc696f9 100644
--- a/mysql-test/r/key_diff.result
+++ b/mysql-test/r/key_diff.result
@@ -36,7 +36,7 @@ a a a a
explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B;
table type possible_keys key key_len ref rows Extra
t1 ALL a NULL NULL NULL 5
-t2 ref b b 4 t1.a 1 Using where
+t2 ALL b NULL NULL NULL 5 Using where
select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a;
a b a b
A B a a
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index 62a42150eb3..48773bfa916 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -450,9 +450,9 @@ gid sid uid
103853 5 250
EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t1.gid, t3.uid;
table type possible_keys key key_len ref rows Extra
-t3 index PRIMARY PRIMARY 2 NULL 6 Using index; Using temporary; Using filesort
-t2 ref PRIMARY,uid uid 2 t3.uid 1 Using where
-t1 eq_ref PRIMARY PRIMARY 4 t2.gid 1 Using index
+t1 index PRIMARY PRIMARY 4 NULL 6 Using index
+t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
+t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr;
table type possible_keys key key_len ref rows Extra
t1 index PRIMARY PRIMARY 4 NULL 6 Using index
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 51cd67ac832..a921d75f20a 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -3239,8 +3239,8 @@ Field Type Null Key Default Extra Privileges
show keys from t2;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE
-t2 0 fld1 1 fld1 A 0 NULL NULL BTREE
-t2 1 fld3 1 fld3 A 1199 NULL NULL BTREE
+t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE
+t2 1 fld3 1 fld3 A NULL NULL NULL BTREE
drop table t4, t3, t2, t1;
DO 1;
DO benchmark(100,1+1),1,1;
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 70548311e26..2c32d766a38 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -9,7 +9,7 @@ Table Op Msg_type Msg_text
test.t1 check status Table is already up to date
check table t1 changed;
Table Op Msg_type Msg_text
-test.t1 check status Table is already up to date
+test.t1 check status OK
insert into t1 values (5,5,5);
check table t1 changed;
Table Op Msg_type Msg_text
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index fcef1284385..797fe97ea74 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -682,17 +682,24 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows)
mi_extra(file, HA_EXTRA_NO_KEYS, 0);
else
{
- /* Only disable old index if the table was empty */
- if (file->state->records == 0)
+ /*
+ Only disable old index if the table was empty and we are inserting
+ a lot of rows.
+ We should not do this for only a few rows as this is slower and
+ we don't want to update the key statistics based of only a few rows.
+ */
+ if (file->state->records == 0 &&
+ rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT)
mi_disable_non_unique_index(file,rows);
else
{
mi_init_bulk_insert(file,
- current_thd->variables.bulk_insert_buff_size, rows);
- table->bulk_insert= 1;
+ current_thd->variables.bulk_insert_buff_size,
+ rows);
+ table->bulk_insert= 1;
+ }
}
}
- }
enable_activate_all_index=1;
}
else
diff --git a/sql/log.cc b/sql/log.cc
index 21c88cc1616..58f5298dad0 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1239,6 +1239,13 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache)
log_file.pos_in_file)))
goto err;
signal_update();
+ if (my_b_tell(&log_file) >= (my_off_t) max_binlog_size)
+ {
+ pthread_mutex_lock(&LOCK_index);
+ new_file(0); // inside mutex
+ pthread_mutex_unlock(&LOCK_index);
+ }
+
}
VOID(pthread_mutex_unlock(&LOCK_log));
DBUG_RETURN(0);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 4d1b2e59f60..56a89e0bd1c 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -187,7 +187,8 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
thd->proc_info="update";
if (duplic == DUP_IGNORE || duplic == DUP_REPLACE)
table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
- if ((lock_type != TL_WRITE_DELAYED && !(specialflag & SPECIAL_SAFE_MODE)))
+ 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,