aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_expr.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2025-04-06 14:43:51 +0200
committerPeter Eisentraut <peter@eisentraut.org>2025-04-06 14:43:51 +0200
commita8025f544854ad8b865c6b4509030ee84aa8f4a0 (patch)
tree845091557eeb98a01ef6ce7ca0e26315f67e8cfc /src/backend/parser/parse_expr.c
parent3a1a7c5a7071c75676c15b26e242c7df17560bd1 (diff)
downloadpostgresql-a8025f544854ad8b865c6b4509030ee84aa8f4a0.tar.gz
postgresql-a8025f544854ad8b865c6b4509030ee84aa8f4a0.zip
Relax ordering-related hardcoded btree requirements in planning
There were several places in ordering-related planning where a requirement for btree was hardcoded but an amcanorder index could suffice. This fixes that. We just need to do the necessary mapping between strategy numbers and compare types and adjust some related APIs so that this works independent of btree strategy numbers. For instance, non-btree amcanorder indexes can now be used to support sorting and merge joins. Also, predtest.c works independent of btree strategy numbers now. To avoid performance regressions, some details on btree and other built-in index types are still hardcoded as shortcuts, but other index types now have access to the same features by providing the required flags and callbacks. Author: Mark Dilger <mark.dilger@enterprisedb.com> Co-authored-by: Peter Eisentraut <peter@eisentraut.org> Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com
Diffstat (limited to 'src/backend/parser/parse_expr.c')
-rw-r--r--src/backend/parser/parse_expr.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index bc602f00ae3..1f8e2d54673 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -2832,7 +2832,7 @@ make_row_comparison_op(ParseState *pstate, List *opname,
ListCell *l,
*r;
List **opinfo_lists;
- Bitmapset *strats;
+ Bitmapset *cmptypes;
int nopers;
int i;
@@ -2897,45 +2897,45 @@ make_row_comparison_op(ParseState *pstate, List *opname,
/*
* Now we must determine which row comparison semantics (= <> < <= > >=)
- * apply to this set of operators. We look for btree opfamilies
- * containing the operators, and see which interpretations (strategy
- * numbers) exist for each operator.
+ * apply to this set of operators. We look for opfamilies containing the
+ * operators, and see which interpretations (cmptypes) exist for each
+ * operator.
*/
opinfo_lists = (List **) palloc(nopers * sizeof(List *));
- strats = NULL;
+ cmptypes = NULL;
i = 0;
foreach(l, opexprs)
{
Oid opno = ((OpExpr *) lfirst(l))->opno;
- Bitmapset *this_strats;
+ Bitmapset *this_cmptypes;
ListCell *j;
- opinfo_lists[i] = get_op_btree_interpretation(opno);
+ opinfo_lists[i] = get_op_index_interpretation(opno);
/*
- * convert strategy numbers into a Bitmapset to make the intersection
+ * convert comparison types into a Bitmapset to make the intersection
* calculation easy.
*/
- this_strats = NULL;
+ this_cmptypes = NULL;
foreach(j, opinfo_lists[i])
{
- OpBtreeInterpretation *opinfo = lfirst(j);
+ OpIndexInterpretation *opinfo = lfirst(j);
- this_strats = bms_add_member(this_strats, opinfo->strategy);
+ this_cmptypes = bms_add_member(this_cmptypes, opinfo->cmptype);
}
if (i == 0)
- strats = this_strats;
+ cmptypes = this_cmptypes;
else
- strats = bms_int_members(strats, this_strats);
+ cmptypes = bms_int_members(cmptypes, this_cmptypes);
i++;
}
/*
* If there are multiple common interpretations, we may use any one of
- * them ... this coding arbitrarily picks the lowest btree strategy
+ * them ... this coding arbitrarily picks the lowest comparison type
* number.
*/
- i = bms_next_member(strats, -1);
+ i = bms_next_member(cmptypes, -1);
if (i < 0)
{
/* No common interpretation, so fail */
@@ -2969,9 +2969,9 @@ make_row_comparison_op(ParseState *pstate, List *opname,
foreach(j, opinfo_lists[i])
{
- OpBtreeInterpretation *opinfo = lfirst(j);
+ OpIndexInterpretation *opinfo = lfirst(j);
- if (opinfo->strategy == cmptype)
+ if (opinfo->cmptype == cmptype)
{
opfamily = opinfo->opfamily_id;
break;