Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
62f49f0b
提交
62f49f0b
authored
1月 16, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not sort index-sorted results with WITH TIES again
上级
bcdfb4a8
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
33 行增加
和
27 行删除
+33
-27
Select.java
h2/src/main/org/h2/command/dml/Select.java
+5
-3
SelectUnion.java
h2/src/main/org/h2/command/dml/SelectUnion.java
+3
-1
LocalResult.java
h2/src/main/org/h2/result/LocalResult.java
+11
-3
LocalResultImpl.java
h2/src/main/org/h2/result/LocalResultImpl.java
+10
-17
ResultTarget.java
h2/src/main/org/h2/result/ResultTarget.java
+3
-3
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-0
没有找到文件。
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
62f49f0b
...
@@ -774,7 +774,7 @@ public class Select extends Query {
...
@@ -774,7 +774,7 @@ public class Select extends Query {
}
}
boolean
fetchPercent
=
this
.
fetchPercent
;
boolean
fetchPercent
=
this
.
fetchPercent
;
if
(
fetchPercent
)
{
if
(
fetchPercent
)
{
// Need to check it
r
ow, because negative limit has special treatment later
// Need to check it
n
ow, because negative limit has special treatment later
if
(
limitRows
<
0
||
limitRows
>
100
)
{
if
(
limitRows
<
0
||
limitRows
>
100
)
{
throw
DbException
.
getInvalidValueException
(
"FETCH PERCENT"
,
limitRows
);
throw
DbException
.
getInvalidValueException
(
"FETCH PERCENT"
,
limitRows
);
}
}
...
@@ -803,7 +803,7 @@ public class Select extends Query {
...
@@ -803,7 +803,7 @@ public class Select extends Query {
}
}
// Do not add rows before OFFSET to result if possible
// Do not add rows before OFFSET to result if possible
boolean
quickOffset
=
!
fetchPercent
;
boolean
quickOffset
=
!
fetchPercent
;
if
(
sort
!=
null
&&
(!
sortUsingIndex
||
isAnyDistinct
()
||
withTies
))
{
if
(
sort
!=
null
&&
(!
sortUsingIndex
||
isAnyDistinct
()))
{
result
=
createLocalResult
(
result
);
result
=
createLocalResult
(
result
);
result
.
setSortOrder
(
sort
);
result
.
setSortOrder
(
sort
);
if
(!
sortUsingIndex
)
{
if
(!
sortUsingIndex
)
{
...
@@ -886,7 +886,9 @@ public class Select extends Query {
...
@@ -886,7 +886,9 @@ public class Select extends Query {
if
(
limitRows
>=
0
)
{
if
(
limitRows
>=
0
)
{
result
.
setLimit
(
limitRows
);
result
.
setLimit
(
limitRows
);
result
.
setFetchPercent
(
fetchPercent
);
result
.
setFetchPercent
(
fetchPercent
);
result
.
setWithTies
(
withTies
);
if
(
withTies
)
{
result
.
setWithTies
(
sort
);
}
}
}
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
result
.
done
();
result
.
done
();
...
...
h2/src/main/org/h2/command/dml/SelectUnion.java
浏览文件 @
62f49f0b
...
@@ -264,7 +264,9 @@ public class SelectUnion extends Query {
...
@@ -264,7 +264,9 @@ public class SelectUnion extends Query {
if
(
v
!=
ValueNull
.
INSTANCE
)
{
if
(
v
!=
ValueNull
.
INSTANCE
)
{
result
.
setLimit
(
v
.
getInt
());
result
.
setLimit
(
v
.
getInt
());
result
.
setFetchPercent
(
fetchPercent
);
result
.
setFetchPercent
(
fetchPercent
);
result
.
setWithTies
(
withTies
);
if
(
withTies
)
{
result
.
setWithTies
(
sort
);
}
}
}
}
}
l
.
close
();
l
.
close
();
...
...
h2/src/main/org/h2/result/LocalResult.java
浏览文件 @
62f49f0b
...
@@ -25,7 +25,10 @@ public interface LocalResult extends ResultInterface, ResultTarget {
...
@@ -25,7 +25,10 @@ public interface LocalResult extends ResultInterface, ResultTarget {
public
void
setMaxMemoryRows
(
int
maxValue
);
public
void
setMaxMemoryRows
(
int
maxValue
);
/**
/**
* @param sort Sort order.
* Sets sort order to be used by this result. When rows are presorted by the
* query this method should not be used.
*
* @param sort the sort order
*/
*/
public
void
setSortOrder
(
SortOrder
sort
);
public
void
setSortOrder
(
SortOrder
sort
);
...
@@ -82,9 +85,14 @@ public interface LocalResult extends ResultInterface, ResultTarget {
...
@@ -82,9 +85,14 @@ public interface LocalResult extends ResultInterface, ResultTarget {
public
void
setFetchPercent
(
boolean
fetchPercent
);
public
void
setFetchPercent
(
boolean
fetchPercent
);
/**
/**
* @param withTies whether tied rows should be included in result too
* Enables inclusion of tied rows to result and sets the sort order for tied
* rows. The specified sort order must be the same as sort order if sort
* order was set. Passed value will be used if sort order was not set that
* is possible when rows are presorted.
*
* @param withTiesSortOrder the sort order for tied rows
*/
*/
public
void
setWithTies
(
boolean
withTies
);
public
void
setWithTies
(
SortOrder
withTiesSortOrder
);
/**
/**
* Set the offset of the first row to return.
* Set the offset of the first row to return.
...
...
h2/src/main/org/h2/result/LocalResultImpl.java
浏览文件 @
62f49f0b
...
@@ -38,7 +38,7 @@ public class LocalResultImpl implements LocalResult {
...
@@ -38,7 +38,7 @@ public class LocalResultImpl implements LocalResult {
private
int
offset
;
private
int
offset
;
private
int
limit
=
-
1
;
private
int
limit
=
-
1
;
private
boolean
fetchPercent
;
private
boolean
fetchPercent
;
private
boolean
withTies
;
private
SortOrder
withTiesSortOrder
;
private
boolean
limitsWereApplied
;
private
boolean
limitsWereApplied
;
private
ResultExternal
external
;
private
ResultExternal
external
;
private
boolean
distinct
;
private
boolean
distinct
;
...
@@ -132,11 +132,6 @@ public class LocalResultImpl implements LocalResult {
...
@@ -132,11 +132,6 @@ public class LocalResultImpl implements LocalResult {
return
copy
;
return
copy
;
}
}
/**
* Set the sort order.
*
* @param sort the sort order
*/
@Override
@Override
public
void
setSortOrder
(
SortOrder
sort
)
{
public
void
setSortOrder
(
SortOrder
sort
)
{
this
.
sort
=
sort
;
this
.
sort
=
sort
;
...
@@ -365,8 +360,8 @@ public class LocalResultImpl implements LocalResult {
...
@@ -365,8 +360,8 @@ public class LocalResultImpl implements LocalResult {
if
(
isAnyDistinct
())
{
if
(
isAnyDistinct
())
{
rows
=
distinctRows
.
values
();
rows
=
distinctRows
.
values
();
}
}
if
(
sort
!=
null
&&
limit
!=
0
)
{
if
(
sort
!=
null
&&
limit
!=
0
&&
!
limitsWereApplied
)
{
boolean
withLimit
=
limit
>
0
&&
!
withTies
;
boolean
withLimit
=
limit
>
0
&&
withTiesSortOrder
==
null
;
if
(
offset
>
0
||
withLimit
)
{
if
(
offset
>
0
||
withLimit
)
{
sort
.
sort
(
rows
,
offset
,
withLimit
?
limit
:
rows
.
size
());
sort
.
sort
(
rows
,
offset
,
withLimit
?
limit
:
rows
.
size
());
}
else
{
}
else
{
...
@@ -412,9 +407,9 @@ public class LocalResultImpl implements LocalResult {
...
@@ -412,9 +407,9 @@ public class LocalResultImpl implements LocalResult {
return
;
return
;
}
}
int
to
=
offset
+
limit
;
int
to
=
offset
+
limit
;
if
(
withTies
&&
sort
!=
null
)
{
if
(
withTies
SortOrder
!=
null
)
{
Value
[]
expected
=
rows
.
get
(
to
-
1
);
Value
[]
expected
=
rows
.
get
(
to
-
1
);
while
(
to
<
rows
.
size
()
&&
sort
.
compare
(
expected
,
rows
.
get
(
to
))
==
0
)
{
while
(
to
<
rows
.
size
()
&&
withTiesSortOrder
.
compare
(
expected
,
rows
.
get
(
to
))
==
0
)
{
to
++;
to
++;
rowCount
++;
rowCount
++;
}
}
...
@@ -448,9 +443,9 @@ public class LocalResultImpl implements LocalResult {
...
@@ -448,9 +443,9 @@ public class LocalResultImpl implements LocalResult {
addRowsToDisk
();
addRowsToDisk
();
}
}
}
}
if
(
withTies
&&
sort
!=
null
&&
row
!=
null
)
{
if
(
withTies
SortOrder
!=
null
&&
row
!=
null
)
{
Value
[]
expected
=
row
;
Value
[]
expected
=
row
;
while
((
row
=
temp
.
next
())
!=
null
&&
sort
.
compare
(
expected
,
row
)
==
0
)
{
while
((
row
=
temp
.
next
())
!=
null
&&
withTiesSortOrder
.
compare
(
expected
,
row
)
==
0
)
{
rows
.
add
(
row
);
rows
.
add
(
row
);
rowCount
++;
rowCount
++;
if
(
rows
.
size
()
>
maxMemoryRows
)
{
if
(
rows
.
size
()
>
maxMemoryRows
)
{
...
@@ -497,12 +492,10 @@ public class LocalResultImpl implements LocalResult {
...
@@ -497,12 +492,10 @@ public class LocalResultImpl implements LocalResult {
this
.
fetchPercent
=
fetchPercent
;
this
.
fetchPercent
=
fetchPercent
;
}
}
/**
* @param withTies whether tied rows should be included in result too
*/
@Override
@Override
public
void
setWithTies
(
boolean
withTies
)
{
public
void
setWithTies
(
SortOrder
withTiesSortOrder
)
{
this
.
withTies
=
withTies
;
assert
sort
==
null
||
sort
==
withTiesSortOrder
;
this
.
withTiesSortOrder
=
withTiesSortOrder
;
}
}
@Override
@Override
...
...
h2/src/main/org/h2/result/ResultTarget.java
浏览文件 @
62f49f0b
...
@@ -27,9 +27,9 @@ public interface ResultTarget {
...
@@ -27,9 +27,9 @@ public interface ResultTarget {
int
getRowCount
();
int
getRowCount
();
/**
/**
* A hint that
offset and limit may be ignored by this result because they
* A hint that
sorting, offset and limit may be ignored by this result
*
were applied during the query. This is useful for WITH TIES clause
*
because they were applied during the query. This is useful for WITH TIES
* because result may contain tied rows above limit.
*
clause
because result may contain tied rows above limit.
*/
*/
void
limitsWereApplied
();
void
limitsWereApplied
();
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
62f49f0b
...
@@ -806,3 +806,4 @@ econd irst bcef ordinality nord unnest
...
@@ -806,3 +806,4 @@ econd irst bcef ordinality nord unnest
analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan
analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan
corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes
corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes
preserves masking holder unboxing avert iae transformed subtle reevaluate exclusions subclause ftbl rgr
preserves masking holder unboxing avert iae transformed subtle reevaluate exclusions subclause ftbl rgr
presorted inclusion
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论