Declaration of package constants as expressions

25 views
Skip to first unread message

Pavel Zotov

unread,
May 26, 2026, 8:14:35 AM (16 hours ago) May 26
to firebird-devel
i have question(s) about proper usage of some functions that are mentioned in the doc/sql.extensions/README.packages.txt:

The following expressions are valid only if all operands are constants:
...
      6)  ... IIF ...

So, i run:
set bail on;
set autoterm on;
set list on;
set names utf8;
set echo on;
shell if exist r:\temp\tmp4test.fdb del r:\temp\tmp4test.fdb;
create database 'localhost:r:\temp\tmp4test.fdb' user sysdba password 'masterkey';

create or alter function standalone_abs returns smallint
as
    declare foo smallint = iif(3 > 2, 1, 0);
begin
    return 1;
end
;
create or alter package pg_const as
begin
    constant bar smallint = iif(3 > 2, 1, 0);
end
;

-- and get:
Statement failed, SQLSTATE = 42000
CREATE OR ALTER PACKAGE "PUBLIC"."PG_CONST" failed
-The constant "PUBLIC"."PG_CONST"."BAR" must be initialized by a constant expression

Is it expected ?

Pavel Zotov

unread,
May 26, 2026, 8:30:20 AM (16 hours ago) May 26
to firebird-devel

PS. And also:

create or alter package pg_const as
begin
    constant k_nullif smallint = nullif(2,1);
end
;

Statement failed, SQLSTATE = 42000
CREATE OR ALTER PACKAGE "PUBLIC"."PG_CONST" failed
-The constant "PUBLIC"."PG_CONST"."K_NULLIF" must be initialized by a constant expression


вторник, 26 мая 2026 г. в 15:14:35 UTC+3, Pavel Zotov:

Artyom Abakumov

unread,
May 26, 2026, 10:03:10 AM (14 hours ago) May 26
to firebird-devel
It was a bug. Fixed in the PR: https://github.com/FirebirdSQL/firebird/pull/9039

вторник, 26 мая 2026 г. в 15:30:20 UTC+3, Pavel Zotov:
Reply all
Reply to author
Forward
0 new messages