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

[plsql] ParseException for CREATE TABLE #980

Closed
dvdtknsn opened this Issue Mar 16, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@dvdtknsn

dvdtknsn commented Mar 16, 2018

Please, prefix the report title with the language it applies to within brackets, such as [java] or [apex].
If not specific to a language, you can use [core].

Affects PMD Version:
6.1.0
Rule:
Issue parsing a .sql file that has a CREATE TABLE definition
Description:
net.sourceforge.pmd.PMDException: Error while parsing D:\flOraGithubRepo\HR_WF\Database\HR\Tables\CUSTOMERS.sql
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:98)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:50)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:75)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:23)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: net.sourceforge.pmd.lang.plsql.ast.ParseException: Encountered " "PRIMARY "" at line 5, column 27.
Was expecting one of:
"@" ...
"." ...
"," ...
")" ...
"%" ...
"DEFAULT" ...
"NOT" ...
"NULL" ...

at net.sourceforge.pmd.lang.plsql.ast.PLSQLParser.generateParseException(PLSQLParser.java:40789)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParser.jj_consume_token(PLSQLParser.java:40643)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParser.Table(PLSQLParser.java:22556)
at net.sourceforge.pmd.lang.plsql.ast.PLSQLParser.Input(PLSQLParser.java:180)
at net.sourceforge.pmd.lang.plsql.PLSQLParser.parse(PLSQLParser.java:48)
at net.sourceforge.pmd.SourceCodeProcessor.parse(SourceCodeProcessor.java:110)
at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:173)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:95)

Code Sample demonstrating the issue:
-- this is the customers.sql file:
CREATE TABLE customers
( customer_id number(10) NOT NULL,
customer_name varchar2(50) NOT NULL,
city varchar2(50),
CONSTRAINT customers_pk PRIMARY KEY (customer_id)
);

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
Windows command line:
call Tools\pmd\bin\pmd -d "Database\HR" -l plsql -R pmd_ruleset.xml -f summaryhtml -r Artifacts\static_analysis_report.html

@dvdtknsn

This comment has been minimized.

dvdtknsn commented Mar 17, 2018

Just found https://sourceforge.net/p/pmd/discussion/188194/thread/a677f39b/ that possibly implies that this isn't supported. Either way, I'd expect it to skip what it can't understand rather than throwing an exception.

@jsotuyod jsotuyod added the a:bug label Mar 18, 2018

@jsotuyod

This comment has been minimized.

Member

jsotuyod commented Mar 18, 2018

@dvdtknsn definitely. The parser shouldn't throw when processing valid PL/SQL.

@adangel adangel changed the title from [plsql] plsql.ast.ParseException for CREATE TABLE to [plsql] ParseException for CREATE TABLE Jul 15, 2018

adangel added a commit to adangel/pmd that referenced this issue Jul 15, 2018

adangel added a commit to adangel/pmd that referenced this issue Jul 15, 2018

@adangel adangel added the has:pr label Jul 15, 2018

@adangel adangel added this to the 6.6.0 milestone Jul 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment