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

"Input parameter mismatch" error after altering external function into PSQL function [CORE5776] #6039

Closed
firebird-issue-importer opened this issue Mar 15, 2018 · 4 comments

Comments

@firebird-issue-importer

Submitted by: @hvlad

Firebird 3 introduced PSQL FUNCTION's and now it is recommended to convert UDF's into PSQL functions when possible.
ALTER FUNCTION statement could convert UDF into PSQL functions but sometime PSQL function become unusable after
such conversion. Example:

a) declare UDF

declare external function sright
varchar(100) by descriptor, smallint,
varchar(100) by descriptor returns parameter 3
entry_point 'right' module_name 'fbudf';

b) make sure it works

select sright('function', 2) from rdb$database;

SRIGHT

on

c) convert UDF into PSQL function

commit;
set term ^;
alter function sright (str varchar(100), len int)
returns varchar(100)
as
begin
return right(str, len);
end^
set term ;^

d) check if it works

select sright('function', 2) from rdb$database;

Statement failed, SQLSTATE = 07001
Dynamic SQL Error
-Input parameter mismatch for function SRIGHT

The problem is that ALTER FUNCTION didn't changed RDB$FUNCTIONS.RDB$RETURN_ARGUMENT value :

a) original UDF

select rdb$return_argument from rdb$functions
where rdb$function_name = 'SRIGHT';

RDB$RETURN_ARGUMENT

              3

select rdb$argument_position, rdb$argument_name from rdb$function_arguments
where rdb$function_name = 'SRIGHT';

RDB$ARGUMENT_POSITION RDB$ARGUMENT_NAME
===================== ===============================
1 <null>
2 <null>
3 <null>

b) after ALTER FUNCTION

select rdb$return_argument from rdb$functions
where rdb$function_name = 'SRIGHT';

RDB$RETURN_ARGUMENT

              3

select rdb$argument_position, rdb$argument_name from rdb$function_arguments
where rdb$function_name = 'SRIGHT';

RDB$ARGUMENT_POSITION RDB$ARGUMENT_NAME
===================== ===============================
0 <null>
1 STR
2 LEN

Commits: cc2b19e f6e93ff

====== Test Details ======

2do: check result of fb_run when issue related "GetThreadId could not be located in the dynamic link library KERNEL32.dll" will be fixed on Win XP (see letter to dimitr, hvlad 18.03.2018)

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Mar 15, 2018

Modified by: @hvlad

assignee: Vlad Khorsun [ hvlad ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Mar 15, 2018

Modified by: @hvlad

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

resolution: Fixed [ 1 ]

Fix Version: 4.0 Beta 1 [ 10750 ]

Fix Version: 3.0.4 [ 10863 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Mar 18, 2018

Modified by: @pavel-zotov

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

QA Status: No test => Done with caveats

Test Details: 2do: check result of fb_run when issue related "GetThreadId could not be located in the dynamic link library KERNEL32.dll" will be fixed on Win XP (see letter to dimitr, hvlad 18.03.2018)

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Mar 18, 2018

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