From 1f36feceb0842f0e69054a49ca04b432be626085 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 6 May 2009 20:31:18 +0000 Subject: [PATCH] Tweak distribute_qual_to_rels so that when we decide a pseudoconstant qual can be pushed to the top of the join tree, we update both the relids and qualscope variables to keep them in sync. This prevents a possible later failure of an Assert clause, and affects nothing else since qualscope isn't used later except for that Assert. At the moment the Assert shouldn't be reachable when we've pushed the qual up; but this is cheap insurance, and it's more sensible anyway in terms of the overall logic of the routine. Per analysis of a bug report from Stefan Huehner. I'm not back-patching this since it's just future-proofing; but if anyone gets tempted to change check_outerjoin_delay again in the back branches, this might be needed. --- src/backend/optimizer/plan/initsplan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index dd73beb759..b31ffa81cc 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.151 2009/04/19 19:46:33 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/plan/initsplan.c,v 1.152 2009/05/06 20:31:18 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -818,9 +818,12 @@ distribute_qual_to_rels(PlannerInfo *root, Node *clause, root->hasPseudoConstantQuals = true; /* if not below outer join, push it to top of tree */ if (!below_outer_join) + { relids = get_relids_in_jointree((Node *) root->parse->jointree, false); + qualscope = bms_copy(relids); + } } } }