[MDEV-21750] InnoDB fulltext query containing percent and wildcard character reports syntax error, unexpected $end, expecting FTS_TERM or FTS_NUMB or '*' Created: 2020-02-17  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: Full-text Search, Storage Engine - InnoDB
Affects Version/s: 10.1, 10.3.20, 10.4.11, 10.2, 10.3, 10.4
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Minor
Reporter: Michal Vrchota Assignee: Thirunarayanan Balathandayuthapani
Resolution: Unresolved Votes: 1
Labels: upstream


 Description   

I find little inconsistency when fulltext query contains percent sign (%) with combination of * wildcard (in both boolean mode and natural language mode)

Since * and % are not considered as special operators in fulltext natural language mode I don't see reason why SQL queries containing those characters should fail due to syntax error.
https://mariadb.com/kb/en/full-text-index-overview/
"IN NATURAL LANGUAGE MODE is the default type of full-text search, and the keywords can be omitted. There are no special operators, and searches consist of one or more comma-separated keywords."

Issue is only present in InnoDB (not MyISAM)

 
 
CREATE TABLE `tab1` (
	`id` INT(11) NOT NULL,
	`str` TEXT NOT NULL,
	PRIMARY KEY (`id`),
	FULLTEXT INDEX `fulltext1` (`str`)
)
ENGINE=InnoDB
;
 
-- those queries fail (both in natural language and boolean mode)
select * from tab1 where match(str) against ('%*');
select * from tab1 where match(str) against ('%*%');
select * from tab1 where match(str) against ('*%*');
select * from tab1 where match(str) against ('%*%%');
select * from tab1 where match(str) against ('%*%*');
select * from tab1 where match(str) against ('%*%%*');
select * from tab1 where match(str) against ('*'); -- this is obvious in boolean mode, but not sure why is this problem in natural language mode
 
/* SQL chyba (1064): syntax error, unexpected $end, expecting FTS_TERM or FTS_NUMB or '*' */
 
-- suprisingly those queries work fine
select * from tab1 where match(str) against ('**');
select * from tab1 where match(str) against ('%');
select * from tab1 where match(str) against ('%%');
select * from tab1 where match(str) against ('%**');
select * from tab1 where match(str) against ('%%**');

As You can see one person can get a headache if You try to escape query rather than just remove any special characters from string.



 Comments   
Comment by Elena Stepanova [ 2020-03-07 ]

Thanks for the report. Reproducible as described.

It is not a regular parser error but InnoDB-specific. Also reproducible with MySQL 5.6-8.0.
Maybe special symbols are not supported in InnoDB full-text search, but the error could be better. Also, it needs to be documented.

Comment by Chris Hewett [ 2021-02-10 ]

It appears this bug was reported back in 2015 on MySQL 5.6 but apart from a few bumps there has been no progress:
https://bugs.mysql.com/bug.php?id=78485

Generated at Thu Feb 08 09:09:31 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.