Issue Details (XML | Word | Printable)

Key: CORE-4280
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Dmitry Yemanov
Reporter: Robert
Votes: 0
Watchers: 2

If you were logged in you would be able to see more operations.
Firebird Core

FB3: Stored function accepts duplicate input arguments

Created: 25/Nov/13 11:42 PM   Updated: 29/May/15 03:58 PM
Component/s: Engine
Affects Version/s: 3.0 Alpha 1
Fix Version/s: 3.0 Beta 2

Environment: Windows

QA Status: Done successfully

 Description  « Hide
(WI-T3.0.0.30566 Firebird 3.0 Alpha 1)

CREATE FUNCTION seems to accept input arguments with the same name, like:
CREATE FUNCTION Test (X INTEGER, X INTEGER) /* argument X appears twice */
  RETURN X + 1;
I think this should not be allowed, like it is also not allowed for parameters of stored procedures (or any other programming language I know).
I suggest to define a unique key on rdb$function_arguments for (rdb$function_name, rdb$argument_name); note rdb$argument_name is NULL for the return argument, but afaik this is okay for unique keys.

BTW, as far as I could test, no real harm is done by the existence of duplicate arguments; references in the body seem to use the first occurence (so, in the example above, Test(1, 5) will return 2; executing COMMENT ON FUNCTION PARAMETER Test.X IS 'Tests', will assign a comment to both occurences of Test.X in rdb$function_arguments.

- Robert

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Adriano dos Santos Fernandes added a comment - 26/Nov/13 03:00 PM
A solution with unique index, like is done for procedures, is not easy on this situation.

Parameters of legacy UDFs may be unnamed.

If we could write a system expression index, it would be solvable, but we neither can do it currently.

So I believe a programatic approach would be necessary here.