@@ -176,7 +176,6 @@ restore_selectivities(List *clauselist, List *relidslist, JoinType join_type,
176176int nargs ;
177177int * args_hash ;
178178int * eclass_hash ;
179- double * cur_sel ;
180179int cur_hash ;
181180int cur_relid ;
182181
@@ -191,30 +190,29 @@ restore_selectivities(List *clauselist, List *relidslist, JoinType join_type,
191190foreach (l ,clauselist )
192191{
193192RestrictInfo * rinfo = (RestrictInfo * )lfirst (l );
193+ Selectivity * cur_sel = NULL ;
194194
195- cur_sel = NULL ;
196195if (parametrized_sel )
197196{
198197cur_hash = get_clause_hash (rinfo -> clause ,nargs ,
199198args_hash ,eclass_hash );
200199cur_sel = selectivity_cache_find_global_relid (cur_hash ,cur_relid );
201- if (cur_sel == NULL )
202- {
203- if (join_type == JOIN_INNER )
204- cur_sel = & rinfo -> norm_selec ;
205- else
206- cur_sel = & rinfo -> outer_selec ;
207- }
208200}
209- else if (join_type == JOIN_INNER )
210- cur_sel = & rinfo -> norm_selec ;
211- else
212- cur_sel = & rinfo -> outer_selec ;
213201
214- if (* cur_sel < 0 )
215- * cur_sel = 0 ;
202+ if (cur_sel == NULL )
203+ {
204+ cur_sel = palloc (sizeof (double ));
205+
206+ if (join_type == JOIN_INNER )
207+ * cur_sel = rinfo -> norm_selec ;
208+ else
209+ * cur_sel = rinfo -> outer_selec ;
210+
211+ if (* cur_sel < 0 )
212+ * cur_sel = 0 ;
213+ }
216214
217- Assert (cur_sel > 0 );
215+ Assert (* cur_sel >= 0 );
218216
219217lst = lappend (lst ,cur_sel );
220218}