summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-01-03 00:04:33 +0200
committerunknown <monty@mashka.mysql.fi>2003-01-03 00:04:33 +0200
commiteebc67f6f8df9e0bdcde7770e383992ff6cad451 (patch)
tree461fafebcf70ffd880e85f8342601eaade292e1b /myisam
parent5265a1656ea58d9534ebadfbd45c662080f89bb0 (diff)
parent62b38d20ddcf4fb0f519e8b647916d7b367e894c (diff)
downloadmariadb-git-eebc67f6f8df9e0bdcde7770e383992ff6cad451.tar.gz
Merge with 4.0.8
BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged acinclude.m4: Auto merged include/my_base.h: Auto merged include/myisam.h: Auto merged include/myisammrg.h: Auto merged libmysql/libmysql.c: Auto merged myisam/mi_check.c: Auto merged myisam/mi_write.c: Auto merged myisam/myisamdef.h: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/case.result: Auto merged mysql-test/r/distinct.result: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/key_diff.result: Auto merged mysql-test/r/multi_update.result: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/select.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/t/multi_update.test: Auto merged mysql-test/t/rpl_log_pos.test: Auto merged mysys/Makefile.am: Auto merged scripts/Makefile.am: Auto merged sql/field.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_myisammrg.cc: Auto merged sql/ha_myisammrg.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_create.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/lex.h: Auto merged sql/log.cc: Auto merged sql/net_serv.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_udf.cc: Auto merged sql/sql_update.cc: Auto merged sql-bench/crash-me.sh: Auto merged sql-bench/server-cfg.sh: Auto merged sql/share/english/errmsg.txt: Auto merged sql/structs.h: Auto merged
Diffstat (limited to 'myisam')
-rw-r--r--myisam/mi_check.c14
-rw-r--r--myisam/mi_extra.c27
-rw-r--r--myisam/mi_write.c47
-rw-r--r--myisam/myisamdef.h3
4 files changed, 48 insertions, 43 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index 34222a5703b..3e6e9d40fab 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/myisam/mi_extra.c b/myisam/mi_extra.c
index d7a3aea516d..8429b22dad4 100644
--- a/myisam/mi_extra.c
+++ b/myisam/mi_extra.c
@@ -358,33 +358,6 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
case HA_EXTRA_QUICK:
info->quick_mode=1;
break;
- case HA_EXTRA_BULK_INSERT_BEGIN:
- error=_mi_init_bulk_insert(info, (extra_arg ? *(ulong*) extra_arg :
- myisam_bulk_insert_tree_size));
- break;
- case HA_EXTRA_BULK_INSERT_FLUSH:
- if (info->bulk_insert)
- {
- uint index_to_flush= *(uint*) extra_arg;
- if (is_tree_inited(&info->bulk_insert[index_to_flush]))
- reset_tree(&info->bulk_insert[index_to_flush]);
- }
- break;
- case HA_EXTRA_BULK_INSERT_END:
- if (info->bulk_insert)
- {
- uint i;
- for (i=0 ; i < share->base.keys ; i++)
- {
- if (is_tree_inited(& info->bulk_insert[i]))
- {
- delete_tree(& info->bulk_insert[i]);
- }
- }
- my_free((void *)info->bulk_insert, MYF(0));
- info->bulk_insert=0;
- }
- break;
case HA_EXTRA_NO_ROWS:
if (!share->state.header.uniques)
info->opt_flag|= OPT_NO_ROWS;
diff --git a/myisam/mi_write.c b/myisam/mi_write.c
index 58f9ebdb735..81941e41010 100644
--- a/myisam/mi_write.c
+++ b/myisam/mi_write.c
@@ -804,26 +804,27 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param)
}
-int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size)
+int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows)
{
MYISAM_SHARE *share=info->s;
MI_KEYDEF *key=share->keyinfo;
bulk_insert_param *params;
- uint i, num_keys;
+ uint i, num_keys, total_keylength;
ulonglong key_map=0;
DBUG_ENTER("_mi_init_bulk_insert");
DBUG_PRINT("enter",("cache_size: %lu", cache_size));
- if (info->bulk_insert)
+ if (info->bulk_insert || (rows && rows < MI_MIN_ROWS_TO_USE_BULK_INSERT))
DBUG_RETURN(0);
- for (i=num_keys=0 ; i < share->base.keys ; i++)
+ for (i=total_keylength=num_keys=0 ; i < share->base.keys ; i++)
{
if (!(key[i].flag & HA_NOSAME) && share->base.auto_key != i+1
&& test(share->state.key_map & ((ulonglong) 1 << i)))
{
num_keys++;
key_map |=((ulonglong) 1 << i);
+ total_keylength+=key[i].maxlength+TREE_ELEMENT_EXTRA_SIZE;
}
}
@@ -831,6 +832,11 @@ int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size)
num_keys * MI_MIN_SIZE_BULK_INSERT_TREE > cache_size)
DBUG_RETURN(0);
+ if (rows && rows*total_keylength < cache_size)
+ cache_size=rows;
+ else
+ cache_size/=total_keylength*16;
+
info->bulk_insert=(TREE *)
my_malloc((sizeof(TREE)*share->base.keys+
sizeof(bulk_insert_param)*num_keys),MYF(0));
@@ -839,7 +845,7 @@ int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size)
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
params=(bulk_insert_param *)(info->bulk_insert+share->base.keys);
- for (i=0 ; i < share->base.keys ; i++,key++)
+ for (i=0 ; i < share->base.keys ; i++)
{
if (test(key_map & ((ulonglong) 1 << i)))
{
@@ -847,8 +853,8 @@ int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size)
params->keynr=i;
/* Only allocate a 16'th of the buffer at a time */
init_tree(&info->bulk_insert[i],
- cache_size / num_keys / 16 + 10,
- cache_size / num_keys, 0,
+ cache_size * key[i].maxlength,
+ cache_size * key[i].maxlength, 0,
(qsort_cmp2)keys_compare, 0,
(tree_element_free) keys_free, (void *)params++);
}
@@ -858,3 +864,30 @@ int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size)
DBUG_RETURN(0);
}
+
+void mi_flush_bulk_insert(MI_INFO *info, uint inx)
+{
+ if (info->bulk_insert)
+ {
+ if (is_tree_inited(&info->bulk_insert[inx]))
+ reset_tree(&info->bulk_insert[inx]);
+ }
+}
+
+void mi_end_bulk_insert(MI_INFO *info)
+{
+ if (info->bulk_insert)
+ {
+ uint i;
+ for (i=0 ; i < info->s->base.keys ; i++)
+ {
+ if (is_tree_inited(& info->bulk_insert[i]))
+ {
+ delete_tree(& info->bulk_insert[i]);
+ }
+ }
+ my_free((void *)info->bulk_insert, MYF(0));
+ info->bulk_insert=0;
+ }
+}
+
diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h
index 90aaff46919..e5cac1f090e 100644
--- a/myisam/myisamdef.h
+++ b/myisam/myisamdef.h
@@ -400,6 +400,7 @@ typedef struct st_mi_sort_param
#define MI_MIN_KEYBLOCK_LENGTH 50 /* When to split delete blocks */
#define MI_MIN_SIZE_BULK_INSERT_TREE 16384 /* this is per key */
+#define MI_MIN_ROWS_TO_USE_BULK_INSERT 100
/* The UNIQUE check is done with a hashed long key */
@@ -683,8 +684,6 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup);
int mi_open_keyfile(MYISAM_SHARE *share);
void mi_setup_functions(register MYISAM_SHARE *share);
-int _mi_init_bulk_insert(MI_INFO *info, ulong cache_size);
-
/* Functions needed by mi_check */
volatile bool *killed_ptr(MI_CHECK *param);
void mi_check_print_error _VARARGS((MI_CHECK *param, const char *fmt,...));