summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authorunknown <serg@sergbook.mylan>2003-11-08 16:00:00 +0100
committerunknown <serg@sergbook.mylan>2003-11-08 16:00:00 +0100
commit9dbaca650210a6eaac3e89cc0e219a2398fb58f5 (patch)
tree8635191bab0519aa253e02dc737794b81efbc186 /myisam
parent21b624f046c4efbb0fd1f25135cc6663ab3ded4e (diff)
parentb036800ee04fb4c15f47305ba83a55d0246921f6 (diff)
downloadmariadb-git-9dbaca650210a6eaac3e89cc0e219a2398fb58f5.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into sergbook.mylan:/usr/home/serg/Abk/mysql-4.1 mysql-test/r/fulltext.result: Auto merged mysql-test/t/fulltext.test: Auto merged
Diffstat (limited to 'myisam')
-rw-r--r--myisam/ft_boolean_search.c2
-rw-r--r--myisam/mi_extra.c20
-rw-r--r--myisam/mi_locking.c20
-rw-r--r--myisam/mi_open.c1
-rw-r--r--myisam/mi_rnext_same.c15
-rw-r--r--myisam/myisamchk.c4
-rw-r--r--myisam/myisamdef.h1
-rw-r--r--myisam/rt_index.c214
-rw-r--r--myisam/rt_split.c3
9 files changed, 159 insertions, 121 deletions
diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c
index 95d0149c67d..f3b593f7341 100644
--- a/myisam/ft_boolean_search.c
+++ b/myisam/ft_boolean_search.c
@@ -362,7 +362,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query,
Hack: instead of init_queue, we'll use reinit queue to be able
to alloc queue with alloc_root()
*/
- res=ftb->queue.max_elements=1+query_len/(ft_min_word_len+1);
+ res=ftb->queue.max_elements=1+query_len/(min(ft_min_word_len,2)+1);
ftb->queue.root=(byte **)alloc_root(&ftb->mem_root, (res+1)*sizeof(void*));
reinit_queue(& ftb->queue, res, 0, 0,
(int (*)(void*,byte*,byte*))FTB_WORD_cmp, 0);
diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c
index 1d57e0c0e18..8c7515550e7 100644
--- a/myisam/mi_extra.c
+++ b/myisam/mi_extra.c
@@ -336,22 +336,10 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
if (share->not_flushed)
{
share->not_flushed=0;
-#if defined(__WIN__)
- if (_commit(share->kfile))
- error=errno;
- if (_commit(info->dfile))
- error=errno;
-#elif defined(HAVE_FDATASYNC)
- if (fdatasync(share->kfile))
- error=errno;
- if (fdatasync(share->dfile))
- error=errno;
-#elif defined(HAVE_FSYNC)
- if ( fsync(share->kfile))
- error=errno;
- if (fsync(share->dfile))
- error=errno;
-#endif
+ if (my_sync(share->kfile, MYF(0)))
+ error= my_errno;
+ if (my_sync(info->dfile, MYF(0)))
+ error= my_errno;
if (error)
{
share->changed=1;
diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c
index 785979235ce..6f996ab5abd 100644
--- a/myisam/mi_locking.c
+++ b/myisam/mi_locking.c
@@ -98,22 +98,10 @@ int mi_lock_database(MI_INFO *info, int lock_type)
share->changed=0;
if (myisam_flush)
{
-#if defined(__WIN__)
- if (_commit(share->kfile))
- error=errno;
- if (_commit(info->dfile))
- error=errno;
-#elif defined(HAVE_FDATASYNC)
- if (fdatasync(share->kfile))
- error=errno;
- if (fdatasync(share->dfile))
- error=errno;
-#elif defined(HAVE_FSYNC)
- if (fsync(share->kfile))
- error=errno;
- if (fsync(share->dfile))
- error=errno;
-#endif
+ if (my_sync(share->kfile, MYF(0)))
+ error= my_errno;
+ if (my_sync(info->dfile, MYF(0)))
+ error= my_errno;
}
else
share->not_flushed=1;
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index 744bb9bb3b6..0b4e8681bdd 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -508,6 +508,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
&info.buff,(share->base.max_key_block_length*2+
share->base.max_key_length),
&info.lastkey,share->base.max_key_length*3+1,
+ &info.first_mbr_key, share->base.max_key_length,
&info.filename,strlen(org_name)+1,
&info.rtree_recursion_state,have_rtree ? 1024 : 0,
NullS))
diff --git a/myisam/mi_rnext_same.c b/myisam/mi_rnext_same.c
index 200e715bddc..19190a60246 100644
--- a/myisam/mi_rnext_same.c
+++ b/myisam/mi_rnext_same.c
@@ -41,17 +41,20 @@ int mi_rnext_same(MI_INFO *info, byte *buf)
if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]);
- switch(keyinfo->key_alg)
+ switch (keyinfo->key_alg)
{
case HA_KEY_ALG_RTREE:
- if((error=rtree_find_next(info,inx,myisam_read_vec[info->last_key_func])))
- {
- /* FIXME: What to do?*/
- }
+ if ((error=rtree_find_next(info,inx,
+ myisam_read_vec[info->last_key_func])))
+ {
+ error=1;
+ my_errno=HA_ERR_END_OF_FILE;
+ info->lastpos= HA_OFFSET_ERROR;
+ break;
+ }
break;
case HA_KEY_ALG_BTREE:
default:
-
memcpy(info->lastkey2,info->lastkey,info->last_rkey_length);
for (;;)
{
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index 5a3768c9932..59cc26b198b 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -411,6 +411,8 @@ static void usage(void)
-q, --quick Faster repair by not modifying the data file.\n\
One can give a second '-q' to force myisamchk to\n\
modify the original datafile in case of duplicate keys.\n\
+ NOTE: Tables where the data file is currupted can't be\n\
+ fixed with this option.\n\
-u, --unpack Unpack file packed with myisampack.\n\
");
@@ -1109,7 +1111,7 @@ end2:
filename));
if (param->testflag & T_REP_ANY)
VOID(fprintf(stderr,
- "Try fixing it by using the --safe-recover (-o) or the --force (-f) option\n"));
+ "Try fixing it by using the --safe-recover (-o), the --force (-f) option or by not using the --quick (-q) flag\n"));
}
else if (!(param->error_printed & 2) &&
!(param->testflag & T_FORCE_CREATE))
diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h
index 3b1dd1fbf92..c23959d995c 100644
--- a/myisam/myisamdef.h
+++ b/myisam/myisamdef.h
@@ -229,6 +229,7 @@ struct st_myisam_info {
char *filename; /* parameter to open filename */
uchar *buff, /* Temp area for key */
*lastkey,*lastkey2; /* Last used search key */
+ uchar *first_mbr_key; /* Searhed spatial key */
byte *rec_buff; /* Tempbuff for recordpack */
uchar *int_keypos, /* Save position for next/previous */
*int_maxpos; /* -""- */
diff --git a/myisam/rt_index.c b/myisam/rt_index.c
index 8b877d2e65c..30146b9fd67 100644
--- a/myisam/rt_index.c
+++ b/myisam/rt_index.c
@@ -36,16 +36,21 @@ typedef struct st_page_list
stPageLevel *pages;
} stPageList;
+
/*
-Find next key in r-tree according to search_flag recursively
-Used in rtree_find_first() and rtree_find_next()
-Result values:
--1 - error
- 0 - found
- 1 - not found
+ Find next key in r-tree according to search_flag recursively
+
+ NOTES
+ Used in rtree_find_first() and rtree_find_next()
+
+ RETURN
+ -1 Error
+ 0 Found
+ 1 Not found
*/
-static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, uint nod_cmp_flag,
- my_off_t page, int level)
+
+static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag,
+ uint nod_cmp_flag, my_off_t page, int level)
{
uchar *k;
uchar *last;
@@ -81,7 +86,7 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u
if (nod_flag)
{
/* this is an internal node in the tree */
- if (!(res = rtree_key_cmp(keyinfo->seg, info->lastkey2, k,
+ if (!(res = rtree_key_cmp(keyinfo->seg, info->first_mbr_key, k,
info->last_rkey_length, nod_cmp_flag)))
{
switch ((res = rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag,
@@ -102,7 +107,7 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, u
else
{
/* this is a leaf */
- if (!rtree_key_cmp(keyinfo->seg, info->lastkey2, k,
+ if (!rtree_key_cmp(keyinfo->seg, info->first_mbr_key, k,
info->last_rkey_length, search_flag))
{
uchar *after_key = rt_PAGE_NEXT_KEY(k, k_len, nod_flag);
@@ -143,13 +148,24 @@ err1:
return -1;
}
+
/*
-Find first key in r-tree according to search_flag condition
-Result values:
--1 - error
- 0 - found
- 1 - not found
+ Find first key in r-tree according to search_flag condition
+
+ SYNOPSIS
+ rtree_find_first()
+ info Handler to MyISAM file
+ uint keynr Key number to use
+ key Key to search for
+ key_length Length of 'key'
+ search_flag Bitmap of flags how to do the search
+
+ RETURN
+ -1 Error
+ 0 Found
+ 1 Not found
*/
+
int rtree_find_first(MI_INFO *info, uint keynr, uchar *key, uint key_length,
uint search_flag)
{
@@ -164,7 +180,8 @@ int rtree_find_first(MI_INFO *info, uint keynr, uchar *key, uint key_length,
}
/* Save searched key */
- memcpy(info->lastkey2, key, keyinfo->keylength - info->s->base.rec_reflength);
+ memcpy(info->first_mbr_key, key, keyinfo->keylength -
+ info->s->base.rec_reflength);
info->last_rkey_length = key_length;
info->rtree_recursion_depth = -1;
@@ -175,13 +192,22 @@ int rtree_find_first(MI_INFO *info, uint keynr, uchar *key, uint key_length,
return rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag, root, 0);
}
+
/*
-Find next key in r-tree according to search_flag condition
-Result values:
--1 - error
- 0 - found
- 1 - not found
+ Find next key in r-tree according to search_flag condition
+
+ SYNOPSIS
+ rtree_find_next()
+ info Handler to MyISAM file
+ uint keynr Key number to use
+ search_flag Bitmap of flags how to do the search
+
+ RETURN
+ -1 Error
+ 0 Found
+ 1 Not found
*/
+
int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag)
{
my_off_t root;
@@ -189,40 +215,30 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag)
MI_KEYDEF *keyinfo = info->s->keyinfo + keynr;
if (info->update & HA_STATE_DELETED)
- {
return rtree_find_first(info, keynr, info->lastkey, info->lastkey_length,
search_flag);
- }
-
+
if (!info->buff_used)
{
- uchar *key = info->int_keypos;
+ uchar *key= info->int_keypos;
while (key < info->int_maxpos)
{
- if (!rtree_key_cmp(keyinfo->seg, info->lastkey2, key,
+ if (!rtree_key_cmp(keyinfo->seg, info->first_mbr_key, key,
info->last_rkey_length, search_flag))
{
uchar *after_key = key + keyinfo->keylength;
- info->lastpos = _mi_dpos(info, 0, after_key);
+ info->lastpos= _mi_dpos(info, 0, after_key);
memcpy(info->lastkey, key, info->lastkey_length);
if (after_key < info->int_maxpos)
- {
- info->int_keypos = after_key;
- }
+ info->int_keypos= after_key;
else
- {
- info->buff_used = 1;
- }
-
+ info->buff_used= 1;
return 0;
}
- else
- {
- key += keyinfo->keylength;
- }
+ key+= keyinfo->keylength;
}
}
if ((root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR)
@@ -236,14 +252,19 @@ int rtree_find_next(MI_INFO *info, uint keynr, uint search_flag)
return rtree_find_req(info, keyinfo, search_flag, nod_cmp_flag, root, 0);
}
+
/*
-Get next key in r-tree recursively
-Used in rtree_get_first() and rtree_get_next()
-Result values:
--1 - error
- 0 - found
- 1 - not found
+ Get next key in r-tree recursively
+
+ NOTES
+ Used in rtree_get_first() and rtree_get_next()
+
+ RETURN
+ -1 Error
+ 0 Found
+ 1 Not found
*/
+
static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length,
my_off_t page, int level)
{
@@ -339,13 +360,16 @@ err1:
return -1;
}
+
/*
-Get first key in r-tree
-Result values:
--1 - error
- 0 - found
- 1 - not found
+ Get first key in r-tree
+
+ RETURN
+ -1 Error
+ 0 Found
+ 1 Not found
*/
+
int rtree_get_first(MI_INFO *info, uint keynr, uint key_length)
{
my_off_t root;
@@ -363,12 +387,16 @@ int rtree_get_first(MI_INFO *info, uint keynr, uint key_length)
return rtree_get_req(info, &keyinfo[keynr], key_length, root, 0);
}
-/* Get next key in r-tree
-Result values:
--1 - error
- 0 - found
- 1 - not found
+
+/*
+ Get next key in r-tree
+
+ RETURN
+ -1 Error
+ 0 Found
+ 1 Not found
*/
+
int rtree_get_next(MI_INFO *info, uint keynr, uint key_length)
{
my_off_t root;
@@ -407,13 +435,16 @@ int rtree_get_next(MI_INFO *info, uint keynr, uint key_length)
}
}
+
/*
-Go down and insert key into tree
-Result values:
--1 - error
- 0 - child was not split
- 1 - child was split
+ Go down and insert key into tree
+
+ RETURN
+ -1 Error
+ 0 Child was not split
+ 1 Child was split
*/
+
static int rtree_insert_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
uint key_length, my_off_t page, my_off_t *new_page,
int ins_level, int level)
@@ -490,13 +521,16 @@ err1:
return -1;
}
+
/*
-Insert key into the tree
-Result values:
--1 - error
- 0 - root was not split
- 1 - root was split
+ Insert key into the tree
+
+ RETURN
+ -1 Error
+ 0 Root was not split
+ 1 Root was split
*/
+
static int rtree_insert_level(MI_INFO *info, uint keynr, uchar *key,
uint key_length, int ins_level)
{
@@ -580,20 +614,29 @@ err1:
return res;
}
+
/*
-Insert key into the tree - interface function
-Result values:
--1 - error
- 0 - OK
+ Insert key into the tree - interface function
+
+ RETURN
+ -1 Error
+ 0 OK
*/
+
int rtree_insert(MI_INFO *info, uint keynr, uchar *key, uint key_length)
{
return (rtree_insert_level(info, keynr, key, key_length, -1) == -1) ? -1 : 0;
}
+
/*
-Fill reinsert page buffer
+ Fill reinsert page buffer
+
+ RETURN
+ -1 Error
+ 0 OK
*/
+
static int rtree_fill_reinsert_list(stPageList *ReinsertList, my_off_t page,
int level)
{
@@ -614,14 +657,17 @@ err1:
return -1;
}
+
/*
-Go down and delete key from the tree
-Result values:
--1 - error
- 0 - deleted
- 1 - not found
- 2 - empty leaf
+ Go down and delete key from the tree
+
+ RETURN
+ -1 Error
+ 0 Deleted
+ 1 Not found
+ 2 Empty leaf
*/
+
static int rtree_delete_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
uint key_length, my_off_t page, uint *page_size,
stPageList *ReinsertList, int level)
@@ -740,12 +786,15 @@ err1:
return -1;
}
+
/*
-Delete key - interface function
-Result values:
--1 - error
- 0 - deleted
+ Delete key - interface function
+
+ RETURN
+ -1 Error
+ 0 Deleted
*/
+
int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length)
{
uint page_size;
@@ -846,9 +895,14 @@ err1:
}
}
+
/*
-Estimate number of suitable keys in the tree
+ Estimate number of suitable keys in the tree
+
+ RETURN
+ estimated value
*/
+
ha_rows rtree_estimate(MI_INFO *info, uint keynr, uchar *key,
uint key_length, uint flag)
{
diff --git a/myisam/rt_split.c b/myisam/rt_split.c
index 41d6f8f8ccd..62b8ea6a65b 100644
--- a/myisam/rt_split.c
+++ b/myisam/rt_split.c
@@ -326,7 +326,8 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key,
cur2 = rt_PAGE_NEXT_KEY(cur2, key_length, nod_flag);
++n2;
}
- memcpy(to - nod_flag, cur->key - nod_flag, full_length);
+ if (to != cur->key)
+ memcpy(to - nod_flag, cur->key - nod_flag, full_length);
}
mi_putint(page, 2 + n1 * full_length, nod_flag);