diff options
author | Michael Widenius <monty@askmonty.org> | 2011-01-10 23:22:40 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-01-10 23:22:40 +0200 |
commit | 505c663a1e19af4c8ee726b305691414ab5fc999 (patch) | |
tree | d85b2a5bbaaf9829612b2cbb8f34537bff8f9c1b /storage/maria | |
parent | c0fc6d42ace74938c0d39907ddf8acfbeb4d247e (diff) | |
download | mariadb-git-505c663a1e19af4c8ee726b305691414ab5fc999.tar.gz |
- Fixed that Aria works with HANDLER commands
- Added test case for Aria
- Tested HANDLER with HEAP (changes to HEAP code will be pushed in 5.3)
- Moved all HANDLER test to suite/handler.
mysql-test/Makefile.am:
Added suite/handler
mysql-test/mysql-test-run.pl:
Added suite/handler
mysql-test/r/lock_multi.result:
Remove test that is already in handler test suite
mysql-test/suite/handler/aria.result:
Test for HANDLER with Aria storage engine
mysql-test/suite/handler/aria.test:
Test for HANDLER with Aria storage engine
mysql-test/suite/handler/handler.inc:
Extended the general handler test
Moved interface testing to 'interface.test'
mysql-test/suite/handler/init.inc:
Common init for handler tests.
mysql-test/suite/handler/innodb.result:
New results
mysql-test/suite/handler/innodb.test:
Update to use new include files
mysql-test/suite/handler/interface.result:
Test of HANDLER interface (not storage engine dependent parts)
mysql-test/suite/handler/interface.test:
Test of HANDLER interface (not storage engine dependent parts)
mysql-test/suite/handler/myisam.result:
New results
mysql-test/suite/handler/myisam.test:
Update to use new include files
mysql-test/t/lock_multi.test:
Remove test that is already in handler test suite
mysys/tree.c:
Added missing handling of read previous (showed up in HEAP testing)
sql/handler.cc:
Don't marka 'HA_ERR_RECORD_CHANGED' as fatal (can be used with HANDLER READ, especially with MEMORY ENGINE)
sql/handler.h:
Added prototype for can_continue_handler_scan()
sql/sql_handler.cc:
Re-initialize search if we switch from key to table search.
Check if handler can continue searching between calls (via can_continue_handler_scan())
Don't write common not fatal errors to log
storage/maria/ma_extra.c:
Don't set index 0 as default. This forces call to ma_check_index() to set up index variables.
storage/maria/ma_ft_boolean_search.c:
Ensure that info->last_key.keyinfo is set
storage/maria/ma_open.c:
Don't set index 0 as default. This forces call to ma_check_index() to set up index variables.
storage/maria/ma_rkey.c:
Trivial optimization
storage/maria/ma_rnext.c:
Added missing code from mi_rnext.c to ensure that handler next/prev works.
storage/maria/ma_rsame.c:
Simple optimizations
storage/maria/ma_search.c:
Initialize info->last_key once and for all when we change keys.
storage/maria/ma_unique.c:
Ensure that info->last_key.keyinfo is up to date.
Diffstat (limited to 'storage/maria')
-rw-r--r-- | storage/maria/ma_extra.c | 4 | ||||
-rw-r--r-- | storage/maria/ma_ft_boolean_search.c | 4 | ||||
-rw-r--r-- | storage/maria/ma_open.c | 2 | ||||
-rw-r--r-- | storage/maria/ma_rkey.c | 2 | ||||
-rw-r--r-- | storage/maria/ma_rnext.c | 17 | ||||
-rw-r--r-- | storage/maria/ma_rsame.c | 5 | ||||
-rw-r--r-- | storage/maria/ma_search.c | 9 | ||||
-rw-r--r-- | storage/maria/ma_unique.c | 1 |
8 files changed, 29 insertions, 15 deletions
diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c index 81f3789523f..e436a51248a 100644 --- a/storage/maria/ma_extra.c +++ b/storage/maria/ma_extra.c @@ -50,7 +50,7 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, switch (function) { case HA_EXTRA_RESET_STATE: /* Reset state (don't free buffers) */ - info->lastinx= 0; /* Use first index as def */ + info->lastinx= ~0; /* Detect index changes */ info->last_search_keypage= info->cur_row.lastpos= HA_OFFSET_ERROR; info->page_changed= 1; /* Next/prev gives first/last */ @@ -545,7 +545,7 @@ int maria_reset(MARIA_HA *info) #endif info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS); info->quick_mode= 0; - info->lastinx= 0; /* Use first index as def */ + info->lastinx= ~0; /* detect index changes */ info->last_search_keypage= info->cur_row.lastpos= HA_OFFSET_ERROR; info->page_changed= 1; info->update= ((info->update & HA_STATE_CHANGED) | HA_STATE_NEXT_FOUND | diff --git a/storage/maria/ma_ft_boolean_search.c b/storage/maria/ma_ft_boolean_search.c index 6cd23558784..db471d2879c 100644 --- a/storage/maria/ma_ft_boolean_search.c +++ b/storage/maria/ma_ft_boolean_search.c @@ -356,7 +356,7 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) { ftbw->key_root=info->s->state.key_root[ftb->keynr]; ftbw->keyinfo=info->s->keyinfo+ftb->keynr; - key.keyinfo= ftbw->keyinfo; + info->last_key.keyinfo= key.keyinfo= ftbw->keyinfo; key.data= ftbw->word; key.data_length= ftbw->len; key.ref_length= 0; @@ -380,7 +380,7 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) max_docid); } - key.keyinfo= ftbw->keyinfo; + info->last_key.keyinfo= key.keyinfo= ftbw->keyinfo; key.data= lastkey_buf; key.data_length= USE_WHOLE_KEY; key.ref_length= 0; diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 63e1801a39a..0890ff7e000 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -130,6 +130,8 @@ static MARIA_HA *maria_clone_internal(MARIA_SHARE *share, const char *name, info.s=share; info.cur_row.lastpos= HA_OFFSET_ERROR; + /* Impossible first index to force initialization in _ma_check_index() */ + info.lastinx= ~0; info.update= (short) (HA_STATE_NEXT_FOUND+HA_STATE_PREV_FOUND); info.opt_flag=READ_CHECK_USED; info.this_unique= (ulong) info.dfile.file; /* Uniq number in process */ diff --git a/storage/maria/ma_rkey.c b/storage/maria/ma_rkey.c index daf1fd5a60c..85b3b463f49 100644 --- a/storage/maria/ma_rkey.c +++ b/storage/maria/ma_rkey.c @@ -43,7 +43,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data, info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); info->last_key_func= search_flag; - keyinfo= share->keyinfo + inx; + keyinfo= info->last_key.keyinfo; key_buff= info->lastkey_buff+info->s->base.max_key_length; diff --git a/storage/maria/ma_rnext.c b/storage/maria/ma_rnext.c index be960eccfe0..c49bbb19e83 100644 --- a/storage/maria/ma_rnext.c +++ b/storage/maria/ma_rnext.c @@ -30,6 +30,7 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx) uint flag; MARIA_SHARE *share= info->s; MARIA_KEYDEF *keyinfo; + uint update_mask= HA_STATE_NEXT_FOUND; DBUG_ENTER("maria_rnext"); if ((inx = _ma_check_index(info,inx)) < 0) @@ -61,6 +62,20 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx) error= _ma_search_first(info, keyinfo, share->state.key_root[inx]); break; } + /* + "search first" failed. This means we have no pivot for + "search next", or in other words MI_INFO::lastkey is + likely uninitialized. + + Normally SQL layer would never request "search next" if + "search first" failed. But HANDLER may do anything. + + As mi_rnext() without preceeding mi_rkey()/mi_rfirst() + equals to mi_rfirst(), we must restore original state + as if failing mi_rfirst() was not called. + */ + if (error) + update_mask|= HA_STATE_PREV_FOUND; } else { @@ -104,7 +119,7 @@ int maria_rnext(MARIA_HA *info, uchar *buf, int inx) /* Don't clear if database-changed */ info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); - info->update|= HA_STATE_NEXT_FOUND; + info->update|= update_mask; if (error) { diff --git a/storage/maria/ma_rsame.c b/storage/maria/ma_rsame.c index 4bdbfd526ba..4bd218a01df 100644 --- a/storage/maria/ma_rsame.c +++ b/storage/maria/ma_rsame.c @@ -36,7 +36,7 @@ int maria_rsame(MARIA_HA *info, uchar *record, int inx) { DBUG_ENTER("maria_rsame"); - if (inx != -1 && ! maria_is_key_active(info->s->state.key_map, inx)) + if (inx >= 0 && !_ma_check_index(info, inx)) { DBUG_PRINT("error", ("wrong index usage")); DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); @@ -55,8 +55,7 @@ int maria_rsame(MARIA_HA *info, uchar *record, int inx) if (inx >= 0) { - MARIA_KEYDEF *keyinfo= info->s->keyinfo + inx; - info->lastinx= inx; + MARIA_KEYDEF *keyinfo= info->last_key.keyinfo; (*keyinfo->make_key)(info, &info->last_key, (uint) inx, info->lastkey_buff, record, info->cur_row.lastpos, diff --git a/storage/maria/ma_search.c b/storage/maria/ma_search.c index e1683dad34a..76e31fc9553 100644 --- a/storage/maria/ma_search.c +++ b/storage/maria/ma_search.c @@ -38,6 +38,8 @@ int _ma_check_index(MARIA_HA *info, int inx) if (info->lastinx != inx) /* Index changed */ { info->lastinx = inx; + info->last_key.keyinfo= info->s->keyinfo + inx; + info->last_key.flag= 0; info->page_changed=1; info->update= ((info->update & (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED)) | HA_STATE_NEXT_FOUND | HA_STATE_PREV_FOUND); @@ -180,7 +182,6 @@ static int _ma_search_no_save(register MARIA_HA *info, MARIA_KEY *key, } } - info->last_key.keyinfo= keyinfo; if ((nextflag & (SEARCH_SMALLER | SEARCH_LAST)) && flag != 0) { uint not_used[2]; @@ -1696,7 +1697,7 @@ int _ma_search_next(register MARIA_HA *info, MARIA_KEY *key, } tmp_key.data= lastkey; - info->last_key.keyinfo= tmp_key.keyinfo= keyinfo; + tmp_key.keyinfo= keyinfo; if (nextflag & SEARCH_BIGGER) /* Next key */ { @@ -1778,8 +1779,6 @@ int _ma_search_first(MARIA_HA *info, MARIA_KEYDEF *keyinfo, first_pos= page.buff + share->keypage_header + page.node; } while ((pos= _ma_kpos(page.node, first_pos)) != HA_OFFSET_ERROR); - info->last_key.keyinfo= keyinfo; - if (!(*keyinfo->get_key)(&info->last_key, page.flag, page.node, &first_pos)) DBUG_RETURN(-1); /* Crashed */ @@ -1830,8 +1829,6 @@ int _ma_search_last(MARIA_HA *info, MARIA_KEYDEF *keyinfo, end_of_page= page.buff + page.size; } while ((pos= _ma_kpos(page.node, end_of_page)) != HA_OFFSET_ERROR); - info->last_key.keyinfo= keyinfo; - if (!_ma_get_last_key(&info->last_key, &page, end_of_page)) DBUG_RETURN(-1); info->cur_row.lastpos= _ma_row_pos_from_key(&info->last_key); diff --git a/storage/maria/ma_unique.c b/storage/maria/ma_unique.c index a90578c2162..6090c624f36 100644 --- a/storage/maria/ma_unique.c +++ b/storage/maria/ma_unique.c @@ -43,6 +43,7 @@ my_bool _ma_check_unique(MARIA_HA *info, MARIA_UNIQUEDEF *def, uchar *record, /* The above changed info->lastkey_buff2. Inform maria_rnext_same(). */ info->update&= ~HA_STATE_RNEXT_SAME; + info->last_key.keyinfo= keyinfo; DBUG_ASSERT(key.data_length == MARIA_UNIQUE_HASH_LENGTH); if (_ma_search(info, &key, SEARCH_FIND, info->s->state.key_root[def->key])) |