diff options
author | unknown <serg@janus.mylan> | 2007-02-21 11:36:23 +0100 |
---|---|---|
committer | unknown <serg@janus.mylan> | 2007-02-21 11:36:23 +0100 |
commit | bd475445612d312689c70dda67f3ca67c0db7876 (patch) | |
tree | 8baa0ee731a4b567ed44cf3227cdb9a926354ef6 /storage/myisam | |
parent | 7fa4131274acc7073dc08d1f97eab08c8bd89e39 (diff) | |
parent | 6a575c2a91ceb29ffdf14a524be02a6b05e321fd (diff) | |
download | mariadb-git-bd475445612d312689c70dda67f3ca67c0db7876.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into janus.mylan:/usr/home/serg/Abk/mysql-5.1
dbug/dbug.c:
Auto merged
include/my_base.h:
Auto merged
include/my_global.h:
Auto merged
sql/event_db_repository.cc:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/ha_ndbcluster.h:
Auto merged
sql/ha_partition.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/item_subselect.cc:
Auto merged
sql/log.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/opt_range.h:
Auto merged
sql/opt_sum.cc:
Auto merged
sql/slave.cc:
Auto merged
sql/slave.h:
Auto merged
sql/sp.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_plugin.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_servers.cc:
Auto merged
sql/sql_servers.h:
Auto merged
sql/table.cc:
Auto merged
sql/table.h:
Auto merged
sql/tztime.cc:
Auto merged
storage/heap/ha_heap.cc:
Auto merged
storage/myisammrg/ha_myisammrg.cc:
Auto merged
support-files/Makefile.am:
Auto merged
sql/opt_range.cc:
manual merge
storage/example/ha_example.cc:
manual merge
storage/federated/ha_federated.cc:
manual merge
storage/myisam/ha_myisam.cc:
manual merge
storage/myisam/mi_rkey.c:
manual merge
Diffstat (limited to 'storage/myisam')
-rw-r--r-- | storage/myisam/ha_myisam.cc | 24 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.h | 10 | ||||
-rw-r--r-- | storage/myisam/mi_check.c | 2 | ||||
-rw-r--r-- | storage/myisam/mi_key.c | 51 | ||||
-rw-r--r-- | storage/myisam/mi_range.c | 42 | ||||
-rw-r--r-- | storage/myisam/mi_rkey.c | 13 | ||||
-rw-r--r-- | storage/myisam/myisamdef.h | 5 | ||||
-rw-r--r-- | storage/myisam/rt_test.c | 2 | ||||
-rw-r--r-- | storage/myisam/sp_test.c | 2 |
9 files changed, 63 insertions, 88 deletions
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 06ec5c4b44e..f38344864b9 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1521,34 +1521,37 @@ int ha_myisam::delete_row(const byte * buf) return mi_delete(file,buf); } -int ha_myisam::index_read(byte * buf, const byte * key, - uint key_len, enum ha_rkey_function find_flag) +int ha_myisam::index_read(byte *buf, const byte *key, ulonglong keypart_map, + enum ha_rkey_function find_flag) { DBUG_ASSERT(inited==INDEX); statistic_increment(table->in_use->status_var.ha_read_key_count, &LOCK_status); - int error=mi_rkey(file,buf,active_index, key, key_len, find_flag); + int error=mi_rkey(file, buf, active_index, key, keypart_map, find_flag); table->status=error ? STATUS_NOT_FOUND: 0; return error; } -int ha_myisam::index_read_idx(byte * buf, uint index, const byte * key, - uint key_len, enum ha_rkey_function find_flag) +int ha_myisam::index_read_idx(byte *buf, uint index, const byte *key, + ulonglong keypart_map, + enum ha_rkey_function find_flag) { statistic_increment(table->in_use->status_var.ha_read_key_count, &LOCK_status); - int error=mi_rkey(file,buf,index, key, key_len, find_flag); + int error=mi_rkey(file, buf, index, key, keypart_map, find_flag); table->status=error ? STATUS_NOT_FOUND: 0; return error; } -int ha_myisam::index_read_last(byte * buf, const byte * key, uint key_len) +int ha_myisam::index_read_last(byte *buf, const byte *key, + ulonglong keypart_map) { DBUG_ENTER("ha_myisam::index_read_last"); DBUG_ASSERT(inited==INDEX); statistic_increment(table->in_use->status_var.ha_read_key_count, &LOCK_status); - int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST); + int error=mi_rkey(file, buf, active_index, key, keypart_map, + HA_READ_PREFIX_LAST); table->status=error ? STATUS_NOT_FOUND: 0; DBUG_RETURN(error); } @@ -1857,8 +1860,9 @@ void ha_myisam::get_auto_increment(ulonglong offset, ulonglong increment, key_copy(key, table->record[0], table->key_info + table->s->next_number_index, table->s->next_number_key_offset); - error= mi_rkey(file,table->record[1],(int) table->s->next_number_index, - key,table->s->next_number_key_offset,HA_READ_PREFIX_LAST); + error= mi_rkey(file, table->record[1], (int) table->s->next_number_index, + key, make_prev_keypart_map(table->s->next_number_keypart), + HA_READ_PREFIX_LAST); if (error) nr= 1; else diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index 882900bd35f..b66a9e5cca4 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -69,11 +69,11 @@ class ha_myisam: public handler int write_row(byte * buf); int update_row(const byte * old_data, byte * new_data); int delete_row(const byte * buf); - int index_read(byte * buf, const byte * key, - uint key_len, enum ha_rkey_function find_flag); - int index_read_idx(byte * buf, uint idx, const byte * key, - uint key_len, enum ha_rkey_function find_flag); - int index_read_last(byte * buf, const byte * key, uint key_len); + int index_read(byte *buf, const byte *key, ulonglong keypart_map, + enum ha_rkey_function find_flag); + int index_read_idx(byte *buf, uint index, const byte *key, + ulonglong keypart_map, enum ha_rkey_function find_flag); + int index_read_last(byte *buf, const byte *key, ulonglong keypart_map); int index_next(byte * buf); int index_prev(byte * buf); int index_first(byte * buf); diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 7bcb8041fe0..5c67404559e 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -532,7 +532,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) mi_extra(info,HA_EXTRA_KEYREAD,0); bzero(info->lastkey,keyinfo->seg->length); if (!mi_rkey(info, info->rec_buff, key, (const byte*) info->lastkey, - keyinfo->seg->length, HA_READ_KEY_EXACT)) + ULL(1), HA_READ_KEY_EXACT)) { /* Don't count this as a real warning, as myisamchk can't correct it */ uint save=param->warning_printed; diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index b203286d544..1b7ba676139 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -206,7 +206,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, uint keynr key number key Store packed key here old Not packed key - k_length Length of 'old' to use + keypart_map bitmap of used keyparts last_used_keyseg out parameter. May be NULL RETURN @@ -216,34 +216,36 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, */ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, - uint k_length, HA_KEYSEG **last_used_keyseg) + ulonglong keypart_map, HA_KEYSEG **last_used_keyseg) { uchar *start_key=key; HA_KEYSEG *keyseg; my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT; DBUG_ENTER("_mi_pack_key"); - for (keyseg=info->s->keyinfo[keynr].seg ; - keyseg->type && (int) k_length > 0; - old+=keyseg->length, keyseg++) + /* "one part" rtree key is 2*SPDIMS part key in MyISAM */ + if (info->s->keyinfo[keynr].key_alg == HA_KEY_ALG_RTREE) + keypart_map= (ULL(1) << (2*SPDIMS)) - 1; + + /* only key prefixes are supported */ + DBUG_ASSERT(((keypart_map+1) & keypart_map) == 0); + + for (keyseg= info->s->keyinfo[keynr].seg ; keyseg->type && keypart_map; + old+= keyseg->length, keyseg++) { - enum ha_base_keytype type=(enum ha_base_keytype) keyseg->type; - uint length=min((uint) keyseg->length,(uint) k_length); + enum ha_base_keytype type= (enum ha_base_keytype) keyseg->type; + uint length= keyseg->length; uint char_length; uchar *pos; CHARSET_INFO *cs=keyseg->charset; + keypart_map>>= 1; if (keyseg->null_bit) { - k_length--; if (!(*key++= (char) 1-*old++)) /* Copy null marker */ { - k_length-=length; if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART)) - { - k_length-=2; /* Skip length */ old+= 2; - } continue; /* Found NULL */ } } @@ -262,7 +264,6 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, while (pos < end && pos[0] == ' ') pos++; } - k_length-=length; length=(uint) (end-pos); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); @@ -274,7 +275,6 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, { /* Length of key-part used with mi_rkey() always 2 */ uint tmp_length=uint2korr(pos); - k_length-= 2+length; pos+=2; set_if_smaller(length,tmp_length); /* Safety */ FIX_LENGTH(cs, pos, length, char_length); @@ -287,11 +287,8 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, else if (keyseg->flag & HA_SWAP_KEY) { /* Numerical column */ pos+=length; - k_length-=length; while (length--) - { *key++ = *--pos; - } continue; } FIX_LENGTH(cs, pos, length, char_length); @@ -299,30 +296,10 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, if (length > char_length) cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' '); key+= length; - k_length-=length; } if (last_used_keyseg) *last_used_keyseg= keyseg; -#ifdef NOT_USED - if (keyseg->type) - { - /* Part-key ; fill with ASCII 0 for easier searching */ - length= (uint) -k_length; /* unused part of last key */ - do - { - if (keyseg->flag & HA_NULL_PART) - length++; - if (keyseg->flag & HA_SPACE_PACK) - length+=2; - else - length+= keyseg->length; - keyseg++; - } while (keyseg->type); - bzero((byte*) key,length); - key+=length; - } -#endif DBUG_RETURN((uint) (key-start_key)); } /* _mi_pack_key */ diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c index 6655f5a7de6..5e5fe3c6b22 100644 --- a/storage/myisam/mi_range.c +++ b/storage/myisam/mi_range.c @@ -21,13 +21,10 @@ #include "myisamdef.h" #include "rt_index.h" -static ha_rows _mi_record_pos(MI_INFO *info,const byte *key,uint key_len, - enum ha_rkey_function search_flag); -static double _mi_search_pos(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key, - uint key_len,uint nextflag,my_off_t pos); -static uint _mi_keynr(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *page, - uchar *keypos,uint *ret_max_key); - +static ha_rows _mi_record_pos(MI_INFO *, const byte *, ulonglong, + enum ha_rkey_function); +static double _mi_search_pos(MI_INFO *,MI_KEYDEF *,uchar *, uint,uint,my_off_t); +static uint _mi_keynr(MI_INFO *info,MI_KEYDEF *,uchar *, uchar *,uint *); /* Estimate how many records there is in a given range @@ -47,9 +44,8 @@ static uint _mi_keynr(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *page, number Estimated number of rows */ - -ha_rows mi_records_in_range(MI_INFO *info, int inx, key_range *min_key, - key_range *max_key) +ha_rows mi_records_in_range(MI_INFO *info, int inx, + key_range *min_key, key_range *max_key) { ha_rows start_pos,end_pos,res; DBUG_ENTER("mi_records_in_range"); @@ -87,7 +83,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, key_range *min_key, } key_buff= info->lastkey+info->s->base.max_key_length; start_key_len= _mi_pack_key(info,inx, key_buff, - (uchar*) min_key->key, min_key->length, + (uchar*) min_key->key, min_key->keypart_map, (HA_KEYSEG**) 0); res= rtree_estimate(info, inx, key_buff, start_key_len, myisam_read_vec[min_key->flag]); @@ -97,14 +93,12 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, key_range *min_key, #endif case HA_KEY_ALG_BTREE: default: - start_pos= (min_key ? - _mi_record_pos(info, min_key->key, min_key->length, - min_key->flag) : - (ha_rows) 0); - end_pos= (max_key ? - _mi_record_pos(info, max_key->key, max_key->length, - max_key->flag) : - info->state->records+ (ha_rows) 1); + start_pos= (min_key ? _mi_record_pos(info, min_key->key, + min_key->keypart_map, min_key->flag) + : (ha_rows) 0); + end_pos= (max_key ? _mi_record_pos(info, max_key->key, + max_key->keypart_map, max_key->flag) + : info->state->records + (ha_rows) 1); res= (end_pos < start_pos ? (ha_rows) 0 : (end_pos == start_pos ? (ha_rows) 1 : end_pos-start_pos)); if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR) @@ -122,21 +116,21 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, key_range *min_key, /* Find relative position (in records) for key in index-tree */ -static ha_rows _mi_record_pos(MI_INFO *info, const byte *key, uint key_len, +static ha_rows _mi_record_pos(MI_INFO *info, const byte *key, + ulonglong keypart_map, enum ha_rkey_function search_flag) { - uint inx=(uint) info->lastinx, nextflag; + uint inx=(uint) info->lastinx, nextflag, key_len; MI_KEYDEF *keyinfo=info->s->keyinfo+inx; uchar *key_buff; double pos; DBUG_ENTER("_mi_record_pos"); DBUG_PRINT("enter",("search_flag: %d",search_flag)); + DBUG_ASSERT(keypart_map); - if (key_len == 0) - key_len=USE_WHOLE_KEY; key_buff=info->lastkey+info->s->base.max_key_length; - key_len=_mi_pack_key(info,inx,key_buff,(uchar*) key,key_len, + key_len=_mi_pack_key(info,inx,key_buff,(uchar*) key, keypart_map, (HA_KEYSEG**) 0); DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg, (uchar*) key_buff,key_len);); diff --git a/storage/myisam/mi_rkey.c b/storage/myisam/mi_rkey.c index 917ba381504..2ff24d565b9 100644 --- a/storage/myisam/mi_rkey.c +++ b/storage/myisam/mi_rkey.c @@ -21,8 +21,8 @@ /* Read a record using key */ /* Ordinary search_flag is 0 ; Give error if no record with key */ -int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len, - enum ha_rkey_function search_flag) +int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, + ulonglong keypart_map, enum ha_rkey_function search_flag) { uchar *key_buff; MYISAM_SHARE *share=info->s; @@ -47,18 +47,17 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len, key is already packed!; This happens when we are using a MERGE TABLE */ key_buff=info->lastkey+info->s->base.max_key_length; - pack_key_length= key_len; - bmove(key_buff,key,key_len); + pack_key_length= keypart_map; + bmove(key_buff, key, pack_key_length); last_used_keyseg= 0; } else { - if (key_len == 0) - key_len=USE_WHOLE_KEY; + DBUG_ASSERT(keypart_map); /* Save the packed key for later use in the second buffer of lastkey. */ key_buff=info->lastkey+info->s->base.max_key_length; pack_key_length=_mi_pack_key(info,(uint) inx, key_buff, (uchar*) key, - key_len, &last_used_keyseg); + keypart_map, &last_used_keyseg); /* Save packed_key_length for use by the MERGE engine. */ info->pack_key_length= pack_key_length; DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE, keyinfo->seg, diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index dceccd10ae2..f1ca1754696 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -604,8 +604,9 @@ extern int _mi_dispose(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos, extern my_off_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo,int level); extern uint _mi_make_key(MI_INFO *info,uint keynr,uchar *key, const byte *record,my_off_t filepos); -extern uint _mi_pack_key(MI_INFO *info,uint keynr,uchar *key,uchar *old, - uint key_length, HA_KEYSEG **last_used_keyseg); +extern uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, + uchar *old, ulonglong keypart_map, + HA_KEYSEG **last_used_keyseg); extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,byte *buf); extern int _mi_read_cache(IO_CACHE *info,byte *buff,my_off_t pos, uint length,int re_read_if_possibly); diff --git a/storage/myisam/rt_test.c b/storage/myisam/rt_test.c index 1126266d2f9..55b52c0c3bf 100644 --- a/storage/myisam/rt_test.c +++ b/storage/myisam/rt_test.c @@ -323,7 +323,7 @@ static int run_test(const char *filename) range.key= record+1; range.length= 1000; /* Big enough */ range.flag= HA_READ_MBR_INTERSECT; - hrows= mi_records_in_range(file,0, &range, (key_range*) 0); + hrows= mi_records_in_range(file, 0, &range, (key_range*) 0); printf(" %ld rows\n", (long) hrows); if (mi_close(file)) goto err; diff --git a/storage/myisam/sp_test.c b/storage/myisam/sp_test.c index c7226589811..96ba05e8a74 100644 --- a/storage/myisam/sp_test.c +++ b/storage/myisam/sp_test.c @@ -255,7 +255,7 @@ int run_test(const char *filename) max_range.key= record+1; max_range.length= 1000; /* Big enough */ max_range.flag= HA_READ_KEY_EXACT; - hrows= mi_records_in_range(file,0, &min_range, &max_range); + hrows= mi_records_in_range(file, 0, &min_range, &max_range); printf(" %ld rows\n", (long) hrows); if (mi_close(file)) goto err; |