Alvaro Herrera wrote:
> hubert depesz lubaczewski wrote:
> > > The minmax operator families don't include any cross-type operators. I'm
> > not exactly sure why not.. Alvaro?
> > > Anyway, try "select * from t where id = 1224::int8"
> >
> > It works that way, but it would be great to have it working with non-casted
> > values too.
>
> Yeah. I didn't put in much extra effort because some simple experiments
> worked with cross-type queries; my guess at the time was that the system
> added casts automatically for some cases and that was good enough. But
> there are several examples that don't work all that nicely, so I'm going
> to rework the opfamilies a bit. Stay tuned.
This patch reworks the opfamilies in pretty much the same way btree has
them: each type category has one opfamily, and there are opclasses for
each datatype; then there are enough pg_amop and pg_amproc entries to
cover all the cross-type operators and necessary support functions.
The collapsed types, and the resulting opfamilies, are:
int2, int4, int8 -> integer_minmax_ops
date, timestamp, timestamptz -> datetime_minmax_ops
float4, float8 -> float_minmax_ops
I'm not sure if there should be something involving numeric. Btree
doesn't appear to have it.
Btree also has a "network" opfamily which I initially guessed to contain
inet and cidr, but on looking closer it only has inet. And Brin doesn't
have cidr at all, so I left this alone.
I won't push this right away because I want to add the cross-type stuff
to the tests, to ensure I haven't bollixed anything; I ran a few quick
manual tests and everything seems to work. But if Depesz wants to test
the behavior, be my guest. Note that you need to initdb after
rebuilding with this patch.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services