*** pgsql/src/backend/optimizer/util/relnode.c 2009/10/12 18:10:48 1.95 --- pgsql/src/backend/optimizer/util/relnode.c 2009/11/28 00:46:19 1.96 *************** *** 8,14 **** * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.94 2009/06/11 14:48:59 momjian Exp $ * *------------------------------------------------------------------------- */ --- 8,14 ---- * * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.95 2009/10/12 18:10:48 tgl Exp $ * *------------------------------------------------------------------------- */ *************** build_join_rel(PlannerInfo *root, *** 402,407 **** --- 402,421 ---- hentry->join_rel = joinrel; } + /* + * Also, if dynamic-programming join search is active, add the new joinrel + * to the appropriate sublist. Note: you might think the Assert on + * number of members should be for equality, but some of the level 1 + * rels might have been joinrels already, so we can only assert <=. + */ + if (root->join_rel_level) + { + Assert(root->join_cur_level > 0); + Assert(root->join_cur_level <= bms_num_members(joinrel->relids)); + root->join_rel_level[root->join_cur_level] = + lappend(root->join_rel_level[root->join_cur_level], joinrel); + } + return joinrel; }