Bug #48781 Quotations in full-text parser plugins do not work
Submitted: 15 Nov 2009 14:15 Modified: 24 Nov 2009 12:45
Reporter: Andrew Hutchings Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[15 Nov 2009 14:15] Andrew Hutchings
Description:
Using quot in MYSQL_FTPARSER_BOOLEAN_INFO when writing full-text parser plugins does not appear to work correctly.

How to repeat:
Source to be attached shortly:

shell> gcc -g -ofulltext_boolean_test.so fulltext_boolean_test.c -I/home/linuxjedi/Programming/Builds/mysql-5.1.40-gpl/include/mysql/ -L/home/linuxjedi/Programming/Builds/mysql-5.1.40-gpl/lib/mysql/ -shared -fPIC  -DMYSQL_DYNAMIC_PLUGIN

mysql> install plugin fulltext_boolean_test soname 'fulltext_boolean_test.so';
mysql> create table t1 (a int primary key auto_increment, b varchar(255), fulltext key (b) with parser `fulltext_boolean_test`);
mysql> create table t2 (a int primary key auto_increment, b varchar(255), fulltext key (b));
mysql> insert into t1 values (null, 'apple microsoft windows linux'),(null, 'orange apple banana grape'),(null, 'windows doors walls gates');
mysql> insert into t2 select * from t1;
mysql> select * from t1 where match b against ('"microsoft windows"' in boolean mode);
Empty set (0.00 sec)

Err log:
Sym: 2
Word: microsoft
Word: windows
Sym: 3

mysql> select * from t2 where match b against ('"microsoft windows"' in boolean mode);
+---+-------------------------------+
| a | b                             |
+---+-------------------------------+
| 1 | apple microsoft windows linux |
+---+-------------------------------+
1 row in set (0.00 sec)
[15 Nov 2009 14:16] Andrew Hutchings
C file quickly knocked up to reproduce this

Attachment: fulltext_boolean_test.c (text/x-csrc), 3.72 KiB.

[15 Nov 2009 14:51] Andrew Hutchings
Removing the usage of quot makes this work but will match the words in any order inside the quote marks.

Using gdb it appears some of the elements of ftbe are different (such as the weight based elements) compared to the internal boolean parser.  I suspect this has something to do with it (either something is missing from my code or the internal parser does something extra).
[24 Nov 2009 12:45] Sergei Golubchik
You store your words on the stack, in the local buffer and use MYSQL_FTFLAGS_NEED_COPY flag.

But it doesn't work because of bug#39640, the word isn't copied and when the data on the stack is overwritten it becomes a garbage that cannot be found in the inserted data.

I'm marking this one a duplicate