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

Use currentTokenType in Parser.parsePrepared()

上级 87e449d9
...@@ -672,13 +672,13 @@ public class Parser { ...@@ -672,13 +672,13 @@ public class Parser {
private Prepared parsePrepared() { private Prepared parsePrepared() {
int start = lastParseIndex; int start = lastParseIndex;
Prepared c = null; Prepared c = null;
String token = currentToken; switch (currentTokenType) {
if (token.length() == 0) { case END:
case SEMICOLON:
c = new NoOperation(session); c = new NoOperation(session);
} else { setSQL(c, null, start);
char first = token.charAt(0); return c;
switch (first) { case PARAMETER:
case '?':
// read the ? as a parameter // read the ? as a parameter
readTerm(); readTerm();
// this is an 'out' parameter - set a dummy value // this is an 'out' parameter - set a dummy value
...@@ -687,9 +687,17 @@ public class Parser { ...@@ -687,9 +687,17 @@ public class Parser {
read("CALL"); read("CALL");
c = parseCall(); c = parseCall();
break; break;
case '(': case OPEN_PAREN:
case FROM:
case SELECT:
c = parseSelect(); c = parseSelect();
break; break;
case WITH:
read();
c = parseWithStatementOrQuery();
break;
case IDENTIFIER:
switch (currentToken.charAt(0)) {
case 'a': case 'a':
case 'A': case 'A':
if (readIf("ALTER")) { if (readIf("ALTER")) {
...@@ -741,12 +749,6 @@ public class Parser { ...@@ -741,12 +749,6 @@ public class Parser {
c = parseExecute(); c = parseExecute();
} }
break; break;
case 'f':
case 'F':
if (isToken(FROM)) {
c = parseSelect();
}
break;
case 'g': case 'g':
case 'G': case 'G':
if (readIf("GRANT")) { if (readIf("GRANT")) {
...@@ -793,9 +795,7 @@ public class Parser { ...@@ -793,9 +795,7 @@ public class Parser {
break; break;
case 's': case 's':
case 'S': case 'S':
if (isToken(SELECT)) { if (readIf("SET")) {
c = parseSelect();
} else if (readIf("SET")) {
c = parseSet(); c = parseSet();
} else if (readIf("SAVEPOINT")) { } else if (readIf("SAVEPOINT")) {
c = parseSavepoint(); c = parseSavepoint();
...@@ -826,17 +826,9 @@ public class Parser { ...@@ -826,17 +826,9 @@ public class Parser {
if (readIf("VALUES")) { if (readIf("VALUES")) {
c = parseValues(); c = parseValues();
} }
break;
case 'w':
case 'W':
if (readIf(WITH)) {
c = parseWithStatementOrQuery();
} }
break; }
case ';': if (c == null) {
c = new NoOperation(session);
break;
default:
throw getSyntaxError(); throw getSyntaxError();
} }
if (indexedParameterList != null) { if (indexedParameterList != null) {
...@@ -869,10 +861,6 @@ public class Parser { ...@@ -869,10 +861,6 @@ public class Parser {
} }
parameters.clear(); parameters.clear();
} }
}
if (c == null) {
throw getSyntaxError();
}
setSQL(c, null, start); setSQL(c, null, start);
return c; return c;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论