99 *
1010 *
1111 * IDENTIFICATION
12- * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.160 2004/05/30 23:40:28 neilc Exp $
12+ * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.161 2004/06/01 04:47:45 tgl Exp $
1313 *
1414 *-------------------------------------------------------------------------
1515 */
@@ -237,22 +237,20 @@ create_index_paths(Query *root, RelOptInfo *rel)
237237static List *
238238group_clauses_by_indexkey (RelOptInfo * rel , IndexOptInfo * index )
239239{
240- FastList clausegroup_list ;
240+ List * clausegroup_list = NIL ;
241241 List * restrictinfo_list = rel -> baserestrictinfo ;
242242 int indexcol = 0 ;
243243 Oid * classes = index -> classlist ;
244244
245245 if (restrictinfo_list == NIL )
246246 return NIL ;
247247
248- FastListInit (& clausegroup_list );
249248 do
250249 {
251250 Oid curClass = classes [0 ];
252- FastList clausegroup ;
251+ List * clausegroup = NIL ;
253252 ListCell * l ;
254253
255- FastListInit (& clausegroup );
256254 foreach (l , restrictinfo_list )
257255 {
258256 RestrictInfo * rinfo = (RestrictInfo * ) lfirst (l );
@@ -262,24 +260,24 @@ group_clauses_by_indexkey(RelOptInfo *rel, IndexOptInfo *index)
262260 indexcol ,
263261 curClass ,
264262 rinfo ))
265- FastAppend ( & clausegroup , rinfo );
263+ clausegroup = lappend ( clausegroup , rinfo );
266264 }
267265
268266 /*
269267 * If no clauses match this key, we're done; we don't want to look
270268 * at keys to its right.
271269 */
272- if (FastListValue ( & clausegroup ) == NIL )
270+ if (clausegroup == NIL )
273271 break ;
274272
275- FastAppend ( & clausegroup_list , FastListValue ( & clausegroup ) );
273+ clausegroup_list = lappend ( clausegroup_list , clausegroup );
276274
277275 indexcol ++ ;
278276 classes ++ ;
279277
280278 } while (!DoneMatchingIndexKeys (classes ));
281279
282- return FastListValue ( & clausegroup_list ) ;
280+ return clausegroup_list ;
283281}
284282
285283/*
@@ -301,21 +299,18 @@ group_clauses_by_indexkey_for_join(Query *root,
301299 Relids outer_relids ,
302300 JoinType jointype , bool isouterjoin )
303301{
304- FastList clausegroup_list ;
302+ List * clausegroup_list = NIL ;
305303 bool jfound = false;
306304 int indexcol = 0 ;
307305 Oid * classes = index -> classlist ;
308306
309- FastListInit (& clausegroup_list );
310307 do
311308 {
312309 Oid curClass = classes [0 ];
313- FastList clausegroup ;
310+ List * clausegroup = NIL ;
314311 int numsources ;
315312 ListCell * l ;
316313
317- FastListInit (& clausegroup );
318-
319314 /*
320315 * We can always use plain restriction clauses for the rel. We scan
321316 * these first because we want them first in the clausegroup list
@@ -337,11 +332,11 @@ group_clauses_by_indexkey_for_join(Query *root,
337332 indexcol ,
338333 curClass ,
339334 rinfo ))
340- FastAppend ( & clausegroup , rinfo );
335+ clausegroup = lappend ( clausegroup , rinfo );
341336 }
342337
343338 /* found anything in base restrict list? */
344- numsources = (FastListValue ( & clausegroup ) != NIL ) ? 1 : 0 ;
339+ numsources = (clausegroup != NIL ) ? 1 : 0 ;
345340
346341 /* Look for joinclauses that are usable with given outer_relids */
347342 foreach (l , rel -> joininfo )
@@ -367,7 +362,7 @@ group_clauses_by_indexkey_for_join(Query *root,
367362 curClass ,
368363 rinfo ))
369364 {
370- FastAppend ( & clausegroup , rinfo );
365+ clausegroup = lappend ( clausegroup , rinfo );
371366 if (!jfoundhere )
372367 {
373368 jfoundhere = true;
@@ -384,22 +379,19 @@ group_clauses_by_indexkey_for_join(Query *root,
384379 */
385380 if (numsources > 1 )
386381 {
387- List * nl ;
388-
389- nl = remove_redundant_join_clauses (root ,
390- FastListValue (& clausegroup ),
391- jointype );
392- FastListFromList (& clausegroup , nl );
382+ clausegroup = remove_redundant_join_clauses (root ,
383+ clausegroup ,
384+ jointype );
393385 }
394386
395387 /*
396388 * If no clauses match this key, we're done; we don't want to look
397389 * at keys to its right.
398390 */
399- if (FastListValue ( & clausegroup ) == NIL )
391+ if (clausegroup == NIL )
400392 break ;
401393
402- FastAppend ( & clausegroup_list , FastListValue ( & clausegroup ) );
394+ clausegroup_list = lappend ( clausegroup_list , clausegroup );
403395
404396 indexcol ++ ;
405397 classes ++ ;
@@ -410,7 +402,7 @@ group_clauses_by_indexkey_for_join(Query *root,
410402 if (!jfound )
411403 return NIL ;
412404
413- return FastListValue ( & clausegroup_list ) ;
405+ return clausegroup_list ;
414406}
415407
416408
@@ -438,28 +430,25 @@ group_clauses_by_indexkey_for_or(RelOptInfo *rel,
438430 IndexOptInfo * index ,
439431 Expr * orsubclause )
440432{
441- FastList clausegroup_list ;
433+ List * clausegroup_list = NIL ;
442434 bool matched = false;
443435 int indexcol = 0 ;
444436 Oid * classes = index -> classlist ;
445437
446- FastListInit (& clausegroup_list );
447438 do
448439 {
449440 Oid curClass = classes [0 ];
450- FastList clausegroup ;
441+ List * clausegroup = NIL ;
451442 ListCell * item ;
452443
453- FastListInit (& clausegroup );
454-
455444 /* Try to match the OR subclause to the index key */
456445 if (IsA (orsubclause , RestrictInfo ))
457446 {
458447 if (match_clause_to_indexcol (rel , index ,
459448 indexcol , curClass ,
460449 (RestrictInfo * ) orsubclause ))
461450 {
462- FastAppend ( & clausegroup , orsubclause );
451+ clausegroup = lappend ( clausegroup , orsubclause );
463452 matched = true;
464453 }
465454 }
@@ -474,7 +463,7 @@ group_clauses_by_indexkey_for_or(RelOptInfo *rel,
474463 indexcol , curClass ,
475464 subsubclause ))
476465 {
477- FastAppend ( & clausegroup , subsubclause );
466+ clausegroup = lappend ( clausegroup , subsubclause );
478467 matched = true;
479468 }
480469 }
@@ -487,7 +476,7 @@ group_clauses_by_indexkey_for_or(RelOptInfo *rel,
487476 * XXX should we always search the top-level list? Slower but
488477 * could sometimes yield a better plan.
489478 */
490- if (FastListValue ( & clausegroup ) == NIL )
479+ if (clausegroup == NIL )
491480 {
492481 foreach (item , rel -> baserestrictinfo )
493482 {
@@ -496,18 +485,18 @@ group_clauses_by_indexkey_for_or(RelOptInfo *rel,
496485 if (match_clause_to_indexcol (rel , index ,
497486 indexcol , curClass ,
498487 rinfo ))
499- FastAppend ( & clausegroup , rinfo );
488+ clausegroup = lappend ( clausegroup , rinfo );
500489 }
501490 }
502491
503492 /*
504493 * If still no clauses match this key, we're done; we don't want
505494 * to look at keys to its right.
506495 */
507- if (FastListValue ( & clausegroup ) == NIL )
496+ if (clausegroup == NIL )
508497 break ;
509498
510- FastAppend ( & clausegroup_list , FastListValue ( & clausegroup ) );
499+ clausegroup_list = lappend ( clausegroup_list , clausegroup );
511500
512501 indexcol ++ ;
513502 classes ++ ;
@@ -517,7 +506,7 @@ group_clauses_by_indexkey_for_or(RelOptInfo *rel,
517506 if (!matched )
518507 return NIL ;
519508
520- return FastListValue ( & clausegroup_list ) ;
509+ return clausegroup_list ;
521510}
522511
523512
@@ -2011,14 +2000,13 @@ match_special_index_operator(Expr *clause, Oid opclass,
20112000List *
20122001expand_indexqual_conditions (IndexOptInfo * index , List * clausegroups )
20132002{
2014- FastList resultquals ;
2003+ List * resultquals = NIL ;
20152004 ListCell * clausegroup_item ;
20162005 Oid * classes = index -> classlist ;
20172006
20182007 if (clausegroups == NIL )
20192008 return NIL ;
20202009
2021- FastListInit (& resultquals );
20222010 clausegroup_item = list_head (clausegroups );
20232011 do
20242012 {
@@ -2029,17 +2017,18 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups)
20292017 {
20302018 RestrictInfo * rinfo = (RestrictInfo * ) lfirst (l );
20312019
2032- FastConc (& resultquals ,
2033- expand_indexqual_condition (rinfo , curClass ));
2020+ resultquals = list_concat (resultquals ,
2021+ expand_indexqual_condition (rinfo ,
2022+ curClass ));
20342023 }
20352024
20362025 clausegroup_item = lnext (clausegroup_item );
20372026 classes ++ ;
20382027 } while (clausegroup_item != NULL && !DoneMatchingIndexKeys (classes ));
20392028
2040- Assert (clausegroup_item == NULL ); /* else more groups than indexkeys... */
2029+ Assert (clausegroup_item == NULL ); /* else more groups than indexkeys */
20412030
2042- return FastListValue ( & resultquals ) ;
2031+ return resultquals ;
20432032}
20442033
20452034/*
0 commit comments