Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALTER INDEX throws exception #124

Open
styper opened this issue Jul 2, 2019 · 3 comments
Open

ALTER INDEX throws exception #124

styper opened this issue Jul 2, 2019 · 3 comments

Comments

@styper
Copy link

styper commented Jul 2, 2019

SQL file:
alter index test.test nologging;

Exception:
com.sonar.sslr.api.RecognitionException: Parse error at line 1 column 6:

--> alter index test.test nologging;
2: /EOF

at org.sonar.sslr.internal.vm.Machine.parse(Machine.java:73)
at com.sonar.sslr.impl.Parser.parse(Parser.java:84)
at com.sonar.sslr.impl.Parser.parse(Parser.java:78)
at org.sonar.sslr.internal.toolkit.SourceCodeModel.setSourceCode(SourceCodeModel.java:62)
at org.sonar.sslr.internal.toolkit.ToolkitPresenter.onSourceCodeParseButtonClick(ToolkitPresenter.java:122)
at org.sonar.sslr.internal.toolkit.ToolkitViewImpl$5.actionPerformed(ToolkitViewImpl.java:201)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
@styper
Copy link
Author

styper commented Jul 2, 2019

Can't seem to edit the issue but my version is:
zpa-toolkit-2.4.0-SNAPSHOT.jar

I switched from zpa-toolkit-2.3.0 because the search was throwing a class not found exception:
Caused by: java.lang.ClassNotFoundException: org.jaxen.saxpath.base.XPathReader

@felipebz
Copy link
Owner

felipebz commented Jul 2, 2019

Hi!

In the "configuration" tab of zpa-toolkit you can change the "Error recovery" property to true. Changing this will make the parser more tolerant and simply ignore the CREATE INDEX. Btw, the "error recovery" is set by default in the SonarQube plugin.

Does it solve your problem? If you want to create a rule to check specifically for the CREATE INDEX command please let me know. :-)

@styper
Copy link
Author

styper commented Jul 2, 2019

Thanks, your solution worked!

Just a little background on why I'm using it for INDEXES. We have a lot of SQL scripts that need to be applied to the DB, and the execution is done by a robot using an owner that's not the application's schema, so a solution would be to parse the SQL files using the scanner to locate DDLs that don't have an owner defined.

I'm creating a custom rule that find xPaths like: //CREATE_PACKAGE/UNIT_NAME[count(./IDENTIFIER_NAME) < 2]

It would be great if the parser had support for indexes as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants