提交 8e1eeaca authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add more context-sensitive keywords part 2

上级 fe046888
...@@ -556,6 +556,8 @@ The following tokens are keywords in H2: ...@@ -556,6 +556,8 @@ The following tokens are keywords in H2:
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr> <td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>JOIN</td> <tr><td>JOIN</td>
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr> <td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>LEFT</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>LIKE</td> <tr><td>LIKE</td>
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr> <td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>LIMIT</td> <tr><td>LIMIT</td>
...@@ -588,6 +590,8 @@ The following tokens are keywords in H2: ...@@ -588,6 +590,8 @@ The following tokens are keywords in H2:
<td>+</td><td></td><td></td><td></td><td></td><td></td></tr> <td>+</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>REGEXP</td> <tr><td>REGEXP</td>
<td>CS</td><td></td><td></td><td></td><td></td><td></td></tr> <td>CS</td><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td>RIGHT</td>
<td>CS</td><td>+</td><td>+</td><td>+</td><td>+</td><td>+</td></tr>
<tr><td>ROW</td> <tr><td>ROW</td>
<td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td></td></tr> <td>+</td><td>+</td><td>+</td><td>+</td><td>+</td><td></td></tr>
<tr><td>_ROWID_</td> <tr><td>_ROWID_</td>
......
...@@ -1563,13 +1563,13 @@ public class JdbcDatabaseMetaData extends TraceObject implements ...@@ -1563,13 +1563,13 @@ public class JdbcDatabaseMetaData extends TraceObject implements
* HAVING, * HAVING,
* IF, ILIKE, IN, INNER, INTERSECT, INTERSECTS, INTERVAL, IS, * IF, ILIKE, IN, INNER, INTERSECT, INTERSECTS, INTERVAL, IS,
* JOIN, * JOIN,
* LIKE, LIMIT, LOCALTIME, LOCALTIMESTAMP, * LEFT, LIKE, LIMIT, LOCALTIME, LOCALTIMESTAMP,
* MINUS, * MINUS,
* NATURAL, NOT, NULL, * NATURAL, NOT, NULL,
* OFFSET, ON, OR, ORDER, OVER, * OFFSET, ON, OR, ORDER, OVER,
* PRIMARY, * PRIMARY,
* QUALIFY, * QUALIFY,
* REGEXP, ROW, _ROWID_, ROWNUM, * REGEXP, RIGHT, ROW, _ROWID_, ROWNUM,
* SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, * SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP,
* TABLE, TODAY, TOP, TRUE, * TABLE, TODAY, TOP, TRUE,
* UNION, UNIQUE, * UNION, UNIQUE,
......
...@@ -476,6 +476,11 @@ public class ParserUtil { ...@@ -476,6 +476,11 @@ public class ParserUtil {
} else if (eq("LOCALTIMESTAMP", s, ignoreCase, start, end)) { } else if (eq("LOCALTIMESTAMP", s, ignoreCase, start, end)) {
return LOCALTIMESTAMP; return LOCALTIMESTAMP;
} }
if (additionalKeywords) {
if (eq("LEFT", s, ignoreCase, start, end)) {
return KEYWORD;
}
}
return IDENTIFIER; return IDENTIFIER;
case 'M': case 'M':
if (eq("MINUS", s, ignoreCase, start, end)) { if (eq("MINUS", s, ignoreCase, start, end)) {
...@@ -522,7 +527,7 @@ public class ParserUtil { ...@@ -522,7 +527,7 @@ public class ParserUtil {
return ROWNUM; return ROWNUM;
} }
if (additionalKeywords) { if (additionalKeywords) {
if (eq("REGEXP", s, ignoreCase, start, end)) { if (eq("REGEXP", s, ignoreCase, start, end) || eq("RIGHT", s, ignoreCase, start, end)) {
return KEYWORD; return KEYWORD;
} }
} }
......
...@@ -87,7 +87,7 @@ public class TestKeywords extends TestBase { ...@@ -87,7 +87,7 @@ public class TestKeywords extends TestBase {
assertEquals(10, rs.getInt(1)); assertEquals(10, rs.getInt(1));
assertFalse(rs.next()); assertFalse(rs.next());
} }
try (ResultSet rs = stat.executeQuery("SELECT SUM(" + s + ") " + s + " FROM " + s)) { try (ResultSet rs = stat.executeQuery("SELECT SUM(" + s + ") " + s + " FROM " + s + ' ' + s)) {
assertTrue(rs.next()); assertTrue(rs.next());
assertEquals(10, rs.getInt(1)); assertEquals(10, rs.getInt(1));
assertFalse(rs.next()); assertFalse(rs.next());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论