-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: parse PL/SQL selection directives
PLSQL selection directives are of the form $IF boolean_static_expression $THEN text [ $ELSIF boolean_static_expression $THEN text ]... [ $ELSE text ] $END In addition, boolean_static_expression conditions like $$MY_CUSTOM_VAR > 3 can appear which confuses the current parser because it thinks $$ is the start of dollar-quoted string and drops the rest of the code. This patch keeps only the $IF branch and skips all the code between $ELSE or $ELSIF and $END. In addition, this patch also drops $ from all identifiers starting with $$ behind $IF and $ELSIF as these may be conditional variables and not dollar-quoted strings.
- Loading branch information
Showing
4 changed files
with
117 additions
and
7 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
Units/parser-sql.r/sql-plsql-selection-directive.d/args.ctags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--sort=no | ||
--extras=+q | ||
--kinds-SQL=+d |
7 changes: 7 additions & 0 deletions
7
Units/parser-sql.r/sql-plsql-selection-directive.d/expected.tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
demo_pkg input.sql /^create or replace package body demo_pkg is$/;" P | ||
demo_pkg.test_func1 input.sql /^function test_func1 return INTEGER$/;" f package:demo_pkg | ||
test_func1 input.sql /^function test_func1 return INTEGER$/;" f package:demo_pkg | ||
demo_pkg.test_func2 input.sql /^function test_func2 return INTEGER$/;" f package:demo_pkg | ||
test_func2 input.sql /^function test_func2 return INTEGER$/;" f package:demo_pkg | ||
demo_pkg.test_func5 input.sql /^function test_func5 return INTEGER$/;" f package:demo_pkg | ||
test_func5 input.sql /^function test_func5 return INTEGER$/;" f package:demo_pkg |
42 changes: 42 additions & 0 deletions
42
Units/parser-sql.r/sql-plsql-selection-directive.d/input.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
create or replace package body demo_pkg is | ||
|
||
function test_func1 return INTEGER | ||
as | ||
begin | ||
return 1; | ||
end; | ||
|
||
$IF $$MY_VERSION_CODE > 3 $THEN | ||
|
||
function test_func2 return INTEGER | ||
as | ||
begin | ||
return 3; | ||
end; | ||
|
||
$ELSIF $$MY_VERSION_CODE > 5 $THEN | ||
|
||
function test_func3 return INTEGER | ||
as | ||
begin | ||
return 5; | ||
end; | ||
|
||
$ELSE | ||
|
||
function test_func4 return INTEGER | ||
as | ||
begin | ||
return 7; | ||
end; | ||
|
||
$END | ||
|
||
function test_func5 return INTEGER | ||
as | ||
begin | ||
return 9; | ||
end; | ||
|
||
end demo_pkg; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters