Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ed78fae8
提交
ed78fae8
authored
12月 18, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Parse datetime value functions as keywords unconditionally
上级
b1da72bd
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
62 行增加
和
29 行删除
+62
-29
Parser.java
h2/src/main/org/h2/command/Parser.java
+41
-17
ParserUtil.java
h2/src/main/org/h2/util/ParserUtil.java
+21
-12
没有找到文件。
h2/src/main/org/h2/command/Parser.java
浏览文件 @
ed78fae8
...
...
@@ -12,6 +12,9 @@ import static org.h2.util.ParserUtil.ALL;
import
static
org
.
h2
.
util
.
ParserUtil
.
CHECK
;
import
static
org
.
h2
.
util
.
ParserUtil
.
CONSTRAINT
;
import
static
org
.
h2
.
util
.
ParserUtil
.
CROSS
;
import
static
org
.
h2
.
util
.
ParserUtil
.
CURRENT_DATE
;
import
static
org
.
h2
.
util
.
ParserUtil
.
CURRENT_TIME
;
import
static
org
.
h2
.
util
.
ParserUtil
.
CURRENT_TIMESTAMP
;
import
static
org
.
h2
.
util
.
ParserUtil
.
DISTINCT
;
import
static
org
.
h2
.
util
.
ParserUtil
.
EXCEPT
;
import
static
org
.
h2
.
util
.
ParserUtil
.
EXISTS
;
...
...
@@ -30,6 +33,8 @@ import static org.h2.util.ParserUtil.IS;
import
static
org
.
h2
.
util
.
ParserUtil
.
JOIN
;
import
static
org
.
h2
.
util
.
ParserUtil
.
LIKE
;
import
static
org
.
h2
.
util
.
ParserUtil
.
LIMIT
;
import
static
org
.
h2
.
util
.
ParserUtil
.
LOCALTIME
;
import
static
org
.
h2
.
util
.
ParserUtil
.
LOCALTIMESTAMP
;
import
static
org
.
h2
.
util
.
ParserUtil
.
MINUS
;
import
static
org
.
h2
.
util
.
ParserUtil
.
NATURAL
;
import
static
org
.
h2
.
util
.
ParserUtil
.
NOT
;
...
...
@@ -457,6 +462,10 @@ public class Parser {
"LIKE"
,
// LIMIT
"LIMIT"
,
// LOCALTIME
"LOCALTIME"
,
// LOCALTIMESTAMP
"LOCALTIMESTAMP"
,
// MINUS
"MINUS"
,
// NATURAL
...
...
@@ -3523,6 +3532,14 @@ public class Parser {
}
}
private
Expression
readKeywordFunction
(
String
name
)
{
if
(
readIf
(
OPEN_PAREN
))
{
return
readFunction
(
null
,
name
);
}
else
{
return
readFunctionWithoutParameters
(
name
);
}
}
private
Expression
readFunctionWithoutParameters
(
String
name
)
{
if
(
database
.
isAllowBuiltinAliasOverride
())
{
FunctionAlias
functionAlias
=
database
.
getSchema
(
session
.
getCurrentSchemaName
()).
findFunction
(
name
);
...
...
@@ -3806,6 +3823,26 @@ public class Parser {
r
=
ValueExpression
.
get
(
currentValue
);
read
();
break
;
case
CURRENT_DATE:
read
();
r
=
readKeywordFunction
(
"CURRENT_DATE"
);
break
;
case
CURRENT_TIME:
read
();
r
=
readKeywordFunction
(
"CURRENT_TIME"
);
break
;
case
CURRENT_TIMESTAMP:
read
();
r
=
readKeywordFunction
(
"CURRENT_TIMESTAMP"
);
break
;
case
LOCALTIME:
read
();
r
=
readKeywordFunction
(
"LOCALTIME"
);
break
;
case
LOCALTIMESTAMP:
read
();
r
=
readKeywordFunction
(
"LOCALTIMESTAMP"
);
break
;
default
:
throw
getSyntaxError
();
}
...
...
@@ -3862,13 +3899,7 @@ public class Parser {
break
;
case
'C'
:
case
'c'
:
if
(
equalsToken
(
"CURRENT_DATE"
,
name
))
{
return
readFunctionWithoutParameters
(
"CURRENT_DATE"
);
}
else
if
(
equalsToken
(
"CURRENT_TIME"
,
name
))
{
return
readFunctionWithoutParameters
(
"CURRENT_TIME"
);
}
else
if
(
equalsToken
(
"CURRENT_TIMESTAMP"
,
name
))
{
return
readFunctionWithoutParameters
(
"CURRENT_TIMESTAMP"
);
}
else
if
(
equalsToken
(
"CURRENT_USER"
,
name
))
{
if
(
equalsToken
(
"CURRENT_USER"
,
name
))
{
return
readFunctionWithoutParameters
(
"USER"
);
}
else
if
(
database
.
getMode
().
getEnum
()
==
ModeEnum
.
DB2
&&
equalsToken
(
"CURRENT"
,
name
))
{
return
parseDB2SpecialRegisters
(
name
);
...
...
@@ -3902,14 +3933,6 @@ public class Parser {
return
readInterval
();
}
break
;
case
'L'
:
case
'l'
:
if
(
equalsToken
(
"LOCALTIME"
,
name
))
{
return
readFunctionWithoutParameters
(
"LOCALTIME"
);
}
else
if
(
equalsToken
(
"LOCALTIMESTAMP"
,
name
))
{
return
readFunctionWithoutParameters
(
"LOCALTIMESTAMP"
);
}
break
;
case
'N'
:
case
'n'
:
if
(
equalsToken
(
"NEXT"
,
name
)
&&
readIf
(
"VALUE"
))
{
...
...
@@ -4061,10 +4084,11 @@ public class Parser {
if
(
readIf
(
WITH
))
{
read
(
"TIME"
);
read
(
"ZONE"
);
return
read
FunctionWithoutParameters
(
"CURRENT_TIMESTAMP"
);
return
read
KeywordFunction
(
"CURRENT_TIMESTAMP"
);
}
return
read
FunctionWithoutParameters
(
"LOCALTIMESTAMP"
);
return
read
KeywordFunction
(
"LOCALTIMESTAMP"
);
}
else
if
(
readIf
(
"TIME"
))
{
// Time with fractional seconds is not supported by DB2
return
readFunctionWithoutParameters
(
"CURRENT_TIME"
);
}
else
if
(
readIf
(
"DATE"
))
{
return
readFunctionWithoutParameters
(
"CURRENT_DATE"
);
...
...
h2/src/main/org/h2/util/ParserUtil.java
浏览文件 @
ed78fae8
...
...
@@ -137,10 +137,20 @@ public class ParserUtil {
*/
public
static
final
int
LIMIT
=
LIKE
+
1
;
/**
* The token "LOCALTIME".
*/
public
static
final
int
LOCALTIME
=
LIMIT
+
1
;
/**
* The token "LOCALTIMESTAMP".
*/
public
static
final
int
LOCALTIMESTAMP
=
LOCALTIME
+
1
;
/**
* The token "MINUS".
*/
public
static
final
int
MINUS
=
L
IMIT
+
1
;
public
static
final
int
MINUS
=
L
OCALTIMESTAMP
+
1
;
/**
* The token "NATURAL".
...
...
@@ -311,12 +321,12 @@ public class ParserUtil {
return
CONSTRAINT
;
}
else
if
(
eq
(
"CROSS"
,
s
,
ignoreCase
,
start
,
end
))
{
return
CROSS
;
}
if
(
additionalKeywords
)
{
if
(
eq
(
"CURRENT_DATE"
,
s
,
ignoreCase
,
start
,
end
)
||
eq
(
"CURRENT_TIME"
,
s
,
ignoreCase
,
start
,
end
)
||
eq
(
"CURRENT_TIMESTAMP"
,
s
,
ignoreCase
,
start
,
end
))
{
return
KEYWORD
;
}
}
else
if
(
eq
(
"CURRENT_DATE"
,
s
,
ignoreCase
,
start
,
end
))
{
return
CURRENT_DATE
;
}
else
if
(
eq
(
"CURRENT_TIME"
,
s
,
ignoreCase
,
start
,
end
))
{
return
CURRENT_TIME
;
}
else
if
(
eq
(
"CURRENT_TIMESTAMP"
,
s
,
ignoreCase
,
start
,
end
))
{
return
CURRENT_TIMESTAMP
;
}
return
IDENTIFIER
;
case
'D'
:
...
...
@@ -380,11 +390,10 @@ public class ParserUtil {
return
LIMIT
;
}
else
if
(
eq
(
"LIKE"
,
s
,
ignoreCase
,
start
,
end
))
{
return
LIKE
;
}
if
(
additionalKeywords
)
{
if
(
eq
(
"LOCALTIME"
,
s
,
ignoreCase
,
start
,
end
)
||
eq
(
"LOCALTIMESTAMP"
,
s
,
ignoreCase
,
start
,
end
))
{
return
KEYWORD
;
}
}
else
if
(
eq
(
"LOCALTIME"
,
s
,
ignoreCase
,
start
,
end
))
{
return
LOCALTIME
;
}
else
if
(
eq
(
"LOCALTIMESTAMP"
,
s
,
ignoreCase
,
start
,
end
))
{
return
LOCALTIMESTAMP
;
}
return
IDENTIFIER
;
case
'M'
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论