@@ -178,7 +178,6 @@ restore_selectivities(List *clauselist, List *relidslist, JoinType join_type,
178178int nargs ;
179179int * args_hash ;
180180int * eclass_hash ;
181- double * cur_sel ;
182181int cur_hash ;
183182int cur_relid ;
184183
@@ -193,30 +192,29 @@ restore_selectivities(List *clauselist, List *relidslist, JoinType join_type,
193192foreach (l ,clauselist )
194193{
195194RestrictInfo * rinfo = (RestrictInfo * )lfirst (l );
195+ Selectivity * cur_sel = NULL ;
196196
197- cur_sel = NULL ;
198197if (parametrized_sel )
199198{
200199cur_hash = get_clause_hash (rinfo -> clause ,nargs ,
201200args_hash ,eclass_hash );
202201cur_sel = selectivity_cache_find_global_relid (cur_hash ,cur_relid );
203- if (cur_sel == NULL )
204- {
205- if (join_type == JOIN_INNER )
206- cur_sel = & rinfo -> norm_selec ;
207- else
208- cur_sel = & rinfo -> outer_selec ;
209- }
210202}
211- else if (join_type == JOIN_INNER )
212- cur_sel = & rinfo -> norm_selec ;
213- else
214- cur_sel = & rinfo -> outer_selec ;
215203
216- if (* cur_sel < 0 )
217- * cur_sel = 0 ;
204+ if (cur_sel == NULL )
205+ {
206+ cur_sel = palloc (sizeof (double ));
207+
208+ if (join_type == JOIN_INNER )
209+ * cur_sel = rinfo -> norm_selec ;
210+ else
211+ * cur_sel = rinfo -> outer_selec ;
212+
213+ if (* cur_sel < 0 )
214+ * cur_sel = 0 ;
215+ }
218216
219- Assert (cur_sel > 0 );
217+ Assert (* cur_sel >= 0 );
220218
221219lst = lappend (lst ,cur_sel );
222220}