felipebz / zpa

Parser and static code analysis tool for PL/SQL and Oracle SQL.
https://zpa.felipebz.com
GNU Lesser General Public License v3.0
216 stars 78 forks source link

Analysis stuck #12

Closed felipebz closed 8 years ago

felipebz commented 8 years ago

@nmorais on https://github.com/felipebz/sonar-plsql/issues/8#issuecomment-251512705:

@felipebz, I got a problem after commit: Complete LIKE syntax 2d77364

The plugin got stuck at a file until the build timed out (30 minutes).

Do you have any tips on how to troubleshoot this kind of problem?

felipebz commented 8 years ago

@nmorais do you already know what file is causing the problem in the analysis, right?

Could you open the problematic file in the sslr-plsql-toolkit and parse it, please?

If I broke the parser, the sslr-plsql-tookit will get stuck too.

nmorais commented 8 years ago

@felipebz, sslr-plsql-toolkit got stuck too.

I have found what was freezing it in the file. After cutting several parts of the file, i have found that a subquery inside an EXISTS clause was the problem.

In previous commits, the parser simply failed because a AT as table alias. I dont know how the parser does not failed again, but moving the AT keyword to non reserved solved the problem.

As I have thousands of ATs used as table alias in my code, I have to support it anyway.

Finally, as it is supported, I'm making pull request #13 to move it to non reserved.

felipebz commented 8 years ago

@nmorais just to be clear, the cause of the freezing is the use "AT" as a table alias? Or the problem with the subquery inside an EXISTS clause that you mentioned is another situation?

Anyway, you made me realize that I made a wrong assumption in the PlSqlKeyword class.

Actually there are two sets of reserved keywords:

"AT" is a reserved keyword in PL/SQL (we can't declare a "PROCEDURE AT(...)"), but it isn't reserved in SQL. Thanks for the pull request, I'll review it soon.

nmorais commented 8 years ago

@felipebz, I have found that the cause was the AT keyword itself. This file has 1k+ lines and the keyword appears dozens of times. Parsing runned instantly after replacing the AT keyword for other alias.

nmorais commented 8 years ago

Hi @felipebz!

I think this issue can be closed.

This problem surfaced again in the same file last week. It was related to a issue in  a CASE statement. When the implementation the the CASE statement was fixed, the filed parsed fast.

It seems a problem that can appear when parser fails in complex files, not a bug of this plugin.

Since 98% of my code base is parsing successfully, I hope this problem never appear again! :)   
felipebz commented 8 years ago

Since it can't be reproduced anymore, I will close this issue. ;-)