Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
40b88b0d
提交
40b88b0d
authored
1月 22, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
d8218ce4
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
173 行增加
和
69 行删除
+173
-69
stylesheet.css
h2/src/docsrc/javadoc/stylesheet.css
+3
-0
ErrorCode.java
h2/src/main/org/h2/constant/ErrorCode.java
+72
-18
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+59
-5
ConstraintReferential.java
h2/src/main/org/h2/constraint/ConstraintReferential.java
+2
-6
LocalResult.java
h2/src/main/org/h2/result/LocalResult.java
+1
-16
TableFilter.java
h2/src/main/org/h2/table/TableFilter.java
+10
-21
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+5
-0
Doclet.java
h2/src/tools/org/h2/tools/doclet/Doclet.java
+21
-3
没有找到文件。
h2/src/docsrc/javadoc/stylesheet.css
浏览文件 @
40b88b0d
...
...
@@ -71,6 +71,9 @@ td.method {
.method
{
}
.fieldText
{
margin
:
6px
20px
6px
20px
;
}
.methodName
{
font-weight
:
bold
;
...
...
h2/src/main/org/h2/constant/ErrorCode.java
浏览文件 @
40b88b0d
...
...
@@ -10,16 +10,65 @@ package org.h2.constant;
public
class
ErrorCode
{
// 02: no data
/**
* The error with code <code>2000</code> is thrown when
* the result set is positioned before the first or after the last row, or
* not on a valid row for the given operation.
* Example:
* <pre>
* ResultSet rs = stat.executeQuery("SELECT * FROM DUAL");
* rs.getString(1);
* </pre>
* Correct:
* <pre>
* ResultSet rs = stat.executeQuery("SELECT * FROM DUAL");
* rs.next();
* rs.getString(1);
* </pre>
*/
public
static
final
int
NO_DATA_AVAILABLE
=
2000
;
// 07: dynamic SQL error
/**
* The error with code <code>7001</code> is thrown when
* trying to call a function with the wrong number of parameters.
* Example:
* <pre>
* CALL ABS(1, 2)
* </pre>
*/
public
static
final
int
INVALID_PARAMETER_COUNT_2
=
7001
;
// 08: connection exception
/**
* The error with code <code>8000</code> is thrown when
* there was a problem trying to create a database lock.
* See the cause for details.
*/
public
static
final
int
ERROR_OPENING_DATABASE
=
8000
;
/**
* The error with code <code>8004</code> is thrown when
* there is no such user registered in the database, when
* the user password does not match, or when the database encryption password
* does not match (if database encryption is used).
*/
public
static
final
int
WRONG_USER_OR_PASSWORD
=
8004
;
// 21: cardinality violation
/**
* The error with code <code>21002</code> is thrown when
* the number of columns does not match.
* Possible reasons are: for an INSERT or MERGE statement, the column count does not match
* the table or the column list specified. For a SELECT UNION statement, both queries
* return a different number of columns. For a constraint, the number of referenced and referencing
* columns does not match.
* Example:
* <pre>
* CREATE TABLE TEST(ID INT, NAME VARCHAR);
* INSERT INTO TEST VALUES('Hello');
* </pre>
*/
public
static
final
int
COLUMN_COUNT_DOES_NOT_MATCH
=
21002
;
// 22: data exception
...
...
@@ -62,16 +111,14 @@ public class ErrorCode {
public
static
final
int
METHOD_ONLY_ALLOWED_FOR_QUERY
=
90002
;
/**
* Thrown when trying to convert a String to a binary value. Two hex digits
* The error with code <code>90003</code> is thrown when
* trying to convert a String to a binary value. Two hex digits
* per byte are required. Example:
*
* <pre>
* CALL X'00023';
* Hexadecimal string with odd number of characters: 00023
* </pre>
*
* Correct:
*
* <pre>
* CALL X'000023';
* </pre>
...
...
@@ -91,17 +138,17 @@ public class ErrorCode {
public
static
final
int
SUM_OR_AVG_ON_WRONG_DATATYPE_1
=
90015
;
/**
* The column must be included in the GROUP BY clause. Example:
*
* The error with code <code>90016</code> is thrown when
* a column was used in the expression list or the order by clause
* of a group or aggregate query, and that column is not in the GROUP BY clause.
* Example:
* <pre>
* CREATE TABLE TEST(ID INT, NAME VARCHAR);
* INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World');
* SELECT ID, MAX(NAME) FROM TEST;
* Column ID must be in the GROUP BY list.
* </pre>
*
* Correct:
*
* <pre>
* SELECT ID, MAX(NAME) FROM TEST GROUP BY ID;
* </pre>
...
...
@@ -110,13 +157,13 @@ public class ErrorCode {
public
static
final
int
SECOND_PRIMARY_KEY
=
90017
;
/**
* The connection was opened, but never closed. In the finalizer of the
* The error with code <code>90018</code> is thrown when
* the connection was opened, but never closed. In the finalizer of the
* connection, this forgotten close was detected and the connection was
* closed automatically, but relying on the finalizer is not good practice
* as it is not guaranteed and behavior is virtual machine dependent. The
* application should close the connection. This exception only appears in
* the .trace.db file. Example:
*
* <pre>
* Connection conn = DriverManager.getConnection("jdbc:h2:˜/test");
* conn = null;
...
...
@@ -126,7 +173,6 @@ public class ErrorCode {
* <pre>
* conn.close();
* </pre>
*
*/
public
static
final
int
TRACE_CONNECTION_NOT_CLOSED
=
90018
;
public
static
final
int
CANNOT_DROP_CURRENT_USER
=
90019
;
...
...
@@ -180,7 +226,9 @@ public class ErrorCode {
public
static
final
int
CONNECTION_BROKEN
=
90067
;
/**
* The given expression that is used in the ORDER BY clause must be in the result list, otherwise the result would be ambiguous.
* The error with code <code>90068</code> is thrown when
* the given expression that is used in the ORDER BY is not in the result list.
* This is required for distinct queries, otherwise the result would be ambiguous.
* <pre>
* CREATE TABLE TEST(ID INT, NAME VARCHAR);
* INSERT INTO TEST VALUES(2, 'Hello'), (1, 'Hello');
...
...
@@ -211,8 +259,8 @@ public class ErrorCode {
public
static
final
int
CANNOT_DROP_LAST_COLUMN
=
90084
;
/**
* The
index was generated by the system because of a unique constraint,
*
and it is not allowed to drop it manually
.
* The
error with code <code>90085</code> is thrown when
*
trying to manually drop an index that was generated by the system because of a unique constraint
.
* <pre>
* CREATE TABLE TEST(ID INT, CONSTRAINT UID UNIQUE(ID));
* DROP INDEX UID_INDEX_0;
...
...
@@ -229,7 +277,10 @@ public class ErrorCode {
public
static
final
int
UNKNOWN_MODE_1
=
90088
;
/**
* The collection of the database must be set when the database is empty.
* The error with code <code>90089</code> is thrown when
* trying to change the collation while there was already data in
* the database. The collation of the database must be set when the
* database is empty.
* <pre>
* CREATE TABLE TEST(NAME VARCHAR PRIMARY KEY);
* INSERT INTO TEST VALUES('Hello', 'World');
...
...
@@ -268,7 +319,8 @@ public class ErrorCode {
public
static
final
int
ERROR_ACCESSING_LINKED_TABLE_2
=
90111
;
/**
* When locking was disabled, a row was deleted twice.
* The error with code <code>90112</code> is thrown when
* a row was deleted twice while locking was disabled.
* This is an intern exception that should never be thrown to the application,
* because such deleted should be detected and the resulting exception ignored inside the database engine.
* <pre>
...
...
@@ -290,7 +342,8 @@ public class ErrorCode {
public
static
final
int
FILE_NOT_FOUND_1
=
90124
;
/**
* This exception is thrown when PreparedStatement.setBigDecimal is called
* The error with code <code>90125</code> is thrown when
* PreparedStatement.setBigDecimal is called
* with object that extends the class BigDecimal, and the system property
* h2.allowBigDecimalExtensions is not set. Using extensions of BigDecimal is
* dangerous because the database relies on the behavior of BigDecimal.
...
...
@@ -319,7 +372,8 @@ public class ErrorCode {
public
static
final
int
UNSUPPORTED_OUTER_JOIN_CONDITION_1
=
90136
;
/**
* Can only assign to a variable.
* The error with code <code>90137</code> is thrown when
* trying to assign a value to something that is not a variable.
* <pre>
* SELECT AMOUNT, SET(@V, IFNULL(@V, 0)+AMOUNT) FROM TEST;
* </pre>
...
...
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
40b88b0d
...
...
@@ -62,7 +62,18 @@ public class SysProperties {
* Comma separated list of class names or prefixes.
*/
public
static
final
String
BIND_ADDRESS
=
getStringSetting
(
"h2.bindAddress"
,
null
);
/**
* System property <code>h2.cacheSizeDefault</code> (default: 16384).<br />
* The default cache size in KB.
*/
public
static
final
int
CACHE_SIZE_DEFAULT
=
getIntSetting
(
"h2.cacheSizeDefault"
,
16
*
1024
);
/**
* System property <code>h2.cacheSizeIndexShift</code> (default: 3).<br />
* How many time the cache size value is divided by two to get the index cache size.
* The index cache size is calculated like this: cacheSize >> cacheSizeIndexShift.
*/
public
static
final
int
CACHE_SIZE_INDEX_SHIFT
=
getIntSetting
(
"h2.cacheSizeIndexShift"
,
3
);
/**
...
...
@@ -89,12 +100,27 @@ public class SysProperties {
public
static
final
String
CLIENT_TRACE_DIRECTORY
=
getStringSetting
(
"h2.clientTraceDirectory"
,
"trace.db/"
);
/**
* System property <code>h2.
check2</code> (default: true
).<br />
*
Additional assertions in the database engine
.
* System property <code>h2.
defaultMaxOperationMemory</code> (default: 100000
).<br />
*
The default for the setting MAX_OPERATION_MEMORY
.
*/
public
static
final
int
DEFAULT_MAX_OPERATION_MEMORY
=
getIntSetting
(
"h2.defaultMaxOperationMemory"
,
100000
);
/**
* System property <code>h2.dataSourceTraceLevel</code> (default: 1).<br />
* The trace level of the data source implementation. Default is 1 for error.
*/
public
static
final
int
DATASOURCE_TRACE_LEVEL
=
getIntSetting
(
"h2.dataSourceTraceLevel"
,
TraceSystem
.
ERROR
);
/**
* System property <code>h2.defaultMaxMemoryUndo</code> (default: 100000).<br />
* The default value for the MAX_MEMORY_UNDO setting.
*/
public
static
final
int
DEFAULT_MAX_MEMORY_UNDO
=
getIntSetting
(
"h2.defaultMaxMemoryUndo"
,
100000
);
/**
* System property <code>h2.defaultLockMode</code> (default: 3).<br />
* The default value for the LOCK_MODE setting.
*/
public
static
final
int
DEFAULT_LOCK_MODE
=
getIntSetting
(
"h2.defaultLockMode"
,
Constants
.
LOCK_MODE_READ_COMMITTED
);
/**
...
...
@@ -109,8 +135,6 @@ public class SysProperties {
*/
public
static
final
int
EMERGENCY_SPACE_MIN
=
getIntSetting
(
"h2.emergencySpaceMin"
,
64
*
1024
);
public
static
final
boolean
INDEX_LOOKUP_NEW
=
getBooleanSetting
(
"h2.indexLookupNew"
,
true
);
/**
* System property <code>h2.lobCloseBetweenReads</code> (default: false).<br />
* Close LOB files between read operations.
...
...
@@ -147,9 +171,19 @@ public class SysProperties {
* Number of times to retry file delete and rename.
*/
public
static
final
int
MAX_FILE_RETRY
=
Math
.
max
(
1
,
getIntSetting
(
"h2.maxFileRetry"
,
16
));
/**
* System property <code>h2.minColumnNameMap</code> (default: 3).<br />
* The minimum number of columns where a hash table is created when result set
* methods with column name (instead of column index) parameter are called.
*/
public
static
final
int
MIN_COLUMN_NAME_MAP
=
getIntSetting
(
"h2.minColumnNameMap"
,
3
);
/**
* System property <code>h2.minWriteDelay</code> (default: 5).<br />
* The minimum write delay that causes commits to be delayed.
*/
public
static
final
int
MIN_WRITE_DELAY
=
getIntSetting
(
"h2.minWriteDelay"
,
5
);
public
static
final
boolean
NEW_DISPLAY_SIZE
=
getBooleanSetting
(
"h2.newDisplaySize"
,
true
);
/**
* System property <code>h2.objectCache</code> (default: true).<br />
...
...
@@ -192,6 +226,11 @@ public class SysProperties {
* Optimize IN(...) comparisons.
*/
public
static
final
boolean
OPTIMIZE_IN
=
getBooleanSetting
(
"h2.optimizeIn"
,
true
);
/**
* System property <code>h2.optimizeInJoin</code> (default: false).<br />
* Optimize IN(SELECT ...) comparisons by converting them to a join.
*/
public
static
final
boolean
OPTIMIZE_IN_JOIN
=
getBooleanSetting
(
"h2.optimizeInJoin"
,
false
);
/**
...
...
@@ -205,7 +244,17 @@ public class SysProperties {
* Cache subquery results.
*/
public
static
final
boolean
OPTIMIZE_SUBQUERY_CACHE
=
getBooleanSetting
(
"h2.optimizeSubqueryCache"
,
true
);
/**
* System property <code>h2.optimizeNot</code> (default: true).<br />
* Optimize NOT expression.
*/
public
static
final
boolean
OPTIMIZE_NOT
=
getBooleanSetting
(
"h2.optimizeNot"
,
true
);
/**
* System property <code>h2.optimizeTwoEquals</code> (default: true).<br />
* Optimize expressions of the form A=B AND B=1. In this case, AND A=1 is added so an index on A can be used.
*/
public
static
final
boolean
OPTIMIZE_TWO_EQUALS
=
getBooleanSetting
(
"h2.optimizeTwoEquals"
,
true
);
/**
...
...
@@ -249,6 +298,11 @@ public class SysProperties {
* The default result set fetch size when using the server mode.
*/
public
static
final
int
SERVER_RESULT_SET_FETCH_SIZE
=
getIntSetting
(
"h2.serverResultSetFetchSize"
,
100
);
/**
* System property <code>h2.traceIO</code> (default: false).<br />
* Trace I/O operations.
*/
public
static
final
boolean
TRACE_IO
=
getBooleanSetting
(
"h2.traceIO"
,
false
);
private
static
String
baseDir
=
getStringSetting
(
"h2.baseDir"
,
null
);
...
...
h2/src/main/org/h2/constraint/ConstraintReferential.java
浏览文件 @
40b88b0d
...
...
@@ -5,10 +5,10 @@
package
org
.
h2
.
constraint
;
import
java.sql.SQLException
;
import
org.h2.command.Parser
;
import
org.h2.command.Prepared
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
import
org.h2.expression.Parameter
;
...
...
@@ -288,11 +288,7 @@ public class ConstraintReferential extends Constraint {
Cursor
cursor
=
index
.
find
(
session
,
check
,
check
);
while
(
cursor
.
next
())
{
SearchRow
found
;
if
(
SysProperties
.
INDEX_LOOKUP_NEW
)
{
found
=
cursor
.
getSearchRow
();
}
else
{
found
=
cursor
.
get
();
}
found
=
cursor
.
getSearchRow
();
Column
[]
cols
=
index
.
getColumns
();
boolean
allEqual
=
true
;
for
(
int
i
=
0
;
i
<
columns
.
length
&&
i
<
cols
.
length
;
i
++)
{
...
...
h2/src/main/org/h2/result/LocalResult.java
浏览文件 @
40b88b0d
...
...
@@ -8,7 +8,6 @@ import java.sql.ResultSet;
import
java.sql.ResultSetMetaData
;
import
java.sql.SQLException
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.expression.Expression
;
...
...
@@ -38,7 +37,6 @@ public class LocalResult implements ResultInterface {
private
SortOrder
sort
;
private
ValueHashMap
distinctRows
;
private
Value
[]
currentRow
;
private
int
[]
displaySizes
;
private
int
offset
,
limit
;
private
ResultDiskBuffer
disk
;
private
int
diskOffset
;
...
...
@@ -99,7 +97,6 @@ public class LocalResult implements ResultInterface {
copy
.
sort
=
this
.
sort
;
copy
.
distinctRows
=
this
.
distinctRows
;
copy
.
currentRow
=
null
;
copy
.
displaySizes
=
this
.
displaySizes
;
copy
.
offset
=
0
;
copy
.
limit
=
0
;
copy
.
disk
=
this
.
disk
;
...
...
@@ -138,7 +135,6 @@ public class LocalResult implements ResultInterface {
this
.
visibleColumnCount
=
visibleColumnCount
;
rowId
=
-
1
;
this
.
expressions
=
expressions
;
this
.
displaySizes
=
new
int
[
expressions
.
length
];
}
public
void
setSortOrder
(
SortOrder
sort
)
{
...
...
@@ -205,13 +201,6 @@ public class LocalResult implements ResultInterface {
}
public
void
addRow
(
Value
[]
values
)
throws
SQLException
{
if
(!
SysProperties
.
NEW_DISPLAY_SIZE
)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
Value
v
=
values
[
i
];
int
size
=
v
.
getDisplaySize
();
displaySizes
[
i
]
=
Math
.
max
(
displaySizes
[
i
],
size
);
}
}
if
(
distinctRows
!=
null
)
{
ValueArray
array
=
ValueArray
.
get
(
values
);
distinctRows
.
put
(
array
,
values
);
...
...
@@ -299,11 +288,7 @@ public class LocalResult implements ResultInterface {
}
public
int
getDisplaySize
(
int
i
)
{
if
(
SysProperties
.
NEW_DISPLAY_SIZE
)
{
return
expressions
[
i
].
getDisplaySize
();
}
else
{
return
displaySizes
[
i
];
}
return
expressions
[
i
].
getDisplaySize
();
}
public
String
getColumnName
(
int
i
)
{
...
...
h2/src/main/org/h2/table/TableFilter.java
浏览文件 @
40b88b0d
...
...
@@ -538,29 +538,18 @@ public class TableFilter implements ColumnResolver {
}
public
Value
getValue
(
Column
column
)
throws
SQLException
{
if
(
SysProperties
.
INDEX_LOOKUP_NEW
)
{
if
(
currentSearchRow
==
null
)
{
return
null
;
}
int
columnId
=
column
.
getColumnId
();
if
(
current
==
null
)
{
Value
v
=
currentSearchRow
.
getValue
(
columnId
);
if
(
v
!=
null
)
{
return
v
;
}
current
=
cursor
.
get
();
}
return
current
.
getValue
(
columnId
);
}
else
{
if
(
currentSearchRow
==
null
)
{
return
null
;
}
if
(
current
==
null
)
{
current
=
cursor
.
get
();
if
(
currentSearchRow
==
null
)
{
return
null
;
}
int
columnId
=
column
.
getColumnId
();
if
(
current
==
null
)
{
Value
v
=
currentSearchRow
.
getValue
(
columnId
);
if
(
v
!=
null
)
{
return
v
;
}
int
columnId
=
column
.
getColumnId
();
return
current
.
getValue
(
columnId
);
current
=
cursor
.
get
();
}
return
current
.
getValue
(
columnId
);
}
public
TableFilter
getTableFilter
()
{
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
40b88b0d
...
...
@@ -150,6 +150,11 @@ java org.h2.test.TestAll timer
/*
CACHE_SIZE_INDEX_DEFAULT
INTERNAL
ErrorCodes doesn't look nice
Roadmap:
History:
...
...
h2/src/tools/org/h2/tools/doclet/Doclet.java
浏览文件 @
40b88b0d
...
...
@@ -137,22 +137,40 @@ public class Doclet {
if
(!
field
.
isFinal
()
||
!
field
.
isStatic
()
||
!
field
.
isPublic
())
{
continue
;
}
String
text
=
field
.
commentText
();
if
(
text
.
startsWith
(
"INTERNAL"
))
{
continue
;
}
if
(
fieldId
==
0
)
{
writer
.
println
(
"<br /><table><tr><th colspan=\"2\">Fields</th></tr>"
);
}
String
name
=
field
.
name
();
String
type
=
getTypeName
(
true
,
field
.
type
());
writer
.
println
(
"<tr><td class=\"return\">"
+
type
+
"</td><td class=\"method\">"
);
// writer.println("<a href=\"#f" + fieldId + "\">" + name + "</a>");
String
constant
=
field
.
constantValueExpression
();
// add a link (a name) if there is a <code> tag
int
linkStart
=
text
.
indexOf
(
"<code>"
);
if
(
linkStart
>=
0
)
{
int
linkEnd
=
text
.
indexOf
(
"</code>"
,
linkStart
);
String
link
=
text
.
substring
(
linkStart
+
"<code>"
.
length
(),
linkEnd
);
if
(
constant
!=
null
&&
!
constant
.
equals
(
link
))
{
throw
new
Error
(
"wrong code tag? "
+
clazz
.
name
()
+
"."
+
name
+
" code: "
+
link
+
" constant: "
+
constant
);
}
if
(
Character
.
isDigit
(
link
.
charAt
(
0
)))
{
link
=
"c"
+
link
;
}
writer
.
println
(
"<a name=\""
+
link
+
"\"></a>"
);
}
if
(
constant
==
null
)
{
writer
.
println
(
name
);
}
else
{
writer
.
println
(
name
+
" = "
+
constant
);
}
String
text
=
field
.
commentText
();
if
(
text
!=
null
)
{
writer
.
println
(
"<div class=\"
metho
dText\">"
+
formatText
(
text
)
+
"</div>"
);
writer
.
println
(
"<div class=\"
fiel
dText\">"
+
formatText
(
text
)
+
"</div>"
);
}
writer
.
println
(
"</td></tr>"
);
fieldId
++;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论