@@ -178,7 +178,6 @@ restore_selectivities(List *clauselist, List *relidslist, JoinType join_type,
178
178
int nargs ;
179
179
int * args_hash ;
180
180
int * eclass_hash ;
181
- double * cur_sel ;
182
181
int cur_hash ;
183
182
int cur_relid ;
184
183
@@ -193,30 +192,29 @@ restore_selectivities(List *clauselist, List *relidslist, JoinType join_type,
193
192
foreach (l ,clauselist )
194
193
{
195
194
RestrictInfo * rinfo = (RestrictInfo * )lfirst (l );
195
+ Selectivity * cur_sel = NULL ;
196
196
197
- cur_sel = NULL ;
198
197
if (parametrized_sel )
199
198
{
200
199
cur_hash = get_clause_hash (rinfo -> clause ,nargs ,
201
200
args_hash ,eclass_hash );
202
201
cur_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
- }
210
202
}
211
- else if (join_type == JOIN_INNER )
212
- cur_sel = & rinfo -> norm_selec ;
213
- else
214
- cur_sel = & rinfo -> outer_selec ;
215
203
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
+ }
218
216
219
- Assert (cur_sel > 0 );
217
+ Assert (* cur_sel >= 0 );
220
218
221
219
lst = lappend (lst ,cur_sel );
222
220
}