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

Allow subroutines to call others subroutines and themself recursively [CORE5380] #5653

Closed
firebird-automations opened this issue Oct 18, 2016 · 9 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Zoran Vučenović (zoran.vucenovic)

Sub-routines cannot use recursion.
For example this will not compile:

create or alter function factoriel(n int)
returns int
as
declare function subfactoriel(n int)
returns int
as
begin
if (n = 0) then
return 1;
else
return n * subfactoriel(n - 1); --this line cannot compile
end

begin
if (n < 0) then
return 0;
else
return subfactoriel(n);
end

As this subroutines' limitation is not mentioned in documentation (here: http://www.firebirdsql.org/file/documentation/release_notes/html/en/3_0/rnfb30-psql-subroutines.html ), I think it is a bug.

Commits: 4be766b

@firebird-automations
Copy link
Collaborator Author

Modified by: Zoran Vučenović (zoran.vucenovic)

description: Sub-routines cannot use recursion.
For example this will not compile:

create or alter function factoriel(n int)
returns int
as
declare function subfactoriel(n int)
returns int
as
begin
if (n = 0) then
return 1;
else
return n * subfactoriel(n - 1); --this line cannot compile
end

begin
if (n < 0) then
return 0;
else
return subfactoriel(n);
end

As this subroutines' limitation is not mentioned in documentation (here: http://www.firebirdsql.org/file/documentation/release_notes/html/en/3_0/rnfb30-psql-subroutines.html), I think it is a bug.

=>

Sub-routines cannot use recursion.
For example this will not compile:

create or alter function factoriel(n int)
returns int
as
declare function subfactoriel(n int)
returns int
as
begin
if (n = 0) then
return 1;
else
return n * subfactoriel(n - 1); --this line cannot compile
end

begin
if (n < 0) then
return 0;
else
return subfactoriel(n);
end

As this subroutines' limitation is not mentioned in documentation (here: http://www.firebirdsql.org/file/documentation/release_notes/html/en/3_0/rnfb30-psql-subroutines.html ), I think it is a bug.

@firebird-automations
Copy link
Collaborator Author

Modified by: Zoran Vučenović (zoran.vucenovic)

Component: Engine [ 10000 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @sim1984

This omission in the Release Noes. Subroutines restrictions described in the file
doc/sql.extensions/README.subroutines

Limitations:
1) Subroutines may not be nested in another subroutine. They are only supported in the main routine.
2) Currently, a subroutine may not directly access or use variables, cursors or another subroutines of the main statements. This may be allowed in the future.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

issuetype: Bug [ 1 ] => Improvement [ 4 ]

summary: Subroutine cannot call itself recursively => Allow subroutines to call others subroutines and itself recursively

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

summary: Allow subroutines to call others subroutines and itself recursively => Allow subroutines to call others subroutines and themself recursively

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

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

resolution: Fixed [ 1 ]

Fix Version: 4.0 Alpha 1 [ 10731 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

QA Status: No test => Done successfully

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

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

2 participants