Unverified 提交 cc040195 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1500 from katzyn/tests

Fix failure after reconnection in envelope.sql
...@@ -21,6 +21,8 @@ Change Log ...@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>Issue #1499: TestScript::envelope.sql failure in “big” mode
</li>
<li>Issue #1495: MERGE statement doesn't affect any rows when Oracle UPDATE .. WHERE .. DELETE .. WHERE is used <li>Issue #1495: MERGE statement doesn't affect any rows when Oracle UPDATE .. WHERE .. DELETE .. WHERE is used
</li> </li>
<li>Issue #1493: MERGE statement fails when it updates more than one row <li>Issue #1493: MERGE statement fails when it updates more than one row
......
...@@ -234,11 +234,7 @@ public class TestScript extends TestDb { ...@@ -234,11 +234,7 @@ public class TestScript extends TestDb {
stat = conn.createStatement(); stat = conn.createStatement();
out = new PrintStream(new FileOutputStream(outFile)); out = new PrintStream(new FileOutputStream(outFile));
errors = new StringBuilder(); errors = new StringBuilder();
testFile(BASE_DIR + scriptFileName, testFile(BASE_DIR + scriptFileName);
!scriptFileName.equals("functions/numeric/rand.sql") &&
!scriptFileName.equals("functions/system/set.sql") &&
!scriptFileName.equals("ddl/createAlias.sql") &&
!scriptFileName.equals("ddl/dropSchema.sql"));
conn.close(); conn.close();
out.close(); out.close();
if (errors.length() > 0) { if (errors.length() > 0) {
...@@ -297,7 +293,7 @@ public class TestScript extends TestDb { ...@@ -297,7 +293,7 @@ public class TestScript extends TestDb {
putBack.addLast(line); putBack.addLast(line);
} }
private void testFile(String inFile, boolean allowReconnect) throws Exception { private void testFile(String inFile) throws Exception {
InputStream is = getClass().getClassLoader().getResourceAsStream(inFile); InputStream is = getClass().getClassLoader().getResourceAsStream(inFile);
if (is == null) { if (is == null) {
throw new IOException("could not find " + inFile); throw new IOException("could not find " + inFile);
...@@ -305,11 +301,8 @@ public class TestScript extends TestDb { ...@@ -305,11 +301,8 @@ public class TestScript extends TestDb {
fileName = inFile; fileName = inFile;
in = new LineNumberReader(new InputStreamReader(is, StandardCharsets.UTF_8)); in = new LineNumberReader(new InputStreamReader(is, StandardCharsets.UTF_8));
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
while (true) { boolean allowReconnect = true;
String sql = readLine(); for (String sql; (sql = readLine()) != null;) {
if (sql == null) {
break;
}
if (sql.startsWith("--")) { if (sql.startsWith("--")) {
write(sql); write(sql);
} else if (sql.startsWith(">")) { } else if (sql.startsWith(">")) {
...@@ -320,12 +313,24 @@ public class TestScript extends TestDb { ...@@ -320,12 +313,24 @@ public class TestScript extends TestDb {
sql = buff.toString(); sql = buff.toString();
buff.setLength(0); buff.setLength(0);
process(sql, allowReconnect); process(sql, allowReconnect);
} else if (sql.equals("@reconnect")) { } else if (sql.startsWith("@")) {
if (buff.length() > 0) { if (buff.length() > 0) {
addWriteResultError("<command>", sql); addWriteResultError("<command>", sql);
} else { } else {
if (!config.memory) { switch (sql) {
reconnect(conn.getAutoCommit()); case "@reconnect":
if (!config.memory) {
reconnect(conn.getAutoCommit());
}
break;
case "@reconnect on":
allowReconnect = true;
break;
case "@reconnect off":
allowReconnect = false;
break;
default:
addWriteResultError("<command>", sql);
} }
} }
} else { } else {
......
...@@ -12,6 +12,8 @@ create alias "MIN" for "java.lang.Integer.parseInt(java.lang.String)"; ...@@ -12,6 +12,8 @@ create alias "MIN" for "java.lang.Integer.parseInt(java.lang.String)";
create alias "CAST" for "java.lang.Integer.parseInt(java.lang.String)"; create alias "CAST" for "java.lang.Integer.parseInt(java.lang.String)";
> exception FUNCTION_ALIAS_ALREADY_EXISTS_1 > exception FUNCTION_ALIAS_ALREADY_EXISTS_1
@reconnect off
--- function alias --------------------------------------------------------------------------------------------- --- function alias ---------------------------------------------------------------------------------------------
CREATE ALIAS MY_SQRT FOR "java.lang.Math.sqrt"; CREATE ALIAS MY_SQRT FOR "java.lang.Math.sqrt";
> ok > ok
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
@reconnect off
CREATE SCHEMA TEST_SCHEMA; CREATE SCHEMA TEST_SCHEMA;
> ok > ok
......
...@@ -69,12 +69,16 @@ SELECT ENVELOPE(V) FROM TEST; ...@@ -69,12 +69,16 @@ SELECT ENVELOPE(V) FROM TEST;
SELECT ESTIMATED_ENVELOPE('TEST', 'V'); SELECT ESTIMATED_ENVELOPE('TEST', 'V');
>> null >> null
@reconnect off
SELECT RAND(1000) * 0; SELECT RAND(1000) * 0;
>> 0.0 >> 0.0
INSERT INTO TEST SELECT CAST('POINT(' || CAST(RAND() * 100000 AS INT) || ' ' || CAST(RAND() * 100000 AS INT) || ')' AS GEOMETRY) FROM SYSTEM_RANGE(1, 1000); INSERT INTO TEST SELECT CAST('POINT(' || CAST(RAND() * 100000 AS INT) || ' ' || CAST(RAND() * 100000 AS INT) || ')' AS GEOMETRY) FROM SYSTEM_RANGE(1, 1000);
> update count: 1000 > update count: 1000
@reconnect on
-- Without index -- Without index
SELECT ENVELOPE(N) FROM (SELECT V AS N FROM TEST); SELECT ENVELOPE(N) FROM (SELECT V AS N FROM TEST);
>> POLYGON ((68 78, 68 99951, 99903 99951, 99903 78, 68 78)) >> POLYGON ((68 78, 68 99951, 99903 99951, 99903 78, 68 78))
...@@ -90,6 +94,8 @@ SELECT ESTIMATED_ENVELOPE('TEST', 'V'); ...@@ -90,6 +94,8 @@ SELECT ESTIMATED_ENVELOPE('TEST', 'V');
TRUNCATE TABLE TEST; TRUNCATE TABLE TEST;
> ok > ok
@reconnect off
SELECT RAND(1000) * 0; SELECT RAND(1000) * 0;
>> 0.0 >> 0.0
...@@ -97,6 +103,8 @@ INSERT INTO TEST SELECT CAST('POINT(' || (CAST(RAND() * 100000 AS INT) * 0.00000 ...@@ -97,6 +103,8 @@ INSERT INTO TEST SELECT CAST('POINT(' || (CAST(RAND() * 100000 AS INT) * 0.00000
|| (CAST(RAND() * 100000 AS INT) * 0.000000001 + 1) || ')' AS GEOMETRY) FROM SYSTEM_RANGE(1, 1000); || (CAST(RAND() * 100000 AS INT) * 0.000000001 + 1) || ')' AS GEOMETRY) FROM SYSTEM_RANGE(1, 1000);
> update count: 1000 > update count: 1000
@reconnect on
-- Without index -- Without index
SELECT ENVELOPE(N) FROM (SELECT V AS N FROM TEST); SELECT ENVELOPE(N) FROM (SELECT V AS N FROM TEST);
>> POLYGON ((1.000000068 1.000000078, 1.000000068 1.000099951, 1.000099903 1.000099951, 1.000099903 1.000000078, 1.000000068 1.000000078)) >> POLYGON ((1.000000068 1.000000078, 1.000000068 1.000099951, 1.000099903 1.000099951, 1.000099903 1.000000078, 1.000000068 1.000000078))
......
...@@ -9,6 +9,8 @@ create memory table test(id int primary key, name varchar(255)); ...@@ -9,6 +9,8 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello'); insert into test values(1, 'Hello');
> update count: 1 > update count: 1
@reconnect off
select rand(1) e, random() f from test; select rand(1) e, random() f from test;
> E F > E F
> ------------------ ------------------- > ------------------ -------------------
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html). -- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group -- Initial Developer: H2 Group
-- --
@reconnect off
-- Try a custom column naming rules setup -- Try a custom column naming rules setup
SET COLUMN_NAME_RULES=MAX_IDENTIFIER_LENGTH = 30; SET COLUMN_NAME_RULES=MAX_IDENTIFIER_LENGTH = 30;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论