Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
684dd3b6
Unverified
提交
684dd3b6
authored
10月 11, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
10月 11, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1513 from katzyn/misc
Assorted minor changes
上级
31ed7544
67477841
显示空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
57 行增加
和
70 行删除
+57
-70
help.csv
h2/src/docsrc/help/help.csv
+3
-1
advanced.html
h2/src/docsrc/html/advanced.html
+14
-23
changelog.html
h2/src/docsrc/html/changelog.html
+6
-0
features.html
h2/src/docsrc/html/features.html
+11
-4
Select.java
h2/src/main/org/h2/command/dml/Select.java
+8
-13
ConditionInConstantSet.java
h2/src/main/org/h2/expression/ConditionInConstantSet.java
+1
-1
Expression.java
h2/src/main/org/h2/expression/Expression.java
+0
-9
ExpressionColumn.java
h2/src/main/org/h2/expression/ExpressionColumn.java
+1
-1
ExpressionVisitor.java
h2/src/main/org/h2/expression/ExpressionVisitor.java
+4
-4
Function.java
h2/src/main/org/h2/expression/Function.java
+1
-1
Parameter.java
h2/src/main/org/h2/expression/Parameter.java
+1
-1
Rownum.java
h2/src/main/org/h2/expression/Rownum.java
+1
-1
SequenceValue.java
h2/src/main/org/h2/expression/SequenceValue.java
+1
-1
ValueExpression.java
h2/src/main/org/h2/expression/ValueExpression.java
+1
-1
Variable.java
h2/src/main/org/h2/expression/Variable.java
+1
-1
Wildcard.java
h2/src/main/org/h2/expression/Wildcard.java
+0
-5
Aggregate.java
h2/src/main/org/h2/expression/aggregate/Aggregate.java
+1
-1
DataAnalysisOperation.java
...in/org/h2/expression/aggregate/DataAnalysisOperation.java
+1
-1
JavaAggregate.java
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
+1
-1
没有找到文件。
h2/src/docsrc/help/help.csv
浏览文件 @
684dd3b6
...
...
@@ -2641,7 +2641,7 @@ preceding and following values means relative number of groups of rows,
and CURRENT ROW in bound specification means current group of rows.
If only window frame preceding clause is specified it is treated as
BETWEEN windowFramePreceding AND CURRENT ROW
BETWEEN windowFramePreceding AND CURRENT ROW
.
Optional window frame exclusion clause specifies rows that should be excluded from the frame.
EXCLUDE CURRENT ROW excludes only the current row regardless the window frame unit.
...
...
@@ -5260,6 +5260,7 @@ PERCENT_RANK() OVER windowNameOrSpecification
Returns the relative rank of the current row.
The relative rank is calculated as (RANK - 1) / (NR - 1),
where RANK is a rank of the row and NR is a number of rows in window partition with this row.
Note that result is always 0 if window order clause is not specified.
Window frame clause is not allowed for this function.
Window functions are currently experimental in H2 and should be used with caution.
...
...
@@ -5276,6 +5277,7 @@ Returns the relative rank of the current row.
The relative rank is calculated as NP / NR
where NP is a number of rows that precede the current row or have the same values in ORDER BY columns
and NR is a number of rows in window partition with this row.
Note that result is always 1 if window order clause is not specified.
Window frame clause is not allowed for this function.
Window functions are currently experimental in H2 and should be used with caution.
...
...
h2/src/docsrc/html/advanced.html
浏览文件 @
684dd3b6
...
...
@@ -273,10 +273,21 @@ When using the isolation level 'serializable', dirty reads, non-repeatable reads
</li>
</ul>
<h3
>
Table Level Locking
</h3>
<h3
id=
"mvcc"
>
Multi-Version Concurrency Control (MVCC)
</h3>
<p>
The database allows multiple concurrent connections to the same database.
To make sure all connections only see consistent data, table level locking is used by default.
With default MVStore engine delete, insert and update operations only issue a shared lock on the table.
An exclusive lock is still used when adding or removing columns,
when dropping the table, and when using
<code>
SELECT ... FOR UPDATE
</code>
.
Connections only 'see' committed data, and own changes. That means, if connection A updates
a row but doesn't commit this change yet, connection B will see the old value.
Only when the change is committed, the new value is visible by other connections
(read committed). If multiple connections concurrently try to update the same row, the
database waits until it can apply the change, but at most until the lock timeout expires.
</p>
<h3>
Table Level Locking (PageStore engine)
</h3>
<p>
With PageStore engine to make sure all connections only see consistent data, table level locking is used.
This mechanism does not allow high concurrency, but is very fast.
Shared locks and exclusive locks are supported.
Before reading from a table, the database tries to add a shared lock to the table
...
...
@@ -300,26 +311,6 @@ connection will get a lock timeout exception. The lock timeout can be set indivi
for each connection.
</p>
<h2
id=
"mvcc"
>
Multi-Version Concurrency Control (MVCC)
</h2>
<p>
The MVCC feature allows higher concurrency than using (table level or row level) locks.
Delete, insert and update operations will only issue a shared lock on the table.
An exclusive lock is still used when adding or removing columns,
when dropping the table, and when using
<code>
SELECT ... FOR UPDATE
</code>
.
Connections only 'see' committed data, and own changes. That means, if connection A updates
a row but doesn't commit this change yet, connection B will see the old value.
Only when the change is committed, the new value is visible by other connections
(read committed). If multiple connections concurrently try to update the same row, the
database waits until it can apply the change, but at most until the lock timeout expires.
</p>
<p>
This feature is only available with the default MVStore storage engine.
Changing the lock mode with it (
<code>
LOCK_MODE
</code>
) has no effect.
</p>
<p>
MVCC is not used when using the PageStore storage engine.
</p>
<h2
id=
"clustering"
>
Clustering / High Availability
</h2>
<p>
This database supports a simple clustering / high availability mechanism. The architecture is:
...
...
h2/src/docsrc/html/changelog.html
浏览文件 @
684dd3b6
...
...
@@ -21,6 +21,12 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<ul>
<li>
PR #1513: Assorted minor changes
</li>
<li>
PR #1510: Add optional EXCEPT clause to wildcards
</li>
<li>
PR #1509: Use domain term everywhere
</li>
<li>
Issue #1507: Add INFORMATION_SCHEMA.COLUMNS.COLUMN_TYPE qualification for domains
</li>
<li>
Issue #1499: TestScript::envelope.sql failure in
“
big
”
mode
...
...
h2/src/docsrc/html/features.html
浏览文件 @
684dd3b6
...
...
@@ -858,10 +858,14 @@ This database synchronizes access to the same connection, but other databases ma
To get higher concurrency, you need to use multiple connections.
</p>
<p>
By default, requests to the same database are synchronized.
That means an application can use multiple threads that access the same database
at the same time, however if one thread executes a long running query, the other threads need to wait.
To enable concurrent database usage, see the setting
<code>
MULTI_THREADED
</code>
.
An application can use multiple threads that access the same database at the same time.
With default MVStore engine threads that use different connections can use the database concurrently.
With PageStore engine requests to the same database are synchronized,
that means that if one thread executes a long running query, the other threads need to wait.
Concurrent database usage may be enabled for PageStore or disabled for MVStore
with
<code>
MULTI_THREADED
</code>
setting.
Note that multi-threaded mode for PageStore engine is not tested well and has some issues;
it should be used with caution.
</p>
<h3>
Locking, Lock-Timeout, Deadlocks
</h3>
...
...
@@ -933,6 +937,9 @@ The initial lock timeout (that is the timeout used for new connections) can be s
To avoid deadlocks, ensure that all transactions lock the tables in the same order
(for example in alphabetical order), and avoid upgrading read locks to write locks.
Both can be achieved using explicitly locking tables using
<code>
SELECT ... FOR UPDATE
</code>
.
</p><p>
Note that delete, insert and update operations issue table level locks with PageStore engine,
but does not issue them with default MVStore engine.
</p>
<h2
id=
"database_file_layout"
>
Database File Layout
</h2>
...
...
h2/src/main/org/h2/command/dml/Select.java
浏览文件 @
684dd3b6
...
...
@@ -882,17 +882,16 @@ public class Select extends Query {
}
private
void
expandColumnList
()
{
Database
db
=
session
.
getDatabase
();
// the expressions may change within the loop
for
(
int
i
=
0
;
i
<
expressions
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
expressions
.
size
();)
{
Expression
expr
=
expressions
.
get
(
i
);
if
(!
expr
.
isWildcard
())
{
if
(!(
expr
instanceof
Wildcard
))
{
i
++;
continue
;
}
String
schemaName
=
expr
.
getSchemaName
();
String
tableAlias
=
expr
.
getTableAlias
();
expressions
.
remove
(
i
);
Wildcard
w
=
(
Wildcard
)
expr
;
String
tableAlias
=
w
.
getTableAlias
();
boolean
hasExceptColumns
=
w
.
getExceptColumns
()
!=
null
;
HashMap
<
Column
,
ExpressionColumn
>
exceptTableColumns
=
null
;
if
(
tableAlias
==
null
)
{
...
...
@@ -902,12 +901,12 @@ public class Select extends Query {
}
exceptTableColumns
=
w
.
mapExceptColumns
();
}
expressions
.
remove
(
i
);
for
(
TableFilter
filter
:
filters
)
{
i
=
expandColumnList
(
filter
,
i
,
exceptTableColumns
);
}
i
--;
}
else
{
Database
db
=
session
.
getDatabase
();
String
schemaName
=
w
.
getSchemaName
();
TableFilter
filter
=
null
;
for
(
TableFilter
f
:
filters
)
{
if
(
db
.
equalsIdentifiers
(
tableAlias
,
f
.
getTableAlias
()))
{
...
...
@@ -924,18 +923,14 @@ public class Select extends Query {
if
(
filter
==
null
)
{
throw
DbException
.
get
(
ErrorCode
.
TABLE_OR_VIEW_NOT_FOUND_1
,
tableAlias
);
}
expressions
.
remove
(
i
);
i
=
expandColumnList
(
filter
,
i
,
exceptTableColumns
);
i
--;
}
}
}
private
int
expandColumnList
(
TableFilter
filter
,
int
index
,
HashMap
<
Column
,
ExpressionColumn
>
except
)
{
Table
t
=
filter
.
getTable
();
String
alias
=
filter
.
getTableAlias
();
Column
[]
columns
=
t
.
getColumns
();
for
(
Column
c
:
columns
)
{
for
(
Column
c
:
filter
.
getTable
().
getColumns
())
{
if
(
except
!=
null
&&
except
.
remove
(
c
)
!=
null
)
{
continue
;
}
...
...
h2/src/main/org/h2/expression/ConditionInConstantSet.java
浏览文件 @
684dd3b6
...
...
@@ -135,7 +135,7 @@ public class ConditionInConstantSet extends Condition {
return
false
;
}
switch
(
visitor
.
getType
())
{
case
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
:
case
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
:
case
ExpressionVisitor
.
DETERMINISTIC
:
case
ExpressionVisitor
.
READONLY
:
case
ExpressionVisitor
.
INDEPENDENT
:
...
...
h2/src/main/org/h2/expression/Expression.java
浏览文件 @
684dd3b6
...
...
@@ -271,15 +271,6 @@ public abstract class Expression {
return
StringUtils
.
unEnclose
(
getSQL
());
}
/**
* Only returns true if the expression is a wildcard.
*
* @return if this expression is a wildcard
*/
public
boolean
isWildcard
()
{
return
false
;
}
/**
* Returns the main expression, skipping aliases.
*
...
...
h2/src/main/org/h2/expression/ExpressionColumn.java
浏览文件 @
684dd3b6
...
...
@@ -292,7 +292,7 @@ public class ExpressionColumn extends Expression {
@Override
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
switch
(
visitor
.
getType
())
{
case
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
:
case
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
:
return
false
;
case
ExpressionVisitor
.
READONLY
:
case
ExpressionVisitor
.
DETERMINISTIC
:
...
...
h2/src/main/org/h2/expression/ExpressionVisitor.java
浏览文件 @
684dd3b6
...
...
@@ -33,10 +33,10 @@ public class ExpressionVisitor {
new
ExpressionVisitor
(
INDEPENDENT
);
/**
* Are all aggregates MIN(column), MAX(column),
or COUNT(*) for the given
* table (getTable)?
* Are all aggregates MIN(column), MAX(column),
COUNT(*), MEDIAN(column),
*
ENVELOPE(count) for the given
table (getTable)?
*/
public
static
final
int
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
=
1
;
public
static
final
int
OPTIMIZABLE_
AGGREGATE
=
1
;
/**
* Does the expression return the same results for the same parameters?
...
...
@@ -209,7 +209,7 @@ public class ExpressionVisitor {
* @return the new visitor
*/
public
static
ExpressionVisitor
getOptimizableVisitor
(
Table
table
)
{
return
new
ExpressionVisitor
(
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
,
0
,
null
,
return
new
ExpressionVisitor
(
OPTIMIZABLE_
AGGREGATE
,
0
,
null
,
null
,
table
,
null
,
null
,
null
);
}
...
...
h2/src/main/org/h2/expression/Function.java
浏览文件 @
684dd3b6
...
...
@@ -2735,7 +2735,7 @@ public class Function extends Expression implements FunctionCall {
case
ExpressionVisitor
.
GET_DEPENDENCIES
:
case
ExpressionVisitor
.
INDEPENDENT
:
case
ExpressionVisitor
.
NOT_FROM_RESOLVER
:
case
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
:
case
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
:
case
ExpressionVisitor
.
SET_MAX_DATA_MODIFICATION_ID
:
case
ExpressionVisitor
.
GET_COLUMNS1
:
case
ExpressionVisitor
.
GET_COLUMNS2
:
...
...
h2/src/main/org/h2/expression/Parameter.java
浏览文件 @
684dd3b6
...
...
@@ -156,7 +156,7 @@ public class Parameter extends Expression implements ParameterInterface {
case
ExpressionVisitor
.
NOT_FROM_RESOLVER
:
case
ExpressionVisitor
.
QUERY_COMPARABLE
:
case
ExpressionVisitor
.
GET_DEPENDENCIES
:
case
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
:
case
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
:
case
ExpressionVisitor
.
DETERMINISTIC
:
case
ExpressionVisitor
.
READONLY
:
case
ExpressionVisitor
.
GET_COLUMNS1
:
...
...
h2/src/main/org/h2/expression/Rownum.java
浏览文件 @
684dd3b6
...
...
@@ -81,7 +81,7 @@ public class Rownum extends Expression {
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
switch
(
visitor
.
getType
())
{
case
ExpressionVisitor
.
QUERY_COMPARABLE
:
case
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
:
case
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
:
case
ExpressionVisitor
.
DETERMINISTIC
:
case
ExpressionVisitor
.
INDEPENDENT
:
return
false
;
...
...
h2/src/main/org/h2/expression/SequenceValue.java
浏览文件 @
684dd3b6
...
...
@@ -80,7 +80,7 @@ public class SequenceValue extends Expression {
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
switch
(
visitor
.
getType
())
{
case
ExpressionVisitor
.
EVALUATABLE
:
case
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
:
case
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
:
case
ExpressionVisitor
.
NOT_FROM_RESOLVER
:
case
ExpressionVisitor
.
GET_COLUMNS1
:
case
ExpressionVisitor
.
GET_COLUMNS2
:
...
...
h2/src/main/org/h2/expression/ValueExpression.java
浏览文件 @
684dd3b6
...
...
@@ -150,7 +150,7 @@ public class ValueExpression extends Expression {
@Override
public
boolean
isEverything
(
ExpressionVisitor
visitor
)
{
switch
(
visitor
.
getType
())
{
case
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
:
case
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
:
case
ExpressionVisitor
.
DETERMINISTIC
:
case
ExpressionVisitor
.
READONLY
:
case
ExpressionVisitor
.
INDEPENDENT
:
...
...
h2/src/main/org/h2/expression/Variable.java
浏览文件 @
684dd3b6
...
...
@@ -69,7 +69,7 @@ public class Variable extends Expression {
case
ExpressionVisitor
.
SET_MAX_DATA_MODIFICATION_ID
:
// it is checked independently if the value is the same as the last
// time
case
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
:
case
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
:
case
ExpressionVisitor
.
READONLY
:
case
ExpressionVisitor
.
INDEPENDENT
:
case
ExpressionVisitor
.
NOT_FROM_RESOLVER
:
...
...
h2/src/main/org/h2/expression/Wildcard.java
浏览文件 @
684dd3b6
...
...
@@ -61,11 +61,6 @@ public class Wildcard extends Expression {
return
exceptTableColumns
;
}
@Override
public
boolean
isWildcard
()
{
return
true
;
}
@Override
public
Value
getValue
(
Session
session
)
{
throw
DbException
.
throwInternalError
(
toString
());
...
...
h2/src/main/org/h2/expression/aggregate/Aggregate.java
浏览文件 @
684dd3b6
...
...
@@ -781,7 +781,7 @@ public class Aggregate extends AbstractAggregate {
if
(
filterCondition
!=
null
&&
!
filterCondition
.
isEverything
(
visitor
))
{
return
false
;
}
if
(
visitor
.
getType
()
==
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
)
{
if
(
visitor
.
getType
()
==
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
)
{
switch
(
type
)
{
case
COUNT:
if
(!
distinct
&&
on
.
getNullable
()
==
Column
.
NOT_NULLABLE
)
{
...
...
h2/src/main/org/h2/expression/aggregate/DataAnalysisOperation.java
浏览文件 @
684dd3b6
...
...
@@ -227,7 +227,7 @@ public abstract class DataAnalysisOperation extends Expression {
}
switch
(
visitor
.
getType
())
{
case
ExpressionVisitor
.
QUERY_COMPARABLE
:
case
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
:
case
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
:
case
ExpressionVisitor
.
DETERMINISTIC
:
case
ExpressionVisitor
.
INDEPENDENT
:
return
false
;
...
...
h2/src/main/org/h2/expression/aggregate/JavaAggregate.java
浏览文件 @
684dd3b6
...
...
@@ -93,7 +93,7 @@ public class JavaAggregate extends AbstractAggregate {
case
ExpressionVisitor
.
DETERMINISTIC
:
// TODO optimization: some functions are deterministic, but we don't
// know (no setting for that)
case
ExpressionVisitor
.
OPTIMIZABLE_
MIN_MAX_COUNT_ALL
:
case
ExpressionVisitor
.
OPTIMIZABLE_
AGGREGATE
:
// user defined aggregate functions can not be optimized
return
false
;
case
ExpressionVisitor
.
GET_DEPENDENCIES
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论