1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-19 04:21:08 +03:00

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.
This commit is contained in:
Tom Lane
2011-07-06 14:53:16 -04:00
parent c7f23494c1
commit 14f67192c2
4 changed files with 147 additions and 183 deletions

View File

@ -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;
}
}