firebird icon indicating copy to clipboard operation
firebird copied to clipboard

Firebird allows a creation of UDF with BLOB SCALAR_ARRAY argument

Open dmitry-lipetsk opened this issue 2 years ago • 1 comments

Example of (incorrect) UDF:

DECLARE EXTERNAL FUNCTION UDF_DUMMY2_BSA__BLOB
BLOB BY SCALAR_ARRAY
RETURNS BLOB BY DESCRIPTOR
ENTRY_POINT 'IB_UDF_abs' MODULE_NAME 'ib_udf';

FB4 executes this query without any problems.

As I understand, Firebird and InterBase don't support array with blobs and this SQL should not be executed.

dmitry-lipetsk avatar Nov 25 '23 20:11 dmitry-lipetsk

A proposal for correct behavior:

SQL> DECLARE EXTERNAL FUNCTION UDF_DUMMY2_BSA__BLOB2 CON> BLOB BY SCALAR_ARRAY CON> RETURNS BLOB BY DESCRIPTOR CON> ENTRY_POINT 'IB_UDF_abs' MODULE_NAME 'ib_udf'; Statement failed, SQLSTATE = 42000 CREATE FUNCTION UDF_DUMMY2_BSA__BLOB2 failed -SQL error code = -607 -Invalid command -BY SCALAR_ARRAY can't be used with BLOB datatype SQL>

Also.

I offer to move the check of usage BY SCALAR_ARRAY with return parameter from CreateAlterFunctionNode::executeAlter (execute stage): https://github.com/FirebirdSQL/firebird/blob/255fc240991b45e8d36064225cc51076112f14f5/src/dsql/DdlNodes.epp#L1955-L1965

in CreateAlterFunctionNode::dsqlPass (prepare stage) https://github.com/FirebirdSQL/firebird/blob/255fc240991b45e8d36064225cc51076112f14f5/src/dsql/DdlNodes.epp#L1630

dmitry-lipetsk avatar Nov 26 '23 18:11 dmitry-lipetsk