zpa icon indicating copy to clipboard operation
zpa copied to clipboard

ALTER INDEX throws exception

Open styper opened this issue 5 years ago • 3 comments

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 avatar Jul 02 '19 19:07 styper

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

styper avatar Jul 02 '19 19:07 styper

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. :-)

felipebz avatar Jul 02 '19 21:07 felipebz

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.

styper avatar Jul 02 '19 22:07 styper