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

Commitccdcd19

Browse files
committed
make_restrictinfo() failed to attach the specified required_relids to
its result when the clause was an OR clause. Brain fade exposed byexample from Sebastian BÎck.
1 parent01798a0 commitccdcd19

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

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

Lines changed: 17 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.42 2005/11/14 23:54:22 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.43 2005/11/16 17:08:03 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -29,7 +29,8 @@ static RestrictInfo *make_restrictinfo_internal(Expr *clause,
2929
Relidsrequired_relids);
3030
staticExpr*make_sub_restrictinfos(Expr*clause,
3131
boolis_pushed_down,
32-
boolouterjoin_delayed);
32+
boolouterjoin_delayed,
33+
Relidsrequired_relids);
3334
staticRestrictInfo*join_clause_is_redundant(PlannerInfo*root,
3435
RestrictInfo*rinfo,
3536
List*reference_list,
@@ -62,7 +63,8 @@ make_restrictinfo(Expr *clause,
6263
if (or_clause((Node*)clause))
6364
return (RestrictInfo*)make_sub_restrictinfos(clause,
6465
is_pushed_down,
65-
outerjoin_delayed);
66+
outerjoin_delayed,
67+
required_relids);
6668

6769
/* Shouldn't be an AND clause, else AND/OR flattening messed up */
6870
Assert(!and_clause((Node*)clause));
@@ -312,10 +314,15 @@ make_restrictinfo_internal(Expr *clause, Expr *orclause,
312314
* This may seem odd but it is closely related to the fact that we use
313315
* implicit-AND lists at top level of RestrictInfo lists. Only ORs and
314316
* simple clauses are valid RestrictInfos.
317+
*
318+
* The given required_relids are attached to our top-level output,
319+
* but any OR-clause constituents are allowed to default to just the
320+
* contained rels.
315321
*/
316322
staticExpr*
317323
make_sub_restrictinfos(Expr*clause,
318-
boolis_pushed_down,boolouterjoin_delayed)
324+
boolis_pushed_down,boolouterjoin_delayed,
325+
Relidsrequired_relids)
319326
{
320327
if (or_clause((Node*)clause))
321328
{
@@ -326,12 +333,13 @@ make_sub_restrictinfos(Expr *clause,
326333
orlist=lappend(orlist,
327334
make_sub_restrictinfos(lfirst(temp),
328335
is_pushed_down,
329-
outerjoin_delayed));
336+
outerjoin_delayed,
337+
NULL));
330338
return (Expr*)make_restrictinfo_internal(clause,
331339
make_orclause(orlist),
332340
is_pushed_down,
333341
outerjoin_delayed,
334-
NULL);
342+
required_relids);
335343
}
336344
elseif (and_clause((Node*)clause))
337345
{
@@ -342,15 +350,16 @@ make_sub_restrictinfos(Expr *clause,
342350
andlist=lappend(andlist,
343351
make_sub_restrictinfos(lfirst(temp),
344352
is_pushed_down,
345-
outerjoin_delayed));
353+
outerjoin_delayed,
354+
required_relids));
346355
returnmake_andclause(andlist);
347356
}
348357
else
349358
return (Expr*)make_restrictinfo_internal(clause,
350359
NULL,
351360
is_pushed_down,
352361
outerjoin_delayed,
353-
NULL);
362+
required_relids);
354363
}
355364

356365
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp