mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Fix make_restrictinfo_from_bitmapqual() to preserve AND/OR flatness of its
output, ie, no OR immediately below an OR. Otherwise we get Asserts or wrong answers for cases such as select * from tenk1 a, tenk1 b where (a.ten = b.ten and (a.unique1 = 100 or a.unique1 = 101)) or (a.hundred = b.hundred and a.unique1 = 42); Per report from Rafael Martinez Guerrero.
This commit is contained in:
parent
69ab90c775
commit
23c6f11b09
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.41.2.3 2005/11/22 18:23:12 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.41.2.4 2006/04/07 17:05:47 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -160,13 +160,44 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
|
|||||||
*/
|
*/
|
||||||
return NIL;
|
return NIL;
|
||||||
}
|
}
|
||||||
/* Create AND subclause with RestrictInfos */
|
/*
|
||||||
withris = lappend(withris,
|
* If the sublist contains multiple RestrictInfos, we create an
|
||||||
make_ands_explicit(sublist));
|
* AND subclause. If there's just one, we have to check if it's
|
||||||
/* And one without */
|
* an OR clause, and if so flatten it to preserve AND/OR flatness
|
||||||
|
* of our output.
|
||||||
|
*
|
||||||
|
* We construct lists with and without sub-RestrictInfos, so
|
||||||
|
* as not to have to regenerate duplicate RestrictInfos below.
|
||||||
|
*/
|
||||||
|
if (list_length(sublist) > 1)
|
||||||
|
{
|
||||||
|
withris = lappend(withris, make_andclause(sublist));
|
||||||
sublist = get_actual_clauses(sublist);
|
sublist = get_actual_clauses(sublist);
|
||||||
withoutris = lappend(withoutris,
|
withoutris = lappend(withoutris, make_andclause(sublist));
|
||||||
make_ands_explicit(sublist));
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RestrictInfo *subri = (RestrictInfo *) linitial(sublist);
|
||||||
|
|
||||||
|
Assert(IsA(subri, RestrictInfo));
|
||||||
|
if (restriction_is_or_clause(subri))
|
||||||
|
{
|
||||||
|
BoolExpr *subor = (BoolExpr *) subri->orclause;
|
||||||
|
|
||||||
|
Assert(or_clause((Node *) subor));
|
||||||
|
withris = list_concat(withris,
|
||||||
|
list_copy(subor->args));
|
||||||
|
subor = (BoolExpr *) subri->clause;
|
||||||
|
Assert(or_clause((Node *) subor));
|
||||||
|
withoutris = list_concat(withoutris,
|
||||||
|
list_copy(subor->args));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
withris = lappend(withris, subri);
|
||||||
|
withoutris = lappend(withoutris, subri->clause);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user