提交 61fdac05 authored 作者: Thomas Mueller's avatar Thomas Mueller

IBM DB2 and Apache Derby compatibility: support the pseudo-table SYSIBM.SYSDUMMY1.

上级 1c9a3212
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>ROWNUM() did not work in combination with IN(..). The following query did not work as expected:
<ul><li>IBM DB2 and Apache Derby compatibility: support the pseudo-table SYSIBM.SYSDUMMY1.
</li><li>ROWNUM() did not work in combination with IN(..). The following query did not work as expected:
select * from (select rownum r from test) where r in (1, 2).
</li><li>H2 Console autocomplete: the autocomplete feature didn't support quoted names.
</li><li>It is now longer allowed to create an index on a CLOB or BLOB column
......
......@@ -1016,6 +1016,7 @@ or the SQL statement <code>SET MODE DB2</code>.
as an alternative for <code>LIMIT .. OFFSET</code>.
</li><li>Concatenating <code>NULL</code> with another value
results in the other value.
</li><li>Support the pseudo-table SYSIBM.SYSDUMMY1.
</li></ul>
<h3>Derby Compatibility Mode</h3>
......@@ -1030,6 +1031,7 @@ or the SQL statement <code>SET MODE Derby</code>.
That means only one row with <code>NULL</code> in one of the columns is allowed.
</li><li>Concatenating <code>NULL</code> with another value
results in the other value.
</li><li>Support the pseudo-table SYSIBM.SYSDUMMY1.
</li></ul>
<h3>HSQLDB Compatibility Mode</h3>
......
......@@ -607,6 +607,8 @@ public class Parser {
if (equalsToken("SESSION", schemaName)) {
// for local temporary tables
schema = database.getSchema(session.getCurrentSchemaName());
} else if (database.getMode().sysDummy1 && "SYSIBM".equals(schemaName)) {
// IBM DB2 and Apache Derby compatibility: SYSIBM.SYSDUMMY1
} else {
throw DbException.get(ErrorCode.SCHEMA_NOT_FOUND_1, schemaName);
}
......@@ -1067,6 +1069,8 @@ public class Parser {
}
} else if (equalsToken("DUAL", tableName)) {
table = getDualTable(false);
} else if (database.getMode().sysDummy1 && equalsToken("SYSDUMMY1", tableName)) {
table = getDualTable(false);
} else {
table = readTableOrView(tableName);
}
......
......@@ -104,6 +104,11 @@ public class Mode {
*/
public boolean uniqueIndexSingleNullExceptAllColumnsAreNull;
/**
* Support the pseudo-table SYSIBM.SYSDUMMY1.
*/
public boolean sysDummy1;
/**
* Text can be concatenated using '+'.
*/
......@@ -119,11 +124,13 @@ public class Mode {
mode = new Mode("DB2");
mode.aliasColumnName = true;
mode.supportOffsetFetch = true;
mode.sysDummy1 = true;
add(mode);
mode = new Mode("Derby");
mode.aliasColumnName = true;
mode.uniqueIndexSingleNull = true;
mode.sysDummy1 = true;
add(mode);
mode = new Mode("HSQLDB");
......
......@@ -40,6 +40,8 @@ public class TestCompatibility extends TestBase {
testUniqueIndexOracle();
testHsqlDb();
testMySQL();
testDB2();
testDerby();
testPlusSignAsConcatOperator();
conn.close();
......@@ -224,4 +226,37 @@ public class TestCompatibility extends TestBase {
}
private void testDB2() throws SQLException {
conn = getConnection("compatibility;MODE=DB2");
ResultSet res = conn.createStatement().executeQuery("SELECT 1 FROM sysibm.sysdummy1");
res.next();
assertEquals("1", res.getString(1));
conn.close();
conn = getConnection("compatibility;MODE=MySQL");
try {
conn.createStatement().executeQuery("SELECT 1 FROM sysibm.sysdummy1");
fail();
} catch (SQLException e) {
// can't lookup sysibm.sysdummy1 on mode=MySQL etc.
}
conn.close();
conn = getConnection("compatibility");
}
private void testDerby() throws SQLException {
conn = getConnection("compatibility;MODE=Derby");
ResultSet res = conn.createStatement().executeQuery("SELECT 1 FROM sysibm.sysdummy1");
res.next();
assertEquals("1", res.getString(1));
conn.close();
conn = getConnection("compatibility;MODE=PostgreSQL");
try {
conn.createStatement().executeQuery("SELECT 1 FROM sysibm.sysdummy1");
fail();
} catch (SQLException e) {
// can't lookup sysibm.sysdummy1 on mode=MySQL etc.
}
conn.close();
conn = getConnection("compatibility");
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论