From 847608350914ad6b192ca3f4e12dab4778798cf2 Mon Sep 17 00:00:00 2001 From: Eric Lam Date: Mon, 6 Jan 2025 10:59:33 +0000 Subject: [PATCH] Fulltext bugs (#21055) bug fix tokenizer bug and show create table with index name. Approved by: @badboynt1, @sukki37, @aressu1985, @ouyuanning, @heni02 --- pkg/monlp/tokenizer/simple.go | 12 ++++++++- pkg/monlp/tokenizer/simple_test.go | 3 +++ pkg/sql/plan/apply_indices.go | 24 ++++++++++------- pkg/sql/plan/apply_indices_fulltext.go | 27 ++++++++++++------- pkg/sql/plan/build_ddl.go | 2 ++ pkg/sql/plan/build_show_util.go | 7 ++++- pkg/sql/plan/build_show_util_test.go | 12 ++++++++- pkg/sql/plan/query_builder.go | 10 ++++--- .../cases/fulltext/fulltext.result | 18 ++++++++----- test/distributed/cases/fulltext/fulltext.sql | 2 ++ .../cases/fulltext/fulltext1.result | 4 +-- .../cases/fulltext/fulltext2.result | 4 +-- .../sys_restore_to_newnonsys_account.result | 8 +++--- .../sys_restore_to_nonsys_account.result | 8 +++--- 14 files changed, 96 insertions(+), 45 deletions(-) diff --git a/pkg/monlp/tokenizer/simple.go b/pkg/monlp/tokenizer/simple.go index 955ccaaea52f9..ebbc5b951c395 100644 --- a/pkg/monlp/tokenizer/simple.go +++ b/pkg/monlp/tokenizer/simple.go @@ -142,9 +142,19 @@ func (t *SimpleTokenizer) outputLatin(pos int, yield func(Token) bool) { bs = t.input[t.begin:pos] } else { if t.input[t.begin+MAX_TOKEN_SIZE-1] <= 127 { + // last character is ascii bs = t.input[t.begin : t.begin+MAX_TOKEN_SIZE] } else { - bs = t.input[t.begin : t.begin+MAX_TOKEN_SIZE-1] + // find the leading byte + n := 1 + for i := 0; i < 4; i++ { + // leading byte must have value at least 192 (binary 11000000) + if t.input[t.begin+MAX_TOKEN_SIZE-i-1] >= 192 { + break + } + n++ + } + bs = t.input[t.begin : t.begin+MAX_TOKEN_SIZE-n] } } diff --git a/pkg/monlp/tokenizer/simple_test.go b/pkg/monlp/tokenizer/simple_test.go index 5cb1dd3cd629c..1d5d9844f506d 100644 --- a/pkg/monlp/tokenizer/simple_test.go +++ b/pkg/monlp/tokenizer/simple_test.go @@ -93,6 +93,9 @@ func TestLatin(t *testing.T) { makeToken("long", 5), makeToken("word", 6), }) + checkTokenize(t, "Pадіоаматорів", []Token{ + makeToken("pадіоаматор", 0), + }) } func TestCJK(t *testing.T) { diff --git a/pkg/sql/plan/apply_indices.go b/pkg/sql/plan/apply_indices.go index d9b90d640e223..6a8ffd9943ee9 100644 --- a/pkg/sql/plan/apply_indices.go +++ b/pkg/sql/plan/apply_indices.go @@ -71,24 +71,28 @@ func isRuntimeConstExpr(expr *plan.Expr) bool { } } -func (builder *QueryBuilder) applyIndices(nodeID int32, colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) int32 { +func (builder *QueryBuilder) applyIndices(nodeID int32, colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) (int32, error) { + var err error if builder.optimizerHints != nil && builder.optimizerHints.applyIndices != 0 { - return nodeID + return nodeID, nil } node := builder.qry.Nodes[nodeID] for i, childID := range node.Children { - node.Children[i] = builder.applyIndices(childID, colRefCnt, idxColMap) + node.Children[i], err = builder.applyIndices(childID, colRefCnt, idxColMap) + if err != nil { + return -1, err + } } replaceColumnsForNode(node, idxColMap) switch node.NodeType { case plan.Node_TABLE_SCAN: - return builder.applyIndicesForFilters(nodeID, node, colRefCnt, idxColMap) + return builder.applyIndicesForFilters(nodeID, node, colRefCnt, idxColMap), nil case plan.Node_JOIN: - return builder.applyIndicesForJoins(nodeID, node, colRefCnt, idxColMap) + return builder.applyIndicesForJoins(nodeID, node, colRefCnt, idxColMap), nil case plan.Node_PROJECT: //NOTE: This is the entry point for vector index rule on SORT NODE. @@ -96,7 +100,7 @@ func (builder *QueryBuilder) applyIndices(nodeID int32, colRefCnt map[[2]int32]i } - return nodeID + return nodeID, nil } func (builder *QueryBuilder) applyIndicesForFilters(nodeID int32, node *plan.Node, @@ -173,7 +177,7 @@ func getColSeqFromColDef(tblCol *plan.ColDef) string { return fmt.Sprintf("%d", tblCol.GetSeqnum()) } -func (builder *QueryBuilder) applyIndicesForProject(nodeID int32, projNode *plan.Node, colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) int32 { +func (builder *QueryBuilder) applyIndicesForProject(nodeID int32, projNode *plan.Node, colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) (int32, error) { // FullText { // support the followings: @@ -261,7 +265,7 @@ func (builder *QueryBuilder) applyIndicesForProject(nodeID int32, projNode *plan } } if len(multiTableIndexes) == 0 { - return nodeID + return nodeID, nil } //1.b if sortNode has more than one order by, skip @@ -344,7 +348,7 @@ func (builder *QueryBuilder) applyIndicesForProject(nodeID int32, projNode *plan projNode.Children[0] = newSortNode replaceColumnsForNode(projNode, idxColMap) - return newSortNode + return newSortNode, nil } END0: // 2. Regular Index Check @@ -352,7 +356,7 @@ END0: } - return nodeID + return nodeID, nil } func (builder *QueryBuilder) applyIndicesForFiltersRegularIndex(nodeID int32, node *plan.Node, colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) int32 { diff --git a/pkg/sql/plan/apply_indices_fulltext.go b/pkg/sql/plan/apply_indices_fulltext.go index b70172ae9478d..19d62ce35ef78 100644 --- a/pkg/sql/plan/apply_indices_fulltext.go +++ b/pkg/sql/plan/apply_indices_fulltext.go @@ -54,15 +54,18 @@ import ( // +------------------------------------------------------------------------------------------+ func (builder *QueryBuilder) applyIndicesForProjectionUsingFullTextIndex(nodeID int32, projNode *plan.Node, sortNode *plan.Node, scanNode *plan.Node, filterids []int32, filterIndexDefs []*plan.IndexDef, projids []int32, projIndexDef []*plan.IndexDef, - colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) int32 { + colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) (int32, error) { ctx := builder.ctxByNode[nodeID] // check equal fulltext_match func and only compute once for equal function() eqmap := builder.findEqualFullTextMatchFunc(projNode, scanNode, projids, filterids) - idxID, filter_node_ids, proj_node_ids := builder.applyJoinFullTextIndices(nodeID, projNode, scanNode, + idxID, filter_node_ids, proj_node_ids, err := builder.applyJoinFullTextIndices(nodeID, projNode, scanNode, filterids, filterIndexDefs, projids, projIndexDef, eqmap, colRefCnt, idxColMap) + if err != nil { + return -1, err + } if sortNode != nil { sortNode.Children[0] = idxID @@ -131,7 +134,7 @@ func (builder *QueryBuilder) applyIndicesForProjectionUsingFullTextIndex(nodeID }, } } - return nodeID + return nodeID, nil } // mysql> explain select count(*) from src where match(title, body) against('d'); @@ -150,25 +153,29 @@ func (builder *QueryBuilder) applyIndicesForProjectionUsingFullTextIndex(nodeID // +----------------------------------------------------------------+ func (builder *QueryBuilder) applyIndicesForAggUsingFullTextIndex(nodeID int32, projNode *plan.Node, aggNode *plan.Node, scanNode *plan.Node, filterids []int32, filterIndexDefs []*plan.IndexDef, - colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) int32 { + colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) (int32, error) { + var err error projids := make([]int32, 0) projIndexDefs := make([]*plan.IndexDef, 0) eqmap := make(map[int32]int32) - idxID, _, _ := builder.applyJoinFullTextIndices(nodeID, projNode, scanNode, + idxID, _, _, err := builder.applyJoinFullTextIndices(nodeID, projNode, scanNode, filterids, filterIndexDefs, projids, projIndexDefs, eqmap, colRefCnt, idxColMap) + if err != nil { + return -1, err + } aggNode.Children[0] = idxID - return nodeID + return nodeID, nil } func (builder *QueryBuilder) applyJoinFullTextIndices(nodeID int32, projNode *plan.Node, scanNode *plan.Node, filterids []int32, filter_indexDefs []*plan.IndexDef, projids []int32, proj_indexDefs []*plan.IndexDef, eqmap map[int32]int32, - colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) (int32, []int32, []int32) { + colRefCnt map[[2]int32]int, idxColMap map[[2]int32]*plan.Expr) (int32, []int32, []int32, error) { ctx := builder.ctxByNode[nodeID] @@ -264,7 +271,7 @@ func (builder *QueryBuilder) applyJoinFullTextIndices(nodeID int32, projNode *pl curr_ftnode_id, err := builder.buildTable(tmpTableFunc, ctx, -1, nil) if err != nil { - panic(err.Error()) + return -1, nil, nil, err } // save the created fulltext node to either filter or projection @@ -283,7 +290,7 @@ func (builder *QueryBuilder) applyJoinFullTextIndices(nodeID int32, projNode *pl ret_proj_node_ids[v] = curr_ftnode_id } else { - panic(moerr.NewInternalError(builder.GetContext(), "Invalid ret_proj_node_ids_map")) + return -1, nil, nil, moerr.NewInternalError(builder.GetContext(), "Invalid ret_proj_node_ids_map") } } @@ -368,7 +375,7 @@ func (builder *QueryBuilder) applyJoinFullTextIndices(nodeID int32, projNode *pl scanNode.Limit = nil scanNode.Offset = nil - return joinnodeID, ret_filter_node_ids, ret_proj_node_ids + return joinnodeID, ret_filter_node_ids, ret_proj_node_ids, nil } func (builder *QueryBuilder) equalsFullTextMatchFunc(fn1 *plan.Function, fn2 *plan.Function) bool { diff --git a/pkg/sql/plan/build_ddl.go b/pkg/sql/plan/build_ddl.go index c8ddda8da511c..a13f3f63d8478 100644 --- a/pkg/sql/plan/build_ddl.go +++ b/pkg/sql/plan/build_ddl.go @@ -2657,6 +2657,8 @@ func buildTruncateTable(stmt *tree.TruncateTable, ctx CompilerContext) (*Plan, e } } else if indexdef.TableExist && catalog.IsMasterIndexAlgo(indexdef.IndexAlgo) { truncateTable.IndexTableNames = append(truncateTable.IndexTableNames, indexdef.IndexTableName) + } else if indexdef.TableExist && catalog.IsFullTextIndexAlgo(indexdef.IndexAlgo) { + truncateTable.IndexTableNames = append(truncateTable.IndexTableNames, indexdef.IndexTableName) } } } diff --git a/pkg/sql/plan/build_show_util.go b/pkg/sql/plan/build_show_util.go index 10a921e8110c3..66b0dcd1d5561 100644 --- a/pkg/sql/plan/build_show_util.go +++ b/pkg/sql/plan/build_show_util.go @@ -172,7 +172,12 @@ func ConstructCreateTableSQL(ctx CompilerContext, tableDef *plan.TableDef, snaps var indexStr string if !indexdef.Unique && catalog.IsFullTextIndexAlgo(indexdef.IndexAlgo) { - indexStr += " FULLTEXT(" + indexStr += " FULLTEXT " + + if len(indexdef.IndexName) > 0 { + indexStr += fmt.Sprintf("`%s`", formatStr(indexdef.IndexName)) + } + indexStr += "(" i := 0 for _, part := range indexdef.Parts { if catalog.IsAlias(part) { diff --git a/pkg/sql/plan/build_show_util_test.go b/pkg/sql/plan/build_show_util_test.go index bc3dda0acd147..30819bfae6c7c 100644 --- a/pkg/sql/plan/build_show_util_test.go +++ b/pkg/sql/plan/build_show_util_test.go @@ -118,7 +118,17 @@ func Test_buildTestShowCreateTable(t *testing.T) { PRIMARY KEY (id), FULLTEXT(json1) WITH PARSER json, FULLTEXT(json1,json2) WITH PARSER json)`, - want: "CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` json DEFAULT NULL,\n `json2` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`json1`) WITH PARSER json,\n FULLTEXT(`json1`,`json2`) WITH PARSER json\n)", + want: "CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` json DEFAULT NULL,\n `json2` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT (`json1`) WITH PARSER json,\n FULLTEXT (`json1`,`json2`) WITH PARSER json\n)", + }, + { + name: "test8", + sql: `CREATE TABLE src (id bigint NOT NULL, + json1 json DEFAULT NULL, + json2 json DEFAULT NULL, + PRIMARY KEY (id), + FULLTEXT idx01(json1) WITH PARSER json, + FULLTEXT idx02(json1,json2) WITH PARSER json)`, + want: "CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` json DEFAULT NULL,\n `json2` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT `idx01`(`json1`) WITH PARSER json,\n FULLTEXT `idx02`(`json1`,`json2`) WITH PARSER json\n)", }, } for _, tt := range tests { diff --git a/pkg/sql/plan/query_builder.go b/pkg/sql/plan/query_builder.go index aef8cda721be7..cd568d4a717f7 100644 --- a/pkg/sql/plan/query_builder.go +++ b/pkg/sql/plan/query_builder.go @@ -1871,6 +1871,7 @@ func (builder *QueryBuilder) removeUnnecessaryProjections(nodeID int32) int32 { } func (builder *QueryBuilder) createQuery() (*Query, error) { + var err error colRefBool := make(map[[2]int32]bool) sinkColRef := make(map[[2]int32]int) @@ -1925,7 +1926,10 @@ func (builder *QueryBuilder) createQuery() (*Query, error) { } // after determine shuffle, be careful when calling ReCalcNodeStats again. // needResetHashMapStats should always be false from here - rootID = builder.applyIndices(rootID, colRefCnt, make(map[[2]int32]*plan.Expr)) + rootID, err = builder.applyIndices(rootID, colRefCnt, make(map[[2]int32]*plan.Expr)) + if err != nil { + return nil, err + } ReCalcNodeStats(rootID, builder, true, false, false) builder.generateRuntimeFilters(rootID) @@ -1969,14 +1973,14 @@ func (builder *QueryBuilder) createQuery() (*Query, error) { colRefCnt[[2]int32{resultTag, int32(j)}] = 1 } } - _, err := builder.remapAllColRefs(rootID, int32(i), colRefCnt, colRefBool, sinkColRef) + _, err = builder.remapAllColRefs(rootID, int32(i), colRefCnt, colRefBool, sinkColRef) if err != nil { return nil, err } builder.qry.Steps[i] = builder.removeUnnecessaryProjections(rootID) } - err := builder.lockTableIfLockNoRowsAtTheEndForDelAndUpdate() + err = builder.lockTableIfLockNoRowsAtTheEndForDelAndUpdate() if err != nil { return nil, err } diff --git a/test/distributed/cases/fulltext/fulltext.result b/test/distributed/cases/fulltext/fulltext.result index 23b56545414cf..7a1b0f617d8c5 100644 --- a/test/distributed/cases/fulltext/fulltext.result +++ b/test/distributed/cases/fulltext/fulltext.result @@ -199,7 +199,7 @@ body VARCHAR(65535) YES MUL null title TEXT(0) YES null show create table src; Table Create Table -src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `body` varchar(65535) DEFAULT NULL,\n `title` text DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`body`,`title`),\n FULLTEXT(`body`)\n) +src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `body` varchar(65535) DEFAULT NULL,\n `title` text DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT `ftidx`(`body`,`title`),\n FULLTEXT `ftidx2`(`body`)\n) drop table src; create table src2 (id1 varchar, id2 bigint, body char(128), title text, primary key (id1, id2)); insert into src2 values ('id0', 0, 'red', 't1'), ('id1', 1, 'yellow', 't2'), ('id2', 2, 'blue', 't3'), ('id3', 3, 'blue red', 't4'); @@ -254,7 +254,7 @@ json1 JSON(0) YES MUL null json2 JSON(0) YES null show create table src; Table Create Table -src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` json DEFAULT NULL,\n `json2` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`json1`) WITH PARSER json,\n FULLTEXT(`json1`,`json2`) WITH PARSER json\n) +src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` json DEFAULT NULL,\n `json2` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT `ftidx`(`json1`) WITH PARSER json,\n FULLTEXT `ftidx2`(`json1`,`json2`) WITH PARSER json\n) drop table src; create table src (id bigint primary key, json1 text, json2 varchar); insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), @@ -282,7 +282,7 @@ json1 TEXT(0) YES MUL null json2 VARCHAR(65535) YES null show create table src; Table Create Table -src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` text DEFAULT NULL,\n `json2` varchar(65535) DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`json1`) WITH PARSER json,\n FULLTEXT(`json1`,`json2`) WITH PARSER json\n) +src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` text DEFAULT NULL,\n `json2` varchar(65535) DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT `ftidx`(`json1`) WITH PARSER json,\n FULLTEXT `ftidx2`(`json1`,`json2`) WITH PARSER json\n) drop table src; create table src (id bigint primary key, body varchar, title text, FULLTEXT(title, body)); insert into src values (0, 'color is red', 't1'), (1, 'car is yellow', 'crazy car'), (2, 'sky is blue', 'no limit'), (3, 'blue is not red', 'colorful'), @@ -296,6 +296,10 @@ insert into src values (0, 'color is red', 't1'), (1, 'car is yellow', 'crazy ca (10, NULL, NULL); select *, match(body) against('遠東兒童中文' in natural language mode) as score from src; not supported: MATCH() AGAINST() function cannot be replaced by FULLTEXT INDEX and full table scan with fulltext search is not supported yet. +select *, match(title, body) against('+Windows +(<"Photo" >defender)' in boolean mode) as score from src; +internal error: double operator +select *, match(title, body) against('+CC_BY +(<-1.0 >-SA-1.0)' in boolean mode) as score from src; +internal error: double operator select * from src where match(body, title) against('red'); id body title 0 color is red t1 @@ -390,7 +394,7 @@ body VARCHAR(65535) YES null title TEXT(0) YES MUL null show create table src; Table Create Table -src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `body` varchar(65535) DEFAULT NULL,\n `title` text DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`title`,`body`)\n) +src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `body` varchar(65535) DEFAULT NULL,\n `title` text DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT (`title`,`body`)\n) drop table src; create table src2 (id1 varchar, id2 bigint, body char(128), title text, primary key (id1, id2), FULLTEXT(body, title)); insert into src2 values ('id0', 0, 'red', 't1'), ('id1', 1, 'yellow', 't2'), ('id2', 2, 'blue', 't3'), ('id3', 3, 'blue red', 't4'); @@ -410,7 +414,7 @@ body CHAR(128) YES MUL null title TEXT(0) YES null show create table src2; Table Create Table -src2 CREATE TABLE `src2` (\n `id1` varchar(65535) NOT NULL,\n `id2` bigint NOT NULL,\n `body` char(128) DEFAULT NULL,\n `title` text DEFAULT NULL,\n PRIMARY KEY (`id1`,`id2`),\n FULLTEXT(`body`,`title`)\n) +src2 CREATE TABLE `src2` (\n `id1` varchar(65535) NOT NULL,\n `id2` bigint NOT NULL,\n `body` char(128) DEFAULT NULL,\n `title` text DEFAULT NULL,\n PRIMARY KEY (`id1`,`id2`),\n FULLTEXT (`body`,`title`)\n) drop table src2; create table src (id bigint primary key, json1 json, json2 json, FULLTEXT(json1) with parser json); insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), @@ -438,7 +442,7 @@ json1 JSON(0) YES MUL null json2 JSON(0) YES null show create table src; Table Create Table -src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` json DEFAULT NULL,\n `json2` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`json1`) WITH PARSER json,\n FULLTEXT(`json1`,`json2`) WITH PARSER json\n) +src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` json DEFAULT NULL,\n `json2` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT (`json1`) WITH PARSER json,\n FULLTEXT `ftidx2`(`json1`,`json2`) WITH PARSER json\n) drop table src; create table src (id bigint primary key, json1 text, json2 varchar, fulltext(json1) with parser json); insert into src values (0, '{"a":1, "b":"red"}', '{"d": "happy birthday", "f":"winter"}'), @@ -469,7 +473,7 @@ json1 TEXT(0) YES MUL null json2 VARCHAR(65535) YES null show create table src; Table Create Table -src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` text DEFAULT NULL,\n `json2` varchar(65535) DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`json1`) WITH PARSER json,\n FULLTEXT(`json1`,`json2`) WITH PARSER json\n) +src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` text DEFAULT NULL,\n `json2` varchar(65535) DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT (`json1`) WITH PARSER json,\n FULLTEXT `ftidx2`(`json1`,`json2`) WITH PARSER json\n) drop table src; drop table if exists t1; create table t1(a int primary key, b varchar(200)); diff --git a/test/distributed/cases/fulltext/fulltext.sql b/test/distributed/cases/fulltext/fulltext.sql index 72ee21b4dd1b9..fb19cfa8a649f 100644 --- a/test/distributed/cases/fulltext/fulltext.sql +++ b/test/distributed/cases/fulltext/fulltext.sql @@ -235,6 +235,8 @@ insert into src values (0, 'color is red', 't1'), (1, 'car is yellow', 'crazy ca -- check error select *, match(body) against('遠東兒童中文' in natural language mode) as score from src; +select *, match(title, body) against('+Windows +(<"Photo" >defender)' in boolean mode) as score from src; +select *, match(title, body) against('+CC_BY +(<-1.0 >-SA-1.0)' in boolean mode) as score from src; -- match in WHERE clause select * from src where match(body, title) against('red'); diff --git a/test/distributed/cases/fulltext/fulltext1.result b/test/distributed/cases/fulltext/fulltext1.result index ad86cfd2f9fcf..3992dd2d52c0f 100644 --- a/test/distributed/cases/fulltext/fulltext1.result +++ b/test/distributed/cases/fulltext/fulltext1.result @@ -5,7 +5,7 @@ use test; create table articles (id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(200), body TEXT, FULLTEXT (title,body)); show create table articles; Table Create Table -articles CREATE TABLE `articles` (\n `id` int unsigned NOT NULL AUTO_INCREMENT,\n `title` varchar(200) DEFAULT NULL,\n `body` text DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`title`,`body`)\n) +articles CREATE TABLE `articles` (\n `id` int unsigned NOT NULL AUTO_INCREMENT,\n `title` varchar(200) DEFAULT NULL,\n `body` text DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT (`title`,`body`)\n) drop table articles; create table articles (id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(200), body TEXT); create fulltext index fdx_01 on articles(title, body); @@ -23,7 +23,7 @@ create table src (id bigint primary key, json1 json, json2 json); create fulltext index ftidx1 on src(json1) with parser json; show create table src; Table Create Table -src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` json DEFAULT NULL,\n `json2` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`json1`) WITH PARSER json\n) +src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` json DEFAULT NULL,\n `json2` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT `ftidx1`(`json1`) WITH PARSER json\n) alter table src drop column json1; drop table src; create table articles (id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, title VARCHAR(200), body TEXT); diff --git a/test/distributed/cases/fulltext/fulltext2.result b/test/distributed/cases/fulltext/fulltext2.result index d930aa3e358e0..207b90a79c760 100644 --- a/test/distributed/cases/fulltext/fulltext2.result +++ b/test/distributed/cases/fulltext/fulltext2.result @@ -193,7 +193,7 @@ insert into articles (title, content) values ('ngram解析器', 'ngram解析器允许MO对中文等语言进行分词,以优化全文搜索。'); show create table articles; Table Create Table -articles CREATE TABLE `articles` (\n `id` int NOT NULL AUTO_INCREMENT,\n `title` varchar(255) DEFAULT NULL,\n `content` text DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`title`,`content`) WITH PARSER ngram\n) +articles CREATE TABLE `articles` (\n `id` int NOT NULL AUTO_INCREMENT,\n `title` varchar(255) DEFAULT NULL,\n `content` text DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT (`title`,`content`) WITH PARSER ngram\n) select * from articles where match(title, content) against('全文索引' IN NATURAL LANGUAGE MODE); id title content 1 MO全文索引示例 这是一个关于MO全文索引的例子。它展示了如何使用ngram解析器进行全文搜索。 @@ -214,7 +214,7 @@ insert into products (name, details) values ('스마트폰', '{"brand": "Apple", "model": "iPhone 12", "price": 800}'); show create table products; Table Create Table -products CREATE TABLE `products` (\n `id` int NOT NULL AUTO_INCREMENT,\n `name` varchar(255) DEFAULT NULL,\n `details` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`details`) WITH PARSER json\n) +products CREATE TABLE `products` (\n `id` int NOT NULL AUTO_INCREMENT,\n `name` varchar(255) DEFAULT NULL,\n `details` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT (`details`) WITH PARSER json\n) insert into products (name, details) values('手机', '{"brand": "Apple", "model": "iPhone 12", "price": 800}'); select * from products; id name details diff --git a/test/distributed/cases/snapshot/sys_restore_to_newnonsys_account.result b/test/distributed/cases/snapshot/sys_restore_to_newnonsys_account.result index 2898f3efd479a..d2b9f27cb1ee5 100644 --- a/test/distributed/cases/snapshot/sys_restore_to_newnonsys_account.result +++ b/test/distributed/cases/snapshot/sys_restore_to_newnonsys_account.result @@ -25,7 +25,7 @@ drop snapshot if exists sp01; create snapshot sp01 for account acc01; show snapshots; SNAPSHOT_NAME TIMESTAMP SNAPSHOT_LEVEL ACCOUNT_NAME DATABASE_NAME TABLE_NAME -sp01 2024-12-16 10:25:34.085639 account acc01 +sp01 2025-01-02 15:10:39.5826 account acc01 use acc_test01; insert into s3t values (300001, 34, 23, 1); select count(*) from s3t; @@ -329,8 +329,8 @@ drop snapshot if exists sp08; create snapshot sp08 for account acc01; show snapshots; SNAPSHOT_NAME TIMESTAMP SNAPSHOT_LEVEL ACCOUNT_NAME DATABASE_NAME TABLE_NAME -sp08 2024-12-16 10:25:40.505317 account acc01 -sp07 2024-12-16 10:25:40.40668 account acc01 +sp08 2025-01-02 15:10:40.539771 account acc01 +sp07 2025-01-02 15:10:40.525108 account acc01 restore account acc01 from snapshot sp07 to account acc02; restore account acc01 from snapshot sp08 to account acc02; use test01; @@ -449,7 +449,7 @@ system_metrics use fulltext_index_acc01; show create table articles; Table Create Table -articles CREATE TABLE `articles` (\n `id` int unsigned NOT NULL AUTO_INCREMENT,\n `title` json DEFAULT NULL,\n `body` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`title`,`body`) WITH PARSER json\n) +articles CREATE TABLE `articles` (\n `id` int unsigned NOT NULL AUTO_INCREMENT,\n `title` json DEFAULT NULL,\n `body` json DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT `fdx_01`(`title`,`body`) WITH PARSER json\n) select * from articles; id title body 1 {"title": "MO Tutorial"} {"body": "DBMS stands for DataBase ..."} diff --git a/test/distributed/cases/snapshot/sys_restore_to_nonsys_account.result b/test/distributed/cases/snapshot/sys_restore_to_nonsys_account.result index 186ee60a4778f..f7315d3b3c0ee 100644 --- a/test/distributed/cases/snapshot/sys_restore_to_nonsys_account.result +++ b/test/distributed/cases/snapshot/sys_restore_to_nonsys_account.result @@ -24,7 +24,7 @@ drop snapshot if exists sp01; create snapshot sp01 for account acc01; show snapshots; SNAPSHOT_NAME TIMESTAMP SNAPSHOT_LEVEL ACCOUNT_NAME DATABASE_NAME TABLE_NAME -sp01 2024-12-16 10:05:37.108041 account acc01 +sp01 2025-01-02 15:10:52.875489 account acc01 show snapshots; SNAPSHOT_NAME TIMESTAMP SNAPSHOT_LEVEL ACCOUNT_NAME DATABASE_NAME TABLE_NAME insert into s3t values (300001, 34, 23, 1); @@ -323,8 +323,8 @@ drop snapshot if exists sp08; create snapshot sp08 for account acc01; show snapshots; SNAPSHOT_NAME TIMESTAMP SNAPSHOT_LEVEL ACCOUNT_NAME DATABASE_NAME TABLE_NAME -sp08 2024-12-16 10:05:42.780808 account acc01 -sp07 2024-12-16 10:05:42.691639 account acc01 +sp08 2025-01-02 15:10:54.010556 account acc01 +sp07 2025-01-02 15:10:53.996763 account acc01 use test01; create table table03 (col1 int); insert into table03 values (1),(2); @@ -451,7 +451,7 @@ system_metrics use fulltext_acc01; show create table src; Table Create Table -src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` text DEFAULT NULL,\n `json2` varchar(65535) DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT(`json1`) WITH PARSER json\n) +src CREATE TABLE `src` (\n `id` bigint NOT NULL,\n `json1` text DEFAULT NULL,\n `json2` varchar(65535) DEFAULT NULL,\n PRIMARY KEY (`id`),\n FULLTEXT (`json1`) WITH PARSER json\n) select * from src; id json1 json2 0 {"a":1, "b":"red"} {"d": "happy birthday", "f":"winter"}