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