Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
b6574a07
提交
b6574a07
authored
16 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fulltext search: new method FT_DROP_INDEX.
上级
9a0081ba
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
61 行增加
和
10 行删除
+61
-10
changelog.html
h2/src/docsrc/html/changelog.html
+3
-1
FullText.java
h2/src/main/org/h2/fulltext/FullText.java
+57
-8
fullTextSearch.sql
h2/src/test/org/h2/samples/fullTextSearch.sql
+1
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
b6574a07
...
...
@@ -18,7 +18,9 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
The optimization to group using an index didn't work in some cases in version 1.1
<ul><li>
The auto-reconnect feature didn't work when using the auto-server mode. Fixed.
</li><li>
Fulltext search: new method FT_DROP_INDEX.
</li><li>
The optimization to group using an index didn't work in some cases in version 1.1
(see also system property h2.optimizeGroupSorted).
</li><li>
OSGi meta data is included in the manifest file.
An OSGi BundleActivator is included: it loads the database driver when starting the bundle,
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/fulltext/FullText.java
浏览文件 @
b6574a07
...
...
@@ -99,20 +99,68 @@ public class FullText implements Trigger {
createTrigger
(
conn
,
schema
,
table
);
indexExistingRows
(
conn
,
schema
,
table
);
}
/**
* Drop an existing full text index for a table.
*
* @param conn the connection
* @param schema the schema name of the table
* @param table the table name
*/
public
static
void
dropIndex
(
Connection
conn
,
String
schema
,
String
table
)
throws
SQLException
{
init
(
conn
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"SELECT ID FROM "
+
SCHEMA
+
".INDEXES WHERE SCHEMA=? AND TABLE=?"
);
prep
.
setString
(
1
,
schema
);
prep
.
setString
(
2
,
table
);
ResultSet
rs
=
prep
.
executeQuery
();
if
(!
rs
.
next
())
{
return
;
}
int
indexId
=
rs
.
getInt
(
1
);
prep
=
conn
.
prepareStatement
(
"DELETE FROM "
+
SCHEMA
+
".INDEXES WHERE ID=?"
);
prep
.
setInt
(
1
,
indexId
);
prep
.
execute
();
createOrDropTrigger
(
conn
,
schema
,
table
,
false
);
prep
=
conn
.
prepareStatement
(
"DELETE FROM "
+
SCHEMA
+
".ROWS WHERE INDEXID=? AND ROWNUM<10000"
);
while
(
true
)
{
prep
.
setInt
(
1
,
indexId
);
int
deleted
=
prep
.
executeUpdate
();
if
(
deleted
==
0
)
{
break
;
}
}
prep
=
conn
.
prepareStatement
(
"DELETE FROM "
+
SCHEMA
+
".MAP M "
+
"WHERE NOT EXISTS (SELECT * FROM "
+
SCHEMA
+
".ROWS R WHERE R.ID=M.ROWID) AND ROWID<10000"
);
while
(
true
)
{
int
deleted
=
prep
.
executeUpdate
();
if
(
deleted
==
0
)
{
break
;
}
}
}
private
static
void
createTrigger
(
Connection
conn
,
String
schema
,
String
table
)
throws
SQLException
{
createOrDropTrigger
(
conn
,
schema
,
table
,
true
);
}
private
static
void
createOrDropTrigger
(
Connection
conn
,
String
schema
,
String
table
,
boolean
create
)
throws
SQLException
{
Statement
stat
=
conn
.
createStatement
();
String
trigger
=
StringUtils
.
quoteIdentifier
(
schema
)
+
"."
+
StringUtils
.
quoteIdentifier
(
TRIGGER_PREFIX
+
table
);
stat
.
execute
(
"DROP TRIGGER IF EXISTS "
+
trigger
);
StringBuffer
buff
=
new
StringBuffer
(
"CREATE TRIGGER IF NOT EXISTS "
);
buff
.
append
(
trigger
);
buff
.
append
(
" AFTER INSERT, UPDATE, DELETE ON "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
schema
)
+
"."
+
StringUtils
.
quoteIdentifier
(
table
));
buff
.
append
(
" FOR EACH ROW CALL \""
);
buff
.
append
(
FullText
.
class
.
getName
());
buff
.
append
(
"\""
);
stat
.
execute
(
buff
.
toString
());
if
(
create
)
{
StringBuffer
buff
=
new
StringBuffer
(
"CREATE TRIGGER IF NOT EXISTS "
);
buff
.
append
(
trigger
);
buff
.
append
(
" AFTER INSERT, UPDATE, DELETE ON "
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
schema
)
+
"."
+
StringUtils
.
quoteIdentifier
(
table
));
buff
.
append
(
" FOR EACH ROW CALL \""
);
buff
.
append
(
FullText
.
class
.
getName
());
buff
.
append
(
"\""
);
stat
.
execute
(
buff
.
toString
());
}
}
private
static
void
indexExistingRows
(
Connection
conn
,
String
schema
,
String
table
)
throws
SQLException
{
...
...
@@ -250,6 +298,7 @@ public class FullText implements Trigger {
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS "
+
SCHEMA
+
".IGNORELIST(LIST VARCHAR)"
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FT_CREATE_INDEX FOR \""
+
FullText
.
class
.
getName
()
+
".createIndex\""
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FT_DROP_INDEX FOR \""
+
FullText
.
class
.
getName
()
+
".dropIndex\""
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FT_SEARCH FOR \""
+
FullText
.
class
.
getName
()
+
".search\""
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FT_SEARCH_DATA FOR \""
+
FullText
.
class
.
getName
()
+
".searchData\""
);
stat
.
execute
(
"CREATE ALIAS IF NOT EXISTS FT_REINDEX FOR \""
+
FullText
.
class
.
getName
()
+
".reindex\""
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/fullTextSearch.sql
浏览文件 @
b6574a07
...
...
@@ -28,7 +28,7 @@ SELECT * FROM FT_SEARCH('World', 1, 0);
SELECT
*
FROM
FT_SEARCH
(
'World'
,
0
,
2
);
SELECT
*
FROM
FT_SEARCH
(
'World'
,
2
,
1
);
SELECT
*
FROM
FT_SEARCH
(
'1'
,
0
,
0
);
CALL
FT_DROP_
ALL
(
);
CALL
FT_DROP_
INDEX
(
'PUBLIC'
,
'TEST'
);
SELECT
*
FROM
FT_SEARCH
(
'World'
,
2
,
1
);
CALL
FT_DROP_ALL
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论