summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2001-10-09 14:53:54 +0200
committerunknown <serg@serg.mysql.com>2001-10-09 14:53:54 +0200
commit736e5b0de2281ab75af2cf3d88480aa6db9a18d2 (patch)
treec39107b036ff091f557b03a1f37183735dcddbad /sql
parent734e2a8bcaa4a5d2de6059f4cdcac8e71bbb5d6d (diff)
downloadmariadb-git-736e5b0de2281ab75af2cf3d88480aa6db9a18d2.tar.gz
Boolean search passes _some_ tests
sql/ha_myisam.cc: One more abstraction layer added (C++ emulated in C :). include/ft_global.h: boolean search code plugged in mysql-test/r/fulltext_cache.result: boolean search code plugged in mysql-test/r/fulltext_left_join.result: boolean search code plugged in mysql-test/r/fulltext_multi.result: boolean search code plugged in mysql-test/r/fulltext_order_by.result: boolean search code plugged in sql/lex.h: IN BOOLEAN MODE syntax myisam/ft_nlq_search.c: boolean search code plugged in myisam/ftdefs.h: boolean search code plugged in sql/ha_myisam.h: boolean search code plugged in sql/handler.h: boolean search code plugged in include/my_base.h: do_not_sort_keyseg feature for MyISAM include/my_global.h: #define comp(a,b) (((a) < (b)) ? -1 : ((a) > (b)) ? 1 : 0) myisam/ft_boolean_search.c: bugfixing myisam/ft_parser.c: cleanup myisam/ft_static.c: do_not_sort_keyseg feature for MyISAM myisam/mi_search.c: do_not_sort_keyseg feature for MyISAM myisam/mi_write.c: cleanup mysql-test/t/fulltext.test: boolean search tests added BitKeeper/etc/ignore: Added myisam/FT1.MYD myisam/FT1.MYI to the ignore list sql/item_func.cc: boolean search sql/item_func.h: boolean search sql/sql_yacc.yy: boolean search
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_myisam.cc2
-rw-r--r--sql/ha_myisam.h6
-rw-r--r--sql/handler.h8
-rw-r--r--sql/item_func.cc109
-rw-r--r--sql/item_func.h21
-rw-r--r--sql/lex.h1
-rw-r--r--sql/sql_yacc.yy22
7 files changed, 102 insertions, 67 deletions
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 61452c3de3b..94481057743 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -1197,7 +1197,7 @@ int ha_myisam::ft_read(byte * buf)
thread_safe_increment(ha_read_next_count,&LOCK_status); // why ?
- error=ft_nlq_read_next((FT_DOCLIST *) ft_handler,(char*) buf);
+ error=ft_handler->please->read_next(ft_handler,(char*) buf);
table->status=error ? STATUS_NOT_FOUND: 0;
return error;
diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h
index a95f0ed71cb..eba2bde7d59 100644
--- a/sql/ha_myisam.h
+++ b/sql/ha_myisam.h
@@ -76,9 +76,9 @@ class ha_myisam: public handler
int index_next_same(byte *buf, const byte *key, uint keylen);
int index_end() { ft_handler=NULL; return 0; }
int ft_init()
- { if(!ft_handler) return 1; ft_nlq_reinit_search(ft_handler); return 0; }
- void *ft_init_ext(uint inx,const byte *key, uint keylen, bool presort)
- { return ft_nlq_init_search(file,inx,(byte*) key,keylen,presort); }
+ { if(!ft_handler) return 1; ft_handler->please->reinit_search(ft_handler); return 0; }
+ FT_INFO *ft_init_ext(uint mode, uint inx,const byte *key, uint keylen, bool presort)
+ { return ft_init_search(mode, file,inx,(byte*) key,keylen,presort); }
int ft_read(byte *buf);
int rnd_init(bool scan=1);
int rnd_next(byte *buf);
diff --git a/sql/handler.h b/sql/handler.h
index 16f7ba90eff..530c94a8b43 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -21,6 +21,8 @@
#pragma interface /* gcc class implementation */
#endif
+#include <ft_global.h>
+
#ifndef NO_HASH
#define NO_HASH /* Not yet implemented */
#endif
@@ -201,7 +203,7 @@ public:
time_t check_time;
time_t update_time;
ulong mean_rec_length; /* physical reclength */
- void *ft_handler;
+ FT_INFO *ft_handler;
bool auto_increment_column_changed;
handler(TABLE *table_arg) : table(table_arg),active_index(MAX_REF_PARTS),
@@ -247,9 +249,9 @@ public:
virtual int index_next_same(byte *buf, const byte *key, uint keylen);
virtual int ft_init()
{ return -1; }
- virtual void *ft_init_ext(uint inx,const byte *key, uint keylen,
+ virtual FT_INFO *ft_init_ext(uint mode,uint inx,const byte *key, uint keylen,
bool presort)
- { return (void *)NULL; }
+ { return NULL; }
virtual int ft_read(byte *buf) { return -1; }
virtual int rnd_init(bool scan=1)=0;
virtual int rnd_end() { return 0; }
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 076194e8b7b..960cadf71e9 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -1903,46 +1903,6 @@ err:
return 0;
}
-double Item_func_match_nl::val()
-{
- if (ft_handler==NULL)
- init_search(1);
-
- if ((null_value= (ft_handler==NULL)))
- return 0.0;
-
- if (join_key)
- {
- if (table->file->ft_handler)
- return ft_nlq_get_relevance(ft_handler);
-
- join_key=0; // Magic here ! See ha_myisam::ft_read()
- }
-
- /* we'll have to find ft_relevance manually in ft_handler array */
-
- int a,b,c;
- FT_DOC *docs=((FT_DOCLIST *)ft_handler)->doc;
- my_off_t docid=table->file->row_position();
-
- if ((null_value=(docid==HA_OFFSET_ERROR)))
- return 0.0;
-
- // Assuming docs[] is sorted by dpos...
-
- for (a=0, b=((FT_DOCLIST *)ft_handler)->ndocs, c=(a+b)/2; b-a>1; c=(a+b)/2)
- {
- if (docs[c].dpos > docid)
- b=c;
- else
- a=c;
- }
- if (docs[a].dpos == docid)
- return docs[a].weight;
- else
- return 0.0;
-}
-
void Item_func_match::init_search(bool no_order)
{
if (ft_handler)
@@ -2113,6 +2073,75 @@ bool Item_func_match::eq(const Item *item) const
return 0;
}
+#if 0
+double Item_func_match::val()
+{
+ if (ft_handler==NULL)
+ init_search(1);
+
+ if ((null_value= (ft_handler==NULL)))
+ return 0.0;
+
+ if (join_key)
+ {
+ if (table->file->ft_handler)
+ return ft_handler->please->get_relevance(ft_handler);
+
+ join_key=0;
+ }
+
+ my_off_t docid=table->file->row_position();
+
+ if ((null_value=(docid==HA_OFFSET_ERROR)))
+ return 0.0;
+ else
+ return ft_handler->please->find_relevance(ft_handler, docid);
+}
+#endif
+
+double Item_func_match_nl::val()
+{
+ if (ft_handler==NULL)
+ init_search(1);
+
+ if ((null_value= (ft_handler==NULL)))
+ return 0.0;
+
+ if (join_key)
+ {
+ if (table->file->ft_handler)
+ return ft_handler->please->get_relevance(ft_handler);
+
+ join_key=0;
+ }
+
+ my_off_t docid=table->file->row_position();
+
+ if ((null_value=(docid==HA_OFFSET_ERROR)))
+ return 0.0;
+ else
+ return ft_handler->please->find_relevance(ft_handler, docid);
+}
+
+double Item_func_match_bool::val()
+{
+ if (ft_handler==NULL)
+ init_search(1);
+
+ if ((null_value= (ft_handler==NULL)))
+ return 0.0;
+
+ if (join_key)
+ {
+ if (table->file->ft_handler)
+ return ft_handler->please->get_relevance(ft_handler);
+
+ join_key=0;
+ }
+
+ null_value=1;
+ return -1.0;
+}
/***************************************************************************
System variables
diff --git a/sql/item_func.h b/sql/item_func.h
index 19f15eaf9b3..1926fd025f4 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -863,7 +863,7 @@ public:
uint key;
bool join_key;
Item_func_match *master;
- void * ft_handler;
+ FT_INFO * ft_handler;
Item_func_match(List<Item> &a, Item *b): Item_real_func(b),
fields(a), table(0), join_key(0), master(0), ft_handler(0) {}
@@ -871,14 +871,13 @@ public:
{
if (!master && ft_handler)
{
- ft_handler_close();
+ ft_handler->please->close_search(ft_handler);
+ ft_handler=0;
if(join_key)
table->file->ft_handler=0;
}
}
- virtual int ft_handler_init(const byte *key, uint keylen, bool presort)
- { return 1; }
- virtual int ft_handler_close() { return 1; }
+ virtual int ft_handler_init(const byte *key, uint keylen, bool presort) =0;
enum Functype functype() const { return FT_FUNC; }
void update_used_tables() {}
bool fix_fields(THD *thd,struct st_table_list *tlist);
@@ -896,18 +895,16 @@ public:
const char *func_name() const { return "match_nl"; }
double val();
int ft_handler_init(const byte *query, uint querylen, bool presort)
- { ft_handler=table->file->ft_init_ext(key, query, querylen, presort); }
- int ft_handler_close() { ft_nlq_close_search(ft_handler); ft_handler=0; }
+ { ft_handler=table->file->ft_init_ext(FT_NL,key, query, querylen, presort); }
};
-#if 0
+
class Item_func_match_bool :public Item_func_match
{
public:
- Item_func_match_nl(List<Item> &a, Item *b): Item_func_match(a,b) {}
+ Item_func_match_bool(List<Item> &a, Item *b): Item_func_match(a,b) {}
const char *func_name() const { return "match_bool"; }
double val();
int ft_handler_init(const byte *query, uint querylen, bool presort)
- { ft_handler=table->file->ft_init_ext(key, query, querylen, presort); }
- int ft_handler_close() { ft_close_search(ft_handler); ft_handler=0; }
+ { ft_handler=table->file->ft_init_ext(FT_BOOL,key, query, querylen, presort); }
};
-#endif
+
diff --git a/sql/lex.h b/sql/lex.h
index 1d481aa7c85..21639fe4b70 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -73,6 +73,7 @@ static SYMBOL symbols[] = {
{ "BINLOG", SYM(BINLOG_SYM),0,0},
{ "BLOB", SYM(BLOB_SYM),0,0},
{ "BOOL", SYM(BOOL_SYM),0,0},
+ { "BOOLEAN", SYM(BOOLEAN_SYM),0,0},
{ "BOTH", SYM(BOTH),0,0},
{ "BY", SYM(BY),0,0},
{ "CASCADE", SYM(CASCADE),0,0},
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 08c2d800acf..3983f3b726c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -23,7 +23,7 @@
#define Lex current_lex
#define Select Lex->select
#include "mysql_priv.h"
-#include "slave.h"
+#include "slave.h"
#include "sql_acl.h"
#include "lex_symbol.h"
#include <myisam.h>
@@ -149,6 +149,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token BINARY
%token BIT_SYM
%token BOOL_SYM
+%token BOOLEAN_SYM
%token BOTH
%token BY
%token CASCADE
@@ -499,7 +500,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
using_list
%type <item_list>
- expr_list udf_expr_list when_list ident_list
+ expr_list udf_expr_list when_list ident_list ident_list_arg
%type <key_type>
key_type opt_unique_or_fulltext
@@ -1547,12 +1548,12 @@ simple_expr:
| '!' expr %prec NEG { $$= new Item_func_not($2); }
| '(' expr ')' { $$= $2; }
| '{' ident expr '}' { $$= $3; }
- | MATCH '(' ident_list ')' AGAINST '(' expr ')'
- { Select->ftfunc_list.push_back(
- (Item_func_match *)($$=new Item_func_match_nl(*$3,$7))); }
- | MATCH ident_list AGAINST '(' expr ')'
- { Select->ftfunc_list.push_back(
- (Item_func_match *)($$=new Item_func_match_nl(*$2,$5))); }
+ | MATCH ident_list_arg AGAINST '(' expr ')'
+ { Select->ftfunc_list.push_back((Item_func_match *)
+ $$=new Item_func_match_nl(*$2,$5)); }
+ | MATCH ident_list_arg AGAINST '(' expr IN_SYM BOOLEAN_SYM MODE_SYM ')'
+ { Select->ftfunc_list.push_back((Item_func_match *)
+ $$=new Item_func_match_bool(*$2,$5)); }
| BINARY expr %prec NEG { $$= new Item_func_binary($2); }
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
{ $$= new Item_func_case(* $4, $2, $5 ) }
@@ -1798,6 +1799,10 @@ expr_list2:
expr { Select->expr_list.head()->push_back($1); }
| expr_list2 ',' expr { Select->expr_list.head()->push_back($3); }
+ident_list_arg:
+ ident_list { $$= $1; }
+ | '(' ident_list ')' { $$= $2; }
+
ident_list:
{ Select->expr_list.push_front(new List<Item>); }
ident_list2
@@ -2816,6 +2821,7 @@ keyword:
| BERKELEY_DB_SYM {}
| BIT_SYM {}
| BOOL_SYM {}
+ | BOOLEAN_SYM {}
| CHANGED {}
| CHECKSUM_SYM {}
| CHECK_SYM {}