Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
5427bf61
Unverified
提交
5427bf61
authored
1月 19, 2018
作者:
Noel Grandin
提交者:
GitHub
1月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #788 from katzyn/keywords
Update lists of keywords
上级
1edf2411
19a51ca0
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
55 行增加
和
27 行删除
+55
-27
advanced.html
h2/src/docsrc/html/advanced.html
+4
-4
Parser.java
h2/src/main/org/h2/command/Parser.java
+35
-10
JdbcDatabaseMetaData.java
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
+9
-9
JdbcStatement.java
h2/src/main/org/h2/jdbc/JdbcStatement.java
+4
-3
TestMetaData.java
h2/src/test/org/h2/test/jdbc/TestMetaData.java
+1
-1
TestStatement.java
h2/src/test/org/h2/test/jdbc/TestStatement.java
+2
-0
没有找到文件。
h2/src/docsrc/html/advanced.html
浏览文件 @
5427bf61
...
@@ -500,10 +500,10 @@ There is a list of keywords that can't be used as identifiers (table names, colu
...
@@ -500,10 +500,10 @@ There is a list of keywords that can't be used as identifiers (table names, colu
unless they are quoted (surrounded with double quotes). The list is currently:
unless they are quoted (surrounded with double quotes). The list is currently:
</p><p>
</p><p>
<code>
<code>
CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DISTINCT, EXCEPT, EXISTS, FALSE
,
ALL, CHECK, CONSTRAINT, CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DISTINCT, EXCEPT
,
FETCH, FOR, FROM, FULL, GROUP, HAVING, INNER, INTERSECT, IS, JOIN, LIKE, LIMIT, MINUS, NATURAL
,
EXISTS, FALSE, FETCH, FOR, FOREIGN, FROM, FULL, GROUP, HAVING, INNER, INTERSECT, IS, JOIN
,
NOT, NULL, OFFSET, ON, ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY
,
LIKE, LIMIT, MINUS, NATURAL, NOT, NULL, OFFSET, ON, ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE
,
TRUE, UNION, UNIQUE, WHERE
SYSTIME, SYSTIMESTAMP, TODAY, TRUE, UNION, UNIQUE, WHERE, WITH
</code>
</code>
</p><p>
</p><p>
Certain words of this list are keywords because they are functions that can be used without '()' for compatibility,
Certain words of this list are keywords because they are functions that can be used without '()' for compatibility,
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
5427bf61
...
@@ -4146,7 +4146,7 @@ public class Parser {
...
@@ -4146,7 +4146,7 @@ public class Parser {
// if not yet converted to uppercase, do it now
// if not yet converted to uppercase, do it now
s
=
StringUtils
.
toUpperEnglish
(
s
);
s
=
StringUtils
.
toUpperEnglish
(
s
);
}
}
return
getSaveTokenType
(
s
,
database
.
getMode
().
supportOffsetFetch
);
return
getSaveTokenType
(
s
,
database
.
getMode
().
supportOffsetFetch
,
false
);
}
}
private
boolean
isKeyword
(
String
s
)
{
private
boolean
isKeyword
(
String
s
)
{
...
@@ -4168,20 +4168,27 @@ public class Parser {
...
@@ -4168,20 +4168,27 @@ public class Parser {
if
(
s
==
null
||
s
.
length
()
==
0
)
{
if
(
s
==
null
||
s
.
length
()
==
0
)
{
return
false
;
return
false
;
}
}
return
getSaveTokenType
(
s
,
supportOffsetFetch
)
!=
IDENTIFIER
;
return
getSaveTokenType
(
s
,
supportOffsetFetch
,
false
)
!=
IDENTIFIER
;
}
}
private
static
int
getSaveTokenType
(
String
s
,
boolean
supportOffsetFetch
)
{
private
static
int
getSaveTokenType
(
String
s
,
boolean
supportOffsetFetch
,
boolean
functionsAsKeywords
)
{
switch
(
s
.
charAt
(
0
))
{
switch
(
s
.
charAt
(
0
))
{
case
'A'
:
case
'A'
:
return
getKeywordOrIdentifier
(
s
,
"ALL"
,
KEYWORD
);
return
getKeywordOrIdentifier
(
s
,
"ALL"
,
KEYWORD
);
case
'C'
:
case
'C'
:
if
(
s
.
equals
(
"CHECK"
))
{
if
(
"CHECK"
.
equals
(
s
))
{
return
KEYWORD
;
return
KEYWORD
;
}
else
if
(
"CONSTRAINT"
.
equals
(
s
))
{
}
else
if
(
"CONSTRAINT"
.
equals
(
s
))
{
return
KEYWORD
;
return
KEYWORD
;
}
else
if
(
"CROSS"
.
equals
(
s
))
{
return
KEYWORD
;
}
if
(
functionsAsKeywords
)
{
if
(
"CURRENT_DATE"
.
equals
(
s
)
||
"CURRENT_TIME"
.
equals
(
s
)
||
"CURRENT_TIMESTAMP"
.
equals
(
s
))
{
return
KEYWORD
;
}
}
}
return
getKeywordOrIdentifier
(
s
,
"CROSS"
,
KEYWORD
)
;
return
IDENTIFIER
;
case
'D'
:
case
'D'
:
return
getKeywordOrIdentifier
(
s
,
"DISTINCT"
,
KEYWORD
);
return
getKeywordOrIdentifier
(
s
,
"DISTINCT"
,
KEYWORD
);
case
'E'
:
case
'E'
:
...
@@ -4241,9 +4248,25 @@ public class Parser {
...
@@ -4241,9 +4248,25 @@ public class Parser {
case
'R'
:
case
'R'
:
return
getKeywordOrIdentifier
(
s
,
"ROWNUM"
,
ROWNUM
);
return
getKeywordOrIdentifier
(
s
,
"ROWNUM"
,
ROWNUM
);
case
'S'
:
case
'S'
:
return
getKeywordOrIdentifier
(
s
,
"SELECT"
,
KEYWORD
);
if
(
"SELECT"
.
equals
(
s
))
{
return
KEYWORD
;
}
if
(
functionsAsKeywords
)
{
if
(
"SYSDATE"
.
equals
(
s
)
||
"SYSTIME"
.
equals
(
s
)
||
"SYSTIMESTAMP"
.
equals
(
s
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'T'
:
case
'T'
:
return
getKeywordOrIdentifier
(
s
,
"TRUE"
,
TRUE
);
if
(
"TRUE"
.
equals
(
s
))
{
return
TRUE
;
}
if
(
functionsAsKeywords
)
{
if
(
"TODAY"
.
equals
(
s
))
{
return
KEYWORD
;
}
}
return
IDENTIFIER
;
case
'U'
:
case
'U'
:
if
(
"UNIQUE"
.
equals
(
s
))
{
if
(
"UNIQUE"
.
equals
(
s
))
{
return
KEYWORD
;
return
KEYWORD
;
...
@@ -6851,7 +6874,7 @@ public class Parser {
...
@@ -6851,7 +6874,7 @@ public class Parser {
if
(
s
==
null
)
{
if
(
s
==
null
)
{
return
"\"\""
;
return
"\"\""
;
}
}
if
(
isSimpleIdentifier
(
s
))
if
(
isSimpleIdentifier
(
s
,
false
))
return
s
;
return
s
;
return
StringUtils
.
quoteIdentifier
(
s
);
return
StringUtils
.
quoteIdentifier
(
s
);
}
}
...
@@ -6859,10 +6882,12 @@ public class Parser {
...
@@ -6859,10 +6882,12 @@ public class Parser {
/**
/**
* @param s
* @param s
* identifier to check
* identifier to check
* @param functionsAsKeywords
* treat system functions as keywords
* @return is specified identifier may be used without quotes
* @return is specified identifier may be used without quotes
* @throws NullPointerException if s is {@code null}
* @throws NullPointerException if s is {@code null}
*/
*/
public
static
boolean
isSimpleIdentifier
(
String
s
)
{
public
static
boolean
isSimpleIdentifier
(
String
s
,
boolean
functionsAsKeywords
)
{
if
(
s
.
length
()
==
0
)
{
if
(
s
.
length
()
==
0
)
{
return
false
;
return
false
;
}
}
...
@@ -6878,7 +6903,7 @@ public class Parser {
...
@@ -6878,7 +6903,7 @@ public class Parser {
return
false
;
return
false
;
}
}
}
}
return
!
isKeyword
(
s
,
true
)
;
return
getSaveTokenType
(
s
,
true
,
functionsAsKeywords
)
==
IDENTIFIER
;
}
}
public
void
setLiteralsChecked
(
boolean
literalsChecked
)
{
public
void
setLiteralsChecked
(
boolean
literalsChecked
)
{
...
...
h2/src/main/org/h2/jdbc/JdbcDatabaseMetaData.java
浏览文件 @
5427bf61
...
@@ -1536,18 +1536,18 @@ public class JdbcDatabaseMetaData extends TraceObject implements
...
@@ -1536,18 +1536,18 @@ public class JdbcDatabaseMetaData extends TraceObject implements
/**
/**
* Gets the comma-separated list of all SQL keywords that are not supported
* Gets the comma-separated list of all SQL keywords that are not supported
* as table/column/index name, in addition to the SQL-
92
keywords. The list
* as table/column/index name, in addition to the SQL-
2003
keywords. The list
* returned is:
* returned is:
* <pre>
* <pre>
* LIMIT,MINUS,ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY
* LIMIT,MINUS,
OFFSET,
ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY
* </pre>
* </pre>
* The complete list of keywords (including SQL-
92
keywords) is:
* The complete list of keywords (including SQL-
2003
keywords) is:
* <pre>
* <pre>
*
CROSS, CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP, DISTINCT
,
*
ALL, CHECK, CONSTRAINT, CROSS, CURRENT_DATE, CURRENT_TIME
,
*
EXCEPT, EXISTS, FALSE, FOR, FROM, FULL, GROUP, HAVING, INNER
,
*
CURRENT_TIMESTAMP, DISTINCT, EXCEPT, EXISTS, FALSE, FETCH, FOR, FOREIGN
,
*
INTERSECT, IS, JOIN, LIKE, LIMIT, MINUS, NATURAL, NOT, NULL, ON
,
*
FROM, FULL, GROUP, HAVING, INNER, INTERSECT, IS, JOIN, LIKE, LIMIT
,
*
ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP
,
*
MINUS, NATURAL, NOT, NULL, OFFSET, ON, ORDER, PRIMARY, ROWNUM, SELECT
,
*
TODAY, TRUE, UNION, UNIQUE, WHERE
*
SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY, TRUE, UNION, UNIQUE, WHERE, WITH
* </pre>
* </pre>
*
*
* @return a list of additional the keywords
* @return a list of additional the keywords
...
@@ -1555,7 +1555,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
...
@@ -1555,7 +1555,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
@Override
@Override
public
String
getSQLKeywords
()
{
public
String
getSQLKeywords
()
{
debugCodeCall
(
"getSQLKeywords"
);
debugCodeCall
(
"getSQLKeywords"
);
return
"LIMIT,MINUS,ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY"
;
return
"LIMIT,MINUS,
OFFSET,
ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY"
;
}
}
/**
/**
...
...
h2/src/main/org/h2/jdbc/JdbcStatement.java
浏览文件 @
5427bf61
...
@@ -1320,9 +1320,10 @@ public class JdbcStatement extends TraceObject implements Statement, JdbcStateme
...
@@ -1320,9 +1320,10 @@ public class JdbcStatement extends TraceObject implements Statement, JdbcStateme
*/
*/
@Override
@Override
public
String
enquoteIdentifier
(
String
identifier
,
boolean
alwaysQuote
)
throws
SQLException
{
public
String
enquoteIdentifier
(
String
identifier
,
boolean
alwaysQuote
)
throws
SQLException
{
if
(
alwaysQuote
)
if
(
alwaysQuote
||
!
isSimpleIdentifier
(
identifier
))
{
return
StringUtils
.
quoteIdentifier
(
identifier
);
return
StringUtils
.
quoteIdentifier
(
identifier
);
return
Parser
.
quoteIdentifier
(
identifier
);
}
return
identifier
;
}
}
/**
/**
...
@@ -1332,7 +1333,7 @@ public class JdbcStatement extends TraceObject implements Statement, JdbcStateme
...
@@ -1332,7 +1333,7 @@ public class JdbcStatement extends TraceObject implements Statement, JdbcStateme
*/
*/
@Override
@Override
public
boolean
isSimpleIdentifier
(
String
identifier
)
throws
SQLException
{
public
boolean
isSimpleIdentifier
(
String
identifier
)
throws
SQLException
{
return
Parser
.
isSimpleIdentifier
(
identifier
);
return
Parser
.
isSimpleIdentifier
(
identifier
,
true
);
}
}
/**
/**
...
...
h2/src/test/org/h2/test/jdbc/TestMetaData.java
浏览文件 @
5427bf61
...
@@ -435,7 +435,7 @@ public class TestMetaData extends TestBase {
...
@@ -435,7 +435,7 @@ public class TestMetaData extends TestBase {
assertEquals
(
"schema"
,
meta
.
getSchemaTerm
());
assertEquals
(
"schema"
,
meta
.
getSchemaTerm
());
assertEquals
(
"\\"
,
meta
.
getSearchStringEscape
());
assertEquals
(
"\\"
,
meta
.
getSearchStringEscape
());
assertEquals
(
"LIMIT,MINUS,ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY"
,
assertEquals
(
"LIMIT,MINUS,
OFFSET,
ROWNUM,SYSDATE,SYSTIME,SYSTIMESTAMP,TODAY"
,
meta
.
getSQLKeywords
());
meta
.
getSQLKeywords
());
assertTrue
(
meta
.
getURL
().
startsWith
(
"jdbc:h2:"
));
assertTrue
(
meta
.
getURL
().
startsWith
(
"jdbc:h2:"
));
...
...
h2/src/test/org/h2/test/jdbc/TestStatement.java
浏览文件 @
5427bf61
...
@@ -334,11 +334,13 @@ public class TestStatement extends TestBase {
...
@@ -334,11 +334,13 @@ public class TestStatement extends TestBase {
assertEquals
(
"\"SOME_ID\""
,
statBC
.
enquoteIdentifier
(
"SOME_ID"
,
true
));
assertEquals
(
"\"SOME_ID\""
,
statBC
.
enquoteIdentifier
(
"SOME_ID"
,
true
));
assertEquals
(
"\"FROM\""
,
statBC
.
enquoteIdentifier
(
"FROM"
,
false
));
assertEquals
(
"\"FROM\""
,
statBC
.
enquoteIdentifier
(
"FROM"
,
false
));
assertEquals
(
"\"Test\""
,
statBC
.
enquoteIdentifier
(
"Test"
,
false
));
assertEquals
(
"\"Test\""
,
statBC
.
enquoteIdentifier
(
"Test"
,
false
));
assertEquals
(
"\"TODAY\""
,
statBC
.
enquoteIdentifier
(
"TODAY"
,
false
));
assertTrue
(
statBC
.
isSimpleIdentifier
(
"SOME_ID"
));
assertTrue
(
statBC
.
isSimpleIdentifier
(
"SOME_ID"
));
assertFalse
(
statBC
.
isSimpleIdentifier
(
"SOME ID"
));
assertFalse
(
statBC
.
isSimpleIdentifier
(
"SOME ID"
));
assertFalse
(
statBC
.
isSimpleIdentifier
(
"FROM"
));
assertFalse
(
statBC
.
isSimpleIdentifier
(
"FROM"
));
assertFalse
(
statBC
.
isSimpleIdentifier
(
"Test"
));
assertFalse
(
statBC
.
isSimpleIdentifier
(
"Test"
));
assertFalse
(
statBC
.
isSimpleIdentifier
(
"TODAY"
));
stat
.
close
();
stat
.
close
();
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论