summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <Sinisa@sinisa.nasamreza.org>2002-03-15 14:11:11 +0200
committerunknown <Sinisa@sinisa.nasamreza.org>2002-03-15 14:11:11 +0200
commit3b2e1fd276094597cfb500bc8b9f27a193bfb60c (patch)
treea25d01855444721b4ec388407fb61159f5bb4370
parent606e3e9550f78894604bac0d4fbf473309798bf2 (diff)
downloadmariadb-git-3b2e1fd276094597cfb500bc8b9f27a193bfb60c.tar.gz
Making full-text queries working with UNION's
-rw-r--r--mysql-test/r/fulltext.result5
-rw-r--r--mysql-test/t/fulltext.test4
-rw-r--r--sql/sql_base.cc8
-rw-r--r--sql/sql_select.cc5
-rw-r--r--sql/sql_union.cc3
5 files changed, 18 insertions, 7 deletions
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index 7f4f3444312..dd5e59e4081 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -16,6 +16,11 @@ select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
a b
Full-text indexes are called collections
Only MyISAM tables support collections
+select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes");
+a b
+Only MyISAM tables support collections
+Full-text indexes are called collections
+Full-text indexes are called collections
select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE);
a b
MySQL has now support for full-text search
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index da0c0a52d8a..ea7a572951a 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -17,6 +17,10 @@ select * from t1 where MATCH(a,b) AGAINST ("collections");
select * from t1 where MATCH(a,b) AGAINST ("indexes");
select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
+# UNION of fulltext's
+select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes");
+
+
# boolean search
select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index f4a70db2e5d..5d80fd63d13 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -2175,8 +2175,8 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
int setup_ftfuncs(THD *thd)
{
- List_iterator<Item_func_match> li(thd->lex.select_lex.ftfunc_list),
- lj(thd->lex.select_lex.ftfunc_list);
+ List_iterator<Item_func_match> li(thd->lex.select->ftfunc_list),
+ lj(thd->lex.select->ftfunc_list);
Item_func_match *ftf, *ftf2;
while ((ftf=li++))
@@ -2196,9 +2196,9 @@ int setup_ftfuncs(THD *thd)
int init_ftfuncs(THD *thd, bool no_order)
{
- if (thd->lex.select_lex.ftfunc_list.elements)
+ if (thd->lex.select->ftfunc_list.elements)
{
- List_iterator<Item_func_match> li(thd->lex.select_lex.ftfunc_list);
+ List_iterator<Item_func_match> li(thd->lex.select->ftfunc_list);
Item_func_match *ifm;
DBUG_PRINT("info",("Performing FULLTEXT search"));
thd->proc_info="FULLTEXT initialization";
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a5ca249d590..71da3c9431c 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -196,6 +196,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
List<Item> all_fields(fields);
bool select_distinct;
SELECT_LEX *select_lex = &(thd->lex.select_lex);
+ SELECT_LEX *cur_sel = thd->lex.select;
DBUG_ENTER("mysql_select");
/* Check that all tables, fields, conds and order are ok */
@@ -553,7 +554,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
make_join_readinfo(&join,
(select_options & (SELECT_DESCRIBE |
SELECT_NO_JOIN_CACHE)) |
- (select_lex->ftfunc_list.elements ? SELECT_NO_JOIN_CACHE : 0));
+ (cur_sel->ftfunc_list.elements ? SELECT_NO_JOIN_CACHE : 0));
/* Need to tell Innobase that to play it safe, it should fetch all
columns of the tables: this is because MySQL
@@ -1615,7 +1616,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
add_key_part(keyuse,field);
}
- if (thd->lex.select_lex.ftfunc_list.elements)
+ if (thd->lex.select->ftfunc_list.elements)
{
add_ft_keys(keyuse,join_tab,cond,normal_tables);
}
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 60155e0ce8d..7d921d6e598 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -126,7 +126,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
}
union_result->save_time_stamp=!describe;
- for (sl=&lex->select_lex;sl;sl=sl->next)
+ for (sl=lex->select=&lex->select_lex;sl;sl=lex->select=sl->next)
{
thd->offset_limit=sl->offset_limit;
thd->select_limit=sl->select_limit+sl->offset_limit;
@@ -155,6 +155,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
delete union_result;
/* Send result to 'result' */
+ lex->select = &lex->select_lex;
res =-1;
{
/* Create a list of fields in the temporary table */