From cb1cc305bc349338f75a549c36041b4c91cf779f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 6 Jul 2011 14:53:16 -0400 Subject: Remove assumptions that not-equals operators cannot be in any opclass. get_op_btree_interpretation assumed this in order to save some duplication of code, but it's not true in general anymore because we added <> support to btree_gist. (We still assume it for btree opclasses, though.) Also, essentially the same logic was baked into predtest.c. Get rid of that duplication by generalizing get_op_btree_interpretation so that it can be used by predtest.c. Per bug report from Denis de Bernardy and investigation by Jeff Davis, though I didn't use Jeff's patch exactly as-is. Back-patch to 9.1; we do not support this usage before that. --- src/backend/parser/parse_expr.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/backend/parser/parse_expr.c') diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 08f0439e7ed..65d03adc494 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -2170,8 +2170,7 @@ make_row_comparison_op(ParseState *pstate, List *opname, List *opfamilies; ListCell *l, *r; - List **opfamily_lists; - List **opstrat_lists; + List **opinfo_lists; Bitmapset *strats; int nopers; int i; @@ -2241,8 +2240,7 @@ make_row_comparison_op(ParseState *pstate, List *opname, * containing the operators, and see which interpretations (strategy * numbers) exist for each operator. */ - opfamily_lists = (List **) palloc(nopers * sizeof(List *)); - opstrat_lists = (List **) palloc(nopers * sizeof(List *)); + opinfo_lists = (List **) palloc(nopers * sizeof(List *)); strats = NULL; i = 0; foreach(l, opexprs) @@ -2251,17 +2249,18 @@ make_row_comparison_op(ParseState *pstate, List *opname, Bitmapset *this_strats; ListCell *j; - get_op_btree_interpretation(opno, - &opfamily_lists[i], &opstrat_lists[i]); + opinfo_lists[i] = get_op_btree_interpretation(opno); /* - * convert strategy number list to a Bitmapset to make the + * convert strategy numbers into a Bitmapset to make the * intersection calculation easy. */ this_strats = NULL; - foreach(j, opstrat_lists[i]) + foreach(j, opinfo_lists[i]) { - this_strats = bms_add_member(this_strats, lfirst_int(j)); + OpBtreeInterpretation *opinfo = lfirst(j); + + this_strats = bms_add_member(this_strats, opinfo->strategy); } if (i == 0) strats = this_strats; @@ -2309,14 +2308,15 @@ make_row_comparison_op(ParseState *pstate, List *opname, for (i = 0; i < nopers; i++) { Oid opfamily = InvalidOid; + ListCell *j; - forboth(l, opfamily_lists[i], r, opstrat_lists[i]) + foreach(j, opinfo_lists[i]) { - int opstrat = lfirst_int(r); + OpBtreeInterpretation *opinfo = lfirst(j); - if (opstrat == rctype) + if (opinfo->strategy == rctype) { - opfamily = lfirst_oid(l); + opfamily = opinfo->opfamily_id; break; } } -- cgit v1.2.3