mirror of
				https://github.com/MariaDB/server.git
				synced 2025-10-31 02:46:29 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			298 lines
		
	
	
	
		
			9 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			298 lines
		
	
	
	
		
			9 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| CREATE TABLE t1 (
 | ||
| i int(10) unsigned not null auto_increment primary key,
 | ||
| a varchar(255) not null,
 | ||
| FULLTEXT KEY (a)
 | ||
| ) ENGINE = INNODB;
 | ||
| check table t1;
 | ||
| Table	Op	Msg_type	Msg_text
 | ||
| test.t1	check	status	OK
 | ||
| select count(*) from t1 where match a against ('aaaxxx');
 | ||
| count(*)
 | ||
| 260
 | ||
| select count(*) from t1 where match a against ('aaayyy');
 | ||
| count(*)
 | ||
| 250
 | ||
| select count(*) from t1 where match a against ('aaazzz');
 | ||
| count(*)
 | ||
| 255
 | ||
| select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
 | ||
| count(*)
 | ||
| 260
 | ||
| select count(*) from t1 where match a against ('aaayyy' in boolean mode);
 | ||
| count(*)
 | ||
| 250
 | ||
| select count(*) from t1 where match a against ('aaazzz' in boolean mode);
 | ||
| count(*)
 | ||
| 255
 | ||
| select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz');
 | ||
| count(*)
 | ||
| 765
 | ||
| select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode);
 | ||
| count(*)
 | ||
| 765
 | ||
| select count(*) from t1 where match a against ('aaax*' in boolean mode);
 | ||
| count(*)
 | ||
| 260
 | ||
| select count(*) from t1 where match a against ('aaay*' in boolean mode);
 | ||
| count(*)
 | ||
| 250
 | ||
| select count(*) from t1 where match a against ('aaa*' in boolean mode);
 | ||
| count(*)
 | ||
| 765
 | ||
| insert t1 (a) values ('aaaxxx'),('aaayyy');
 | ||
| insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz');
 | ||
| select count(*) from t1 where match a against ('aaaxxx');
 | ||
| count(*)
 | ||
| 261
 | ||
| select count(*) from t1 where match a against ('aaayyy');
 | ||
| count(*)
 | ||
| 251
 | ||
| select count(*) from t1 where match a against ('aaazzz');
 | ||
| count(*)
 | ||
| 260
 | ||
| insert t1 (a) values ('aaaxxx 000000');
 | ||
| select count(*) from t1 where match a against ('000000');
 | ||
| count(*)
 | ||
| 1
 | ||
| delete from t1 where match a against ('000000');
 | ||
| select count(*) from t1 where match a against ('000000');
 | ||
| count(*)
 | ||
| 0
 | ||
| select count(*) from t1 where match a against ('aaaxxx');
 | ||
| count(*)
 | ||
| 261
 | ||
| delete from t1 where match a against ('aaazzz');
 | ||
| select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
 | ||
| count(*)
 | ||
| 261
 | ||
| select count(*) from t1 where match a against ('aaayyy' in boolean mode);
 | ||
| count(*)
 | ||
| 251
 | ||
| select count(*) from t1 where match a against ('aaazzz' in boolean mode);
 | ||
| count(*)
 | ||
| 0
 | ||
| select count(*) from t1 where a = 'aaaxxx';
 | ||
| count(*)
 | ||
| 261
 | ||
| select count(*) from t1 where a = 'aaayyy';
 | ||
| count(*)
 | ||
| 251
 | ||
| select count(*) from t1 where a = 'aaazzz';
 | ||
| count(*)
 | ||
| 0
 | ||
| insert t1 (a) values ('aaaxxx 000000');
 | ||
| select count(*) from t1 where match a against ('000000');
 | ||
| count(*)
 | ||
| 1
 | ||
| update t1 set a='aaazzz' where match a against ('000000');
 | ||
| select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
 | ||
| count(*)
 | ||
| 261
 | ||
| select count(*) from t1 where match a against ('aaazzz' in boolean mode);
 | ||
| count(*)
 | ||
| 1
 | ||
| update t1 set a='aaazzz' where a = 'aaaxxx';
 | ||
| update t1 set a='aaaxxx' where a = 'aaayyy';
 | ||
| select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
 | ||
| count(*)
 | ||
| 251
 | ||
| select count(*) from t1 where match a against ('aaayyy' in boolean mode);
 | ||
| count(*)
 | ||
| 0
 | ||
