Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Procedure parsing error in SAP HANA #2733

Closed
stesix opened this issue Mar 19, 2020 · 2 comments
Closed

Procedure parsing error in SAP HANA #2733

stesix opened this issue Mar 19, 2020 · 2 comments

Comments

@stesix
Copy link

stesix commented Mar 19, 2020

Which version and edition of Flyway are you using?

6.3.1 ce

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

command-line

Which database are you using (type & version)?

SAP HANA 2.0

What did you do?

sql file with a stored procedure inside. If the stored procedure happens to have a select with a CASE keyword and the next instruction is an IF the depth is not increased.

e.g.

create or replace procedure anothertest()
LANGUAGE SQLSCRIPT
AS
v_test varchar(33);
cursor mytable for
	select 'monkey test' mycolumn
	from dummy;
begin
    for cur_row as mytable() do
    	v_test := 'is mytest a "monkey test"? ' || 
    		case 
    			when cur_row.mycolumn = 'monkey test' then 'yes'
    			else 'no'
    		end;

		if cur_row.mycolumn is not null then
			-- whoops this IF is not considered correctly in the code
			v_test := v_test || '!!!';
		end if;
		-- the parser stops here processing, creating an invalid procedure.
	end for;
end;

The issue is in flyway-core/src/main/java/org/flywaydb/core/internal/database/saphana/SAPHANAParser.java.

BTW this proposed example can be used only after fixing #2724 .

@stesix
Copy link
Author

stesix commented Mar 20, 2020

here's another example that works without fixing the #2724

create or replace procedure another_example(in p_in integer, out o_result integer)
LANGUAGE SQLSCRIPT
AS
begin
    DECLARE EXIT HANDLER FOR SQLEXCEPTION
    BEGIN
        o_result := 0;
    END;

    if p_in = 5 then
        o_result := 2
    end if;

    -- other code that might result in a SQLEXCEPTION
end;

As soon as the parser reaches the IF right after of the HANDLER declaration, the depth won't be increased correctly since the previous keyword was END.

@juliahayward
Copy link
Contributor

Will be fixed by the 6.3.2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants