Type inference of parameters

16 views
Skip to first unread message

Mark Rotteveel

unread,
Jun 8, 2025, 7:43:41 AMJun 8
to firebir...@googlegroups.com
Working on some improvements to the Firebird support in Hibernate, I
noticed an inconsistency in type inference of parameters:

For example, the following doesn't infer types:

select * from rdb$database where (? + 1) > ?;
select * from rdb$database where (? + 1) > (? * 1);
select * from rdb$database where (? + 1) > (? / 1);
select * from rdb$database where (? / 1) > (? * 1);
select * from rdb$database where (? * 1) > (? / 1);

Resulting in
-Data type unknown

or

-expression evaluation not supported
-Invalid data type for multiplication in dialect 3

or

-expression evaluation not supported
-Invalid data type for division in dialect 3

The following do work:

select * from rdb$database where (? + 1) > (? + 1); -- both BIGINT
select * from rdb$database where (? + 1) > (? - 1); -- both BIGINT
select * from rdb$database where (? * 1) > (? - 1); -- BIGINT, INT128
select * from rdb$database where (? / 1) > (? + 1); -- BIGINT, INT128

Why can't Firebird infer the datatypes in the first five cases? I would
argue that if (? + 1) > (? + 1) infers to BIGINT, then it can also infer
the second parameter in (? + 1) > ? to BIGINT, similarly if (? * 1) > (?
- 1) works, then so should (? - 1) / (? * 1) (and same for /).

Should I report this as a bug?

Mark
--
Mark Rotteveel

Reply all
Reply to author
Forward
0 new messages