diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 7f346c5f24..88cef7279d 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -61,7 +61,10 @@ about the usage and features of the rule designer. * [#1966](https://github.com/pmd/pmd/issues/1966): \[java] CloseResource false positive if Stream is passed as method parameter * [#1967](https://github.com/pmd/pmd/issues/1967): \[java] CloseResource false positive with late assignment of variable * plsql + * [#1935](https://github.com/pmd/pmd/issues/1935): \[plsql] ParseException with SELECT INTO record defined as global variable * [#1947](https://github.com/pmd/pmd/issues/1947): \[plsql] ParseError - SELECT with FOR UPDATE OF + * [#1948](https://github.com/pmd/pmd/issues/1948): \[plsql] ParseException with INSERT INTO using package global variables + * [#1950](https://github.com/pmd/pmd/issues/1950): \[plsql] ParseException with UPDATE and package record variable ### API Changes @@ -105,6 +108,7 @@ about the usage and features of the rule designer. * [#1970](https://github.com/pmd/pmd/pull/1970): \[java] DoubleBraceInitialization: Fix example - [Tobias Weimer](https://github.com/tweimer) * [#1971](https://github.com/pmd/pmd/pull/1971): \[java] 1862 - Message Digest should not be used as class field - [AnthonyKot](https://github.com/AnthonyKot) * [#1972](https://github.com/pmd/pmd/pull/1972): \[plsql] ParseError - SELECT with FOR UPDATE OF - [Piotr Szymanski](https://github.com/szyman23) +* [#1974](https://github.com/pmd/pmd/pull/1974): \[plsql] Fixes for referencing record type variables - [Piotr Szymanski](https://github.com/szyman23) * [#1994](https://github.com/pmd/pmd/pull/1994): \[core] Resolve pmd-report failure when java folder in filepath - [Amish Shah](https://github.com/shahamish150294) {% endtocmaker %} diff --git a/pmd-plsql/etc/grammar/PldocAST.jjt b/pmd-plsql/etc/grammar/PldocAST.jjt index cec0142acc..b0236fe629 100644 --- a/pmd-plsql/etc/grammar/PldocAST.jjt +++ b/pmd-plsql/etc/grammar/PldocAST.jjt @@ -1911,6 +1911,7 @@ ASTVariableName VariableName() : { id = ID() { name.append(id.getImage()); } [ "." id = ID() { name.append('.').append(id.getImage()); } ] + [ "." id = ID() { name.append('.').append(id.getImage()); } ] { jjtThis.setImage(name.toString()); return jjtThis; @@ -2351,7 +2352,7 @@ ASTValuesClause ValuesClause() : ( "(" ( Expression() | <_DEFAULT> ) ( "," ( Expression() | <_DEFAULT> ) )* ")" | - ID() // that's a record variable name + Name() // that's a record variable name ) { return jjtThis; } } @@ -2435,7 +2436,7 @@ ASTUpdateSetClause UpdateSetClause() : { ( - LOOKAHEAD(1) "=" ID() + LOOKAHEAD(1) "=" Name() | "VALUE" "(" TableAlias() ")" "=" ( LOOKAHEAD(1) "(" Subquery() ")" | Expression() ) | @@ -2457,7 +2458,7 @@ ASTUpdateSetClause UpdateSetClause() : ASTReturningClause ReturningClause() : {} { - ( | ) ( Expression() (",")? )+ ( ID() (",")? )+ + ( | ) ( Expression() (",")? )+ ( Name() (",")? )+ { return jjtThis; } } diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/RecordTypeTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/RecordTypeTest.java new file mode 100644 index 0000000000..1b0a3f4e06 --- /dev/null +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/RecordTypeTest.java @@ -0,0 +1,24 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.plsql.ast; + +import java.nio.charset.StandardCharsets; + +import org.apache.commons.io.IOUtils; +import org.junit.Assert; +import org.junit.Test; + +import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst; + +public class RecordTypeTest extends AbstractPLSQLParserTst { + + @Test + public void parseRecordType() throws Exception { + String code = IOUtils.toString(this.getClass().getResourceAsStream("RecordType.pls"), + StandardCharsets.UTF_8); + ASTInput input = parsePLSQL(code); + Assert.assertNotNull(input); + } +} diff --git a/pmd-plsql/src/test/resources/net/sourceforge/pmd/lang/plsql/ast/RecordType.pls b/pmd-plsql/src/test/resources/net/sourceforge/pmd/lang/plsql/ast/RecordType.pls new file mode 100644 index 0000000000..c9d62a1226 --- /dev/null +++ b/pmd-plsql/src/test/resources/net/sourceforge/pmd/lang/plsql/ast/RecordType.pls @@ -0,0 +1,47 @@ +create or replace package body solt9001 is + + procedure upd is + + begin + + update solt90_web_service_log + set row = solt9001.rec + returning record_version into solt9001.rec.record_version; + + end upd; + +end; +/ + +create or replace package body solt9001 is + + procedure upd is + + begin + + update solt90_web_service_log + set row = solt9001.rec + returning record_version into solt9001.rec.record_version; + + end upd; + +end; +/ + +create or replace function test return varchar2 is + begin + + insert into sol_individual_commission_rate + values solt4601.rec + returning record_version, rowid into solt4601.rec.record_version, solt4601.current_rowid; + + return null; + end test; +/ + +begin + +select id_no into t4666.rec.agent_no from name where company_reg_no = '66666111'; + +end; +/ \ No newline at end of file