Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e2d3afcb
提交
e2d3afcb
authored
1月 24, 2007
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
a22f28fa
隐藏空白字符变更
内嵌
并排
正在显示
21 个修改的文件
包含
236 行增加
和
147 行删除
+236
-147
Column.java
h2/src/main/org/h2/table/Column.java
+10
-1
MetaTable.java
h2/src/main/org/h2/table/MetaTable.java
+2
-2
Plan.java
h2/src/main/org/h2/table/Plan.java
+4
-4
PlanItem.java
h2/src/main/org/h2/table/PlanItem.java
+17
-2
Table.java
h2/src/main/org/h2/table/Table.java
+10
-4
TableData.java
h2/src/main/org/h2/table/TableData.java
+3
-2
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+88
-41
TableView.java
h2/src/main/org/h2/table/TableView.java
+2
-2
CompressTool.java
h2/src/main/org/h2/tools/CompressTool.java
+15
-15
Csv.java
h2/src/main/org/h2/tools/Csv.java
+10
-2
Recover.java
h2/src/main/org/h2/tools/Recover.java
+1
-1
RunScript.java
h2/src/main/org/h2/tools/RunScript.java
+5
-5
Server.java
h2/src/main/org/h2/tools/Server.java
+1
-1
SimpleResultSet.java
h2/src/main/org/h2/tools/SimpleResultSet.java
+27
-27
IOUtils.java
h2/src/main/org/h2/util/IOUtils.java
+19
-16
MathUtils.java
h2/src/main/org/h2/util/MathUtils.java
+1
-1
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+17
-17
DataType.java
h2/src/main/org/h2/value/DataType.java
+1
-1
Transfer.java
h2/src/main/org/h2/value/Transfer.java
+1
-1
ValueDecimal.java
h2/src/main/org/h2/value/ValueDecimal.java
+1
-1
ValueLob.java
h2/src/main/org/h2/value/ValueLob.java
+1
-1
没有找到文件。
h2/src/main/org/h2/table/Column.java
浏览文件 @
e2d3afcb
...
...
@@ -24,6 +24,7 @@ import org.h2.util.StringUtils;
import
org.h2.value.DataType
;
import
org.h2.value.Value
;
import
org.h2.value.ValueInt
;
import
org.h2.value.ValueLong
;
import
org.h2.value.ValueNull
;
import
org.h2.value.ValueString
;
import
org.h2.value.ValueTime
;
...
...
@@ -54,6 +55,7 @@ public class Column {
private
int
selectivity
;
private
SingleColumnResolver
resolver
;
private
String
comment
;
private
boolean
primaryKey
;
// must be equal to ResultSetMetaData columnNoNulls, columnNullable, columnNullableUnknown
public
static
final
int
NOT_NULLABLE
=
0
,
NULLABLE
=
1
,
NULLABLE_UNKNOWN
=
2
;
...
...
@@ -148,6 +150,9 @@ public class Column {
value
=
ValueNull
.
INSTANCE
;
}
else
{
value
=
defaultExpression
.
getValue
(
session
).
convertTo
(
type
);
if
(
primaryKey
)
{
session
.
setLastIdentity
(
value
);
}
}
}
if
(
value
==
ValueNull
.
INSTANCE
)
{
...
...
@@ -203,7 +208,7 @@ public class Column {
}
if
(
update
)
{
sequence
.
setStartValue
(
now
+
increment
);
session
.
setLastIdentity
(
now
);
session
.
setLastIdentity
(
ValueLong
.
get
(
now
)
);
sequence
.
flush
();
}
}
...
...
@@ -424,5 +429,9 @@ public class Column {
public
String
getComment
()
{
return
comment
;
}
public
void
setPrimaryKey
(
boolean
primaryKey
)
{
this
.
primaryKey
=
primaryKey
;
}
}
h2/src/main/org/h2/table/MetaTable.java
浏览文件 @
e2d3afcb
...
...
@@ -654,7 +654,7 @@ public class MetaTable extends Table {
add
(
rows
,
new
String
[]{
"h2.lobFilesInDirectories"
,
""
+
Constants
.
LOB_FILES_IN_DIRECTORIES
});
add
(
rows
,
new
String
[]{
"h2.lobFilesPerDirectory"
,
""
+
Constants
.
LOB_FILES_PER_DIRECTORY
});
add
(
rows
,
new
String
[]{
"h2.multiThreadedKernel"
,
""
+
Constants
.
MULTI_THREADED_KERNEL
});
add
(
rows
,
new
String
[]{
"h2.runFinalize
rs"
,
""
+
Constants
.
RUN_FINALIZERS
});
add
(
rows
,
new
String
[]{
"h2.runFinalize
"
,
""
+
Constants
.
RUN_FINALIZE
});
add
(
rows
,
new
String
[]{
"h2.optimizeMinMax"
,
""
+
Constants
.
OPTIMIZE_MIN_MAX
});
add
(
rows
,
new
String
[]{
"h2.optimizeIn"
,
""
+
Constants
.
OPTIMIZE_IN
});
add
(
rows
,
new
String
[]{
"h2.redoBufferSize"
,
""
+
Constants
.
REDO_BUFFER_SIZE
});
...
...
@@ -664,7 +664,7 @@ public class MetaTable extends Table {
add
(
rows
,
new
String
[]{
"h2.logAllErrors"
,
""
+
Constants
.
LOG_ALL_ERRORS
});
add
(
rows
,
new
String
[]{
"h2.logAllErrorsFile"
,
""
+
Constants
.
LOG_ALL_ERRORS_FILE
});
add
(
rows
,
new
String
[]{
"h2.serverCachedObjects"
,
""
+
Constants
.
SERVER_CACHED_OBJECTS
});
add
(
rows
,
new
String
[]{
"h2.serverSmallResultSetSize"
,
""
+
Constants
.
SERVER_SMALL_RESULTSET_SIZE
});
add
(
rows
,
new
String
[]{
"h2.serverSmallResultSetSize"
,
""
+
Constants
.
SERVER_SMALL_RESULT
_
SET_SIZE
});
add
(
rows
,
new
String
[]{
"h2.emergencySpaceInitial"
,
""
+
Constants
.
EMERGENCY_SPACE_INITIAL
});
add
(
rows
,
new
String
[]{
"h2.emergencySpaceMin"
,
""
+
Constants
.
EMERGENCY_SPACE_MIN
});
add
(
rows
,
new
String
[]{
"h2.objectCache"
,
""
+
Constants
.
OBJECT_CACHE
});
...
...
h2/src/main/org/h2/table/Plan.java
浏览文件 @
e2d3afcb
...
...
@@ -25,14 +25,14 @@ public class Plan {
this
.
filters
=
new
TableFilter
[
count
];
System
.
arraycopy
(
filters
,
0
,
this
.
filters
,
0
,
count
);
ObjectArray
allCond
=
new
ObjectArray
();
ObjectArray
all
Filt
=
new
ObjectArray
();
ObjectArray
all
=
new
ObjectArray
();
if
(
condition
!=
null
)
{
allCond
.
add
(
condition
);
}
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
TableFilter
f
=
filters
[
i
];
do
{
all
Filt
.
add
(
f
);
all
.
add
(
f
);
if
(
f
.
getJoinCondition
()
!=
null
)
{
allCond
.
add
(
f
.
getJoinCondition
());
}
...
...
@@ -41,8 +41,8 @@ public class Plan {
}
allConditions
=
new
Expression
[
allCond
.
size
()];
allCond
.
toArray
(
allConditions
);
allFilters
=
new
TableFilter
[
all
Filt
.
size
()];
all
Filt
.
toArray
(
allFilters
);
allFilters
=
new
TableFilter
[
all
.
size
()];
all
.
toArray
(
allFilters
);
}
public
PlanItem
getItem
(
TableFilter
filter
)
{
...
...
h2/src/main/org/h2/table/PlanItem.java
浏览文件 @
e2d3afcb
...
...
@@ -11,11 +11,26 @@ import org.h2.index.Index;
*/
public
class
PlanItem
{
public
double
cost
;
public
Index
index
;
public
PlanItem
joinPlan
;
private
Index
index
;
private
int
todoObjectArray
;
private
PlanItem
joinPlan
;
public
void
setIndex
(
Index
index
)
{
this
.
index
=
index
;
}
public
Index
getIndex
()
{
return
index
;
}
public
PlanItem
getJoinPlan
()
{
return
joinPlan
;
}
public
void
setJoinPlan
(
PlanItem
joinPlan
)
{
this
.
joinPlan
=
joinPlan
;
}
}
h2/src/main/org/h2/table/Table.java
浏览文件 @
e2d3afcb
...
...
@@ -225,15 +225,15 @@ public abstract class Table extends SchemaObject {
*/
public
PlanItem
getBestPlanItem
(
Session
session
,
int
[]
masks
)
throws
SQLException
{
PlanItem
item
=
new
PlanItem
();
item
.
index
=
getScanIndex
(
session
);
item
.
cost
=
item
.
index
.
getCost
(
null
);
item
.
setIndex
(
getScanIndex
(
session
)
);
item
.
cost
=
item
.
getIndex
()
.
getCost
(
null
);
ObjectArray
indexes
=
getIndexes
();
for
(
int
i
=
1
;
indexes
!=
null
&&
masks
!=
null
&&
i
<
indexes
.
size
();
i
++)
{
Index
index
=
(
Index
)
indexes
.
get
(
i
);
int
cost
=
index
.
getCost
(
masks
);
if
(
cost
<
item
.
cost
)
{
item
.
cost
=
cost
;
item
.
index
=
index
;
item
.
setIndex
(
index
)
;
}
}
return
item
;
...
...
@@ -289,6 +289,12 @@ public abstract class Table extends SchemaObject {
ObjectArray
indexes
=
getIndexes
();
if
(
indexes
!=
null
)
{
remove
(
indexes
,
index
);
if
(
index
.
indexType
.
isPrimaryKey
())
{
Column
[]
cols
=
index
.
getColumns
();
for
(
int
i
=
0
;
i
<
cols
.
length
;
i
++)
{
cols
[
i
].
setPrimaryKey
(
false
);
}
}
}
}
...
...
@@ -334,7 +340,7 @@ public abstract class Table extends SchemaObject {
if
(
list
==
null
)
{
list
=
new
ObjectArray
();
}
// self contraints are two entries in the list
// self con
s
traints are two entries in the list
// if(Database.CHECK) {
// if(list.indexOf(obj) >= 0) {
// throw Message.internal("object already in list: " + obj.getName());
...
...
h2/src/main/org/h2/table/TableData.java
浏览文件 @
e2d3afcb
...
...
@@ -96,7 +96,7 @@ public class TableData extends Table implements RecordReader {
}
}
}
catch
(
SQLException
e2
)
{
// this could happen
d
, for example on failure in the storage
// this could happen, for example on failure in the storage
// but if that is not the case it means there is something wrong with the database
// TODO log this problem
throw
e2
;
...
...
@@ -132,6 +132,7 @@ public class TableData extends Table implements RecordReader {
if
(
column
.
getNullable
())
{
throw
Message
.
getSQLException
(
Message
.
COLUMN_MUST_NOT_BE_NULLABLE_1
,
column
.
getName
());
}
column
.
setPrimaryKey
(
true
);
}
}
Index
index
;
...
...
@@ -175,7 +176,7 @@ public class TableData extends Table implements RecordReader {
try
{
index
.
remove
(
session
);
}
catch
(
SQLException
e2
)
{
// this could happen
d
, for example on failure in the storage
// this could happen, for example on failure in the storage
// but if that is not the case it means there is something wrong with the database
// TODO log this problem
throw
e2
;
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
e2d3afcb
...
...
@@ -44,7 +44,11 @@ public class TableFilter implements ColumnResolver {
private
Expression
joinCondition
;
private
Row
current
;
private
int
state
;
private
TableFilter
join
;
private
int
todo
;
private
ObjectArray
joins
;
// private TableFilter join;
private
boolean
outerJoin
;
private
boolean
foundOne
;
private
Expression
fullCondition
;
...
...
@@ -70,17 +74,21 @@ public class TableFilter implements ColumnResolver {
session
.
getUser
().
checkRight
(
table
,
Right
.
SELECT
);
}
table
.
lock
(
session
,
exclusive
);
if
(
join
!=
null
)
{
join
.
lock
(
session
,
exclusive
);
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++
)
{
getTableFilter
(
i
)
.
lock
(
session
,
exclusive
);
}
}
private
TableFilter
getTableFilter
(
int
i
)
{
return
(
TableFilter
)
joins
.
get
(
i
);
}
public
PlanItem
getBestPlanItem
(
Session
session
)
throws
SQLException
{
PlanItem
item
;
if
(
indexConditions
.
size
()
==
0
)
{
item
=
new
PlanItem
();
item
.
index
=
table
.
getScanIndex
(
session
);
item
.
cost
=
item
.
index
.
getCost
(
null
);
item
.
setIndex
(
table
.
getScanIndex
(
session
)
);
item
.
cost
=
item
.
getIndex
()
.
getCost
(
null
);
}
else
{
int
len
=
table
.
getColumns
().
length
;
int
[]
masks
=
new
int
[
len
];
...
...
@@ -98,27 +106,34 @@ public class TableFilter implements ColumnResolver {
}
item
=
table
.
getBestPlanItem
(
session
,
masks
);
}
if
(
join
!=
null
)
{
TableFilter
j
=
join
;
// this table filter is now evaluatable - in all sub-joins
do
{
Expression
e
=
j
.
getJoinCondition
();
if
(
e
!=
null
)
{
e
.
setEvaluatable
(
this
,
true
);
}
j
=
j
.
getJoin
();
}
while
(
j
!=
null
);
item
.
joinPlan
=
join
.
getBestPlanItem
(
session
);
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
setEvaluatable
(
join
);
item
.
setJoinPlan
(
join
.
getBestPlanItem
(
session
));
// TODO optimizer: calculate cost of a join: should use separate expected row number and lookup cost
item
.
cost
+=
item
.
cost
*
item
.
joinPlan
.
cost
;
item
.
cost
+=
item
.
cost
*
item
.
getJoinPlan
()
.
cost
;
}
return
item
;
}
private
void
setEvaluatable
(
TableFilter
join
)
{
// this table filter is now evaluatable - in all sub-joins
do
{
Expression
e
=
join
.
getJoinCondition
();
if
(
e
!=
null
)
{
e
.
setEvaluatable
(
this
,
true
);
}
join
=
join
.
getJoin
();
}
while
(
join
!=
null
);
}
public
void
setPlanItem
(
PlanItem
item
)
{
this
.
index
=
item
.
index
;
if
(
join
!=
null
&&
item
.
joinPlan
!=
null
)
{
join
.
setPlanItem
(
item
.
joinPlan
);
this
.
index
=
item
.
getIndex
();
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
if
(
item
.
getJoinPlan
()!=
null
)
{
join
.
setPlanItem
(
item
.
getJoinPlan
());
}
}
}
...
...
@@ -134,7 +149,8 @@ public class TableFilter implements ColumnResolver {
}
}
}
if
(
join
!=
null
)
{
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
if
(
Constants
.
CHECK
&&
join
==
this
)
{
throw
Message
.
getInternalError
(
"self join"
);
}
...
...
@@ -144,13 +160,15 @@ public class TableFilter implements ColumnResolver {
public
void
startQuery
()
{
scanCount
=
0
;
if
(
join
!=
null
)
{
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
join
.
startQuery
();
}
}
public
void
reset
()
throws
SQLException
{
if
(
join
!=
null
)
{
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
join
.
reset
();
}
state
=
BEFORE_FIRST
;
...
...
@@ -190,14 +208,23 @@ public class TableFilter implements ColumnResolver {
}
if
(!
alwaysFalse
)
{
cursor
=
index
.
find
(
session
,
start
,
end
);
if
(
join
!=
null
)
{
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
join
.
reset
();
}
}
}
else
{
// state == FOUND || LAST_ROW
// the last row was ok - try next row of the join
if
(
join
!=
null
&&
join
.
next
())
{
boolean
found
=
joins
!=
null
;
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
if
(!
join
.
next
())
{
found
=
false
;
break
;
}
}
if
(
found
)
{
return
true
;
}
}
...
...
@@ -233,12 +260,20 @@ public class TableFilter implements ColumnResolver {
if
(
state
==
FOUND
&&
joinConditionOk
)
{
foundOne
=
true
;
}
if
(
join
!=
null
)
{
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
join
.
reset
();
}
boolean
cont
=
false
;
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
if
(!
join
.
next
())
{
cont
in
ue
;
cont
=
tr
ue
;
}
}
if
(
cont
)
{
continue
;
}
// check if it's ok
if
(
state
==
NULL_ROW
||
joinConditionOk
)
{
return
true
;
...
...
@@ -295,28 +330,36 @@ public class TableFilter implements ColumnResolver {
if
(
on
!=
null
)
{
on
.
mapColumns
(
this
,
0
);
}
if
(
join
==
null
)
{
this
.
join
=
filter
;
if
(
joins
==
null
)
{
this
.
joins
=
new
ObjectArray
();
joins
.
add
(
filter
);
filter
.
outerJoin
=
outer
;
if
(
on
!=
null
)
{
TableFilter
f
=
filter
;
do
{
on
.
mapColumns
(
f
,
0
);
f
.
addFilterCondition
(
on
,
true
);
on
.
createIndexConditions
(
f
);
f
=
f
.
join
;
}
while
(
f
!=
null
);
filter
.
mapAndAddFilter
(
on
);
}
}
else
{
int
todoAddJoinNestedOrSameLevel
;
TableFilter
join
=
getTableFilter
(
0
);
join
.
addJoin
(
filter
,
outer
,
on
);
}
if
(
on
!=
null
)
{
on
.
optimize
(
session
);
}
}
private
void
mapAndAddFilter
(
Expression
on
)
throws
SQLException
{
on
.
mapColumns
(
this
,
0
);
addFilterCondition
(
on
,
true
);
on
.
createIndexConditions
(
this
);
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
join
.
mapAndAddFilter
(
on
);
}
}
public
TableFilter
getJoin
()
{
return
join
;
int
todoGetJoin
;
return
joins
==
null
?
null
:
getTableFilter
(
0
);
}
public
boolean
isJoinOuter
()
{
...
...
@@ -392,7 +435,8 @@ public class TableFilter implements ColumnResolver {
}
public
void
removeJoin
()
{
this
.
join
=
null
;
int
todoRemoveJoin
;
this
.
joins
=
null
;
}
public
Expression
getJoinCondition
()
{
...
...
@@ -413,7 +457,8 @@ public class TableFilter implements ColumnResolver {
public
void
setFullCondition
(
Expression
condition
)
{
this
.
fullCondition
=
condition
;
if
(
join
!=
null
)
{
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
join
.
setFullCondition
(
condition
);
}
}
...
...
@@ -421,7 +466,8 @@ public class TableFilter implements ColumnResolver {
public
void
optimizeFullCondition
(
boolean
fromOuterJoin
)
{
if
(
fullCondition
!=
null
)
{
fullCondition
.
addFilterConditions
(
this
,
fromOuterJoin
||
outerJoin
);
if
(
join
!=
null
)
{
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
join
.
optimizeFullCondition
(
fromOuterJoin
||
outerJoin
);
}
}
...
...
@@ -434,7 +480,8 @@ public class TableFilter implements ColumnResolver {
if
(
joinCondition
!=
null
)
{
joinCondition
.
setEvaluatable
(
filter
,
b
);
}
if
(
join
!=
null
)
{
for
(
int
i
=
0
;
joins
!=
null
&&
i
<
joins
.
size
();
i
++)
{
TableFilter
join
=
getTableFilter
(
i
);
join
.
setEvaluatable
(
filter
,
b
);
}
}
...
...
h2/src/main/org/h2/table/TableView.java
浏览文件 @
e2d3afcb
...
...
@@ -88,7 +88,7 @@ public class TableView extends Table {
public
PlanItem
getBestPlanItem
(
Session
session
,
int
[]
masks
)
throws
SQLException
{
PlanItem
item
=
new
PlanItem
();
item
.
cost
=
index
.
getCost
(
session
,
masks
);
item
.
index
=
index
;
item
.
setIndex
(
index
)
;
return
item
;
}
...
...
@@ -187,7 +187,7 @@ public class TableView extends Table {
throw
Message
.
getSQLException
(
Message
.
VIEW_IS_INVALID_1
,
getSQL
());
}
PlanItem
item
=
getBestPlanItem
(
session
,
null
);
return
item
.
index
;
return
item
.
getIndex
()
;
}
public
ObjectArray
getIndexes
()
{
...
...
h2/src/main/org/h2/tools/CompressTool.java
浏览文件 @
e2d3afcb
...
...
@@ -19,7 +19,7 @@ import java.util.zip.ZipOutputStream;
import
org.h2.compress.CompressDeflate
;
import
org.h2.compress.CompressLZF
;
import
org.h2.compress.CompressNo
;
import
org.h2.compress.Compress
e
r
;
import
org.h2.compress.Compress
o
r
;
import
org.h2.compress.LZFInputStream
;
import
org.h2.compress.LZFOutputStream
;
import
org.h2.message.Message
;
...
...
@@ -69,7 +69,7 @@ public class CompressTool {
if
(
in
.
length
<
5
)
{
algorithm
=
"NO"
;
}
Compress
er
compress
=
getCompresse
r
(
algorithm
);
Compress
or
compress
=
getCompresso
r
(
algorithm
);
byte
[]
buff
=
getBuffer
((
len
<
100
?
len
+
100
:
len
)
*
2
);
int
newLen
=
compress
(
in
,
in
.
length
,
compress
,
buff
);
byte
[]
out
=
new
byte
[
newLen
];
...
...
@@ -80,13 +80,13 @@ public class CompressTool {
/**
* INTERNAL
*/
public
synchronized
int
compress
(
byte
[]
in
,
int
len
,
Compress
e
r
compress
,
byte
[]
out
)
{
public
synchronized
int
compress
(
byte
[]
in
,
int
len
,
Compress
o
r
compress
,
byte
[]
out
)
{
int
newLen
=
0
;
out
[
0
]
=
(
byte
)
compress
.
getAlgorithm
();
int
start
=
1
+
writeInt
(
out
,
1
,
len
);
newLen
=
compress
.
compress
(
in
,
len
,
out
,
start
);
if
(
newLen
>
len
+
start
||
newLen
<=
0
)
{
out
[
0
]
=
Compress
e
r
.
NO
;
out
[
0
]
=
Compress
o
r
.
NO
;
System
.
arraycopy
(
in
,
0
,
out
,
start
,
len
);
newLen
=
len
+
start
;
}
...
...
@@ -102,7 +102,7 @@ public class CompressTool {
*/
public
byte
[]
expand
(
byte
[]
in
)
throws
SQLException
{
int
algorithm
=
in
[
0
];
Compress
er
compress
=
getCompresse
r
(
algorithm
);
Compress
or
compress
=
getCompresso
r
(
algorithm
);
try
{
int
len
=
readInt
(
in
,
1
);
int
start
=
1
+
getLength
(
len
);
...
...
@@ -119,7 +119,7 @@ public class CompressTool {
*/
public
void
expand
(
byte
[]
in
,
byte
[]
out
,
int
outPos
)
throws
SQLException
{
int
algorithm
=
in
[
0
];
Compress
er
compress
=
getCompresse
r
(
algorithm
);
Compress
or
compress
=
getCompresso
r
(
algorithm
);
try
{
int
len
=
readInt
(
in
,
1
);
int
start
=
1
+
getLength
(
len
);
...
...
@@ -198,7 +198,7 @@ public class CompressTool {
}
}
private
Compress
er
getCompresse
r
(
String
algorithm
)
throws
SQLException
{
private
Compress
or
getCompresso
r
(
String
algorithm
)
throws
SQLException
{
if
(
algorithm
==
null
)
{
algorithm
=
"LZF"
;
}
...
...
@@ -209,7 +209,7 @@ public class CompressTool {
algorithm
=
algorithm
.
substring
(
0
,
idx
);
}
int
a
=
getCompressAlgorithm
(
algorithm
);
Compress
er
compress
=
getCompresse
r
(
a
);
Compress
or
compress
=
getCompresso
r
(
a
);
compress
.
setOptions
(
options
);
return
compress
;
}
...
...
@@ -220,23 +220,23 @@ public class CompressTool {
public
int
getCompressAlgorithm
(
String
algorithm
)
throws
SQLException
{
algorithm
=
StringUtils
.
toUpperEnglish
(
algorithm
);
if
(
"NO"
.
equals
(
algorithm
))
{
return
Compress
e
r
.
NO
;
return
Compress
o
r
.
NO
;
}
else
if
(
"LZF"
.
equals
(
algorithm
))
{
return
Compress
e
r
.
LZF
;
return
Compress
o
r
.
LZF
;
}
else
if
(
"DEFLATE"
.
equals
(
algorithm
))
{
return
Compress
e
r
.
DEFLATE
;
return
Compress
o
r
.
DEFLATE
;
}
else
{
throw
Message
.
getSQLException
(
Message
.
UNSUPPORTED_COMPRESSION_ALGORITHM_1
,
algorithm
);
}
}
private
Compress
er
getCompresse
r
(
int
algorithm
)
throws
SQLException
{
private
Compress
or
getCompresso
r
(
int
algorithm
)
throws
SQLException
{
switch
(
algorithm
)
{
case
Compress
e
r
.
NO
:
case
Compress
o
r
.
NO
:
return
new
CompressNo
();
case
Compress
e
r
.
LZF
:
case
Compress
o
r
.
LZF
:
return
new
CompressLZF
();
case
Compress
e
r
.
DEFLATE
:
case
Compress
o
r
.
DEFLATE
:
return
new
CompressDeflate
();
default
:
throw
Message
.
getSQLException
(
Message
.
UNSUPPORTED_COMPRESSION_ALGORITHM_1
,
""
+
algorithm
);
...
...
h2/src/main/org/h2/tools/Csv.java
浏览文件 @
e2d3afcb
...
...
@@ -193,7 +193,7 @@ public class Csv implements SimpleRowSource {
private
void
writeHeader
()
{
for
(
int
i
=
0
;
i
<
columnNames
.
length
;
i
++)
{
if
(
i
>
0
)
{
writer
.
print
(
fieldSeparator
Read
);
writer
.
print
(
fieldSeparator
Write
);
}
writer
.
print
(
columnNames
[
i
]);
}
...
...
@@ -475,6 +475,14 @@ public class Csv implements SimpleRowSource {
public
void
setFieldSeparatorWrite
(
String
fieldSeparatorWrite
)
{
this
.
fieldSeparatorWrite
=
fieldSeparatorWrite
;
}
/**
* Override the field separator for reading. The default is ','.
* @param fieldSeparatorRead
*/
public
void
setFieldSeparatorRead
(
char
fieldSeparatorRead
)
{
this
.
fieldSeparatorRead
=
fieldSeparatorRead
;
}
/**
* Override the end-of-row marker for writing. The default is null.
...
...
@@ -489,7 +497,7 @@ public class Csv implements SimpleRowSource {
* This is not supported at this time, and this methods throws a SQLException
*/
public
void
reset
()
throws
SQLException
{
throw
new
SQLException
(
"Method is notsupported"
,
"CSV"
);
throw
new
SQLException
(
"Method is not
supported"
,
"CSV"
);
}
}
h2/src/main/org/h2/tools/Recover.java
浏览文件 @
e2d3afcb
...
...
@@ -277,7 +277,7 @@ public class Recover implements DataHandler {
}
private
void
writeDataError
(
PrintWriter
writer
,
String
error
,
byte
[]
data
,
int
dumpBlocks
)
throws
IOException
{
writer
.
println
(
"-- ERROR:"
+
error
+
" block:"
+
block
+
" blockCount:"
+
blockCount
+
" storageId:"
+
storageId
+
" recordLength: "
+
recordLength
+
" valu
d
Id:"
+
valueId
);
writer
.
println
(
"-- ERROR:"
+
error
+
" block:"
+
block
+
" blockCount:"
+
blockCount
+
" storageId:"
+
storageId
+
" recordLength: "
+
recordLength
+
" valu
e
Id:"
+
valueId
);
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
dumpBlocks
*
DiskFile
.
BLOCK_SIZE
;
i
++)
{
int
x
=
(
data
[
i
]
&
0xff
);
...
...
h2/src/main/org/h2/tools/RunScript.java
浏览文件 @
e2d3afcb
...
...
@@ -107,7 +107,7 @@ public class RunScript {
showUsage
();
return
;
}
//
long time = System.currentTimeMillis();
long
time
=
System
.
currentTimeMillis
();
// for(int i=0; i<10; i++) {
// int test;
if
(
options
!=
null
)
{
...
...
@@ -116,8 +116,8 @@ public class RunScript {
execute
(
url
,
user
,
password
,
script
,
null
,
continueOnError
);
}
// }
//
time = System.currentTimeMillis() - time;
//
System.out.println("Done in " + time + " ms");
time
=
System
.
currentTimeMillis
()
-
time
;
System
.
out
.
println
(
"Done in "
+
time
+
" ms"
);
}
/**
...
...
@@ -136,8 +136,8 @@ public class RunScript {
if
(
sql
==
null
)
{
break
;
}
boolean
result
s
et
=
stat
.
execute
(
sql
);
if
(
result
s
et
)
{
boolean
result
S
et
=
stat
.
execute
(
sql
);
if
(
result
S
et
)
{
if
(
rs
!=
null
)
{
rs
.
close
();
rs
=
null
;
...
...
h2/src/main/org/h2/tools/Server.java
浏览文件 @
e2d3afcb
...
...
@@ -318,7 +318,7 @@ public class Server implements Runnable {
/**
* Tries to start the server.
* @return the server if successful
l
* @return the server if successful
* @throws SQLException if the server could not be started
*/
public
Server
start
()
throws
SQLException
{
...
...
h2/src/main/org/h2/tools/SimpleResultSet.java
浏览文件 @
e2d3afcb
...
...
@@ -162,7 +162,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
/**
* Moves the cursor to the next row of the result set.
*
* @return true if successful
l
, false if there are no more rows
* @return true if successful, false if there are no more rows
*/
public
boolean
next
()
throws
SQLException
{
if
(
source
!=
null
)
{
...
...
@@ -1228,30 +1228,30 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
return
(
Column
)
columns
.
get
(
i
);
}
//#ifdef JDK16
//#ifdef JDK16
/*
public RowId getRowId(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
//#ifdef JDK16
//#ifdef JDK16
/*
public RowId getRowId(String columnName) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public void updateRowId(int columnIndex, RowId x) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
...
...
@@ -1293,76 +1293,76 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
}
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public void updateNClob(String columnName, NClob nClob) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public NClob getNClob(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public NClob getNClob(String columnName) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public SQLXML getSQLXML(int columnIndex) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public SQLXML getSQLXML(String columnName) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public void updateSQLXML(String columnName, SQLXML xmlObject) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
public
String
getNString
(
int
columnIndex
)
throws
SQLException
{
...
...
@@ -1395,22 +1395,22 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
}
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public <T> T unwrap(Class<T> iface) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
//#ifdef JDK16
//#ifdef JDK16
/*
public boolean isWrapperFor(Class<?> iface) throws SQLException {
throw getUnsupportedException();
}
*/
//#endif
//#endif
/** INTERNAL */
public
void
updateAsciiStream
(
int
columnIndex
,
InputStream
x
)
throws
SQLException
{
...
...
h2/src/main/org/h2/util/IOUtils.java
浏览文件 @
e2d3afcb
...
...
@@ -55,7 +55,7 @@ public class IOUtils {
}
public
static
long
copyAndCloseInput
(
InputStream
in
,
OutputStream
out
)
throws
IOException
{
int
written
=
0
;
long
written
=
0
;
try
{
byte
[]
buffer
=
new
byte
[
4
*
1024
];
while
(
true
)
{
...
...
@@ -145,23 +145,26 @@ public class IOUtils {
}
public
static
String
readStringAndClose
(
Reader
in
,
int
length
)
throws
IOException
{
if
(
length
<=
0
)
{
length
=
Integer
.
MAX_VALUE
;
}
int
block
=
Math
.
min
(
BUFFER_BLOCK_SIZE
,
length
);
StringWriter
out
=
new
StringWriter
(
length
==
Integer
.
MAX_VALUE
?
block
:
length
);
char
[]
buff
=
new
char
[
block
];
while
(
length
>
0
)
{
int
len
=
Math
.
min
(
block
,
length
);
len
=
in
.
read
(
buff
,
0
,
len
);
if
(
len
<
0
)
{
break
;
try
{
if
(
length
<=
0
)
{
length
=
Integer
.
MAX_VALUE
;
}
out
.
write
(
buff
,
0
,
len
);
length
-=
len
;
int
block
=
Math
.
min
(
BUFFER_BLOCK_SIZE
,
length
);
StringWriter
out
=
new
StringWriter
(
length
==
Integer
.
MAX_VALUE
?
block
:
length
);
char
[]
buff
=
new
char
[
block
];
while
(
length
>
0
)
{
int
len
=
Math
.
min
(
block
,
length
);
len
=
in
.
read
(
buff
,
0
,
len
);
if
(
len
<
0
)
{
break
;
}
out
.
write
(
buff
,
0
,
len
);
length
-=
len
;
}
return
out
.
toString
();
}
finally
{
in
.
close
();
}
in
.
close
();
return
out
.
toString
();
}
public
static
int
readFully
(
InputStream
in
,
byte
[]
buffer
,
int
max
)
throws
IOException
{
...
...
h2/src/main/org/h2/util/MathUtils.java
浏览文件 @
e2d3afcb
...
...
@@ -35,7 +35,7 @@ public class MathUtils {
}
public
static
BigDecimal
setScale
(
BigDecimal
bd
,
int
scale
)
throws
SQLException
{
if
(
scale
>
Constants
.
BIGDECIMAL_SCALE_MAX
)
{
if
(
scale
>
Constants
.
BIG
_
DECIMAL_SCALE_MAX
)
{
throw
Message
.
getInvalidValueException
(
""
+
scale
,
"scale"
);
}
else
if
(
scale
<
0
)
{
throw
Message
.
getInvalidValueException
(
""
+
scale
,
"scale"
);
...
...
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
e2d3afcb
...
...
@@ -24,19 +24,19 @@ import org.h2.message.Message;
public
class
StringUtils
{
// TODO hack for gcj
//#GCJHACK private static final Class[] gcjClasses = {
//#GCJHACK gnu.gcj.convert.Input_ASCII.class,
//#GCJHACK gnu.gcj.convert.Input_UTF8.class,
//#GCJHACK gnu.gcj.convert.Input_8859_1.class,
//#GCJHACK gnu.gcj.convert.Output_ASCII.class,
//#GCJHACK gnu.gcj.convert.Output_UTF8.class,
//#GCJHACK gnu.gcj.convert.UnicodeToBytes.class,
//#GCJHACK gnu.gcj.convert.BytesToUnicode.class,
//#GCJHACK gnu.java.locale.Calendar.class,
//#GCJHACK gnu.java.locale.LocaleInformation.class,
//#GCJHACK gnu.java.locale.LocaleInformation_de.class,
//#GCJHACK java.util.GregorianCalendar.class,
//#GCJHACK };
//#GCJHACK private static final Class[] gcjClasses = {
//#GCJHACK gnu.gcj.convert.Input_ASCII.class,
//#GCJHACK gnu.gcj.convert.Input_UTF8.class,
//#GCJHACK gnu.gcj.convert.Input_8859_1.class,
//#GCJHACK gnu.gcj.convert.Output_ASCII.class,
//#GCJHACK gnu.gcj.convert.Output_UTF8.class,
//#GCJHACK gnu.gcj.convert.UnicodeToBytes.class,
//#GCJHACK gnu.gcj.convert.BytesToUnicode.class,
//#GCJHACK gnu.java.locale.Calendar.class,
//#GCJHACK gnu.java.locale.LocaleInformation.class,
//#GCJHACK gnu.java.locale.LocaleInformation_de.class,
//#GCJHACK java.util.GregorianCalendar.class,
//#GCJHACK };
public
static
boolean
equals
(
String
a
,
String
b
)
{
if
(
a
==
null
)
{
...
...
@@ -127,7 +127,7 @@ public class StringUtils {
return
buff
.
toString
();
}
public
static
String
addAsteri
x
(
String
s
,
int
index
)
{
public
static
String
addAsteri
sk
(
String
s
,
int
index
)
{
if
(
s
!=
null
&&
index
<
s
.
length
())
{
s
=
s
.
substring
(
0
,
index
)
+
"[*]"
+
s
.
substring
(
index
);
}
...
...
@@ -135,7 +135,7 @@ public class StringUtils {
}
private
static
SQLException
getFormatException
(
String
s
,
int
i
)
{
return
Message
.
getSQLException
(
Message
.
STRING_FORMAT_ERROR_1
,
addAsteri
x
(
s
,
i
));
return
Message
.
getSQLException
(
Message
.
STRING_FORMAT_ERROR_1
,
addAsteri
sk
(
s
,
i
));
}
public
static
String
javaDecode
(
String
s
)
throws
SQLException
{
...
...
@@ -378,8 +378,8 @@ public class StringUtils {
* Formats a date using a format string
*/
public
static
String
formatDateTime
(
Date
date
,
String
format
,
String
locale
,
String
timezone
)
throws
SQLException
{
SimpleDateFormat
sdf
=
getDateFormat
(
format
,
locale
,
timezone
);
return
sdf
.
format
(
date
);
SimpleDateFormat
dateFormat
=
getDateFormat
(
format
,
locale
,
timezone
);
return
dateFormat
.
format
(
date
);
}
/**
...
...
h2/src/main/org/h2/value/DataType.java
浏览文件 @
e2d3afcb
...
...
@@ -534,7 +534,7 @@ public class DataType {
return
ValueNull
.
INSTANCE
;
}
if
(
type
==
Value
.
JAVA_OBJECT
)
{
// serialize JAVA_OBJECT
s
, even if the type is known
// serialize JAVA_OBJECT, even if the type is known
if
(
Constants
.
SERIALIZE_JAVA_OBJECTS
)
{
return
ValueJavaObject
.
getNoCopy
(
ByteUtils
.
serialize
(
x
));
}
...
...
h2/src/main/org/h2/value/Transfer.java
浏览文件 @
e2d3afcb
...
...
@@ -49,7 +49,7 @@ public class Transfer {
}
protected
void
finalize
()
{
if
(!
Constants
.
RUN_FINALIZE
RS
)
{
if
(!
Constants
.
RUN_FINALIZE
)
{
return
;
}
if
(
socket
!=
null
)
{
...
...
h2/src/main/org/h2/value/ValueDecimal.java
浏览文件 @
e2d3afcb
...
...
@@ -161,7 +161,7 @@ public class ValueDecimal extends Value {
}
else
if
(
DEC_ONE
.
equals
(
dec
))
{
return
ONE
;
}
// TODO value optimization: find a way to read size of
bigd
ecimal,
// TODO value optimization: find a way to read size of
BigD
ecimal,
// check max cache size
return
(
ValueDecimal
)
Value
.
cache
(
new
ValueDecimal
(
dec
));
}
...
...
h2/src/main/org/h2/value/ValueLob.java
浏览文件 @
e2d3afcb
...
...
@@ -534,7 +534,7 @@ public class ValueLob extends Value {
// }
public
int
getDisplaySize
()
{
// TODO displaysize of lob?
// TODO display
size of lob?
return
40
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论