提交 8e75a3cb authored 作者: noelgrandin's avatar noelgrandin

Issue 274: Sybase/MSSQLServer compatibility - support index clause e.g. "select…

Issue 274: Sybase/MSSQLServer compatibility - support index clause e.g. "select * from test (index table1_index)"
上级 da652fde
...@@ -30,8 +30,9 @@ Change Log ...@@ -30,8 +30,9 @@ Change Log
</li><li>Fix Issue 406: support "SELECT h2version()" </li><li>Fix Issue 406: support "SELECT h2version()"
</li><li>Fix Issue 389: When there is a multi-column primary key, H2 does not seem to always pick the right index </li><li>Fix Issue 389: When there is a multi-column primary key, H2 does not seem to always pick the right index
</li><li>Fix Issue 305: Implement SELECT ... FOR FETCH ONLY </li><li>Fix Issue 305: Implement SELECT ... FOR FETCH ONLY
</li><li>Issue 274: Sybase/MSSQLServer compatibility - Add GETDATE and CHARINDEX system functions </li><li>Issue 274: Sybase/MSSQLServer compatibility - Add GETDATE and CHARINDEX system functions
</li><li>Issue 274: Sybase/MSSQLServer compatibility - swap parameters of CONVERT function. </li><li>Issue 274: Sybase/MSSQLServer compatibility - swap parameters of CONVERT function.
</li><li>Issue 274: Sybase/MSSQLServer compatibility - support index clause e.g. "select * from test (index table1_index)"
</li></ul> </li></ul>
<h2>Version 1.3.171 (2013-03-17)</h2> <h2>Version 1.3.171 (2013-03-17)</h2>
......
...@@ -1065,7 +1065,14 @@ public class Parser { ...@@ -1065,7 +1065,14 @@ public class Parser {
} else { } else {
String tableName = readIdentifierWithSchema(null); String tableName = readIdentifierWithSchema(null);
Schema schema = getSchema(); Schema schema = getSchema();
if (readIf("(")) { boolean foundLeftBracket = readIf("(");
if (foundLeftBracket && readIf("INDEX")) {
// Sybase compatibility with "select * from test (index table1_index)"
readIdentifierWithSchema(null);
read(")");
foundLeftBracket = false;
}
if (foundLeftBracket) {
Schema mainSchema = database.getSchema(Constants.SCHEMA_MAIN); Schema mainSchema = database.getSchema(Constants.SCHEMA_MAIN);
if (equalsToken(tableName, RangeTable.NAME)) { if (equalsToken(tableName, RangeTable.NAME)) {
Expression min = readExpression(); Expression min = readExpression();
......
...@@ -309,6 +309,10 @@ public class TestCompatibility extends TestBase { ...@@ -309,6 +309,10 @@ public class TestCompatibility extends TestBase {
rs.next(); rs.next();
assertEquals(10, rs.getInt(1)); assertEquals(10, rs.getInt(1));
rs.close(); rs.close();
// make sure we're ignoring the index part of the statement
rs = stat.executeQuery("select * from test (index table1_index)");
rs.close();
} }
private void testDB2() throws SQLException { private void testDB2() throws SQLException {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论