Commit 1dad2a5e authored by Tomas Vondra's avatar Tomas Vondra

Fix order of parameters in BRIN minmax-multi calls

The BRIN minmax-multi consistent function incorrectly assumed it can
lookup an operator, and then swap the arguments to get the commutator.
For example <(a,b) would be called as <(b,a) to get >(a,b). This works
when the arguments are of the same type, but with cross-type opclasses
this fails. We can't swap <(float4,float8) arguments, for example.

Fixed by passing arguments in the right order.

Discussion: https://postgr.es/m/CAJKUy5jLZFLCxyxfT%3DMfK5mtPfSzHA1rVLowR-j4RRsFVvKm7A%40mail.gmail.com
parent e1fbe118
...@@ -2606,16 +2606,16 @@ brin_minmax_multi_consistent(PG_FUNCTION_ARGS) ...@@ -2606,16 +2606,16 @@ brin_minmax_multi_consistent(PG_FUNCTION_ARGS)
* value in the array. * value in the array.
*/ */
cmpFn = minmax_multi_get_strategy_procinfo(bdesc, attno, subtype, cmpFn = minmax_multi_get_strategy_procinfo(bdesc, attno, subtype,
BTLessStrategyNumber); BTGreaterStrategyNumber);
compar = FunctionCall2Coll(cmpFn, colloid, value, minval); compar = FunctionCall2Coll(cmpFn, colloid, minval, value);
/* smaller than the smallest value in this range */ /* smaller than the smallest value in this range */
if (DatumGetBool(compar)) if (DatumGetBool(compar))
break; break;
cmpFn = minmax_multi_get_strategy_procinfo(bdesc, attno, subtype, cmpFn = minmax_multi_get_strategy_procinfo(bdesc, attno, subtype,
BTGreaterStrategyNumber); BTLessStrategyNumber);
compar = FunctionCall2Coll(cmpFn, colloid, value, maxval); compar = FunctionCall2Coll(cmpFn, colloid, maxval, value);
/* larger than the largest value in this range */ /* larger than the largest value in this range */
if (DatumGetBool(compar)) if (DatumGetBool(compar))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment