diff options
author | unknown <monty@hundin.mysql.fi> | 2002-01-16 01:08:29 +0200 |
---|---|---|
committer | unknown <monty@hundin.mysql.fi> | 2002-01-16 01:08:29 +0200 |
commit | 40c146f6a22e7397d9e5d1880b29f2c88fb39eda (patch) | |
tree | 04255ad8dbcf3e3e29807adb609c4e3e4da328eb /myisam | |
parent | 62f9d3c201f8e8673041a365378f953107dd783e (diff) | |
parent | f015cbdc7e3427cf0f77012c4ce89f3cf8d5dd5f (diff) | |
download | mariadb-git-40c146f6a22e7397d9e5d1880b29f2c88fb39eda.tar.gz |
merge
sql/mysqld.cc:
Auto merged
sql/sql_delete.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/mi_static.c | 2 | ||||
-rw-r--r-- | myisam/mi_write.c | 86 |
2 files changed, 47 insertions, 41 deletions
diff --git a/myisam/mi_static.c b/myisam/mi_static.c index 55efb727309..86d7fc38f25 100644 --- a/myisam/mi_static.c +++ b/myisam/mi_static.c @@ -15,7 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - Static variables for pisam library. All definied here for easy making of + Static variables for MyISAM library. All definied here for easy making of a shared library */ diff --git a/myisam/mi_write.c b/myisam/mi_write.c index 8f4db221a9c..1f43a5defcc 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -25,7 +25,8 @@ /* Functions declared in this file */ -static int w_search(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key, +static int w_search(MI_INFO *info,MI_KEYDEF *keyinfo, + uint comp_flag, uchar *key, uint key_length, my_off_t pos, uchar *father_buff, uchar *father_keypos, my_off_t father_page, my_bool insert_last); @@ -245,10 +246,23 @@ int _mi_ck_write_btree(register MI_INFO *info, uint keynr, uchar *key, uint key_length) { int error; + uint comp_flag; + MI_KEYDEF *keyinfo=info->s->keyinfo+keynr; DBUG_ENTER("_mi_ck_write_btree"); + if (keyinfo->flag & HA_SORT_ALLOWS_SAME) + comp_flag=SEARCH_BIGGER; /* Put after same key */ + else if (keyinfo->flag & HA_NOSAME) + { + comp_flag=SEARCH_FIND | SEARCH_UPDATE; /* No dupplicates */ + if (keyinfo->flag & HA_NULL_ARE_EQUAL) + comp_flag|= SEARCH_NULL_ARE_EQUAL; + } + else + comp_flag=SEARCH_SAME; /* Keys in rec-pos order */ + if (info->s->state.key_root[keynr] == HA_OFFSET_ERROR || - (error=w_search(info,info->s->keyinfo+keynr,key, key_length, + (error=w_search(info, keyinfo, comp_flag, key, key_length, info->s->state.key_root[keynr], (uchar *) 0, (uchar*) 0, (my_off_t) 0, 1)) > 0) error=_mi_enlarge_root(info,keynr,key); @@ -291,13 +305,12 @@ int _mi_enlarge_root(register MI_INFO *info, uint keynr, uchar *key) */ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, - uchar *key, uint key_length, my_off_t page, - uchar *father_buff, - uchar *father_keypos, my_off_t father_page, - my_bool insert_last) + uint comp_flag, uchar *key, uint key_length, my_off_t page, + uchar *father_buff, uchar *father_keypos, + my_off_t father_page, my_bool insert_last) { int error,flag; - uint comp_flag,nod_flag, search_key_length; + uint nod_flag, search_key_length; uchar *temp_buff,*keypos; uchar keybuff[MI_MAX_KEY_BUFF]; my_bool was_last_key; @@ -305,17 +318,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, DBUG_ENTER("w_search"); DBUG_PRINT("enter",("page: %ld",page)); - search_key_length=USE_WHOLE_KEY; - if (keyinfo->flag & HA_SORT_ALLOWS_SAME) - comp_flag=SEARCH_BIGGER; /* Put after same key */ - else if (keyinfo->flag & HA_NOSAME) - { - comp_flag=SEARCH_FIND | SEARCH_UPDATE; /* No dupplicates */ - search_key_length= key_length; - } - else - comp_flag=SEARCH_SAME; /* Keys in rec-pos order */ - + search_key_length= (comp_flag & SEARCH_FIND) ? key_length : USE_WHOLE_KEY; if (!(temp_buff= (uchar*) my_alloca((uint) keyinfo->block_length+ MI_MAX_KEY_BUFF*2))) DBUG_RETURN(-1); @@ -344,7 +347,7 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, insert_last=0; next_page=_mi_kpos(nod_flag,keypos); if (next_page == HA_OFFSET_ERROR || - (error=w_search(info,keyinfo,key,key_length,next_page, + (error=w_search(info, keyinfo, comp_flag, key, key_length, next_page, temp_buff, keypos, page, insert_last)) >0) { error=_mi_insert(info,keyinfo,key,temp_buff,keypos,keybuff,father_buff, @@ -759,41 +762,44 @@ static int keys_compare(bulk_insert_param *param, uchar *key1, uchar *key2) { uint not_used; return _mi_key_cmp(param->info->s->keyinfo[param->keynr].seg, - key1, key2, USE_WHOLE_KEY, SEARCH_SAME, ¬_used); + key1, key2, USE_WHOLE_KEY, SEARCH_SAME, + ¬_used); } static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) { - /* probably I can use info->lastkey here, but I'm not sure, - and to be safe I'd better use local lastkey. - Monty, feel free to comment on this */ + /* + Probably I can use info->lastkey here, but I'm not sure, + and to be safe I'd better use local lastkey. + */ uchar lastkey[MI_MAX_KEY_BUFF]; uint keylen; MI_KEYDEF *keyinfo; switch (mode) { - case free_init: - if (param->info->s->concurrent_insert) - { - rw_wrlock(¶m->info->s->key_root_lock[param->keynr]); - param->info->s->keyinfo[param->keynr].version++; - } - return 0; - case free_free: - keyinfo=param->info->s->keyinfo+param->keynr; - keylen=_mi_keylength(keyinfo, key); - memcpy(lastkey, key, keylen); - return _mi_ck_write_btree(param->info,param->keynr,lastkey, - keylen - param->info->s->rec_reflength); - case free_end: - if (param->info->s->concurrent_insert) - rw_unlock(¶m->info->s->key_root_lock[param->keynr]); - return 0; + case free_init: + if (param->info->s->concurrent_insert) + { + rw_wrlock(¶m->info->s->key_root_lock[param->keynr]); + param->info->s->keyinfo[param->keynr].version++; + } + return 0; + case free_free: + keyinfo=param->info->s->keyinfo+param->keynr; + keylen=_mi_keylength(keyinfo, key); + memcpy(lastkey, key, keylen); + return _mi_ck_write_btree(param->info,param->keynr,lastkey, + keylen - param->info->s->rec_reflength); + case free_end: + if (param->info->s->concurrent_insert) + rw_unlock(¶m->info->s->key_root_lock[param->keynr]); + return 0; } return -1; } + int _mi_init_bulk_insert(MI_INFO *info) { MYISAM_SHARE *share=info->s; |