Improve upcasting for INT range and multi range types - Mailing list pgsql-hackers

From Federico
Subject Improve upcasting for INT range and multi range types
Date
Msg-id CAN19dyc8ey8_di+Lbsoh4et1d85Caaq2w4VTPcPNMYP-QVOsDg@mail.gmail.com
Whole thread Raw
Responses Re: Improve upcasting for INT range and multi range types
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Proposal to add page headers to SLRU pages
Next
From: Jeff Davis
Date:
Subject: Re: CREATE FUNCTION ... SEARCH { DEFAULT | SYSTEM | SESSION }