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-issue-importer opened this issue Oct 18, 2016 · 9 comments

Comments

@firebird-issue-importer

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-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 18, 2016

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-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 18, 2016

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

Component: Engine [ 10000 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Oct 18, 2016

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-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jan 3, 2017

Modified by: @asfernandes

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 11, 2017

Modified by: @asfernandes

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

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

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 11, 2017

Modified by: @asfernandes

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

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 11, 2017

Modified by: @asfernandes

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

resolution: Fixed [ 1 ]

Fix Version: 4.0 Alpha 1 [ 10731 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 14, 2017

Modified by: @pavel-zotov

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

QA Status: No test => Done successfully

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jul 14, 2017

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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants