Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
fe046888
提交
fe046888
authored
2月 27, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more context-sensitive keywords
上级
997e2d98
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
102 行增加
和
11 行删除
+102
-11
advanced.html
h2/src/docsrc/html/advanced.html
+18
-0
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+38
-10
ParserUtil.java
h2/src/main/org/h2/util/ParserUtil.java
+32
-0
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+8
-1
TestKeywords.java
h2/src/test/org/h2/test/unit/TestKeywords.java
+6
-0
没有找到文件。
h2/src/docsrc/html/advanced.html
浏览文件 @
fe046888
...
...
@@ -490,8 +490,14 @@ The following tokens are keywords in H2:
<tbody>
<tr><td>
ALL
</td>
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
AND
</td>
<td>
CS
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
ARRAY
</td>
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td></td></tr>
<tr><td>
AS
</td>
<td>
CS
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
BETWEEN
</td>
<td>
CS
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
NR
</td><td>
+
</td></tr>
<tr><td>
CASE
</td>
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
CHECK
</td>
...
...
@@ -518,6 +524,8 @@ The following tokens are keywords in H2:
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
FETCH
</td>
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
FILTER
</td>
<td>
CS
</td><td>
+
</td><td>
+
</td><td>
+
</td><td></td><td></td></tr>
<tr><td>
FOR
</td>
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
FOREIGN
</td>
...
...
@@ -532,6 +540,10 @@ The following tokens are keywords in H2:
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
IF
</td>
<td>
+
</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>
ILIKE
</td>
<td>
CS
</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>
IN
</td>
<td>
CS
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
INNER
</td>
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
INTERSECT
</td>
...
...
@@ -564,12 +576,18 @@ The following tokens are keywords in H2:
<td>
+
</td><td>
+
</td><td>
+
</td><td></td><td></td><td></td></tr>
<tr><td>
ON
</td>
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
OR
</td>
<td>
CS
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
ORDER
</td>
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
OVER
</td>
<td>
CS
</td><td>
+
</td><td>
+
</td><td>
+
</td><td></td><td></td></tr>
<tr><td>
PRIMARY
</td>
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td></tr>
<tr><td>
QUALIFY
</td>
<td>
+
</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>
REGEXP
</td>
<td>
CS
</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>
ROW
</td>
<td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td>
+
</td><td></td></tr>
<tr><td>
_ROWID_
</td>
...
...
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
fe046888
...
...
@@ -1542,18 +1542,39 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* table/column/index name, in addition to the SQL-2003 keywords. The list
* returned is:
* <pre>
* INTERSECTS,LIMIT,MINUS,OFFSET,QUALIFY,ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY,TOP
* IF,ILIKE,INTERSECTS,
* LIMIT,
* MINUS,
* OFFSET,
* QUALIFY,
* REGEXP,_ROWID_,ROWNUM,
* SYSDATE,SYSTIME,SYSTIMESTAMP,
* TODAY,TOP
* </pre>
* The complete list of keywords (including SQL-2003 keywords) is:
* <pre>
* ALL, ARRAY, CASE, CHECK, CONSTRAINT, CROSS, CURRENT_DATE,
* CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER, DISTINCT, EXCEPT,
* EXISTS, FALSE, FETCH, FOR, FOREIGN, FROM, FULL, GROUP, HAVING,
* IF, INNER, INTERSECT, INTERSECTS, INTERVAL, IS, JOIN, LIKE,
* LIMIT, LOCALTIME, LOCALTIMESTAMP, MINUS, NATURAL, NOT, NULL,
* OFFSET, ON, ORDER, PRIMARY, QUALIFY, ROW, _ROWID_, ROWNUM, SELECT,
* SYSDATE, SYSTIME, SYSTIMESTAMP, TABLE, TODAY, TOP, TRUE, UNION,
* UNIQUE, VALUES, WHERE, WINDOW, WITH
* ALL, AND, ARRAY, AS,
* BETWEEN,
* CASE, CHECK, CONSTRAINT, CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_USER,
* DISTINCT,
* EXCEPT, EXISTS,
* FALSE, FETCH, FILTER, FOR, FOREIGN, FROM, FULL,
* GROUP,
* HAVING,
* IF, ILIKE, IN, INNER, INTERSECT, INTERSECTS, INTERVAL, IS,
* JOIN,
* LIKE, LIMIT, LOCALTIME, LOCALTIMESTAMP,
* MINUS,
* NATURAL, NOT, NULL,
* OFFSET, ON, OR, ORDER, OVER,
* PRIMARY,
* QUALIFY,
* REGEXP, ROW, _ROWID_, ROWNUM,
* SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP,
* TABLE, TODAY, TOP, TRUE,
* UNION, UNIQUE,
* VALUES,
* WHERE, WINDOW, WITH
* </pre>
*
* @return a list of additional the keywords
...
...
@@ -1561,7 +1582,14 @@ public class JdbcDatabaseMetaData extends TraceObject implements
@Override
public
String
getSQLKeywords
()
{
debugCodeCall
(
"getSQLKeywords"
);
return
"IF,INTERSECTS,LIMIT,MINUS,OFFSET,QUALIFY,_ROWID_,ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY,TOP"
;
return
"IF,ILIKE,INTERSECTS,"
//
+
"LIMIT,"
//
+
"MINUS,"
//
+
"OFFSET,"
//
+
"QUALIFY,"
//
+
"REGEXP,_ROWID_,ROWNUM,"
//
+
"SYSDATE,SYSTIME,SYSTIMESTAMP,"
//
+
"TODAY,TOP"
;
}
/**
...
...
h2/src/main/org/h2/util/ParserUtil.java
浏览文件 @
fe046888
...
...
@@ -367,6 +367,18 @@ public class ParserUtil {
}
else
if
(
eq
(
"ARRAY"
,
s
,
ignoreCase
,
start
,
end
))
{
return
ARRAY
;
}
if
(
additionalKeywords
)
{
if
(
eq
(
"AND"
,
s
,
ignoreCase
,
start
,
end
)
||
eq
(
"AS"
,
s
,
ignoreCase
,
start
,
end
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'B'
:
if
(
additionalKeywords
)
{
if
(
eq
(
"BETWEEN"
,
s
,
ignoreCase
,
start
,
end
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'C'
:
if
(
eq
(
"CASE"
,
s
,
ignoreCase
,
start
,
end
))
{
...
...
@@ -413,6 +425,11 @@ public class ParserUtil {
}
else
if
(
eq
(
"FALSE"
,
s
,
ignoreCase
,
start
,
end
))
{
return
FALSE
;
}
if
(
additionalKeywords
)
{
if
(
eq
(
"FILTER"
,
s
,
ignoreCase
,
start
,
end
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'G'
:
if
(
eq
(
"GROUP"
,
s
,
ignoreCase
,
start
,
end
))
{
...
...
@@ -438,6 +455,11 @@ public class ParserUtil {
}
else
if
(
eq
(
"IS"
,
s
,
ignoreCase
,
start
,
end
))
{
return
IS
;
}
if
(
additionalKeywords
)
{
if
(
eq
(
"ILIKE"
,
s
,
ignoreCase
,
start
,
end
)
||
eq
(
"IN"
,
s
,
ignoreCase
,
start
,
end
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'J'
:
if
(
eq
(
"JOIN"
,
s
,
ignoreCase
,
start
,
end
))
{
...
...
@@ -477,6 +499,11 @@ public class ParserUtil {
}
else
if
(
eq
(
"ORDER"
,
s
,
ignoreCase
,
start
,
end
))
{
return
ORDER
;
}
if
(
additionalKeywords
)
{
if
(
eq
(
"OR"
,
s
,
ignoreCase
,
start
,
end
)
||
eq
(
"OVER"
,
s
,
ignoreCase
,
start
,
end
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'P'
:
if
(
eq
(
"PRIMARY"
,
s
,
ignoreCase
,
start
,
end
))
{
...
...
@@ -494,6 +521,11 @@ public class ParserUtil {
}
else
if
(
eq
(
"ROWNUM"
,
s
,
ignoreCase
,
start
,
end
))
{
return
ROWNUM
;
}
if
(
additionalKeywords
)
{
if
(
eq
(
"REGEXP"
,
s
,
ignoreCase
,
start
,
end
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'S'
:
if
(
eq
(
"SELECT"
,
s
,
ignoreCase
,
start
,
end
))
{
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
fe046888
...
...
@@ -463,7 +463,14 @@ public class TestMetaData extends TestDb {
assertEquals
(
"schema"
,
meta
.
getSchemaTerm
());
assertEquals
(
"\\"
,
meta
.
getSearchStringEscape
());
assertEquals
(
"IF,INTERSECTS,LIMIT,MINUS,OFFSET,QUALIFY,_ROWID_,ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY,TOP"
,
assertEquals
(
"IF,ILIKE,INTERSECTS,"
//
+
"LIMIT,"
//
+
"MINUS,"
//
+
"OFFSET,"
//
+
"QUALIFY,"
//
+
"REGEXP,_ROWID_,ROWNUM,"
//
+
"SYSDATE,SYSTIME,SYSTIMESTAMP,"
//
+
"TODAY,TOP"
,
//
meta
.
getSQLKeywords
());
assertTrue
(
meta
.
getURL
().
startsWith
(
"jdbc:h2:"
));
...
...
h2/src/test/org/h2/test/unit/TestKeywords.java
浏览文件 @
fe046888
...
...
@@ -87,6 +87,12 @@ public class TestKeywords extends TestBase {
assertEquals
(
10
,
rs
.
getInt
(
1
));
assertFalse
(
rs
.
next
());
}
try
(
ResultSet
rs
=
stat
.
executeQuery
(
"SELECT SUM("
+
s
+
") "
+
s
+
" FROM "
+
s
))
{
assertTrue
(
rs
.
next
());
assertEquals
(
10
,
rs
.
getInt
(
1
));
assertFalse
(
rs
.
next
());
assertEquals
(
s
,
rs
.
getMetaData
().
getColumnLabel
(
1
));
}
}
catch
(
Throwable
t
)
{
throw
new
AssertionError
(
s
+
" cannot be used as identifier."
,
t
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论