summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--myisam/myisamdef.h1
-rw-r--r--sql/ha_myisam.cc2
-rw-r--r--sql/sql_insert.cc10
3 files changed, 11 insertions, 2 deletions
diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h
index ecef9953202..0f43fe7fb61 100644
--- a/myisam/myisamdef.h
+++ b/myisam/myisamdef.h
@@ -417,6 +417,7 @@ typedef struct st_mi_sort_param
#define MI_MIN_SIZE_BULK_INSERT_TREE 16384 /* this is per key */
#define MI_MIN_ROWS_TO_USE_BULK_INSERT 100
#define MI_MIN_ROWS_TO_DISABLE_INDEXES 100
+#define MI_MIN_ROWS_TO_USE_WRITE_CACHE 10
/* The UNIQUE check is done with a hashed long key */
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index ca264f500a6..b9d6cec38aa 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -868,7 +868,7 @@ void ha_myisam::start_bulk_insert(ha_rows rows)
ulong size= min(thd->variables.read_buff_size, table->avg_row_length*rows);
/* don't enable row cache if too few rows */
- if (!rows && rows > 10)
+ if (!rows && rows > MI_MIN_ROWS_TO_USE_WRITE_CACHE)
mi_extra(file, HA_EXTRA_WRITE_CACHE, (void*) &size);
can_enable_indexes= (file->s->state.key_map ==
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 6333beb5cb8..cc2ba29dbd8 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -260,7 +260,15 @@ 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 && values_list.elements != 1);
+ /*
+ let's *try* to start bulk inserts. It won't necessary
+ start them as values_list.elements should be greater than
+ some - handler dependent - threshold.
+ So we call start_bulk_insert to perform nesessary checks on
+ values_list.elements, and - if nothing else - to initialize
+ the code to make the call of end_bulk_insert() below safe.
+ */
+ if (lock_type != TL_WRITE_DELAYED)
table->file->start_bulk_insert(values_list.elements);
while ((values= its++))