Added correct parse of IS [NOT] NULL
fixed crash of parsing following code (from unittest): IF V_BUF IS NULL THEN null; end if;
This commit is contained in:

committed by
Juan Martín Sotuyo Dodero

parent
051f50e932
commit
90862cc993
@ -38,6 +38,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* Andreas Dangel 11/2016
|
||||
*/
|
||||
|
||||
/**
|
||||
* Added ASTIsNullCondition node
|
||||
*
|
||||
* Sergey Yanzin 11/2016
|
||||
*/
|
||||
|
||||
//
|
||||
options {
|
||||
DEBUG_PARSER = false ;
|
||||
@ -1972,12 +1978,33 @@ ASTUnaryExpressionNotPlusMinus UnaryExpressionNotPlusMinus() :
|
||||
(<NOT>) {sb.append(" NOT "); }
|
||||
(simpleNode = UnaryExpression(false) ) { sb.append(simpleNode.getImage()); }
|
||||
|
|
||||
(simpleNode = IsOfTypeCondition() ) {sb.append(simpleNode.getImage()); }
|
||||
(simpleNode = IsNullCondition() ) {sb.append(simpleNode.getImage()); }
|
||||
)
|
||||
{
|
||||
jjtThis.setImage(sb.toString()); return jjtThis;
|
||||
}
|
||||
}
|
||||
ASTIsNullCondition IsNullCondition() : //yanzin
|
||||
{ PLSQLNode simpleNode = null; PLSQLNode name = null; StringBuilder sb = new StringBuilder(); }
|
||||
{
|
||||
(
|
||||
LOOKAHEAD(<IDENTIFIER> <IS> (<NOT> <NULL>|<NULL>))
|
||||
(
|
||||
(name = Name()) {sb.append(name.getImage());} <IS> {sb.append(" IS");} [<NOT> {sb.append(" NOT");}] <NULL> {sb.append(" NULL");}
|
||||
)
|
||||
|
|
||||
(
|
||||
simpleNode = IsOfTypeCondition()
|
||||
)
|
||||
{
|
||||
sb.append(simpleNode.getImage());
|
||||
}
|
||||
)
|
||||
{
|
||||
jjtThis.setImage(sb.toString());
|
||||
return jjtThis;
|
||||
}
|
||||
}
|
||||
|
||||
ASTIsOfTypeCondition IsOfTypeCondition() :
|
||||
{ PLSQLNode simpleNode = null; PLSQLNode name = null; StringBuilder sb = new StringBuilder(); }
|
||||
|
@ -789,6 +789,11 @@ public abstract class AbstractPLSQLRule extends AbstractRule implements PLSQLPar
|
||||
return visit((PLSQLNode) node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTIsNullCondition node, Object data) {
|
||||
return visit((PLSQLNode) node, data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Treat all Executable Code
|
||||
*/
|
||||
|
@ -60,4 +60,9 @@ public class PLSQLParserTest extends AbstractPLSQLParserTst {
|
||||
public void testBug1520Using() throws Exception {
|
||||
parsePLSQL(IOUtils.toString(PLSQLParserTest.class.getResourceAsStream("ast/Using.pls")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsNull() throws Exception {
|
||||
parsePLSQL(IOUtils.toString(PLSQLParserTest.class.getResourceAsStream("ast/IsNull.pls")));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
PROCEDURE IsNull (
|
||||
dummy IN number
|
||||
)
|
||||
is
|
||||
V_BUF varchar(1);
|
||||
BEGIN
|
||||
|
||||
IF V_BUF IS NULL THEN
|
||||
null;
|
||||
end if;
|
||||
|
||||
IF V_BUF IS NOT NULL THEN
|
||||
null;
|
||||
end if;
|
||||
|
||||
end;
|
Reference in New Issue
Block a user