Bug #14496 | Crash or strange results with prepared statement, MATCH and FULLTEXT | ||
---|---|---|---|
Submitted: | 30 Oct 2005 22:45 | Modified: | 14 Feb 2006 2:50 |
Reporter: | Michael Wallner (Candidate Quality Contributor) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Prepared statements | Severity: | S2 (Serious) |
Version: | 5.0.15-nt, 5.0.16-BK, 4.1.16-BK, 4.1.14 | OS: | Windows (Windows, Linux) |
Assigned to: | Sergey Vojtovich | CPU Architecture: | Any |
[30 Oct 2005 22:45]
Michael Wallner
[31 Oct 2005 9:38]
Valeriy Kravchuk
Thank you for a bug report. I was able to repeat this crash om 5.0.15-nt using mysql client: mysql> create table foo ( bar text NULL, FULLTEXT KEY bar (bar) ) engine=MyISAM; Query OK, 0 rows affected (0.05 sec) mysql> insert into foo (bar) values ( "This is row sample"); Query OK, 1 row affected (0.02 sec) mysql> insert into foo (bar) values ( "This is row foobar"); Query OK, 1 row affected (0.00 sec) mysql> insert into foo (bar) values ( "This is row sample"); Query OK, 1 row affected (0.00 sec) mysql> insert into foo (bar) values ( "This is row another" ); Query OK, 1 row affected (0.00 sec) mysql> insert into foo (bar) values ( "This is row wordlist" ); Query OK, 1 row affected (0.04 sec) mysql> insert into foo (bar) values ( "This is row random" ); Query OK, 1 row affected (0.01 sec) mysql> select bar, MATCH(bar) AGAINST ('foobar sample') as afoo -> from foo where MATCH(bar) AGAINST ('foobar sample'); +--------------------+------------------+ | bar | afoo | +--------------------+------------------+ | This is row foobar | 1.5911398452715 | | This is row sample | 0.68526663197496 | | This is row sample | 0.68526663197496 | +--------------------+------------------+ 3 rows in set (0.03 sec) mysql> select bar, MATCH(bar) AGAINST ('foobar sample') as afoo -> from foo where MATCH(bar) AGAINST ('foobar sample'); +--------------------+------------------+ | bar | afoo | +--------------------+------------------+ | This is row foobar | 1.5911398452715 | | This is row sample | 0.68526663197496 | | This is row sample | 0.68526663197496 | +--------------------+------------------+ 3 rows in set (0.03 sec) mysql> select version(); +-----------+ | version() | +-----------+ | 5.0.15-nt | +-----------+ 1 row in set (0.00 sec) So, it works OK two times whne PS is not used. Let's try to prepare it: mysql> prepare stmt2 from "select bar, MATCH(bar) AGAINST ('foobar sample') as afoo "> from foo where MATCH(bar) AGAINST ('foobar sample')"; Query OK, 0 rows affected (0.00 sec) Statement prepared mysql> execute stmt2; +--------------------+------------------+ | bar | afoo | +--------------------+------------------+ | This is row foobar | 1.5911398452715 | | This is row sample | 0.68526663197496 | | This is row sample | 0.68526663197496 | +--------------------+------------------+ 3 rows in set (0.00 sec) mysql> execute stmt2; ERROR 2013 (HY000): Lost connection to MySQL server during query This is a crash on Windows. Now let's come to Linux. Both 5.0.16-BK (ChangeSet@1.1957, 2005-10-29 13:11:34+04:00, konstantin@mysql.com) and 4.1.16-BK-debug (ChangeSet@1.2450, 2005-10-27 10:20:38-07:00, jimw@mysql.com) gave me the following results (with the same table and data) on Fedora Core 1: mysql> prepare stmt2 from "select bar, MATCH(bar) AGAINST ('foobar sample') as afoo from foo where MATCH(bar) AGAINST ('foobar sample')"; Query OK, 0 rows affected (0,00 sec) Statement prepared mysql> execute stmt2; +--------------------+------------------+ | bar | afoo | +--------------------+------------------+ | This is row foobar | 1.591139793396 | | This is row sample | 0.68526661396027 | | This is row sample | 0.68526661396027 | +--------------------+------------------+ 3 rows in set (0,00 sec) mysql> execute stmt2; +--------------------+------------------+ | bar | afoo | +--------------------+------------------+ | This is row foobar | 0 | | This is row sample | 0.68526661396027 | | This is row sample | 0.68526661396027 | +--------------------+------------------+ 3 rows in set (0,00 sec) mysql> select version(); +--------------+ | version() | +--------------+ | 4.1.16-debug | +--------------+ 1 row in set (0,00 sec) This different results is a bug also. Without PS we get the consistent results: mysql> select bar, MATCH(bar) AGAINST ('foobar sample') as afoo from foo where MATCH(bar) AGAINST ('foobar sample'); +--------------------+------------------+ | bar | afoo | +--------------------+------------------+ | This is row foobar | 1.591139793396 | | This is row sample | 0.68526661396027 | | This is row sample | 0.68526661396027 | +--------------------+------------------+ 3 rows in set (0,00 sec) mysql> select bar, MATCH(bar) AGAINST ('foobar sample') as afoo from foo where MATCH(bar) AGAINST ('foobar sample'); +--------------------+------------------+ | bar | afoo | +--------------------+------------------+ | This is row foobar | 1.591139793396 | | This is row sample | 0.68526661396027 | | This is row sample | 0.68526661396027 | +--------------------+------------------+ 3 rows in set (0,00 sec) Your PHP script also works and give some strange results for me on 4.1.16 and 5.0.16, but no crash. But I think that simple mysql is enough to demonstrate the erronious behaviour and crash.
[1 Feb 2006 16:41]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/2015
[7 Feb 2006 19:42]
Sergey Vojtovich
Fixed that fulltext query using PS results in unexpected behaviour when executed 2 or more times. Fixed in 4.1.19, 5.0.19. Wasn't able to push into 5.1 yet.
[14 Feb 2006 2:50]
Paul DuBois
Noted in 4.1.19, 5.0.19, 5.1.6 changelogs. <para> A <literal>FULLTEXT</literal> query in a prepared statement could result in unexpected behavior. (Bug #14496) </para>