提交 f61d2340 authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 f0bf7fad
<!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>
......
<!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>
......
<!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>
......
......@@ -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
......
......@@ -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>");
}
......
......@@ -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:
......
......@@ -157,7 +157,7 @@
90134=Der Zugriff auf die Klasse {0} ist nicht erlaubt
90135=Die Datenbank befindet sich im Exclusiv Modus; es k\u00F6nnen keine zus\u00E4tzlichen Verbindungen ge\u00F6ffnet werden
90136=Diese Outer Join Bedingung wird nicht unterst\u00FCtzt\: {0}
90137=\#Can only assign to a variable, not to\: {0}
90137=Werte k\u00F6nnen nur einer Variablen zugewiesen werden, nicht an\: {0}
HY000=Allgemeiner Fehler\: {0}
HY004=Unbekannter Datentyp\: {0}
HYC00=Dieses Feature wird unterst\u00FCtzt
......
......@@ -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
......
......@@ -36,7 +36,7 @@
90013=Base de dados {0} n\u00E3o encontrada
90014=Erro na convers\u00E3o {0}
90015=SUM ou AVG com tipo de dados errado para {0}
90016=Coluna {0} tamb\u00E9m deve estar no group by
90016=Coluna {0} tamb\u00E9m deve estar no GROUP BY
90017=Tentativa para definir uma segunda chave prim\u00E1ria
90018=A conec\u00E7\u00E3o foi fechada pela aplica\u00E7\u00E3o e retirada da mem\u00F3ria
90019=N\u00E3o pode remover o usu\u00E1rio corrente
......
......@@ -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
","
......
......@@ -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);
}
}
}
......@@ -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
......
--- 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,
......
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;
......
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论