Current Path : /home/usr.opt/mysql57/mysql-test/suite/innodb_fts/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/suite/innodb_fts/t/ngram_2.test |
# # InnoDB FULLTEXT SEARCH: CJK support - ngram parser # # --source include/have_innodb.inc --source include/not_embedded.inc #Test 3 scenarios: #1. CREATE a CJK fulltext index with ngram parser when ngram parser is loaded, # restart without ngram parser, do SELECT/INSERT; #2. CREATE a CJK fulltext index with ngram parser when ngram parser is not loaded. #3. CREATE a CJK fulltext index without ngram parser when ngram parser is not loaded. SET NAMES utf8; # t1 with default parser CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(200), content TEXT, FULLTEXT INDEX ft_content (content) ) ENGINE=InnoDB DEFAULT CHARACTER SET gb2312 COLLATE gb2312_chinese_ci; INSERT INTO t1 (title, content) VALUES ('中国', '中国'), ('中国上海', '中国上海'); ALTER TABLE t1 ADD FULLTEXT INDEX ft_title (title); SHOW CREATE TABLE t1; SELECT * FROM t1 WHERE MATCH(title) AGAINST('中国'); SELECT * FROM t1 WHERE MATCH(title) AGAINST('中国上海'); SELECT * FROM t1 WHERE MATCH(content) AGAINST('中国'); SELECT * FROM t1 WHERE MATCH(content) AGAINST('中国上海'); DROP TABLE t1; # t1 with ngram parser CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(200), content TEXT, FULLTEXT INDEX ft_content (content) WITH PARSER ngram ) ENGINE=InnoDB DEFAULT CHARACTER SET gb2312 COLLATE gb2312_chinese_ci; INSERT INTO t1 (title, content) VALUES ('中国', '中国'), ('中国上海', '中国上海'); ALTER TABLE t1 ADD FULLTEXT INDEX ft_title (title) WITH PARSER ngram; SHOW CREATE TABLE t1; SELECT * FROM t1 WHERE MATCH(title) AGAINST('中国'); SELECT * FROM t1 WHERE MATCH(title) AGAINST('中国上海'); SELECT * FROM t1 WHERE MATCH(content) AGAINST('中国'); SELECT * FROM t1 WHERE MATCH(content) AGAINST('中国上海'); # t2 with ngram parser CREATE TABLE t2 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(200), content TEXT, FULLTEXT INDEX ft_content (content) WITH PARSER ngram ) ENGINE=InnoDB DEFAULT CHARACTER SET gb2312 COLLATE gb2312_chinese_ci; ALTER TABLE t2 ADD FULLTEXT INDEX ft_title (title) WITH PARSER ngram; # Restart without ngram. let $restart_parameters = restart: --ngram=OFF; --source include/restart_mysqld.inc # t1 CHECK TABLE t1; --error ER_PLUGIN_IS_NOT_LOADED SELECT * FROM t1; --error ER_PLUGIN_IS_NOT_LOADED SELECT * FROM t1 WHERE MATCH(title) AGAINST('中国'); --error ER_PLUGIN_IS_NOT_LOADED SELECT * FROM t1 WHERE MATCH(title) AGAINST('中国上海'); --error ER_PLUGIN_IS_NOT_LOADED SELECT * FROM t1 WHERE MATCH(content) AGAINST('中国'); --error ER_PLUGIN_IS_NOT_LOADED SELECT * FROM t1 WHERE MATCH(content) AGAINST('中国上海'); --error ER_PLUGIN_IS_NOT_LOADED INSERT INTO t1 (title, content) VALUES ('中国', '中国'); --error ER_PLUGIN_IS_NOT_LOADED DROP INDEX ft_title ON t1; --error ER_PLUGIN_IS_NOT_LOADED DROP INDEX ft_content ON t1; --error ER_PLUGIN_IS_NOT_LOADED TRUNCATE TABLE t1; --error ER_PLUGIN_IS_NOT_LOADED ALTER TABLE t1 RENAME TO t3; # t2 RENAME TABLE t2 to t3; DROP TABLE t3; --error ER_FUNCTION_NOT_DEFINED CREATE TABLE t2 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(200), FULLTEXT INDEX ft_title (title) WITH PARSER ngram ) ENGINE=InnoDB DEFAULT CHARACTER SET gb2312 COLLATE gb2312_chinese_ci; CREATE TABLE t2 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(200) ) ENGINE=InnoDB DEFAULT CHARACTER SET gb2312 COLLATE gb2312_chinese_ci; --error ER_FUNCTION_NOT_DEFINED ALTER TABLE t2 ADD FULLTEXT INDEX ft_title (title) WITH PARSER ngram; ALTER TABLE t2 ADD FULLTEXT INDEX ft_title (title); INSERT INTO t2 (title) VALUES ('中国'); SELECT * FROM t2 WHERE MATCH(title) AGAINST('中国'); SELECT * FROM t2 WHERE MATCH(title) AGAINST('中国上海'); DROP TABLE t2; # Restart with ngram. let $restart_parameters = restart; --source include/restart_mysqld.inc CHECK TABLE t1; SELECT * FROM t1; SELECT * FROM t1 WHERE MATCH(title) AGAINST('中国'); SELECT * FROM t1 WHERE MATCH(title) AGAINST('中国上海'); SELECT * FROM t1 WHERE MATCH(content) AGAINST('中国'); SELECT * FROM t1 WHERE MATCH(content) AGAINST('中国上海'); DROP TABLE t1;