summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authormonty@mysql.com <>2003-11-23 14:52:02 +0200
committermonty@mysql.com <>2003-11-23 14:52:02 +0200
commit05f1e1003092da9ff10c8bbdd8278b867395727c (patch)
tree8f204f07ae960452be45956ae6ad1f8f796ea41f /myisam
parent7c725b2486de1f48f4e4e16a87b4b3cb542ab19b (diff)
parent5443cba38e392a34e13814da10b823edb5ab9d30 (diff)
downloadmariadb-git-05f1e1003092da9ff10c8bbdd8278b867395727c.tar.gz
merge with 4.0
Diffstat (limited to 'myisam')
-rw-r--r--myisam/ft_boolean_search.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c
index e44516c16d6..aa41bc11513 100644
--- a/myisam/ft_boolean_search.c
+++ b/myisam/ft_boolean_search.c
@@ -61,10 +61,11 @@ typedef struct st_ftb_expr FTB_EXPR;
struct st_ftb_expr
{
FTB_EXPR *up;
- byte *quot, *qend;
- my_off_t docid[2]; /* for index search and for scan */
+ my_off_t docid[2];
+/* ^^^^^^^^^^^^^^^^^^ FTB_{EXPR,WORD} common section */
float weight;
float cur_weight;
+ byte *quot, *qend;
uint flags;
uint yesses; /* number of "yes" words matched */
uint nos; /* number of "no" words matched */
@@ -77,6 +78,7 @@ typedef struct st_ftb_word
FTB_EXPR *up;
MI_KEYDEF *keyinfo;
my_off_t docid[2]; /* for index search and for scan */
+/* ^^^^^^^^^^^^^^^^^^ FTB_{EXPR,WORD} common section */
my_off_t key_root;
float weight;
uint ndepth;
@@ -299,13 +301,15 @@ static void _ftb_init_index_search(FT_INFO *ftb)
if (ftbw->flags & FTB_FLAG_TRUNC)
{
/*
- special treatment for truncation operator :((
- 1. +trunc* and there're other (not +trunc*) words
+ special treatment for truncation operator
+ 1. there are some (besides this) +words
| no need to search in the index, it can never ADD new rows
| to the result, and to remove half-matched rows we do scan anyway
2. -trunc*
| same as 1.
- 3. trunc*
+ 3. in 1 and 2, +/- need not be on the same expr. level,
+ but can be on any upper level, as in +word +(trunc1* trunc2*)
+ 4. otherwise
| We have to index-search for this prefix.
| It may cause duplicates, as in the index (sorted by <word,docid>)
| <aaaa,row1>
@@ -313,22 +317,31 @@ static void _ftb_init_index_search(FT_INFO *ftb)
| <aacc,row1>
| Searching for "aa*" will find row1 twice...
*/
- if ( test(ftbw->flags&FTB_FLAG_NO) || /* 2 */
- (test(ftbw->flags&FTB_FLAG_YES) && /* 1 */
- ftbw->up->ythresh - ftbw->up->yweaks >1)) /* 1 */
- {
- ftbw->docid[0]=HA_POS_ERROR;
- ftbw->up->yweaks++;
- continue;
- }
- else /* 3 */
+ FTB_EXPR *ftbe;
+ for (ftbe=(FTB_EXPR*)ftbw;
+ ftbe->up && !(ftbe->up->flags & FTB_FLAG_TRUNC);
+ ftbe->up->flags|= FTB_FLAG_TRUNC, ftbe=ftbe->up)
{
- if (!is_tree_inited(& ftb->no_dupes))
- init_tree(&ftb->no_dupes,0,0,sizeof(my_off_t),
- _ftb_no_dupes_cmp, 0, NULL, NULL);
- else
- reset_tree(& ftb->no_dupes);
+ if (ftbe->flags & FTB_FLAG_NO || /* 2 */
+ ftbe->up->ythresh - ftbe->up->yweaks >1) /* 1 */
+ {
+ FTB_EXPR *top_ftbe=ftbe->up->up;
+ ftbw->docid[0]=HA_POS_ERROR;
+ for (ftbe=ftbw->up; ftbe != top_ftbe; ftbe=ftbe->up)
+ if (ftbe->flags & FTB_FLAG_YES)
+ ftbe->yweaks++;
+ ftbe=0;
+ break;
+ }
}
+ if (!ftbe)
+ continue;
+ /* 3 */
+ if (!is_tree_inited(& ftb->no_dupes))
+ init_tree(& ftb->no_dupes,0,0,sizeof(my_off_t),
+ _ftb_no_dupes_cmp,0,0,0);
+ else
+ reset_tree(& ftb->no_dupes);
}
if (_ft2_search(ftb, ftbw, 1))