firebird icon indicating copy to clipboard operation
firebird copied to clipboard

inconsistent results with minvalue/maxvalue and date/timestamp arguments

Open tonne1 opened this issue 2 months ago • 0 comments

minvalue/maxvalue with date/timestamp arguments behave inconsistent in several ways:

  • re argument count
  • re argument sequence
  • different behaviour vs earlier versions when used in join condition

Tested with Firebird 5.0.3 1683, 5.0.1 and 4.0.4, SS, Win11

  1. Inconsistent behaviour depending on argument count and/or argument sequence:
-- ok
select maxvalue(current_date, current_timestamp, current_timestamp) from rdb$database

-- datatypes are not comparable
select maxvalue(current_date, current_date, current_timestamp) from rdb$database

-- ok
select maxvalue(current_timestamp, current_date, current_timestamp) from rdb$database

-- datatypes are not comparable
select maxvalue(current_date, current_timestamp) from rdb$database
  1. Changed behaviour vs former versions when used in join condition:
-- conversion error with 5.0.3 1683, but ok with version 4.0.4 und 5.0.1
select 1
from rdb$database a
join rdb$database b on maxvalue(current_date, current_timestamp, current_timestamp) >= current_date;

-- datatypes are not comparable
select 1
from rdb$database a
join rdb$database b on maxvalue(current_date, current_timestamp) >= current_date;

Similar results for localtimestamp instead of current_timestamp, and for minvalue:

-- ok
select minvalue('2025-10-14', cast('2025-10-14 03:00:00.000' as timestamp)) from rdb$database;

-- conversion error
select minvalue(cast('2025-10-14' as date), '2025-10-14 03:00:00.000') from rdb$database;
select minvalue(current_date, '2025-10-14 03:00:00.000') from rdb$database;

Part of this could have been caused by fixes for #8304, but the inconsistencies re argument count/sequence seem to be older.

tonne1 avatar Oct 22 '25 23:10 tonne1