Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e862609d
提交
e862609d
authored
8月 05, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify execution flow in Query.initExpression()
上级
cbb4d2ac
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
33 行增加
和
49 行删除
+33
-49
Query.java
h2/src/main/org/h2/command/dml/Query.java
+33
-49
没有找到文件。
h2/src/main/org/h2/command/dml/Query.java
浏览文件 @
e862609d
...
@@ -451,83 +451,67 @@ public abstract class Query extends Prepared {
...
@@ -451,83 +451,67 @@ public abstract class Query extends Prepared {
// (oracle supports it, but only in order by, not in group by and
// (oracle supports it, but only in order by, not in group by and
// not in having):
// not in having):
// SELECT 1 AS A FROM DUAL ORDER BY -A
// SELECT 1 AS A FROM DUAL ORDER BY -A
boolean
isAlias
=
false
;
int
idx
=
expressions
.
size
();
if
(
e
instanceof
ExpressionColumn
)
{
if
(
e
instanceof
ExpressionColumn
)
{
// order by expression
// order by expression
ExpressionColumn
exprCol
=
(
ExpressionColumn
)
e
;
ExpressionColumn
exprCol
=
(
ExpressionColumn
)
e
;
String
tableAlias
=
exprCol
.
getOriginalTableAliasName
();
String
tableAlias
=
exprCol
.
getOriginalTableAliasName
();
String
col
=
exprCol
.
getOriginalColumnName
();
String
col
=
exprCol
.
getOriginalColumnName
();
for
(
int
j
=
0
;
j
<
visible
;
j
++)
{
for
(
int
j
=
0
;
j
<
visible
;
j
++)
{
boolean
found
=
false
;
Expression
ec
=
expressions
.
get
(
j
);
Expression
ec
=
expressions
.
get
(
j
);
if
(
ec
instanceof
ExpressionColumn
)
{
if
(
ec
instanceof
ExpressionColumn
)
{
// select expression
// select expression
ExpressionColumn
c
=
(
ExpressionColumn
)
ec
;
ExpressionColumn
c
=
(
ExpressionColumn
)
ec
;
found
=
db
.
equalsIdentifiers
(
col
,
c
.
getColumnName
());
if
(!
db
.
equalsIdentifiers
(
col
,
c
.
getColumnName
()))
{
if
(
found
&&
tableAlias
!=
null
)
{
continue
;
}
if
(
tableAlias
==
null
)
{
return
j
;
}
String
ca
=
c
.
getOriginalTableAliasName
();
String
ca
=
c
.
getOriginalTableAliasName
();
if
(
ca
==
null
)
{
if
(
ca
!=
null
)
{
found
=
false
;
if
(
db
.
equalsIdentifiers
(
ca
,
tableAlias
))
{
if
(
filters
!=
null
)
{
return
j
;
}
}
else
if
(
filters
!=
null
)
{
// select id from test order by test.id
// select id from test order by test.id
for
(
TableFilter
f
:
filters
)
{
for
(
TableFilter
f
:
filters
)
{
if
(
db
.
equalsIdentifiers
(
f
.
getTableAlias
(),
tableAlias
))
{
if
(
db
.
equalsIdentifiers
(
f
.
getTableAlias
(),
tableAlias
))
{
found
=
true
;
return
j
;
break
;
}
}
}
}
}
}
else
{
found
=
db
.
equalsIdentifiers
(
ca
,
tableAlias
);
}
}
}
else
if
(
ec
instanceof
Alias
)
{
if
(
tableAlias
==
null
&&
db
.
equalsIdentifiers
(
col
,
ec
.
getAlias
()))
{
return
j
;
}
}
}
else
if
(!(
ec
instanceof
Alias
))
{
continue
;
}
else
if
(
tableAlias
==
null
&&
db
.
equalsIdentifiers
(
col
,
ec
.
getAlias
()))
{
found
=
true
;
}
else
{
Expression
ec2
=
ec
.
getNonAliasExpression
();
Expression
ec2
=
ec
.
getNonAliasExpression
();
if
(
ec2
instanceof
ExpressionColumn
)
{
if
(
ec2
instanceof
ExpressionColumn
)
{
ExpressionColumn
c2
=
(
ExpressionColumn
)
ec2
;
ExpressionColumn
c2
=
(
ExpressionColumn
)
ec2
;
String
ta
=
exprCol
.
getSQL
();
String
ta
=
exprCol
.
getSQL
();
String
tb
=
c2
.
getSQL
();
String
tb
=
c2
.
getSQL
();
String
s2
=
c2
.
getColumnName
();
String
s2
=
c2
.
getColumnName
();
found
=
db
.
equalsIdentifiers
(
col
,
s2
);
if
(
db
.
equalsIdentifiers
(
col
,
s2
)
&&
db
.
equalsIdentifiers
(
ta
,
tb
))
{
if
(!
db
.
equalsIdentifiers
(
ta
,
tb
))
{
return
j
;
found
=
false
;
}
}
}
}
}
}
if
(
found
)
{
idx
=
j
;
isAlias
=
true
;
break
;
}
}
}
}
else
if
(
expressionSQL
!=
null
)
{
}
else
{
String
s
=
e
.
getSQL
();
String
s
=
e
.
getSQL
();
if
(
expressionSQL
!=
null
)
{
for
(
int
j
=
0
,
size
=
expressionSQL
.
size
();
j
<
size
;
j
++)
{
for
(
int
j
=
0
,
size
=
expressionSQL
.
size
();
j
<
size
;
j
++)
{
String
s2
=
expressionSQL
.
get
(
j
);
if
(
db
.
equalsIdentifiers
(
expressionSQL
.
get
(
j
),
s
))
{
if
(
db
.
equalsIdentifiers
(
s2
,
s
))
{
return
j
;
idx
=
j
;
isAlias
=
true
;
break
;
}
}
}
}
}
}
}
if
(!
isAlias
)
{
if
(
expressionSQL
==
null
if
(
expressionSQL
==
null
||
mustBeInResult
&&
session
.
getDatabase
().
getMode
().
getEnum
()
!=
ModeEnum
.
MySQL
||
mustBeInResult
&&
session
.
getDatabase
().
getMode
().
getEnum
()
!=
ModeEnum
.
MySQL
&&
!
checkOrderOther
(
session
,
e
,
expressionSQL
))
{
&&
!
checkOrderOther
(
session
,
e
,
expressionSQL
))
{
throw
DbException
.
get
(
ErrorCode
.
ORDER_BY_NOT_IN_RESULT
,
e
.
getSQL
());
throw
DbException
.
get
(
ErrorCode
.
ORDER_BY_NOT_IN_RESULT
,
e
.
getSQL
());
}
}
int
idx
=
expressions
.
size
();
expressions
.
add
(
e
);
expressions
.
add
(
e
);
String
sql
=
e
.
getSQL
();
expressionSQL
.
add
(
e
.
getSQL
());
expressionSQL
.
add
(
sql
);
}
return
idx
;
return
idx
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论