Skip to content

Commit

Permalink
fix: fix the Grammar so it builds with Maven
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Reichel <[email protected]>
Signed-off-by: manticore-projects <[email protected]>
  • Loading branch information
manticore-projects committed Aug 23, 2024
1 parent d837b67 commit d3d3af9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
4 changes: 1 addition & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<version>[7.0.13,)</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down Expand Up @@ -72,7 +71,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>[2.2.224,)</version>
<version>[2.3.232,)</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -205,7 +204,6 @@
<plugin>
<groupId>org.javacc.plugin</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>3.0.3</version>
<executions>
<execution>
<id>javacc</id>
Expand Down
10 changes: 7 additions & 3 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -1192,22 +1192,26 @@ ExplainStatement Explain():
Select select;
Table table;
List<ExplainStatement.Option> options;
ExplainStatement es;
}
{
( tk=<K_EXPLAIN> | tk = <K_SUMMARIZE> )
(
LOOKAHEAD(3)(
options=ExplainStatementOptions()
options= ExplainStatementOptions()
select = Select( )
{
return new ExplainStatement(tk.image, select, options);
es = new ExplainStatement(tk.image, select, options);
}
)
|
(
table=Table( ) { return new ExplainStatement(tk.image, table); }
table=Table( ) { es = new ExplainStatement(tk.image, table); }
)
)
{
return es;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2024 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.statement;

import net.sf.jsqlparser.JSQLParserException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ public void testRecursiveBracketExpressionIssue1019() {
// maxDepth = 10 collides with the Parser Timeout = 6 seconds
// @todo: implement methods to set the Parser Timeout explicitly and on demand
@Test
@Timeout(20000)
@Timeout(2000)
public void testRecursiveBracketExpressionIssue1019_2() throws JSQLParserException {
// Temporally set the maxDepth to be 6, was 8 before this
doIncreaseOfParseTimeTesting("IF(1=1, $1, 2)", "1", 6);
doIncreaseOfParseTimeTesting("IF(1=1, $1, 2)", "1", 8);
}

@Test
Expand All @@ -165,9 +165,9 @@ public void testIssue1013_3() throws JSQLParserException {
@Test
@Timeout(2000)
public void testIssue1013_4() throws JSQLParserException {
String s = "tblA";
StringBuilder s = new StringBuilder("tblA");
for (int i = 1; i < 100; i++) {
s = "(" + s + ")";
s = new StringBuilder("(" + s + ")");
}
String sql = "SELECT * FROM " + s;
LOG.info("testing " + sql);
Expand All @@ -182,8 +182,7 @@ public void testIssue1013_4() throws JSQLParserException {
@Test
@Timeout(2000)
public void testIncreaseOfParseTime() throws JSQLParserException {
// Temporally set the maxDepth to be 6, was 50 before this
doIncreaseOfParseTimeTesting("concat($1,'B')", "'A'", 6);
doIncreaseOfParseTimeTesting("concat($1,'B')", "'A'", 50);
}

private void doIncreaseOfParseTimeTesting(String template, String finalExpression, int maxDepth)
Expand All @@ -194,7 +193,7 @@ private void doIncreaseOfParseTimeTesting(String template, String finalExpressio
String sql = "SELECT " + buildRecursiveBracketExpression(template, finalExpression, i)
+ " FROM mytbl";
long startTime = System.currentTimeMillis();
assertSqlCanBeParsedAndDeparsed(sql, true, parser -> parser.withTimeOut(60000));
assertSqlCanBeParsedAndDeparsed(sql, true, parser -> parser.withTimeOut(12000));
long durationTime = System.currentTimeMillis() - startTime;

if (i > 0) {
Expand Down

0 comments on commit d3d3af9

Please sign in to comment.