diff --git a/pmd-plsql/etc/grammar/PldocAST.jjt b/pmd-plsql/etc/grammar/PldocAST.jjt index b48397094e..5e030fc847 100644 --- a/pmd-plsql/etc/grammar/PldocAST.jjt +++ b/pmd-plsql/etc/grammar/PldocAST.jjt @@ -25,6 +25,14 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + +/** + * Adjusted ProgramUnit() to allow Pragma(), even though this is not + * valid syntax. See PMD Bug #1527. + * + * Andreas Dangel 11/2016 + */ + // options { DEBUG_PARSER = false ; @@ -483,7 +491,9 @@ ASTProgramUnit ProgramUnit() : | ( DeclarativeSection() - (Statement())* (ExceptionHandler())? [ID()] + + [Pragma()] // See PMD Bug #1527 + (Statement())* (ExceptionHandler())? [ID()] ) ) ] diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLParserTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLParserTest.java index 07120bfee9..dc11365fb6 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLParserTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/PLSQLParserTest.java @@ -3,6 +3,7 @@ */ package net.sourceforge.pmd.lang.plsql; +import org.apache.commons.io.IOUtils; import org.junit.Test; @@ -44,4 +45,9 @@ public class PLSQLParserTest extends AbstractPLSQLParserTst { "select \"CFT_ID\",\"CFR_ID\",\"CFT_NAME\",\"TCN\",\"LOG_MODULE\",\"LOG_USER\",\"LOG_DATE\",\"LOG_TIME\" from crm_function_role_types\n" + "/"); } + + @Test + public void testBug1527() throws Exception { + parsePLSQL(IOUtils.toString(PLSQLParserTest.class.getResourceAsStream("ast/InlinePragmaProcError.pls"))); + } } diff --git a/pmd-plsql/src/test/resources/net/sourceforge/pmd/lang/plsql/ast/InlinePragmaProcError.pls b/pmd-plsql/src/test/resources/net/sourceforge/pmd/lang/plsql/ast/InlinePragmaProcError.pls new file mode 100644 index 0000000000..a362cfe50c --- /dev/null +++ b/pmd-plsql/src/test/resources/net/sourceforge/pmd/lang/plsql/ast/InlinePragmaProcError.pls @@ -0,0 +1,17 @@ +create or replace package inline_praqma_error is + +end; +/ + +create or replace package body inline_praqma_error is + procedure do_transaction(p_input_token in varchar(200)) is + + begin + PRAGMA AUTONOMOUS_TRANSACTION; + bno74.log_hentglass_request(p_hentglass_request + ,v_logging_req_seq_no); + COMMIT; + end do_transaction; + +end inline_praqma_error; +/ diff --git a/src/site/markdown/overview/changelog.md b/src/site/markdown/overview/changelog.md index 0178f3740f..6502afc7ca 100644 --- a/src/site/markdown/overview/changelog.md +++ b/src/site/markdown/overview/changelog.md @@ -37,6 +37,7 @@ * java-typeresolution/SignatureDeclareThrowsException * [#1535](https://sourceforge.net/p/pmd/bugs/1535/): \[java] SignatureDeclareThrowsException: ClassCastException with Annotation * PLSQL + * [#1527](https://sourceforge.net/p/pmd/bugs/1527/): \[plsql] PRAGMA AUTONOMOUS_TRANSACTION gives processing errors * [#1531](https://sourceforge.net/p/pmd/bugs/1531/): \[plsql] OOM/Endless loop while parsing (PL)SQL * General * [#1499](https://sourceforge.net/p/pmd/bugs/1499/): \[core] CPD test break PMD 5.5.1 build on Windows