Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 215237 - SQL Query Parser throws NPE at comment in SQL
Summary: SQL Query Parser throws NPE at comment in SQL
Status: CLOSED FIXED
Alias: None
Product: Data Tools
Classification: Tools
Component: SQL Query Parser (show other bugs)
Version: 1.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.6M5   Edit
Assignee: Brian Payton CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 202602
  Show dependency tree
 
Reported: 2008-01-14 11:37 EST by Jeremy Lindop CLA
Modified: 2008-04-25 15:54 EDT (History)
0 users

See Also:


Attachments
Part 1 of patch for o.e.d.modelbase.sql.query plugin (1.03 MB, patch)
2008-01-30 21:28 EST, Brian Payton CLA
no flags Details | Diff
Part 2 of patch for o.e.d.modelbase.sql.query plugin (1.04 MB, patch)
2008-01-30 21:29 EST, Brian Payton CLA
no flags Details | Diff
Part 3 of patch for o.e.d.modelbase.sql.query plugin (1.28 MB, patch)
2008-01-30 21:30 EST, Brian Payton CLA
no flags Details | Diff
Part 4 of patch for o.e.d.modelbase.sql.query plugin (1.13 MB, patch)
2008-01-30 21:30 EST, Brian Payton CLA
no flags Details | Diff
Part 5 of patch for o.e.d.modelbase.sql.query plugin (1.34 MB, patch)
2008-01-30 21:31 EST, Brian Payton CLA
no flags Details | Diff
Part 6 of patch for o.e.d.modelbase.sql.query plugin (374.78 KB, patch)
2008-01-30 21:32 EST, Brian Payton CLA
no flags Details | Diff
Patch for o.e.d.modelbase.sql.query.edit plugin (248.55 KB, patch)
2008-01-30 21:33 EST, Brian Payton CLA
no flags Details | Diff
Patch for o.e.d.sqltools.parsers.sql plugin (6.83 KB, patch)
2008-01-30 21:34 EST, Brian Payton CLA
no flags Details | Diff
Patch for o.e.d.sqltools.parsers.sql.lexer plugin (51.37 KB, patch)
2008-01-30 21:34 EST, Brian Payton CLA
no flags Details | Diff
Patch for o.e.d.sqltools.parsers.sql.query plugin (19.68 KB, patch)
2008-01-30 21:35 EST, Brian Payton CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Lindop CLA 2008-01-14 11:37:33 EST
The parser org.eclipse.datatools.sqltools.parsers.sql.query throws an NPE when parsing SQL with "--" end-of-line style comments.

This was found using the interactiveTest:
   Plugin:  org.eclipse.datatools.sqltools.parsers.sql.query.test 
   Program:  InteractiveTest 

This is run as a "Java Application".
The SQL I tried was:
SELECT DISTINCT PAYMENTNO, PLAYERNO -- comment
  FROM DBA.PENALTIES;

and the console contains this error:
Parsing:
SELECT DISTINCT PAYMENTNO, PLAYERNO -- comment
  FROM DBA.PENALTIES;
Error reading from stdin, quitting...null
org.eclipse.datatools.sqltools.parsers.sql.SQLParserInternalException
	at org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager.makeAST(SQLParserManager.java:528)
	at org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager.parse(SQLParserManager.java:791)
	at org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager.parseQuery(SQLQueryParserManager.java:326)
	at org.eclipse.datatools.sqltools.parsers.sql.query.test.InteractiveTest.main(InteractiveTest.java:78)
Caused by: java.lang.NullPointerException
	at lpg.lpgjavaruntime.AbstractToken.getValue(AbstractToken.java:53)
	at org.eclipse.datatools.sqltools.parsers.sql.query.AbstractSQLQueryParser.createCommentObject(AbstractSQLQueryParser.java:528)
	at org.eclipse.datatools.sqltools.parsers.sql.query.AbstractSQLQueryParser.createCommentObjectsSorted(AbstractSQLQueryParser.java:477)
	at org.eclipse.datatools.sqltools.parsers.sql.query.AbstractSQLQueryParser.addCommentsToAST(AbstractSQLQueryParser.java:117)
	at org.eclipse.datatools.sqltools.parsers.sql.AbstractSQLParser.parser(AbstractSQLParser.java:391)
	at org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager.makeAST(SQLParserManager.java:436)
	... 3 more
Comment 1 Brian Payton CLA 2008-01-30 21:28:58 EST
Created attachment 88356 [details]
Part 1 of patch for o.e.d.modelbase.sql.query plugin
Comment 2 Brian Payton CLA 2008-01-30 21:29:36 EST
Created attachment 88357 [details]
Part 2 of patch for o.e.d.modelbase.sql.query plugin
Comment 3 Brian Payton CLA 2008-01-30 21:30:14 EST
Created attachment 88358 [details]
Part 3 of patch for o.e.d.modelbase.sql.query plugin
Comment 4 Brian Payton CLA 2008-01-30 21:30:51 EST
Created attachment 88359 [details]
Part 4 of patch for o.e.d.modelbase.sql.query plugin
Comment 5 Brian Payton CLA 2008-01-30 21:31:36 EST
Created attachment 88360 [details]
Part 5 of patch for o.e.d.modelbase.sql.query plugin
Comment 6 Brian Payton CLA 2008-01-30 21:32:03 EST
Created attachment 88361 [details]
Part 6 of patch for o.e.d.modelbase.sql.query plugin
Comment 7 Brian Payton CLA 2008-01-30 21:33:01 EST
Created attachment 88362 [details]
Patch for o.e.d.modelbase.sql.query.edit plugin
Comment 8 Brian Payton CLA 2008-01-30 21:34:00 EST
Created attachment 88363 [details]
Patch for o.e.d.sqltools.parsers.sql plugin
Comment 9 Brian Payton CLA 2008-01-30 21:34:41 EST
Created attachment 88364 [details]
Patch for o.e.d.sqltools.parsers.sql.lexer plugin
Comment 10 Brian Payton CLA 2008-01-30 21:35:12 EST
Created attachment 88365 [details]
Patch for o.e.d.sqltools.parsers.sql.query plugin
Comment 11 Brian Payton CLA 2008-01-30 21:40:07 EST
These patches to the modelbase.sql.query plugins and the sqltools.parsers.sql plugins fix several problems, including comment handling.

The patch for the modelbase.sql.query plugin is very large because the EMF code generator changed almost all the methods in all the model classes in some trivial way.  The number of real changes in plugin is actually quite small.
Comment 12 Brian Payton CLA 2008-01-31 13:30:58 EST
Should be working now.  Let me know if not.
Comment 13 Jeremy Lindop CLA 2008-02-05 07:19:57 EST
The NPE is fixed.
I was expecting comment objects to be added to the AST when the query contained comments, but there's nothing in the AST representing the comment using the test described above.
Comment 14 Brian Payton CLA 2008-04-25 15:54:27 EDT
Closing...