Bug #361 Bug with optimizer and fulltext search using wildchar
Submitted: 2 May 2003 18:10 Modified: 10 Aug 2003 8:32
Reporter: jocelyn fournier (Silver Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: MyISAM storage engine Severity:S2 (Serious)
Version:4.0.13 OS:
Assigned to: Sergei Golubchik CPU Architecture:Any

[2 May 2003 18:10] jocelyn fournier
Description:
Fulltext search seems to not work properly with wildchar, depending whether a condition on another column of the table is used or not. (ft_stopword_file is /dev/null ;))

How to repeat:
Download tables at : ftp://support.mysql.com/pub/mysql/secret/bugfulltext.tar.gz

SELECT produits.categorie,produits.id_produit,produits.nom,categories.nom_cat FROM produits,stocks,categories WHERE produits.categorie='10' AND produits.categorie=categories.id_cat AND produits.id_produit=stocks.id_produit AND stocks.maj=1 AND (MATCH (categories.nom_cat) AGAINST ('imprimante*' IN BOOLEAN MODE)) GROUP BY id_produit;

+-----------+------------+---------------------------+-------------+
| categorie | id_produit | nom                       | nom_cat     |
+-----------+------------+---------------------------+-------------+
|        10 |        895 | Stylus C60 (C11C418041HA) | Imprimantes |
+-----------+------------+---------------------------+-------------+
1 row in set (0.00 sec)

=> This should return more results.

Then I try with "imprimantes" instead of "imprimante*" :

SELECT produits.categorie,produits.id_produit,produits.nom,categories.nom_cat FROM produits,stocks,categories WHERE produits.categorie='10' AND produits.categorie=categories.id_cat AND produits.id_produit=stocks.id_produit AND stocks.maj=1 AND (MATCH (categories.nom_cat) AGAINST ('imprimantes' IN BOOLEAN MODE)) GROUP BY id_produit ;

+-----------+------------+------------------------------------------+-------------+
| categorie | id_produit | nom                                      | nom_cat     |
+-----------+------------+------------------------------------------+-------------+
|        10 |        316 | Photosmart 1115                          | Imprimantes |
|        10 |        843 | HL-1230                                  | Imprimantes |
|        10 |        845 | HL-1440                                  | Imprimantes |
|        10 |        846 | HL-1450/LT                               | Imprimantes |
|        10 |        847 | HL-1470N                                 | Imprimantes |
|        10 |        848 | HL-P2500                                 | Imprimantes |
|        10 |        849 | HL-1650                                  | Imprimantes |
<cut>
|        10 |      11390 | Stylus Photo 830U (C11C525051)           | Imprimantes |
+-----------+------------+------------------------------------------+-------------+
258 rows in set (0.11 sec)

If I remove the produits.categorie='10' condition for the first query, the fulltext search seems to work properly :

SELECT produits.id_produit,produits.nom,categories.nom_cat FROM produits,stocks,categories WHERE produits.categorie=categories.id_cat AND produits.id_produit=stocks.id_produit AND stocks.maj=1 AND (MATCH (categories.nom_cat) AGAINST ('imprimante*' IN BOOLEAN MODE)) GROUP BY id_produit ;
+------------+------------------------------------------+----------------------------+
| id_produit | nom                                      | nom_cat                    |
+------------+------------------------------------------+----------------------------+
|        316 | Photosmart 1115                          | Imprimantes                |
|        843 | HL-1230                                  | Imprimantes                |
<cut>
|      11091 | X5190 Pro                                | Imprimantes multifonctions |
|      11277 | Stylus C42 + Epson Perfection 660        | Imprimantes                |
|      11356 | i6500                                    | Imprimantes                |
|      11373 | LaserJet 1300N                           | Imprimantes                |
|      11390 | Stylus Photo 830U (C11C525051)           | Imprimantes                |
+------------+------------------------------------------+----------------------------+
301 rows in set (0.07 sec)

I don't know if this is related but I also have a different behaviour with the following query :

SELECT produits.categorie,produits.id_produit,produits.nom,categories.nom_cat FROM produits,stocks,categories WHERE produits.categorie='10' AND produits.categorie=categories.id_cat AND produits.id_produit=stocks.id_produit AND stocks.maj=1 AND (MATCH (categories.nom_cat) AGAINST ('"imprimante"*' IN BOOLEAN MODE)) GROUP BY id_produit ;
Empty set (0.04 sec)
[3 May 2003 6:07] Sergei Golubchik
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at 
    http://www.mysql.com/doc/en/Installing_source_tree.html