JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

replace all uses of expression with simpleexpression where it fits

Open wumpz opened this issue 4 years ago • 6 comments
trafficstars

Expression does allow all kinds of complex boolean relations like a = 5 and b = 6 which is for most cases not suitable.

This will increase parsing speed of those productions by a huge margin.

wumpz avatar Nov 19 '21 21:11 wumpz

Greetings.

Unfortunately I do not understand what you intend to do: Did we not replace a few SimpleExpression with Expression exactly for parsing complex expressions?

manticore-projects avatar Nov 22 '21 08:11 manticore-projects

Thats right, but not in every case that is needed. But in doing so, the parsing is much more complex.

For instance your latest change of LikeExpression. Why should the escape expression be indeed this kind of complex expression?

And I do not want to replace all / or a few SimpleExpressions with Expression to parse in every occasion complex expressions. At least not when this has such a performance impact. I know your argument of being complete, but not at the lately discovered costs.

Maybe this should be optional? The class itself could hold an Expression but if a complex expression is parsed, could be switched on / off.

wumpz avatar Nov 28 '21 20:11 wumpz

Greetings.

We actually DO have such a FEATURE already: AllowComplexExpressionParsing, which is set to TRUE most times, but only set to FALSE when we detect too deep nesting.

You can set this FEATURE manually though when calling the parser:

CCJSqlParser parser = newParser(sql).withAllowComplexParsing(false);

If you insist in SimpleExpression on demand, then just modify the LOOKAHEADs like

LOOKAHEAD( {getAsBoolean(Feature.allowComplexParsing)} ) expression = Expression() | expression = SimpleExpression()

manticore-projects avatar Nov 29 '21 08:11 manticore-projects

We could implement two methods parse() and fastParse() and set AllowComplexExpressionParsing to FALSE for the later one.

manticore-projects avatar Nov 29 '21 08:11 manticore-projects

I was not aware that this AllowComplexExpressionParsing is a global option. I thought it was only checked for CaseWhenExpressions.

Am I wrong?

wumpz avatar Dec 12 '21 14:12 wumpz

We use it at various places. Most prominently in Primary Expression and Case.Sent from my Galaxy -------- Original message --------From: Tobias @.> Date: 12/12/2021 15:34 (GMT+01:00) To: JSQLParser/JSqlParser @.> Cc: manticore-projects @.>, Comment @.> Subject: Re: [JSQLParser/JSqlParser] replace all uses of expression with simpleexpression where it fits (Issue #1424) I was not aware that this AllowComplexExpressionParsing is a global option. I thought it was only checked for CaseWhenExpressions. Am I wrong?

—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.

manticore-projects avatar Dec 12 '21 14:12 manticore-projects

Closed, since no further question has been asked.

manticore-projects avatar Nov 12 '22 06:11 manticore-projects