提交 12627199 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add more context-sensitive keywords

上级 a8488f5f
......@@ -540,6 +540,8 @@ The following tokens are keywords in H2:
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>GROUP</td>
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>GROUPS</td>
<td>CS</td><td>+</td><td></td><td></td><td></td><td></td></tr>
<tr><td>HAVING</td>
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>IF</td>
......@@ -590,10 +592,14 @@ The following tokens are keywords in H2:
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>OVER</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td></td><td></td></tr>
<tr><td>PARTITION</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td></td><td></td></tr>
<tr><td>PRIMARY</td>
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>QUALIFY</td>
<td>+</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>RANGE</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td></td><td></td></tr>
<tr><td>REGEXP</td>
<td>CS</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>RIGHT</td>
......@@ -604,6 +610,8 @@ The following tokens are keywords in H2:
<td>+</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>ROWNUM</td>
<td>+</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>ROWS</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>SELECT</td>
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>SYSDATE</td>
......
......@@ -1541,6 +1541,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* table/column/index name, in addition to the SQL:2003 keywords. The list
* returned is:
* <pre>
* GROUPS
* IF,ILIKE,INTERSECTS,
* LIMIT,
* MINUS,
......@@ -1558,7 +1559,7 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* DISTINCT,
* EXCEPT, EXISTS,
* FALSE, FETCH, FILTER, FOR, FOREIGN, FROM, FULL,
* GROUP,
* GROUP, GROUPS
* HAVING,
* IF, ILIKE, IN, INNER, INTERSECT, INTERSECTS, INTERVAL, IS,
* JOIN,
......@@ -1566,9 +1567,9 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* MINUS,
* NATURAL, NOT, NULL,
* OFFSET, ON, OR, ORDER, OVER,
* PRIMARY,
* PARTITION, PRIMARY,
* QUALIFY,
* REGEXP, RIGHT, ROW, _ROWID_, ROWNUM,
* RANGE, REGEXP, RIGHT, ROW, _ROWID_, ROWNUM, ROWS,
* SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP,
* TABLE, TODAY, TOP, TRAILING, TRUE,
* UNION, UNIQUE,
......@@ -1581,7 +1582,8 @@ public class JdbcDatabaseMetaData extends TraceObject implements
@Override
public String getSQLKeywords() {
debugCodeCall("getSQLKeywords");
return "IF,ILIKE,INTERSECTS," //
return "GROUPS," //
+ "IF,ILIKE,INTERSECTS," //
+ "LIMIT," //
+ "MINUS," //
+ "OFFSET," //
......
......@@ -472,6 +472,11 @@ public class ParserUtil {
if (eq("GROUP", s, ignoreCase, start, end)) {
return GROUP;
}
if (additionalKeywords) {
if (eq("GROUPS", s, ignoreCase, start, end)) {
return KEYWORD;
}
}
return IDENTIFIER;
case 'H':
if (eq("HAVING", s, ignoreCase, start, end)) {
......@@ -551,6 +556,11 @@ public class ParserUtil {
if (eq("PRIMARY", s, ignoreCase, start, end)) {
return PRIMARY;
}
if (additionalKeywords) {
if (eq("PARTITION", s, ignoreCase, start, end)) {
return KEYWORD;
}
}
return IDENTIFIER;
case 'Q':
if (eq("QUALIFY", s, ignoreCase, start, end)) {
......@@ -564,7 +574,8 @@ public class ParserUtil {
return ROWNUM;
}
if (additionalKeywords) {
if (eq("REGEXP", s, ignoreCase, start, end) || eq("RIGHT", s, ignoreCase, start, end)) {
if (eq("RANGE", s, ignoreCase, start, end) || eq("REGEXP", s, ignoreCase, start, end)
|| eq("ROWS", s, ignoreCase, start, end) || eq("RIGHT", s, ignoreCase, start, end)) {
return KEYWORD;
}
}
......
......@@ -463,7 +463,8 @@ public class TestMetaData extends TestDb {
assertEquals("schema", meta.getSchemaTerm());
assertEquals("\\", meta.getSearchStringEscape());
assertEquals("IF,ILIKE,INTERSECTS," //
assertEquals("GROUPS," //
+ "IF,ILIKE,INTERSECTS," //
+ "LIMIT," //
+ "MINUS," //
+ "OFFSET," //
......
......@@ -100,6 +100,9 @@ public class TestKeywords extends TestBase {
assertEquals("a", rs.getString(1));
}
stat.execute("DROP TABLE TEST");
try (ResultSet rs = stat
.executeQuery("SELECT ROW_NUMBER() OVER(" + s + ") WINDOW " + s + " AS ()")) {
}
} catch (Throwable t) {
throw new AssertionError(s + " cannot be used as identifier.", t);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论