Skip to content

Commit cd0689e

Browse files
fix: remove obsolete SimpleFunction
- fixes #2059 Signed-off-by: Andreas Reichel <[email protected]> Signed-off-by: manticore-projects <[email protected]>
1 parent d7bf249 commit cd0689e

File tree

2 files changed

+12
-52
lines changed

2 files changed

+12
-52
lines changed

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

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5587,7 +5587,6 @@ Function Function() #Function:
55875587
{
55885588
(
55895589
"{" <K_FN> function = InternalFunction(true) "}"
5590-
| LOOKAHEAD( SimpleFunction(), { getAsBoolean(Feature.allowComplexParsing) }) function = SimpleFunction()
55915590
| LOOKAHEAD(3) function = SpecialStringFunctionWithNamedParameters()
55925591
| function = InternalFunction(false)
55935592
)
@@ -5623,57 +5622,6 @@ Function SpecialStringFunctionWithNamedParameters() :
56235622
}
56245623
}
56255624

5626-
// a simplified function with only one parameter
5627-
// useful for parsing nested functions fast
5628-
Function SimpleFunction():
5629-
{
5630-
Function function = new Function();
5631-
ObjectNames name;
5632-
Expression expr=null;
5633-
Expression attributeExpression = null;
5634-
Column attributeColumn = null;
5635-
}
5636-
{
5637-
name = RelObjectNames()
5638-
"("
5639-
[
5640-
(
5641-
"*" { expr = new AllColumns(); }
5642-
|
5643-
LOOKAHEAD( AllTableColumns() ) expr=AllTableColumns()
5644-
|
5645-
LOOKAHEAD( 3 ) expr = ParenthesedSelect()
5646-
|
5647-
LOOKAHEAD( SimpleFunction() ) expr = SimpleFunction()
5648-
|
5649-
LOOKAHEAD( RegularCondition() ) expr = RegularCondition()
5650-
|
5651-
LOOKAHEAD( SimpleExpressionList() ) expr = SimpleExpressionList()
5652-
)
5653-
]
5654-
")"
5655-
{
5656-
function.setName(name.getNames());
5657-
if (expr!=null) {
5658-
function.setParameters(expr);
5659-
}
5660-
}
5661-
5662-
[ LOOKAHEAD(2) "." (
5663-
// tricky lookahead since we do need to support the following constructs
5664-
// schema.f1().f2() - Function with Function Column
5665-
// schema.f1().f2.f3 - Function with Attribute Column
5666-
LOOKAHEAD( Function() ) attributeExpression=Function() { function.setAttribute(attributeExpression); }
5667-
|
5668-
attributeColumn=Column() { function.setAttribute(attributeColumn); }
5669-
)
5670-
]
5671-
5672-
{
5673-
return function;
5674-
}
5675-
}
5676-
56775625
Function InternalFunction(boolean escaped):
56785626
{
56795627
Token prefixToken = null;
@@ -5701,6 +5649,10 @@ Function InternalFunction(boolean escaped):
57015649
)
57025650
]
57035651
(
5652+
"*" { expr = new AllColumns(); expressionList = new ExpressionList(expr); }
5653+
|
5654+
LOOKAHEAD( AllTableColumns() ) expr=AllTableColumns() { expressionList = new ExpressionList(expr); }
5655+
|
57045656
LOOKAHEAD(3) expressionList=ExpressionList() [ orderByList = OrderByElements() { retval.setOrderByElements(orderByList); } ]
57055657
|
57065658
expr = Select() { expressionList = new ExpressionList(expr); }

src/test/java/net/sf/jsqlparser/expression/FunctionTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,12 @@ void testSubSelectArrayWithoutKeywordParameter() throws JSQLParserException {
7575
" UNNEST(addresses) AS email";
7676
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true);
7777
}
78+
79+
@Test
80+
void testSimpleFunctionIssue2059() throws JSQLParserException {
81+
String sqlStr = "select count(*) from zzz";
82+
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true, parser -> {
83+
parser.withAllowComplexParsing(false);
84+
});
85+
}
7886
}

0 commit comments

Comments
 (0)