Skip to content

Commit 78aa006

Browse files
authored
[PlSql] Break out unary_logical_operation rule and allow not more than one unary_logical_operation per unary_logical_expression (#3811)
To simplify processing of multiple unary logical operations within a `unary_logical_expression`, as well as to avoid ambiguity of NOT tokens `within unary_logical_expression`. Previously "foo IS NULL IS NOT NAN" would be allowed.
1 parent 4388b62 commit 78aa006

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

sql/plsql/PlSqlParser.g4

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6083,7 +6083,11 @@ logical_expression
60836083
;
60846084

60856085
unary_logical_expression
6086-
: NOT? multiset_expression (IS NOT? logical_operation)*
6086+
: NOT? multiset_expression unary_logical_operation?
6087+
;
6088+
6089+
unary_logical_operation
6090+
: IS NOT? logical_operation
60876091
;
60886092

60896093
logical_operation:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
DECLARE
2+
FOO NUMBER := 1;
3+
BAR NUMBER := 2;
4+
BEGIN
5+
IF FOO = 1 AND BAR IS NOT NULL THEN
6+
RAISE_APPLICATION_ERROR(-20001, 'FOO is 1 and BAR is not null');
7+
END IF;
8+
9+
IF FOO = 1 OR NOT BAR IS NULL THEN
10+
RAISE_APPLICATION_ERROR(-20002, 'FOO is 1 or BAR is not null');
11+
END IF;
12+
13+
IF FOO = 1 AND BAR IS NOT NULL AND BAR IS NOT NAN THEN
14+
RAISE_APPLICATION_ERROR(-20003, 'FOO is 1 and BAR is not null and BAR is not nan');
15+
END IF;
16+
END;
17+
/

0 commit comments

Comments
 (0)