firebird icon indicating copy to clipboard operation
firebird copied to clipboard

[UDF] Server must prevent "return BY VALUE" for data types ISC_TIMESTAMP_TZ, ISC_TIME_TZ and so on

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

Firebird prohibits the creation of UDF with "return BY VALUE" for data types ISC_TIMESTAMP, ISC_QUAD based on structs but allows it for:

  • FB_I128_t
  • FB_DEC34_t
  • FB_DEC16_t
  • ISC_TIMESTAMP_TZ
  • ISC_TIME_TZ

dmitry-lipetsk avatar Nov 28 '23 07:11 dmitry-lipetsk

Is it an standard C ABI feature (per platform - using different compilers) return of structs by value?

asfernandes avatar Nov 28 '23 09:11 asfernandes

Is it an standard C ABI feature (per platform - using different compilers) return of structs by value?

I don't know.

dmitry-lipetsk avatar Nov 28 '23 10:11 dmitry-lipetsk

I tested FB4 with the following UDF:

DECLARE EXTERNAL FUNCTION IBP_UDF__COPY_TS_WITH_TZ
TIMESTAMP WITH TIME ZONE
RETURNS TIMESTAMP WITH TIME ZONE BY VALUE
ENTRY_POINT 'fn_copy_ts_with_tz'
MODULE_NAME 'lcpi.ibp.test.udf.01.dll';

select IBP_UDF__COPY_TS_WITH_TZ(CURRENT_TIMESTAMP) from rdb$database where 1=1

Server goes here:

https://github.com/FirebirdSQL/firebird/blob/e96217a9ca92fb30b8ab4fce6c80d625c7224208/src/jrd/fun.epp#L714-L717

and after that it returns this error:

return data type not supported; UDF: IBP_UDF__COPY_TS_WITH_TZ [SQLState:HY000, ISC error code:335544382]

dmitry-lipetsk avatar Dec 01 '23 17:12 dmitry-lipetsk