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

Cannot compile source with "ELSE IF ( <expr> ) THEN" statement and commands to manupulate explicit cursor inside [CORE4929] #5220

Closed
firebird-automations opened this issue Sep 9, 2015 · 12 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

Test:

show version;

create or alter procedure sp_test1 as
begin
--- stub ---
end;

set term ^;
alter procedure sp_test1
as

declare v smallint;

declare c1 cursor for (
select 1 id from rdb$database
);

declare c2 cursor for (
select 2 id from rdb$database
);

begin

v = 1;

if \( v = 1 \) then open c1;
else 
    if \( :v = 2 \) then  
        open c2;

if \( v = 1 \) then close c1;
else 
    if \( :v = 2 \) then  
        close c2;

end
^
set term ;^
commit;

show procedure sp_test1;

drop procedure sp_test1;
commit;

Output:

1) in 2.5.5:
ISQL Version: WI-V2.5.5.26928 Firebird 2.5
Server version:
Firebird/x86/Windows NT (access method), version "WI-V2.5.5.26928 Firebird 2.5"
Firebird/x86/Windows NT (remote server), version "WI-V2.5.5.26928 Firebird 2.5/tcp (csprog)/P12"
Firebird/x86/Windows NT (remote interface), version "WI-V2.5.5.26928 Firebird 2.5/tcp (csprog)/P12"
on disk structure version 11.2
Procedure text:

declare v smallint;

declare c1 cursor for (
select 1 id from rdb$database
);

declare c2 cursor for (
select 2 id from rdb$database
);

begin

v = 1;

if \( v = 1 \) then open c1;
else
    if \( :v = 2 \) then \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \[ 1 \]
        open c2;

if \( v = 1 \) then close c1;
else
    if \( :v = 2 \) then \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \[ 2 \]
        close c2;

end

2) in WI-T3.0.0.30809 (release of 3.0 Alpha-2): the same as in 2.5.5, i.e. all fine

3) since WI-T3.0.0.31374 (release of 3.0 Beta-1) and up to current builds:

ISQL Version: WI-T3.0.0.31374 Firebird 3.0 Beta 1
Server version:
Firebird/Windows/Intel/i386 (access method), version "WI-T3.0.0.31374 Firebird 3.0 Beta 1"
Firebird/Windows/Intel/i386 (remote server), version "WI-T3.0.0.31374 Firebird 3.0 Beta 1/tcp (csprog)/P13"
Firebird/Windows/Intel/i386 (remote interface), version "WI-T3.0.0.31374 Firebird 3.0 Beta 1/tcp (csprog)/P13"
on disk structure version 12.0
Statement failed, SQLSTATE = 2F000
Error while parsing procedure SP_TEST1's BLR
-invalid request BLR at offset 208
-BLR syntax error: expected end_of_command at offset 209, encountered 255
After line 8 in file blr.2p.sql
Procedure text:

begin
--- stub ---
end

Problem is caused by "else if (expr)", see lines marked as [ 1] and [ 2 ]. If we remove or comment them, all works OK.

Commits: a8496bc 5b57c14 FirebirdSQL/fbt-repository@ea60bbc FirebirdSQL/fbt-repository@dbb48dd

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

summary: Can`t compile source which tries to manupulate with explicit cursor in " => Can`t compile source which "ELSE IF ( <expr> ) THEN" statement and commands to manupulating explicit cursor in it

description: Test:

show version;

create or alter procedure sp_test1 as
begin
--- stub ---
end;

set term ^;
alter procedure sp_test1
as

declare v smallint;

declare c1 cursor for (
select 1 id from rdb$database
);

declare c2 cursor for (
select 2 id from rdb$database
);

begin

v = 1;

if \( v = 1 \) then open c1;
else 
    if \( :v = 2 \) then  
        open c2;

if \( v = 1 \) then close c1;
else 
    if \( :v = 2 \) then  
        close c2;

end
^
set term ;^
commit;

show procedure sp_test1;

drop procedure sp_test1;
commit;

Output:

