Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
97f0f775
提交
97f0f775
authored
10月 14, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
0840ef36
全部展开
显示空白字符变更
内嵌
并排
正在显示
27 个修改的文件
包含
498 行增加
和
73 行删除
+498
-73
changelog.html
h2/src/docsrc/html/changelog.html
+10
-1
roadmap.html
h2/src/docsrc/html/roadmap.html
+2
-0
_messages_en.properties
h2/src/docsrc/textbase/_messages_en.properties
+1
-1
ErrorCode.java
h2/src/main/org/h2/constant/ErrorCode.java
+5
-3
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+2
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+12
-0
Session.java
h2/src/main/org/h2/engine/Session.java
+7
-5
UndoLog.java
h2/src/main/org/h2/log/UndoLog.java
+14
-2
Message.java
h2/src/main/org/h2/message/Message.java
+27
-27
_messages_de.properties
h2/src/main/org/h2/res/_messages_de.properties
+1
-1
_messages_en.properties
h2/src/main/org/h2/res/_messages_en.properties
+1
-1
_messages_ja.properties
h2/src/main/org/h2/res/_messages_ja.properties
+1
-1
_messages_pl.properties
h2/src/main/org/h2/res/_messages_pl.properties
+1
-1
_messages_pt_br.properties
h2/src/main/org/h2/res/_messages_pt_br.properties
+1
-1
help.csv
h2/src/main/org/h2/res/help.csv
+37
-15
BitField.java
h2/src/main/org/h2/util/BitField.java
+4
-2
ObjectArray.java
h2/src/main/org/h2/util/ObjectArray.java
+10
-1
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+13
-3
TestOptimizations.java
h2/src/test/org/h2/test/db/TestOptimizations.java
+35
-0
TestOutOfMemory.java
h2/src/test/org/h2/test/db/TestOutOfMemory.java
+10
-1
TestPreparedStatement.java
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
+1
-1
TestFuzzOptimizations.java
h2/src/test/org/h2/test/synth/TestFuzzOptimizations.java
+1
-1
test-1.0.txt
h2/src/test/org/h2/test/test-1.0.txt
+6
-0
test-1.1.txt
h2/src/test/org/h2/test/test-1.1.txt
+6
-0
supportTemplates.txt
h2/src/test/org/h2/test/todo/supportTemplates.txt
+3
-3
TestDateIso8601.java
h2/src/test/org/h2/test/unit/TestDateIso8601.java
+262
-0
ThreadDumpFilter.java
h2/src/tools/org/h2/dev/util/ThreadDumpFilter.java
+25
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
97f0f775
...
...
@@ -18,7 +18,16 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Linked tables: compatibility with MS SQL Server has been improved.
<ul><li>
The wrong parameters were bound to subqueries with parameters, specially
when using IN(SELECT ...) and IN(...).
</li><li>
Unset parameters were not detected when the query was re-compiled.
</li><li>
New functions ISO_YEAR, ISO_WEEK, ISO_DAY_OF_WEEK.
Thanks a lot to Robert Rathsack for implementing those!
</li><li>
The date functions DAYOFYEAR, DAYOFMONTH, DAYOFWEEK are now called
DAY_OF_YEAR, DAY_OF_MONTH, DAY_OF_WEEK (the old names still work).
</li><li>
An out of memory error while deleting or updating many rows could
result in a strange exception.
</li><li>
Linked tables: compatibility with MS SQL Server has been improved.
</li><li>
Renaming tables that have foreign keys with cascade didn't work correctly.
</li><li>
The auto-reconnect feature didn't work when using the auto-server mode. Fixed.
</li><li>
Fulltext search: new method FT_DROP_INDEX.
...
...
h2/src/docsrc/html/roadmap.html
浏览文件 @
97f0f775
...
...
@@ -379,6 +379,8 @@ Of course, patches are always welcome, but are not always applied as is. Patches
</li><li>
Use http://recaptcha.net somehow to secure the Google Group.
</li><li>
Support DELETE with TOP or LIMIT. See also: http://dev.mysql.com/doc/refman/5.1/de/delete.html
</li><li>
Change the default for NULL || 'x' to return NULL
</li><li>
ANALYZE: Use a bloom filter for each indexed column to estimate count of distinct values.
</li><li>
ANALYZE: For unique indexes that allow null, count the number of null.
</li></ul>
<h2>
Not Planned
</h2>
...
...
h2/src/docsrc/textbase/_messages_en.properties
浏览文件 @
97f0f775
...
...
@@ -129,7 +129,7 @@
90105
=
Exception calling user-defined function
90106
=
Cannot truncate {0}
90107
=
Cannot drop {0} because {1} depends on it
90108
=
Out of memory.
Size
\:
{0}
90108
=
Out of memory.
90109
=
View {0} is invalid
\:
{1}
90110
=
{0} out of range
90111
=
Error accessing linked table with SQL statement {0}, cause
\:
{1}
...
...
h2/src/main/org/h2/constant/ErrorCode.java
浏览文件 @
97f0f775
...
...
@@ -1497,10 +1497,12 @@ public class ErrorCode {
public
static
final
int
CANNOT_DROP_2
=
90107
;
/**
* The error with code <code>90108</code> is thrown when
* not enough memory was available to read a value from the disk.
* The error with code <code>90108</code> is thrown when not enough heap
* memory was available. A possible solutions is to increase the memory size
* using <code>java -Xmx128m ...</code>. Another solution is to reduce
* the cache size.
*/
public
static
final
int
OUT_OF_MEMORY
_1
=
90108
;
public
static
final
int
OUT_OF_MEMORY
=
90108
;
/**
* The error with code <code>90109</code> is thrown when
...
...
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
97f0f775
...
...
@@ -443,12 +443,12 @@ public class SysProperties {
public
static
final
int
REDO_BUFFER_SIZE
=
getIntSetting
(
"h2.redoBufferSize"
,
256
*
1024
);
/**
* System property <code>h2.reserveMemory</code> (default:
131072
).<br />
* System property <code>h2.reserveMemory</code> (default:
524288
).<br />
* This many bytes in main memory are allocated as a reserve. This reserve
* is freed up when if no memory is available, so that rolling back a large
* transaction is easier.
*/
public
static
final
int
RESERVE_MEMORY
=
getIntSetting
(
"h2.reserveMemory"
,
128
*
1024
);
public
static
final
int
RESERVE_MEMORY
=
getIntSetting
(
"h2.reserveMemory"
,
512
*
1024
);
/**
* System property <code>h2.reuseSpaceAfter</code> (default: 16).<br />
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
97f0f775
...
...
@@ -2088,4 +2088,16 @@ public class Database implements DataHandler {
return
databaseShortName
+
":"
+
super
.
toString
();
}
/**
* Immediately close the database.
*/
public
void
shutdownImmediately
()
{
setPowerOffCount
(
1
);
try
{
checkPowerOff
();
}
catch
(
SQLException
e
)
{
// ignore
}
}
}
h2/src/main/org/h2/engine/Session.java
浏览文件 @
97f0f775
...
...
@@ -391,9 +391,10 @@ public class Session implements SessionInterface {
ArrayList
rows
=
new
ArrayList
();
synchronized
(
database
)
{
while
(
undoLog
.
size
()
>
0
)
{
UndoLogRecord
entry
=
undoLog
.
get
AndRemove
Last
();
UndoLogRecord
entry
=
undoLog
.
getLast
();
entry
.
commit
();
rows
.
add
(
entry
.
getRow
());
undoLog
.
removeLast
(
false
);
}
for
(
int
i
=
0
;
i
<
rows
.
size
();
i
++)
{
Row
r
=
(
Row
)
rows
.
get
(
i
);
...
...
@@ -440,7 +441,7 @@ public class Session implements SessionInterface {
currentTransactionName
=
null
;
boolean
needCommit
=
false
;
if
(
undoLog
.
size
()
>
0
)
{
rollbackTo
(
0
);
rollbackTo
(
0
,
false
);
needCommit
=
true
;
}
if
(
locks
.
size
()
>
0
||
needCommit
)
{
...
...
@@ -459,10 +460,11 @@ public class Session implements SessionInterface {
*
* @param index the position to which should be rolled back
*/
public
void
rollbackTo
(
int
index
)
throws
SQLException
{
public
void
rollbackTo
(
int
index
,
boolean
trimToSize
)
throws
SQLException
{
while
(
undoLog
.
size
()
>
index
)
{
UndoLogRecord
entry
=
undoLog
.
get
AndRemove
Last
();
UndoLogRecord
entry
=
undoLog
.
getLast
();
entry
.
undo
(
this
);
undoLog
.
removeLast
(
trimToSize
);
}
if
(
savepoints
!=
null
)
{
String
[]
names
=
new
String
[
savepoints
.
size
()];
...
...
@@ -687,7 +689,7 @@ public class Session implements SessionInterface {
throw
Message
.
getSQLException
(
ErrorCode
.
SAVEPOINT_IS_INVALID_1
,
name
);
}
int
i
=
id
.
intValue
();
rollbackTo
(
i
);
rollbackTo
(
i
,
false
);
}
/**
...
...
h2/src/main/org/h2/log/UndoLog.java
浏览文件 @
97f0f775
...
...
@@ -69,7 +69,7 @@ public class UndoLog {
*
* @return the last record
*/
public
UndoLogRecord
get
AndRemove
Last
()
throws
SQLException
{
public
UndoLogRecord
getLast
()
throws
SQLException
{
int
i
=
records
.
size
()
-
1
;
UndoLogRecord
entry
=
(
UndoLogRecord
)
records
.
get
(
i
);
if
(
entry
.
isStored
())
{
...
...
@@ -87,11 +87,23 @@ public class UndoLog {
}
first
.
seek
(
file
);
}
return
entry
;
}
/**
* Remove the last record from the list of operations.
*
* @param trimToSize if the undo array should shrink to conserve memory
*/
public
void
removeLast
(
boolean
trimToSize
)
{
int
i
=
records
.
size
()
-
1
;
UndoLogRecord
r
=
(
UndoLogRecord
)
records
.
remove
(
i
);
if
(!
r
.
isStored
())
{
memoryUndo
--;
}
return
entry
;
if
(
trimToSize
&&
i
>
1024
&&
(
i
&
1023
)
==
0
)
{
records
.
trimToSize
();
}
}
/**
...
...
h2/src/main/org/h2/message/Message.java
浏览文件 @
97f0f775
...
...
@@ -22,10 +22,10 @@ import org.h2.util.Resources;
import
org.h2.util.StringUtils
;
/**
* Messages used in the database engine.
*
Use the PropertiesToUTF8 tool to translate properties files to UTF-8 and back.
*
If the word 'SQL' appears then the whole SQL statement must be a parameter,
*
otherwise this may be added: ';
SQL statement: ' + sql
* Messages used in the database engine.
Use the PropertiesToUTF8 tool to
*
translate properties files to UTF-8 and back. If the word 'SQL' appears then
*
the whole SQL statement must be a parameter, otherwise this may be added: ';
* SQL statement: ' + sql
*/
public
class
Message
{
...
...
@@ -39,7 +39,7 @@ public class Message {
}
String
language
=
Locale
.
getDefault
().
getLanguage
();
if
(!
"en"
.
equals
(
language
))
{
byte
[]
translations
=
Resources
.
get
(
"/org/h2/res/_messages_"
+
language
+
".properties"
);
byte
[]
translations
=
Resources
.
get
(
"/org/h2/res/_messages_"
+
language
+
".properties"
);
// message: translated message + english
// (otherwise certain applications don't work)
if
(
translations
!=
null
)
{
...
...
@@ -80,7 +80,7 @@ public class Message {
private
static
String
translate
(
String
key
,
String
[]
param
)
{
String
message
=
MESSAGES
.
getProperty
(
key
);
if
(
message
==
null
)
{
message
=
"(Message "
+
key
+
" not found)"
;
message
=
"(Message "
+
key
+
" not found)"
;
}
if
(
param
!=
null
)
{
Object
[]
o
=
param
;
...
...
@@ -136,7 +136,7 @@ public class Message {
*/
public
static
SQLException
getSyntaxError
(
String
sql
,
int
index
,
String
expected
)
{
sql
=
StringUtils
.
addAsterisk
(
sql
,
index
);
return
getSQLException
(
ErrorCode
.
SYNTAX_ERROR_2
,
new
String
[]
{
sql
,
expected
});
return
getSQLException
(
ErrorCode
.
SYNTAX_ERROR_2
,
new
String
[]
{
sql
,
expected
});
}
/**
...
...
@@ -166,7 +166,7 @@ public class Message {
* @return the SQLException object
*/
public
static
JdbcSQLException
getInvalidValueException
(
String
value
,
String
param
)
{
return
getSQLException
(
ErrorCode
.
INVALID_VALUE_2
,
new
String
[]
{
value
,
param
});
return
getSQLException
(
ErrorCode
.
INVALID_VALUE_2
,
new
String
[]
{
value
,
param
});
}
/**
...
...
@@ -190,9 +190,9 @@ public class Message {
*/
public
static
Error
getInternalError
(
String
s
,
Exception
e
)
{
Error
e2
=
new
Error
(
s
);
//## Java 1.4 begin ##
//
## Java 1.4 begin ##
e2
.
initCause
(
e
);
//## Java 1.4 end ##
//
## Java 1.4 end ##
TraceSystem
.
traceThrowable
(
e2
);
return
e2
;
}
...
...
@@ -212,9 +212,7 @@ public class Message {
}
return
j
;
}
return
new
JdbcSQLException
(
e
.
getMessage
(),
sql
,
e
.
getSQLState
(),
e
.
getErrorCode
(),
e
,
null
);
return
new
JdbcSQLException
(
e
.
getMessage
(),
sql
,
e
.
getSQLState
(),
e
.
getErrorCode
(),
e
,
null
);
}
/**
...
...
@@ -244,6 +242,8 @@ public class Message {
}
if
(
e
instanceof
SQLException
)
{
return
(
SQLException
)
e
;
}
else
if
(
e
instanceof
OutOfMemoryError
)
{
return
getSQLException
(
ErrorCode
.
OUT_OF_MEMORY
,
null
,
e
);
}
else
if
(
e
instanceof
InvocationTargetException
)
{
InvocationTargetException
te
=
(
InvocationTargetException
)
e
;
Throwable
t
=
te
.
getTargetException
();
...
...
@@ -254,7 +254,7 @@ public class Message {
}
else
if
(
e
instanceof
IOException
)
{
return
getSQLException
(
ErrorCode
.
IO_EXCEPTION_1
,
new
String
[]
{
e
.
toString
()
},
e
);
}
return
getSQLException
(
ErrorCode
.
GENERAL_ERROR_1
,
new
String
[]
{
e
.
toString
()
},
e
);
return
getSQLException
(
ErrorCode
.
GENERAL_ERROR_1
,
new
String
[]
{
e
.
toString
()
},
e
);
}
/**
...
...
@@ -266,9 +266,9 @@ public class Message {
*/
public
static
SQLException
convertIOException
(
IOException
e
,
String
message
)
{
if
(
message
==
null
)
{
return
getSQLException
(
ErrorCode
.
IO_EXCEPTION_1
,
new
String
[]
{
e
.
toString
()
},
e
);
return
getSQLException
(
ErrorCode
.
IO_EXCEPTION_1
,
new
String
[]
{
e
.
toString
()
},
e
);
}
return
getSQLException
(
ErrorCode
.
IO_EXCEPTION_2
,
new
String
[]
{
e
.
toString
(),
message
},
e
);
return
getSQLException
(
ErrorCode
.
IO_EXCEPTION_2
,
new
String
[]
{
e
.
toString
(),
message
},
e
);
}
/**
...
...
@@ -304,9 +304,9 @@ public class Message {
}
}
IOException
io
=
new
IOException
(
e
.
toString
());
//## Java 1.4 begin ##
//
## Java 1.4 begin ##
io
.
initCause
(
e
);
//## Java 1.4 end ##
//
## Java 1.4 end ##
return
io
;
}
...
...
h2/src/main/org/h2/res/_messages_de.properties
浏览文件 @
97f0f775
...
...
@@ -129,7 +129,7 @@
90105
=
Fehler beim Aufruf eine benutzerdefinierten Funktion
90106
=
Kann {0} nicht zur
\u
00FCcksetzen per TRUNCATE
90107
=
Kann {0} nicht l
\u
00F6schen weil {1} davon abh
\u
00E4ngt
90108
=
Nicht genug Hauptspeicher.
Anzahl Bytes
\:
{0}
90108
=
Nicht genug Hauptspeicher.
90109
=
View {0} ist ung
\u
00FCltig
\:
{1}
90110
=
{0} ausserhalb des Bereichts
90111
=
Fehler beim Zugriff auf eine verkn
\u
00FCpfte Tabelle mit SQL Befehl {0}, Grund
\:
{1}
...
...
h2/src/main/org/h2/res/_messages_en.properties
浏览文件 @
97f0f775
...
...
@@ -129,7 +129,7 @@
90105
=
Exception calling user-defined function
90106
=
Cannot truncate {0}
90107
=
Cannot drop {0} because {1} depends on it
90108
=
Out of memory.
Size
\:
{0}
90108
=
Out of memory.
90109
=
View {0} is invalid
\:
{1}
90110
=
{0} out of range
90111
=
Error accessing linked table with SQL statement {0}, cause
\:
{1}
...
...
h2/src/main/org/h2/res/_messages_ja.properties
浏览文件 @
97f0f775
...
...
@@ -129,7 +129,7 @@
90105
=
\u
30E6
\u
30FC
\u
30B6
\u
5B9A
\u
7FA9
\u
95A2
\u6570\u3092\u
5B9F
\u
884C
\u
4E2D
\u
306B
\u
4F8B
\u5916\u
304C
\u
767A
\u
751F
\u3057\u
307E
\u3057\u
305F
90106
=
{0}
\u3092\u
7A7A
\u
306B
\u3067\u
304D
\u
307E
\u
305B
\u3093
90107
=
{1}
\u
304C
\u
4F9D
\u
5B58
\u3057\u3066\u3044\u
308B
\u
305F
\u3081\u3001
{0}
\u3092\u
30C9
\u
30ED
\u
30C3
\u
30D7
\u3059\u
308B
\u3053\u3068\u
306F
\u3067\u
304D
\u
307E
\u
305B
\u3093
90108
=
\u
30E1
\u
30E2
\u
30EA
\u
304C
\u
4E0D
\u
8DB3
\u3057\u3066\u3044\u
307E
\u3059\u3002\u
30B5
\u
30A4
\u
30BA
\:
{0}
90108
=
#\u30E1\u30E2\u30EA\u304C\u4E0D\u8DB3\u3057\u3066\u3044\u307E\u3059\u3002\u30B5\u30A4\u30BA\
90109=
\u
30D3
\u
30E5
\u
30FC {0}
\u
304C
\u7121\u
52B9
\u3067\u3059\:
{1}
90110
=
{0}
\u
306F
\u
7BC4
\u
56F2
\u5916\u3067\u3059
90111
=
SQL
\u
30B9
\u
30C6
\u
30FC
\u
30C8
\u
30E1
\u
30F3
\u
30C8 {0}
\u
306B
\u3088\u
308B
\u
7D50
\u5408\u
30C6
\u
30FC
\u
30D6
\u
30EB
\u
30A2
\u
30AF
\u
30BB
\u
30B9
\u
30A8
\u
30E9
\u
30FC
...
...
h2/src/main/org/h2/res/_messages_pl.properties
浏览文件 @
97f0f775
...
...
@@ -129,7 +129,7 @@
90105
=
Wyjatek wywoluje funkcje uzytkownika
90106
=
Nie mozna obciac {0}
90107
=
Nie mozna skasowac {0} poniewaz zalezy od {1}
90108
=
\#
Out of memory.
Size
\:
{0}
90108
=
\#
Out of memory.
90109
=
Widok {0} jest nieprawidlowy
90110
=
{0} poza zakresem
90111
=
\#
Error accessing linked table with SQL statement {0}, cause
\:
{1}
...
...
h2/src/main/org/h2/res/_messages_pt_br.properties
浏览文件 @
97f0f775
...
...
@@ -129,7 +129,7 @@
90105
=
Exce
\u
00E7
\u
00E3o na chamada da fun
\u
00E7
\u
00E3o definida pelo usu
\u
00E1rio
90106
=
N
\u
00E3o pode fazer o truncate {0}
90107
=
N
\u
00E3o pode apagar {0} por que depende de {1}
90108
=
\#
Out of memory.
Size
\:
{0}
90108
=
\#
Out of memory.
90109
=
Vista {0}
\u
00E9 inv
\u
00E1lida
\:
{1}
90110
=
{0} out of range
90111
=
Erro ao acessar a tabela lincada com a instru
\u
00E7
\u
00E3o SQL {0}, causa
\:
{1}
...
...
h2/src/main/org/h2/res/help.csv
浏览文件 @
97f0f775
...
...
@@ -2493,6 +2493,7 @@ The value is encoded as XML text.
","
CALL XMLNODE('a', XMLATTR('href', 'http://h2database.com'))
"
"Functions (String)","XMLNODE","
XMLNODE(elementString [, attributesString [, contentString]]): string
","
...
...
@@ -2500,6 +2501,7 @@ Create an XML node element.
","
CALL XMLNODE('a', XMLATTR('href', 'http://h2database.com'), 'H2')
"
"Functions (String)","XMLCOMMENT","
XMLCOMMENT(commentString): string
","
...
...
@@ -2507,6 +2509,7 @@ Creates an XML comment. Two dashes (--) are converted to - -.
","
CALL XMLCOMMENT('Test')
"
"Functions (String)","XMLCDATA","
XMLCDATA(valueString): string
","
...
...
@@ -2514,6 +2517,7 @@ Creates an XML CDATA element. If the value contains ']]>', an XML text element i
","
CALL XMLCDATA('data')
"
"Functions (String)","XMLSTARTDOC","
XMLSTARTDOC(): string
","
...
...
@@ -2521,6 +2525,7 @@ The string '<?xml version=""1.0""?>' is returned.
","
CALL XMLSTARTDOC()
"
"Functions (String)","XMLTEXT","
XMLTEXT(valueString): string
","
...
...
@@ -2528,6 +2533,7 @@ Creates an XML text element.
","
CALL XMLTEXT('test')
"
"Functions (Time and Date)","CURRENT_DATE","
{CURRENT_DATE[()] | CURDATE() | SYSDATE | TODAY}: date
","
...
...
@@ -2535,6 +2541,7 @@ Returns the current date.
","
CURRENT_DATE()
"
"Functions (Time and Date)","CURRENT_TIME","
{CURRENT_TIME[()] | CURTIME()}: time
","
...
...
@@ -2542,6 +2549,7 @@ Returns the current time.
","
CURRENT_TIME()
"
"Functions (Time and Date)","CURRENT_TIMESTAMP","
{CURRENT_TIMESTAMP[([int])] | NOW([int])}: timestamp
","
...
...
@@ -2550,24 +2558,25 @@ The precision parameter for nanoseconds precision is optional.
","
CURRENT_TIMESTAMP()
"
"Functions (Time and Date)","DATEADD","
DATEADD(unitString, addInt, timestamp): timestamp
","
Adds units to a timestamp. The string indicates the unit. Use negative values to subtract units.
The following units are supported:
YY, YEAR, MM, MONTH, DD, DAY, HH, HOUR, MI, MINUTE, SS, SECOND, MS, MILLISECOND.
The same units as in the EXTRACT function are supported.
","
DATEADD('MONTH', 1, DATE '2001-01-31')
"
"Functions (Time and Date)","DATEDIFF","
DATEDIFF(unitString, aTimestamp, bTimestamp): long
","
Returns the difference between two timestamps. The string indicates the unit.
The following units are supported:
YY, YEAR, MM, MONTH, DD, DAY, HH, HOUR, MI, MINUTE, SS, SECOND, MS, MILLISECOND.
The same units as in the EXTRACT function are supported.
","
DATEDIFF('YEAR', T1.CREATED, T2.CREATED)
"
"Functions (Time and Date)","DAYNAME","
DAYNAME(date): string
","
...
...
@@ -2575,37 +2584,42 @@ Returns the name of the day (in English).
","
DAYNAME(CREATED)
"
"Functions (Time and Date)","DAYOFMONTH","
DAYOFMONTH(date): int
"Functions (Time and Date)","DAY_OF_MONTH","
DAY_OF_MONTH(date): int
","
Returns the day of the month (1-31).
","
DAY
OF
MONTH(CREATED)
DAY
_OF_
MONTH(CREATED)
"
"Functions (Time and Date)","DAYOFWEEK","
DAYOFWEEK(date): int
"Functions (Time and Date)","DAY_OF_WEEK","
DAY_OF_WEEK(date): int
","
Returns the day of the week (1 means Sunday).
","
DAY
OF
WEEK(CREATED)
DAY
_OF_
WEEK(CREATED)
"
"Functions (Time and Date)","DAYOFYEAR","
DAYOFYEAR(date): int
"Functions (Time and Date)","DAY_OF_YEAR","
DAY_OF_YEAR(date): int
","
Returns the day of the year (1-366).
","
DAY
OF
YEAR(CREATED)
DAY
_OF_
YEAR(CREATED)
"
"Functions (Time and Date)","EXTRACT","
EXTRACT(
{Y
Y | YEAR | MM | MONTH | DD | DAY | HH | HOUR |
MI | MINUTE | SS | SECOND | MS | MILLISECOND
}
{Y
EAR | YY | MONTH | MM | DAY | DD | DAY_OF_YEAR | DOY |
HOUR | HH | MINUTE | MI | SECOND | SS | MILLISECOND | MS
}
FROM timestamp): int
","
Returns a specific value from a timestamps.
","
EXTRACT(SECOND FROM CURRENT_TIMESTAMP)
"
"Functions (Time and Date)","FORMATDATETIME","
FORMATDATETIME(timestamp, formatString [, localeString [, timeZoneString]]): string
","
...
...
@@ -2615,6 +2629,7 @@ For details of the format, see java.text.SimpleDateFormat.
","
CALL FORMATDATETIME(TIMESTAMP '2001-02-03 04:05:06', 'EEE, d MMM yyyy HH:mm:ss z', 'en', 'GMT')
"
"Functions (Time and Date)","HOUR","
HOUR(timestamp): int
","
...
...
@@ -2629,6 +2644,7 @@ Returns the minute (0-59) from a timestamp.
","
MINUTE(CREATED)
"
"Functions (Time and Date)","MONTH","
MONTH(timestamp): int
","
...
...
@@ -2636,6 +2652,7 @@ Returns the month (1-12) from a timestamp.
","
MONTH(CREATED)
"
"Functions (Time and Date)","MONTHNAME","
MONTHNAME(date): string
","
...
...
@@ -2643,6 +2660,7 @@ Returns the name of the month (in English).
","
MONTHNAME(CREATED)
"
"Functions (Time and Date)","PARSEDATETIME","
PARSEDATETIME(string, formatString [, localeString [, timeZoneString]]): string
","
...
...
@@ -2652,6 +2670,7 @@ For details of the format, see java.text.SimpleDateFormat.
","
CALL PARSEDATETIME('Sat, 3 Feb 2001 03:05:06 GMT', 'EEE, d MMM yyyy HH:mm:ss z', 'en', 'GMT')
"
"Functions (Time and Date)","QUARTER","
QUARTER(timestamp): int
","
...
...
@@ -2659,6 +2678,7 @@ Returns the quarter (1-4) from a timestamp.
","
QUARTER(CREATED)
"
"Functions (Time and Date)","SECOND","
SECOND(timestamp): int
","
...
...
@@ -2666,6 +2686,7 @@ Returns the second (0-59) from a timestamp.
","
SECOND(CREATED)
"
"Functions (Time and Date)","WEEK","
WEEK(timestamp): int
","
...
...
@@ -2674,6 +2695,7 @@ This method uses the current system locale.
","
WEEK(CREATED)
"
"Functions (Time and Date)","YEAR","
YEAR(timestamp): int
","
...
...
h2/src/main/org/h2/util/BitField.java
浏览文件 @
97f0f775
...
...
@@ -153,8 +153,10 @@ public class BitField {
* @param len the number of bits to enable or disable
*/
public
void
setRange
(
int
start
,
int
len
,
boolean
value
)
{
for
(
int
end
=
start
+
len
;
start
<
end
;
start
++)
{
set
(
start
,
value
);
// go backwards so that OutOfMemory happens
// before some bytes are modified
for
(
int
i
=
start
+
len
-
1
;
i
>=
start
;
i
--)
{
set
(
i
,
value
);
}
}
...
...
h2/src/main/org/h2/util/ObjectArray.java
浏览文件 @
97f0f775
...
...
@@ -130,11 +130,20 @@ public class ObjectArray {
private
void
ensureCapacity
(
int
i
)
{
while
(
i
>=
data
.
length
)
{
Object
[]
d
=
new
Object
[
Math
.
max
(
CAPACITY_INIT
,
data
.
length
*
2
)];
System
.
arraycopy
(
data
,
0
,
d
,
0
,
data
.
length
);
System
.
arraycopy
(
data
,
0
,
d
,
0
,
size
);
data
=
d
;
}
}
/**
* Shrink the array to the required size.
*/
public
void
trimToSize
()
{
Object
[]
d
=
new
Object
[
size
];
System
.
arraycopy
(
data
,
0
,
d
,
0
,
size
);
data
=
d
;
}
/**
* Insert an element at the given position. The element at this position and
* all elements with a higher index move one element.
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
97f0f775
...
...
@@ -102,6 +102,7 @@ import org.h2.test.unit.TestCache;
import
org.h2.test.unit.TestCompress
;
import
org.h2.test.unit.TestDataPage
;
import
org.h2.test.unit.TestDate
;
import
org.h2.test.unit.TestDateIso8601
;
import
org.h2.test.unit.TestExit
;
import
org.h2.test.unit.TestFile
;
import
org.h2.test.unit.TestFileLock
;
...
...
@@ -278,13 +279,21 @@ java org.h2.test.TestAll timer
/*
java -Xmx3m
create table test(name varchar);
set max_log_size 1024;
@LOOP 20000 insert into test values(space(10000));
delete from test;
SELECT * FROM TEST where name like 'a';
test with 1.0
document shared connections for linked tables
document osgi
document url parameter auto_server
document url parameter auto_reconnect
document url parameter open_new
document shared connections for linked tables
document osgi
merge join test case
...
...
@@ -584,6 +593,7 @@ http://www.w3schools.com/sql/
new
TestCompress
().
runTest
(
this
);
new
TestDataPage
().
runTest
(
this
);
new
TestDate
().
runTest
(
this
);
new
TestDateIso8601
().
runTest
(
this
);
new
TestExit
().
runTest
(
this
);
new
TestFile
().
runTest
(
this
);
new
TestFileLock
().
runTest
(
this
);
...
...
h2/src/test/org/h2/test/db/TestOptimizations.java
浏览文件 @
97f0f775
...
...
@@ -37,6 +37,7 @@ public class TestOptimizations extends TestBase {
}
public
void
test
()
throws
Exception
{
testInSelectJoin
();
testMinMaxNullOptimization
();
if
(
config
.
networked
)
{
return
;
...
...
@@ -54,6 +55,40 @@ public class TestOptimizations extends TestBase {
testMinMaxCountOptimization
(
false
);
}
private
void
testInSelectJoin
()
throws
SQLException
{
deleteDb
(
"optimizations"
);
Connection
conn
=
getConnection
(
"optimizations"
);
Statement
stat
=
conn
.
createStatement
();
stat
.
execute
(
"create table test(a int, b int, c int, d int) "
+
"as select 1, 1, 1, 1 from dual;"
);
ResultSet
rs
;
PreparedStatement
prep
;
prep
=
conn
.
prepareStatement
(
"SELECT 2 FROM TEST A "
+
"INNER JOIN (SELECT DISTINCT B.C AS X FROM TEST B "
+
"WHERE B.D = ?2) V ON 1=1 WHERE (A = ?1) AND (B = V.X)"
);
prep
.
setInt
(
1
,
1
);
prep
.
setInt
(
2
,
1
);
rs
=
prep
.
executeQuery
();
assertTrue
(
rs
.
next
());
assertFalse
(
rs
.
next
());
boolean
old
=
SysProperties
.
optimizeInJoin
;
SysProperties
.
optimizeInJoin
=
true
;
prep
=
conn
.
prepareStatement
(
"select 2 from test a where a=? and b in("
+
"select b.c from test b where b.d=?)"
);
prep
.
setInt
(
1
,
1
);
prep
.
setInt
(
2
,
1
);
rs
=
prep
.
executeQuery
();
assertTrue
(
rs
.
next
());
assertFalse
(
rs
.
next
());
conn
.
close
();
SysProperties
.
optimizeInJoin
=
old
;
}
private
void
testOptimizeInJoinSelect
()
throws
SQLException
{
boolean
old
=
SysProperties
.
optimizeInJoin
;
SysProperties
.
optimizeInJoin
=
true
;
...
...
h2/src/test/org/h2/test/db/TestOutOfMemory.java
浏览文件 @
97f0f775
...
...
@@ -24,6 +24,15 @@ public class TestOutOfMemory extends TestBase {
private
LinkedList
list
=
new
LinkedList
();
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
[]
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
public
void
test
()
throws
SQLException
{
if
(
config
.
memory
||
config
.
mvcc
)
{
return
;
...
...
@@ -42,7 +51,7 @@ public class TestOutOfMemory extends TestBase {
prep
.
execute
();
fail
();
}
catch
(
SQLException
e
)
{
assertEquals
(
ErrorCode
.
GENERAL_ERROR_1
,
e
.
getErrorCode
());
assertEquals
(
ErrorCode
.
OUT_OF_MEMORY
,
e
.
getErrorCode
());
}
list
=
null
;
ResultSet
rs
=
stat
.
executeQuery
(
"select count(*) from stuff"
);
...
...
h2/src/test/org/h2/test/jdbc/TestPreparedStatement.java
浏览文件 @
97f0f775
...
...
@@ -531,7 +531,7 @@ public class TestPreparedStatement extends TestBase {
stat
.
execute
(
"CREATE TABLE TEST(ID INT)"
);
stat
.
execute
(
"INSERT INTO TEST VALUES(1),(2),(3)"
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
"select x.id, ? from "
+
"(select * from test where id in(?, ?)) x
"
+
"
where x.id*2 <> ?"
);
+
"(select * from test where id in(?, ?)) x where x.id*2 <> ?"
);
assertEquals
(
prep
.
getParameterMetaData
().
getParameterCount
(),
4
);
prep
.
setInt
(
1
,
0
);
prep
.
setInt
(
2
,
1
);
...
...
h2/src/test/org/h2/test/synth/TestFuzzOptimizations.java
浏览文件 @
97f0f775
...
...
@@ -84,7 +84,7 @@ public class TestFuzzOptimizations extends TestBase {
p
.
set
(
new
String
[]
{
null
,
"0"
,
"1"
,
"2"
}[
random
.
nextInt
(
4
)]);
p
.
execute
();
}
int
len
=
getSize
(
1000
,
10
000
);
int
len
=
getSize
(
1000
,
3
000
);
for
(
int
i
=
0
;
i
<
len
/
10
;
i
++)
{
db
.
execute
(
"CREATE TABLE TEST_INDEXED AS SELECT * FROM TEST"
);
int
jLen
=
1
+
random
.
nextInt
(
2
);
...
...
h2/src/test/org/h2/test/test-1.0.txt
浏览文件 @
97f0f775
--- special grammar and test cases ---------------------------------------------------------------------------------------------
select iso_week('2006-12-31') w, iso_year('2007-12-31') y, iso_day_of_week('2007-12-31') w;
> W Y W
> -- ---- -
> 52 2008 1
> rows: 1
create schema a;
> ok
...
...
h2/src/test/org/h2/test/test-1.1.txt
浏览文件 @
97f0f775
--- special grammar and test cases ---------------------------------------------------------------------------------------------
select iso_week('2006-12-31') w, iso_year('2007-12-31') y, iso_day_of_week('2007-12-31') w;
> W Y W
> -- ---- -
> 52 2008 1
> rows: 1
create schema a;
> ok
...
...
h2/src/test/org/h2/test/todo/supportTemplates.txt
浏览文件 @
97f0f775
...
...
@@ -55,12 +55,12 @@ I am sorry to say that, but it looks like a corruption problem. I am very intere
or two phase commit, linked tables, cache settings)?
- Is the application multi-threaded?
- On what operating system, file system, and virtual machine (java -version)?
- How big is the database?
- How big is the database
(file sizes)
?
- Is the database usually closed normally, or is process terminated forcefully
or the computer switched off?
- Is it possible to reproduce this problem using a fresh database
(sometimes, or always)?
- Are there any other exceptions (maybe in the .trace.db file)?
Could you send them
to me
please?
Could you send them please?
- Do you still have any .trace.db files, and if yes could you send them?
- Could you send
me
the .data.db file where this exception occurs?
- Could you send the .data.db file where this exception occurs?
h2/src/test/org/h2/test/unit/TestDateIso8601.java
0 → 100644
浏览文件 @
97f0f775
差异被折叠。
点击展开。
h2/src/tools/org/h2/dev/util/ThreadDumpFilter.java
0 → 100644
浏览文件 @
97f0f775
package
org
.
h2
.
dev
.
util
;
import
java.io.InputStreamReader
;
import
java.io.LineNumberReader
;
/**
* Filter full thread dumps from a log file.
*/
public
class
ThreadDumpFilter
{
/**
* Usage: java ThreadDumpFilter <log.txt >threadDump.txt
* @param a ignored
*/
public
static
void
main
(
String
[]
a
)
throws
Exception
{
LineNumberReader
in
=
new
LineNumberReader
(
new
InputStreamReader
(
System
.
in
));
for
(
String
s
;
(
s
=
in
.
readLine
())
!=
null
;)
{
if
(
s
.
startsWith
(
"Full thread"
))
{
do
{
System
.
out
.
println
(
s
);
s
=
in
.
readLine
();
}
while
(
s
!=
null
&&
(
s
.
length
()
==
0
||
"\t\""
.
indexOf
(
s
.
charAt
(
0
))
>=
0
));
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论