Hi,

Postgresql seems to be missing upcasting when doing INT range and
multi-range operation, for example when checking if an int4 is inside
an int8 range.
Some non working example are the following

    SELECT 2::INT4 <@ '[1, 4)'::INT8RANGE
    -- ERROR: operator does not exist: integer <@ int8range

    SELECT 1::INT4 <@ '{[1, 4),[6,19)}'::INT8MULTIRANGE
    -- ERROR: operator does not exist: integer <@ int8multirange

    SELECT 1::INT2 <@ '{[1, 4),[6,19)}'::INT4MULTIRANGE
    -- ERROR: operator does not exist: smallint <@ int4multirange

    SELECT '[2, 3]'::INT4RANGE <@ '[1, 42)'::INT8RANGE
    -- ERROR: operator does not exist: int4range <@ int8range

    SELECT 2::INT8 <@ '[1, 4)'::INT4RANGE
    -- ERROR: operator does not exist: bigint <@ int4range

etc.

In all these cases the smaller integer type can be upcasted to the
larger integer type.

Posted here since it doesn't seem like a bug, just a missing feature.

Thanks for reading
    Federico


Reply via email to