summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <ram@mysql.r18.ru>2003-02-19 21:14:50 +0400
committerunknown <ram@mysql.r18.ru>2003-02-19 21:14:50 +0400
commit75d1d877b3585346e9202e78c6126bcea3cded96 (patch)
tree7a33696a40357fbbb5d14a020b3a3919830880c4
parent19f00e0abe39dad5475e466aeeb49347ef10550f (diff)
downloadmariadb-git-75d1d877b3585346e9202e78c6126bcea3cded96.tar.gz
Bug fix: we should set have_rtree value in case of table reopen.
Code cleanup. myisam/mi_open.c: Bug fix: we should set have_rtree value in case of table reopen. myisam/myisamdef.h: code cleanup myisam/rt_index.c: code cleanup
-rw-r--r--myisam/mi_open.c6
-rw-r--r--myisam/myisamdef.h2
-rw-r--r--myisam/rt_index.c10
3 files changed, 11 insertions, 7 deletions
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index 406facec164..1ed3ee78ffb 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -484,6 +484,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
if (mi_open_datafile(&info, share, old_info->dfile))
goto err;
errpos=5;
+ have_rtree= old_info->rtree_recursion_state != NULL;
}
/* alloc and set up private structure parts */
@@ -492,12 +493,15 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
&info.blobs,sizeof(MI_BLOB)*share->base.blobs,
&info.buff,(share->base.max_key_block_length*2+
share->base.max_key_length),
- &info.rtree_recursion_state,have_rtree ? 1024 : 0,
&info.lastkey,share->base.max_key_length*3+1,
&info.filename,strlen(org_name)+1,
+ &info.rtree_recursion_state,have_rtree ? 1024 : 0,
NullS))
goto err;
errpos=6;
+
+ if (!have_rtree)
+ info.rtree_recursion_state= NULL;
strmov(info.filename,org_name);
memcpy(info.blobs,share->blobs,sizeof(MI_BLOB)*share->base.blobs);
diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h
index 7d11c4f1231..25f2969a973 100644
--- a/myisam/myisamdef.h
+++ b/myisam/myisamdef.h
@@ -272,7 +272,7 @@ struct st_myisam_info {
#ifdef THREAD
THR_LOCK_DATA lock;
#endif
- uchar * rtree_recursion_state; /* For RTREE */
+ uchar *rtree_recursion_state; /* For RTREE */
int rtree_recursion_depth;
};
diff --git a/myisam/rt_index.c b/myisam/rt_index.c
index 567d91c74be..ac436245c0f 100644
--- a/myisam/rt_index.c
+++ b/myisam/rt_index.c
@@ -53,7 +53,7 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u
int res;
uchar *page_buf;
int k_len;
- int *saved_key = (int*)(info->rtree_recursion_state + level * sizeof(int));
+ uint *saved_key = (uint*) (info->rtree_recursion_state) + level;
if (!(page_buf = (uchar*)my_alloca((uint)keyinfo->block_length)))
{
@@ -114,7 +114,7 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u
uchar *after_key = rt_PAGE_NEXT_KEY(k, k_len, nod_flag);
info->lastpos = _mi_dpos(info, 0, after_key);
info->lastkey_length = k_len + info->s->base.rec_reflength;
- memcpy(info->lastkey, k, k_len + info->s->base.rec_reflength);
+ memcpy(info->lastkey, k, info->lastkey_length);
info->rtree_recursion_depth = level;
*saved_key = k - page_buf;
@@ -205,7 +205,7 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag)
info->lastpos = _mi_dpos(info, 0, after_key);
info->lastkey_length = k_len + info->s->base.rec_reflength;
- memcpy(info->lastkey, key, k_len + info->s->base.rec_reflength);
+ memcpy(info->lastkey, key, info->lastkey_length);
*(int*)info->int_keypos = key - info->buff;
if (after_key >= info->int_maxpos)
@@ -246,7 +246,7 @@ static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length,
int res;
uchar *page_buf;
uint k_len;
- int *saved_key = (int*)(info->rtree_recursion_state + level*sizeof(int));
+ uint *saved_key = (uint*) (info->rtree_recursion_state) + level;
if (!(page_buf = (uchar*)my_alloca((uint)keyinfo->block_length)))
return -1;
@@ -297,7 +297,7 @@ static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length,
uchar *after_key = rt_PAGE_NEXT_KEY(k, k_len, nod_flag);
info->lastpos = _mi_dpos(info, 0, after_key);
info->lastkey_length = k_len + info->s->base.rec_reflength;
- memcpy(info->lastkey, k, k_len + info->s->base.rec_reflength);
+ memcpy(info->lastkey, k, info->lastkey_length);
info->rtree_recursion_depth = level;
*saved_key = k - page_buf;