Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f61d2340
提交
f61d2340
authored
1月 16, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
f0bf7fad
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
89 行增加
和
52 行删除
+89
-52
datatypes.jsp
h2/src/docsrc/html/datatypes.jsp
+4
-4
functions.jsp
h2/src/docsrc/html/functions.jsp
+8
-8
grammar.jsp
h2/src/docsrc/html/grammar.jsp
+8
-8
_messages_en.properties
h2/src/docsrc/textbase/_messages_en.properties
+1
-1
Bnf.java
h2/src/main/org/h2/bnf/Bnf.java
+7
-8
ErrorCode.java
h2/src/main/org/h2/constant/ErrorCode.java
+2
-2
_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_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
+17
-0
UpdatableRow.java
h2/src/main/org/h2/result/UpdatableRow.java
+20
-8
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+4
-7
test.in.txt
h2/src/test/org/h2/test/test.in.txt
+11
-0
testSimple.in.txt
h2/src/test/org/h2/test/testSimple.in.txt
+0
-3
GenerateDoc.java
h2/src/tools/org/h2/tools/doc/GenerateDoc.java
+4
-0
没有找到文件。
h2/src/docsrc/html/datatypes.jsp
浏览文件 @
f61d2340
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
...
...
@@ -13,12 +13,12 @@ Data Types
<h1>
Data Types
</h1>
<c:forEach
var=
"item"
items=
"dataTypes"
>
<a
href=
"#
sql${item.id
}"
>
${item.topic}
</a><br
/>
<a
href=
"#
${item.link
}"
>
${item.topic}
</a><br
/>
</c:forEach>
<c:forEach
var=
"item"
items=
"dataTypes"
>
<br
/>
<a
name=
"
sql${item.id
}"
></a><h3>
${item.topic}
</h3>
<a
name=
"
${item.link
}"
></a><h3>
${item.topic}
</h3>
<pre>
${item.syntax}
</pre>
...
...
h2/src/docsrc/html/functions.jsp
浏览文件 @
f61d2340
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
...
...
@@ -15,32 +15,32 @@ Functions
<h2>
Aggregate Functions
</h2>
<c:forEach
var=
"item"
items=
"functionsAggregate"
>
<a
href=
"#
sql${item.id
}"
>
${item.topic}
</a><br
/>
<a
href=
"#
${item.link
}"
>
${item.topic}
</a><br
/>
</c:forEach>
<h2>
Numeric Functions
</h2>
<c:forEach
var=
"item"
items=
"functionsNumeric"
>
<a
href=
"#
sql${item.id
}"
>
${item.topic}
</a><br
/>
<a
href=
"#
${item.link
}"
>
${item.topic}
</a><br
/>
</c:forEach>
<h2>
String Functions
</h2>
<c:forEach
var=
"item"
items=
"functionsString"
>
<a
href=
"#
sql${item.id
}"
>
${item.topic}
</a><br
/>
<a
href=
"#
${item.link
}"
>
${item.topic}
</a><br
/>
</c:forEach>
<h2>
Time and Date Functions
</h2>
<c:forEach
var=
"item"
items=
"functionsTimeDate"
>
<a
href=
"#
sql${item.id
}"
>
${item.topic}
</a><br
/>
<a
href=
"#
${item.link
}"
>
${item.topic}
</a><br
/>
</c:forEach>
<h2>
System Functions
</h2>
<c:forEach
var=
"item"
items=
"functionsSystem"
>
<a
href=
"#
sql${item.id
}"
>
${item.topic}
</a><br
/>
<a
href=
"#
${item.link
}"
>
${item.topic}
</a><br
/>
</c:forEach>
<c:forEach
var=
"item"
items=
"functionsAll"
>
<br
/>
<a
name=
"
sql${item.id
}"
></a><h3>
${item.topic}
</h3>
<a
name=
"
${item.link
}"
></a><h3>
${item.topic}
</h3>
<pre>
${item.syntax}
</pre>
...
...
h2/src/docsrc/html/grammar.jsp
浏览文件 @
f61d2340
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"en"
xml:lang=
"en"
>
...
...
@@ -14,24 +14,24 @@ SQL Grammar
<h1>
SQL Grammar
</h1>
<h2>
Commands (Data Manipulation)
</h2>
<c:forEach
var=
"item"
items=
"commandsDML"
>
<a
href=
"#
sql${item.id
}"
>
${item.topic}
</a><br
/>
<a
href=
"#
${item.link
}"
>
${item.topic}
</a><br
/>
</c:forEach>
<h2>
Commands (Data Definition)
</h2>
<c:forEach
var=
"item"
items=
"commandsDDL"
>
<a
href=
"#
sql${item.id
}"
>
${item.topic}
</a><br
/>
<a
href=
"#
${item.link
}"
>
${item.topic}
</a><br
/>
</c:forEach>
<h2>
Commands (Other)
</h2>
<c:forEach
var=
"item"
items=
"commandsOther"
>
<a
href=
"#
sql${item.id
}"
>
${item.topic}
</a><br
/>
<a
href=
"#
${item.link
}"
>
${item.topic}
</a><br
/>
</c:forEach>
<h2>
Other Grammar
</h2>
<c:forEach
var=
"item"
items=
"otherGrammar"
>
<a
href=
"#
sql${item.id
}"
>
${item.topic}
</a><br
/>
<a
href=
"#
${item.link
}"
>
${item.topic}
</a><br
/>
</c:forEach>
<c:forEach
var=
"item"
items=
"commands"
>
<br
/>
<a
name=
"
sql${item.id
}"
></a><h3>
${item.topic}
</h3>
<a
name=
"
${item.link
}"
></a><h3>
${item.topic}
</h3>
<pre>
${item.syntax}
</pre>
...
...
@@ -45,7 +45,7 @@ ${item.example}
<c:forEach
var=
"item"
items=
"otherGrammar"
>
<br
/>
<a
name=
"
sql${item.id
}"
></a><h3>
${item.topic}
</h3>
<a
name=
"
${item.link
}"
></a><h3>
${item.topic}
</h3>
<pre>
${item.syntax}
</pre>
...
...
h2/src/docsrc/textbase/_messages_en.properties
浏览文件 @
f61d2340
...
...
@@ -36,7 +36,7 @@
90013
=
Database {0} not found
90014
=
Error parsing {0}
90015
=
SUM or AVG on wrong data type for {0}
90016
=
Column {0} must be in
group by
list
90016
=
Column {0} must be in
the GROUP BY
list
90017
=
Attempt to define a second primary key
90018
=
The connection was not closed by the application and is garbage collected
90019
=
Cannot drop the current user
...
...
h2/src/main/org/h2/bnf/Bnf.java
浏览文件 @
f61d2340
...
...
@@ -142,28 +142,27 @@ public class Bnf {
buff
.
append
(
s
);
continue
;
}
String
section
=
null
;
int
id
=
-
1
;
RuleHead
found
=
null
;
for
(
int
i
=
0
;
i
<
s
.
length
();
i
++)
{
String
test
=
StringUtils
.
toLowerEnglish
(
s
.
substring
(
i
));
RuleHead
r
=
(
RuleHead
)
ruleMap
.
get
(
test
);
if
(
r
!=
null
)
{
id
=
r
.
id
;
section
=
r
.
section
;
found
=
r
;
break
;
}
}
if
(
id
==
-
1
)
{
if
(
found
==
null
||
found
.
rule
instanceof
RuleFixed
)
{
buff
.
append
(
s
);
continue
;
}
String
page
=
"grammar.html"
;
if
(
section
.
startsWith
(
"Data Types"
))
{
if
(
found
.
section
.
startsWith
(
"Data Types"
))
{
page
=
"datatypes.html"
;
}
else
if
(
section
.
startsWith
(
"Functions"
))
{
}
else
if
(
found
.
section
.
startsWith
(
"Functions"
))
{
page
=
"functions.html"
;
}
buff
.
append
(
"<a href=\""
+
page
+
"#sql"
+
id
+
"\">"
);
String
link
=
StringUtils
.
urlEncode
(
found
.
getTopic
().
toLowerCase
());
buff
.
append
(
"<a href=\""
+
page
+
"#"
+
link
+
"\">"
);
buff
.
append
(
s
);
buff
.
append
(
"</a>"
);
}
...
...
h2/src/main/org/h2/constant/ErrorCode.java
浏览文件 @
f61d2340
...
...
@@ -91,13 +91,13 @@ 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 column must be included 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
group by
list.
* Column ID must be in
the GROUP BY
list.
* </pre>
*
* Correct:
...
...
h2/src/main/org/h2/res/_messages_de.properties
浏览文件 @
f61d2340
...
...
@@ -157,7 +157,7 @@
90134
=
Der Zugriff auf die Klasse {0} ist nicht erlaubt
90135
=
Die Datenbank befindet sich im Exclusiv Modus; es k
\u
00F6nnen keine zus
\u
00E4tzlichen Verbindungen ge
\u
00F6ffnet werden
90136
=
Diese Outer Join Bedingung wird nicht unterst
\u
00FCtzt
\:
{0}
90137
=
\#
Can only assign to a variable, not to
\:
{0}
90137
=
Werte k
\u
00F6nnen nur einer Variablen zugewiesen werden, nicht an
\:
{0}
HY000
=
Allgemeiner Fehler
\:
{0}
HY004
=
Unbekannter Datentyp
\:
{0}
HYC00
=
Dieses Feature wird unterst
\u
00FCtzt
...
...
h2/src/main/org/h2/res/_messages_en.properties
浏览文件 @
f61d2340
...
...
@@ -36,7 +36,7 @@
90013
=
Database {0} not found
90014
=
Error parsing {0}
90015
=
SUM or AVG on wrong data type for {0}
90016
=
Column {0} must be in
group by
list
90016
=
Column {0} must be in
the GROUP BY
list
90017
=
Attempt to define a second primary key
90018
=
The connection was not closed by the application and is garbage collected
90019
=
Cannot drop the current user
...
...
h2/src/main/org/h2/res/_messages_pt_br.properties
浏览文件 @
f61d2340
...
...
@@ -36,7 +36,7 @@
90013
=
Base de dados {0} n
\u
00E3o encontrada
90014
=
Erro na convers
\u
00E3o {0}
90015
=
SUM ou AVG com tipo de dados errado para {0}
90016
=
Coluna {0} tamb
\u
00E9m deve estar no
group by
90016
=
Coluna {0} tamb
\u
00E9m deve estar no
GROUP BY
90017
=
Tentativa para definir uma segunda chave prim
\u
00E1ria
90018
=
A conec
\u
00E7
\u
00E3o foi fechada pela aplica
\u
00E7
\u
00E3o e retirada da mem
\u
00F3ria
90019
=
N
\u
00E3o pode remover o usu
\u
00E1rio corrente
...
...
h2/src/main/org/h2/res/help.csv
浏览文件 @
f61d2340
...
...
@@ -722,6 +722,14 @@ Savepoints are only valid until the transaction is committed or rolled back.
SAVEPOINT HALF_DONE
"
"Commands (Other)","SET @","
SET @variableName [=] expression
","
Updates a user defined variable.
","
SET @TOTAL=0
"
"Commands (Other)","SET ALLOW_LITERALS","
SET ALLOW_LITERALS {NONE|ALL|NUMBERS}
","
...
...
@@ -2806,6 +2814,15 @@ The database engine may re-use a session id after the connection is closed.
CALL SESSION_ID()
"
"Functions (System)","SET","
SET(@variableName, value): value
","
Updates a variable with the given value. The new value is returned.
When used in a query, the value is updated in the order the rows are read.
","
SELECT X, SET(@I, IFNULL(@I, 0)+X) RUNNING_TOTAL FROM SYSTEM_RANGE(1, 10)
"
"Functions (System)","TABLE","
TABLE|TABLE_DISTINCT( { name dataType = expression } [,..]): result set
","
...
...
h2/src/main/org/h2/result/UpdatableRow.java
浏览文件 @
f61d2340
...
...
@@ -94,7 +94,7 @@ public class UpdatableRow {
private
void
appendColumnList
(
StringBuffer
buff
,
boolean
set
)
{
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
if
(
i
>
0
)
{
buff
.
append
(
", "
);
buff
.
append
(
','
);
}
String
col
=
result
.
getColumnName
(
i
);
buff
.
append
(
StringUtils
.
quoteIdentifier
(
col
));
...
...
@@ -120,6 +120,11 @@ public class UpdatableRow {
String
col
=
(
String
)
key
.
get
(
i
);
int
idx
=
getColumnIndex
(
col
);
Value
v
=
current
[
idx
];
if
(
v
==
null
||
v
==
ValueNull
.
INSTANCE
)
{
// rows with a unique key containing NULL are not supported,
// as multiple such rows could exist
throw
Message
.
getSQLException
(
ErrorCode
.
NO_DATA_AVAILABLE
);
}
v
.
set
(
prep
,
start
+
i
);
}
}
...
...
@@ -167,7 +172,6 @@ public class UpdatableRow {
Value
[]
newRow
=
new
Value
[
columnCount
];
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
int
type
=
result
.
getColumnType
(
i
);
// TODO lob: support updatable rows
newRow
[
i
]
=
DataType
.
readValue
(
session
,
rs
,
i
+
1
,
type
);
}
return
newRow
;
...
...
@@ -182,6 +186,7 @@ public class UpdatableRow {
setKey
(
prep
,
1
,
current
);
int
count
=
prep
.
executeUpdate
();
if
(
count
!=
1
)
{
// the row has already been deleted
throw
Message
.
getSQLException
(
ErrorCode
.
NO_DATA_AVAILABLE
);
}
}
...
...
@@ -206,23 +211,27 @@ public class UpdatableRow {
v
.
set
(
prep
,
j
++);
}
setKey
(
prep
,
j
,
current
);
prep
.
execute
();
int
count
=
prep
.
executeUpdate
();
if
(
count
!=
1
)
{
// the row has been deleted
throw
Message
.
getSQLException
(
ErrorCode
.
NO_DATA_AVAILABLE
);
}
}
public
void
insertRow
(
Value
[]
row
)
throws
SQLException
{
StringBuffer
buff
=
new
StringBuffer
();
buff
.
append
(
"INSERT INTO "
);
appendTableName
(
buff
);
buff
.
append
(
"("
);
buff
.
append
(
'('
);
appendColumnList
(
buff
,
false
);
buff
.
append
(
")VALUES("
);
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
if
(
i
>
0
)
{
buff
.
append
(
","
);
buff
.
append
(
','
);
}
buff
.
append
(
"?"
);
buff
.
append
(
'?'
);
}
buff
.
append
(
")"
);
buff
.
append
(
')'
);
PreparedStatement
prep
=
conn
.
prepareStatement
(
buff
.
toString
());
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
Value
v
=
row
[
i
];
...
...
@@ -231,7 +240,10 @@ public class UpdatableRow {
}
v
.
set
(
prep
,
i
+
1
);
}
prep
.
executeUpdate
();
int
count
=
prep
.
executeUpdate
();
if
(
count
!=
1
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
NO_DATA_AVAILABLE
);
}
}
}
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
f61d2340
...
...
@@ -150,22 +150,19 @@ java org.h2.test.TestAll timer
/*
document SET method, variables
send mail
find send mail source code?
Roadmap:
History:
User defined variables are now supported. Examples: SET @VAR=10;CALL @VAR
User defined variables are now supported. Examples: SET @VAR=10;CALL @VAR.
This can be used for running totals as in:
select x, set(@t, ifnull(@t, 0) + x) from system_range(1, 10)
Test Recovery with MAX_LOG_FILE_SIZE=1; test with various log file sizes
Test H2 on OS X (result are here: h2-2007-12-27_test.zip)
Docs:
H2 can emulate PostgreSQL server.
Web site:
link to history page, bug page
Add a link to the google code bug page
...
...
h2/src/test/org/h2/test/test.in.txt
浏览文件 @
f61d2340
--- special grammar and test cases ---------------------------------------------------------------------------------------------
set @t = 0;
> ok
call set(1, 2);
> exception
select x, set(@t, ifnull(@t, 0) + x) from system_range(1, 3);
> X SET(@T, (IFNULL(@T, 0) + X))
> - ----------------------------
> 1 1
> 2 3
> 3 6
> rows: 3
select * from system_range(1, 2) a,
...
...
h2/src/test/org/h2/test/testSimple.in.txt
浏览文件 @
f61d2340
call set(1, 2);
> exception;
CREATE TABLE TEST(A int NOT NULL, B int NOT NULL, C int) ;
ALTER TABLE TEST ADD CONSTRAINT CON UNIQUE(A,B);
ALTER TABLE TEST DROP C;
...
...
h2/src/tools/org/h2/tools/doc/GenerateDoc.java
浏览文件 @
f61d2340
...
...
@@ -104,6 +104,10 @@ public class GenerateDoc {
syntax
=
StringUtils
.
replaceAll
(
syntax
,
"<br />"
,
""
);
syntax
=
bnf
.
getSyntax
(
topic
,
syntax
);
map
.
put
(
"syntax"
,
syntax
);
String
link
=
topic
.
toLowerCase
();
link
=
StringUtils
.
replaceAll
(
link
,
" "
,
""
);
link
=
StringUtils
.
replaceAll
(
link
,
"_"
,
""
);
map
.
put
(
"link"
,
StringUtils
.
urlEncode
(
link
));
list
.
add
(
map
);
}
session
.
put
(
key
,
list
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论