aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2021-04-04 19:25:36 +0200
committerTomas Vondra <tomas.vondra@postgresql.org>2021-04-04 19:25:41 +0200
commit1dad2a5ea3d14dd205603c31cc94ec088183ab2a (patch)
treeaeffab551a97f91682a55f740bdc935cd74b5b2e /src
parente1fbe1181c86247eaf8b4b142b81361ce4efcc66 (diff)
downloadpostgresql-1dad2a5ea3d14dd205603c31cc94ec088183ab2a.tar.gz
postgresql-1dad2a5ea3d14dd205603c31cc94ec088183ab2a.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/brin/brin_minmax_multi.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/access/brin/brin_minmax_multi.c b/src/backend/access/brin/brin_minmax_multi.c
index 19ded7d933c..2f4e92695c7 100644
--- a/src/backend/access/brin/brin_minmax_multi.c
+++ b/src/backend/access/brin/brin_minmax_multi.c
@@ -2606,16 +2606,16 @@ brin_minmax_multi_consistent(PG_FUNCTION_ARGS)
* value in the array.
*/
cmpFn = minmax_multi_get_strategy_procinfo(bdesc, attno, subtype,
- BTLessStrategyNumber);
- compar = FunctionCall2Coll(cmpFn, colloid, value, minval);
+ BTGreaterStrategyNumber);
+ compar = FunctionCall2Coll(cmpFn, colloid, minval, value);
/* smaller than the smallest value in this range */
if (DatumGetBool(compar))
break;
cmpFn = minmax_multi_get_strategy_procinfo(bdesc, attno, subtype,
- BTGreaterStrategyNumber);
- compar = FunctionCall2Coll(cmpFn, colloid, value, maxval);
+ BTLessStrategyNumber);
+ compar = FunctionCall2Coll(cmpFn, colloid, maxval, value);
/* larger than the largest value in this range */
if (DatumGetBool(compar))