1) in 2.5.5:
ISQL Version: WI-V2.5.5.26928 Firebird 2.5
Server version:
Firebird/x86/Windows NT (access method), version "WI-V2.5.5.26928 Firebird 2.5"
Firebird/x86/Windows NT (remote server), version "WI-V2.5.5.26928 Firebird 2.5/tcp (csprog)/P12"
Firebird/x86/Windows NT (remote interface), version "WI-V2.5.5.26928 Firebird 2.5/tcp (csprog)/P12"
on disk structure version 11.2
Procedure text:

declare v smallint;

declare c1 cursor for (
select 1 id from rdb$database
);

declare c2 cursor for (
select 2 id from rdb$database
);

begin

v = 1;

if \( v = 1 \) then open c1;
else
    if \( :v = 2 \) then \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \[ 1 \]
        open c2;

if \( v = 1 \) then close c1;
else
    if \( :v = 2 \) then \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \[ 2 \]
        close c2;

end

2) in WI-T3.0.0.30809 (release of 3.0 Alpha-2): the same as in 2.5.5, i.e. all fine

3) since WI-T3.0.0.31374 (release of 3.0 Beta-1) and up to current builds:

ISQL Version: WI-T3.0.0.31374 Firebird 3.0 Beta 1
Server version:
Firebird/Windows/Intel/i386 (access method), version "WI-T3.0.0.31374 Firebird 3.0 Beta 1"
Firebird/Windows/Intel/i386 (remote server), version "WI-T3.0.0.31374 Firebird 3.0 Beta 1/tcp (csprog)/P13"
Firebird/Windows/Intel/i386 (remote interface), version "WI-T3.0.0.31374 Firebird 3.0 Beta 1/tcp (csprog)/P13"
on disk structure version 12.0
Statement failed, SQLSTATE = 2F000
Error while parsing procedure SP_TEST1's BLR
-invalid request BLR at offset 208
-BLR syntax error: expected end_of_command at offset 209, encountered 255
After line 8 in file blr.2p.sql
Procedure text:

begin
--- stub ---
end

Problem is caused by "else if (expr)", see lines marked as [ 1] and [ 2 ]. If we remove or comment them, all works OK.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

summary: Can`t compile source which "ELSE IF ( <expr> ) THEN" statement and commands to manupulating explicit cursor in it => Can`t compile source which has "ELSE IF ( <expr> ) THEN" statement and commands to manupulating explicit cursor in it

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

PS. Seems that the problem is more serious. Following sample does NOT contain neither 'else' nor 'else if', but it also fails starting from 3.0.0.31374:

show version;
create or alter procedure sp_test1 as
begin
--- stub ---
end;

set term ^;
alter procedure sp_test1
as

declare v smallint;

declare c1 cursor for (
select 1 id from rdb$database
);

begin

v = 1;

if \( v = 1 \) then open c1;
if \( v = 1 \) then close c1;

end
^
set term ;^
commit;

show procedure sp_test1;

drop procedure sp_test1;
commit;

Output is the same:

Server version:
Firebird/Windows/Intel/i386 (access method), version "WI-T3.0.0.31374 Firebird 3.0 Beta 1"
. . .
Statement failed, SQLSTATE = 2F000
Error while parsing procedure SP_TEST1's BLR
-invalid request BLR at offset 123
-BLR syntax error: expected end_of_command at offset 124, encountered 255
. . .

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

Finally I have:

1) fails:
if ( v = 1 ) then open c1;
if ( v = 1 ) then close c1;

2) works OK:
if ( v = 1 ) then open c1;
else open c2;
if ( v = 1 ) then close c1;
else close c2;

3) fails:
if ( v = 1 ) then open c1;
else if( v = 2 ) then open c2;
if ( v = 1 ) then close c1;
else if( v = 2 ) then close c2;

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

summary: Can`t compile source which has "ELSE IF ( <expr> ) THEN" statement and commands to manupulating explicit cursor in it => Cannot compile source with "ELSE IF ( <expr> ) THEN" statement and commands to manupulate explicit cursor inside

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Please test the new build.

@firebird-automations
Copy link
Collaborator Author

Commented by: @pavel-zotov

LI-V3.0.0.32030 -- works fine.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Open [ 1 ] => Open [ 1 ]

QA Status: No test => Done successfully

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Fix Version: 3.0 RC 1 [ 10584 ]

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