Skip to content

Commit fb16b7e

Browse files
committed
Fix #4441: [plsql] XMLQuery - Support identifier as XQuery_string parameter (#5596)
Merge pull request #5596 from adangel:plsql/issue-4441-xmlquery
2 parents cdc2a51 + 6917d16 commit fb16b7e

File tree

13 files changed

+1505
-67
lines changed

13 files changed

+1505
-67
lines changed

docs/pages/release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ This is a {{ site.pmd.release_type }} release.
3737
* [#5079](https://github.com/pmd/pmd/issues/5079): \[java] LocalVariableCouldBeFinal false-positive with lombok.val
3838
* [#5452](https://github.com/pmd/pmd/issues/5452): \[java] PackageCase: Suppression comment has no effect due to finding at wrong position in case of JavaDoc comment
3939
* plsql
40+
* [#4441](https://github.com/pmd/pmd/issues/4441): \[plsql] Parsing exception with XMLQUERY function in SELECT
4041
* [#5521](https://github.com/pmd/pmd/issues/5521): \[plsql] Long parse time and eventually parse error with XMLAGG order by clause
4142

4243
### 🚨 API Changes

pmd-plsql/src/main/javacc/PLSQL.jjt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,7 @@ ASTOuterJoinExpression OuterJoinExpression() :
18191819
* XML Functions:
18201820
* https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/XMLROOT.html#GUID-5BD300E2-7138-436D-87AF-21658840CF9D
18211821
* https://docs.oracle.com/en/database/oracle/oracle-database/18/sqlrf/XMLFOREST.html#GUID-68E5C67E-CE97-4BF8-B7FF-2365E062C363
1822+
* https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/XMLQUERY.html#GUID-9E8D3220-2CF5-4C63-BDC2-0526D57B9CDB
18221823
*
18231824
* A function reference/name might be:
18241825
* function_name
@@ -1836,7 +1837,7 @@ ASTFunctionCall FunctionCall() :
18361837
(
18371838
LOOKAHEAD({"TRIM".equalsIgnoreCase(token.getImage()) && !jjtree.peekNode().getImage().contains(".")}) TrimExpression()
18381839
| LOOKAHEAD({"XMLCAST".equalsIgnoreCase(token.getImage())}) "(" Expression() <AS> Datatype() ")"
1839-
| LOOKAHEAD({"XMLQUERY".equalsIgnoreCase(token.getImage())}) "(" StringLiteral() [ LOOKAHEAD({isKeyword("PASSING")}) XMLPassingClause() ] <RETURNING> KEYWORD("CONTENT") [ <NULL> <ON> <EMPTY> ] ")"
1840+
| LOOKAHEAD({"XMLQUERY".equalsIgnoreCase(token.getImage())}) "(" ( StringLiteral() | ID() ) [ LOOKAHEAD({isKeyword("PASSING")}) XMLPassingClause() ] <RETURNING> KEYWORD("CONTENT") [ <NULL> <ON> <EMPTY> ] ")"
18401841
| LOOKAHEAD({"CAST".equalsIgnoreCase(token.getImage())}) "(" ( <MULTISET> "(" Subquery() ")" | Expression() ) <AS> Datatype() ")"
18411842
| LOOKAHEAD({"XMLFOREST".equalsIgnoreCase(token.getImage())}) "(" SqlExpression() [ [ <AS> ] ID() ] ( "," SqlExpression() [ [ <AS> ] ID() ] )* ")"
18421843
| LOOKAHEAD({"XMLELEMENT".equalsIgnoreCase(token.getImage())}) XMLElement()

pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/AllPlsqlAstTreeDumpTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
SelectIntoWithGroupByTest.class,
2020
WhereClauseTest.class,
2121
PLSQLParserTest.class,
22-
FunctionsTest.class
22+
FunctionsTest.class,
23+
XmlDbTreeDumpTest.class
2324
})
2425
class AllPlsqlAstTreeDumpTest {
2526

pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/FunctionsTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@ class FunctionsTest extends AbstractPLSQLParserTst {
1414
void parseSelectExtractExpression() {
1515
doTest("ExtractExpressions");
1616
}
17-
18-
@Test
19-
void parseXMLExpression() {
20-
doTest("XMLFunctions");
21-
}
2217
}

pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/XMLElementTest.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/XMLTableTest.java

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3+
*/
4+
5+
package net.sourceforge.pmd.lang.plsql.ast;
6+
7+
import org.junit.jupiter.api.Test;
8+
9+
import net.sourceforge.pmd.lang.plsql.PlsqlParsingHelper;
10+
import net.sourceforge.pmd.lang.test.ast.BaseParsingHelper;
11+
import net.sourceforge.pmd.lang.test.ast.BaseTreeDumpTest;
12+
import net.sourceforge.pmd.lang.test.ast.RelevantAttributePrinter;
13+
14+
class XmlDbTreeDumpTest extends BaseTreeDumpTest {
15+
XmlDbTreeDumpTest() {
16+
super(new RelevantAttributePrinter(), ".pls");
17+
}
18+
19+
@Override
20+
public BaseParsingHelper<?, ?> getParser() {
21+
return PlsqlParsingHelper.DEFAULT.withResourceContext(getClass());
22+
}
23+
24+
@Test
25+
void xmlElement() {
26+
doTest("XMLElement");
27+
}
28+
29+
@Test
30+
void xmlTable() {
31+
doTest("XMLTable");
32+
}
33+
34+
@Test
35+
void xmlFunctions() {
36+
doTest("XMLFunctions");
37+
}
38+
39+
/**
40+
* @see <a href="https://github.com/pmd/pmd/issues/4441">[plsql] Parsing exception with XMLTYPE and XMLQUERY function in SELECT</a>
41+
*/
42+
@Test
43+
void xmlQuery() {
44+
doTest("XMLQuery");
45+
}
46+
47+
@Test
48+
void xmlType() {
49+
doTest("XMLType");
50+
}
51+
}

0 commit comments

Comments
 (0)