diff --git a/pmd-plsql/etc/grammar/PldocAST.jjt b/pmd-plsql/etc/grammar/PldocAST.jjt index 6f3477722a..768f4e7a12 100644 --- a/pmd-plsql/etc/grammar/PldocAST.jjt +++ b/pmd-plsql/etc/grammar/PldocAST.jjt @@ -1885,6 +1885,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; @@ -2325,7 +2326,7 @@ ASTValuesClause ValuesClause() : ( "(" ( Expression() | <_DEFAULT> ) ( "," ( Expression() | <_DEFAULT> ) )* ")" | - ID() // that's a record variable name + Name() // that's a record variable name ) { return jjtThis; } } @@ -2409,7 +2410,7 @@ ASTUpdateSetClause UpdateSetClause() : { ( - LOOKAHEAD(1) "=" ID() + LOOKAHEAD(1) "=" Name() | "VALUE" "(" TableAlias() ")" "=" ( LOOKAHEAD(1) "(" Subquery() ")" | Expression() ) | @@ -2431,7 +2432,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