Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f8a7bf

Browse files
committed
Fix make_restrictinfo_from_bitmapqual() to preserve AND/OR flatness of its
output, ie, no OR immediately below an OR. Otherwise we get Asserts orwrong answers for cases such asselect * from tenk1 a, tenk1 bwhere (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.
1 parent0914ae1 commit2f8a7bf

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

‎src/backend/optimizer/util/restrictinfo.c

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.46 2006/03/05 15:58:32 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.47 2006/04/07 17:05:39 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -160,13 +160,44 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
160160
*/
161161
returnNIL;
162162
}
163-
/* Create AND subclause with RestrictInfos */
164-
withris=lappend(withris,
165-
make_ands_explicit(sublist));
166-
/* And one without */
167-
sublist=get_actual_clauses(sublist);
168-
withoutris=lappend(withoutris,
169-
make_ands_explicit(sublist));
163+
/*
164+
* If the sublist contains multiple RestrictInfos, we create an
165+
* AND subclause. If there's just one, we have to check if it's
166+
* an OR clause, and if so flatten it to preserve AND/OR flatness
167+
* of our output.
168+
*
169+
* We construct lists with and without sub-RestrictInfos, so
170+
* as not to have to regenerate duplicate RestrictInfos below.
171+
*/
172+
if (list_length(sublist)>1)
173+
{
174+
withris=lappend(withris,make_andclause(sublist));
175+
sublist=get_actual_clauses(sublist);
176+
withoutris=lappend(withoutris,make_andclause(sublist));
177+
}
178+
else
179+
{
180+
RestrictInfo*subri= (RestrictInfo*)linitial(sublist);
181+
182+
Assert(IsA(subri,RestrictInfo));
183+
if (restriction_is_or_clause(subri))
184+
{
185+
BoolExpr*subor= (BoolExpr*)subri->orclause;
186+
187+
Assert(or_clause((Node*)subor));
188+
withris=list_concat(withris,
189+
list_copy(subor->args));
190+
subor= (BoolExpr*)subri->clause;
191+
Assert(or_clause((Node*)subor));
192+
withoutris=list_concat(withoutris,
193+
list_copy(subor->args));
194+
}
195+
else
196+
{
197+
withris=lappend(withris,subri);
198+
withoutris=lappend(withoutris,subri->clause);
199+
}
200+
}
170201
}
171202

172203
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp