提交 54d5672c authored 作者: Thomas Mueller's avatar Thomas Mueller

Improved error message for some syntax errors.

上级 aea17cdf
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>File system abstraction: if used directly, some file systems did not work correctly
<ul><li>Improved error message for some syntax errors.
</li><li>File system abstraction: if used directly, some file systems did not work correctly
with spliced byte buffers (the database engine doesn't use those).
</li><li>To use the MVStore storage engine (which is still work in progress), append
";mv_store=true" to the database URL. Using the MVTableEngine when creating the table
......
......@@ -224,9 +224,13 @@ public class Parser {
public Command prepareCommand(String sql) {
try {
Prepared p = parse(sql);
boolean hasMore = isToken(";");
if (!hasMore && currentTokenType != END) {
throw getSyntaxError();
}
p.prepare();
Command c = new CommandContainer(this, sql, p);
if (isToken(";")) {
if (hasMore) {
String remaining = originalSQL.substring(parseIndex);
if (remaining.trim().length() != 0) {
CommandList list = new CommandList(this, sql, c, remaining);
......@@ -237,8 +241,6 @@ public class Parser {
// } while(currentToken.equals(";"));
c = list;
}
} else if (currentTokenType != END) {
throw getSyntaxError();
}
return c;
} catch (DbException e) {
......
......@@ -39,6 +39,7 @@ public class TestCases extends TestBase {
@Override
public void test() throws Exception {
testClearSyntaxException();
testEmptyStatements();
testViewParameters();
testLargeKeys();
......@@ -102,6 +103,19 @@ public class TestCases extends TestBase {
deleteDb("cases");
}
private void testClearSyntaxException() throws SQLException {
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
try {
stat.execute("select t.x, t.x t.y from dual t");
fail();
} catch (SQLException e) {
assertEquals("42000", e.getSQLState());
}
conn.close();
}
private void testEmptyStatements() throws SQLException {
Connection conn = getConnection("cases");
Statement stat = conn.createStatement();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论