提交 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"> <!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 Initial Developer: H2 Group
--> -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
...@@ -13,12 +13,12 @@ Data Types ...@@ -13,12 +13,12 @@ Data Types
<h1>Data Types</h1> <h1>Data Types</h1>
<c:forEach var="item" items="dataTypes"> <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>
<c:forEach var="item" items="dataTypes"> <c:forEach var="item" items="dataTypes">
<br /> <br />
<a name="sql${item.id}"></a><h3>${item.topic}</h3> <a name="${item.link}"></a><h3>${item.topic}</h3>
<pre> <pre>
${item.syntax} ${item.syntax}
</pre> </pre>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!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 Initial Developer: H2 Group
--> -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
...@@ -15,32 +15,32 @@ Functions ...@@ -15,32 +15,32 @@ Functions
<h2>Aggregate Functions</h2> <h2>Aggregate Functions</h2>
<c:forEach var="item" items="functionsAggregate"> <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> </c:forEach>
<h2>Numeric Functions</h2> <h2>Numeric Functions</h2>
<c:forEach var="item" items="functionsNumeric"> <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> </c:forEach>
<h2>String Functions</h2> <h2>String Functions</h2>
<c:forEach var="item" items="functionsString"> <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> </c:forEach>
<h2>Time and Date Functions</h2> <h2>Time and Date Functions</h2>
<c:forEach var="item" items="functionsTimeDate"> <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> </c:forEach>
<h2>System Functions</h2> <h2>System Functions</h2>
<c:forEach var="item" items="functionsSystem"> <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>
<c:forEach var="item" items="functionsAll"> <c:forEach var="item" items="functionsAll">
<br /> <br />
<a name="sql${item.id}"></a><h3>${item.topic}</h3> <a name="${item.link}"></a><h3>${item.topic}</h3>
<pre> <pre>
${item.syntax} ${item.syntax}
</pre> </pre>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!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 Initial Developer: H2 Group
--> -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
...@@ -14,24 +14,24 @@ SQL Grammar ...@@ -14,24 +14,24 @@ SQL Grammar
<h1>SQL Grammar</h1> <h1>SQL Grammar</h1>
<h2>Commands (Data Manipulation)</h2> <h2>Commands (Data Manipulation)</h2>
<c:forEach var="item" items="commandsDML"> <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> </c:forEach>
<h2>Commands (Data Definition)</h2> <h2>Commands (Data Definition)</h2>
<c:forEach var="item" items="commandsDDL"> <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> </c:forEach>
<h2>Commands (Other)</h2> <h2>Commands (Other)</h2>
<c:forEach var="item" items="commandsOther"> <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> </c:forEach>
<h2>Other Grammar</h2> <h2>Other Grammar</h2>
<c:forEach var="item" items="otherGrammar"> <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>
<c:forEach var="item" items="commands"> <c:forEach var="item" items="commands">
<br /> <br />
<a name="sql${item.id}"></a><h3>${item.topic}</h3> <a name="${item.link}"></a><h3>${item.topic}</h3>
<pre> <pre>
${item.syntax} ${item.syntax}
</pre> </pre>
...@@ -45,7 +45,7 @@ ${item.example} ...@@ -45,7 +45,7 @@ ${item.example}
<c:forEach var="item" items="otherGrammar"> <c:forEach var="item" items="otherGrammar">
<br /> <br />
<a name="sql${item.id}"></a><h3>${item.topic}</h3> <a name="${item.link}"></a><h3>${item.topic}</h3>
<pre> <pre>
${item.syntax} ${item.syntax}
</pre> </pre>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
90013=Database {0} not found 90013=Database {0} not found
90014=Error parsing {0} 90014=Error parsing {0}
90015=SUM or AVG on wrong data type for {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 90017=Attempt to define a second primary key
90018=The connection was not closed by the application and is garbage collected 90018=The connection was not closed by the application and is garbage collected
90019=Cannot drop the current user 90019=Cannot drop the current user
......
...@@ -142,28 +142,27 @@ public class Bnf { ...@@ -142,28 +142,27 @@ public class Bnf {
buff.append(s); buff.append(s);
continue; continue;
} }
String section = null; RuleHead found = null;
int id = -1;
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
String test = StringUtils.toLowerEnglish(s.substring(i)); String test = StringUtils.toLowerEnglish(s.substring(i));
RuleHead r = (RuleHead) ruleMap.get(test); RuleHead r = (RuleHead) ruleMap.get(test);
if (r != null) { if (r != null) {
id = r.id; found = r;
section = r.section;
break; break;
} }
} }
if (id == -1) { if (found == null || found.rule instanceof RuleFixed) {
buff.append(s); buff.append(s);
continue; continue;
} }
String page = "grammar.html"; String page = "grammar.html";
if (section.startsWith("Data Types")) { if (found.section.startsWith("Data Types")) {
page = "datatypes.html"; page = "datatypes.html";
} else if (section.startsWith("Functions")) { } else if (found.section.startsWith("Functions")) {
page = "functions.html"; 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(s);
buff.append("</a>"); buff.append("</a>");
} }
......
...@@ -91,13 +91,13 @@ public class ErrorCode { ...@@ -91,13 +91,13 @@ public class ErrorCode {
public static final int SUM_OR_AVG_ON_WRONG_DATATYPE_1 = 90015; 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> * <pre>
* CREATE TABLE TEST(ID INT, NAME VARCHAR); * CREATE TABLE TEST(ID INT, NAME VARCHAR);
* INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World'); * INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World');
* SELECT ID, MAX(NAME) FROM TEST; * SELECT ID, MAX(NAME) FROM TEST;
* Column ID must be in group by list. * Column ID must be in the GROUP BY list.
* </pre> * </pre>
* *
* Correct: * Correct:
......
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
90134=Der Zugriff auf die Klasse {0} ist nicht erlaubt 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 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} 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} HY000=Allgemeiner Fehler\: {0}
HY004=Unbekannter Datentyp\: {0} HY004=Unbekannter Datentyp\: {0}
HYC00=Dieses Feature wird unterst\u00FCtzt HYC00=Dieses Feature wird unterst\u00FCtzt
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
90013=Database {0} not found 90013=Database {0} not found
90014=Error parsing {0} 90014=Error parsing {0}
90015=SUM or AVG on wrong data type for {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 90017=Attempt to define a second primary key
90018=The connection was not closed by the application and is garbage collected 90018=The connection was not closed by the application and is garbage collected
90019=Cannot drop the current user 90019=Cannot drop the current user
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
90013=Base de dados {0} n\u00E3o encontrada 90013=Base de dados {0} n\u00E3o encontrada
90014=Erro na convers\u00E3o {0} 90014=Erro na convers\u00E3o {0}
90015=SUM ou AVG com tipo de dados errado para {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 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 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 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. ...@@ -722,6 +722,14 @@ Savepoints are only valid until the transaction is committed or rolled back.
SAVEPOINT HALF_DONE SAVEPOINT HALF_DONE
" "
"Commands (Other)","SET @","
SET @variableName [=] expression
","
Updates a user defined variable.
","
SET @TOTAL=0
"
"Commands (Other)","SET ALLOW_LITERALS"," "Commands (Other)","SET ALLOW_LITERALS","
SET ALLOW_LITERALS {NONE|ALL|NUMBERS} SET ALLOW_LITERALS {NONE|ALL|NUMBERS}
"," ","
...@@ -2806,6 +2814,15 @@ The database engine may re-use a session id after the connection is closed. ...@@ -2806,6 +2814,15 @@ The database engine may re-use a session id after the connection is closed.
CALL SESSION_ID() 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"," "Functions (System)","TABLE","
TABLE|TABLE_DISTINCT( { name dataType = expression } [,..]): result set TABLE|TABLE_DISTINCT( { name dataType = expression } [,..]): result set
"," ","
......
...@@ -94,7 +94,7 @@ public class UpdatableRow { ...@@ -94,7 +94,7 @@ public class UpdatableRow {
private void appendColumnList(StringBuffer buff, boolean set) { private void appendColumnList(StringBuffer buff, boolean set) {
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
if (i > 0) { if (i > 0) {
buff.append(", "); buff.append(',');
} }
String col = result.getColumnName(i); String col = result.getColumnName(i);
buff.append(StringUtils.quoteIdentifier(col)); buff.append(StringUtils.quoteIdentifier(col));
...@@ -120,6 +120,11 @@ public class UpdatableRow { ...@@ -120,6 +120,11 @@ public class UpdatableRow {
String col = (String) key.get(i); String col = (String) key.get(i);
int idx = getColumnIndex(col); int idx = getColumnIndex(col);
Value v = current[idx]; 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); v.set(prep, start + i);
} }
} }
...@@ -167,7 +172,6 @@ public class UpdatableRow { ...@@ -167,7 +172,6 @@ public class UpdatableRow {
Value[] newRow = new Value[columnCount]; Value[] newRow = new Value[columnCount];
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
int type = result.getColumnType(i); int type = result.getColumnType(i);
// TODO lob: support updatable rows
newRow[i] = DataType.readValue(session, rs, i + 1, type); newRow[i] = DataType.readValue(session, rs, i + 1, type);
} }
return newRow; return newRow;
...@@ -182,6 +186,7 @@ public class UpdatableRow { ...@@ -182,6 +186,7 @@ public class UpdatableRow {
setKey(prep, 1, current); setKey(prep, 1, current);
int count = prep.executeUpdate(); int count = prep.executeUpdate();
if (count != 1) { if (count != 1) {
// the row has already been deleted
throw Message.getSQLException(ErrorCode.NO_DATA_AVAILABLE); throw Message.getSQLException(ErrorCode.NO_DATA_AVAILABLE);
} }
} }
...@@ -206,23 +211,27 @@ public class UpdatableRow { ...@@ -206,23 +211,27 @@ public class UpdatableRow {
v.set(prep, j++); v.set(prep, j++);
} }
setKey(prep, j, current); 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 { public void insertRow(Value[] row) throws SQLException {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
buff.append("INSERT INTO "); buff.append("INSERT INTO ");
appendTableName(buff); appendTableName(buff);
buff.append("("); buff.append('(');
appendColumnList(buff, false); appendColumnList(buff, false);
buff.append(")VALUES("); buff.append(")VALUES(");
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
if (i > 0) { if (i > 0) {
buff.append(","); buff.append(',');
} }
buff.append("?"); buff.append('?');
} }
buff.append(")"); buff.append(')');
PreparedStatement prep = conn.prepareStatement(buff.toString()); PreparedStatement prep = conn.prepareStatement(buff.toString());
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
Value v = row[i]; Value v = row[i];
...@@ -231,7 +240,10 @@ public class UpdatableRow { ...@@ -231,7 +240,10 @@ public class UpdatableRow {
} }
v.set(prep, i + 1); 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 ...@@ -150,22 +150,19 @@ java org.h2.test.TestAll timer
/* /*
document SET method, variables find send mail source code?
send mail
Roadmap: Roadmap:
History: 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 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) Test H2 on OS X (result are here: h2-2007-12-27_test.zip)
Docs:
H2 can emulate PostgreSQL server.
Web site: Web site:
link to history page, bug page link to history page, bug page
Add a link to the google code bug page Add a link to the google code bug page
......
--- special grammar and test cases --------------------------------------------------------------------------------------------- --- 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); 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 > rows: 3
select * from system_range(1, 2) a, 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) ; 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 ADD CONSTRAINT CON UNIQUE(A,B);
ALTER TABLE TEST DROP C; ALTER TABLE TEST DROP C;
......
...@@ -104,6 +104,10 @@ public class GenerateDoc { ...@@ -104,6 +104,10 @@ public class GenerateDoc {
syntax = StringUtils.replaceAll(syntax, "<br />", ""); syntax = StringUtils.replaceAll(syntax, "<br />", "");
syntax = bnf.getSyntax(topic, syntax); syntax = bnf.getSyntax(topic, syntax);
map.put("syntax", 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); list.add(map);
} }
session.put(key, list); session.put(key, list);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论