1010 *
1111 *
1212 * IDENTIFICATION
13- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.143 2003/05/2816:03:56 tgl Exp $
13+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.144 2003/05/2823:06:16 tgl Exp $
1414 *
1515 *-------------------------------------------------------------------------
1616 */
@@ -681,7 +681,7 @@ create_indexscan_plan(Query *root,
681681Expr * indxqual_or_expr = NULL ;
682682List * fixed_indxqual ;
683683List * recheck_indxqual ;
684- List * indexids ;
684+ FastList indexids ;
685685List * ixinfo ;
686686IndexScan * scan_plan ;
687687
@@ -692,12 +692,12 @@ create_indexscan_plan(Query *root,
692692/*
693693 * Build list of index OIDs.
694694 */
695- indexids = NIL ;
695+ FastListInit ( & indexids ) ;
696696foreach (ixinfo ,best_path -> indexinfo )
697697{
698698IndexOptInfo * index = (IndexOptInfo * )lfirst (ixinfo );
699699
700- indexids = lappendo ( indexids ,index -> indexoid );
700+ FastAppendo ( & indexids ,index -> indexoid );
701701}
702702
703703/*
@@ -719,15 +719,15 @@ create_indexscan_plan(Query *root,
719719 * the implicit OR and AND semantics of the first- and
720720 * second-level lists.
721721 */
722- List * orclauses = NIL ;
722+ FastList orclauses ;
723723List * orclause ;
724724
725+ FastListInit (& orclauses );
725726foreach (orclause ,indxqual )
726727{
727- orclauses = lappend (orclauses ,
728- make_ands_explicit (lfirst (orclause )));
728+ FastAppend (& orclauses ,make_ands_explicit (lfirst (orclause )));
729729}
730- indxqual_or_expr = make_orclause (orclauses );
730+ indxqual_or_expr = make_orclause (FastListValue ( & orclauses ) );
731731
732732qpqual = set_difference (scan_clauses ,makeList1 (indxqual_or_expr ));
733733}
@@ -778,7 +778,7 @@ create_indexscan_plan(Query *root,
778778scan_plan = make_indexscan (tlist ,
779779qpqual ,
780780baserelid ,
781- indexids ,
781+ FastListValue ( & indexids ) ,
782782fixed_indxqual ,
783783indxqual ,
784784best_path -> indexscandir );
@@ -1091,13 +1091,15 @@ static void
10911091fix_indxqual_references (List * indexquals ,IndexPath * index_path ,
10921092List * * fixed_indexquals ,List * * recheck_indexquals )
10931093{
1094- List * fixed_quals = NIL ;
1095- List * recheck_quals = NIL ;
1094+ FastList fixed_quals ;
1095+ FastList recheck_quals ;
10961096Relids baserelids = index_path -> path .parent -> relids ;
10971097int baserelid = index_path -> path .parent -> relid ;
10981098List * ixinfo = index_path -> indexinfo ;
10991099List * i ;
11001100
1101+ FastListInit (& fixed_quals );
1102+ FastListInit (& recheck_quals );
11011103foreach (i ,indexquals )
11021104{
11031105List * indexqual = lfirst (i );
@@ -1107,15 +1109,15 @@ fix_indxqual_references(List *indexquals, IndexPath *index_path,
11071109
11081110fix_indxqual_sublist (indexqual ,baserelids ,baserelid ,index ,
11091111& fixed_qual ,& recheck_qual );
1110- fixed_quals = lappend ( fixed_quals ,fixed_qual );
1112+ FastAppend ( & fixed_quals ,fixed_qual );
11111113if (recheck_qual != NIL )
1112- recheck_quals = lappend ( recheck_quals ,recheck_qual );
1114+ FastAppend ( & recheck_quals ,recheck_qual );
11131115
11141116ixinfo = lnext (ixinfo );
11151117}
11161118
1117- * fixed_indexquals = fixed_quals ;
1118- * recheck_indexquals = recheck_quals ;
1119+ * fixed_indexquals = FastListValue ( & fixed_quals ) ;
1120+ * recheck_indexquals = FastListValue ( & recheck_quals ) ;
11191121}
11201122
11211123/*
@@ -1136,10 +1138,12 @@ fix_indxqual_sublist(List *indexqual,
11361138IndexOptInfo * index ,
11371139List * * fixed_quals ,List * * recheck_quals )
11381140{
1139- List * fixed_qual = NIL ;
1140- List * recheck_qual = NIL ;
1141+ FastList fixed_qual ;
1142+ FastList recheck_qual ;
11411143List * i ;
11421144
1145+ FastListInit (& fixed_qual );
1146+ FastListInit (& recheck_qual );
11431147foreach (i ,indexqual )
11441148{
11451149OpExpr * clause = (OpExpr * )lfirst (i );
@@ -1178,19 +1182,18 @@ fix_indxqual_sublist(List *indexqual,
11781182index ,
11791183& opclass );
11801184
1181- fixed_qual = lappend ( fixed_qual ,newclause );
1185+ FastAppend ( & fixed_qual ,newclause );
11821186
11831187/*
11841188 * Finally, check to see if index is lossy for this operator. If
11851189 * so, add (a copy of) original form of clause to recheck list.
11861190 */
11871191if (op_requires_recheck (newclause -> opno ,opclass ))
1188- recheck_qual = lappend (recheck_qual ,
1189- copyObject ((Node * )clause ));
1192+ FastAppend (& recheck_qual ,copyObject ((Node * )clause ));
11901193}
11911194
1192- * fixed_quals = fixed_qual ;
1193- * recheck_quals = recheck_qual ;
1195+ * fixed_quals = FastListValue ( & fixed_qual ) ;
1196+ * recheck_quals = FastListValue ( & recheck_qual ) ;
11941197}
11951198
11961199static Node *
@@ -1327,26 +1330,28 @@ get_switched_clauses(List *clauses, Relids outerrelids)
13271330static List *
13281331order_qual_clauses (Query * root ,List * clauses )
13291332{
1330- List * nosubplans ;
1331- List * withsubplans ;
1333+ FastList nosubplans ;
1334+ FastList withsubplans ;
13321335List * l ;
13331336
13341337/* No need to work hard if the query is subselect-free */
13351338if (!root -> hasSubLinks )
13361339return clauses ;
13371340
1338- nosubplans = withsubplans = NIL ;
1341+ FastListInit (& nosubplans );
1342+ FastListInit (& withsubplans );
13391343foreach (l ,clauses )
13401344{
13411345Node * clause = lfirst (l );
13421346
13431347if (contain_subplans (clause ))
1344- withsubplans = lappend ( withsubplans ,clause );
1348+ FastAppend ( & withsubplans ,clause );
13451349else
1346- nosubplans = lappend ( nosubplans ,clause );
1350+ FastAppend ( & nosubplans ,clause );
13471351}
13481352
1349- return nconc (nosubplans ,withsubplans );
1353+ FastConcFast (& nosubplans ,& withsubplans );
1354+ return FastListValue (& nosubplans );
13501355}
13511356
13521357/*