From d3d3af9b5974fb538f18b29cceb7fb0f59365da9 Mon Sep 17 00:00:00 2001 From: manticore-projects Date: Fri, 23 Aug 2024 23:08:42 +0700 Subject: [PATCH] fix: fix the Grammar so it builds with Maven Signed-off-by: Andreas Reichel Signed-off-by: manticore-projects --- pom.xml | 4 +--- .../net/sf/jsqlparser/parser/JSqlParserCC.jjt | 10 +++++++--- .../jsqlparser/statement/ExplainStatementTest.java | 9 +++++++++ .../select/NestedBracketsPerformanceTest.java | 13 ++++++------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 91c8b0a3a..f01ff7452 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,6 @@ [7.0.13,) test - commons-io commons-io @@ -72,7 +71,7 @@ com.h2database h2 - [2.2.224,) + [2.3.232,) test @@ -205,7 +204,6 @@ org.javacc.plugin javacc-maven-plugin - 3.0.3 javacc diff --git a/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt b/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt index d11fe5edc..b980cdf24 100644 --- a/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt +++ b/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt @@ -1192,22 +1192,26 @@ ExplainStatement Explain(): Select select; Table table; List options; + ExplainStatement es; } { ( tk= | tk = ) ( 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; + } } /** diff --git a/src/test/java/net/sf/jsqlparser/statement/ExplainStatementTest.java b/src/test/java/net/sf/jsqlparser/statement/ExplainStatementTest.java index 87799f5de..2a27bada7 100644 --- a/src/test/java/net/sf/jsqlparser/statement/ExplainStatementTest.java +++ b/src/test/java/net/sf/jsqlparser/statement/ExplainStatementTest.java @@ -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; diff --git a/src/test/java/net/sf/jsqlparser/statement/select/NestedBracketsPerformanceTest.java b/src/test/java/net/sf/jsqlparser/statement/select/NestedBracketsPerformanceTest.java index 240e10bf9..c70d29c73 100644 --- a/src/test/java/net/sf/jsqlparser/statement/select/NestedBracketsPerformanceTest.java +++ b/src/test/java/net/sf/jsqlparser/statement/select/NestedBracketsPerformanceTest.java @@ -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 @@ -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); @@ -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) @@ -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) {