Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
40351e70
Unverified
提交
40351e70
authored
3月 06, 2018
作者:
Noel Grandin
提交者:
GitHub
3月 06, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #929 from katzyn/offset_fetch
Remove Mode.supportOffsetFetch
上级
fbde5208
3cbdbab9
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
38 行增加
和
54 行删除
+38
-54
DbContextRule.java
h2/src/main/org/h2/bnf/context/DbContextRule.java
+2
-2
Parser.java
h2/src/main/org/h2/command/Parser.java
+27
-31
Mode.java
h2/src/main/org/h2/engine/Mode.java
+0
-10
ParserUtil.java
h2/src/main/org/h2/util/ParserUtil.java
+9
-11
没有找到文件。
h2/src/main/org/h2/bnf/context/DbContextRule.java
浏览文件 @
40351e70
...
...
@@ -154,7 +154,7 @@ public class DbContextRule implements Rule {
break
;
}
String
alias
=
up
.
substring
(
0
,
i
);
if
(
ParserUtil
.
isKeyword
(
alias
,
true
))
{
if
(
ParserUtil
.
isKeyword
(
alias
))
{
break
;
}
s
=
s
.
substring
(
alias
.
length
());
...
...
@@ -301,7 +301,7 @@ public class DbContextRule implements Rule {
return
s
;
}
String
alias
=
up
.
substring
(
0
,
i
);
if
(
"SET"
.
equals
(
alias
)
||
ParserUtil
.
isKeyword
(
alias
,
true
))
{
if
(
"SET"
.
equals
(
alias
)
||
ParserUtil
.
isKeyword
(
alias
))
{
return
s
;
}
if
(
newAlias
)
{
...
...
h2/src/main/org/h2/command/Parser.java
浏览文件 @
40351e70
...
...
@@ -2022,38 +2022,34 @@ public class Parser {
command
.
setOrder
(
orderList
);
currentSelect
=
oldSelect
;
}
if
(
database
.
getMode
().
supportOffsetFetch
)
{
// make sure aggregate functions will not work here
Select
temp
=
currentSelect
;
currentSelect
=
null
;
// http://sqlpro.developpez.com/SQL2008/
if
(
readIf
(
"OFFSET"
))
{
command
.
setOffset
(
readExpression
().
optimize
(
session
));
if
(!
readIf
(
"ROW"
))
{
readIf
(
"ROWS"
);
}
// make sure aggregate functions will not work here
Select
temp
=
currentSelect
;
currentSelect
=
null
;
// http://sqlpro.developpez.com/SQL2008/
if
(
readIf
(
"OFFSET"
))
{
command
.
setOffset
(
readExpression
().
optimize
(
session
));
if
(!
readIf
(
"ROW"
))
{
readIf
(
"ROWS"
);
}
if
(
readIf
(
"FETCH"
))
{
if
(!
readIf
(
"FIRST
"
))
{
read
(
"NEXT"
);
}
if
(
readIf
(
"ROW"
))
{
command
.
setLimit
(
ValueExpression
.
get
(
ValueInt
.
get
(
1
)));
}
else
{
Expression
limit
=
readExpression
().
optimize
(
session
);
command
.
setLimit
(
limit
);
if
(!
readIf
(
"ROW"
))
{
read
(
"ROWS"
);
}
}
if
(
readIf
(
"FETCH
"
))
{
if
(!
readIf
(
"FIRST"
))
{
read
(
"NEXT"
);
}
if
(
readIf
(
"ROW"
))
{
command
.
setLimit
(
ValueExpression
.
get
(
ValueInt
.
get
(
1
)));
}
else
{
Expression
limit
=
readExpression
().
optimize
(
session
);
command
.
setLimit
(
limit
);
if
(!
readIf
(
"ROW"
))
{
read
(
"ROWS"
);
}
read
(
"ONLY"
);
}
currentSelect
=
temp
;
read
(
"ONLY"
);
}
currentSelect
=
temp
;
if
(
readIf
(
"LIMIT"
))
{
Select
temp
=
currentSelect
;
temp
=
currentSelect
;
// make sure aggregate functions will not work here
currentSelect
=
null
;
Expression
limit
=
readExpression
().
optimize
(
session
);
...
...
@@ -4195,7 +4191,7 @@ public class Parser {
// if not yet converted to uppercase, do it now
s
=
StringUtils
.
toUpperEnglish
(
s
);
}
return
getSaveTokenType
(
s
,
database
.
getMode
().
supportOffsetFetch
,
false
);
return
getSaveTokenType
(
s
,
false
);
}
private
boolean
isKeyword
(
String
s
)
{
...
...
@@ -4203,11 +4199,11 @@ public class Parser {
// if not yet converted to uppercase, do it now
s
=
StringUtils
.
toUpperEnglish
(
s
);
}
return
ParserUtil
.
isKeyword
(
s
,
false
);
return
ParserUtil
.
isKeyword
(
s
);
}
private
static
int
getSaveTokenType
(
String
s
,
boolean
supportOffsetFetch
,
boolean
functionsAsKeywords
)
{
return
ParserUtil
.
getSaveTokenType
(
s
,
supportOffsetFetch
,
functionsAsKeywords
);
private
static
int
getSaveTokenType
(
String
s
,
boolean
functionsAsKeywords
)
{
return
ParserUtil
.
getSaveTokenType
(
s
,
functionsAsKeywords
);
}
private
Column
parseColumnForTable
(
String
columnName
,
...
...
h2/src/main/org/h2/engine/Mode.java
浏览文件 @
40351e70
...
...
@@ -99,13 +99,6 @@ public class Mode {
*/
public
boolean
squareBracketQuotedNames
;
/**
* Support for the syntax
* [OFFSET .. ROW|ROWS] [FETCH FIRST .. ROW|ROWS ONLY]
* as an alternative for LIMIT .. OFFSET.
*/
public
boolean
supportOffsetFetch
=
Constants
.
VERSION_MINOR
>=
4
;
/**
* The system columns 'CTID' and 'OID' are supported.
*/
...
...
@@ -216,7 +209,6 @@ public class Mode {
mode
=
new
Mode
(
ModeEnum
.
DB2
.
name
());
mode
.
aliasColumnName
=
true
;
mode
.
supportOffsetFetch
=
true
;
mode
.
sysDummy1
=
true
;
mode
.
isolationLevelInSelectOrInsertStatement
=
true
;
// See
...
...
@@ -232,7 +224,6 @@ public class Mode {
mode
=
new
Mode
(
ModeEnum
.
Derby
.
name
());
mode
.
aliasColumnName
=
true
;
mode
.
uniqueIndexNullsHandling
=
UniqueIndexNullsHandling
.
FORBID_ANY_DUPLICATES
;
mode
.
supportOffsetFetch
=
true
;
mode
.
sysDummy1
=
true
;
mode
.
isolationLevelInSelectOrInsertStatement
=
true
;
// Derby does not support client info properties as of version 10.12.1.1
...
...
@@ -298,7 +289,6 @@ public class Mode {
mode
=
new
Mode
(
ModeEnum
.
PostgreSQL
.
name
());
mode
.
aliasColumnName
=
true
;
mode
.
nullConcatIsNull
=
true
;
mode
.
supportOffsetFetch
=
true
;
mode
.
systemColumns
=
true
;
mode
.
logIsLogBase10
=
true
;
mode
.
regexpReplaceBackslashReferences
=
true
;
...
...
h2/src/main/org/h2/util/ParserUtil.java
浏览文件 @
40351e70
...
...
@@ -45,14 +45,13 @@ public class ParserUtil {
* Checks if this string is a SQL keyword.
*
* @param s the token to check
* @param supportOffsetFetch if OFFSET and FETCH are keywords
* @return true if it is a keyword
*/
public
static
boolean
isKeyword
(
String
s
,
boolean
supportOffsetFetch
)
{
public
static
boolean
isKeyword
(
String
s
)
{
if
(
s
==
null
||
s
.
length
()
==
0
)
{
return
false
;
}
return
getSaveTokenType
(
s
,
supportOffsetFetch
,
false
)
!=
IDENTIFIER
;
return
getSaveTokenType
(
s
,
false
)
!=
IDENTIFIER
;
}
/**
...
...
@@ -79,18 +78,17 @@ public class ParserUtil {
return
false
;
}
}
return
getSaveTokenType
(
s
,
true
,
functionsAsKeywords
)
==
IDENTIFIER
;
return
getSaveTokenType
(
s
,
functionsAsKeywords
)
==
IDENTIFIER
;
}
/**
* Get the token type.
*
* @param s the token
* @param supportOffsetFetch whether offset / fetch are supported
* @param functionsAsKeywords whether "current data / time" functions are keywords
* @return the token type
*/
public
static
int
getSaveTokenType
(
String
s
,
boolean
supportOffsetFetch
,
boolean
functionsAsKeywords
)
{
public
static
int
getSaveTokenType
(
String
s
,
boolean
functionsAsKeywords
)
{
switch
(
s
.
charAt
(
0
))
{
case
'A'
:
return
getKeywordOrIdentifier
(
s
,
"ALL"
,
KEYWORD
);
...
...
@@ -116,7 +114,9 @@ public class ParserUtil {
}
return
getKeywordOrIdentifier
(
s
,
"EXISTS"
,
KEYWORD
);
case
'F'
:
if
(
"FROM"
.
equals
(
s
))
{
if
(
"FETCH"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
"FROM"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
"FOR"
.
equals
(
s
))
{
return
KEYWORD
;
...
...
@@ -124,8 +124,6 @@ public class ParserUtil {
return
KEYWORD
;
}
else
if
(
"FULL"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
supportOffsetFetch
&&
"FETCH"
.
equals
(
s
))
{
return
KEYWORD
;
}
return
getKeywordOrIdentifier
(
s
,
"FALSE"
,
FALSE
);
case
'G'
:
...
...
@@ -156,9 +154,9 @@ public class ParserUtil {
}
return
getKeywordOrIdentifier
(
s
,
"NULL"
,
NULL
);
case
'O'
:
if
(
"O
N
"
.
equals
(
s
))
{
if
(
"O
FFSET
"
.
equals
(
s
))
{
return
KEYWORD
;
}
else
if
(
supportOffsetFetch
&&
"OFFSET
"
.
equals
(
s
))
{
}
else
if
(
"ON
"
.
equals
(
s
))
{
return
KEYWORD
;
}
return
getKeywordOrIdentifier
(
s
,
"ORDER"
,
KEYWORD
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论