| select count(*) from t1 where match a against ('aaazzz' in boolean mode);
 | ||
| count(*)
 | ||
| 262
 | ||
| drop table t1;
 | ||
| CREATE TABLE t1 (
 | ||
| i int(10) unsigned not null auto_increment primary key,
 | ||
| a varchar(255) not null,
 | ||
| FULLTEXT KEY (a)
 | ||
| ) ENGINE = INNODB;
 | ||
| select count(*) from t1 where match a against ('aaaxxx');
 | ||
| count(*)
 | ||
| 260
 | ||
| select count(*) from t1 where match a against ('aaayyy');
 | ||
| count(*)
 | ||
| 250
 | ||
| select count(*) from t1 where match a against ('aaazzz');
 | ||
| count(*)
 | ||
| 255
 | ||
| select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
 | ||
| count(*)
 | ||
| 260
 | ||
| select count(*) from t1 where match a against ('aaayyy' in boolean mode);
 | ||
| count(*)
 | ||
| 250
 | ||
| select count(*) from t1 where match a against ('aaazzz' in boolean mode);
 | ||
| count(*)
 | ||
| 255
 | ||
| select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz');
 | ||
| count(*)
 | ||
| 765
 | ||
| select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode);
 | ||
| count(*)
 | ||
| 765
 | ||
| select count(*) from t1 where match a against ('aaax*' in boolean mode);
 | ||
| count(*)
 | ||
| 260
 | ||
| select count(*) from t1 where match a against ('aaay*' in boolean mode);
 | ||
| count(*)
 | ||
| 250
 | ||
| select count(*) from t1 where match a against ('aaa*' in boolean mode);
 | ||
| count(*)
 | ||
| 765
 | ||
| insert t1 (a) values ('aaaxxx'),('aaayyy');
 | ||
| insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz');
 | ||
| select count(*) from t1 where match a against ('aaaxxx');
 | ||
| count(*)
 | ||
| 261
 | ||
| select count(*) from t1 where match a against ('aaayyy');
 | ||
| count(*)
 | ||
| 251
 | ||
| select count(*) from t1 where match a against ('aaazzz');
 | ||
| count(*)
 | ||
| 260
 | ||
| insert t1 (a) values ('aaaxxx 000000');
 | ||
| select count(*) from t1 where match a against ('000000');
 | ||
| count(*)
 | ||
| 1
 | ||
| delete from t1 where match a against ('000000');
 | ||
| select count(*) from t1 where match a against ('000000');
 | ||
| count(*)
 | ||
| 0
 | ||
| select count(*) from t1 where match a against ('aaaxxx');
 | ||
| count(*)
 | ||
| 261
 | ||
| delete from t1 where match a against ('aaazzz');
 | ||
| select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
 | ||
| count(*)
 | ||
| 261
 | ||
| select count(*) from t1 where match a against ('aaayyy' in boolean mode);
 | ||
| count(*)
 | ||
| 251
 | ||
| select count(*) from t1 where match a against ('aaazzz' in boolean mode);
 | ||
| count(*)
 | ||
| 0
 | ||
| select count(*) from t1 where a = 'aaaxxx';
 | ||
| count(*)
 | ||
| 261
 | ||
| select count(*) from t1 where a = 'aaayyy';
 | ||
| count(*)
 | ||
| 251
 | ||
| select count(*) from t1 where a = 'aaazzz';
 | ||
| count(*)
 | ||
| 0
 | ||
| insert t1 (a) values ('aaaxxx 000000');
 | ||
| select count(*) from t1 where match a against ('000000');
 | ||
| count(*)
 | ||
| 1
 | ||
| update t1 set a='aaazzz' where match a against ('000000');
 | ||
| select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
 | ||
| count(*)
 | ||
| 261
 | ||
| select count(*) from t1 where match a against ('aaazzz' in boolean mode);
 | ||
| count(*)
 | ||
| 1
 | ||
| update t1 set a='aaazzz' where a = 'aaaxxx';
 | ||
| update t1 set a='aaaxxx' where a = 'aaayyy';
 | ||
| select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
 | ||
| count(*)
 | ||
| 251
 | ||
| select count(*) from t1 where match a against ('aaayyy' in boolean mode);
 | ||
| count(*)
 | ||
| 0
 | ||
| select count(*) from t1 where match a against ('aaazzz' in boolean mode);
 | ||
| count(*)
 | ||
| 262
 | ||
| drop table t1;
 | ||
| set names utf8;
 | ||
