Skip to content

Commit 8f9b627

Browse files
committed
fixes #484
1 parent 84f8e78 commit 8f9b627

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

src/main/java/net/sf/jsqlparser/statement/execute/Execute.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333
public class Execute implements Statement {
3434

35+
private EXEC_TYPE execType = EXEC_TYPE.EXECUTE;
3536
private String name;
3637
private ExpressionList exprList;
3738

@@ -51,15 +52,29 @@ public void setExprList(ExpressionList exprList) {
5152
this.exprList = exprList;
5253
}
5354

55+
public EXEC_TYPE getExecType() {
56+
return execType;
57+
}
58+
59+
public void setExecType(EXEC_TYPE execType) {
60+
this.execType = execType;
61+
}
62+
5463
@Override
5564
public void accept(StatementVisitor statementVisitor) {
5665
statementVisitor.visit(this);
5766
}
5867

5968
@Override
6069
public String toString() {
61-
return "EXECUTE " + name + " " + PlainSelect.
70+
return execType.name() + " " + name + " " + PlainSelect.
6271
getStringList(exprList.getExpressions(), true, false);
6372
}
73+
74+
public static enum EXEC_TYPE {
75+
EXECUTE,
76+
EXEC,
77+
CALL
78+
}
6479

6580
}

src/main/java/net/sf/jsqlparser/util/deparser/ExecuteDeParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void setBuffer(StringBuilder buffer) {
5252
}
5353

5454
public void deParse(Execute execute) {
55-
buffer.append("EXECUTE ").append(execute.getName());
55+
buffer.append(execute.getExecType().name()).append(" ").append(execute.getName());
5656
List<Expression> expressions = execute.getExprList().getExpressions();
5757
for (int i = 0; i < expressions.size(); i++) {
5858
if (i > 0) {

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
285285
| <K_DISABLE : "DISABLE">
286286
| <K_USE : "USE">
287287
| <K_FORCE : "FORCE">
288+
| <K_CALL : "CALL">
288289
}
289290

290291
TOKEN : /* Stuff */
@@ -2704,7 +2705,9 @@ Execute Execute(): {
27042705
Execute execute = new Execute();
27052706
}
27062707
{
2707-
(<K_EXEC> | <K_EXECUTE>)
2708+
(<K_EXEC> { execute.setExecType(Execute.EXEC_TYPE.EXEC); }
2709+
| <K_EXECUTE> { execute.setExecType(Execute.EXEC_TYPE.EXECUTE); }
2710+
| <K_CALL> { execute.setExecType(Execute.EXEC_TYPE.CALL); } )
27082711

27092712
funcName=RelObjectName() { execute.setName(funcName); }
27102713

src/test/java/net/sf/jsqlparser/statement/execute/ExecuteTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ public void tearDown() {
5757
* @throws net.sf.jsqlparser.JSQLParserException
5858
*/
5959
@Test
60-
public void testAccept() throws JSQLParserException {
60+
public void testAcceptExecute() throws JSQLParserException {
6161
assertSqlCanBeParsedAndDeparsed("EXECUTE myproc 'a', 2, 'b'");
6262
}
63+
64+
@Test
65+
public void testAcceptExec() throws JSQLParserException {
66+
assertSqlCanBeParsedAndDeparsed("EXEC myproc 'a', 2, 'b'");
67+
}
68+
69+
@Test
70+
public void testAcceptCall() throws JSQLParserException {
71+
assertSqlCanBeParsedAndDeparsed("CALL myproc 'a', 2, 'b'");
72+
}
6373
}

0 commit comments

Comments
 (0)