提交 31d87e12 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix failure after reconnection in envelope.sql

上级 36b9166f
......@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<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>
<li>Issue #1493: MERGE statement fails when it updates more than one row
......
......@@ -234,11 +234,7 @@ public class TestScript extends TestDb {
stat = conn.createStatement();
out = new PrintStream(new FileOutputStream(outFile));
errors = new StringBuilder();
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"));
testFile(BASE_DIR + scriptFileName);
conn.close();
out.close();
if (errors.length() > 0) {
......@@ -297,7 +293,7 @@ public class TestScript extends TestDb {
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);
if (is == null) {
throw new IOException("could not find " + inFile);
......@@ -305,11 +301,8 @@ public class TestScript extends TestDb {
fileName = inFile;
in = new LineNumberReader(new InputStreamReader(is, StandardCharsets.UTF_8));
StringBuilder buff = new StringBuilder();
while (true) {
String sql = readLine();
if (sql == null) {
break;
}
boolean allowReconnect = true;
for (String sql; (sql = readLine()) != null;) {
if (sql.startsWith("--")) {
write(sql);
} else if (sql.startsWith(">")) {
......@@ -320,12 +313,24 @@ public class TestScript extends TestDb {
sql = buff.toString();
buff.setLength(0);
process(sql, allowReconnect);
} else if (sql.equals("@reconnect")) {
} else if (sql.startsWith("@")) {
if (buff.length() > 0) {
addWriteResultError("<command>", sql);
} else {
if (!config.memory) {
reconnect(conn.getAutoCommit());
switch (sql) {
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 {
......
......@@ -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)";
> exception FUNCTION_ALIAS_ALREADY_EXISTS_1
@reconnect off
--- function alias ---------------------------------------------------------------------------------------------
CREATE ALIAS MY_SQRT FOR "java.lang.Math.sqrt";
> ok
......
......@@ -3,6 +3,8 @@
-- Initial Developer: H2 Group
--
@reconnect off
CREATE SCHEMA TEST_SCHEMA;
> ok
......
......@@ -69,12 +69,16 @@ SELECT ENVELOPE(V) FROM TEST;
SELECT ESTIMATED_ENVELOPE('TEST', 'V');
>> null
@reconnect off
SELECT RAND(1000) * 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);
> update count: 1000
@reconnect on
-- Without index
SELECT ENVELOPE(N) FROM (SELECT V AS N FROM TEST);
>> POLYGON ((68 78, 68 99951, 99903 99951, 99903 78, 68 78))
......@@ -90,6 +94,8 @@ SELECT ESTIMATED_ENVELOPE('TEST', 'V');
TRUNCATE TABLE TEST;
> ok
@reconnect off
SELECT RAND(1000) * 0;
>> 0.0
......@@ -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);
> update count: 1000
@reconnect on
-- Without index
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))
......
......@@ -9,6 +9,8 @@ create memory table test(id int primary key, name varchar(255));
insert into test values(1, 'Hello');
> update count: 1
@reconnect off
select rand(1) e, random() f from test;
> E F
> ------------------ -------------------
......
......@@ -2,6 +2,9 @@
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
@reconnect off
-- Try a custom column naming rules setup
SET COLUMN_NAME_RULES=MAX_IDENTIFIER_LENGTH = 30;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论