| create table t1(a text,fulltext(a)) ENGINE = INNODB collate=utf8_swedish_ci;
 | ||
| insert into t1 values('test test '),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'),
 | ||
| ('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test');
 | ||
| delete from t1 limit 1;
 | ||
| truncate table t1;
 | ||
| insert into t1 values('ab c d');
 | ||
| update t1 set a='ab c d';
 | ||
| select * from t1 where match a against('ab c' in boolean mode);
 | ||
| a
 | ||
| select * from t1 where match a against('ab	c' in boolean mode);
 | ||
| a
 | ||
| drop table t1;
 | ||
| set names latin1;
 | ||
| SET NAMES utf8;
 | ||
| CREATE TABLE t1(a VARCHAR(255), FULLTEXT(a)) ENGINE = INNODB DEFAULT CHARSET=utf8;
 | ||
| INSERT INTO t1 VALUES('„MySQL“');
 | ||
| SELECT a FROM t1 WHERE MATCH a AGAINST('“MySQL„' IN BOOLEAN MODE);
 | ||
| a
 | ||
| „MySQL“
 | ||
| DROP TABLE t1;
 | ||
| SET NAMES latin1;
 | ||
| CREATE TABLE t1 (
 | ||
| FTS_DOC_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 | ||
| id int(10) not null ,
 | ||
| first_name varchar(50) NOT NULL,
 | ||
| last_name varchar(50) NOT NULL,
 | ||
| PRIMARY KEY (FTS_DOC_ID),
 | ||
| UNIQUE KEY idx_1 (first_name, last_name),
 | ||
| FULLTEXT KEY `idx_2` (first_name)
 | ||
| ) ENGINE=InnoDB;
 | ||
| INSERT INTO t1 (id, first_name, last_name) VALUES
 | ||
| (10, 'Bart', 'Simpson'),
 | ||
| (11, 'Homer', 'Simpson'),
 | ||
| (12, 'Marge', 'Simpson'),
 | ||
| (13, 'Lisa', 'Simpson'),
 | ||
| (14, 'Maggie', 'Simpson'),
 | ||
| (15, 'Ned', 'Flanders'),
 | ||
| (16, 'Nelson', 'Muntz');
 | ||
| analyze table t1;
 | ||
| Table	Op	Msg_type	Msg_text
 | ||
| test.t1	analyze	status	Engine-independent statistics collected
 | ||
| test.t1	analyze	status	OK
 | ||
| SELECT fts_doc_id, first_name, last_name, MATCH(first_name) AGAINST('Homer' IN BOOLEAN MODE) AS score FROM t1;
 | ||
| fts_doc_id	first_name	last_name	score
 | ||
| 1	Bart	Simpson	0
 | ||
| 2	Homer	Simpson	0.7141907215118408
 | ||
| 4	Lisa	Simpson	0
 | ||
| 5	Maggie	Simpson	0
 | ||
| 3	Marge	Simpson	0
 | ||
| 6	Ned	Flanders	0
 | ||
| 7	Nelson	Muntz	0
 | ||
| DROP TABLE t1;
 | ||
| CREATE TABLE t1(a INT, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
 | ||
| KEY FTS_DOC_ID_INDEX(FTS_DOC_ID))ENGINE=InnoDB;
 | ||
| ALTER TABLE t1 ADD COLUMN c INT as (a) VIRTUAL;
 | ||
| ALTER TABLE t1 ADD d INT NULL;
 | ||
| ALTER TABLE t1 ADD FULLTEXT(b);
 | ||
| ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index
 | ||
| DROP TABLE t1;
 | ||
| #
 | ||
| # MDEV-29169 Using MATCH returns NULL for Virtual Column
 | ||
| #
 | ||
| CREATE TABLE t (a TEXT DEFAULT NULL,
 | ||
| b TEXT AS (a),
 | ||
| c TEXT AS (concat(a, '1')),
 | ||
| d int AS (111) VIRTUAL,
 | ||
| FULLTEXT KEY `a` (`a`)
 | ||
| ) ENGINE=InnoDB;
 | ||
| INSERT INTO t (a) VALUES ('test');
 | ||
| SELECT * FROM t;
 | ||
| a	b	c	d
 | ||
| test	test	test1	111
 | ||
| SELECT * FROM t WHERE MATCH(a) AGAINST('test');
 | ||
| a	b	c	d
 | ||
| test	test	test1	111
 | ||
| DROP TABLE t;
 | 
